From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm2-f13.google.com (mail-wm2-f13.google.com [74.125.225.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DB9D51EE0C for ; Wed, 23 Sep 2026 14:27:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790173637; cv=none; b=D6KcBeL6slLo0Fz7CHM9aBhjbgCmQbp9exQeSGtLWzDf7Fgs/TnJh7aGzUWMrHYV3ZK3g+6bzsLEJgifDnzfiQ15MZkuHKbFH/HYpBBoJlzS+d7shhhqcwUY0NY3/w/o3VKzZlpp6xW/xViPvjL9uiiDifNKk3owX4xkrRXfaS8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790173637; c=relaxed/simple; bh=8h06L4zgt0xbnYaqADQB9yddRobQhsv4hVUNTqVY1jo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PHFb5jc+/WwmBcowezqv5ywVtSZuN11CRwFq/6vazYwXLuawguI4DPPm1tbb4plIr9wAbFYsTPomgh0aYMklPIB1oyP6PrD/RLpfidiUVp9ppHrBKFc9z1T4BUJMgndVwsbJcWYOQLNJzCPZW7OmRIbxPq+MoEG1zyQfrNxYvDI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bzNC1eNM; arc=none smtp.client-ip=74.125.225.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bzNC1eNM" Received: by mail-wm2-f13.google.com with SMTP id 5b1f17b1804b1-49ccead2aecso4566825e9.0 for ; Wed, 23 Sep 2026 07:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1790173633; x=1790778433; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=PSzGnM9hkcOoFtPupK98ZapwC/NnVGSiD0/uooo0h9E=; b=bzNC1eNMuM1eShI2U0vCqWsQQzIXyrxi5Ku7mDQ80V18DQ8f9v4n092LXfBPxCI79z mx6Go3u6l9OkhDFe5z3gBNTrlFO7OUUSahlV9m4pZvi0mRsNyRdrveD3JhX5SZ2nzvhp NMlJ1Se3WgL4FBwhVj4GRmmCI+c/4nStaF8WTlWeQhP+bJ6i4/wRPgsyUTWMOHcibOXP mYWpHJ6A1JAjGBC29D1AE26M8diqDcNSEHStT1IOPpc5WMzmJW0rEPmy/7BXJNvD45x7 wDRlZMB7kZqYENcuaXsf5GMevY1rjmsuX0CEqik6hHewgkzOaPBqvq1H/OvRjl4rCgme GkLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790173633; x=1790778433; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=PSzGnM9hkcOoFtPupK98ZapwC/NnVGSiD0/uooo0h9E=; b=k/5eut9Qf0VkdROlHQO/TTkChGMzL+1bM68hml3Re8KLbJv8lUckbtyaDAANizsZV5 y3sjYAumT01fp8sGnq1V8HEgcbfTHVgxz/LciqH+7aGWqIltJWPbiuk8BtYI6rBfarLp VUlYe3ZhXherrJ1iKuCF0GfMbA/3dYASiv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9.17.1790173632836; Wed, 23 Sep 2026 07:27:12 -0700 (PDT) Received: from google.com ([2a00:79e0:288a:8:c20f:9e7a:eeee:1b06]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4886848636asm6964795f8f.6.2026.09.23.07.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 07:27:12 -0700 (PDT) Date: Wed, 23 Sep 2026 16:27:07 +0200 From: =?utf-8?Q?G=C3=BCnther?= Noack To: Geliang Tang Cc: =?utf-8?Q?G=C3=BCnther?= Noack , =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= , Matthieu Baerts , Mat Martineau , Mikhail Ivanov , mptcp@lists.linux.dev, netdev@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH 3/6] landlock: Add MPTCP bind and connect access rights Message-ID: References: <20260830201650.67050-1-gnoack3000@gmail.com> <20260830201650.67050-4-gnoack3000@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Sep 23, 2026 at 01:04:40PM +0800, Geliang Tang wrote: > On Mon, 2026-08-31 at 12:09 +0800, Geliang Tang wrote: > > On Sun, 2026-08-30 at 22:16 +0200, Günther Noack wrote: > > > MPTCP sockets have equivalent bind(2) and connect(2) operations as > > > TCP > > > sockets, but can not currently be restricted with Landlock without > > > explicit MPTCP access rights.  As MPTCP operates on the same TCP > > > port > > > number space as TCP, this is a gap in Landlock's policies. > > > > > > Add access rights for MPTCP bind(2) and connect(2) operations > > > and document them in the header. > > > > > > Treat TCP Fast Open the same as done for plain TCP in > > > commit 33cb713db016 ("landlock: Fix TCP Fast Open connection > > > bypass") > > > > > > The port numbers used in MPTCP subflows are negotiated by the > > > kernel > > > and therefore not subject to these access rights. > > > > > > Bump the Landlock ABI version to 12. > > > > > > Closes: https://github.com/landlock-lsm/linux/issues/54 > > > Signed-off-by: Günther Noack > > > --- > > >  include/linux/landlock.h                     |  5 +- > > >  include/uapi/linux/landlock.h                | 24 +++++++ > > >  security/landlock/limits.h                   |  2 +- > > >  security/landlock/net.c                      | 68 ++++++++++++++-- > > > -- > > > -- > > >  security/landlock/syscalls.c                 |  2 +- > > >  tools/testing/selftests/landlock/base_test.c |  2 +- > > >  6 files changed, 79 insertions(+), 24 deletions(-) > > > > > > diff --git a/include/linux/landlock.h b/include/linux/landlock.h > > > index 004cbd0b9298..b04ffc7caa21 100644 > > > --- a/include/linux/landlock.h > > > +++ b/include/linux/landlock.h > > > @@ -46,7 +46,10 @@ > > >   _LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_NET_CONNECT_TCP, > > > "connect_tcp"), \ > > >   _LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_NET_BIND_UDP, > > > "bind_udp"), \ > > >   _LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP, > > > \ > > > -      "connect_send_udp") > > > +      "connect_send_udp"), \ > > > + _LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_NET_BIND_MPTCP, > > > "bind_mptcp"), \ > > > + _LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_NET_CONNECT_MPTCP, \ > > > +      "connect_mptcp") > > >   > > >  #define _LANDLOCK_SCOPE_NAMES \ > > >   _LANDLOCK_NAME_ENTRY(LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET, > > > \ > > > diff --git a/include/uapi/linux/landlock.h > > > b/include/uapi/linux/landlock.h > > > index cceda3b3b961..2a953ba7ce25 100644 > > > --- a/include/uapi/linux/landlock.h > > > +++ b/include/uapi/linux/landlock.h > > > @@ -448,6 +448,9 @@ struct landlock_net_port_attr { > > >   * - %LANDLOCK_ACCESS_NET_CONNECT_TCP: Connect TCP sockets to the > > > given > > >   *   remote port. Support added in Landlock ABI version 4. > > >   * > > > + * .. note:: These rights do not apply to MPTCP sockets, which > > > have > > > their own > > > + *   access rights (see below). > > > + * > > >   * And similarly for UDP port numbers: > > >   * > > >   * - %LANDLOCK_ACCESS_NET_BIND_UDP: Bind UDP sockets to the given > > > local > > > @@ -474,12 +477,33 @@ struct landlock_net_port_attr { > > >   * .. note:: Sending datagrams to an ``AF_UNSPEC`` destination > > > address > > >   *   family is not supported for IPv6 UDP sockets: you will need > > > to > > > use a > > >   *   ``NULL`` address instead. > > > + * > > > + * MPTCP sockets (created with ``IPPROTO_MPTCP``) use TCP port > > > numbers, but > > > + * they are controlled by their own access rights: > > > + * > > > + * - %LANDLOCK_ACCESS_NET_BIND_MPTCP: Bind MPTCP sockets to the > > > given local > > > + *   port. Support added in Landlock ABI version 12. > > > + * - %LANDLOCK_ACCESS_NET_CONNECT_MPTCP: Connect MPTCP sockets to > > > the given > > > + *   remote port. Support added in Landlock ABI version 12. > > > + * > > > + * .. note:: The TCP and the MPTCP access rights are independent, > > > even though > > > + *   they refer to the same port number space. Handling only > > > + *   %LANDLOCK_ACCESS_NET_BIND_TCP and > > > %LANDLOCK_ACCESS_NET_CONNECT_TCP leaves > > > + *   MPTCP sockets unrestricted, and vice versa. A sandbox that > > > wants to > > > + *   control all TCP-based traffic needs to handle both sets. > > > + * > > > + * .. note:: These MPTCP access rights restrict the ports passed > > > to > > > + *   :manpage:`bind(2)` and :manpage:`connect(2)`. The ports used > > > in > > > MPTCP > > > + *   subflows are negotiated in the MPTCP protocol by the kernel > > > and > > > are not > > > + *   subject to these restrictions. > > >   */ > > >  /* clang-format off */ > > >  #define LANDLOCK_ACCESS_NET_BIND_TCP (1ULL << > > > 0) > > >  #define > > > LANDLOCK_ACCESS_NET_CONNECT_TCP (1ULL << 1) > > >  #define LANDLOCK_ACCESS_NET_BIND_UDP (1ULL << > > > 2) > > >  #define LANDLOCK_ACCESS_NET_CONNECT_SEND_UDP (1ULL << > > > 3) > > > +#define LANDLOCK_ACCESS_NET_BIND_MPTCP (1ULL << > > > 4) > > > +#define LANDLOCK_ACCESS_NET_CONNECT_MPTCP (1ULL << > > > 5) > > >  /* clang-format on */ > > >   > > >  /** > > > diff --git a/security/landlock/limits.h > > > b/security/landlock/limits.h > > > index 1a7c5fb8f6fd..d25e056b7ca2 100644 > > > --- a/security/landlock/limits.h > > > +++ b/security/landlock/limits.h > > > @@ -23,7 +23,7 @@ > > >  #define > > > LANDLOCK_MASK_ACCESS_FS ((LANDLOCK_LAST_ACCESS_FS << 1) - > > > 1) > > >  #define > > > LANDLOCK_NUM_ACCESS_FS __const_hweight64(LANDLOCK_MASK_AC > > > CESS_FS) > > >   > > > -#define > > > LANDLOCK_LAST_ACCESS_NET LANDLOCK_ACCESS_NET_CONNECT_SEND_U > > > DP > > > +#define > > > LANDLOCK_LAST_ACCESS_NET LANDLOCK_ACCESS_NET_CONNECT_MPTCP > > >  #define LANDLOCK_MASK_ACCESS_NET ((LANDLOCK_LAST_ACCESS_NET > > > << 1) - 1) > > >  #define > > > LANDLOCK_NUM_ACCESS_NET __const_hweight64(LANDLOCK_MASK_AC > > > CESS_NET) > > >   > > > diff --git a/security/landlock/net.c b/security/landlock/net.c > > > index 8f2aaac54b33..8541b0c07d64 100644 > > > --- a/security/landlock/net.c > > > +++ b/security/landlock/net.c > > > @@ -11,6 +11,7 @@ > > >  #include > > >  #include > > >  #include > > > +#include > > >   > > >  #include "common.h" > > >  #include "cred.h" > > > @@ -53,6 +54,26 @@ int landlock_append_net_rule(struct > > > landlock_ruleset *const ruleset, > > >   return err; > > >  } > > >   > > > +static bool sk_is_mptcp_socket(const struct sock *sk) > > > +{ > > > + return sk_is_inet(sk) && sk->sk_type == SOCK_STREAM && > > > +        sk->sk_protocol == IPPROTO_MPTCP; > > > +} > > > > This helper should be placed in include/net/mptcp.h. I had already > > implemented one in [1], called sk_is_msk(), to differentiate it from > > sk_is_mptcp(). If you have no concerns with my implementation, please > > feel free to pick it up and use it in your series. > > Sorry, let me correct myself. I thought about this more carefully, and > the ideal place to define sk_is_msk() is in include/net/sock.h, between > sk_is_tcp() and sk_is_udp(): > > static inline bool sk_is_tcp(const struct sock *sk) > { > return sk_is_inet(sk) && > sk->sk_type == SOCK_STREAM && > sk->sk_protocol == IPPROTO_TCP; > } > > static inline bool sk_is_msk(const struct sock *sk) > { > return sk_is_inet(sk) && > sk->sk_type == SOCK_STREAM && > sk->sk_protocol == IPPROTO_MPTCP; > } > > static inline bool sk_is_udp(const struct sock *sk) > { > return sk_is_inet(sk) && > sk->sk_type == SOCK_DGRAM && > sk->sk_protocol == IPPROTO_UDP; > } > > If possible, please fold this code into this patch. Thank you for the review, Geliang! I'll include something like this in the next review round. (We are a bit bottlenecked on doing Landlock code reviews at the moment, so some delays are unfortunately expected.) Small question about the function name sk_is_msk(): Is "msk" the right name for this? It seems to be used as abbreviation for "MPTCP" in net/mptcp, but it's also used in net/mctp as an abbreviation, and I could not find a function name in include/net/mptcp.h which used "msk" to mean "MPTCP". Should that say sk_is_mptcp() instead? Thanks, —Günther