The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] smb: client: set SB_I_NODEV to prevent device node injection
@ 2026-07-09 15:54 Bjoern Doebel
  2026-07-09 17:20 ` Steve French
  0 siblings, 1 reply; 2+ messages in thread
From: Bjoern Doebel @ 2026-07-09 15:54 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM, linux-cifs, linux-kernel, samba-technical
  Cc: stable, doebel, nmanthey

From: Norbert Manthey <nmanthey@amazon.de>

Set SB_I_NODEV on the superblock by default for CIFS mounts. This is
consistent with how other filesystems handle untrusted remote content
and prevents the server side from injecting device nodes on the client.

Fixes: 2e4564b31b645 ("smb3: add support for stat of WSL reparse points for special file types")
Signed-off-by: Norbert Manthey <nmanthey@amazon.de>
Assisted-by: Kiro:claude-opus-4.6
Cc: stable@vger.kernel.org
---
 fs/smb/client/cifsfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index ea4fc0fa68cac..35eee2f9899d5 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -208,6 +208,9 @@ cifs_read_super(struct super_block *sb)
 	if (sbflags & CIFS_MOUNT_POSIXACL)
 		sb->s_flags |= SB_POSIXACL;
 
+	/* Prevent device node opens from remote filesystem by default */
+	sb->s_iflags |= SB_I_NODEV;
+
 	if (tcon->snapshot_time)
 		sb->s_flags |= SB_RDONLY;
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] smb: client: set SB_I_NODEV to prevent device node injection
  2026-07-09 15:54 [PATCH] smb: client: set SB_I_NODEV to prevent device node injection Bjoern Doebel
@ 2026-07-09 17:20 ` Steve French
  0 siblings, 0 replies; 2+ messages in thread
From: Steve French @ 2026-07-09 17:20 UTC (permalink / raw)
  To: Bjoern Doebel
  Cc: Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Tom Talpey,
	Bharath SM, linux-cifs, linux-kernel, samba-technical, stable,
	nmanthey, linux-fsdevel

Setting SB_I_NODEV is apparently not done for any remote filesystems,
and AI search confirmed that it probably isn't a good idea to set it
for remote fs.  It is more of a thing in pseudofilesystems and not
needed for network filesystems.

e.g.

"Is there any benefit to setting SB_I_NODEV?

Today, probably not.If you grep the kernel, you'll find SB_I_NODEV is
used in only a handful of places, and those places generally involve
pseudo-filesystems or internal VFS assumptions rather than remote
storage.  Setting it on CIFS or NFS is unlikely to change behavior,
because those filesystems have worked correctly for decades without
it. Most remote filesystems don't set s_iflags because almost none of
the SB_I_* flags are intended as generic filesystem capability flags.
They're mostly internal VFS state, and SB_I_NODEV in particular has a
very specific purpose.  SB_I_NODEV does not mean "this filesystem
contains no device nodes." It means something closer to:  This
superblock is not associated with a block device.
or more precisely: The VFS should not expect a backing struct
block_device for this superblock."

Has something changed?  How did this question about SB_I_NODEV come up?

On Thu, Jul 9, 2026 at 11:05 AM Bjoern Doebel <doebel@amazon.de> wrote:
>
> From: Norbert Manthey <nmanthey@amazon.de>
>
> Set SB_I_NODEV on the superblock by default for CIFS mounts. This is
> consistent with how other filesystems handle untrusted remote content
> and prevents the server side from injecting device nodes on the client.
>
> Fixes: 2e4564b31b645 ("smb3: add support for stat of WSL reparse points for special file types")
> Signed-off-by: Norbert Manthey <nmanthey@amazon.de>
> Assisted-by: Kiro:claude-opus-4.6
> Cc: stable@vger.kernel.org
> ---
>  fs/smb/client/cifsfs.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
> index ea4fc0fa68cac..35eee2f9899d5 100644
> --- a/fs/smb/client/cifsfs.c
> +++ b/fs/smb/client/cifsfs.c
> @@ -208,6 +208,9 @@ cifs_read_super(struct super_block *sb)
>         if (sbflags & CIFS_MOUNT_POSIXACL)
>                 sb->s_flags |= SB_POSIXACL;
>
> +       /* Prevent device node opens from remote filesystem by default */
> +       sb->s_iflags |= SB_I_NODEV;
> +
>         if (tcon->snapshot_time)
>                 sb->s_flags |= SB_RDONLY;
>
> --
> 2.50.1
>
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-09 17:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 15:54 [PATCH] smb: client: set SB_I_NODEV to prevent device node injection Bjoern Doebel
2026-07-09 17:20 ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox