From: sashiko-bot@kernel.org
Cc: linux-security-module@vger.kernel.org
Subject: Re: [PATCH v4 3/7] landlock: Add UDP send access control
Date: Fri, 30 Oct 2026 04:53:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-190351@kernel.org> (raw)
In-Reply-To: <20260502124306.3975990-4-matthieu@buffet.re>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] TCP Fast Open (MSG_FASTOPEN) via sendmsg()/sendto() bypasses LANDLOCK_ACCESS_NET_CONNECT_TCP enforcement.
- [Medium] Lockless plain reads of concurrently modified socket state (`skc_family` and `inet_num`) introduce data races.
--
commit b84eacd95b135c773c622b9361a03b428f1f3bce
Author: Matthieu Buffet <matthieu@buffet.re>
landlock: Add UDP send access control
This patch adds Landlock access control for sending UDP datagrams to
explicit destinations via sendto() and sendmsg(). It introduces a new
socket_sendmsg hook that applies the LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP
policy.
> diff --git a/security/landlock/net.c b/security/landlock/net.c
> index 045881f81295..8a53aebdb8c6 100644
> --- a/security/landlock/net.c
> +++ b/security/landlock/net.c
[ ... ]
> @@ -82,6 +84,35 @@ static int current_check_access_socket(struct socket *const sock,
> * inconsistencies and return -EINVAL if needed.
> */
> return 0;
> + } else if (access_request ==
> + LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP) {
> + if (sock->sk->__sk_common.skc_family == AF_INET6) {
The comment below notes that the socket's family can change under our feet
due to concurrent setsockopt(IPV6_ADDRFORM) calls. Since this is a plain C
read of a concurrently modified variable, should we use READ_ONCE() here to
avoid data races and KCSAN warnings?
Additionally, since skc_family is evaluated multiple times in this function,
would it be safer to read it once into a local variable to prevent
inconsistent evaluations due to compiler reloads?
The same question applies to the lockless read of inet_sk(sock->sk)->inet_num
in current_check_autobind_udp_socket(), which also acknowledges concurrent
modifications in its comments.
> + /*
> + * We cannot allow sending UDP datagrams to an
> + * explicit AF_UNSPEC address on IPv6 sockets,
> + * even if AF_UNSPEC is treated as "no address"
> + * on such sockets (so it should always be allowed).
> + * That's because the socket's family can change under
> + * our feet (if another thread calls setsockopt(IPV6_ADDRFORM))
> + * to IPv4, which would then treat AF_UNSPEC as
> + * AF_INET.
> + */
[ ... ]
> @@ -299,9 +333,33 @@ static int hook_socket_connect(struct socket *const sock,
> return ret;
> }
>
> +static int hook_socket_sendmsg(struct socket *const sock,
> + struct msghdr *const msg, const int size)
> +{
> + struct sockaddr *const address = msg->msg_name;
> + const int addrlen = msg->msg_namelen;
> + access_mask_t access_request;
> + int ret = 0;
> +
> + if (sk_is_udp(sock->sk))
> + access_request = LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP;
> + else
> + return 0;
Does returning 0 for all non-UDP sockets leave a pre-existing bypass open for
TCP Fast Open?
If a sandboxed process calls sendmsg() on an unconnected TCP socket with
MSG_FASTOPEN and a target address, it routes through sys_sendmsg() to
security_socket_sendmsg() and then tcp_sendmsg_fastopen(). This entirely
bypasses the connect() wrapper and the security_socket_connect hook where
LANDLOCK_ACCESS_NET_CONNECT_TCP is normally enforced.
Since this patch introduces the socket_sendmsg hook, could we also evaluate
TCP sockets here when address != NULL to enforce the
LANDLOCK_ACCESS_NET_CONNECT_TCP restriction and close this gap?
> +
> + if (address != NULL)
> + ret = current_check_access_socket(sock, address, addrlen,
> + access_request, false);
> +
> + if (ret == 0)
> + ret = current_check_autobind_udp_socket(sock);
> +
> + return ret;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260502124306.3975990-1-matthieu@buffet.re?part=3
next prev parent reply other threads:[~2026-10-30 4:53 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-02 12:42 [PATCH v4 0/7] landlock: Add UDP access control support Matthieu Buffet
2026-05-02 12:43 ` [PATCH v4 1/7] landlock: Add UDP bind() access control Matthieu Buffet
2026-10-30 4:53 ` sashiko-bot
2026-05-02 12:43 ` [PATCH v4 2/7] landlock: Add UDP connect() " Matthieu Buffet
2026-05-22 21:10 ` Mickaël Salaün
2026-06-06 17:11 ` Matthieu Buffet
2026-06-09 21:15 ` [PATCH 1/2] landlock: Fix unmarked concurrent access to socket family Matthieu Buffet
2026-06-09 21:15 ` [PATCH 2/2] landlock: replace __sk_common struct sock field accesses Matthieu Buffet
2026-06-10 13:41 ` Mickaël Salaün
2026-06-10 13:48 ` Mickaël Salaün
2026-05-22 21:18 ` [PATCH v4 2/7] landlock: Add UDP connect() access control Mickaël Salaün
2026-06-06 17:04 ` Matthieu Buffet
2026-10-30 4:53 ` sashiko-bot
2026-05-02 12:43 ` [PATCH v4 3/7] landlock: Add UDP send " Matthieu Buffet
2026-05-22 21:10 ` Mickaël Salaün
2026-10-30 4:53 ` sashiko-bot [this message]
2026-05-02 12:43 ` [PATCH v4 4/7] selftests/landlock: Add UDP bind/connect tests Matthieu Buffet
2026-10-30 4:53 ` sashiko-bot
2026-05-02 12:43 ` [PATCH v4 5/7] selftests/landlock: Add tests for sendmsg() Matthieu Buffet
2026-10-30 4:53 ` sashiko-bot
2026-05-02 12:43 ` [PATCH v4 6/7] samples/landlock: Add sandboxer UDP access control Matthieu Buffet
2026-05-02 12:43 ` [PATCH v4 7/7] landlock: Add documentation for UDP support Matthieu Buffet
2026-05-22 21:11 ` Mickaël Salaün
2026-05-06 15:33 ` [PATCH v4 0/7] landlock: Add UDP access control support Günther Noack
2026-05-07 22:11 ` Matthieu Buffet
2026-05-22 21:08 ` Mickaël Salaün
2026-06-06 17:01 ` Matthieu Buffet
2026-06-10 13:44 ` Mickaël Salaün
2026-05-25 20:28 ` Mickaël Salaün
2026-06-11 0:27 ` Matthieu Buffet
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=sashiko-outbox-190351@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.