From patchwork Sun Sep 15 19:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 13804898 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DCC91C9ED7; Sun, 15 Sep 2024 19:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726429556; cv=none; b=krz3t04OiN8WX/4tuKHhcm6+IONSq9dNaTda68n2juIoyG4sx+vyeQcArU0Ac3rDwG5YyF75VikAh4mLZp4R4fBm53azbhxY/gtBYTi0of3yufBlUuPIwqq2C2oTKiMBmjIyxqydBQ4I6tOtVkQnNMn8Xy3xSxMQnUMV5Oz8Jl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726429556; c=relaxed/simple; bh=0jXRDe3Au5vgW5gbMHbJSVYKmeRM43vkNYMJ7QYDdW8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=LTG6WT7xqTZc3xKeem6rZ10m48O7WVamcUQH01V3JrYCUxJ5jMPLkzd/W2Hh2dpKavV9fuKkZTAP17sNdF0wnk2W/D7qZKVU2eflmX+so/HxKO2kY0Da/lGpr2zkK1/VHYpfQGZExEOLKddahOx/tL3QaOn+oyC6xzOwLUzZPVc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nc+N9+mR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nc+N9+mR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 708FDC4CECD; Sun, 15 Sep 2024 19:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726429555; bh=0jXRDe3Au5vgW5gbMHbJSVYKmeRM43vkNYMJ7QYDdW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nc+N9+mRNT+YnIuYBU6n+ZhuV5RMmL2YkflcN83FpFXjESO5+LStli6RNyWUBu2Lc hsQEOJzeFsM+ARMnGPEAd1rWhbvcxbeetXfZtmhIHT4fPPyFtLVTHTm0h2oTE6e8Qb 6Gi4FCzDO6ZUZg0Dpx6W+ydEkVa/Rk/UbkCxFRnYzMzN/fxDzDWXsbj/kn/MKMCOlw wzwvlScZ1QCH4To79uJNEJNJsALgI+XnS6bJsDTRUCscUT4mHPh9gCv3qmFVdEc6Fs DA0SlnbByBON9wCH6I7HhH7yLaELGd3z5R7V+v5t6KBGmJD2Mv+hE4dztKnOy92lEH Er608WYL024Ag== Received: by pali.im (Postfix) id 4B7E6A7F; Sun, 15 Sep 2024 21:45:50 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] cifs: Add support for creating SFU symlinks Date: Sun, 15 Sep 2024 21:45:42 +0200 Message-Id: <20240915194545.14779-2-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240915194545.14779-1-pali@kernel.org> References: <20240912120548.15877-7-pali@kernel.org> <20240915194545.14779-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Linux cifs client can already detect SFU symlinks and reads it content (target location). But currently is not able to create new symlink. So implement this missing support. When 'sfu' mount option is specified and 'mfsymlinks' is not specified then create new symlinks in SFU-style. This will provide full SFU compatibility of symlinks when mounting cifs share with 'sfu' option. 'mfsymlinks' option override SFU for better Apple compatibility as explained in fs_context.c file in smb3_update_mnt_flags() function. Extend __cifs_sfu_make_node() function, which now can handle also S_IFLNK type and refactor structures passed to sync_write() in this function, by splitting SFU type and SFU data from original combined struct win_dev as combined fixed-length struct cannot be used for variable-length symlinks. Signed-off-by: Pali Rohár --- fs/smb/client/cifspdu.h | 6 --- fs/smb/client/cifsproto.h | 4 ++ fs/smb/client/fs_context.c | 13 ++++--- fs/smb/client/link.c | 3 ++ fs/smb/client/smb2ops.c | 80 +++++++++++++++++++++++++++++--------- 5 files changed, 77 insertions(+), 29 deletions(-) diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h index a2072ab9e586..c3b6263060b0 100644 --- a/fs/smb/client/cifspdu.h +++ b/fs/smb/client/cifspdu.h @@ -2573,12 +2573,6 @@ typedef struct { } __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */ -struct win_dev { - unsigned char type[8]; /* IntxCHR or IntxBLK or LnxFIFO or LnxSOCK */ - __le64 major; - __le64 minor; -} __attribute__((packed)); - struct fea { unsigned char EA_flags; __u8 name_len; diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h index 497bf3c447bc..791bddac0396 100644 --- a/fs/smb/client/cifsproto.h +++ b/fs/smb/client/cifsproto.h @@ -676,6 +676,10 @@ char *extract_sharename(const char *unc); int parse_reparse_point(struct reparse_data_buffer *buf, u32 plen, struct cifs_sb_info *cifs_sb, bool unicode, struct cifs_open_info_data *data); +int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, + struct dentry *dentry, struct cifs_tcon *tcon, + const char *full_path, umode_t mode, dev_t dev, + const char *symname); int cifs_sfu_make_node(unsigned int xid, struct inode *inode, struct dentry *dentry, struct cifs_tcon *tcon, const char *full_path, umode_t mode, dev_t dev); diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c index bc926ab2555b..2f0c3894b0f7 100644 --- a/fs/smb/client/fs_context.c +++ b/fs/smb/client/fs_context.c @@ -1896,14 +1896,17 @@ void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb) if (ctx->mfsymlinks) { if (ctx->sfu_emul) { /* - * Our SFU ("Services for Unix" emulation does not allow - * creating symlinks but does allow reading existing SFU - * symlinks (it does allow both creating and reading SFU - * style mknod and FIFOs though). When "mfsymlinks" and + * Our SFU ("Services for Unix") emulation allows now + * creating new and reading existing SFU symlinks. + * Older Linux kernel versions were not able to neither + * read existing nor create new SFU symlinks. But + * creating and reading SFU style mknod and FIFOs was + * supported for long time. When "mfsymlinks" and * "sfu" are both enabled at the same time, it allows * reading both types of symlinks, but will only create * them with mfsymlinks format. This allows better - * Apple compatibility (probably better for Samba too) + * Apple compatibility, compatibility with older Linux + * kernel clients (probably better for Samba too) * while still recognizing old Windows style symlinks. */ cifs_dbg(VFS, "mount options mfsymlinks and sfu both enabled\n"); diff --git a/fs/smb/client/link.c b/fs/smb/client/link.c index 80099bbb333b..47ddeb7fa111 100644 --- a/fs/smb/client/link.c +++ b/fs/smb/client/link.c @@ -606,6 +606,9 @@ cifs_symlink(struct mnt_idmap *idmap, struct inode *inode, /* BB what if DFS and this volume is on different share? BB */ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) { rc = create_mf_symlink(xid, pTcon, cifs_sb, full_path, symname); + } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { + rc = __cifs_sfu_make_node(xid, inode, direntry, pTcon, + full_path, S_IFLNK, 0, symname); #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY } else if (pTcon->unix_ext) { rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname, diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 9c2d065d3cc4..2c251e9a3a30 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -5055,9 +5055,10 @@ static int smb2_next_header(struct TCP_Server_Info *server, char *buf, return 0; } -static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, +int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, struct dentry *dentry, struct cifs_tcon *tcon, - const char *full_path, umode_t mode, dev_t dev) + const char *full_path, umode_t mode, dev_t dev, + const char *symname) { struct TCP_Server_Info *server = tcon->ses->server; struct cifs_open_parms oparms; @@ -5065,30 +5066,64 @@ static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); struct cifs_fid fid; unsigned int bytes_written; - struct win_dev pdev = {}; - struct kvec iov[2]; + u8 type[8]; + int type_len = 0; + struct { + __le64 major; + __le64 minor; + } __packed pdev = {}; + __le16 *symname_utf16 = NULL; + u8 *data = NULL; + int data_len = 0; + struct kvec iov[3]; __u32 oplock = server->oplocks ? REQ_OPLOCK : 0; int rc; switch (mode & S_IFMT) { case S_IFCHR: - memcpy(pdev.type, "IntxCHR\0", 8); + type_len = 8; + memcpy(type, "IntxCHR\0", type_len); pdev.major = cpu_to_le64(MAJOR(dev)); pdev.minor = cpu_to_le64(MINOR(dev)); + data = (u8 *)&pdev; + data_len = sizeof(pdev); break; case S_IFBLK: - memcpy(pdev.type, "IntxBLK\0", 8); + type_len = 8; + memcpy(type, "IntxBLK\0", type_len); pdev.major = cpu_to_le64(MAJOR(dev)); pdev.minor = cpu_to_le64(MINOR(dev)); + data = (u8 *)&pdev; + data_len = sizeof(pdev); + break; + case S_IFLNK: + type_len = 8; + memcpy(type, "IntxLNK\1", type_len); + symname_utf16 = cifs_strndup_to_utf16(symname, strlen(symname), + &data_len, cifs_sb->local_nls, + NO_MAP_UNI_RSVD); + if (!symname_utf16) { + rc = -ENOMEM; + goto out; + } + data_len -= 2; /* symlink is without trailing wide-nul */ + data = (u8 *)symname_utf16; break; case S_IFSOCK: - strscpy(pdev.type, "LnxSOCK"); + type_len = 8; + strscpy(type, "LnxSOCK"); + data = (u8 *)&pdev; + data_len = sizeof(pdev); break; case S_IFIFO: - strscpy(pdev.type, "LnxFIFO"); + type_len = 8; + strscpy(type, "LnxFIFO"); + data = (u8 *)&pdev; + data_len = sizeof(pdev); break; default: - return -EPERM; + rc = -EPERM; + goto out; } oparms = CIFS_OPARMS(cifs_sb, tcon, full_path, GENERIC_WRITE, @@ -5098,17 +5133,26 @@ static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, rc = server->ops->open(xid, &oparms, &oplock, NULL); if (rc) - return rc; + goto out; - io_parms.pid = current->tgid; - io_parms.tcon = tcon; - io_parms.length = sizeof(pdev); - iov[1].iov_base = &pdev; - iov[1].iov_len = sizeof(pdev); + if (type_len + data_len > 0) { + io_parms.pid = current->tgid; + io_parms.tcon = tcon; + io_parms.length = type_len + data_len; + iov[1].iov_base = type; + iov[1].iov_len = type_len; + iov[2].iov_base = data; + iov[2].iov_len = data_len; + + rc = server->ops->sync_write(xid, &fid, &io_parms, + &bytes_written, + iov, ARRAY_SIZE(iov)-1); + } - rc = server->ops->sync_write(xid, &fid, &io_parms, - &bytes_written, iov, 1); server->ops->close(xid, tcon, &fid); + +out: + kfree(symname_utf16); return rc; } @@ -5120,7 +5164,7 @@ int cifs_sfu_make_node(unsigned int xid, struct inode *inode, int rc; rc = __cifs_sfu_make_node(xid, inode, dentry, tcon, - full_path, mode, dev); + full_path, mode, dev, NULL); if (rc) return rc; From patchwork Sun Sep 15 19:45:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 13804896 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DC231C9EA0; Sun, 15 Sep 2024 19:45:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726429556; cv=none; b=WfcMVDJyor8f34s1YOSScWVMT6ZkMyT6jZRhI8x8a1IUNVa7F6dsnf9Fz8AL+czJJe+37tB59hPlN8XX4rmRlkznhutDr4FvXFLMoe+wVQrR51WbIlpza3mfIjmCJz6nnQYiUqkACa/xZY65AbV3CyRw4YWA28QDDqiY+JtWslo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726429556; c=relaxed/simple; bh=Xk4iAldMeXrsBRjhfpmL+ofisAHqsPO1bT9HypUneR0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=VymC58eMRyb8Dr671byDowcM4Ac1XEl/PpM6GC4jfmbgqaekiHErk2+MNxXLx/NxFmwRNy233TQ8yBi3kGGPZtdSr6YTBRWjvAYPhg1dNrar8Eb2g9MR5R7BErXPJa5/ovah2GEKI41/DYT9M2XNQbGH0oQgM6uQ+s33XeihX/w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z8O8uxMO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z8O8uxMO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C724CC4CECE; Sun, 15 Sep 2024 19:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726429555; bh=Xk4iAldMeXrsBRjhfpmL+ofisAHqsPO1bT9HypUneR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z8O8uxMO5LzitVzM2QOD6zGTfdPNeaF3dbzvdyb9qaJ34Nw2Ao237SzAMA3FDQ2g2 +buruNCYfBtLbZE77m7ZS5YDCIOVSxebSMGe7nXyo6cpqaX+U2FYraESTeo5NVHMxY ltIoxg9qDUTVRwXN4QMkgaTrclm77TK49s3WF9XNW2E8b0A2/4vjmPuSPWlxgXvIGa Kvw55aUeaNzsDUfTEIgm2sEB7WG3dBk7ekXwKIG6xOpOoU/OS6XortbjeJdgGXllFA LDoHicuFqdtv6y2cUNfwnuYBujXH/xHgBLpEICocb/xie772bMie9SzliOUcGlVVuq ofBpt0aS1UOBA== Received: by pali.im (Postfix) id 784BEB45; Sun, 15 Sep 2024 21:45:50 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] cifs: Fix creating of SFU socket special files Date: Sun, 15 Sep 2024 21:45:43 +0200 Message-Id: <20240915194545.14779-3-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240915194545.14779-1-pali@kernel.org> References: <20240912120548.15877-7-pali@kernel.org> <20240915194545.14779-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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; From patchwork Sun Sep 15 19:45:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 13804899 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95E981CB33F; Sun, 15 Sep 2024 19:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726429557; cv=none; b=ZLld/FBNZ1dRa7khDpL7T8nAT7UkxVyCRRUVRus5LkVqlp+gk4ZvzFgUB0qyL85Zj6GiOGgHXOaaWeV2v9lIW5NkCvxAVXkaZePwQ+Znib69um+mXY5eIBwLVvvKUdFZXGpi3AqfuyIhuIF2TN9YmLuXmlU4GKWb7GT0N0ZTKTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726429557; c=relaxed/simple; bh=vp0tJ6174kqd3NVUVhvDpzmPnqU1dZ9ivhzYz0EgvRg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=J0z19SG6VgTZM4X2s+Qxt7MvQqWi0VcZl+pAYN0dmFTYCtsVk8fwA2KLg8nRBeXdGqgXoz+Coxtw0vvYOacQPqawzW9Poqv3tWvUqyUK/H+aKG7WCo2NEvqVfk4fUDgCOH88j63Gaz0cp8wSM7NyJJQ49ZHFkqP8WNCS7yWyEPY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NncchzfX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NncchzfX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48262C4CED5; Sun, 15 Sep 2024 19:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726429557; bh=vp0tJ6174kqd3NVUVhvDpzmPnqU1dZ9ivhzYz0EgvRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NncchzfXBhzIL1H6QsMnTVqt20Tf+Mvl2i/x8S+kZrP4igs/uZkRxEJAlAwOSJ7UF jn26aUwkdkJ32boLMFLIUIiXm56cgsxHumfCHQH12bmUvGH1i6vE9oHzlAVHItCsi4 bHWZdAdvW37GvGhBdixW7CK8uMzXu3YuOSkuW+MdizPzBqSbXz+pb9ExZXz6Fj4Mvm bHn7XmLaVDEFmmujM1U3GDf74CLOeqP2j4wwde34ZBOJBhf/tlz6PXuWSwf/GNmtnQ NDndFTmHVBtp7mS9fy8pWmpUit85sAlnslfAEDu9CDqbeuIFGVw+mIE27KQ8GpGzvF xmsv3jGC/7i7g== Received: by pali.im (Postfix) id A470CCB5; Sun, 15 Sep 2024 21:45:50 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] cifs: Fix creating of SFU fifo special files Date: Sun, 15 Sep 2024 21:45:44 +0200 Message-Id: <20240915194545.14779-4-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240915194545.14779-1-pali@kernel.org> References: <20240912120548.15877-7-pali@kernel.org> <20240915194545.14779-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 SFU-style fifo is empty file with system attribute set. This format is used by old Microsoft POSIX subsystem and later also by OpenNT/Interix subsystem (which replaced Microsoft POSIX subsystem and is part of Microsoft SFU). This format of SFU-style fifos 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 fifo files with content LnxFIFO. This was introduced in commit 72bc63f5e23a ("smb3: fix creating FIFOs when mounting with "sfu" mount option"). It is important to note that LnxFIFO is not SFU-compatible and neither Interix, SFU, SUA or Windows NFS server recognize file with content of LnxFIFO as special fifo file. So when sfu mount option is specified, fix this problem and create all fifo special files compatible with SFU format, as it is expected by sfu mount option. This allows interoperability with other SFU implementations and also with Windows NFS server. Fixes: 72bc63f5e23a ("smb3: fix creating FIFOs when mounting with "sfu" mount option") Signed-off-by: Pali Rohár --- fs/smb/client/smb2ops.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index dc56f7ba1a06..406f2399f0c5 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -5115,10 +5115,8 @@ int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, type[0] = '\0'; break; case S_IFIFO: - type_len = 8; - strscpy(type, "LnxFIFO"); - data = (u8 *)&pdev; - data_len = sizeof(pdev); + /* SFU fifo is system file which is empty */ + type_len = 0; break; default: rc = -EPERM; From patchwork Sun Sep 15 19:45:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 13804897 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DC761C9ED4; Sun, 15 Sep 2024 19:45:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726429556; cv=none; b=R3KJtWn8mt6oNwQBSjceF99os19FGUgi7tWYSSw1PH8TzyehuvbM24/oGGyqNo5m1wTBA7659vdu2thH5wPpd5OZtJ1SClVA5JcBy5jAR5quKQ5vCNyal81+khA3DuThLUhskxBzLOcMhwCYmmmmG7SAZ/DD/rB/aOnne11kMHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726429556; c=relaxed/simple; bh=kBgkdFHz49MetJQnsWgzyt5qwDabg4EPCDFgVX9Fd7Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=MP85BLlAx8dmKt0pQIOGVW27536ygn3931oyaB1i9uqNPZv3W6Z/Ij08kpF4LhPAWyNsEetYoDOJCjVfr/xg2M63LivwtjwRIVFt4jKtLybFbClU+Ne4KAiy86T0qOBVn9xzRqliPA2KjUm4wOM7g8zHfrOoiqDypyDmIn4aR4U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m1RFBc2M; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m1RFBc2M" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4450C4CEC4; Sun, 15 Sep 2024 19:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726429555; bh=kBgkdFHz49MetJQnsWgzyt5qwDabg4EPCDFgVX9Fd7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m1RFBc2MUpHdJC1UPwLj4Q6AX5/Uob9B6IXOkWM/kTUE/W+JS3ZeHm/AxNonH/1WM vxdm1bI3oGJtHW7sxfk6XBhBN9+HrEs+BrNyW3yIBSHOozJ8eDPAeCM+gTTAy46Bns dauosbwjKnsvuffml8t/Ff1BvRsOdRKQO0g6W6Pwx4rRbRXfruoJVKEc0VU7MIjkGc GjdcVyBnHVqgPPDDvmIqFf0A6CKs0ukO/4DPzDSu3+kOck2l0wJ5DTJVU4fqSicSXE TL2GsJkzFXfWmdMJUnhPARaReGepihqjmnM/JFfspAb1r8L92J/5SzG1n95UpBhDhi fOFE5atVgWO/w== Received: by pali.im (Postfix) id CF0F9CF3; Sun, 15 Sep 2024 21:45:50 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] cifs: Update SFU comments about fifos and sockets Date: Sun, 15 Sep 2024 21:45:45 +0200 Message-Id: <20240915194545.14779-5-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240915194545.14779-1-pali@kernel.org> References: <20240912120548.15877-7-pali@kernel.org> <20240915194545.14779-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In SFU mode, activated by -o sfu mount option is now also support for creating new fifos and sockets. Signed-off-by: Pali Rohár --- fs/smb/client/cifssmb.c | 8 ++++---- fs/smb/client/smb1ops.c | 2 +- fs/smb/client/smb2ops.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c index cfae2e918209..0ffc45aa5e2c 100644 --- a/fs/smb/client/cifssmb.c +++ b/fs/smb/client/cifssmb.c @@ -1076,8 +1076,8 @@ SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon, pSMB->OpenFlags |= cpu_to_le16(REQ_MORE_INFO); pSMB->Mode = cpu_to_le16(access_flags_to_smbopen_mode(access_flags)); pSMB->Mode |= cpu_to_le16(0x40); /* deny none */ - /* set file as system file if special file such - as fifo and server expecting SFU style and + /* set file as system file if special file such as fifo, + * socket, char or block and server expecting SFU style and no Unix extensions */ if (create_options & CREATE_OPTION_SPECIAL) @@ -1193,8 +1193,8 @@ CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, int *oplock, req->AllocationSize = 0; /* - * Set file as system file if special file such as fifo and server - * expecting SFU style and no Unix extensions. + * Set file as system file if special file such as fifo, socket, char + * or block and server expecting SFU style and no Unix extensions. */ if (create_options & CREATE_OPTION_SPECIAL) req->FileAttributes = cpu_to_le32(ATTR_SYSTEM); diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c index e1f2feb56f45..e03c91a49650 100644 --- a/fs/smb/client/smb1ops.c +++ b/fs/smb/client/smb1ops.c @@ -1078,7 +1078,7 @@ cifs_make_node(unsigned int xid, struct inode *inode, /* * Check if mounted with mount parm 'sfu' mount parm. * SFU emulation should work with all servers, but only - * supports block and char device (no socket & fifo), + * supports block and char device, socket & fifo, * and was used by default in earlier versions of Windows */ if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 406f2399f0c5..d30f7cab197e 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -5190,7 +5190,7 @@ static int smb2_make_node(unsigned int xid, struct inode *inode, /* * Check if mounted with mount parm 'sfu' mount parm. * SFU emulation should work with all servers, but only - * supports block and char device (no socket & fifo), + * supports block and char device, socket & fifo, * and was used by default in earlier versions of Windows */ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {