From patchwork Thu Jun 1 04:50:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 9758665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B1CCF60375 for ; Thu, 1 Jun 2017 04:50:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 931FF284EA for ; Thu, 1 Jun 2017 04:50:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83CCD284F4; Thu, 1 Jun 2017 04:50:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11D89284EA for ; Thu, 1 Jun 2017 04:50:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750790AbdFAEuR (ORCPT ); Thu, 1 Jun 2017 00:50:17 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:32948 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750726AbdFAEuQ (ORCPT ); Thu, 1 Jun 2017 00:50:16 -0400 Received: by mail-io0-f193.google.com with SMTP id m4so3752898ioe.0 for ; Wed, 31 May 2017 21:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=fH7b7VndXu7qsOVDRqPrZYuBe1SGzklmJPzjIeQXu1c=; b=QYQTUUDx0ULZnj2W2uVrhBntNn3H6caM/clgExBrD8NYbkaXdwCg5W2bnuerwp7RHR w9yFEkk3rhSMU3V0aLcbgB6QYvHfugiZjHsY7vsmgUfD/OHql6OBGi+xFA5bZAaklo2C Zxx58H02z0BQNCqx+Ls/m7SkvqaAMdBn0jPaKNWaouycmta57/eBVU91BUuS0AYTILRY dH68lVs3cN4VJhZd6mNvPctLGLTrUWiBSNK/mfMszuZdw1U97U/YduVaxiYvjgLRA/yf BMwF48CrCX4jfGOKEq+0Uu94mo6oIUSKB7B1e6l8srei8qn0OmGz8W696iwo6FV7Bj/m 9HZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fH7b7VndXu7qsOVDRqPrZYuBe1SGzklmJPzjIeQXu1c=; b=A6BUinDDBDz5CqyjupTZFj1t3mmcpN6YqVScAnulFO9700Zfl9wXcFAE3+Z6PGPwHs tYlkLmYQLp9POtqpHwQNan6VEluB3IurdyTIiLkzSxAHXBTolFCF9yna8aAbTXrD/rW1 YR8ILn4rhwFUWxDEvAx7OxnScqAVCL/d5fgD9SGPh2x0+Frs7vXBtpH9XhKKkGYcLhQT 97gXQg14A9tq4QWfA4L5GNa6DJojv8FBaMLQYl0sbGxRIjIkmWAK6BeDQlWEapNzPBqd 0Zq7qTQzglU0bZuzqIonWGkBM/xDL0ug7TlJlVDsMT9Avt4dlpdMob5UGxVAexnqmc2+ Yekg== X-Gm-Message-State: AODbwcBWn+qIohAg4R0cR/LNp1hB5P721ym91ffC5AY5YaARhnnMVIKN hIvo3GkxEP+bwg== X-Received: by 10.107.47.197 with SMTP id v66mr24618976iov.112.1496292615816; Wed, 31 May 2017 21:50:15 -0700 (PDT) Received: from shirish-ThinkPad-T400.attlocal.net (75-13-85-90.lightspeed.austtx.sbcglobal.net. [75.13.85.90]) by smtp.gmail.com with ESMTPSA id i74sm11942717itb.5.2017.05.31.21.50.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 May 2017 21:50:14 -0700 (PDT) From: shirishpargaonkar@gmail.com To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Shirish Pargaonkar Subject: [PATCH 1/2] cifs: prototype declaration and definition for smb 2 - 3 and cifsacl mount options Date: Wed, 31 May 2017 23:50:05 -0500 Message-Id: <1496292605-8754-1-git-send-email-shirishpargaonkar@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shirish Pargaonkar 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 Reviewed-by: Pavel Shilovsky --- 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);