linux/security/apparmor
Bryam Vargas 20383429b5 apparmor: mediate the implicit connect of TCP fast open sendmsg
[ Upstream commit 4d587cd8a7 ]

sendmsg()/sendto() with MSG_FASTOPEN is a combination of connect(2) and
write(2): it opens the connection in the SYN. apparmor_socket_sendmsg()
only checks AA_MAY_SEND, so a profile that grants send but denies connect
lets a confined task open an outbound TCP/MPTCP connection that connect(2)
would have refused, bypassing connect mediation.

Mediate the implicit connect when MSG_FASTOPEN is set and a destination
is supplied. Add it to apparmor_socket_sendmsg() (not the shared
aa_sock_msg_perm() helper, which recvmsg also uses) and call aa_sk_perm()
directly, mirroring the selinux and tomoyo fixes. sk_is_tcp() does not
cover MPTCP fast open, so the SOCK_STREAM/IPPROTO_MPTCP arm is explicit.

Fixes: cf60af03ca ("net-tcp: Fast Open client - sendmsg(MSG_FASTOPEN)")
Cc: stable@vger.kernel.org
Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
Signed-off-by: John Johansen <john.johansen@canonical.com>
[ expanded sk_is_tcp() (absent in 5.15) into its equivalent sk_is_inet() && SOCK_STREAM && (IPPROTO_TCP || IPPROTO_MPTCP) check ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-07-24 15:51:16 +02:00
..
include apparmor: fix use-after-free in rawdata dedup loop 2026-07-24 15:51:16 +02:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
apparmorfs.c apparmor: fix race between freeing data and fs accessing it 2026-04-18 10:33:36 +02:00
audit.c ima: Avoid blocking in RCU read-side critical section 2024-07-18 13:07:34 +02:00
capability.c apparmor: fix 'Do simple duplicate message elimination' 2024-12-14 19:51:11 +01: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:40:00 +02:00
file.c apparmor: handle idmapped mounts 2021-01-24 14:27:20 +01:00
ipc.c audit: purge audit_log_string from the intra-kernel audit API 2020-07-21 11:12:31 -04:00
Kconfig Minor fixes for v5.9. 2020-08-11 14:30:36 -07:00
label.c apparmor: fix race between freeing data and fs accessing it 2026-04-18 10:33:36 +02:00
lib.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
lsm.c apparmor: mediate the implicit connect of TCP fast open sendmsg 2026-07-24 15:51:16 +02:00
Makefile apparmor: add base infastructure for socket mediation 2018-03-13 17:25:48 -07:00
match.c apparmor: fix differential encoding verification 2026-04-18 10:33:36 +02:00
mount.c apparmor: fix reference count leak in aa_pivotroot() 2022-08-25 11:40:01 +02:00
net.c apparmor: fix NULL sock in aa_sock_file_perm 2026-03-04 07:19:53 -05:00
nulldfa.in apparmor: cleanup add proper line wrapping to nulldfa.in 2018-02-09 11:30:01 -08:00
path.c AppArmor: Remove semicolon 2020-01-18 15:36:58 -08:00
policy.c apparmor: fix use-after-free in rawdata dedup loop 2026-07-24 15:51:16 +02:00
policy_ns.c apparmor: fix: limit the number of levels of policy namespaces 2026-04-18 10:33:36 +02:00
policy_unpack.c apparmor: validate default DFA states are in bounds 2026-06-19 13:33:50 +02:00
policy_unpack_test.c apparmor: test: Fix memory leak for aa_unpack_strdup() 2024-12-14 19:51:14 +01:00
procattr.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
resource.c apparmor: fix rlimit for posix cpu timers 2026-03-04 07:19:53 -05:00
secid.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
stacksplitdfa.in apparmor: use the dfa to do label parse string splitting 2018-02-09 11:30:01 -08:00
task.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00