From patchwork Thu Jul 22 18:58:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1508844 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=uypBeevd; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4GW1vj1Wl0z9sT6 for ; Fri, 23 Jul 2021 04:59:13 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbhGVSSg (ORCPT ); Thu, 22 Jul 2021 14:18:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbhGVSSf (ORCPT ); Thu, 22 Jul 2021 14:18:35 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AFAEC061575 for ; Thu, 22 Jul 2021 11:59:10 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id g22so10140042lfu.0 for ; Thu, 22 Jul 2021 11:59:10 -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=Bew8qUCK1VrN0VQJNLhW1NacYLqOiV0G6ii2zRK6mP0=; b=uypBeevdTvwWnMmNZlZszMhb3q9+r02yVw4KuvotbRhfCuE3QQ3BxYbBwtMzH45j2L aR981j/HBMyy8yqRTXlSPzglQN6qvW3PGTNjtTgZepNrdGCKdHaHikUe4N4JK/OXWm0U H67aFvW3M4tbvMJVJll6DVmz/mxIyNhzePp5RCbwn4SH1B4kRfd3RFKWeoEPNnxGY2a3 5U8ri1nG0+/6zzbjPZVRz+lRvfAFk9kTtg1sQMZTnD2ap9u1GQPsMAVBEly732m36iGG ptRkjONGMWSINH2B4ZXCiJE63ijdUJz4BEVzIJMy/GWRiV3Sngn+XGpCYEtxfpjRpNU0 2FOw== 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=Bew8qUCK1VrN0VQJNLhW1NacYLqOiV0G6ii2zRK6mP0=; b=Jal7dB8dP+qliK3B5tS0mMx2PNf5MxWkOpXqcVBTB9Lx9qPgaL39mEVL0ZpEZ8GU95 Pm7gpsPlIWXT+xt6+fJdM4Jvg9EVTEZZoYADrmIzjQyoxAAX/08v5v5erMllkShrPR+3 qtWqHvbluxx7C9iNT/Iz7PXFm6aeH47YrOl67YuMuUQhaEIdHTdifoZUU10ayojF8emn Oumis3HhtcagJ2KIHVThYGwfkiJdnqbe6HRfFwmOiyIQS5vHrNud6nurxeIS8U4lg9Um 7ug0g4N5jvoqcUoH0BwrAuSh3wlszJmbaA7C8HXwA8Kf1qzahLn/p2z+siXILzbMtJd0 405w== X-Gm-Message-State: AOAM532e4yWUblK0dfNsoZyOBnSiAl7CoFFjMU5DfFtg+IZmByakb6kz xbAoCjj35Bz7bCGKhmrv0YinS1dlNA2sYjRVyEyBJDOj+dPCEg== X-Google-Smtp-Source: ABdhPJwCtB7SK5idQ/dcJEn0xU3T5BcRgQp3ucW5tUe4kqSn6Gx5Rw3rGl4BsKa3Z+Qnb1Xs+2fS4HXx1kRDJ8y85p4= X-Received: by 2002:a19:5e15:: with SMTP id s21mr608554lfb.282.1626980348304; Thu, 22 Jul 2021 11:59:08 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Thu, 22 Jul 2021 13:58:35 -0500 Message-ID: Subject: [PATCH][CIFS] Clarify SMB1 code for POSIX Create 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 CIFSPOSIXCreate. This changeset doesn't change the address but makes it slightly clearer. Addresses-Coverity: 711518 ("Out of bounds write") Signed-off-by: Steve French --- fs/cifs/cifssmb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) pdata->Permissions = cpu_to_le64(mode); pdata->PosixOpenFlags = cpu_to_le32(posix_flags); From 21a64910997e0c1d268bebf9b1217ba5804d592d Mon Sep 17 00:00:00 2001 From: Steve French Date: Thu, 22 Jul 2021 13:50:41 -0500 Subject: [PATCH] CIFS: Clarify SMB1 code for POSIX Create 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 CIFSPOSIXCreate. This changeset doesn't change the address but makes it slightly clearer. Addresses-Coverity: 711518 ("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 f72e3b3dca69..d4144c182604 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1081,7 +1081,8 @@ CIFSPOSIXCreate(const unsigned int xid, struct cifs_tcon *tcon, param_offset = offsetof(struct smb_com_transaction2_spi_req, InformationLevel) - 4; offset = param_offset + params; - pdata = (OPEN_PSX_REQ *)(((char *)&pSMB->hdr.Protocol) + offset); + /* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */ + pdata = (OPEN_PSX_REQ *)((char *)(pSMB) + offset + 4); pdata->Level = cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC); pdata->Permissions = cpu_to_le64(mode); pdata->PosixOpenFlags = cpu_to_le32(posix_flags); -- 2.30.2