linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] leds: mt6360: Annotate struct mt6360_priv with __counted_by
@ 2023-09-15 20:10 Kees Cook
  2023-09-15 20:47 ` Gustavo A. R. Silva
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kees Cook @ 2023-09-15 20:10 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Kees Cook, Lee Jones, Matthias Brugger,
	AngeloGioacchino Del Regno, Gene Chen, Jacek Anaszewski,
	Andy Shevchenko, linux-leds, linux-arm-kernel, linux-mediatek,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, linux-kernel, llvm,
	linux-hardening

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 mt6360_priv.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Pavel Machek <pavel@ucw.cz>
Cc: Lee Jones <lee@kernel.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Gene Chen <gene_chen@richtek.com>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-leds@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/leds/flash/leds-mt6360.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/flash/leds-mt6360.c b/drivers/leds/flash/leds-mt6360.c
index 1af6c5898343..b70dc689b33f 100644
--- a/drivers/leds/flash/leds-mt6360.c
+++ b/drivers/leds/flash/leds-mt6360.c
@@ -91,7 +91,7 @@ struct mt6360_priv {
 	unsigned int fled_torch_used;
 	unsigned int leds_active;
 	unsigned int leds_count;
-	struct mt6360_led leds[];
+	struct mt6360_led leds[] __counted_by(leds_count);
 };
 
 static int mt6360_mc_brightness_set(struct led_classdev *lcdev,
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] leds: mt6360: Annotate struct mt6360_priv with __counted_by
  2023-09-15 20:10 [PATCH] leds: mt6360: Annotate struct mt6360_priv with __counted_by Kees Cook
@ 2023-09-15 20:47 ` Gustavo A. R. Silva
  2023-09-18  8:27 ` AngeloGioacchino Del Regno
  2023-09-20 13:50 ` (subset) " Lee Jones
  2 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-15 20:47 UTC (permalink / raw)
  To: Kees Cook, Pavel Machek
  Cc: Lee Jones, Matthias Brugger, AngeloGioacchino Del Regno,
	Gene Chen, Jacek Anaszewski, Andy Shevchenko, linux-leds,
	linux-arm-kernel, linux-mediatek, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, linux-kernel, llvm, linux-hardening



On 9/15/23 14:10, 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 mt6360_priv.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Lee Jones <lee@kernel.org>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Cc: Gene Chen <gene_chen@richtek.com>
> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: linux-leds@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mediatek@lists.infradead.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   drivers/leds/flash/leds-mt6360.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/leds/flash/leds-mt6360.c b/drivers/leds/flash/leds-mt6360.c
> index 1af6c5898343..b70dc689b33f 100644
> --- a/drivers/leds/flash/leds-mt6360.c
> +++ b/drivers/leds/flash/leds-mt6360.c
> @@ -91,7 +91,7 @@ struct mt6360_priv {
>   	unsigned int fled_torch_used;
>   	unsigned int leds_active;
>   	unsigned int leds_count;
> -	struct mt6360_led leds[];
> +	struct mt6360_led leds[] __counted_by(leds_count);
>   };
>   
>   static int mt6360_mc_brightness_set(struct led_classdev *lcdev,

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] leds: mt6360: Annotate struct mt6360_priv with __counted_by
  2023-09-15 20:10 [PATCH] leds: mt6360: Annotate struct mt6360_priv with __counted_by Kees Cook
  2023-09-15 20:47 ` Gustavo A. R. Silva
@ 2023-09-18  8:27 ` AngeloGioacchino Del Regno
  2023-09-20 13:50 ` (subset) " Lee Jones
  2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-09-18  8:27 UTC (permalink / raw)
  To: Kees Cook, Pavel Machek
  Cc: Lee Jones, Matthias Brugger, Gene Chen, Jacek Anaszewski,
	Andy Shevchenko, linux-leds, linux-arm-kernel, linux-mediatek,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, linux-kernel, llvm,
	linux-hardening

Il 15/09/23 22:10, Kees Cook ha scritto:
> 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 mt6360_priv.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Lee Jones <lee@kernel.org>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Cc: Gene Chen <gene_chen@richtek.com>
> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: linux-leds@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mediatek@lists.infradead.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: (subset) [PATCH] leds: mt6360: Annotate struct mt6360_priv with __counted_by
  2023-09-15 20:10 [PATCH] leds: mt6360: Annotate struct mt6360_priv with __counted_by Kees Cook
  2023-09-15 20:47 ` Gustavo A. R. Silva
  2023-09-18  8:27 ` AngeloGioacchino Del Regno
@ 2023-09-20 13:50 ` Lee Jones
  2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2023-09-20 13:50 UTC (permalink / raw)
  To: Pavel Machek, Kees Cook
  Cc: Lee Jones, Matthias Brugger, AngeloGioacchino Del Regno,
	Gene Chen, Jacek Anaszewski, Andy Shevchenko, linux-leds,
	linux-arm-kernel, linux-mediatek, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, linux-kernel, llvm, linux-hardening

On Fri, 15 Sep 2023 13:10:20 -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 mt6360_priv.
> 
> [...]

Applied, thanks!

[1/1] leds: mt6360: Annotate struct mt6360_priv with __counted_by
      commit: cecdfff8f5c82816d8b9ef2f4b3d7f4943dfd360

--
Lee Jones [李琼斯]


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-20 13:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-15 20:10 [PATCH] leds: mt6360: Annotate struct mt6360_priv with __counted_by Kees Cook
2023-09-15 20:47 ` Gustavo A. R. Silva
2023-09-18  8:27 ` AngeloGioacchino Del Regno
2023-09-20 13:50 ` (subset) " Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).