From patchwork Tue Apr 16 23:01:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 10904257 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 2AA5214DB for ; Tue, 16 Apr 2019 23:01:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00002289FC for ; Tue, 16 Apr 2019 23:01:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E404128A00; Tue, 16 Apr 2019 23:01:48 +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 8F4AB289FC for ; Tue, 16 Apr 2019 23:01:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729664AbfDPXBr (ORCPT ); Tue, 16 Apr 2019 19:01:47 -0400 Received: from mail-pf1-f169.google.com ([209.85.210.169]:34827 "EHLO mail-pf1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727942AbfDPXBr (ORCPT ); Tue, 16 Apr 2019 19:01:47 -0400 Received: by mail-pf1-f169.google.com with SMTP id t21so11133405pfh.2 for ; Tue, 16 Apr 2019 16:01:46 -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=uZ16YEIkpmXuLIPN1iU9e901M3VpTZ5njZVDsAwL/DQ=; b=K3oG+VRbvTSd5S2/NvbcNVii9xHPq29OQQ2qAv7aXQlrwln2Jy2JkZx7X4ETfkq2Tv 8GLGAWirJCidm/5gnunP8DNtn9uU93NUWBa0KZC0Kgo3zzK+w7r2GgCxLqoTzGcBlOzn 54hwuRtMVCc+3LVMHWMvluDqRE3IvkR2usyeSvlCX0jxdesz3SwmpUhK9IeiVkbVr07r ntwQRkNWVXUhPg9cMO6r5gn7OInWbgwfMiXKoWvVw3JKtbgALFkWIDoda5+INUmQHFpA wPtolHZX+LMeA3f8TUFCe7sdkA0BrtOdNMtYBY5FkDrOicqRvFNLoYVRSSxEIAxUe7Lb 6BjQ== 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=uZ16YEIkpmXuLIPN1iU9e901M3VpTZ5njZVDsAwL/DQ=; b=Xr138lBnVDkrxNkAB656lA7HUNwzCod9JIVRqSyliP9vthmcYF2blsmxRTHKkXzV8x bTejKS7kDmote1hCXEu3IYj0c3g/L3lCSiqdu9eDJDaCxJO66f0FiH79GH6zfTecSltK yO8KZyjLy29WYxa3ZMK3b4V5aDfRHtfYC3dlXPok0T/Fjd1Qw0sS0RdjWwiE6xHV+JBF dFtJtHXVeYQR0eaNV95axbLZCk/3j6DIpRZIzDMR5eoA4sQjf/fZqWK8nrsYRM1Om47D 3x68chqVQ1obK3aSLgaQlWrHUWgibjcegyrSoRrfybYa5biR6E+61XHiOO57VqgLoMTg G1EQ== X-Gm-Message-State: APjAAAWtNi9iKzCWf3pfoEwvps20ya3CJ4Slbhb9GwALtbhT9oBp8mt8 S6SSTvE+99J28ikoaO4jhf1PvmsziCMjM2pWWUk= X-Google-Smtp-Source: APXvYqyAsNjbfOONWRkPDAgGqOGnfeksmBrSmeGM67QEXnHQukFGyQUzqOKxgqUzNCa0DYv+einoDR/T8nfMZOK74X8= X-Received: by 2002:aa7:8c13:: with SMTP id c19mr84832850pfd.225.1555455706283; Tue, 16 Apr 2019 16:01:46 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Tue, 16 Apr 2019 18:01:35 -0500 Message-ID: Subject: [PATCH] cifs: fix bi-directional fsctl passthrough calls To: ronnie sahlberg , CIFS 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 Trivial fix up for compile/sparse warning From 2dce1073a0008e46673684cc59b990504fc66235 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Mon, 15 Apr 2019 12:13:52 +1000 Subject: [PATCH 1/2] cifs: fix bi-directional fsctl passthrough calls SMB2 Ioctl responses from servers may respond with both the request blob from the client followed by the actual reply blob for ioctls that are bi-directional. In that case we can not assume that the reply blob comes immediately after the ioctl response structure. This fixes FSCTLs such as SMB2:FSCTL_QUERY_ALLOCATED_RANGES Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French --- fs/cifs/smb2ops.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 08ff044fbb4b..841ce7e1fb72 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1462,12 +1462,19 @@ smb2_ioctl_query_info(const unsigned int xid, io_rsp = (struct smb2_ioctl_rsp *)rsp_iov[1].iov_base; if (le32_to_cpu(io_rsp->OutputCount) < qi.input_buffer_length) qi.input_buffer_length = le32_to_cpu(io_rsp->OutputCount); + if (qi.input_buffer_length > 0 && + le32_to_cpu(io_rsp->OutputOffset) + qi.input_buffer_length > rsp_iov[1].iov_len) { + rc = -EFAULT; + goto iqinf_exit; + } if (copy_to_user(&pqi->input_buffer_length, &qi.input_buffer_length, sizeof(qi.input_buffer_length))) { rc = -EFAULT; goto iqinf_exit; } - if (copy_to_user(pqi + 1, &io_rsp[1], qi.input_buffer_length)) { + if (copy_to_user((void __user *)pqi + sizeof(struct smb_query_info), + (const void *)io_rsp + le32_to_cpu(io_rsp->OutputOffset), + qi.input_buffer_length)) { rc = -EFAULT; goto iqinf_exit; } -- 2.17.1