Skip to content

Commit 844f7ea

Browse files
esyr-rhklassert
authored andcommitted
include/uapi/linux/xfrm.h: Fix XFRM_MSG_MAPPING ABI breakage
Commit 2d151d3 ("xfrm: Add possibility to set the default to block if we have no policy") broke ABI by changing the value of the XFRM_MSG_MAPPING enum item, thus also evading the build-time check in security/selinux/nlmsgtab.c:selinux_nlmsg_lookup for presence of proper security permission checks in nlmsg_xfrm_perms. Fix it by placing XFRM_MSG_SETDEFAULT/XFRM_MSG_GETDEFAULT to the end of the enum, right before __XFRM_MSG_MAX, and updating the nlmsg_xfrm_perms accordingly. Fixes: 2d151d3 ("xfrm: Add possibility to set the default to block if we have no policy") References: https://lore.kernel.org/netdev/[email protected]/ Signed-off-by: Eugene Syromiatnikov <[email protected]> Acked-by: Antony Antony <[email protected]> Acked-by: Nicolas Dichtel <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 3c10ffd commit 844f7ea

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

include/uapi/linux/xfrm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ enum {
213213
XFRM_MSG_GETSPDINFO,
214214
#define XFRM_MSG_GETSPDINFO XFRM_MSG_GETSPDINFO
215215

216+
XFRM_MSG_MAPPING,
217+
#define XFRM_MSG_MAPPING XFRM_MSG_MAPPING
218+
216219
XFRM_MSG_SETDEFAULT,
217220
#define XFRM_MSG_SETDEFAULT XFRM_MSG_SETDEFAULT
218221
XFRM_MSG_GETDEFAULT,
219222
#define XFRM_MSG_GETDEFAULT XFRM_MSG_GETDEFAULT
220-
221-
XFRM_MSG_MAPPING,
222-
#define XFRM_MSG_MAPPING XFRM_MSG_MAPPING
223223
__XFRM_MSG_MAX
224224
};
225225
#define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)

security/selinux/nlmsgtab.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ static const struct nlmsg_perm nlmsg_xfrm_perms[] =
126126
{ XFRM_MSG_NEWSPDINFO, NETLINK_XFRM_SOCKET__NLMSG_WRITE },
127127
{ XFRM_MSG_GETSPDINFO, NETLINK_XFRM_SOCKET__NLMSG_READ },
128128
{ XFRM_MSG_MAPPING, NETLINK_XFRM_SOCKET__NLMSG_READ },
129+
{ XFRM_MSG_SETDEFAULT, NETLINK_XFRM_SOCKET__NLMSG_WRITE },
130+
{ XFRM_MSG_GETDEFAULT, NETLINK_XFRM_SOCKET__NLMSG_READ },
129131
};
130132

131133
static const struct nlmsg_perm nlmsg_audit_perms[] =
@@ -189,7 +191,7 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)
189191
* structures at the top of this file with the new mappings
190192
* before updating the BUILD_BUG_ON() macro!
191193
*/
192-
BUILD_BUG_ON(XFRM_MSG_MAX != XFRM_MSG_MAPPING);
194+
BUILD_BUG_ON(XFRM_MSG_MAX != XFRM_MSG_GETDEFAULT);
193195
err = nlmsg_perm(nlmsg_type, perm, nlmsg_xfrm_perms,
194196
sizeof(nlmsg_xfrm_perms));
195197
break;

0 commit comments

Comments
 (0)