Message ID | 20230915201219.never.352-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 h50csp1474764vqi; Fri, 15 Sep 2023 21:38:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgpM/veL2nBNrXX7f5IcMjano3WAEfcJ5YaIcDiRjq2lrUvxP3EzQijD54IvWTNO9H3v9E X-Received: by 2002:a05:6870:5606:b0:1c7:ebf5:b6cb with SMTP id m6-20020a056870560600b001c7ebf5b6cbmr3968763oao.25.1694839094168; Fri, 15 Sep 2023 21:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694839094; cv=none; d=google.com; s=arc-20160816; b=G/MyA2+H343pAlE4LYN/KwWkglGW07JprVQPSd4hJaXpsQoj2akAACfuZtu2+w9FlJ pH7epjEQT1UfBlV/s+wNaTZLBLr9XJvIHl8rAxykkY9scdr4r+iPj3+IggDwBbEvr4yd zJ5Rz2JIx6ydxz31ej5B6+0r9/sySo8HKbMqTYuonafrFcIV8FeVBJmnAku6ZCXPvOP7 2vjSNRzEz+OSDzEmC5sCto9Fn6M/lhKyQEpVxvhD5b84QtGE4cSjUtvXwRsKx+c0nLgE 4LqiEWvtK2JIDYXcOpYiQSIonCo3JqkZbvhaLaA1ROw+XynSlicNEY34nFan1wnxvkEH AGVw== 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=vbgir45P8c3Pig3O82d5C6ZtsdrQshUxHqzUl7LRBJ8=; fh=u4D0wHX2J9ZCVsF60+w1iGn8SPoA72iKKDuUnTzbvDY=; b=GyOrWKsrNhH/EWs7tWYyRRz99e7f0+7NWDNWVciiQovUVVSb5Bn46xVzaXvQDT/VmA Z3hDumA/d26hJldPHOxL8cCuhbOPx8sZgyIq8ZBSCY2iuQK/dKiDy6OxRywSpESQIwTC UwmuRu9wApXeC6hcKaOz+mddtOYXNmfZEF4X4rmN30kHW/CnChkZ5hjTvAC2Z2zq7Md0 TAz/J82J0zKqj1l/bYncLl5UONr1MvVje5IXlwhrXhFTSZlpcpnKR+zSfAQgTiWVM7vV yQUWuFl5tN/9OqNtTmD9/23/xJTLd+RrrB85BVn9ZhXCRoTLIgsDFWN6msrIoEk+jBrJ jvNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JnSLagM2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w70-20020a638249000000b005706961d4d2si4177008pgd.463.2023.09.15.21.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 21:38:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JnSLagM2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 7C336822B8CE; Fri, 15 Sep 2023 13:14:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237189AbjIOUNh (ORCPT <rfc822;realc9580@gmail.com> + 29 others); Fri, 15 Sep 2023 16:13:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237277AbjIOUNQ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 15 Sep 2023 16:13:16 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFF382D71 for <linux-kernel@vger.kernel.org>; Fri, 15 Sep 2023 13:12:22 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-68fc9e0e22eso2122999b3a.1 for <linux-kernel@vger.kernel.org>; Fri, 15 Sep 2023 13:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694808742; x=1695413542; 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=vbgir45P8c3Pig3O82d5C6ZtsdrQshUxHqzUl7LRBJ8=; b=JnSLagM2GJ/sivdTHmyoopz72F+W5Iem9lwet38/5o8TTRnue6roVp6C2v2YvVMq2L 6gwOK4CPBIY77WwXwSCb7T1Fzqsel1doLmTZVmOELiplWOqlcwgO8Y4nepFndJMAwDTd wBwVSrNxI+jpXiegtIJp7i5q44KX1Yw/IDdbE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694808742; x=1695413542; 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=vbgir45P8c3Pig3O82d5C6ZtsdrQshUxHqzUl7LRBJ8=; b=ugWufxK6EA6u/ehIyFGLdESoCbjNWiXttGL9kavrqFl9oeoHXGVCwszNfeFfJPTKF6 xRLh2kDY7VFJlXCdK//277+3m2f7jsng7vqfX4Hp+i2m/kfmpO5iGkmXqxJDTt3doqaU yb6dzXyXWMJtD5S3ISwXoY4VdR8i64obiB8Ou+Y0QtIpZOURCeInC1iM4VyCjrYr7yYc KASH5/ez+BIY62IA32cIx0xdcyINsfAidil0QogJaspAltPYUEJ9nfLpJDnkEtWp/Fk7 msqmUh5ESAOzRZ9vMhDOita2/y9zVmXT2OLtTrEmrkuY6PerhxNe5anYo7r1DhnU8onW OyBA== X-Gm-Message-State: AOJu0YydTf6igKNSOinVEWhMn3oLb8ILOcXrg0TlnegnzrKo5vLOVK74 BQvyb+7FQYClwUSxTr1CvKKooA== X-Received: by 2002:a05:6a20:160e:b0:14b:887a:6d70 with SMTP id l14-20020a056a20160e00b0014b887a6d70mr3499753pzj.15.1694808742247; Fri, 15 Sep 2023 13:12:22 -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 a21-20020a62e215000000b0068c6e666066sm3327765pfi.111.2023.09.15.13.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:12:21 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Tudor Ambarus <tudor.ambarus@linaro.org> Cc: Kees Cook <keescook@chromium.org>, Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, Nicolas Ferre <nicolas.ferre@microchip.com>, Alexandre Belloni <alexandre.belloni@bootlin.com>, Claudiu Beznea <claudiu.beznea@tuxon.dev>, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.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] mtd: rawnand: atmel: Annotate struct atmel_nand with __counted_by Date: Fri, 15 Sep 2023 13:12:20 -0700 Message-Id: <20230915201219.never.352-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1585; i=keescook@chromium.org; h=from:subject:message-id; bh=Tdr7pAr2Wb4/8w/gmPSQOqizdA4eTmvQlqS8OoRKddg=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBLqkv2XZPgk3DLyZFw3FAR71jSeYJBJnbdcTE k2PsyMAmBKJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQS6pAAKCRCJcvTf3G3A JoNrD/9bXYCBxADrZNHe5KYuXZa2MpAe6bX4jbfGcBcOh/Ugaq5DHdiRZ1029txqS953Eg+J7pJ 4a2Ae0PAfgHBWg+DTNZgpFuZdZVjmmA+C2Jek1oRG9j1sOPzK5g3dEKzqM0T3SCSG9ltaBGAaXB 4mJ4oJVZsywrSPmpnBsHloni/CITMF65he+pl9MzG+gt8XiGtiVO9x82Ja5P+VDx3HnlQtkfvwJ uiZaJb0o3mZArnjWMPTMzx5Vr8FDd1RgiqgfdCuANBN9rBs4ZPZKbqK6dHz3KMLFxw34Vs9g5DW QL1OeYO/nsO9COQqGEG+Eju7ASKKedTGsFLqzdxxeORZre7+qJJkxSs/UcA8DHWkYS/HpZtvLtF BSBdlZHteJ/HlYfTPTWd/jIBjFsSdRUkKzIgDb4BPhSyHbrZ0jKOCs79l2Fk9mhZ+7DpLh83VpG lnaDwD5gbMFG6RFosKr+j2LMBNcqtLSNBJC57ZcgvECQNgGy3oFq+m0Mne3Sg68G3TnakTjFtI0 lFmUUvubrfVj6jPZfm113wYcvENBIVGjC59zqFpg4AUbAOpULsLLbf4ihMaxOXG2yCI6Nb8bnRT tUygiBi5+DcAgoQCg4tO393PtyIKRx54A5CsFCeC8iCVwKqdd+FnSBzCCQOZkxU93X7wLijiaWp EOhkDTw GDHW+fKw== 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 15 Sep 2023 13:14:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777138454756770445 X-GMAIL-MSGID: 1777167597856249175 |
Series |
mtd: rawnand: atmel: Annotate struct atmel_nand with __counted_by
|
|
Commit Message
Kees Cook
Sept. 15, 2023, 8:12 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 atmel_nand.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc: Tudor Ambarus <tudor.ambarus@linaro.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Cc: linux-mtd@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 15.09.2023 23:12, 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 atmel_nand. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Tudor Ambarus <tudor.ambarus@linaro.org> > Cc: Miquel Raynal <miquel.raynal@bootlin.com> > Cc: Richard Weinberger <richard@nod.at> > Cc: Vignesh Raghavendra <vigneshr@ti.com> > Cc: Nicolas Ferre <nicolas.ferre@microchip.com> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com> > Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev> > Cc: linux-mtd@lists.infradead.org > Cc: linux-arm-kernel@lists.infradead.org > Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org> > --- > drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c > index 3f494f7c7ecb..4cb478bbee4a 100644 > --- a/drivers/mtd/nand/raw/atmel/nand-controller.c > +++ b/drivers/mtd/nand/raw/atmel/nand-controller.c > @@ -165,7 +165,7 @@ struct atmel_nand { > struct atmel_pmecc_user *pmecc; > struct gpio_desc *cdgpio; > int numcs; > - struct atmel_nand_cs cs[]; > + struct atmel_nand_cs cs[] __counted_by(numcs); > }; > > static inline struct atmel_nand *to_atmel_nand(struct nand_chip *chip)
On Fri, 2023-09-15 at 20:12:20 UTC, 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 atmel_nand. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Tudor Ambarus <tudor.ambarus@linaro.org> > Cc: Miquel Raynal <miquel.raynal@bootlin.com> > Cc: Richard Weinberger <richard@nod.at> > Cc: Vignesh Raghavendra <vigneshr@ti.com> > Cc: Nicolas Ferre <nicolas.ferre@microchip.com> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com> > Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev> > Cc: linux-mtd@lists.infradead.org > Cc: linux-arm-kernel@lists.infradead.org > Signed-off-by: Kees Cook <keescook@chromium.org> > Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> > Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org> Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks. Miquel
diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c index 3f494f7c7ecb..4cb478bbee4a 100644 --- a/drivers/mtd/nand/raw/atmel/nand-controller.c +++ b/drivers/mtd/nand/raw/atmel/nand-controller.c @@ -165,7 +165,7 @@ struct atmel_nand { struct atmel_pmecc_user *pmecc; struct gpio_desc *cdgpio; int numcs; - struct atmel_nand_cs cs[]; + struct atmel_nand_cs cs[] __counted_by(numcs); }; static inline struct atmel_nand *to_atmel_nand(struct nand_chip *chip)