summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorOndrej Mosnacek <omosnace@redhat.com>2024-01-26 19:45:31 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-02-23 09:25:02 +0100
commit8df43e53f2f7f059e4131aad04e18af1c375ea91 (patch)
tree750a80011545d2770384ac697be9bd248ec894ea /include
parent38fd4dfa2764280e48c862e89623def321d0328d (diff)
downloadlinux-stable-8df43e53f2f7f059e4131aad04e18af1c375ea91.tar.gz
linux-stable-8df43e53f2f7f059e4131aad04e18af1c375ea91.tar.bz2
linux-stable-8df43e53f2f7f059e4131aad04e18af1c375ea91.zip
lsm: fix default return value of the socket_getpeersec_*() hooks
commit 5a287d3d2b9de2b3e747132c615599907ba5c3c1 upstream. For these hooks the true "neutral" value is -EOPNOTSUPP, which is currently what is returned when no LSM provides this hook and what LSMs return when there is no security context set on the socket. Correct the value in <linux/lsm_hooks.h> and adjust the dispatch functions in security/security.c to avoid issues when the BPF LSM is enabled. Cc: stable@vger.kernel.org Fixes: 98e828a0650f ("security: Refactor declaration of LSM hooks") Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> [PM: subject line tweak] Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/lsm_hook_defs.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index 74c60f9446f8..489362b0cd85 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -311,9 +311,9 @@ LSM_HOOK(int, 0, socket_getsockopt, struct socket *sock, int level, int optname)
LSM_HOOK(int, 0, socket_setsockopt, struct socket *sock, int level, int optname)
LSM_HOOK(int, 0, socket_shutdown, struct socket *sock, int how)
LSM_HOOK(int, 0, socket_sock_rcv_skb, struct sock *sk, struct sk_buff *skb)
-LSM_HOOK(int, 0, socket_getpeersec_stream, struct socket *sock,
+LSM_HOOK(int, -ENOPROTOOPT, socket_getpeersec_stream, struct socket *sock,
sockptr_t optval, sockptr_t optlen, unsigned int len)
-LSM_HOOK(int, 0, socket_getpeersec_dgram, struct socket *sock,
+LSM_HOOK(int, -ENOPROTOOPT, socket_getpeersec_dgram, struct socket *sock,
struct sk_buff *skb, u32 *secid)
LSM_HOOK(int, 0, sk_alloc_security, struct sock *sk, int family, gfp_t priority)
LSM_HOOK(void, LSM_RET_VOID, sk_free_security, struct sock *sk)