selinux: correct return values in selinux_socket_getpeersec_dgram()
authorPaul Moore <paul@paul-moore.com>
Tue, 30 Jan 2024 21:16:29 +0000 (16:16 -0500)
committerPaul Moore <paul@paul-moore.com>
Fri, 2 Feb 2024 18:46:39 +0000 (13:46 -0500)
commitbfda63fa2243f66e3d07cce2f38cf12d68a2ddf0
treecdc06c670d60facc8c96e6a841e90774b0e7a934
parent90593caf7db74da2300f7a7056a26ae000b3e7cd
selinux: correct return values in selinux_socket_getpeersec_dgram()

Instead of returning -EINVAL if any type of error occurs, limit
-EINVAL to only those errors caused by passing a bad/invalid socket
or packet/skb.  In other cases where everything is correct but there
isn't a valid peer label we return -ENOPROTOOPT.

This helps make selinux_socket_getpeersec_dgram() more consistent
with selinux_socket_getpeersec_stream().

Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/hooks.c