* [PATCH] cifs: add passthrough for smb2 setinfo
@ 2019-07-25 3:08 Ronnie Sahlberg
2019-07-25 4:49 ` Steve French
0 siblings, 1 reply; 2+ messages in thread
From: Ronnie Sahlberg @ 2019-07-25 3:08 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French, Ronnie Sahlberg
Add support to send smb2 set-info commands from userspace.
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/cifs_ioctl.h | 1 +
fs/cifs/smb2ops.c | 29 +++++++++++++++++++++++++----
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/fs/cifs/cifs_ioctl.h b/fs/cifs/cifs_ioctl.h
index 086ddc5108af..6c3bd07868d7 100644
--- a/fs/cifs/cifs_ioctl.h
+++ b/fs/cifs/cifs_ioctl.h
@@ -46,6 +46,7 @@ struct smb_snapshot_array {
/* query_info flags */
#define PASSTHRU_QUERY_INFO 0x00000000
#define PASSTHRU_FSCTL 0x00000001
+#define PASSTHRU_SET_INFO 0x00000002
struct smb_query_info {
__u32 info_type;
__u32 file_info_class;
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 592aa11aaf57..fc464dc20b30 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -1369,7 +1369,10 @@ smb2_ioctl_query_info(const unsigned int xid,
struct cifs_fid fid;
struct kvec qi_iov[1];
struct kvec io_iov[SMB2_IOCTL_IOV_SIZE];
+ struct kvec si_iov[SMB2_SET_INFO_IOV_SIZE];
struct kvec close_iov[1];
+ unsigned int size[2];
+ void *data[2];
memset(rqst, 0, sizeof(rqst));
resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
@@ -1404,7 +1407,6 @@ smb2_ioctl_query_info(const unsigned int xid,
memset(&oparms, 0, sizeof(oparms));
oparms.tcon = tcon;
- oparms.desired_access = FILE_READ_ATTRIBUTES | READ_CONTROL;
oparms.disposition = FILE_OPEN;
if (is_dir)
oparms.create_options = CREATE_NOT_FILE;
@@ -1413,9 +1415,6 @@ 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:
@@ -1431,6 +1430,10 @@ smb2_ioctl_query_info(const unsigned int xid,
oparms.desired_access = GENERIC_WRITE;
break;
}
+ } else if (qi.flags & PASSTHRU_SET_INFO) {
+ oparms.desired_access = GENERIC_WRITE;
+ } else {
+ oparms.desired_access = FILE_READ_ATTRIBUTES | READ_CONTROL;
}
rc = SMB2_open_init(tcon, &rqst[0], &oplock, &oparms, path);
@@ -1454,6 +1457,24 @@ smb2_ioctl_query_info(const unsigned int xid,
qi.output_buffer_length,
CIFSMaxBufSize);
}
+ } else if (qi.flags == PASSTHRU_SET_INFO) {
+ /* Can eventually relax perm check since server enforces too */
+ if (!capable(CAP_SYS_ADMIN))
+ rc = -EPERM;
+ else {
+ memset(&si_iov, 0, sizeof(si_iov));
+ rqst[1].rq_iov = si_iov;
+ rqst[1].rq_nvec = 1;
+
+ size[0] = 8;
+ data[0] = buffer;
+
+ rc = SMB2_set_info_init(tcon, &rqst[1],
+ COMPOUND_FID, COMPOUND_FID,
+ current->tgid,
+ FILE_END_OF_FILE_INFORMATION,
+ SMB2_O_INFO_FILE, 0, data, size);
+ }
} else if (qi.flags == PASSTHRU_QUERY_INFO) {
memset(&qi_iov, 0, sizeof(qi_iov));
rqst[1].rq_iov = qi_iov;
--
2.13.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cifs: add passthrough for smb2 setinfo
2019-07-25 3:08 [PATCH] cifs: add passthrough for smb2 setinfo Ronnie Sahlberg
@ 2019-07-25 4:49 ` Steve French
0 siblings, 0 replies; 2+ messages in thread
From: Steve French @ 2019-07-25 4:49 UTC (permalink / raw)
To: Ronnie Sahlberg; +Cc: linux-cifs
tentatively merged into cifs-2.6.git for-next pending more testing
On Wed, Jul 24, 2019 at 10:09 PM Ronnie Sahlberg <lsahlber@redhat.com> wrote:
>
> Add support to send smb2 set-info commands from userspace.
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
> fs/cifs/cifs_ioctl.h | 1 +
> fs/cifs/smb2ops.c | 29 +++++++++++++++++++++++++----
> 2 files changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/fs/cifs/cifs_ioctl.h b/fs/cifs/cifs_ioctl.h
> index 086ddc5108af..6c3bd07868d7 100644
> --- a/fs/cifs/cifs_ioctl.h
> +++ b/fs/cifs/cifs_ioctl.h
> @@ -46,6 +46,7 @@ struct smb_snapshot_array {
> /* query_info flags */
> #define PASSTHRU_QUERY_INFO 0x00000000
> #define PASSTHRU_FSCTL 0x00000001
> +#define PASSTHRU_SET_INFO 0x00000002
> struct smb_query_info {
> __u32 info_type;
> __u32 file_info_class;
> diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> index 592aa11aaf57..fc464dc20b30 100644
> --- a/fs/cifs/smb2ops.c
> +++ b/fs/cifs/smb2ops.c
> @@ -1369,7 +1369,10 @@ smb2_ioctl_query_info(const unsigned int xid,
> struct cifs_fid fid;
> struct kvec qi_iov[1];
> struct kvec io_iov[SMB2_IOCTL_IOV_SIZE];
> + struct kvec si_iov[SMB2_SET_INFO_IOV_SIZE];
> struct kvec close_iov[1];
> + unsigned int size[2];
> + void *data[2];
>
> memset(rqst, 0, sizeof(rqst));
> resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
> @@ -1404,7 +1407,6 @@ smb2_ioctl_query_info(const unsigned int xid,
>
> memset(&oparms, 0, sizeof(oparms));
> oparms.tcon = tcon;
> - oparms.desired_access = FILE_READ_ATTRIBUTES | READ_CONTROL;
> oparms.disposition = FILE_OPEN;
> if (is_dir)
> oparms.create_options = CREATE_NOT_FILE;
> @@ -1413,9 +1415,6 @@ 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:
> @@ -1431,6 +1430,10 @@ smb2_ioctl_query_info(const unsigned int xid,
> oparms.desired_access = GENERIC_WRITE;
> break;
> }
> + } else if (qi.flags & PASSTHRU_SET_INFO) {
> + oparms.desired_access = GENERIC_WRITE;
> + } else {
> + oparms.desired_access = FILE_READ_ATTRIBUTES | READ_CONTROL;
> }
>
> rc = SMB2_open_init(tcon, &rqst[0], &oplock, &oparms, path);
> @@ -1454,6 +1457,24 @@ smb2_ioctl_query_info(const unsigned int xid,
> qi.output_buffer_length,
> CIFSMaxBufSize);
> }
> + } else if (qi.flags == PASSTHRU_SET_INFO) {
> + /* Can eventually relax perm check since server enforces too */
> + if (!capable(CAP_SYS_ADMIN))
> + rc = -EPERM;
> + else {
> + memset(&si_iov, 0, sizeof(si_iov));
> + rqst[1].rq_iov = si_iov;
> + rqst[1].rq_nvec = 1;
> +
> + size[0] = 8;
> + data[0] = buffer;
> +
> + rc = SMB2_set_info_init(tcon, &rqst[1],
> + COMPOUND_FID, COMPOUND_FID,
> + current->tgid,
> + FILE_END_OF_FILE_INFORMATION,
> + SMB2_O_INFO_FILE, 0, data, size);
> + }
> } else if (qi.flags == PASSTHRU_QUERY_INFO) {
> memset(&qi_iov, 0, sizeof(qi_iov));
> rqst[1].rq_iov = qi_iov;
> --
> 2.13.6
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-25 4:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-25 3:08 [PATCH] cifs: add passthrough for smb2 setinfo Ronnie Sahlberg
2019-07-25 4:49 ` Steve French
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).