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: 1501544 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=L21NRDTq; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GKP231Xgvz9s24 for ; Wed, 7 Jul 2021 12:46:19 +1000 (AEST) 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