linux-stable/security/apparmor
Paul Moore ea6e87db90 lsm: make security_socket_getpeersec_stream() sockptr_t safe
[ Upstream commit b10b9c342f ]

Commit 4ff09db1b7 ("bpf: net: Change sk_getsockopt() to take the
sockptr_t argument") made it possible to call sk_getsockopt()
with both user and kernel address space buffers through the use of
the sockptr_t type.  Unfortunately at the time of conversion the
security_socket_getpeersec_stream() LSM hook was written to only
accept userspace buffers, and in a desire to avoid having to change
the LSM hook the commit author simply passed the sockptr_t's
userspace buffer pointer.  Since the only sk_getsockopt() callers
at the time of conversion which used kernel sockptr_t buffers did
not allow SO_PEERSEC, and hence the
security_socket_getpeersec_stream() hook, this was acceptable but
also very fragile as future changes presented the possibility of
silently passing kernel space pointers to the LSM hook.

There are several ways to protect against this, including careful
code review of future commits, but since relying on code review to
catch bugs is a recipe for disaster and the upstream eBPF maintainer
is "strongly against defensive programming", this patch updates the
LSM hook, and all of the implementations to support sockptr_t and
safely handle both user and kernel space buffers.

Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Stable-dep-of: 5a287d3d2b ("lsm: fix default return value of the socket_getpeersec_*() hooks")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-15 10:48:20 -04:00
..
include apparmor: fix overlapping attachment computation 2022-08-25 11:37:53 +02:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Kconfig Minor fixes for v5.9. 2020-08-11 14:30:36 -07:00
Makefile
apparmorfs.c apparmor: fix a memleak in multi_transaction_new() 2023-01-14 10:15:46 +01:00
audit.c apparmor: fix quiet_denied for file rules 2022-08-25 11:37:51 +02:00
capability.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
crypto.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
domain.c apparmor: fix overlapping attachment computation 2022-08-25 11:37:53 +02:00
file.c audit: purge audit_log_string from the intra-kernel audit API 2020-07-21 11:12:31 -04:00
ipc.c audit: purge audit_log_string from the intra-kernel audit API 2020-07-21 11:12:31 -04:00
label.c apparmor: fix aa_label_asxprint return check 2022-08-25 11:37:52 +02:00
lib.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
lsm.c lsm: make security_socket_getpeersec_stream() sockptr_t safe 2024-03-15 10:48:20 -04:00
match.c apparmor: ensure that dfa state tables have entries 2020-04-08 04:42:48 -07:00
mount.c apparmor: fix reference count leak in aa_pivotroot() 2022-08-25 11:37:53 +02:00
net.c audit: purge audit_log_string from the intra-kernel audit API 2020-07-21 11:12:31 -04:00
nulldfa.in
path.c AppArmor: Remove semicolon 2020-01-18 15:36:58 -08:00
policy.c apparmor: fix lockdep warning when removing a namespace 2023-01-14 10:15:46 +01:00
policy_ns.c apparmor: Fix memleak in alloc_ns() 2023-01-14 10:15:48 +01:00
policy_unpack.c apparmor: avoid crash when parsed profile name is empty 2024-01-25 14:37:55 -08:00
policy_unpack_test.c apparmor: add AppArmor KUnit tests for policy unpack 2020-01-09 16:27:43 -07:00
procattr.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
resource.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
secid.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
stacksplitdfa.in
task.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00