smb: client: set SB_I_NODEV to prevent device node injection
Subsystems (4)
PATCH 1/1 smb: client: set SB_I_NODEV to prevent device node injection
From: Norbert Manthey <[email protected]>
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.
--- fs/smb/client/cifsfs.c | 3 +++ 1 file changed, 3 insertions(+)
fs/smb/client/cifsfs.c +3 -0
@@ -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 ;
Signature · 1 line
2.50.1
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?
Quoted 33 lines · Bjoern Doebel
From: Norbert Manthey <[email protected]>
Set
SB_I_NODEVon 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 <[email protected]>Assisted-by Kiro:claude-opus-4.6--- fs/smb/client/cifsfs.c | 3 +++ 1 file changed, 3 insertions(+)fs/smb/client/cifsfs.c +3
-1@@ -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
Signature · 3 lines
Thanks, Steve
Hi Steve,
The issue is that the client takes the device node's mode straight from the server. So a malicious/compromised SMB server can define a device node (type + major/minor + permissions) on the client that the admin never created and cannot otherwise constrain -- the only knob left to block it is the "nodev" mount option. That's why we introduce the change using SB_I_NODEV here.
We did analyze the CIFS code, and found this missing security checks. We have a reproducer that allows a malicious server and local user to elevate privileges by introducing a new device in the mount.
Best,
Norbert
________________________________________
From: Steve French <[email protected]>
Sent: Thursday, July 9, 2026 7:20 PM
To: Doebel, Bjoern <[email protected]>
Cc: Paulo Alcantara <[email protected]>; Ronnie Sahlberg <[email protected]>; Shyam Prasad N <[email protected]>; Tom Talpey <[email protected]>; Bharath SM <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Manthey, Norbert <[email protected]>; linux-fsdevel <[email protected]>
Subject: RE: [EXTERNAL] [PATCH] smb: client: set SB_I_NODEV to prevent device node injection
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
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?
Quoted 30 lines · Bjoern Doebel
From: Norbert Manthey <[email protected]>
Set
SB_I_NODEVon 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 <[email protected]>Assisted-by Kiro:claude-opus-4.6---
fs/smb/client/cifsfs.c| 3 +++1 file changed, 3 insertions(+)fs/smb/client/cifsfs.c +3
-1@@ -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; --
Quoted 3 lines
2.50.1
--
Thanks,
Steve
If this is needed for cifs.ko wouldn't this also be needed for AFS, NFS, CEPH and others?
Quoted 93 lines · Norbert
Hi Steve,
The issue is that the client takes the device node's mode straight from the server. So a malicious/compromised SMB server can define a device node (type + major/minor + permissions) on the client that the admin never created and cannot otherwise constrain -- the only knob left to block it is the "nodev" mount option. That's why we introduce the change using
SB_I_NODEVhere.We did analyze the CIFS code, and found this missing security checks. We have a reproducer that allows a malicious server and local user to elevate privileges by introducing a new device in the mount.
Best,
Norbert________________________________________
From: Steve French <[email protected]>
Sent: Thursday, July 9, 2026 7:20 PM
To: Doebel, Bjoern <[email protected]>
Cc: Paulo Alcantara <[email protected]>; Ronnie Sahlberg <[email protected]>; Shyam Prasad N <[email protected]>; Tom Talpey <[email protected]>; Bharath SM <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Manthey, Norbert <[email protected]>; linux-fsdevel <[email protected]>
Subject: RE: [EXTERNAL] [PATCH] smb: client: setSB_I_NODEVto prevent device node injectionCAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
Setting
SB_I_NODEVis 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_NODEVis 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 sets_iflagsbecause almost none of the SB_I_* flags are intended as generic filesystem capability flags. They're mostly internal VFS state, andSB_I_NODEVin particular has a very specific purpose.SB_I_NODEVdoes 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 structblock_devicefor this superblock."Has something changed? How did this question about
SB_I_NODEVcome up?Quoted 30 lines · Bjoern Doebel
From: Norbert Manthey <[email protected]>
Set
SB_I_NODEVon 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 <[email protected]>Assisted-by Kiro:claude-opus-4.6--- fs/smb/client/cifsfs.c | 3 +++ 1 file changed, 3 insertions(+)fs/smb/client/cifsfs.c +3
-1@@ -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 ; --Quoted 3 lines
2.50.1
--
Thanks,Steve
Signature · 3 lines
Thanks, Steve
This is likely. We did not investigate the other file systems. We've been looking specifically into CIFS. As I am not a file system expert, I'd appreciate help and guidance from experts on this.
Thanks,
Norbert
________________________________________
From: Steve French <[email protected]>
Sent: Tuesday, July 14, 2026 11:43 PM
To: Manthey, Norbert <[email protected]>
Cc: Doebel, Bjoern <[email protected]>; Paulo Alcantara <[email protected]>; Ronnie Sahlberg <[email protected]>; Shyam Prasad N <[email protected]>; Tom Talpey <[email protected]>; Bharath SM <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; linux-fsdevel <[email protected]>; David Howells <[email protected]>
Subject: RE: [EXTERNAL] [PATCH] smb: client: set SB_I_NODEV to prevent device node injection
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
If this is needed for cifs.ko wouldn't this also be needed for AFS, NFS, CEPH and others?
Quoted 92 lines · Norbert
Hi Steve,
The issue is that the client takes the device node's mode straight from the server. So a malicious/compromised SMB server can define a device node (type + major/minor + permissions) on the client that the admin never created and cannot otherwise constrain -- the only knob left to block it is the "nodev" mount option. That's why we introduce the change using
SB_I_NODEVhere.We did analyze the CIFS code, and found this missing security checks. We have a reproducer that allows a malicious server and local user to elevate privileges by introducing a new device in the mount.
Best,
Norbert________________________________________
From: Steve French <[email protected]>
Sent: Thursday, July 9, 2026 7:20 PM
To: Doebel, Bjoern <[email protected]>
Cc: Paulo Alcantara <[email protected]>; Ronnie Sahlberg <[email protected]>; Shyam Prasad N <[email protected]>; Tom Talpey <[email protected]>; Bharath SM <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Manthey, Norbert <[email protected]>; linux-fsdevel <[email protected]>
Subject: RE: [EXTERNAL] [PATCH] smb: client: setSB_I_NODEVto prevent device node injectionCAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
Setting
SB_I_NODEVis 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_NODEVis 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 sets_iflagsbecause almost none of the SB_I_* flags are intended as generic filesystem capability flags. They're mostly internal VFS state, andSB_I_NODEVin particular has a very specific purpose.SB_I_NODEVdoes 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 structblock_devicefor this superblock."Has something changed? How did this question about
SB_I_NODEVcome up?Quoted 30 lines · Bjoern Doebel
From: Norbert Manthey <[email protected]>
Set
SB_I_NODEVon 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 <[email protected]>Assisted-by Kiro:claude-opus-4.6---
fs/smb/client/cifsfs.c| 3 +++1 file changed, 3 insertions(+)fs/smb/client/cifsfs.c +3
-1@@ -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; --Quoted 3 lines
2.50.1
--
Thanks,
Quoted 1 line
Steve
--
Thanks,
Steve