From: "Mickaël Salaün" <mic@digikod.net>
To: Matthieu Buffet <matthieu@buffet.re>
Cc: "Bryam Vargas" <hexlabsecurity@proton.me>,
"Günther Noack" <gnoack@google.com>,
linux-security-module@vger.kernel.org,
"Mikhail Ivanov" <ivanov.mikhail1@huawei-partners.com>,
"Paul Moore" <paul@paul-moore.com>,
"Eric Dumazet" <edumazet@google.com>,
"Neal Cardwell" <ncardwell@google.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v2 1/2] landlock: fix TCP Fast Open connection bypass
Date: Thu, 2 Jul 2026 16:59:20 +0200 [thread overview]
Message-ID: <20260702.EiNg0kiph4ew@digikod.net> (raw)
In-Reply-To: <20260701214628.33319-1-matthieu@buffet.re>
Thanks, applied!
On Wed, Jul 01, 2026 at 11:46:27PM +0200, Matthieu Buffet wrote:
> The documentation of the socket_connect() LSM hook states that it
> controls connecting a socket to a remote address. It has not been the
> case since the addition of TCP Fast Open (RFC 7413) support, which allows
> opening a TCP connection (thus, setting a socket's destination address)
> via the MSG_FASTOPEN flag passed to sendto()/sendmsg()/sendmmsg(). The
> problem then got duplicated into MPTCP.
>
> Landlock did not take it into account when its TCP support was added,
> leaving a bypass of TCP connect policy.
>
> Ideally a call to the LSM hook would be added in the fastopen code path,
> in order to fix this generically. But connect() hooks are designed to run
> with the socket locked, unlike sendmsg() hooks.
>
> Closes: https://github.com/landlock-lsm/linux/issues/41
> Fixes: fff69fb03dde ("landlock: Support network rules with TCP bind and connect")
> Signed-off-by: Matthieu Buffet <matthieu@buffet.re>
> ---
> security/landlock/net.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/security/landlock/net.c b/security/landlock/net.c
> index cbff59ec3aba..46c17116fcf4 100644
> --- a/security/landlock/net.c
> +++ b/security/landlock/net.c
> @@ -351,6 +351,14 @@ static int hook_socket_sendmsg(struct socket *const sock,
> access_mask_t access_request;
> int ret = 0;
>
> + if ((msg->msg_flags & MSG_FASTOPEN) && address && sk_is_tcp(sock->sk)) {
> + ret = current_check_access_socket(
> + sock, address, addrlen, LANDLOCK_ACCESS_NET_CONNECT_TCP,
> + true);
> + if (ret != 0)
> + return ret;
> + }
> +
> if (sk_is_udp(sock->sk))
> access_request = LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP;
> else
> --
> 2.47.3
>
>
next prev parent reply other threads:[~2026-07-02 14:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 20:16 Landlock: LANDLOCK_ACCESS_NET_CONNECT_TCP bypass via TCP Fast Open Bryam Vargas
2026-06-17 14:22 ` Mickaël Salaün
2026-06-17 18:05 ` Matthieu Buffet
2026-06-17 18:05 ` [RFC PATCH 1/2] landlock: fix TCP Fast Open connection bypass Matthieu Buffet
2026-06-18 1:25 ` Bryam Vargas
2026-06-19 0:34 ` Matthieu Buffet
2026-06-19 1:39 ` Bryam Vargas
2026-06-26 20:40 ` Mickaël Salaün
2026-07-01 21:42 ` Matthieu Buffet
2026-07-01 21:46 ` [PATCH v2 " Matthieu Buffet
2026-07-01 21:46 ` [PATCH v2 2/2] selftests/landlock: Add test for TCP fast open Matthieu Buffet
2026-07-02 14:59 ` Mickaël Salaün [this message]
2026-06-17 18:05 ` [RFC PATCH " Matthieu Buffet
2026-06-26 21:19 ` Mickaël Salaün
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260702.EiNg0kiph4ew@digikod.net \
--to=mic@digikod.net \
--cc=edumazet@google.com \
--cc=gnoack@google.com \
--cc=hexlabsecurity@proton.me \
--cc=ivanov.mikhail1@huawei-partners.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=matthieu@buffet.re \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=paul@paul-moore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.