[PATCH v5] hwmon: (acpi_power_meter) replace open-coded kmemdup_nul

2023-09-25 Thread Justin Stitt
nated-strings [1] Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Changes in v5: - fix indentation (thanks Kees) - Link to v4: https://lore.kernel.org/r/20230925-strncpy-drivers-hwmon-acpi_power_meter-c-v4-1-3bac7534f...@google.com Ch

Re: [PATCH] MAINTAINERS: hardening: Add __counted_by regex

2023-09-25 Thread Eric Biggers
Hi Kees, On Mon, Sep 25, 2023 at 10:20:41AM -0700, Kees Cook wrote: > Since __counted_by annotations may also require that code be changed to > get initialization ordering correct, let's get an extra group of eyes on > code that is working on these annotations. > > Signed-off-by: Kees Cook > ---

Re: [PATCH v2] Input: axp20x-pek - avoid needless newline removal

2023-09-25 Thread Chen-Yu Tsai
On Tue, Sep 26, 2023 at 2:00 AM Kees Cook wrote: > > On Mon, Sep 25, 2023 at 04:31:05AM +, Justin Stitt wrote: > > This code is doing more work than it needs to. > > > > Before handing off `val_str` to `kstrtouint()` we are eagerly removing > > any trailing newline which requires copying `buf`

Re: [PATCH] i3c: svc: Annotate struct svc_i3c_xfer with __counted_by

2023-09-25 Thread Alexandre Belloni
On Fri, 22 Sep 2023 10:50:23 -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 inde

Re: [PATCH] i3c/master/mipi-i3c-hci: Annotate struct hci_rings_data with __counted_by

2023-09-25 Thread Alexandre Belloni
On Fri, 22 Sep 2023 10:50:19 -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 inde

Re: [PATCH] i3c: master: cdns: Annotate struct cdns_i3c_xfer with __counted_by

2023-09-25 Thread Alexandre Belloni
On Fri, 22 Sep 2023 10:50:15 -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 inde

Re: [PATCH] i3c: dw: Annotate struct dw_i3c_xfer with __counted_by

2023-09-25 Thread Alexandre Belloni
On Fri, 22 Sep 2023 10:50:11 -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 inde

Re: [PATCH] i3c: replace deprecated strncpy

2023-09-25 Thread Alexandre Belloni
On Thu, 21 Sep 2023 03:51:04 +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We should prefer more robust and less ambiguous string interfaces. > > We expect adap->name to be NUL-terminated based on i2c_adapter name use: > | dev_dbg(&a

Re: [PATCH] md: replace deprecated strncpy with memcpy

2023-09-25 Thread Kees Cook
On Mon, Sep 25, 2023 at 09:49:17AM +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > There are three such strncpy uses that this patch addresses: > > The res

Re: [PATCH v4] hwmon: (acpi_power_meter) replace open-coded kmemdup_nul

2023-09-25 Thread Kees Cook
On Mon, Sep 25, 2023 at 03:43:23AM +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > Let's refactor this kcalloc() + strncpy() into a kmemdup_nul() which has > more obvious behavior and is less error prone. > > Link: > https://www.kernel.

Re: [PATCH v2] Input: axp20x-pek - avoid needless newline removal

2023-09-25 Thread Kees Cook
On Mon, Sep 25, 2023 at 04:31:05AM +, Justin Stitt wrote: > This code is doing more work than it needs to. > > Before handing off `val_str` to `kstrtouint()` we are eagerly removing > any trailing newline which requires copying `buf`, validating it's > length and checking/replacing any potenti

Re: [PATCH] MAINTAINERS: hardening: Add Gustavo as Reviewer

2023-09-25 Thread Gustavo A. R. Silva
On 9/25/23 11:32, Kees Cook wrote: It's an oversight to not have already listed Gustavo here. Add him as a Reviewer. Cc: Gustavo A. R. Silva Signed-off-by: Kees Cook Accepted-by: Gustavo A. R. Silva ;P -- Gustavo --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/M

[PATCH] MAINTAINERS: hardening: Add Gustavo as Reviewer

2023-09-25 Thread Kees Cook
It's an oversight to not have already listed Gustavo here. Add him as a Reviewer. Cc: Gustavo A. R. Silva Signed-off-by: Kees Cook --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 741285b8246e..5f18ed0fbd42 100644 --- a/MAINTAINERS +++ b/MAINTA

[PATCH] MAINTAINERS: hardening: Add __counted_by regex

2023-09-25 Thread Kees Cook
Since __counted_by annotations may also require that code be changed to get initialization ordering correct, let's get an extra group of eyes on code that is working on these annotations. Signed-off-by: Kees Cook --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/M

[PATCH v2] arm64: dts: ti: k3-am625-beagleplay: Fix typo in ramoops reg

2023-09-25 Thread Wadim Egorov
Seems like the address value of the reg property was mistyped. Update reg to 0x9ca0 to match node's definition. Fixes: f5a731f0787f ("arm64: dts: ti: Add k3-am625-beagleplay") Signed-off-by: Wadim Egorov Reviewed-by: Nishanth Menon --- v2: - Add Fixes: f5a731f0787f ("arm64: dts: ti: Add k3

Re: [PATCH] arm64: dts: ti: k3-am625-beagleplay: Fix typo in ramoops reg

2023-09-25 Thread Nishanth Menon
On 16:07-20230925, Wadim Egorov wrote: > Seems like the address value of the reg property was mistyped. > Update reg to 0x9ca0 to match node's definition. > > Signed-off-by: Wadim Egorov Missing: Fixes: f5a731f0787f ("arm64: dts: ti: Add k3-am625-beagleplay"

[PATCH] arm64: dts: ti: k3-am625-beagleplay: Fix typo in ramoops reg

2023-09-25 Thread Wadim Egorov
Seems like the address value of the reg property was mistyped. Update reg to 0x9ca0 to match node's definition. Signed-off-by: Wadim Egorov --- arch/arm64/boot/dts/ti/k3-am625-beagleplay.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/ti/k3-am625-b

Re: [PATCH] virtio_console: Annotate struct port_buffer with __counted_by

2023-09-25 Thread Amit Shah
On Fri, 2023-09-22 at 10:51 -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 indexin

Re: [PATCH] platform/chrome: wilco_ec: Annotate struct ec_event_queue with __counted_by

2023-09-25 Thread patchwork-bot+chrome-platform
Hello: This patch was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih : On Fri, 22 Sep 2023 10:51:47 -0700 you 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 acce

[PATCH] md: replace deprecated strncpy with memcpy

2023-09-25 Thread Justin Stitt
0; if (namelen && mddev->metadata_type[namelen-1] == '\n') mddev->metadata_type[--namelen] = 0; --- base-commit: 6465e260f48790807eef06b583b38ca9789b6072 change-id: 20230925-strncpy-drivers-md-md-c-e775504361ab Best regards, -- Justin Stitt

Re: [PATCH] gpiolib: cdev: Annotate struct linereq with __counted_by

2023-09-25 Thread Bartosz Golaszewski
On Fri, Sep 22, 2023 at 7:52 PM 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 indexin

Re: [PATCH] eeprom: at24: Annotate struct at24_data with __counted_by

2023-09-25 Thread Bartosz Golaszewski
On Fri, Sep 22, 2023 at 7:51 PM 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 indexin

Re: [PATCH] mxser: Annotate struct mxser_board with __counted_by

2023-09-25 Thread Jiri Slaby
On 22. 09. 23, 19:52, 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_FORTI

Re: [PATCH] mm/memcg: Annotate struct mem_cgroup_threshold_ary with __counted_by

2023-09-25 Thread Michal Hocko
On Fri 22-09-23 10:53:28, 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 CO

Re: [PATCH] libata: Annotate struct ata_cpr_log with __counted_by

2023-09-25 Thread Damien Le Moal
On 2023/09/22 19:52, 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_