From patchwork Fri Oct 6 20:17:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 149399 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp574076vqo; Fri, 6 Oct 2023 13:18:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSaWYw+e4JoQD5OMl9jFlNrBd1ZkwsJhHtghEbrltNvINibtJRQQ9ZoEL+eqQXwiLSDzvX X-Received: by 2002:a17:902:8212:b0:1c7:29fd:33b6 with SMTP id x18-20020a170902821200b001c729fd33b6mr8470244pln.40.1696623498711; Fri, 06 Oct 2023 13:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696623498; cv=none; d=google.com; s=arc-20160816; b=XLjG749qCMMhlmTg096Fs2YqBLSa30af+EyPI8aaiqnAvtWGhUQPFAAcMv5YlbtSkM XQz4rNVLRzkCsvixMfhP1ybVq7x/IdJ6UR6sU1nhlXPJBqisDUzZ4QciyrmrEI+KUuCH hfehTu8u+vOwMrTEqkogWfOyMiiWYQg6jyi8Hd3wWEXcHdeCsd4DbFIkmfdY6/izmhsU uz5Ry/wM6Mtb/FDYqR4Jioxec5OLvf7FjX4uQf9Ha4TFAZjEC5maIBiPpGDdXwDSpdWp 975HsbBd0SAHBUBmFaGCGtZBk6LpemGRAo/fGcHlUEnigm3cKoYXYYdj1Oo0VjaqGOck ECVA== 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=SVW48+aAw5RrT5lkfRy3SJYTnhGkwarT0QT62F6zY44=; fh=pWPpWT0887WIDqeeEJ5ibAzMxoeJU1Hq9vz+oEBA/Ko=; b=KOkIx6OCDwA4vDbBhAkcm4cpaI+06WcH5UBK5ShLxECSXUCEywtA0TSapRlP8G25z+ x/TJ1aTvmOIGTliVGuicjoYo23k5kjbvFRfPpoS8qEAiy/L7nOyl1gY+6E8obuRj9o04 zq5JsgpRDE4VqKGOdkl8zQU6IvttGy/MNcBHJk7cawZJ3g+1skaoXAqX3vONsZergamk Wf1UJLVqlHUYFq5BUeHlnbkBP/JsqkzpjCHVPDgFUwL6Z4Z4auX8QMvWlf+jNrGjkbnG mCg6/YfOyw86AgZ5A7UPKZ4TCZpG6s2sEQeT8OP/RZCjqXqqsipMH+Gbf+jgWSTZa6bZ oAzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ULKnwnb8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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. [23.128.96.31]) by mx.google.com with ESMTPS id u9-20020a17090341c900b001c5ecff1bd4si4630991ple.603.2023.10.06.13.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 13:18:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ULKnwnb8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 3826680B19CC; Fri, 6 Oct 2023 13:18:16 -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 S233461AbjJFURx (ORCPT + 18 others); Fri, 6 Oct 2023 16:17:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233437AbjJFURv (ORCPT ); Fri, 6 Oct 2023 16:17:51 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B6CCBF for ; Fri, 6 Oct 2023 13:17:37 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-690bc3f82a7so2264490b3a.0 for ; Fri, 06 Oct 2023 13:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696623456; x=1697228256; 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=SVW48+aAw5RrT5lkfRy3SJYTnhGkwarT0QT62F6zY44=; b=ULKnwnb8G0N3lbHYsw1zCXa+eYk4VmkMVui/kjGkhAmncYHkwlnhpKoD/fflMOPVP4 kcTWJnkGVEZO743tx48QyvflU06THMOT/epv9UXja9O1nRJUwDSsS5iyBlpy8yLOCeSY ktT1bAv0qE7zg6MfJXt8jHC9feQeXTGKTGFOw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696623456; x=1697228256; 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=SVW48+aAw5RrT5lkfRy3SJYTnhGkwarT0QT62F6zY44=; b=OP4XQEFxWmtBUInH/pIo6LpxBCy4yTIVYAshosB7ITmjZWBdJOn0QvMhIdgSfCNWFD ZcX+SqjxOhGvTYJmGyCMdg2xWz2TVOafQoKhCUncPIx1o7xZmHM8bzqEFS/GxyANtVqH aA0A4Fu653oigMWuQS4l3wXE+k9oZYpfiM5xxEfUelvF48T2SiDto9AJuakC7j8UcxDX 1crF3HsKBgbSzOU7rhOml0RdwsKZp+B5Gt2JmZID4ksz9pmIPIx1Iu9hpSWE/YI0rMq6 JnvcMqKtlXiDdau2wIwFFqy9Vwz2yIS8wNutkqmAKHdlEtDoN66bt5zCjbzolUzjlyJ6 xW3g== X-Gm-Message-State: AOJu0Yz7HzrcEkWG3xO81Hsr3crq+IEGIRAS5yKArlz3DI8vLjbqGqdK OhEQolsS9X/pUVT1+/YZ/tkqxg== X-Received: by 2002:a05:6a00:1d89:b0:68f:c6f8:144a with SMTP id z9-20020a056a001d8900b0068fc6f8144amr8344041pfw.22.1696623456614; Fri, 06 Oct 2023 13:17:36 -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 g29-20020a63375d000000b0056c2de1f32esm3761746pgn.78.2023.10.06.13.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 13:17:36 -0700 (PDT) From: Kees Cook To: Miquel Raynal Cc: Kees Cook , Richard Weinberger , Vignesh Raghavendra , "Gustavo A. R. Silva" , Martin Blumenstingl , Nicolas Ferre , Roger Quadros , Thierry Reding , Yang Yingliang , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Valentin Korenblit , ye xingchen , linux-mtd@lists.infradead.org, linux-hardening@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , Heiko Stuebner , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] mtd: rawnand: cadence: Annotate struct cdns_nand_chip with __counted_by Date: Fri, 6 Oct 2023 13:17:34 -0700 Message-Id: <20231006201734.work.060-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1719; i=keescook@chromium.org; h=from:subject:message-id; bh=v/mBW37FRWiHDbQSeKGRt7jHSIbBK2m2caz2GN2pAMs=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlIGtehhtNs4fsQLlK/idmpyBfIyy3VLPUCxgiM uN0LPqd+ImJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZSBrXgAKCRCJcvTf3G3A JkStEACSGTbTsp8zz1atoDGJhIXcLq7dkczKkpuqx43dYR8vq3nM6javyZ6DU7cAg2OhRoAplw0 mA8jHnMFQixkl5LkbmCfoRytUqgJCK+dMCySAAPwBp9IItFtaqczmNI/I6/d/gDJvtqQQep0jSk PW0HSCeEDsFzX/CdW0t6C1dRPVu7gddhQI2dT1KUMTLPghKqCKjqgUrKfruh+yarpwMIKUmhV3X rklM4b718lqThCqUPASeb/zZeCoN3g+MQAmL5MM3Vf9Vtx780jFE4SHxFwk+do0CrYsWhTxO9a4 8FNOJNfUrv8dasPXCafK9pQxYkzRE4lKjDlKWPbrzSfelocXGryBNFQPiOTkAkRMf3RqiNh2GCR z8QM/L+lmF4dv//gnu3oXL3ds1MRzA8FY5nKjYoduHvOOsVDQTEx+B+4XPa6vTmDxWk68HDhoOV CKOyMtZUCdXdo7dGXx+OhYtsFT/beclrvneNK+WXJJ8DAXpxRJYlmCGfmAV1/okr5oEOrE8U8ru cshkana+HpzpbJuzw28HhcouY+hWSF2Clzt6FUws6hL+evFTv6yEopyovGmCakC3k2VR5UMumZ7 MvA//yU5JMxP7SDbF30UVevcNuhKSu2LoEBaAp4CJ4xAJzaBrUaKqgdOogIP6IIGac0nANokUqs 9OfVz+T lNbq/PRA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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, 06 Oct 2023 13:18:16 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779038681683082638 X-GMAIL-MSGID: 1779038681683082638 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 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 cdns_nand_chip. Cc: Miquel Raynal Cc: Richard Weinberger Cc: Vignesh Raghavendra Cc: "Gustavo A. R. Silva" Cc: Martin Blumenstingl Cc: Nicolas Ferre Cc: Roger Quadros Cc: Thierry Reding Cc: Yang Yingliang Cc: "Uwe Kleine-König" Cc: Valentin Korenblit Cc: ye xingchen Cc: linux-mtd@lists.infradead.org Cc: linux-hardening@vger.kernel.org Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1] Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- drivers/mtd/nand/raw/cadence-nand-controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/cadence-nand-controller.c b/drivers/mtd/nand/raw/cadence-nand-controller.c index 034ec564c2ed..7d5ef7ffe0fe 100644 --- a/drivers/mtd/nand/raw/cadence-nand-controller.c +++ b/drivers/mtd/nand/raw/cadence-nand-controller.c @@ -526,7 +526,7 @@ struct cdns_nand_chip { /* ECC strength index. */ u8 corr_str_idx; - u8 cs[]; + u8 cs[] __counted_by(nsels); }; struct ecc_info {