From patchwork Wed Jul 7 02:46:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 12361531 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 C2730C07E96 for ; Wed, 7 Jul 2021 02:46:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6B4161C81 for ; Wed, 7 Jul 2021 02:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbhGGCs5 (ORCPT ); Tue, 6 Jul 2021 22:48:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbhGGCs5 (ORCPT ); Tue, 6 Jul 2021 22:48:57 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8946C061574 for ; Tue, 6 Jul 2021 19:46:16 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id y42so1401895lfa.3 for ; Tue, 06 Jul 2021 19:46:16 -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=zp9FK4ClBBXMRVq3i9TrKEbK6GCWnIVqRpypGdPGgI0=; b=L21NRDTq6wGGhV5/aaUYJXVz/FAj44HFb89R4liQpyQ+c60cTS7qdR1Ai7H3Ud9Yyf 50K7n9gQncPpaUCyJGY/NIkgDOsy0sCXH0pkUQZwlInCJClMHzpuQGqRdz0fheXliOkG dDjGON/XufEcPz1mwMbmUwgDp3yuqyPZz3A72liW5ilJ0JSTQ9poXCNZBkElm+nsf2US td9AWllXLLmO/JuZGT3GjHEdTVTke3EkxUaLn6cMHpR17sYiUr5hQ0btYQy995inwpOB 3Rk1BFaOO1brltPJkslTBLqksP3eu6RuS/+PL2SZjp283cs7JmGrpiiARXjf43lhv6q0 vX+w== 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=zp9FK4ClBBXMRVq3i9TrKEbK6GCWnIVqRpypGdPGgI0=; b=KB9Fh7X4EHeEjNeOqEoFX/mx0lGGGlCrERVk2DYjNzmOo/LN9ZHQUbzV69Ew250dIK psKnzKC1+lro0RBiT8OiqeBMS3CXeg9AGDQFH7a532Krl1ErU+Pbxx0lkEcwDzAWMLRI KW1e5Tebo0zpuIBNey0nCts6wVEwgrNoGDpyU+EnKBGzqvilgNlqZP06ETrePsgb+VeJ Wx+eravvRKjBlBkEwX3AUKvYW3kA8xzTPcjG8qU4vR04Ukq71qjrERDGm+JKFpU3ohfn eAy6hDKrJLDv7DvU0SJT3hKwzNA0dF5N/gHEFnUQBtykaXGzPj5LR3HPO76pU75b+ZiR +ZJw== X-Gm-Message-State: AOAM530BdQuH2R8NK5Ou0Jy4eO0p/jYXOiqDzUZ8fMwkJ2xxa3uQPbHT 5SjxAjmtOzhHX2od3yRkPeIjYkm+ePkWdRgUOnvN0mA7ZxY= X-Google-Smtp-Source: ABdhPJw3pD19Z+oNo3+hpRy5nUtlgoWwyxO2OBsNjES/IhFeV3cNR/4bsv0QoygcljBWhvWbtPI/tUeZIcK/ylhcINE= X-Received: by 2002:a19:5043:: with SMTP id z3mr15927248lfj.282.1625625974956; Tue, 06 Jul 2021 19:46:14 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Tue, 6 Jul 2021 21:46:01 -0500 Message-ID: Subject: [CIFS][PATCH] Clarify SMB1 code for delete 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 SetFileDisposition (which is used to unlink a file by setting the delete on close flag). This changeset doesn't change the address but makes it slightly clearer. Addresses-Coverity: 711524 ("Out of bounds write") Signed-off-by: Steve French Reviewed-by: Paulo Alcantara (SUSE) --- fs/cifs/cifssmb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) count = 1; pSMB->MaxParameterCount = cpu_to_le16(2); From 532db4bf85f9f2fae13154ffc45cfb71279a5dab Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 6 Jul 2021 21:42:08 -0500 Subject: [PATCH] CIFS: Clarify SMB1 code for delete 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 SetFileDisposition (which is used to unlink a file by setting the delete on close flag). This changeset doesn't change the address but makes it slightly clearer. Addresses-Coverity: 711524 ("Out of bounds write") Signed-off-by: Steve French --- fs/cifs/cifssmb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index a513a89aad1a..0863238ddd20 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -5763,7 +5763,8 @@ CIFSSMBSetFileDisposition(const unsigned int xid, struct cifs_tcon *tcon, param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4; offset = param_offset + params; - data_offset = (char *) (&pSMB->hdr.Protocol) + offset; + /* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */ + data_offset = (char *)(pSMB) + offset + 4; count = 1; pSMB->MaxParameterCount = cpu_to_le16(2); -- 2.30.2