From patchwork Wed Jul 7 02:32:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 12361441 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 7CCE7C07E96 for ; Wed, 7 Jul 2021 02:32:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6408361CA2 for ; Wed, 7 Jul 2021 02:32:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbhGGCe7 (ORCPT ); Tue, 6 Jul 2021 22:34:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbhGGCe6 (ORCPT ); Tue, 6 Jul 2021 22:34:58 -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 76B6FC061574 for ; Tue, 6 Jul 2021 19:32:18 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id e20so688665ljn.8 for ; Tue, 06 Jul 2021 19:32:18 -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=J6edy1Q3uFiMOoeNC4ijFGchxRUA2b/DRCKTIWpJrXs=; b=bsqB684MOtWpLXxeB1PoFHCipmdHwk+fl/KtrDldGIldqUXjRCjBGNzwIGBAY3Eu2S UgQrs5rkpX1nuPfoQOyYLd8Kmhn35LJlPtUkURJDqm2tXQWhdfEkqMqAqJCXLTe2GKya A7nx5AsUYwgSToai/VabFU9Bz53VbBD6Gx1nnOMK7RX9OljvHAYO4v+fhFDaQu+uMZ+K T8GrJXTxJJl/FkpsmmdtJkTo+XQiiTrYbTv1Dn9opOAhwlebtEiCCLzD/m43rxZwmawQ ySO13jWCpDxIqSH0fCrXNnuR3nDCxyRTx/4/j8qV98EGSijyA0c1F+7/LaN2ue5RWhEf /j2w== 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=J6edy1Q3uFiMOoeNC4ijFGchxRUA2b/DRCKTIWpJrXs=; b=Ea+LMw2potZ4HRUZb6phK+WurmMrNK6NuSfXb1flcZp8qgIJAvf815wh2CkqQOr/5U fWmWE1TqNFcip9/McYk+Bt8w/83GCuw+uw2EgGKq6OkUdllDq/R19LTb4OPTvxSsVvTk 0zJ2CfgWaNe1IAVq78HpCT0C/xXuQq42BJ2G23FYKfuzR3MtKUvEttax3x8DeibiIOAN m6XltzrXODpBF1czGNHq4OQ9sKLaYvSVbeaR1bz9MdladmP/8XgC+adv2HJ/TxAdtLXX yIqBOrZgGJ5hPnqi3FjhxIWlVXxgNWZz1Z0SvQt9DSF8GVrBxcakinauxJqc/E8mzWrO TnXw== X-Gm-Message-State: AOAM5339t3kaenm9O28OaKUh2RXS4/RnVr4w2mSXMRitwHKAf9Yr97Ls oaKeGRA+7tbgIzW+IFPSPLEW909bnq3vZ43MFSTngIGJaSw= X-Google-Smtp-Source: ABdhPJxPCaprH5i5qQH1j6P36UAM/qJbPSiNzQDfIY0t9uMoc8Ztr7hbzUhXG+/uWIRJNYXjXCVMWtIbMF+Ch6rmEoY= X-Received: by 2002:a2e:140e:: with SMTP id u14mr9944014ljd.148.1625625136264; Tue, 06 Jul 2021 19:32:16 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Tue, 6 Jul 2021 21:32:02 -0500 Message-ID: Subject: [PATCH][CIFS] Clarify code for SMB1 SetFileSize 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 setting the file size using SMB1. This changeset doesn't change the address but makes it slightly clearer. Addresses-Coverity: 711525 ("Out of bounds write") Signed-off-by: Steve French Reviewed-by: Paulo Alcantara (SUSE) --- fs/cifs/cifssmb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) parm_data->FileSize = cpu_to_le64(size); pSMB->Fid = cfile->fid.netfid; From 1194128e37edf86c7e2bbb61f878573f54fb0e80 Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 6 Jul 2021 21:27:26 -0500 Subject: [PATCH] CIFS: Clarify SMB1 code for SetFileSize 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 setting the file size using SMB1. This changeset doesn't change the address but makes it slightly clearer. Addresses-Coverity: 711525 ("Out of bounds write") Signed-off-by: Steve French --- fs/cifs/cifssmb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 22b8c12962fa..a513a89aad1a 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -5628,9 +5628,9 @@ CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon, pSMB->TotalDataCount = pSMB->DataCount; pSMB->TotalParameterCount = pSMB->ParameterCount; pSMB->ParameterOffset = cpu_to_le16(param_offset); + /* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */ parm_data = - (struct file_end_of_file_info *) (((char *) &pSMB->hdr.Protocol) - + offset); + (struct file_end_of_file_info *)(((char *)pSMB) + offset + 4); pSMB->DataOffset = cpu_to_le16(offset); parm_data->FileSize = cpu_to_le64(size); pSMB->Fid = cfile->fid.netfid; -- 2.30.2