Native Windows sockets created by WinSock on Windows 10 April 2018 Update
(version 1803) or Windows Server 2019 (version 1809) or later versions is
reparse point with IO_REPARSE_TAG_AF_UNIX tag, with empty reparse point
data buffer and without any EAs.
Create AF_UNIX sockets in this native format when -o reparse=native or
-o reparse=native+<something> mount option is used.
This change makes AF_UNIX sockets created by Linux CIFS client compatible
with AF_UNIX sockets created by Windows applications on NTFS volumes.
Signed-off-by: Pali Rohár <pali@kernel.org>
---
fs/smb/client/cifsglob.h | 6 +++---
fs/smb/client/reparse.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 7632d2ba5390..570b22d02f7e 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -155,9 +155,9 @@ enum securityEnum {
enum cifs_reparse_type {
CIFS_REPARSE_TYPE_NONE, /* disable creating new reparse points */
- CIFS_REPARSE_TYPE_NATIVE, /* native symlinks only */
- CIFS_REPARSE_TYPE_NATIVE_NFS, /* native for symlinks, nfs for others */
- CIFS_REPARSE_TYPE_NATIVE_WSL, /* native for symlinks, wsl for others */
+ CIFS_REPARSE_TYPE_NATIVE, /* native symlinks and sockets only, no support for others */
+ CIFS_REPARSE_TYPE_NATIVE_NFS, /* native for symlinks/sockets, nfs for fifos/block/char */
+ CIFS_REPARSE_TYPE_NATIVE_WSL, /* native for symlinks/sockets, wsl for fifos/block/char */
CIFS_REPARSE_TYPE_NFS, /* nfs for everything */
CIFS_REPARSE_TYPE_WSL, /* wsl for everything */
CIFS_REPARSE_TYPE_DEFAULT = CIFS_REPARSE_TYPE_NATIVE_NFS,
diff --git a/fs/smb/client/reparse.c b/fs/smb/client/reparse.c
index 38fe0a710c65..f1488f870320 100644
--- a/fs/smb/client/reparse.c
+++ b/fs/smb/client/reparse.c
@@ -379,6 +379,35 @@ static int detect_directory_symlink_target(struct cifs_sb_info *cifs_sb,
return 0;
}
+static int create_native_socket(const unsigned int xid, struct inode *inode,
+ struct dentry *dentry, struct cifs_tcon *tcon,
+ const char *full_path)
+{
+ struct cifs_open_info_data data = {
+ .reparse_point = true,
+ .reparse = { .tag = IO_REPARSE_TAG_AF_UNIX, },
+ };
+ struct reparse_data_buffer buf = {
+ .ReparseTag = cpu_to_le32(IO_REPARSE_TAG_AF_UNIX),
+ .ReparseDataLength = 0,
+ };
+ struct kvec iov = {
+ .iov_base = &buf,
+ .iov_len = sizeof(buf),
+ };
+ struct inode *new;
+ int rc;
+
+ new = smb2_get_reparse_inode(&data, inode->i_sb, xid,
+ tcon, full_path, false, &iov, NULL);
+ if (!IS_ERR(new))
+ d_instantiate(dentry, new);
+ else
+ rc = PTR_ERR(new);
+ cifs_free_open_info(&data);
+ return rc;
+}
+
static int nfs_set_reparse_buf(struct reparse_posix_data *buf,
mode_t mode, dev_t dev,
struct kvec *iov)
@@ -602,6 +631,13 @@ int smb2_mknod_reparse(unsigned int xid, struct inode *inode,
{
struct smb3_fs_context *ctx = CIFS_SB(inode->i_sb)->ctx;
+ if (S_ISSOCK(mode) && (
+ ctx->reparse_type == CIFS_REPARSE_TYPE_NATIVE ||
+ ctx->reparse_type == CIFS_REPARSE_TYPE_NATIVE_NFS ||
+ ctx->reparse_type == CIFS_REPARSE_TYPE_NATIVE_WSL)) {
+ return create_native_socket(xid, inode, dentry, tcon, full_path);
+ }
+
switch (ctx->reparse_type) {
case CIFS_REPARSE_TYPE_NATIVE_NFS:
case CIFS_REPARSE_TYPE_NFS:
--
2.20.1
On Sunday 06 October 2024 12:00:42 Pali Rohár wrote: > Native Windows sockets created by WinSock on Windows 10 April 2018 Update > (version 1803) or Windows Server 2019 (version 1809) or later versions is > reparse point with IO_REPARSE_TAG_AF_UNIX tag, with empty reparse point > data buffer and without any EAs. > > Create AF_UNIX sockets in this native format when -o reparse=native or > -o reparse=native+<something> mount option is used. > > This change makes AF_UNIX sockets created by Linux CIFS client compatible > with AF_UNIX sockets created by Windows applications on NTFS volumes. > > Signed-off-by: Pali Rohár <pali@kernel.org> > --- > fs/smb/client/cifsglob.h | 6 +++--- > fs/smb/client/reparse.c | 36 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 39 insertions(+), 3 deletions(-) > > diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h > index 7632d2ba5390..570b22d02f7e 100644 > --- a/fs/smb/client/cifsglob.h > +++ b/fs/smb/client/cifsglob.h > @@ -155,9 +155,9 @@ enum securityEnum { > > enum cifs_reparse_type { > CIFS_REPARSE_TYPE_NONE, /* disable creating new reparse points */ > - CIFS_REPARSE_TYPE_NATIVE, /* native symlinks only */ > - CIFS_REPARSE_TYPE_NATIVE_NFS, /* native for symlinks, nfs for others */ > - CIFS_REPARSE_TYPE_NATIVE_WSL, /* native for symlinks, wsl for others */ > + CIFS_REPARSE_TYPE_NATIVE, /* native symlinks and sockets only, no support for others */ > + CIFS_REPARSE_TYPE_NATIVE_NFS, /* native for symlinks/sockets, nfs for fifos/block/char */ > + CIFS_REPARSE_TYPE_NATIVE_WSL, /* native for symlinks/sockets, wsl for fifos/block/char */ > CIFS_REPARSE_TYPE_NFS, /* nfs for everything */ > CIFS_REPARSE_TYPE_WSL, /* wsl for everything */ > CIFS_REPARSE_TYPE_DEFAULT = CIFS_REPARSE_TYPE_NATIVE_NFS, > diff --git a/fs/smb/client/reparse.c b/fs/smb/client/reparse.c > index 38fe0a710c65..f1488f870320 100644 > --- a/fs/smb/client/reparse.c > +++ b/fs/smb/client/reparse.c > @@ -379,6 +379,35 @@ static int detect_directory_symlink_target(struct cifs_sb_info *cifs_sb, > return 0; > } > > +static int create_native_socket(const unsigned int xid, struct inode *inode, > + struct dentry *dentry, struct cifs_tcon *tcon, > + const char *full_path) > +{ > + struct cifs_open_info_data data = { > + .reparse_point = true, > + .reparse = { .tag = IO_REPARSE_TAG_AF_UNIX, }, > + }; > + struct reparse_data_buffer buf = { > + .ReparseTag = cpu_to_le32(IO_REPARSE_TAG_AF_UNIX), > + .ReparseDataLength = 0, Correctly, this should be: .ReparseDataLength = cpu_to_le16(0), > + }; > + struct kvec iov = { > + .iov_base = &buf, > + .iov_len = sizeof(buf), > + }; > + struct inode *new; > + int rc; Here is missing initialization of rc: int rc = 0; > + > + new = smb2_get_reparse_inode(&data, inode->i_sb, xid, > + tcon, full_path, false, &iov, NULL); > + if (!IS_ERR(new)) > + d_instantiate(dentry, new); > + else > + rc = PTR_ERR(new); > + cifs_free_open_info(&data); > + return rc; > +} > + > static int nfs_set_reparse_buf(struct reparse_posix_data *buf, > mode_t mode, dev_t dev, > struct kvec *iov) > @@ -602,6 +631,13 @@ int smb2_mknod_reparse(unsigned int xid, struct inode *inode, > { > struct smb3_fs_context *ctx = CIFS_SB(inode->i_sb)->ctx; > > + if (S_ISSOCK(mode) && ( > + ctx->reparse_type == CIFS_REPARSE_TYPE_NATIVE || > + ctx->reparse_type == CIFS_REPARSE_TYPE_NATIVE_NFS || > + ctx->reparse_type == CIFS_REPARSE_TYPE_NATIVE_WSL)) { > + return create_native_socket(xid, inode, dentry, tcon, full_path); > + } > + > switch (ctx->reparse_type) { > case CIFS_REPARSE_TYPE_NATIVE_NFS: > case CIFS_REPARSE_TYPE_NFS: > -- > 2.20.1 >
© 2016 - 2024 Red Hat, Inc.