Skip to content

Commit cf89013

Browse files
NicolasDichteldavem330
authored andcommitted
selinux/nlmsg: add a build time check for rtnl/xfrm cmds
When a new rtnl or xfrm command is added, this part of the code is frequently missing. Let's help the developer with a build time test. Signed-off-by: Nicolas Dichtel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e60a9de commit cf89013

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

security/selinux/nlmsgtab.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)
153153

154154
switch (sclass) {
155155
case SECCLASS_NETLINK_ROUTE_SOCKET:
156+
/* RTM_MAX always point to RTM_SETxxxx, ie RTM_NEWxxx + 3 */
157+
BUILD_BUG_ON(RTM_MAX != (RTM_NEWNSID + 3));
156158
err = nlmsg_perm(nlmsg_type, perm, nlmsg_route_perms,
157159
sizeof(nlmsg_route_perms));
158160
break;
@@ -163,6 +165,7 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)
163165
break;
164166

165167
case SECCLASS_NETLINK_XFRM_SOCKET:
168+
BUILD_BUG_ON(XFRM_MSG_MAX != XFRM_MSG_MAPPING);
166169
err = nlmsg_perm(nlmsg_type, perm, nlmsg_xfrm_perms,
167170
sizeof(nlmsg_xfrm_perms));
168171
break;

0 commit comments

Comments
 (0)