Message ID | 20230922175322.work.170-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5889678vqi; Fri, 22 Sep 2023 15:02:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElS6liFyc9Q0wPK/Dk/6W49mETF/jk1avsXxoPGdQr/SOVVIqgegiviA0xtIJv0GyiOdz0 X-Received: by 2002:a17:90b:4a49:b0:274:9200:3973 with SMTP id lb9-20020a17090b4a4900b0027492003973mr926267pjb.36.1695420170643; Fri, 22 Sep 2023 15:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695420170; cv=none; d=google.com; s=arc-20160816; b=VnJTXhGq0GYFBj7bBXtmyzTdVqmS9QMLAxMKmgwafeKal7RZqVPwRyQHtwRmIoMHKW qvTPS0OjrBWL8DwfyK4M/LH0dWLf4xhBSGVFo3LFKQL98q/V5YjegrL6fCMF020h1zRS sJA7PVsWIzC/QIhz+bbjGVL45sULmaFLJXp2QukvLLiFjcoeDlvsqclus3YFpuGMYm/1 B0Dz4jR7GAjjJ4VyCZYdvZJHymWwuXZDZ3vwHtAEa9X8ZhLmb2ob2miFOaL+qRWbflEq 2dx/FiDTNporj7J2gWIUl96HIGW7q6lDcQnOA6aWssy6KlXtomT+UErc5Ch98WEnWHto gYLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=IKU0OOROZX8GtXmlmWtOSoc3m5tAbejEF8ueJbXNfc4=; fh=cH5kIAIdIm5WkBFhAk1EF2O/LMVl9SfsVUIypKMAwIc=; b=0buAZHaiZzgWK/i8x7yMt+vzAKjOAOHHoIH3HWGP2U8HzuFVgHcP1ASHbItXbw2nTj oI4uyG61ZqxSvO4LkxPF7ridcnxoXUcdwKb90rLhJaDMOjxtlqJty5rvhe0EUyWIt1NP 1cj6UCictotLUEL0DEswQBGmo3xKkVMBUmK5BnAv5hrqzOGIn99ks3oZtKBYOvnEgdtE 4BLa9BV7sNYl3yoBWJcuS2ZXiPZTnGLLuEM7Jc3Dhodnh21OM2m56BBL5JfR79V73pgn tgqspDK/idrsy/jQWBy74dHlgJdpTw7S0qxC/lEb6eRcEGbZsvVsOyJR/iJnbZN+3Ri6 AaMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=F58ptNvB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id mq18-20020a17090b381200b00263c23a5693si5353600pjb.13.2023.09.22.15.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 15:02:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=F58ptNvB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id D23318022E7A; Fri, 22 Sep 2023 11:05:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233955AbjIVSFh (ORCPT <rfc822;pwkd43@gmail.com> + 28 others); Fri, 22 Sep 2023 14:05:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233570AbjIVSFO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 22 Sep 2023 14:05:14 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 513592727 for <linux-kernel@vger.kernel.org>; Fri, 22 Sep 2023 10:53:25 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-578a44dfa88so1753674a12.0 for <linux-kernel@vger.kernel.org>; Fri, 22 Sep 2023 10:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695405204; x=1696010004; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IKU0OOROZX8GtXmlmWtOSoc3m5tAbejEF8ueJbXNfc4=; b=F58ptNvBVKPGVaAMka8B0iZ/kGkA3NLoJFen4r6FZYlwVinh261WVZhVNwNNOciVny 4DcqwtxzJHW1bv6vFwI/MR920QoJP15/trvKvGxJsVx96ij95Z1Aks9iOS8+gGq523HI cOfOqNse7sm2a4Gnr26nKCWAqoRuwkrzH8yPE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695405204; x=1696010004; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IKU0OOROZX8GtXmlmWtOSoc3m5tAbejEF8ueJbXNfc4=; b=kWz3ieO4+HRWgJhHR/43Enrsz6zMUTZWWPGEaHjALsRRQuixkMwWDmH5am9xvUZcP5 KgHByw1Ivt0qye/EBS+ZSeHTGYS/Txhe+9PWjWGYDYvrtEbkQib1mpOSrRlyjryua12E lq4sm8NA3mAWJcSnJJSnKHdPzsuvabPNslp28VULm+TrHgv93WybIwT6x9kB8+Kc3gGl Z/qD0pKE6Rd2HM0Es7n+r7sxX3DWyAkjx4S7vFviM8zXRan8Ap1UD0rSvwzRCSzswdd+ Ug1gXctgBtI7jvxR0mPEeSZvrTBCMk8qC4tGwxcBH+r1csJ/HknXoAz8hQfXQzW+KDVd J6wQ== X-Gm-Message-State: AOJu0YzcKxTb2+ztrNDX684iKbDb5ngAgz4sG1AYNtJ6/yqat0Lvho8o rKanN84DB852DnDsxx9UhcEWuA== X-Received: by 2002:a17:90b:1010:b0:274:6839:6a8c with SMTP id gm16-20020a17090b101000b0027468396a8cmr417452pjb.6.1695405204678; Fri, 22 Sep 2023 10:53:24 -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 gp24-20020a17090adf1800b00268032f6a64sm5263304pjb.25.2023.09.22.10.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:53:24 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Mark Brown <broonie@kernel.org> Cc: Kees Cook <keescook@chromium.org>, linux-spi@vger.kernel.org, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] spi: mchp-pci1xxxx: Annotate struct pci1xxxx_spi with __counted_by Date: Fri, 22 Sep 2023 10:53:23 -0700 Message-Id: <20230922175322.work.170-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1195; i=keescook@chromium.org; h=from:subject:message-id; bh=e8Sf0qGa4GnkduLkbR5QVFirRy5SjwftZRC9XwaCaCY=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDdSTbzRFK4+Or9MsQ5t6WkcBxx10MfOAmUZo3 pFRqrY3QsqJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3UkwAKCRCJcvTf3G3A JtW1D/0Z2xHXPyQGLIdKy1N7E/opbora00YtESYD+ty6cAdcM4pNdrtP+Jq3IH5IOOGBWn9n1eS 8uG7hhmdw03xWE2evg0UZh3CgNCbhMBtcmy8MK8iPe3+gN/eTFfXr2sJrgUB2Qw749p3CWg2iew IfNsRu1jQAo6Aa77Jkp3bwvCKP0d3k196ICBYnePUOrosEyIETz+XId1BgfUFQIYfsN2oK8h875 Tsu5WRENvEW1sI7BcjEk4hdYF6bLypg4kZpU+T9Ss5majLz4bYsG60uxFt77nH92rr5Qm78V+LR z8XII87IrDNiXgFrE7X6V/wyLDQ7feSQq5Y51LZIyQM9NQcH1humoQ2mCYrabvaWFaqEF3cEsF7 275CdvQYgQXmatoG6GDm/mM5aeAU/5i/vvkAI35lEmW/Vf4VMbtcuB335o2K5v4R4kwZLkTf3Qg VQ62z2h9jSMFmNhCX/nL0h4aWZYOo6j0zjy42/nyQT+7jTvC2a4c6bmcOnwBiX/bI58sPtDBgnA Ick8nKcuJTVRD+DFYmPiAExYWBqzEfcggr7Ex5akn7SYwglRZ4bC84R8lksWvp19CN9VOaJy5mp vI5eTc1MJxnXmy6bVagZocn/17k/A1thqk5TU7ysuKVlx6nGUCcIR9AEhvvJ/KJEnGWV3I9wErM Uo/pDz6 SkGkVu0g== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 22 Sep 2023 11:05:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777776900692345389 X-GMAIL-MSGID: 1777776900692345389 |
Series |
spi: mchp-pci1xxxx: Annotate struct pci1xxxx_spi with __counted_by
|
|
Commit Message
Kees Cook
Sept. 22, 2023, 5:53 p.m. UTC
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).
As found with Coccinelle[1], add __counted_by for struct pci1xxxx_spi.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/spi/spi-pci1xxxx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, 22 Sep 2023 10:53:23 -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). > > As found with Coccinelle[1], add __counted_by for struct pci1xxxx_spi. > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next Thanks! [1/1] spi: mchp-pci1xxxx: Annotate struct pci1xxxx_spi with __counted_by commit: c40897f4730f4f9a37f3155e3e0452e1c8da37b4 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
On Fri, Sep 22, 2023 at 10:53:23AM -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). > > As found with Coccinelle[1], add __counted_by for struct pci1xxxx_spi. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Mark Brown <broonie@kernel.org> > Cc: linux-spi@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Thanks -- Gustavo > --- > drivers/spi/spi-pci1xxxx.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/spi/spi-pci1xxxx.c b/drivers/spi/spi-pci1xxxx.c > index 3638e974f5d4..5b2d3e4e21b7 100644 > --- a/drivers/spi/spi-pci1xxxx.c > +++ b/drivers/spi/spi-pci1xxxx.c > @@ -77,7 +77,7 @@ struct pci1xxxx_spi { > struct pci_dev *dev; > u8 total_hw_instances; > void __iomem *reg_base; > - struct pci1xxxx_spi_internal *spi_int[]; > + struct pci1xxxx_spi_internal *spi_int[] __counted_by(total_hw_instances); > }; > > static const struct pci_device_id pci1xxxx_spi_pci_id_table[] = { > -- > 2.34.1 > >
diff --git a/drivers/spi/spi-pci1xxxx.c b/drivers/spi/spi-pci1xxxx.c index 3638e974f5d4..5b2d3e4e21b7 100644 --- a/drivers/spi/spi-pci1xxxx.c +++ b/drivers/spi/spi-pci1xxxx.c @@ -77,7 +77,7 @@ struct pci1xxxx_spi { struct pci_dev *dev; u8 total_hw_instances; void __iomem *reg_base; - struct pci1xxxx_spi_internal *spi_int[]; + struct pci1xxxx_spi_internal *spi_int[] __counted_by(total_hw_instances); }; static const struct pci_device_id pci1xxxx_spi_pci_id_table[] = {