Skip to content

Commit

Permalink
selinux/nlmsg: add a build time check for rtnl/xfrm cmds
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
NicolasDichtel authored and davem330 committed Apr 13, 2015
1 parent e60a9de commit cf89013
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions security/selinux/nlmsgtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)

switch (sclass) {
case SECCLASS_NETLINK_ROUTE_SOCKET:
/* RTM_MAX always point to RTM_SETxxxx, ie RTM_NEWxxx + 3 */
BUILD_BUG_ON(RTM_MAX != (RTM_NEWNSID + 3));
err = nlmsg_perm(nlmsg_type, perm, nlmsg_route_perms,
sizeof(nlmsg_route_perms));
break;
Expand All @@ -163,6 +165,7 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)
break;

case SECCLASS_NETLINK_XFRM_SOCKET:
BUILD_BUG_ON(XFRM_MSG_MAX != XFRM_MSG_MAPPING);
err = nlmsg_perm(nlmsg_type, perm, nlmsg_xfrm_perms,
sizeof(nlmsg_xfrm_perms));
break;
Expand Down

0 comments on commit cf89013

Please sign in to comment.