Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1339324rda; Mon, 23 Oct 2023 09:31:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8G0vEa/tGTT5OITaCIaCMqUbjEhxUFZS+xfZX4uVX0LODZUBn7HkH+cZU//irjb+e4+0n X-Received: by 2002:a17:90b:124e:b0:274:dd15:87bf with SMTP id gx14-20020a17090b124e00b00274dd1587bfmr17263906pjb.20.1698078687859; Mon, 23 Oct 2023 09:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698078687; cv=none; d=google.com; s=arc-20160816; b=W7jW+iNV84mQKXkaTbBnl63tWymz8KKVAfFAmmrT9+fbeBXA5Tm86F9cPBogoM24Vx TpuGE87MOnEboQyx+/WF1jRG0qzWrFLl3IA44KOJSn6KFSLR9INRXKQ1BPgZ+IpWn4qn 37TDO7h6vYlV9y1lPr2ZnsB4UQhuTJpL+WXwDKYpM1Xbp9U6vCOpRKQ7rXTUSvpipkkd Z0YCgCgx0fc/lYW9ixOuQDGl55Cq4Vhg510yiFD80rgiwUgbcJ5YA8E/UWJEUDlcFybb e4iY0oZYZUXzPp19MyB9nOwLpol4NbDhy4uGbYQ7breZoRS/lY0sGRIcXZzNPaXbJN0e ApEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JCTUhnkp8BfIf0+VHOy2mczZq79A4ZVsByr98RfEeM0=; fh=jv6e9kCAcf5+Yf3cx5WMGVzvpncrUEk/Jjhb7CNfYls=; b=suqexqEGhUc18/qBYS5uql0GFVbxrKc21MvNdeo+e/EbtMBXRdpeDscnGQlGKlIsX0 GXkS+o7pgV1QrblgrYCoKa8GjZXV40vj4wr1pMTQVK0ibpLPwGk+5pMkPXdzMAeEhuRG /k8oPAPPpneqcxwLUnpgEJIY+KQD89budPliLNyOeoyC9hku3JcaBpLrolGtTEssNrLa GGn7eL5Z3l4s/qlFreD5QbLOwivgR9q0PIwQVr8gcORme4Su7sdWL7qG1hu5iIcof2k7 p0rVUiZAnmAStMtwNze4Q7Sy0plCCxXd5fHeBMLKoLDJO4jaEe8Rhgn6wskPMOfUvXEu 97gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gsUvVQdq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u7-20020a17090341c700b001c9f6df8a7csi6998320ple.531.2023.10.23.09.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 09:31:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gsUvVQdq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 8505680775BE; Mon, 23 Oct 2023 09:30:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231159AbjJWQa2 (ORCPT + 99 others); Mon, 23 Oct 2023 12:30:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232723AbjJWQaX (ORCPT ); Mon, 23 Oct 2023 12:30:23 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2C751738 for ; Mon, 23 Oct 2023 09:30:09 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c9e06f058bso32931575ad.0 for ; Mon, 23 Oct 2023 09:30:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1698078608; x=1698683408; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=JCTUhnkp8BfIf0+VHOy2mczZq79A4ZVsByr98RfEeM0=; b=gsUvVQdqt2PqAd5jheAEZg7osBDUmfE+n4ltI3d1XOOdDKU/s4Hby0xm902NqpVTsw L+tPZHLFZ3qDBrULpcfVDg5D3e0/MG0O0rvhyoqpShqxABkZkwnTSPJcc/0kFcaRgL1O SYTarwTHOLF7Q6QWko6iV5K3Tifetec1R0xfw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698078608; x=1698683408; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JCTUhnkp8BfIf0+VHOy2mczZq79A4ZVsByr98RfEeM0=; b=Rzn77UcCB3nUVfLxQ2eyGVQKb0uD/lOXQRTSkCRfkEtsT/YgPYbShIOI7PnV1u09k2 BOIMUfuX5eS64CdWd58adhDBjMUWtREMm4ZKQxuyc5D/Y27lxGVLrAzkz2cDo6Addwcf 6BeVFCYMbRJO0xSPiW3Jh2nUBgOsUnZXmK2RKRa57Y9p0nzroaivJ/tHXLzrpfpMzG/e n9HQOkokmcGk65AoAcRX1MxhtPZXjrVmkEcL1so6oYXj8ewtMdvpflbEcxEzcOgZ0MKG 7SfieJxGCycF3svPGWGNzaOE+4WWnhLtwsKCuaqbgIbY/JjIkQvFp3McVhWlGulrIZCs ksTQ== X-Gm-Message-State: AOJu0Yyxfg/3tY/p0q1isMtUeDKwWVCjuAfXmLAXBCMrgr8xcNIHjH8D TBfm48gRjxZJnws47ZWSiMP3CQ== X-Received: by 2002:a17:903:2304:b0:1b8:a67f:1c15 with SMTP id d4-20020a170903230400b001b8a67f1c15mr15277922plh.25.1698078608431; Mon, 23 Oct 2023 09:30:08 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id j6-20020a170902da8600b001c9c8d761a3sm6042522plx.131.2023.10.23.09.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 09:30:07 -0700 (PDT) Date: Mon, 23 Oct 2023 09:30:07 -0700 From: Kees Cook To: "Martin K. Petersen" Cc: Borislav Petkov , Niklas Cassel , James Seo , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , "James E.J. Bottomley" , "Gustavo A. R. Silva" , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 00/12] scsi: mpt3sas: Use flexible arrays and do a few cleanups Message-ID: <202310230929.494FD6E14E@keescook> References: <20230806170604.16143-1-james@equiv.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230806170604.16143-1-james@equiv.tech> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 23 Oct 2023 09:30:37 -0700 (PDT) On Sun, Aug 06, 2023 at 10:05:52AM -0700, James Seo wrote: > Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") has > resulted in the only arrays that UBSAN_BOUNDS considers unbounded > being trailing arrays declared with [] as the last member of a > struct. Unbounded trailing arrays declared with [1] are common in > mpt3sas, which is causing spurious warnings to appear in some > situations, e.g. when more than one physical disk is connected: > > UBSAN: array-index-out-of-bounds in drivers/scsi/mpt3sas/mpt3sas_scsih.c:6810:36 > index 1 is out of range for type 'MPI2_SAS_IO_UNIT0_PHY_DATA [1]' > > which relates to this unbounded array access: > > port_id = sas_iounit_pg0->PhyData[i].Port; > > and is just one example of 10 similar warnings currently occurring > for me during boot. > > This series converts most trailing arrays declared with [1] in mptsas > into proper C99 flexible array members. Those that are not unbounded > and really are fixed-length arrays of length 1 are left alone. > > I didn't find any conversions that required further source edits > besides changing [1] to [], and everything seems to work with my > SAS2008-based add-in card, but please look things over in case I > missed something subtle. > > Rounding out the series are some opportunistic cleanups. > > The only dependency is that patch 7 ("Use struct_size() for struct > size calculations") depends on patches 3-5. > > History: > v1: https://lore.kernel.org/linux-scsi/20230725161331.27481-1-james@equiv.tech/ > > Changes v1->v2: > - Slightly reword and add Reviewed-by: tags to commit messages > - Split up a commit that was resulting in many binary changes > - Remove the iounit_pg8 member of the per-adapter struct > - Replace more dynamic allocations with local variables Here's a tested-by: from Boris: https://lore.kernel.org/all/20231023135615.GBZTZ7fwRh48euq3ew@fat_crate.local -Kees > > James Seo (12): > scsi: mpt3sas: Use flexible arrays when obviously possible > scsi: mpt3sas: Make MPI2_CONFIG_PAGE_IO_UNIT_8::Sensor[] a flexible > array > scsi: mpt3sas: Make MPI2_CONFIG_PAGE_RAID_VOL_0::PhysDisk[] a flexible > array > scsi: mpt3sas: Make MPI2_CONFIG_PAGE_SASIOUNIT_0::PhyData[] a flexible > array > scsi: mpt3sas: Make MPI2_CONFIG_PAGE_SASIOUNIT_1::PhyData[] a flexible > array > scsi: mpt3sas: Make MPI26_CONFIG_PAGE_PIOUNIT_1::PhyData[] a flexible > array > scsi: mpt3sas: Use struct_size() for struct size calculations > scsi: mpt3sas: Remove the iounit_pg8 member of the per-adapter struct > scsi: mpt3sas: Fix an outdated comment > scsi: mpt3sas: Fix typo of "TRIGGER" > scsi: mpt3sas: Replace a dynamic allocation with a local variable > scsi: mpt3sas: Replace dynamic allocations with local variables > > drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h | 231 ++++++------------- > drivers/scsi/mpt3sas/mpi/mpi2_image.h | 32 +-- > drivers/scsi/mpt3sas/mpi/mpi2_ioc.h | 27 +-- > drivers/scsi/mpt3sas/mpt3sas_base.c | 35 ++- > drivers/scsi/mpt3sas/mpt3sas_base.h | 2 - > drivers/scsi/mpt3sas/mpt3sas_config.c | 6 +- > drivers/scsi/mpt3sas/mpt3sas_scsih.c | 55 ++--- > drivers/scsi/mpt3sas/mpt3sas_transport.c | 9 +- > drivers/scsi/mpt3sas/mpt3sas_trigger_pages.h | 44 ++-- > drivers/scsi/mpt3sas/mpt3sas_warpdrive.c | 3 +- > 10 files changed, 151 insertions(+), 293 deletions(-) > > > base-commit: 6cae9a3910ac1b5daf5ac3db9576b78cc4eff5aa > -- > 2.39.2 > -- Kees Cook