selinux: Fix the NetLabel glue code for setsockopt()
authorPaul Moore <paul.moore@hp.com>
Fri, 20 Feb 2009 21:33:02 +0000 (16:33 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 17 Mar 2009 00:52:57 +0000 (17:52 -0700)
commit068c8059e492c269ae6291286e6d942cae652cb6
tree46c25cf6deb44f0bbcfe48515dd9a9ad311eb587
parent480f51ace44e212fb825903c57d1535a9b01c1f5
selinux: Fix the NetLabel glue code for setsockopt()

commit 09c50b4a52c01a1f450b8eec819089e228655bfb upstream.

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>
Cc: Chuck Ebbert <cebbert@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
security/selinux/netlabel.c