linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Günther Noack" <gnoack3000@gmail.com>
To: Mikhail Ivanov <ivanov.mikhail1@huawei-partners.com>, mic@digikod.net
Cc: mic@digikod.net, gnoack@google.com,
	willemdebruijn.kernel@gmail.com, matthieu@buffet.re,
	linux-security-module@vger.kernel.org, netdev@vger.kernel.org,
	netfilter-devel@vger.kernel.org, yusongping@huawei.com,
	artem.kuzin@huawei.com, konstantin.meskhidze@huawei.com
Subject: Re: [RFC PATCH v4 01/19] landlock: Support socket access-control
Date: Sat, 22 Nov 2025 13:18:00 +0100	[thread overview]
Message-ID: <20251122.d391a246d7dd@gnoack.org> (raw)
In-Reply-To: <af464773-b01b-f3a4-474d-0efb2cfae142@huawei-partners.com>

On Sat, Nov 22, 2025 at 02:13:08PM +0300, Mikhail Ivanov wrote:
> On 11/22/2025 1:49 PM, Günther Noack wrote:
> > (Remark, should those be exposed as constants?)
> 
> I thought it could overcomplicate socket rules definition and Landlock
> API. Do you think introducing such constants will be better decision?

No, I am not convinced either.  FWIW, there is a bit of prior art for
"wildcard-like" -1 constants (grepping include/uapi for 'define.*-1'),
but then again, the places where people did the opposite are hard to
grep for.  I would also be OK if we documented "-1" in that place and
left out the constant.

Mickaël, maybe you have a preference for the API style here?


> > > diff --git a/security/landlock/syscalls.c b/security/landlock/syscalls.c
> > > index 33eafb71e4f3..e9f500f97c86 100644
> > > --- a/security/landlock/syscalls.c
> > > +++ b/security/landlock/syscalls.c
> > > @@ -407,6 +458,8 @@ static int add_rule_net_port(struct landlock_ruleset *ruleset,
> > >    *   &landlock_net_port_attr.allowed_access is not a subset of the ruleset
> > >    *   handled accesses)
> > >    * - %EINVAL: &landlock_net_port_attr.port is greater than 65535;
> > > + * - %EINVAL: &landlock_socket_attr.{family, type} are greater than 254 or
> > > + *   &landlock_socket_attr.protocol is greater than 65534;
> > 
> > Hmm, this is a bit annoying that these values have such unusual
> > bounds, even though the input parameters are 32 bit.  We are exposing
> > a little bit that we are internally storing this with only 8 and 16
> > bits...  (I don't know a better solution immediately either, though. I
> > think we discussed this on a previous version of the patch set as well
> > and ended up with permitting larger values than the narrower SOCK_MAX
> > etc bounds.)
> 
> I agree, one of the possible solutions may be to store larger values in
> socket keys (eg. s32), but this would require to make a separate
> interface for storing socket rules (in order to not change key size for
> other type of rules which is currently 32-64 bit depending on virtual
> address size).

Yes, I'd be OK with it.

Do I remember this correctly that we settled on enforcing the looser
UINT8_MAX and UINT16_MAX instead of SOCK_MAX, AF_MAX, which we used in
v3 and before?  I tried to find the conversation but could not find it
any more.  (Or did you have other reasons why you switched the
implementation to use these larger bounds?)

Thanks,
–Günther

  reply	other threads:[~2025-11-22 12:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-18 13:46 [RFC PATCH v4 00/19] Support socket access-control Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 01/19] landlock: " Mikhail Ivanov
2025-11-22 10:49   ` Günther Noack
2025-11-22 11:13     ` Mikhail Ivanov
2025-11-22 12:18       ` Günther Noack [this message]
2025-11-22 16:51         ` Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 02/19] selftests/landlock: Test creating a ruleset with unknown access Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 03/19] selftests/landlock: Test adding a socket rule Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 04/19] selftests/landlock: Testing adding rule with wildcard value Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 05/19] selftests/landlock: Test acceptable ranges of socket rule key Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 06/19] landlock: Add hook on socket creation Mikhail Ivanov
2025-11-22 11:41   ` Günther Noack
2025-11-22 17:19     ` Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 07/19] selftests/landlock: Test basic socket restriction Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 08/19] selftests/landlock: Test network stack error code consistency Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 09/19] selftests/landlock: Test overlapped rulesets with rules of protocol ranges Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 10/19] selftests/landlock: Test that kernel space sockets are not restricted Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 11/19] selftests/landlock: Test protocol mappings Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 12/19] selftests/landlock: Test socketpair(2) restriction Mikhail Ivanov
2025-11-22 10:16   ` Günther Noack
2025-11-22 10:21     ` Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 13/19] selftests/landlock: Test SCTP peeloff restriction Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 14/19] selftests/landlock: Test that accept(2) is not restricted Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 15/19] lsm: Support logging socket common data Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 16/19] landlock: Log socket creation denials Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 17/19] selftests/landlock: Test socket creation denial log for audit Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 18/19] samples/landlock: Support socket protocol restrictions Mikhail Ivanov
2025-11-18 13:46 ` [RFC PATCH v4 19/19] landlock: Document socket rule type support Mikhail Ivanov

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=20251122.d391a246d7dd@gnoack.org \
    --to=gnoack3000@gmail.com \
    --cc=artem.kuzin@huawei.com \
    --cc=gnoack@google.com \
    --cc=ivanov.mikhail1@huawei-partners.com \
    --cc=konstantin.meskhidze@huawei.com \
    --cc=linux-security-module@vger.kernel.org \
    --cc=matthieu@buffet.re \
    --cc=mic@digikod.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=yusongping@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).