From: "Pali Rohár" <pali@kernel.org>
To: Steve French <sfrench@samba.org>,
Paulo Alcantara <pc@manguebit.com>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>
Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/7] cifs: Fix creating of SFU fifo and socket special files
Date: Fri, 13 Sep 2024 22:07:21 +0200 [thread overview]
Message-ID: <20240913200721.7egunkwp76qo5yy7@pali> (raw)
In-Reply-To: <20240912120548.15877-7-pali@kernel.org>
On Thursday 12 September 2024 14:05:47 Pali Rohár wrote:
> 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).
>
> 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.
>
> Currently when sfu mount option is specified then CIFS creates fifo and
> socket special files with some strange LnxSOCK or LnxFIFO content which is
> not compatible with Microsoft SFU and neither recognized by other SMB
> implementations which have some SFU support, including older Linux cifs
> implementations.
>
> So when sfu mount option is specified, create all fifo and socket special
> files compatible with SFU format to achieve SFU interop, as it is expected
> by sfu mount option.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
Fixes: 72bc63f5e23a ("smb3: fix creating FIFOs when mounting with "sfu" mount option")
Fixes: 518549c120e6 ("cifs: fix creating sockets when using sfu mount options")
I located commits which introduced those strange LnxSOCK or LnxFIFO
types which are not compatible with SFU. I would suggest to add those
two Fixes: tags into commit message for reference.
> ---
> fs/smb/client/cifssmb.c | 8 ++++----
> fs/smb/client/smb1ops.c | 2 +-
> fs/smb/client/smb2ops.c | 29 +++++++++++++++++++----------
> 3 files changed, 24 insertions(+), 15 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 9c2d065d3cc4..9e90672caf60 100644
> --- a/fs/smb/client/smb2ops.c
> +++ b/fs/smb/client/smb2ops.c
> @@ -5066,26 +5066,32 @@ static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode,
> struct cifs_fid fid;
> unsigned int bytes_written;
> struct win_dev pdev = {};
> + size_t pdev_len = 0;
> struct kvec iov[2];
> __u32 oplock = server->oplocks ? REQ_OPLOCK : 0;
> int rc;
>
> switch (mode & S_IFMT) {
> case S_IFCHR:
> + pdev_len = sizeof(pdev);
> memcpy(pdev.type, "IntxCHR\0", 8);
> pdev.major = cpu_to_le64(MAJOR(dev));
> pdev.minor = cpu_to_le64(MINOR(dev));
> break;
> case S_IFBLK:
> + pdev_len = sizeof(pdev);
> memcpy(pdev.type, "IntxBLK\0", 8);
> pdev.major = cpu_to_le64(MAJOR(dev));
> pdev.minor = cpu_to_le64(MINOR(dev));
> break;
> case S_IFSOCK:
> - strscpy(pdev.type, "LnxSOCK");
> + /* SFU socket is system file with one zero byte */
> + pdev_len = 1;
> + pdev.type[0] = '\0';
> break;
> case S_IFIFO:
> - strscpy(pdev.type, "LnxFIFO");
> + /* SFU fifo is system file which is empty */
> + pdev_len = 0;
> break;
> default:
> return -EPERM;
> @@ -5100,14 +5106,17 @@ static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode,
> if (rc)
> return rc;
>
> - 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 (pdev_len > 0) {
> + io_parms.pid = current->tgid;
> + io_parms.tcon = tcon;
> + io_parms.length = pdev_len;
> + iov[1].iov_base = &pdev;
> + iov[1].iov_len = pdev_len;
> +
> + rc = server->ops->sync_write(xid, &fid, &io_parms,
> + &bytes_written, iov, 1);
> + }
>
> - rc = server->ops->sync_write(xid, &fid, &io_parms,
> - &bytes_written, iov, 1);
> server->ops->close(xid, tcon, &fid);
> return rc;
> }
> @@ -5149,7 +5158,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) {
> --
> 2.20.1
>
next prev parent reply other threads:[~2024-09-13 20:07 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-12 12:05 [PATCH 0/7] cifs: Improve client SFU support for special files Pali Rohár
2024-09-12 12:05 ` [PATCH 1/7] cifs: Fix recognizing SFU symlinks Pali Rohár
2024-09-13 20:04 ` Pali Rohár
2024-09-12 12:05 ` [PATCH 2/7] cifs: Add support for reading SFU symlink location Pali Rohár
2024-09-12 12:05 ` [PATCH 3/7] cifs: Put explicit zero byte into SFU block/char types Pali Rohár
2024-09-12 12:05 ` [PATCH 4/7] cifs: Show debug message when SFU Fifo type was detected Pali Rohár
2024-09-12 12:05 ` [PATCH 5/7] cifs: Recognize SFU socket type Pali Rohár
2024-09-12 12:05 ` [PATCH 6/7] cifs: Fix creating of SFU fifo and socket special files Pali Rohár
2024-09-13 20:07 ` Pali Rohár [this message]
2024-09-13 22:14 ` Steve French
2024-09-13 22:33 ` Steve French
2024-09-13 22:45 ` Pali Rohár
2024-09-13 22:42 ` Pali Rohár
2024-09-14 6:21 ` Steve French
2024-09-14 8:17 ` Pali Rohár
2024-09-15 17:41 ` Pali Rohár
[not found] ` <CAH2r5muXcyMxc=F2WsTtwQyKZ9TL64TWEBzX7bXJqZky2g0TzA@mail.gmail.com>
2024-09-15 17:48 ` Pali Rohár
2024-09-16 16:23 ` Pali Rohár
2024-09-16 12:51 ` Volker Lendecke
2024-09-16 16:31 ` Pali Rohár
2024-09-15 19:45 ` [PATCH 0/4] cifs: Improve client SFU support for special files (2) Pali Rohár
2024-09-15 19:45 ` [PATCH 1/4] cifs: Add support for creating SFU symlinks Pali Rohár
2024-09-15 21:15 ` Steve French
2024-09-27 17:54 ` Enzo Matsumiya
2024-09-27 18:11 ` Pali Rohár
2024-09-15 19:45 ` [PATCH 2/4] cifs: Fix creating of SFU socket special files Pali Rohár
2024-09-15 19:45 ` [PATCH 3/4] cifs: Fix creating of SFU fifo " Pali Rohár
2024-09-15 19:45 ` [PATCH 4/4] cifs: Update SFU comments about fifos and sockets Pali Rohár
2024-09-15 21:14 ` Steve French
2024-09-12 12:05 ` [PATCH 7/7] cifs: Add support for creating SFU symlinks Pali Rohár
2024-09-13 3:44 ` [PATCH 0/7] cifs: Improve client SFU support for special files Steve French
2024-09-13 7:42 ` Pali Rohár
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240913200721.7egunkwp76qo5yy7@pali \
--to=pali@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.com \
--cc=ronniesahlberg@gmail.com \
--cc=sfrench@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox