From patchwork Wed Mar 13 07:28:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 10850701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0B701669 for ; Wed, 13 Mar 2019 07:29:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D184287BF for ; Wed, 13 Mar 2019 07:29:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50DBB28911; Wed, 13 Mar 2019 07:29:09 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 DA729287BF for ; Wed, 13 Mar 2019 07:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726735AbfCMH3I (ORCPT ); Wed, 13 Mar 2019 03:29:08 -0400 Received: from mail-pf1-f169.google.com ([209.85.210.169]:36840 "EHLO mail-pf1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725820AbfCMH3I (ORCPT ); Wed, 13 Mar 2019 03:29:08 -0400 Received: by mail-pf1-f169.google.com with SMTP id n22so771610pfa.3 for ; Wed, 13 Mar 2019 00:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=7vu/SSiSlAq/xg2xWCta1KsTzvuxTMXVIwBlZPSSE2g=; b=r4xkbdWomt7eu1JTbnp6nFNEMNRE5MW3gHrmarbSMVstFnh1jvGWrgVHUTVB2Yu8y2 YdmgjSoE8iCbx/VSrraifqZ1EKJD8omKlx/3QrEU7NxB8QFn+WG2s9d2RKwGbFAst58a 3psZqv3l5U9wNb3hqPiD8RYJLZecA7WXOIMG4iJ29txLp9S0sjiBHiD9J6+2SHkkY5XS 7HOpTQVX8wmcfWqGmo2esq5FWtVcCZamWUeqtgaXAJFjfh3bUFe+UN3TvjP3HwgTG1DB Nbji1pu30uA6j92eGO8Iwszb2bw3MY9YNiPyfeD3YndtGP6W70lcHJFgN5OqlLz+JTxh LXSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=7vu/SSiSlAq/xg2xWCta1KsTzvuxTMXVIwBlZPSSE2g=; b=EmGCB3bBcirM2SLXkAthE5K7m1vppXvBiGLvIyZCxq1jNdB/UrW4/ROEYMOdJwjkOG e0eSxmTCWR1NxA6q4NfHVMIcX/LBQ0sI4eW2xIdQT9rt1Na2TNISogAUT92jtweAHu51 4RyTT3vZRWDAtXAxw+gcly9wGqG5yYRAhcjPj2ra17Kb7wrLYKVpC6ysf3w0ka4A7ybm 9x8e7wvoIxHo3gfQrQsrqIo6HmzqjVjd7R3IabSVPNNS4LYih4VmhjmQOljZuAqACW5n DsQumsx5HCGLu9u2mZL+3x7nIg8b7syC9jAkNPgNeZ5qwZdTZjNYkVKO1cVu29xS9pTV pkcQ== X-Gm-Message-State: APjAAAWEWKegWDmqxj6YZEJ6x65v5DnwC5Ey8+ySEAl/8mjW3Z0vyfP3 ta/EiCLcTbEFrKBv+ePVCrTrNgsgtP4wVw6TzfSLllvJ X-Google-Smtp-Source: APXvYqx+kzJ+IeEKk/l2RqRMFnqRszN+PdGYXw/v0hBhL74TKWMCWM0v6vJHswNb4HJi3ntWib1Z3xwIZZvHMnhP21Y= X-Received: by 2002:a63:974a:: with SMTP id d10mr26831805pgo.344.1552462146784; Wed, 13 Mar 2019 00:29:06 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Wed, 13 Mar 2019 02:28:55 -0500 Message-ID: Subject: [SMB3][PATCH] To: CIFS , ronnie sahlberg 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 SMB3: passthru query info doesn't check for SMB3 FSCTL passthru The passthrough queries from user space tools like smbinfo can be either SMB3 QUERY_INFO or SMB3 FSCTL, but we are not checking for the latter. Temporarily we return EOPNOTSUPP for SMB3 FSCTL passthrough requests but once compounding fsctls is fixed we can remove the EOPNOTSUPP. From 70d2deccf6ff82e8709061ff998cec25d050cdf5 Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 13 Mar 2019 02:23:48 -0500 Subject: [PATCH] SMB3: passthru query info doesn't check for SMB3 FSCTL passthru The passthrough queries from user space tools like smbinfo can be either SMB3 QUERY_INFO or SMB3 FSCTL, but we are not checking for the latter. Temporarily we return EOPNOTSUPP for SMB3 FSCTL passthrough requests but once compounding fsctls is fixed can enable. Signed-off-by: Steve French --- fs/cifs/cifs_ioctl.h | 3 +++ fs/cifs/smb2ops.c | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/fs/cifs/cifs_ioctl.h b/fs/cifs/cifs_ioctl.h index d8bce2f862de..086ddc5108af 100644 --- a/fs/cifs/cifs_ioctl.h +++ b/fs/cifs/cifs_ioctl.h @@ -43,6 +43,9 @@ struct smb_snapshot_array { /* snapshots[]; */ } __packed; +/* query_info flags */ +#define PASSTHRU_QUERY_INFO 0x00000000 +#define PASSTHRU_FSCTL 0x00000001 struct smb_query_info { __u32 info_type; __u32 file_info_class; diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 823a58550dfd..43b3a9b0096f 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1390,15 +1390,26 @@ smb2_ioctl_query_info(const unsigned int xid, smb2_set_next_command(tcon, &rqst[0]); /* Query */ - memset(&qi_iov, 0, sizeof(qi_iov)); - rqst[1].rq_iov = qi_iov; - rqst[1].rq_nvec = 1; + if (qi.flags & PASSTHRU_FSCTL) { + /* Can eventually relax perm check since server enforces too */ + if (!capable(CAP_SYS_ADMIN)) + rc = -EPERM; + else /* TBD: Add code to compound FSCTL */ + rc = -EOPNOTSUPP; + } else if (qi.flags != PASSTHRU_QUERY_INFO) { + cifs_dbg(VFS, "invalid passthru query flags: 0x%x\n", qi.flags); + rc = -EINVAL; + } else { + memset(&qi_iov, 0, sizeof(qi_iov)); + rqst[1].rq_iov = qi_iov; + rqst[1].rq_nvec = 1; - rc = SMB2_query_info_init(tcon, &rqst[1], COMPOUND_FID, COMPOUND_FID, - qi.file_info_class, qi.info_type, - qi.additional_information, + rc = SMB2_query_info_init(tcon, &rqst[1], COMPOUND_FID, + COMPOUND_FID, qi.file_info_class, + qi.info_type, qi.additional_information, qi.input_buffer_length, qi.output_buffer_length, buffer); + } if (rc) goto iqinf_exit; smb2_set_next_command(tcon, &rqst[1]); -- 2.17.1