Re: [PATCH v1 1/2] landlock: Handle weird files
From: Christian Brauner
Date: Wed Jan 15 2025 - 05:55:04 EST
On Tue, Jan 14, 2025 at 11:15:42PM -0800, Christoph Hellwig wrote:
> On Sat, Jan 11, 2025 at 04:38:56PM +0100, Mickaël Salaün wrote:
> > I guess it depends on the filesystem implementation. For instance, XFS
> > returns an error if a weird file is detected [1], whereas bcachefs
> > ignores it (which is considered a bug, but not fixed yet) [2].
>
> If a filesyste, returns an invalid mode that's a file system bug and
> needs to be fixed there. Warning in a consumer is perfectly fine.
> But the right action in that case is indeed not to grant the access.
Fyi, anonymous inodes traditionally set the mode to 0 which is
really annoying:
lrwx------ 1 root root 64 15. Jan 11:52 94 -> anon_inode:bpf-prog
> sudo stat -L /proc/1/fd/94
File: /proc/1/fd/94
Size: 0 Blocks: 0 IO Block: 4096 weird file
Device: 0,15 Inode: 4120 Links: 1
Access: (0600/?rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2024-11-05 17:15:54.404000000 +0100
Modify: 2024-11-05 17:15:54.404000000 +0100
Change: 2024-11-05 17:15:54.404000000 +0100
Birth: -