From: "Günther Noack" <gnoack3000@gmail.com>
To: Demi Marie Obenour <demiobenour@gmail.com>
Cc: Justin Suess <utilityemal77@gmail.com>,
Tingmao Wang <m@maowtm.org>,
fahimitahera@gmail.com, hi@alyssa.is,
ivanov.mikhail1@huawei-partners.com, jannh@google.com,
konstantin.meskhidze@huawei.com,
linux-security-module@vger.kernel.org, matthieu@buffet.re,
mic@digikod.net, paul@paul-moore.com,
samasth.norway.ananda@oracle.com
Subject: Re: [RFC PATCH 3/5] samples/landlock: Add support for LANDLOCK_ACCESS_FS_CONNECT_UNIX
Date: Fri, 2 Jan 2026 10:53:49 +0100 [thread overview]
Message-ID: <20260102.d6870733fe10@gnoack.org> (raw)
In-Reply-To: <884e44c6-7695-49a2-8d60-c7e76d260bea@gmail.com>
On Thu, Jan 01, 2026 at 05:39:26PM -0500, Demi Marie Obenour wrote:
> On 1/1/26 17:38, Justin Suess wrote:
> > On 1/1/26 17:19, Tingmao Wang wrote:
> >> On 1/1/26 22:11, Demi Marie Obenour wrote:
> >>> On 1/1/26 17:07, Tingmao Wang wrote:
> >>>
> >>> (snip)
> >>>
> >>>> Looking at this I guess it might also make sense for the kernel side to
> >>>> enforce only being able to add LANDLOCK_ACCESS_FS_CONNECT_UNIX on socket
> >>>> files (S_ISSOCK(d_backing_inode)) too in landlock_append_fs_rule?
> >>>>
> >>>> Also, for the sandboxer logic, maybe a better way would be having
> >>>> LANDLOCK_ACCESS_FS_CONNECT_UNIX in ACCESS_FILE (matching the kernel code),
> >>>> then another if(!S_ISSOCK) below this that will clear out
> >>>> LANDLOCK_ACCESS_FS_CONNECT_UNIX if not socket.
> >>> A process might legitimately need to connect to a socket that doesn't
> >>> exist at the time it sandboxes itself. Therefore, I think it makes
> >>> sense to for LANDLOCK_ACCESS_FS_CONNECT_UNIX access to a directory
> >>> to allow LANDLOCK_ACCESS_FS_CONNECT_UNIX to any socket under that
> >>> directory. This matches the flexibility mount namespaces can achieve.
> >> Right, I forgot about the fact that we also need it on dirs, apologies.
> >>
> >> (But maybe it might still make sense to not allow this on files which are
> >> neither a socket or a dir? (If the file later gets removed and recreated
> >> as a socket, the rule would not apply retroactively anyway due to being
> >> tied to the inode.))
> > How do we handle IOCTL access on regular files? I think that landlock will let you put IOCTL rights on regular files even they are not valid for that operation.
>
> Regular files definitely support ioctls.
The LANDLOCK_ACCESS_FS_IOCTL_DEV right only applies to ioctl(2)
invocations on device files.
> > Sockets seem like a similar case where the operation is only valid for a subset of file types.
> >
> > I think we should mirror the existing behavior is for consistency.
> >
> > Besides, restricting which file types can have that right also makes it harder for applications that may not care about the specific file type, but now would have to check the filetype before making a policy on them (also opening them to TOCTOU).
>
> I agree.
I also agree with your interpretation, Justin.
For the record, Landlock's kernel implementation currently groups FS
access rights into two groups:
- file access rights
- directory-only rights
When adding a rule, the directory access rights can only be granted on
a directory inode. The file access rights can be granted on both a
directory inode and a regular file inode.
It is pointless to grant the CONNECT_UNIX (or IOCTL_DEV) right on a
file which is not a Unix socket (or device file). But it complicates
the userspace API if we introduce more special rules there. - Users of
Landlock would have to keep track of all these special cases and
mirror the logic, which is error prone. IMHO is is granular enough if
we differentiate between files and directories as we currently do.
For reference, this is documented at
https://docs.kernel.org/userspace-api/landlock.html#filesystem-flags
and the logic is implemented in landlock_append_fs_rule() in fs.c.
(Actually, in the implementation, the IOCTL_DEV right is treated the
same as one of the ACCESS_FILE rights - I should probably revise that
documentation: That right does not *directly* apply to a directory
inode, as directories are not device files. It only inherits down in
the file system hierarchy. Looking back at earlier versions of the
IOCTL_DEV patch set, it was different there. I think I missed to keep
the documentation in-line.)
–Günther
next prev parent reply other threads:[~2026-01-02 9:53 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-01 13:40 [RFC PATCH 0/5] landlock: Pathname-based UNIX connect() control Günther Noack
2026-01-01 13:40 ` [RFC PATCH 1/5] landlock/selftests: add a missing close(srv_fd) call Günther Noack
2026-01-01 13:40 ` [RFC PATCH 2/5] landlock: Control connections to pathname UNIX sockets by path Günther Noack
2026-01-01 13:41 ` [RFC PATCH 3/5] samples/landlock: Add support for LANDLOCK_ACCESS_FS_CONNECT_UNIX Günther Noack
2026-01-01 19:30 ` Justin Suess
2026-01-01 22:07 ` Tingmao Wang
2026-01-01 22:11 ` Demi Marie Obenour
2026-01-01 22:19 ` Tingmao Wang
2026-01-01 22:36 ` Demi Marie Obenour
2026-01-01 22:38 ` Justin Suess
2026-01-01 22:39 ` Demi Marie Obenour
2026-01-02 9:53 ` Günther Noack [this message]
2026-01-01 13:41 ` [RFC PATCH 4/5] landlock/selftests: test LANDLOCK_ACCESS_FS_CONNECT_UNIX Günther Noack
2026-01-01 13:41 ` [RFC PATCH 5/5] landlock: Document LANDLOCK_ACCESS_FS_UNIX_CONNECT Günther Noack
2026-01-01 22:14 ` [RFC PATCH 0/5] landlock: Pathname-based UNIX connect() control Demi Marie Obenour
2026-01-01 22:34 ` Tingmao Wang
2026-01-01 22:44 ` Demi Marie Obenour
2026-01-02 10:16 ` Günther Noack
2026-01-02 10:25 ` Günther Noack
2026-01-02 10:27 ` Demi Marie Obenour
2026-01-02 10:50 ` Günther Noack
2026-01-02 18:37 ` Demi Marie Obenour
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=20260102.d6870733fe10@gnoack.org \
--to=gnoack3000@gmail.com \
--cc=demiobenour@gmail.com \
--cc=fahimitahera@gmail.com \
--cc=hi@alyssa.is \
--cc=ivanov.mikhail1@huawei-partners.com \
--cc=jannh@google.com \
--cc=konstantin.meskhidze@huawei.com \
--cc=linux-security-module@vger.kernel.org \
--cc=m@maowtm.org \
--cc=matthieu@buffet.re \
--cc=mic@digikod.net \
--cc=paul@paul-moore.com \
--cc=samasth.norway.ananda@oracle.com \
--cc=utilityemal77@gmail.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).