]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
lsm: fix default return value of the socket_getpeersec_*() hooks
authorOndrej Mosnacek <omosnace@redhat.com>
Fri, 26 Jan 2024 18:45:31 +0000 (19:45 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Feb 2024 08:25:02 +0000 (09:25 +0100)
commit8df43e53f2f7f059e4131aad04e18af1c375ea91
tree750a80011545d2770384ac697be9bd248ec894ea
parent38fd4dfa2764280e48c862e89623def321d0328d
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>
include/linux/lsm_hook_defs.h
security/security.c