1 From 8767cb3fbd514c4cf85b4f516ca30388e846f540 Mon Sep 17 00:00:00 2001
2 From: Steve French <stfrench@microsoft.com>
3 Date: Mon, 14 Jul 2025 22:16:19 -0500
4 Subject: Fix SMB311 posix special file creation to servers which do not advertise reparse support
6 From: Steve French <stfrench@microsoft.com>
8 commit 8767cb3fbd514c4cf85b4f516ca30388e846f540 upstream.
10 Some servers (including Samba), support the SMB3.1.1 POSIX Extensions (which use reparse
11 points for handling special files) but do not properly advertise file system attribute
12 FILE_SUPPORTS_REPARSE_POINTS. Although we don't check for this attribute flag when
13 querying special file information, we do check it when creating special files which
14 causes them to fail unnecessarily. If we have negotiated SMB3.1.1 POSIX Extensions
15 with the server we can expect the server to support creating special files via
16 reparse points, and even if the server fails the operation due to really forbidding
17 creating special files, then it should be no problem and is more likely to return a
18 more accurate rc in any case (e.g. EACCES instead of EOPNOTSUPP).
20 Allow creating special files as long as the server supports either reparse points
21 or the SMB3.1.1 POSIX Extensions (note that if the "sfu" mount option is specified
22 it uses a different way of storing special files that does not rely on reparse points).
24 Cc: <stable@vger.kernel.org>
25 Fixes: 6c06be908ca19 ("cifs: Check if server supports reparse points before using them")
26 Acked-by: Ralph Boehme <slow@samba.org>
27 Acked-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
28 Signed-off-by: Steve French <stfrench@microsoft.com>
29 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31 fs/smb/client/smb2inode.c | 3 ++-
32 fs/smb/client/smb2ops.c | 3 ++-
33 2 files changed, 4 insertions(+), 2 deletions(-)
35 --- a/fs/smb/client/smb2inode.c
36 +++ b/fs/smb/client/smb2inode.c
37 @@ -1346,7 +1346,8 @@ struct inode *smb2_get_reparse_inode(str
38 * empty object on the server.
40 if (!(le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS))
41 - return ERR_PTR(-EOPNOTSUPP);
42 + if (!tcon->posix_extensions)
43 + return ERR_PTR(-EOPNOTSUPP);
45 oparms = CIFS_OPARMS(cifs_sb, tcon, full_path,
46 SYNCHRONIZE | DELETE |
47 --- a/fs/smb/client/smb2ops.c
48 +++ b/fs/smb/client/smb2ops.c
49 @@ -5246,7 +5246,8 @@ static int smb2_make_node(unsigned int x
50 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
51 rc = cifs_sfu_make_node(xid, inode, dentry, tcon,
52 full_path, mode, dev);
53 - } else if (le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS) {
54 + } else if ((le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS)
55 + || (tcon->posix_extensions)) {
56 rc = smb2_mknod_reparse(xid, inode, dentry, tcon,
57 full_path, mode, dev);