]> git.ipfire.org Git - thirdparty/linux.git/commit
apparmor: mediate the implicit connect of TCP fast open sendmsg
authorBryam Vargas <hexlabsecurity@proton.me>
Mon, 22 Jun 2026 20:57:38 +0000 (15:57 -0500)
committerJohn Johansen <john.johansen@canonical.com>
Tue, 23 Jun 2026 07:16:59 +0000 (00:16 -0700)
commit4d587cd8a72155089a627130bbd4716ec0856e21
tree532480cdc33a22f8313709395059ff012aabf586
parent1ed40bd525c00d22af666016af9aef7167f8085f
apparmor: mediate the implicit connect of TCP fast open sendmsg

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: cf60af03ca4e ("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>
security/apparmor/lsm.c