From patchwork Fri Sep 15 20:13:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 140738 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1362111vqi; Fri, 15 Sep 2023 15:46:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaMJi9wZbMoLuhyUIR8dVImxaCqalx/4tHY0e97UWRFpjwpivoW9h5iqBKWGgpDZjgY2fb X-Received: by 2002:a05:6a00:1397:b0:68c:3f2:5ff8 with SMTP id t23-20020a056a00139700b0068c03f25ff8mr3332777pfg.1.1694817977861; Fri, 15 Sep 2023 15:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694817977; cv=none; d=google.com; s=arc-20160816; b=P4vxp4HoTV3iqdAdOOA0gF6d3VoSRsC+mrWMoWYLny4SL8xtRTwt5PbDHp+buT85YX c1VUXa8X+Ph4nMrQDwAWxBftb4uz8qvt83FscPwB/bKAonjXiGetGHJc/IWyvt3HcSdq 7uVMC6KDYIUMgkHbKd4u7sgF/FaMKgBTjc/QJjteXIkgDOaNOjkMypnE+F5OTMAnFNHU oSK5A8ZqdUfV4vHNP0U/Uy53GEhrsPc3nxXqvP43lRG4yTgk13yzd/LpGnx4cfkq1pm3 irNduTx8golUzCM1R9ESZdWsz96288hDQdQg/0JX+JM+P3rJ9MG3hrJc9eEB9rBsYNal 8IfQ== 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=2M49lx0SrOSxw3SwYD5z4lDni11acdMA1KrbMre3cHA=; fh=RP5b9qprzCmviP+pny77i6gUMRMQVjXC86s+7KjbPeQ=; b=OA4omzS+f5967cWpg0Nitcfk2x/vswStIIYq3xUUBG4dnugftRpkce8SEomIhiLB4/ ac17icQh/PIUczo6xJwAdGlItH+U1WvtUUP1qISGxcKEjj08scFK5KPJp1lq1NGbHQTq iOQ/m+eNmocG9Atrz8rbQt1Wk34FR9MRsctSIZU4Zl+Hwv/sejhFcIWEOfnZ6/f2wHRB GGtISkb4CRnV6itZb0gqrVHrsTQDYZ7mMKJpDLU/wPJWKAcmGD5DdOrAL5tXl0a8am2g AbPIlR0A0VmfhwPKkwGeziKHXRPCJJYJl35DSRz8ps4Shk/JiJzRjh57T0wxrh5n1sFJ AycA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DY1mxFbh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id f19-20020a056a0022d300b0068bc14cabc0si4024690pfj.31.2023.09.15.15.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 15:46:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DY1mxFbh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id E26A28119D37; Fri, 15 Sep 2023 13:14:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237294AbjIOUOO (ORCPT + 29 others); Fri, 15 Sep 2023 16:14:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237317AbjIOUNt (ORCPT ); Fri, 15 Sep 2023 16:13:49 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 725CE2D67 for ; Fri, 15 Sep 2023 13:13:03 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c1e3a4a06fso21426825ad.3 for ; Fri, 15 Sep 2023 13:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694808783; x=1695413583; 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=2M49lx0SrOSxw3SwYD5z4lDni11acdMA1KrbMre3cHA=; b=DY1mxFbh8oyQBVBSke3Qb3cDb5AdkNpTTL1bcxjv+x1t6TPMJMi8fyr/nVJ44TkzTm onrDJs+HnHbP5r8UOkkS3f1+mzKAebSq2o3C+mcjbnzHjLrhmpGWDhWguudCnCncMsZ3 /PTs10DvWPeS7bomZ650s7kYIkMcZ2lWPexlQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694808783; x=1695413583; 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=2M49lx0SrOSxw3SwYD5z4lDni11acdMA1KrbMre3cHA=; b=m+JbmTnEvT6UzkQyDuLqFESSVQmFkFuMLtZKvLtGTj1wL73rGge5j/km7KsM+jdfUh FgPr3UYInz1E4UtCpVmxy3SI2dfe5FVFAZ7G/wumQiAoB0JYpsha/zmWWb2SoYEc1/Q9 74RUT3loqNvsX1TfCA9fdIuKSiWKAd4XhkiV6xuphFdVFXlfoRbOykOETgdyIlgitKw7 GUD3prU78MIAxkBwrbwPeBOep7P2y6N53CsQoESsvng4xG0fp46EkyQznAqTjkWt2BJj bEyLnwTuPaABSjLyEFfzI15lZWkoYJ1TRT77TBYOJlzchZal0BqlElLXrrxRiJKGvsPF sSoQ== X-Gm-Message-State: AOJu0Ywngm6Vm70PBSSow5ted07ITMlRFo6HGwm+DAJtqXDhoMROrboc +kSaz8QKxhvgVCDOHrnL/LhHWA== X-Received: by 2002:a17:902:db08:b0:1be:1fc:8ce0 with SMTP id m8-20020a170902db0800b001be01fc8ce0mr3734260plx.12.1694808782967; Fri, 15 Sep 2023 13:13:02 -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 iy13-20020a170903130d00b001bdd512df9csm218663plb.74.2023.09.15.13.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:13:02 -0700 (PDT) From: Kees Cook To: Miquel Raynal Cc: Kees Cook , Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Manuel Dipolt , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Nathan Chancellor , Nick Desaulniers , Tom Rix , Heiko Stuebner , Martin Blumenstingl , Rob Herring , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Yangtao Li , Li Zetao , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] mtd: rawnand: sunxi: Annotate struct sunxi_nand_chip with __counted_by Date: Fri, 15 Sep 2023 13:13:01 -0700 Message-Id: <20230915201300.never.057-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1533; i=keescook@chromium.org; h=from:subject:message-id; bh=9LgHW2ESmAWnpC8VkPKIjSNhD9+xewvO1BU6xLYCYys=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBLrN7bH2fSvx7Pk5xVsFyM9ZP63U7SCER0Gx/ 1a7bYV9DdCJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQS6zQAKCRCJcvTf3G3A JjKID/9gXg8w66qZfCGmvAX8Ub+SGXwCmA3YOfUDES+znbHz9/CripNvDDfLLhe5EVL5h3kJO6m 35FkrSXVpHWljoV3QAOyH34CLD+X7WoBY2hQCne3oLauVtJFKYHDi+1xiM60MUD1cJm+7bbrPJR Ywyhs6nkYn/yLxhuQB0Fg1lA7qfOoQSt/ZGI/pRPV9ehSOb6n0owmVEYm1v+VZjAxzACRWjjEzJ +MmwR6qVCBlwlOD/h9f+V0KeODYE1O4HuqtBZSp8eTEEP1kjtc92Zh+EPRzpvDwywIzQFygFFgU R5CTNEBEP+5eUFeKYDnan3QUhZzTJnNk5c9NXJ3lpIe9/q204g/M2+fpbPFY1UGEagTqKyI43tG eh/NDIHf3zTaM5cZpHL++wvYoz1PzEpxmgQMhi/gkJKk8p9LixpYEHQx1WGSlvkbLs22CqHGZB0 +qB8wd1Rlxqkds0B9k3Nm73iul/qPyRkx82+hWrle4r77c4F0aMZyQJx1sSZXAL74oUSuZ2n14m /04J/LRUq8a/BALl+3ZyJVurqFg5w7rtQEcqho0TVyRT8YEn9PvICX4HaJwQuPcfk7mY79YwlIv qzUUZprHpLJZTbfjJvdTAgUje2fPni05Ab33Ntka+sBFJpOgRhy66zEWzU5ChzUyC4SK2vfYD4t b0+mhO7 VDdYbzZw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 13:14:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777139219999933434 X-GMAIL-MSGID: 1777145455925337859 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 sunxi_nand_chip. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Miquel Raynal Cc: Richard Weinberger Cc: Vignesh Raghavendra Cc: Chen-Yu Tsai Cc: Jernej Skrabec Cc: Samuel Holland Cc: Manuel Dipolt Cc: linux-mtd@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-sunxi@lists.linux.dev Signed-off-by: Kees Cook --- drivers/mtd/nand/raw/sunxi_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 9abf38049d35..4ec17c8bce5a 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -197,7 +197,7 @@ struct sunxi_nand_chip { u32 timing_cfg; u32 timing_ctl; int nsels; - struct sunxi_nand_chip_sel sels[]; + struct sunxi_nand_chip_sel sels[] __counted_by(nsels); }; static inline struct sunxi_nand_chip *to_sunxi_nand(struct nand_chip *nand)