[PATCH 2/4] cifs: Fix creating of SFU socket special files

Pali Rohár posted 4 patches 2 months, 2 weeks ago
[PATCH 2/4] cifs: Fix creating of SFU socket special files
Posted by Pali Rohár 2 months, 2 weeks ago
SFU-style socket is file which has system attribute set and file content is
one zero byte. This format was introduced in Interix 3.0 subsystem, as part
of the Microsoft SFU 3.0 and is used also by all later versions. Previous
versions had no UNIX domain socket support.

This format of SFU-style sockets is recognized also by Windows NFS server
included in the latest version on Windows Server 2022.

Currently when sfu mount option is specified then CIFS creates new socket
files with content LnxSOCK. This was introduced in commit 518549c120e6
("cifs: fix creating sockets when using sfu mount options") as nobody
figured out what is the correct SFU format of sockets and tag LnxSOCK was
chosen to allow creating socket files. LnxSOCK looks similar to IntxCHR and
IntxBLK tags which are the proper SFU tags for char and block devices.

It is important to note that LnxSOCK is not SFU-compatible and neither
Interix, SFU, SUA or Windows NFS server recognize file with content of
LnxSOCK as special socket file.

Now when the proper format of SFU-style sockets is known and it was
verified that works with both old Interix 3.x subsystem and also with
Windows NFS server, change implementation of creating new SFU socket files
by CIFS client to be compatible with SFU.

518549c120e6 ("cifs: fix creating sockets when using sfu mount options")
Signed-off-by: Pali Rohár <pali@kernel.org>
---
 fs/smb/client/smb2ops.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 2c251e9a3a30..dc56f7ba1a06 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -5110,10 +5110,9 @@ int __cifs_sfu_make_node(unsigned int xid, struct inode *inode,
 		data = (u8 *)symname_utf16;
 		break;
 	case S_IFSOCK:
-		type_len = 8;
-		strscpy(type, "LnxSOCK");
-		data = (u8 *)&pdev;
-		data_len = sizeof(pdev);
+		/* SFU socket is system file with one zero byte */
+		type_len = 1;
+		type[0] = '\0';
 		break;
 	case S_IFIFO:
 		type_len = 8;
-- 
2.20.1