All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] cifs: prototype declaration and definition for smb 2 - 3 and cifsacl mount options
@ 2017-06-01  4:50 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w
       [not found] ` <1496292605-8754-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w @ 2017-06-01  4:50 UTC (permalink / raw)
  To: smfrench-Re5JQEeQqe8AvxtiuMwx3w
  Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA, Shirish Pargaonkar

From: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Add definition and declaration of function to get cifs acls when
mounting with smb version 2 onwards to 3.

Extend/Alter query info function to allocate and return
security descriptors within the response.

Not yet handling the error case when the size of security descriptors
in response to query exceeds SMB2_MAX_BUFFER_SIZE.

Signed-off-by: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

---
 fs/cifs/smb2pdu.c   | 52 +++++++++++++++++++++++++++++++++++++++++-----------
 fs/cifs/smb2proto.h |  3 +++
 2 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index e4afdaa..4938e8b 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2081,8 +2081,9 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
 
 static int
 query_info(const unsigned int xid, struct cifs_tcon *tcon,
-	   u64 persistent_fid, u64 volatile_fid, u8 info_class,
-	   size_t output_len, size_t min_len, void *data)
+	   u64 persistent_fid, u64 volatile_fid, u8 info_class, u8 info_type,
+	   u32 additional_info, size_t output_len, size_t min_len, void **data,
+		u32 *dlen)
 {
 	struct smb2_query_info_req *req;
 	struct smb2_query_info_rsp *rsp = NULL;
@@ -2108,10 +2109,11 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
 	if (encryption_required(tcon))
 		flags |= CIFS_TRANSFORM_REQ;
 
-	req->InfoType = SMB2_O_INFO_FILE;
+	req->InfoType = info_type;
 	req->FileInfoClass = info_class;
 	req->PersistentFileId = persistent_fid;
 	req->VolatileFileId = volatile_fid;
+	req->AdditionalInformation = cpu_to_le32(additional_info);
 	/* 4 for rfc1002 length field and 1 for Buffer */
 	req->InputBufferOffset =
 		cpu_to_le16(sizeof(struct smb2_query_info_req) - 1 - 4);
@@ -2130,24 +2132,51 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
 		goto qinf_exit;
 	}
 
+	if (dlen) {
+		*dlen = le32_to_cpu(rsp->OutputBufferLength);
+		if (!*data) {
+			*data = kmalloc(*dlen, GFP_KERNEL);
+			if (!*data) {
+				cifs_dbg(VFS,
+					"Error %d allocating memory for acl\n",
+					rc);
+				*dlen = 0;
+				goto qinf_exit;
+			}
+		}
+	}
+
 	rc = validate_and_copy_buf(le16_to_cpu(rsp->OutputBufferOffset),
 				   le32_to_cpu(rsp->OutputBufferLength),
-				   &rsp->hdr, min_len, data);
+				   &rsp->hdr, min_len, *data);
 
 qinf_exit:
 	free_rsp_buf(resp_buftype, rsp);
 	return rc;
 }
 
+int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
+	u64 persistent_fid, u64 volatile_fid, struct smb2_file_all_info *data)
+{
+	return query_info(xid, tcon, persistent_fid, volatile_fid,
+			  FILE_ALL_INFORMATION, SMB2_O_INFO_FILE, 0,
+			  sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
+			  sizeof(struct smb2_file_all_info), (void **)&data,
+			  NULL);
+}
+
 int
-SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
+SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
 		u64 persistent_fid, u64 volatile_fid,
-		struct smb2_file_all_info *data)
+		void **data, u32 *plen)
 {
+	__u32 additional_info = OWNER_SECINFO | GROUP_SECINFO | DACL_SECINFO;
+	*plen = 0;
+
 	return query_info(xid, tcon, persistent_fid, volatile_fid,
-			  FILE_ALL_INFORMATION,
-			  sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
-			  sizeof(struct smb2_file_all_info), data);
+			  0, SMB2_O_INFO_SECURITY, additional_info,
+			  SMB2_MAX_BUFFER_SIZE,
+			  sizeof(struct smb2_file_all_info), data, plen);
 }
 
 int
@@ -2155,9 +2184,10 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
 		 u64 persistent_fid, u64 volatile_fid, __le64 *uniqueid)
 {
 	return query_info(xid, tcon, persistent_fid, volatile_fid,
-			  FILE_INTERNAL_INFORMATION,
+			  FILE_INTERNAL_INFORMATION, SMB2_O_INFO_FILE, 0,
+			  sizeof(struct smb2_file_internal_info),
 			  sizeof(struct smb2_file_internal_info),
-			  sizeof(struct smb2_file_internal_info), uniqueid);
+			  (void **)&uniqueid, NULL);
 }
 
 /*
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
index 6853454..3595cd7 100644
--- a/fs/cifs/smb2proto.h
+++ b/fs/cifs/smb2proto.h
@@ -135,6 +135,9 @@ extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
 extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
 			   u64 persistent_file_id, u64 volatile_file_id,
 			   struct smb2_file_all_info *data);
+extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
+			   u64 persistent_file_id, u64 volatile_file_id,
+			   void **data, unsigned int *plen);
 extern int SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon,
 			    u64 persistent_fid, u64 volatile_fid,
 			    __le64 *uniqueid);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH 1/2] cifs: prototype declaration and definition for smb 2 - 3 and cifsacl mount options
       [not found] ` <1496292605-8754-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-06-22 22:30   ` Pavel Shilovskiy
  0 siblings, 0 replies; 4+ messages in thread
From: Pavel Shilovskiy @ 2017-06-22 22:30 UTC (permalink / raw)
  To: shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w,
	smfrench-Re5JQEeQqe8AvxtiuMwx3w
  Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA

2017-05-31 21:50 GMT-07:00  <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> From: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> Add definition and declaration of function to get cifs acls when
> mounting with smb version 2 onwards to 3.
>
> Extend/Alter query info function to allocate and return
> security descriptors within the response.
>
> Not yet handling the error case when the size of security descriptors
> in response to query exceeds SMB2_MAX_BUFFER_SIZE.
>
> Signed-off-by: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> ---
>  fs/cifs/smb2pdu.c   | 52 +++++++++++++++++++++++++++++++++++++++++-----------
>  fs/cifs/smb2proto.h |  3 +++
>  2 files changed, 44 insertions(+), 11 deletions(-)
>
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index e4afdaa..4938e8b 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -2081,8 +2081,9 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
>
>  static int
>  query_info(const unsigned int xid, struct cifs_tcon *tcon,
> -          u64 persistent_fid, u64 volatile_fid, u8 info_class,
> -          size_t output_len, size_t min_len, void *data)
> +          u64 persistent_fid, u64 volatile_fid, u8 info_class, u8 info_type,
> +          u32 additional_info, size_t output_len, size_t min_len, void **data,
> +               u32 *dlen)
>  {
>         struct smb2_query_info_req *req;
>         struct smb2_query_info_rsp *rsp = NULL;
> @@ -2108,10 +2109,11 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
>         if (encryption_required(tcon))
>                 flags |= CIFS_TRANSFORM_REQ;
>
> -       req->InfoType = SMB2_O_INFO_FILE;
> +       req->InfoType = info_type;
>         req->FileInfoClass = info_class;
>         req->PersistentFileId = persistent_fid;
>         req->VolatileFileId = volatile_fid;
> +       req->AdditionalInformation = cpu_to_le32(additional_info);
>         /* 4 for rfc1002 length field and 1 for Buffer */
>         req->InputBufferOffset =
>                 cpu_to_le16(sizeof(struct smb2_query_info_req) - 1 - 4);
> @@ -2130,24 +2132,51 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
>                 goto qinf_exit;
>         }
>
> +       if (dlen) {
> +               *dlen = le32_to_cpu(rsp->OutputBufferLength);
> +               if (!*data) {
> +                       *data = kmalloc(*dlen, GFP_KERNEL);
> +                       if (!*data) {
> +                               cifs_dbg(VFS,
> +                                       "Error %d allocating memory for acl\n",
> +                                       rc);
> +                               *dlen = 0;
> +                               goto qinf_exit;
> +                       }
> +               }
> +       }
> +
>         rc = validate_and_copy_buf(le16_to_cpu(rsp->OutputBufferOffset),
>                                    le32_to_cpu(rsp->OutputBufferLength),
> -                                  &rsp->hdr, min_len, data);
> +                                  &rsp->hdr, min_len, *data);
>
>  qinf_exit:
>         free_rsp_buf(resp_buftype, rsp);
>         return rc;
>  }
>
> +int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
> +       u64 persistent_fid, u64 volatile_fid, struct smb2_file_all_info *data)
> +{
> +       return query_info(xid, tcon, persistent_fid, volatile_fid,
> +                         FILE_ALL_INFORMATION, SMB2_O_INFO_FILE, 0,
> +                         sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
> +                         sizeof(struct smb2_file_all_info), (void **)&data,
> +                         NULL);
> +}
> +
>  int
> -SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
> +SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
>                 u64 persistent_fid, u64 volatile_fid,
> -               struct smb2_file_all_info *data)
> +               void **data, u32 *plen)
>  {
> +       __u32 additional_info = OWNER_SECINFO | GROUP_SECINFO | DACL_SECINFO;
> +       *plen = 0;
> +
>         return query_info(xid, tcon, persistent_fid, volatile_fid,
> -                         FILE_ALL_INFORMATION,
> -                         sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
> -                         sizeof(struct smb2_file_all_info), data);
> +                         0, SMB2_O_INFO_SECURITY, additional_info,
> +                         SMB2_MAX_BUFFER_SIZE,
> +                         sizeof(struct smb2_file_all_info), data, plen);
>  }
>
>  int
> @@ -2155,9 +2184,10 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
>                  u64 persistent_fid, u64 volatile_fid, __le64 *uniqueid)
>  {
>         return query_info(xid, tcon, persistent_fid, volatile_fid,
> -                         FILE_INTERNAL_INFORMATION,
> +                         FILE_INTERNAL_INFORMATION, SMB2_O_INFO_FILE, 0,
> +                         sizeof(struct smb2_file_internal_info),
>                           sizeof(struct smb2_file_internal_info),
> -                         sizeof(struct smb2_file_internal_info), uniqueid);
> +                         (void **)&uniqueid, NULL);
>  }
>
>  /*
> diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
> index 6853454..3595cd7 100644
> --- a/fs/cifs/smb2proto.h
> +++ b/fs/cifs/smb2proto.h
> @@ -135,6 +135,9 @@ extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
>  extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
>                            u64 persistent_file_id, u64 volatile_file_id,
>                            struct smb2_file_all_info *data);
> +extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
> +                          u64 persistent_file_id, u64 volatile_file_id,
> +                          void **data, unsigned int *plen);
>  extern int SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon,
>                             u64 persistent_fid, u64 volatile_fid,
>                             __le64 *uniqueid);
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Looks good!

Reviewed-by: Pavel Shilovsky <pshilov-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>

--
Best regards,
Pavel Shilovsky

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH 1/2] cifs: prototype declaration and definition for smb 2 - 3 and cifsacl mount options
       [not found] ` <1498189891-4824-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-07-08 16:42   ` Pavel Shilovskiy
  0 siblings, 0 replies; 4+ messages in thread
From: Pavel Shilovskiy @ 2017-07-08 16:42 UTC (permalink / raw)
  To: shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w,
	smfrench-Re5JQEeQqe8AvxtiuMwx3w
  Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA

2017-06-28 20:37 GMT-07:00  <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> From: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> Modified current set info function to accommodate multiple info types and
> additional information.
>
> Added cifs acl specific function to invoke set info functionality.
>
>
> Signed-off-by: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> ---
>  fs/cifs/smb2pdu.c   | 39 +++++++++++++++++++++++++++------------
>  fs/cifs/smb2proto.h |  3 +++
>  2 files changed, 30 insertions(+), 12 deletions(-)
>
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index 4938e8b..c3c8eaf 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -3000,8 +3000,9 @@ void smb2_reconnect_server(struct work_struct *work)
>
>  static int
>  send_set_info(const unsigned int xid, struct cifs_tcon *tcon,
> -              u64 persistent_fid, u64 volatile_fid, u32 pid, int info_class,
> -              unsigned int num, void **data, unsigned int *size)
> +              u64 persistent_fid, u64 volatile_fid, u32 pid, u8 info_class,
> +              u8 info_type, u32 additional_info, unsigned int num,
> +               void **data, unsigned int *size)
>  {
>         struct smb2_set_info_req *req;
>         struct smb2_set_info_rsp *rsp = NULL;
> @@ -3037,10 +3038,11 @@ void smb2_reconnect_server(struct work_struct *work)
>
>         req->hdr.sync_hdr.ProcessId = cpu_to_le32(pid);
>
> -       req->InfoType = SMB2_O_INFO_FILE;
> +       req->InfoType = info_type;
>         req->FileInfoClass = info_class;
>         req->PersistentFileId = persistent_fid;
>         req->VolatileFileId = volatile_fid;
> +       req->AdditionalInformation = cpu_to_le32(additional_info);
>
>         /* 4 for RFC1001 length and 1 for Buffer */
>         req->BufferOffset =
> @@ -3100,8 +3102,8 @@ void smb2_reconnect_server(struct work_struct *work)
>         size[1] = len + 2 /* null */;
>
>         rc = send_set_info(xid, tcon, persistent_fid, volatile_fid,
> -                          current->tgid, FILE_RENAME_INFORMATION, 2, data,
> -                          size);
> +               current->tgid, FILE_RENAME_INFORMATION, SMB2_O_INFO_FILE,
> +               0, 2, data, size);
>         kfree(data);
>         return rc;
>  }
> @@ -3118,8 +3120,8 @@ void smb2_reconnect_server(struct work_struct *work)
>         size = 1; /* sizeof __u8 */
>
>         return send_set_info(xid, tcon, persistent_fid, volatile_fid,
> -                       current->tgid, FILE_DISPOSITION_INFORMATION, 1, &data,
> -                       &size);
> +               current->tgid, FILE_DISPOSITION_INFORMATION, SMB2_O_INFO_FILE,
> +               0, 1, &data, &size);
>  }
>
>  int
> @@ -3148,7 +3150,8 @@ void smb2_reconnect_server(struct work_struct *work)
>         size[1] = len + 2 /* null */;
>
>         rc = send_set_info(xid, tcon, persistent_fid, volatile_fid,
> -                          current->tgid, FILE_LINK_INFORMATION, 2, data, size);
> +                       current->tgid, FILE_LINK_INFORMATION, SMB2_O_INFO_FILE,
> +                       0, 2, data, size);
>         kfree(data);
>         return rc;
>  }
> @@ -3168,10 +3171,12 @@ void smb2_reconnect_server(struct work_struct *work)
>
>         if (is_falloc)
>                 return send_set_info(xid, tcon, persistent_fid, volatile_fid,
> -                       pid, FILE_ALLOCATION_INFORMATION, 1, &data, &size);
> +                       pid, FILE_ALLOCATION_INFORMATION, SMB2_O_INFO_FILE,
> +                       0, 1, &data, &size);
>         else
>                 return send_set_info(xid, tcon, persistent_fid, volatile_fid,
> -                       pid, FILE_END_OF_FILE_INFORMATION, 1, &data, &size);
> +                       pid, FILE_END_OF_FILE_INFORMATION, SMB2_O_INFO_FILE,
> +                       0, 1, &data, &size);
>  }
>
>  int
> @@ -3181,8 +3186,18 @@ void smb2_reconnect_server(struct work_struct *work)
>         unsigned int size;
>         size = sizeof(FILE_BASIC_INFO);
>         return send_set_info(xid, tcon, persistent_fid, volatile_fid,
> -                            current->tgid, FILE_BASIC_INFORMATION, 1,
> -                            (void **)&buf, &size);
> +               current->tgid, FILE_BASIC_INFORMATION, SMB2_O_INFO_FILE,
> +               0, 1, (void **)&buf, &size);
> +}
> +
> +int
> +SMB2_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
> +               u64 persistent_fid, u64 volatile_fid,
> +               struct cifs_ntsd *pnntsd, int pacllen, int aclflag)
> +{
> +       return send_set_info(xid, tcon, persistent_fid, volatile_fid,
> +                       current->tgid, 0, SMB2_O_INFO_SECURITY, aclflag,
> +                       1, (void **)&pnntsd, &pacllen);
>  }
>
>  int
> diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
> index 3595cd7..1cadaf9 100644
> --- a/fs/cifs/smb2proto.h
> +++ b/fs/cifs/smb2proto.h
> @@ -166,6 +166,9 @@ extern int SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon,
>  extern int SMB2_set_info(const unsigned int xid, struct cifs_tcon *tcon,
>                          u64 persistent_fid, u64 volatile_fid,
>                          FILE_BASIC_INFO *buf);
> +extern int SMB2_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
> +                       u64 persistent_fid, u64 volatile_fid,
> +                       struct cifs_ntsd *pnntsd, int pacllen, int aclflag);
>  extern int SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
>                                 u64 persistent_fid, u64 volatile_fid);
>  extern int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Looks good.

Reviewed-by: Pavel Shilovsky <pshilov-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>

--
Best regards,
Pavel Shilovsky

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] cifs: prototype declaration and definition for smb 2 - 3 and cifsacl mount options
@ 2017-06-23  3:51 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w
       [not found] ` <1498189891-4824-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w @ 2017-06-23  3:51 UTC (permalink / raw)
  To: smfrench-Re5JQEeQqe8AvxtiuMwx3w
  Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA, Shirish Pargaonkar

From: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Add definition and declaration of function to get cifs acls when
mounting with smb version 2 onwards to 3.

Extend/Alter query info function to allocate and return
security descriptors within the response.

Not yet handling the error case when the size of security descriptors
in response to query exceeds SMB2_MAX_BUFFER_SIZE.

Signed-off-by: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

---
 fs/cifs/smb2pdu.c   | 52 +++++++++++++++++++++++++++++++++++++++++-----------
 fs/cifs/smb2proto.h |  3 +++
 2 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index e4afdaa..4938e8b 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2081,8 +2081,9 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
 
 static int
 query_info(const unsigned int xid, struct cifs_tcon *tcon,
-	   u64 persistent_fid, u64 volatile_fid, u8 info_class,
-	   size_t output_len, size_t min_len, void *data)
+	   u64 persistent_fid, u64 volatile_fid, u8 info_class, u8 info_type,
+	   u32 additional_info, size_t output_len, size_t min_len, void **data,
+		u32 *dlen)
 {
 	struct smb2_query_info_req *req;
 	struct smb2_query_info_rsp *rsp = NULL;
@@ -2108,10 +2109,11 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
 	if (encryption_required(tcon))
 		flags |= CIFS_TRANSFORM_REQ;
 
-	req->InfoType = SMB2_O_INFO_FILE;
+	req->InfoType = info_type;
 	req->FileInfoClass = info_class;
 	req->PersistentFileId = persistent_fid;
 	req->VolatileFileId = volatile_fid;
+	req->AdditionalInformation = cpu_to_le32(additional_info);
 	/* 4 for rfc1002 length field and 1 for Buffer */
 	req->InputBufferOffset =
 		cpu_to_le16(sizeof(struct smb2_query_info_req) - 1 - 4);
@@ -2130,24 +2132,51 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
 		goto qinf_exit;
 	}
 
+	if (dlen) {
+		*dlen = le32_to_cpu(rsp->OutputBufferLength);
+		if (!*data) {
+			*data = kmalloc(*dlen, GFP_KERNEL);
+			if (!*data) {
+				cifs_dbg(VFS,
+					"Error %d allocating memory for acl\n",
+					rc);
+				*dlen = 0;
+				goto qinf_exit;
+			}
+		}
+	}
+
 	rc = validate_and_copy_buf(le16_to_cpu(rsp->OutputBufferOffset),
 				   le32_to_cpu(rsp->OutputBufferLength),
-				   &rsp->hdr, min_len, data);
+				   &rsp->hdr, min_len, *data);
 
 qinf_exit:
 	free_rsp_buf(resp_buftype, rsp);
 	return rc;
 }
 
+int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
+	u64 persistent_fid, u64 volatile_fid, struct smb2_file_all_info *data)
+{
+	return query_info(xid, tcon, persistent_fid, volatile_fid,
+			  FILE_ALL_INFORMATION, SMB2_O_INFO_FILE, 0,
+			  sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
+			  sizeof(struct smb2_file_all_info), (void **)&data,
+			  NULL);
+}
+
 int
-SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
+SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
 		u64 persistent_fid, u64 volatile_fid,
-		struct smb2_file_all_info *data)
+		void **data, u32 *plen)
 {
+	__u32 additional_info = OWNER_SECINFO | GROUP_SECINFO | DACL_SECINFO;
+	*plen = 0;
+
 	return query_info(xid, tcon, persistent_fid, volatile_fid,
-			  FILE_ALL_INFORMATION,
-			  sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
-			  sizeof(struct smb2_file_all_info), data);
+			  0, SMB2_O_INFO_SECURITY, additional_info,
+			  SMB2_MAX_BUFFER_SIZE,
+			  sizeof(struct smb2_file_all_info), data, plen);
 }
 
 int
@@ -2155,9 +2184,10 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon)
 		 u64 persistent_fid, u64 volatile_fid, __le64 *uniqueid)
 {
 	return query_info(xid, tcon, persistent_fid, volatile_fid,
-			  FILE_INTERNAL_INFORMATION,
+			  FILE_INTERNAL_INFORMATION, SMB2_O_INFO_FILE, 0,
+			  sizeof(struct smb2_file_internal_info),
 			  sizeof(struct smb2_file_internal_info),
-			  sizeof(struct smb2_file_internal_info), uniqueid);
+			  (void **)&uniqueid, NULL);
 }
 
 /*
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
index 6853454..3595cd7 100644
--- a/fs/cifs/smb2proto.h
+++ b/fs/cifs/smb2proto.h
@@ -135,6 +135,9 @@ extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
 extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
 			   u64 persistent_file_id, u64 volatile_file_id,
 			   struct smb2_file_all_info *data);
+extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
+			   u64 persistent_file_id, u64 volatile_file_id,
+			   void **data, unsigned int *plen);
 extern int SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon,
 			    u64 persistent_fid, u64 volatile_fid,
 			    __le64 *uniqueid);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-08 16:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-01  4:50 [PATCH 1/2] cifs: prototype declaration and definition for smb 2 - 3 and cifsacl mount options shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <1496292605-8754-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-22 22:30   ` Pavel Shilovskiy
2017-06-23  3:51 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <1498189891-4824-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-07-08 16:42   ` Pavel Shilovskiy

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.