From patchwork Thu Jul 22 19:41:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 12394571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80B3AC4338F for ; Thu, 22 Jul 2021 19:42:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5302F60EB2 for ; Thu, 22 Jul 2021 19:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229737AbhGVTBY (ORCPT ); Thu, 22 Jul 2021 15:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbhGVTBY (ORCPT ); Thu, 22 Jul 2021 15:01:24 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D169C061575 for ; Thu, 22 Jul 2021 12:41:58 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id y25so8002042ljy.13 for ; Thu, 22 Jul 2021 12:41:58 -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=2T2UdF5U9AE4wfAUFdvnJ8TrivryyufCnja4iT0JhRA=; b=vIUKByWEsMxjcrJmTUysnP2BbmYDpNcLAguiRIZVa8K0SZfWuSthXmqbcqrFw13/am PjzyqSQaZzeYzKkdFonYx823lmLgPMBRCyPtf94/7B3htM8D95EG6PmQodYlOpYh2Ihc J/fmGY9PK0nNFbHnH2zVyysFCL3tMSLGCPzZKUl6O9apXSbRBh5jArioyzpdA9nzZd6q lqjMyu6tEPab29jqrYUPiGTJF6q8/J6LazP+BrRbDzZu3gITLd0qs4HEGojL9GXBUMrZ IZk4zYY2iZ9Fvge0MjqSueQ0hkASjNGK8tmPYK7b5bDpK36L8jwGx5X9PwJUIEpMs9o8 MGWQ== 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=2T2UdF5U9AE4wfAUFdvnJ8TrivryyufCnja4iT0JhRA=; b=YgHyjyQkScQL1INR1unB4WB8o1MP9WVW7BlrbXjlC3vg8rThO9rlECILYL3SEnwCK0 H4CHd7utsdE50XAZP9n3ttrgRJH3Ki4g9WBZgsDccMcENU8tLUAiUkmp8S9/BusZEW4N dsJsjKaFbEirJ8n5ypEkwttVsRqPnS7hneBztlEIJI3lSrVVDyb4k0FONzwtccXi66NZ FaFvNeEqDftPZL/tVu+LOzyo85kNRd63cjQemJFWZsnGuc8BKOP9RzkkVsY4076tZQOm grA+Qe+ZMoS0EJvfqmZJzDmd3HW5Q5KrVRfh8UFbZAwD9uPKB7GOZV8+T6APOF/dX2cB oo8g== X-Gm-Message-State: AOAM533Lvh58BTdWOsKFw34dpCKiBzcfhFqcuxInaNrIjaZ2cGMvFpqj lqnWVmAUMWGcUImknUl4vrsCKYOQmpkk5o07BE/NA6dC1BBvLA== X-Google-Smtp-Source: ABdhPJytXDst+XXGq4OGsFWDInWT0mogBRo/vllTb9rbqjNLc07Gq/EyfZooQjuEuSP0gOV5N4Nq8qRRqBsy3Q0H3XM= X-Received: by 2002:a2e:9613:: with SMTP id v19mr1083324ljh.148.1626982916370; Thu, 22 Jul 2021 12:41:56 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Thu, 22 Jul 2021 14:41:43 -0500 Message-ID: Subject: [PATCH[[CIFS] Clarify SMB1 code for POSIX delete file To: CIFS Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Coverity also complains about the way we calculate the offset (starting from the address of a 4 byte array within the header structure rather than from the beginning of the struct plus 4 bytes) for SMB1 CIFSPOSIXDelFile. This changeset doesn't change the address but makes it slightly clearer. Addresses-Coverity: 711519 ("Out of bounds write") Signed-off-by: Steve French pSMB->DataOffset = cpu_to_le16(offset); From 7b09d4e0be94968b7c6c117e34ca90cea9c6d986 Mon Sep 17 00:00:00 2001 From: Steve French Date: Thu, 22 Jul 2021 14:35:15 -0500 Subject: [PATCH] CIFS: Clarify SMB1 code for POSIX delete file Coverity also complains about the way we calculate the offset (starting from the address of a 4 byte array within the header structure rather than from the beginning of the struct plus 4 bytes) for SMB1 CIFSPOSIXDelFile. This changeset doesn't change the address but makes it slightly clearer. Addresses-Coverity: 711519 ("Out of bounds write") Signed-off-by: Steve French --- fs/cifs/cifssmb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index d4144c182604..65d1a65bfc37 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -873,8 +873,11 @@ CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon, InformationLevel) - 4; offset = param_offset + params; - /* Setup pointer to Request Data (inode type) */ - pRqD = (struct unlink_psx_rq *)(((char *)&pSMB->hdr.Protocol) + offset); + /* Setup pointer to Request Data (inode type). + * Note that SMB offsets are from the beginning of SMB which is 4 bytes + * in, after RFC1001 field + */ + pRqD = (struct unlink_psx_rq *)((char *)(pSMB) + offset + 4); pRqD->type = cpu_to_le16(type); pSMB->ParameterOffset = cpu_to_le16(param_offset); pSMB->DataOffset = cpu_to_le16(offset); -- 2.30.2