Skip to content

Commit

Permalink
selinux: Fix a panic in selinux_netlbl_inode_permission()
Browse files Browse the repository at this point in the history
Rick McNeal from LSI identified a panic in selinux_netlbl_inode_permission()
caused by a certain sequence of SUNRPC operations.  The problem appears to be
due to the lack of NULL pointer checking in the function; this patch adds the
pointer checks so the function will exit safely in the cases where the socket
is not completely initialized.

Signed-off-by: Paul Moore <paul.moore@hp.com>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
Paul Moore authored and James Morris committed Mar 1, 2009
1 parent 778ef1e commit d7f59dc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions security/selinux/netlabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,12 @@ int selinux_netlbl_inode_permission(struct inode *inode, int mask)
if (!S_ISSOCK(inode->i_mode) ||
((mask & (MAY_WRITE | MAY_APPEND)) == 0))
return 0;

sock = SOCKET_I(inode);
sk = sock->sk;
if (sk == NULL)
return 0;
sksec = sk->sk_security;
if (sksec->nlbl_state != NLBL_REQUIRE)
if (sksec == NULL || sksec->nlbl_state != NLBL_REQUIRE)
return 0;

local_bh_disable();
Expand Down

0 comments on commit d7f59dc

Please sign in to comment.