From patchwork Fri Sep 15 20:12:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13387632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F70BCD379F for ; Fri, 15 Sep 2023 20:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237158AbjIOUOF (ORCPT ); Fri, 15 Sep 2023 16:14:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237149AbjIOUNe (ORCPT ); Fri, 15 Sep 2023 16:13:34 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A8882D44 for ; Fri, 15 Sep 2023 13:12:37 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-68fc9a4ebe9so2317604b3a.2 for ; Fri, 15 Sep 2023 13:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694808757; x=1695413557; 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=PrBmIK/7ZBFkfIJ+GoT9lofYoxjkLNz9RY+nH/vRJ5g=; b=Hyr26EoDc/3IqnsEj1f949dN52APUFRos05grk0rf4AGJZyPtHznjIR0CTCS/4+cRq VojOdZpad9u5YDfvohFTxfkmMdvB2fKfgH5WjVYcHZg4mHkXTFDj1JJ2uPBcf8fpK1Ur 4hW9SjKDO9ijB/O5yVg825VstCzoqYWSOmFyc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694808757; x=1695413557; 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=PrBmIK/7ZBFkfIJ+GoT9lofYoxjkLNz9RY+nH/vRJ5g=; b=Tw4xUKf3KP8IOqlxjNYP7soi6z52aRd9xYrxqp7PKvzx6sV0aeOgpAul6QAlmi+CTz 2nzPfwX4l58hS51pyVUMN5t/oL1Y5qRmGCmVmgnLlDuPf0s3glS867NFRsIlnJrFP2fv gXl7OW9xdKwYPzN0g4Py/pxINY2CdFXC3qGYIdc9Fy6SNof1KXFCqFwUsMIbgXhJ2yFM y0muSuGszV1lbsQhaIsB1M8XfCKYjUPSWCmkb3U2NwXxU4Eh0uO9XyamvvV6cTMmjRUh 5BM4C/8LEQaHDq/zbhMX/it7O/GXltCXU5Uh5TqCDMTU58JsjIgxbno8I6aPhTQl6Rkw n5mg== X-Gm-Message-State: AOJu0YwFlf/zteRexjAflvHr3hQm8WHLkbfduuaW09Lq2g7bP8d+BPRy rVD2ZEuSlT6jtngKKBSgTpdjSg== X-Google-Smtp-Source: AGHT+IHaSepHftYvn6j1J/8NjB2sQp1S0SXdFatkZesmqR96Dm0a8qXQYyp/030E766wL+sQ438gNQ== X-Received: by 2002:a05:6a00:1490:b0:690:454a:dc7b with SMTP id v16-20020a056a00149000b00690454adc7bmr3035526pfu.28.1694808757000; Fri, 15 Sep 2023 13:12:37 -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 k192-20020a636fc9000000b0055bf13811f5sm2994033pgc.15.2023.09.15.13.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:12:36 -0700 (PDT) From: Kees Cook To: Paul Cercueil Cc: Kees Cook , Harvey Hunt , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mips@vger.kernel.org, linux-mtd@lists.infradead.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] mtd: rawnand: ingenic: Annotate struct ingenic_nfc with __counted_by Date: Fri, 15 Sep 2023 13:12:35 -0700 Message-Id: <20230915201234.never.868-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1453; i=keescook@chromium.org; h=from:subject:message-id; bh=u7N1dQwnfrzLeR4rYuLcrvgfoIzHpMlv8osLJuSY2+Y=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBLqzjowlIzJmYXlgsM3m8LT0SCSdfQTsxoB/i acbRSZ+5eeJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQS6swAKCRCJcvTf3G3A JsI5EACJLga/jCgx7S0K+M8EI9/HpJJsQ4twNYBlge15BlTjzWL6+s3zgE5f7UOcVRpkq67GHb+ FeToD49bp07c9OF4Y2xbpjHB/lYhHing/bv51pliDDUlQLsWicGBOoaC2GT6lwt4fwpqSDtOa9A TA8a1qAJT9wj2WwiEU0Zj8IG49xkuILQt2a6r/pd5AgQQa/FUwVr15kSK7RmRRBejWggW+3rhCa rSgdqJU36g/RBkZcBEQHdRUimIo0VAeZ9ksIsMsxNhv3mxG4m9PXWkwjhDvGrmx+oK7OKRoTu2k 2b37q/dOck12rVK7Zp7OSOXKN09n1QsFSsw20fa4OPreJeAcpFZMJIJPaMZoNvIrcK6RFg0WJQ1 pDaE7yH8U+FQPEIKFguHdPM1dKoDzLxtbmLgyIguyoTQr5el7bk3wxn8X53JOGpA24BQxsHR8nL WygbnLNvYhmDscT7wuWQ8ROnjn25sZUe5TZsLWij0dZdYprGIOy7I5CNhKmP0M3znYsHEJG4/Fh kk175ctq9KqoZmyeJFNBddnk+nbM0Cve21DvPxLyd2Al1nEp8yF9gZzqm6fHeT560E3Vg88ih4b YvODs23KDa5lanCSm99HJ7GXcQAXIj3w2WYkXFMQXl7bUZ+xamamKcWJeD14/oVwjqAkI2rGARw G1gmn7q 2KMQ5WVQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org 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 ingenic_nfc. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Paul Cercueil Cc: Harvey Hunt Cc: Miquel Raynal Cc: Richard Weinberger Cc: Vignesh Raghavendra Cc: linux-mips@vger.kernel.org Cc: linux-mtd@lists.infradead.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c index 6748226b8bd1..ce9ef4e65597 100644 --- a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c +++ b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c @@ -46,7 +46,7 @@ struct ingenic_nfc { struct nand_controller controller; unsigned int num_banks; struct list_head chips; - struct ingenic_nand_cs cs[]; + struct ingenic_nand_cs cs[] __counted_by(num_banks); }; struct ingenic_nand {