* [PATCH 0/1] FSCTL write support @ 2019-04-11 2:20 Ronnie Sahlberg 2019-04-11 2:20 ` [PATCH] cifs: Add support for FSCTL passthrough that write data to the server Ronnie Sahlberg 0 siblings, 1 reply; 7+ messages in thread From: Ronnie Sahlberg @ 2019-04-11 2:20 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French, Stable Steve, This patch adds code to allow us to do fsctl passthrough for fsctl types that need to pass data to the server. This not only needs to pass the blob to the server but also need to decode the access-type part of the fsctl code and change the arguments to the CREATE accordingly. The values for the access are from wireshark traces of win16 -> win16. For now I only implement the special handling we need for FILE_READ_WRITE_ACCESS. We can add the others as needed and as we we discover them while adding new functions to smbinfo. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] cifs: Add support for FSCTL passthrough that write data to the server 2019-04-11 2:20 [PATCH 0/1] FSCTL write support Ronnie Sahlberg @ 2019-04-11 2:20 ` Ronnie Sahlberg 2019-04-11 2:48 ` Steve French 2019-04-11 17:49 ` Pavel Shilovsky 0 siblings, 2 replies; 7+ messages in thread From: Ronnie Sahlberg @ 2019-04-11 2:20 UTC (permalink / raw) To: linux-cifs; +Cc: Steve French, Stable, Ronnie Sahlberg Add support to pass a blob to the server in FSCTL passthrough. Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> --- fs/cifs/smb2ops.c | 17 +++++++++++++++-- fs/cifs/smbfsctl.h | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 83a100dd2497..bb7522b882ea 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1382,6 +1382,18 @@ smb2_ioctl_query_info(const unsigned int xid, oparms.fid = &fid; oparms.reconnect = false; + /* + * FSCTL codes encode the special access they need in the fsctl code. + */ + if (qi.flags & PASSTHRU_FSCTL) { + switch (qi.info_type & FSCTL_DEVICE_ACCESS_MASK) { + case FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS: + oparms.desired_access = FILE_READ_DATA | FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE; + ; + break; + } + } + rc = SMB2_open_init(tcon, &rqst[0], &oplock, &oparms, path); if (rc) goto iqinf_exit; @@ -1399,8 +1411,9 @@ smb2_ioctl_query_info(const unsigned int xid, rc = SMB2_ioctl_init(tcon, &rqst[1], COMPOUND_FID, COMPOUND_FID, - qi.info_type, true, NULL, - 0, CIFSMaxBufSize); + qi.info_type, true, buffer, + qi.output_buffer_length, + CIFSMaxBufSize); } } else if (qi.flags == PASSTHRU_QUERY_INFO) { memset(&qi_iov, 0, sizeof(qi_iov)); diff --git a/fs/cifs/smbfsctl.h b/fs/cifs/smbfsctl.h index f996daeea271..9b3459b9a5ce 100644 --- a/fs/cifs/smbfsctl.h +++ b/fs/cifs/smbfsctl.h @@ -35,6 +35,33 @@ * below). Additional detail on less common ones can be found in MS-FSCC * section 2.3. */ + +/* + * FSCTL values are 32 bits and are constructed as + * <device 16bits> <access 2bits> <function 12bits> <method 2bits> + */ +/* Device */ +#define FSCTL_DEVICE_DFS (0x0006 << 16) +#define FSCTL_DEVICE_FILE_SYSTEM (0x0009 << 16) +#define FSCTL_DEVICE_NAMED_PIPE (0x0011 << 16) +#define FSCTL_DEVICE_NETWORK_FILE_SYSTEM (0x0014 << 16) +#define FSCTL_DEVICE_MASK 0xffff0000 +/* Access */ +#define FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS (0x00 << 14) +#define FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS (0x01 << 14) +#define FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS (0x02 << 14) +#define FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS (0x03 << 14) +#define FSCTL_DEVICE_ACCESS_MASK 0x0000c000 +/* Function */ +#define FSCTL_DEVICE_FUNCTION_MASK 0x00003ffc +/* Method */ +#define FSCTL_DEVICE_METHOD_BUFFERED 0x00 +#define FSCTL_DEVICE_METHOD_IN_DIRECT 0x01 +#define FSCTL_DEVICE_METHOD_OUT_DIRECT 0x02 +#define FSCTL_DEVICE_METHOD_NEITHER 0x03 +#define FSCTL_DEVICE_METHOD_MASK 0x00000003 + + #define FSCTL_DFS_GET_REFERRALS 0x00060194 #define FSCTL_DFS_GET_REFERRALS_EX 0x000601B0 #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000 -- 2.13.6 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] cifs: Add support for FSCTL passthrough that write data to the server 2019-04-11 2:20 ` [PATCH] cifs: Add support for FSCTL passthrough that write data to the server Ronnie Sahlberg @ 2019-04-11 2:48 ` Steve French 2019-04-11 17:49 ` Pavel Shilovsky 1 sibling, 0 replies; 7+ messages in thread From: Steve French @ 2019-04-11 2:48 UTC (permalink / raw) To: Ronnie Sahlberg; +Cc: linux-cifs, Steve French, Stable tentatively merged into cifs-2.6.git for-next On Wed, Apr 10, 2019 at 9:20 PM Ronnie Sahlberg <lsahlber@redhat.com> wrote: > > Add support to pass a blob to the server in FSCTL passthrough. > > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> > --- > fs/cifs/smb2ops.c | 17 +++++++++++++++-- > fs/cifs/smbfsctl.h | 27 +++++++++++++++++++++++++++ > 2 files changed, 42 insertions(+), 2 deletions(-) > > diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c > index 83a100dd2497..bb7522b882ea 100644 > --- a/fs/cifs/smb2ops.c > +++ b/fs/cifs/smb2ops.c > @@ -1382,6 +1382,18 @@ smb2_ioctl_query_info(const unsigned int xid, > oparms.fid = &fid; > oparms.reconnect = false; > > + /* > + * FSCTL codes encode the special access they need in the fsctl code. > + */ > + if (qi.flags & PASSTHRU_FSCTL) { > + switch (qi.info_type & FSCTL_DEVICE_ACCESS_MASK) { > + case FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS: > + oparms.desired_access = FILE_READ_DATA | FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE; > + ; > + break; > + } > + } > + > rc = SMB2_open_init(tcon, &rqst[0], &oplock, &oparms, path); > if (rc) > goto iqinf_exit; > @@ -1399,8 +1411,9 @@ smb2_ioctl_query_info(const unsigned int xid, > > rc = SMB2_ioctl_init(tcon, &rqst[1], > COMPOUND_FID, COMPOUND_FID, > - qi.info_type, true, NULL, > - 0, CIFSMaxBufSize); > + qi.info_type, true, buffer, > + qi.output_buffer_length, > + CIFSMaxBufSize); > } > } else if (qi.flags == PASSTHRU_QUERY_INFO) { > memset(&qi_iov, 0, sizeof(qi_iov)); > diff --git a/fs/cifs/smbfsctl.h b/fs/cifs/smbfsctl.h > index f996daeea271..9b3459b9a5ce 100644 > --- a/fs/cifs/smbfsctl.h > +++ b/fs/cifs/smbfsctl.h > @@ -35,6 +35,33 @@ > * below). Additional detail on less common ones can be found in MS-FSCC > * section 2.3. > */ > + > +/* > + * FSCTL values are 32 bits and are constructed as > + * <device 16bits> <access 2bits> <function 12bits> <method 2bits> > + */ > +/* Device */ > +#define FSCTL_DEVICE_DFS (0x0006 << 16) > +#define FSCTL_DEVICE_FILE_SYSTEM (0x0009 << 16) > +#define FSCTL_DEVICE_NAMED_PIPE (0x0011 << 16) > +#define FSCTL_DEVICE_NETWORK_FILE_SYSTEM (0x0014 << 16) > +#define FSCTL_DEVICE_MASK 0xffff0000 > +/* Access */ > +#define FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS (0x00 << 14) > +#define FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS (0x01 << 14) > +#define FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS (0x02 << 14) > +#define FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS (0x03 << 14) > +#define FSCTL_DEVICE_ACCESS_MASK 0x0000c000 > +/* Function */ > +#define FSCTL_DEVICE_FUNCTION_MASK 0x00003ffc > +/* Method */ > +#define FSCTL_DEVICE_METHOD_BUFFERED 0x00 > +#define FSCTL_DEVICE_METHOD_IN_DIRECT 0x01 > +#define FSCTL_DEVICE_METHOD_OUT_DIRECT 0x02 > +#define FSCTL_DEVICE_METHOD_NEITHER 0x03 > +#define FSCTL_DEVICE_METHOD_MASK 0x00000003 > + > + > #define FSCTL_DFS_GET_REFERRALS 0x00060194 > #define FSCTL_DFS_GET_REFERRALS_EX 0x000601B0 > #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000 > -- > 2.13.6 > -- Thanks, Steve ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cifs: Add support for FSCTL passthrough that write data to the server 2019-04-11 2:20 ` [PATCH] cifs: Add support for FSCTL passthrough that write data to the server Ronnie Sahlberg 2019-04-11 2:48 ` Steve French @ 2019-04-11 17:49 ` Pavel Shilovsky 2019-04-11 18:56 ` Steve French 2019-04-11 20:00 ` ronnie sahlberg 1 sibling, 2 replies; 7+ messages in thread From: Pavel Shilovsky @ 2019-04-11 17:49 UTC (permalink / raw) To: Ronnie Sahlberg; +Cc: linux-cifs, Steve French, Stable ср, 10 апр. 2019 г. в 19:21, Ronnie Sahlberg <lsahlber@redhat.com>: > > Add support to pass a blob to the server in FSCTL passthrough. > > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> > --- > fs/cifs/smb2ops.c | 17 +++++++++++++++-- > fs/cifs/smbfsctl.h | 27 +++++++++++++++++++++++++++ > 2 files changed, 42 insertions(+), 2 deletions(-) > > diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c > index 83a100dd2497..bb7522b882ea 100644 > --- a/fs/cifs/smb2ops.c > +++ b/fs/cifs/smb2ops.c > @@ -1382,6 +1382,18 @@ smb2_ioctl_query_info(const unsigned int xid, > oparms.fid = &fid; > oparms.reconnect = false; > > + /* > + * FSCTL codes encode the special access they need in the fsctl code. > + */ > + if (qi.flags & PASSTHRU_FSCTL) { > + switch (qi.info_type & FSCTL_DEVICE_ACCESS_MASK) { > + case FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS: > + oparms.desired_access = FILE_READ_DATA | FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE; > + ; This extra ":" looks unnecessary. Don't we need to add cases for +#define FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS (0x00 << 14) +#define FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS (0x01 << 14) +#define FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS (0x02 << 14) ? -- Best regards, Pavel Shilovsky ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cifs: Add support for FSCTL passthrough that write data to the server 2019-04-11 17:49 ` Pavel Shilovsky @ 2019-04-11 18:56 ` Steve French 2019-04-11 20:02 ` ronnie sahlberg 2019-04-11 20:00 ` ronnie sahlberg 1 sibling, 1 reply; 7+ messages in thread From: Steve French @ 2019-04-11 18:56 UTC (permalink / raw) To: Pavel Shilovsky; +Cc: Ronnie Sahlberg, linux-cifs, Steve French [-- Attachment #1: Type: text/plain, Size: 1652 bytes --] How about this small followon patch to address this? On Thu, Apr 11, 2019 at 12:49 PM Pavel Shilovsky <piastryyy@gmail.com> wrote: > > ср, 10 апр. 2019 г. в 19:21, Ronnie Sahlberg <lsahlber@redhat.com>: > > > > Add support to pass a blob to the server in FSCTL passthrough. > > > > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> > > --- > > fs/cifs/smb2ops.c | 17 +++++++++++++++-- > > fs/cifs/smbfsctl.h | 27 +++++++++++++++++++++++++++ > > 2 files changed, 42 insertions(+), 2 deletions(-) > > > > diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c > > index 83a100dd2497..bb7522b882ea 100644 > > --- a/fs/cifs/smb2ops.c > > +++ b/fs/cifs/smb2ops.c > > @@ -1382,6 +1382,18 @@ smb2_ioctl_query_info(const unsigned int xid, > > oparms.fid = &fid; > > oparms.reconnect = false; > > > > + /* > > + * FSCTL codes encode the special access they need in the fsctl code. > > + */ > > + if (qi.flags & PASSTHRU_FSCTL) { > > + switch (qi.info_type & FSCTL_DEVICE_ACCESS_MASK) { > > + case FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS: > > + oparms.desired_access = FILE_READ_DATA | FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE; > > + ; > > This extra ":" looks unnecessary. Don't we need to add cases for > +#define FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS (0x00 << 14) > +#define FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS (0x01 << 14) > +#define FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS (0x02 << 14) > ? > > -- > Best regards, > Pavel Shilovsky -- Thanks, Steve [-- Attachment #2: 0001-SMB3-Add-handling-for-different-FSCTL-access-flags.patch --] [-- Type: text/x-patch, Size: 1272 bytes --] From 2f1490f506b583f1533e7165adc7f21eaa01df22 Mon Sep 17 00:00:00 2001 From: Steve French <stfrench@microsoft.com> Date: Thu, 11 Apr 2019 13:53:17 -0500 Subject: [PATCH] SMB3: Add handling for different FSCTL access flags DesiredAccess field in SMB3 open request needs to be set differently for READ vs. WRITE ioctls (not just ones that request both). Originally noticed by Pavel Signed-off-by: Steve French <stfrench@microsoft.com> --- fs/cifs/smb2ops.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index ed8c2ba9590b..08ff044fbb4b 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1389,7 +1389,15 @@ smb2_ioctl_query_info(const unsigned int xid, switch (qi.info_type & FSCTL_DEVICE_ACCESS_MASK) { case FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS: oparms.desired_access = FILE_READ_DATA | FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE; - ; + break; + case FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS: + oparms.desired_access = GENERIC_ALL; + break; + case FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS: + oparms.desired_access = GENERIC_READ; + break; + case FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS: + oparms.desired_access = GENERIC_WRITE; break; } } -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] cifs: Add support for FSCTL passthrough that write data to the server 2019-04-11 18:56 ` Steve French @ 2019-04-11 20:02 ` ronnie sahlberg 0 siblings, 0 replies; 7+ messages in thread From: ronnie sahlberg @ 2019-04-11 20:02 UTC (permalink / raw) To: Steve French; +Cc: Pavel Shilovsky, Ronnie Sahlberg, linux-cifs On Fri, Apr 12, 2019 at 4:57 AM Steve French <smfrench@gmail.com> wrote: > > How about this small followon patch to address this? Looks reasonable. Reviewed-by me > > > On Thu, Apr 11, 2019 at 12:49 PM Pavel Shilovsky <piastryyy@gmail.com> wrote: > > > > ср, 10 апр. 2019 г. в 19:21, Ronnie Sahlberg <lsahlber@redhat.com>: > > > > > > Add support to pass a blob to the server in FSCTL passthrough. > > > > > > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> > > > --- > > > fs/cifs/smb2ops.c | 17 +++++++++++++++-- > > > fs/cifs/smbfsctl.h | 27 +++++++++++++++++++++++++++ > > > 2 files changed, 42 insertions(+), 2 deletions(-) > > > > > > diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c > > > index 83a100dd2497..bb7522b882ea 100644 > > > --- a/fs/cifs/smb2ops.c > > > +++ b/fs/cifs/smb2ops.c > > > @@ -1382,6 +1382,18 @@ smb2_ioctl_query_info(const unsigned int xid, > > > oparms.fid = &fid; > > > oparms.reconnect = false; > > > > > > + /* > > > + * FSCTL codes encode the special access they need in the fsctl code. > > > + */ > > > + if (qi.flags & PASSTHRU_FSCTL) { > > > + switch (qi.info_type & FSCTL_DEVICE_ACCESS_MASK) { > > > + case FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS: > > > + oparms.desired_access = FILE_READ_DATA | FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE; > > > + ; > > > > This extra ":" looks unnecessary. Don't we need to add cases for > > +#define FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS (0x00 << 14) > > +#define FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS (0x01 << 14) > > +#define FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS (0x02 << 14) > > ? > > > > -- > > Best regards, > > Pavel Shilovsky > > > > -- > Thanks, > > Steve ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cifs: Add support for FSCTL passthrough that write data to the server 2019-04-11 17:49 ` Pavel Shilovsky 2019-04-11 18:56 ` Steve French @ 2019-04-11 20:00 ` ronnie sahlberg 1 sibling, 0 replies; 7+ messages in thread From: ronnie sahlberg @ 2019-04-11 20:00 UTC (permalink / raw) To: Pavel Shilovsky; +Cc: Ronnie Sahlberg, linux-cifs, Steve French, Stable On Fri, Apr 12, 2019 at 3:49 AM Pavel Shilovsky <piastryyy@gmail.com> wrote: > > ср, 10 апр. 2019 г. в 19:21, Ronnie Sahlberg <lsahlber@redhat.com>: > > > > Add support to pass a blob to the server in FSCTL passthrough. > > > > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> > > --- > > fs/cifs/smb2ops.c | 17 +++++++++++++++-- > > fs/cifs/smbfsctl.h | 27 +++++++++++++++++++++++++++ > > 2 files changed, 42 insertions(+), 2 deletions(-) > > > > diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c > > index 83a100dd2497..bb7522b882ea 100644 > > --- a/fs/cifs/smb2ops.c > > +++ b/fs/cifs/smb2ops.c > > @@ -1382,6 +1382,18 @@ smb2_ioctl_query_info(const unsigned int xid, > > oparms.fid = &fid; > > oparms.reconnect = false; > > > > + /* > > + * FSCTL codes encode the special access they need in the fsctl code. > > + */ > > + if (qi.flags & PASSTHRU_FSCTL) { > > + switch (qi.info_type & FSCTL_DEVICE_ACCESS_MASK) { > > + case FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS: > > + oparms.desired_access = FILE_READ_DATA | FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE; > > + ; > > This extra ":" looks unnecessary. Don't we need to add cases for > +#define FSCTL_DEVICE_ACCESS_FILE_ANY_ACCESS (0x00 << 14) > +#define FSCTL_DEVICE_ACCESS_FILE_READ_ACCESS (0x01 << 14) > +#define FSCTL_DEVICE_ACCESS_FILE_WRITE_ACCESS (0x02 << 14) > ? Thanks, yeah that ';' should go. We should add cases for the other three DEVICE_ACCESS cases but i don't know yet how these are mapped on windows. READ_WRITE was based on what win16 used as desired_access for this. We can add the others later when we start adding other fsctl types when we compare to what windows uses. > > -- > Best regards, > Pavel Shilovsky ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-04-11 20:02 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-04-11 2:20 [PATCH 0/1] FSCTL write support Ronnie Sahlberg 2019-04-11 2:20 ` [PATCH] cifs: Add support for FSCTL passthrough that write data to the server Ronnie Sahlberg 2019-04-11 2:48 ` Steve French 2019-04-11 17:49 ` Pavel Shilovsky 2019-04-11 18:56 ` Steve French 2019-04-11 20:02 ` ronnie sahlberg 2019-04-11 20:00 ` ronnie sahlberg
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.