Skip to content

Commit

Permalink
selinux: Fix the NetLabel glue code for setsockopt()
Browse files Browse the repository at this point in the history
At some point we (okay, I) managed to break the ability for users to use the
setsockopt() syscall to set IPv4 options when NetLabel was not active on the
socket in question.  The problem was noticed by someone trying to use the
"-R" (record route) option of ping:

 # ping -R 10.0.0.1
 ping: record route: No message of desired type

The solution is relatively simple, we catch the unlabeled socket case and
clear the error code, allowing the operation to succeed.  Please note that we
still deny users the ability to override IPv4 options on socket's which have
NetLabel labeling active; this is done to ensure the labeling remains intact.

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 Feb 22, 2009
1 parent 586c250 commit 09c50b4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion security/selinux/netlabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,10 @@ int selinux_netlbl_socket_setsockopt(struct socket *sock,
lock_sock(sk);
rc = netlbl_sock_getattr(sk, &secattr);
release_sock(sk);
if (rc == 0 && secattr.flags != NETLBL_SECATTR_NONE)
if (rc == 0)
rc = -EACCES;
else if (rc == -ENOMSG)
rc = 0;
netlbl_secattr_destroy(&secattr);
}

Expand Down

0 comments on commit 09c50b4

Please sign in to comment.