]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
apparmor: fix race in unix socket mediation when peer_path is used
authorJohn Johansen <john.johansen@canonical.com>
Fri, 24 Oct 2025 19:25:38 +0000 (12:25 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Sun, 14 Jun 2026 03:14:06 +0000 (20:14 -0700)
commitb1aea2c1960771a276d7e68c7424168eccd0c3da
tree2f52297456c15c0863dc7556f45d830d7327be52
parent4483efe4f21510b30c24bc97d9fd0e8feab94125
apparmor: fix race in unix socket mediation when peer_path is used

The holding a reference to the peer_sk is not enough to ensure access
to the peer sk path. Accessing the path outside of the state lock
allows for a race with unix_release_sock(). Fix this by taking the
state lock and getting a reference to the path under lock.

Ideally for connected sockets we would cache this information so we
don't have to take the lock here. But for now just fix the race.

Fixes: bc6e5f6933b8e ("apparmor: Remove use of the double lock")
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/af_unix.c