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)
committerPaul Moore <paul@paul-moore.com>
Tue, 30 Jan 2024 22:01:54 +0000 (17:01 -0500)
commit5a287d3d2b9de2b3e747132c615599907ba5c3c1
tree9678de7e208789e322d4799e85dbd1a5c64d0d2b
parent99b817c173cd213671daecd25ca27f56b0c7c4ec
lsm: fix default return value of the socket_getpeersec_*() hooks

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>
include/linux/lsm_hook_defs.h
security/security.c