Re: [PATCH] hardening: x86: drop reference to removed config AMD_IOMMU_V2

2023-10-11 Thread Vasant Hegde
On 10/12/2023 12:05 PM, Dan Carpenter wrote: > On Thu, Oct 12, 2023 at 10:45:03AM +0530, Vasant Hegde wrote: >> >> >> On 10/12/2023 10:20 AM, Lukas Bulwahn wrote: >>> Commit 5a0b11a180a9 ("iommu/amd: Remove iommu_v2 module") removes the >>> config AMD_IOMMU_V2. >>> >>> Remove the reference to th

Re: [PATCH] hardening: x86: drop reference to removed config AMD_IOMMU_V2

2023-10-11 Thread Dan Carpenter
On Thu, Oct 12, 2023 at 10:45:03AM +0530, Vasant Hegde wrote: > > > On 10/12/2023 10:20 AM, Lukas Bulwahn wrote: > > Commit 5a0b11a180a9 ("iommu/amd: Remove iommu_v2 module") removes the > > config AMD_IOMMU_V2. > > > > Remove the reference to this config in the x86 architecture-specific > > har

Re: [PATCH] hardening: x86: drop reference to removed config AMD_IOMMU_V2

2023-10-11 Thread Vasant Hegde
On 10/12/2023 10:20 AM, Lukas Bulwahn wrote: > Commit 5a0b11a180a9 ("iommu/amd: Remove iommu_v2 module") removes the > config AMD_IOMMU_V2. > > Remove the reference to this config in the x86 architecture-specific > hardening config fragment as well. > > Signed-off-by: Lukas Bulwahn > --- > Jo

[PATCH] hardening: x86: drop reference to removed config AMD_IOMMU_V2

2023-10-11 Thread Lukas Bulwahn
Commit 5a0b11a180a9 ("iommu/amd: Remove iommu_v2 module") removes the config AMD_IOMMU_V2. Remove the reference to this config in the x86 architecture-specific hardening config fragment as well. Signed-off-by: Lukas Bulwahn --- Joerg, please pick this patch on top of the commit above. Thanks.

[PATCH 2/2][next] clk: visconti: Add bounds-checking coverage for struct visconti_pll_provider

2023-10-11 Thread Gustavo A. R. Silva
In order to gain the bounds-checking coverage that __counted_by provides to flexible-array members at run-time via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions), we must make sure that the counter member, in this particular case `num`, is up

[PATCH 1/2][next] clk: visconti: Fix undefined behavior bug in struct visconti_pll_provider

2023-10-11 Thread Gustavo A. R. Silva
`struct clk_hw_onecell_data` is a flexible structure, which means that it contains flexible-array member at the bottom, in this case array `hws`: include/linux/clk-provider.h: 1380 struct clk_hw_onecell_data { 1381 unsigned int num; 1382 struct clk_hw *hws[] __counted_by(num); 1383

[PATCH 0/2][next] clk: visconti: Fix undefined behavior bug and add bounds-checking coverage

2023-10-11 Thread Gustavo A. R. Silva
This small series aims to fix an undefined behavior bug in `struct visconti_pll_provider` and add bounds-checking coverage at run-time for flexible-array member `hws` in `struct clk_hw_onecell_data` when accessed throught `struct visconti_pll_provider`. Gustavo A. R. Silva (2): clk: visconti: Fi

Re: [PATCH 1/2][next] clk: socfpga: Fix undefined behavior bug in struct stratix10_clock_data

2023-10-11 Thread Gustavo A. R. Silva
Fixes: ba7e258425ac ("clk: socfpga: Convert to s10/agilex/n5x to use clk_hw") Cc: sta...@vger.kernel.org Signed-off-by: Gustavo A. R. Silva Nice find! :D Reviewed-by: Kees Cook Thanks! -- Gustavo

Re: [PATCH 2/2][next] clk: socfpga: agilex: Add bounds-checking coverage for struct stratix10_clock_data

2023-10-11 Thread Gustavo A. R. Silva
Hence, we need to move the assignments to `clk_data->clk_data.num` after allocations for `struct stratix10_clock_data` and before accessing the flexible array `clk_data->clk_data.hws`. And, as assignments for both `clk_data->clk_data.num` and `clk_data->base` are originally adjacent to each o

Re: [PATCH v2] bna: replace deprecated strncpy with strscpy_pad

2023-10-11 Thread patchwork-bot+netdevbpf
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski : On Mon, 09 Oct 2023 17:45:33 + you 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. > > bfa_ioc

Re: [PATCH] net: dsa: lantiq_gswip: replace deprecated strncpy with ethtool_sprintf

2023-10-11 Thread patchwork-bot+netdevbpf
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski : On Mon, 09 Oct 2023 18:24:20 + you 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. > > ethtool

Re: [PATCH] net: mvpp2: replace deprecated strncpy with strscpy

2023-10-11 Thread patchwork-bot+netdevbpf
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski : On Tue, 10 Oct 2023 21:24:42 + you 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. > > We expe

Re: [PATCH] net: dsa: mt7530: replace deprecated strncpy with ethtool_sprintf

2023-10-11 Thread patchwork-bot+netdevbpf
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski : On Mon, 09 Oct 2023 18:29:19 + you 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. > > ethtool

Re: [PATCH] octeontx2-af: replace deprecated strncpy with strscpy

2023-10-11 Thread patchwork-bot+netdevbpf
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski : On Tue, 10 Oct 2023 21:38:11 + you 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. > > We can

Re: [PATCH] nfp: replace deprecated strncpy with strscpy

2023-10-11 Thread Kees Cook
On Wed, Oct 11, 2023 at 09:48:39PM +, 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. > > We expect res->name to be NUL-terminated based on its usage with format >

Re: [PATCH] qed: replace uses of strncpy

2023-10-11 Thread Kees Cook
On Wed, Oct 11, 2023 at 10:20:10PM +, 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. > > This patch eliminates three uses of strncpy(): > > Firstly, `dest` is ex

Re: [PATCH] ionic: replace deprecated strncpy with strscpy

2023-10-11 Thread Kees Cook
On Wed, Oct 11, 2023 at 09:53:44PM +, 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. > > NUL-padding is not needed due to `ident` being memset'd to 0 just before

Re: [PATCH] ionic: replace deprecated strncpy with strscpy

2023-10-11 Thread Justin Stitt
@ int ionic_identify(struct ionic *ionic) > > memset(ident, 0, sizeof(*ident)); > > > > ident->drv.os_type = cpu_to_le32(IONIC_OS_TYPE_LINUX); > > - strncpy(ident->drv.driver_ver_str, UTS_RELEASE, > > - sizeof(ident->drv.driver_

[PATCH] qed: replace uses of strncpy

2023-10-11 Thread Justin Stitt
uf)[*offset]; - strncpy(dest, source_str, size); - dest[size - 1] = '\0'; + strscpy(dest, source_str, size); *offset += size; } --- base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2 change-id: 20231011-strncpy-drivers-net-ethernet-qlogic-qed-qed_debug-c-211d594201e4 Best regards, -- Justin Stitt

Re: [PATCH] ionic: replace deprecated strncpy with strscpy

2023-10-11 Thread Nelson, Shannon
ommit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2 change-id: 20231011-strncpy-drivers-net-ethernet-pensando-ionic-ionic_main-c-709f8f1ea312 Best regards, -- Justin Stitt

[PATCH] ionic: replace deprecated strncpy with strscpy

2023-10-11 Thread Justin Stitt
driver_ver_str, UTS_RELEASE, + sizeof(ident->drv.driver_ver_str)); mutex_lock(&ionic->dev_cmd_lock); --- base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2 change-id: 20231011-strncpy-drivers-net-ethernet-pensando-ionic-ionic_main-c-709f8f1ea312 Best regards, -- Justin Stitt

[PATCH] nfp: replace deprecated strncpy with strscpy

2023-10-11 Thread Justin Stitt
; - strncpy(res->name, name, NFP_RESOURCE_ENTRY_NAME_SZ); + strscpy(res->name, name, sizeof(res->name)); dev_mutex = nfp_cpp_mutex_alloc(cpp, NFP_RESOURCE_TBL_TARGET, NFP_RESOURCE_TBL_BASE, --- base-commit: cbf3a2cb156a

Re: [PATCH] net: sparx5: replace deprecated strncpy with ethtool_sprintf

2023-10-11 Thread Kees Cook
On Wed, Oct 11, 2023 at 09:37:18PM +, 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. > > ethtool_sprintf() is designed specifically for get_strings() usage. > Let

Re: [PATCH 2/2][next] clk: socfpga: agilex: Add bounds-checking coverage for struct stratix10_clock_data

2023-10-11 Thread Kees Cook
On Wed, Oct 11, 2023 at 03:35:26PM -0600, Gustavo A. R. Silva wrote: > In order to gain the bounds-checking coverage that __counted_by provides > to flexible-array members at run-time via CONFIG_UBSAN_BOUNDS (for array > indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions), > we

Re: [PATCH 1/2][next] clk: socfpga: Fix undefined behavior bug in struct stratix10_clock_data

2023-10-11 Thread Kees Cook
On Wed, Oct 11, 2023 at 03:34:03PM -0600, Gustavo A. R. Silva wrote: > `struct clk_hw_onecell_data` is a flexible structure, which means that > it contains flexible-array member at the bottom, in this case array > `hws`: > > include/linux/clk-provider.h: > 1380 struct clk_hw_onecell_data { > 1381

[PATCH] net: sparx5: replace deprecated strncpy with ethtool_sprintf

2023-10-11 Thread Justin Stitt
>stats_layout[idx]); } static void sparx5_get_sset_data(struct net_device *ndev, --- base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2 change-id: 20231011-strncpy-drivers-net-ethernet-microchip-sparx5-sparx5_ethtool-c-793896db6cf4 Best regards, -- Justin Stitt

[PATCH 2/2][next] clk: socfpga: agilex: Add bounds-checking coverage for struct stratix10_clock_data

2023-10-11 Thread Gustavo A. R. Silva
In order to gain the bounds-checking coverage that __counted_by provides to flexible-array members at run-time via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions), we must make sure that the counter member, in this case `num`, is updated befor

[PATCH 1/2][next] clk: socfpga: Fix undefined behavior bug in struct stratix10_clock_data

2023-10-11 Thread Gustavo A. R. Silva
`struct clk_hw_onecell_data` is a flexible structure, which means that it contains flexible-array member at the bottom, in this case array `hws`: include/linux/clk-provider.h: 1380 struct clk_hw_onecell_data { 1381 unsigned int num; 1382 struct clk_hw *hws[] __counted_by(num); 1383

Re: [PATCH] net/mlx5: simplify mlx5_set_driver_version string assignments

2023-10-11 Thread Kees Cook
On Wed, Oct 11, 2023 at 09:29:57PM +, Justin Stitt wrote: > In total, just assigning this version string takes: > (1) strncpy()'s > (5) strlen()'s > (3) strncat()'s > (1) snprintf()'s > (4) max_t()'s > > Moreover, `strncpy` is deprecated [1] and `strncat` really shouldn't be > used either [2].

[PATCH 0/2][next] Fix undefined behavior bug and add bounds-checking coverage

2023-10-11 Thread Gustavo A. R. Silva
This series aims to fix an undefined behavior bug in `struct stratix10_clock_data` and add bounds-checking coverage at run-time for flexible-array member `hws` in `struct clk_hw_onecell_data` when accessed throught `struct stratix10_clock_data`. Gustavo A. R. Silva (2): clk: socfpga: Fix undefin

Re: [PATCH] net/mlx4_core: replace deprecated strncpy with strscpy

2023-10-11 Thread Kees Cook
On Wed, Oct 11, 2023 at 09:04:37PM +, 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. > > We expect `dst` to be NUL-terminated based on its use with format > strin

[PATCH] net/mlx5: simplify mlx5_set_driver_version string assignments

2023-10-11 Thread Justin Stitt
ver_ver_sz, "Linux,%s,%u.%u.%u", +KBUILD_MODNAME, LINUX_VERSION_MAJOR, +LINUX_VERSION_PATCHLEVEL, LINUX_VERSION_SUBLEVEL); /*Send the command*/ MLX5_SET(set_driver_version_in, in, opcode, --- base-commit: cbf3a2cb156a2c911d8f38d8247814b4c0

[PATCH] net/mlx4_core: replace deprecated strncpy with strscpy

2023-10-11 Thread Justin Stitt
trncpy(dst, DRV_NAME_FOR_FW, INIT_HCA_DRIVER_VERSION_SZ - 1); + strscpy(dst, DRV_NAME_FOR_FW, INIT_HCA_DRIVER_VERSION_SZ); mlx4_dbg(dev, "Reporting Driver Version to FW: %s\n", dst); } --- base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2 ch

Re: [PATCH] Bluetooth: hci_sock: Correctly bounds check and pad HCI_MON_NEW_INDEX name

2023-10-11 Thread patchwork-bot+bluetooth
Hello: This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz : On Wed, 11 Oct 2023 09:31:44 -0700 you wrote: > The code pattern of memcpy(dst, src, strlen(src)) is almost always > wrong. In this case it is wrong because it leaves memory uninitialized > if it is

[PATCH] Bluetooth: hci_sock: Correctly bounds check and pad HCI_MON_NEW_INDEX name

2023-10-11 Thread Kees Cook
The code pattern of memcpy(dst, src, strlen(src)) is almost always wrong. In this case it is wrong because it leaves memory uninitialized if it is less than sizeof(ni->name), and overflows ni->name when longer. Normally strtomem_pad() could be used here, but since ni->name is a trailing array in s

Re: [PATCH v4 1/8] mm/util: Introduce kmemdup_array() to duplicate an array

2023-10-11 Thread Kartik
On Wed, 2023-10-11 at 18:36:11 +0300, Andy Shevchenko wrote: > On Wed, Oct 11, 2023 at 2:17 PM Kartik wrote: > > > > Introduce function kmemdup_array(), that will copy `n` number of > > elements from a given array `src` to `dst`. > > > > On success, kmemdup_array() returns 0 and copy the elements

Re: [PATCH v4 1/8] mm/util: Introduce kmemdup_array() to duplicate an array

2023-10-11 Thread Andy Shevchenko
On Wed, Oct 11, 2023 at 2:17 PM Kartik wrote: > > Introduce function kmemdup_array(), that will copy `n` number of > elements from a given array `src` to `dst`. > > On success, kmemdup_array() returns 0 and copy the elements from `src` > to newly allocated array `dst`, it also stores number of ele

Re: [PATCH] regulator: da9063: Annotate struct da9063_regulators with __counted_by

2023-10-11 Thread Mark Brown
On Fri, 22 Sep 2023 10:52:07 -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 indexi

Re: [PATCH][next] xen/xenbus: Add __counted_by for struct read_buffer and use struct_size()

2023-10-11 Thread Jason Andryuk
On Mon, Oct 9, 2023 at 2:55 PM Gustavo A. R. Silva 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 via CONFIG_UBSAN_BOUNDS (for > array indexin

Re: [PATCH] ASoC: apple: mca: Annotate struct mca_data with __counted_by

2023-10-11 Thread Mark Brown
On Fri, 22 Sep 2023 10:50:50 -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 indexi

[PATCH v4 8/8] soc/tegra: fuse: Add support for Tegra241

2023-10-11 Thread Kartik
Add support for Tegra241 which use ACPI boot. Signed-off-by: Kartik --- v1 -> v2: * Removed few entries from tegra241_fuse_soc which were initilized as NULL or 0. --- drivers/soc/tegra/Kconfig | 5 + drivers/soc/tegra/fuse/fuse-tegra.c| 5 + drivers/s

[PATCH v4 7/8] soc/tegra: fuse: Add ACPI support for Tegra194 and Tegra234

2023-10-11 Thread Kartik
Add ACPI support for Tegra194 & Tegra243 SoC's. This requires following modifications to the probe when ACPI boot is used: - Initialize soc data. - Add nvmem lookups. - Register soc device. - use devm_clk_get_optional() instead of devm_clk_get() to get fuse->clk, as fuse clocks are not requi

[PATCH v4 6/8] soc/tegra: fuse: Add function to print SKU info

2023-10-11 Thread Kartik
Add helper function tegra_fuse_print_sku_info() to print Tegra SKU information. So, it can be shared between tegra_fuse_init() and ACPI probe which is to be introduced later. Signed-off-by: Kartik --- v1 -> v2: * Renamed tegra_fuse_pr_sku_info() as tegra_fuse_print_sku_info(). -

[PATCH v4 5/8] soc/tegra: fuse: Add function to add lookups

2023-10-11 Thread Kartik
Add helper function tegra_fuse_add_lookups() to register Tegra fuse nvmem lookups. So, this can be shared between tegra_fuse_init() and ACPI probe, which is to be introduced later. Use kmemdup_array to duplicate fuse->soc->lookups. Signed-off-by: Kartik --- v3 -> v4: * Use kmemdup_array

[PATCH v4 4/8] soc/tegra: fuse: Add tegra_acpi_init_apbmisc()

2023-10-11 Thread Kartik
In preparation to ACPI support in Tegra fuse driver add function tegra_acpi_init_apbmisc() to initialize tegra-apbmisc driver. Also, document the reason of calling tegra_init_apbmisc() at early init. Note that function tegra_acpi_init_apbmisc() is not placed in the __init section, because it will

[PATCH v4 3/8] soc/tegra: fuse: Refactor resource mapping

2023-10-11 Thread Kartik
To prepare for adding ACPI support to the tegra-apbmisc driver, relocate the code responsible for mapping memory resources from the function ‘tegra_init_apbmisc’ to the function ‘tegra_init_apbmisc_resources.’ This adjustment will allow the code to be shared between ‘tegra_init_apbmisc’ and the upc

[PATCH v4 2/8] soc/tegra: fuse: Use dev_err_probe for probe failures

2023-10-11 Thread Kartik
Currently, in tegra_fuse_probe() if clock/reset get fails, then the driver prints an error if the error is not caused by -EPROBE_DEFER. This can be improved by using dev_err_probe() instead. So, return dev_err_probe() if clock/reset get fails. Signed-off-by: Kartik --- drivers/soc/tegra/fuse/fu

[PATCH v4 1/8] mm/util: Introduce kmemdup_array() to duplicate an array

2023-10-11 Thread Kartik
Introduce function kmemdup_array(), that will copy `n` number of elements from a given array `src` to `dst`. On success, kmemdup_array() returns 0 and copy the elements from `src` to newly allocated array `dst`, it also stores number of elements copied from `src` array to `dst_count` parameter. On

[PATCH v4 0/8] soc/tegra: fuse: Add ACPI support

2023-10-11 Thread Kartik
This series of patches add ACPI support for Tegra194 and Tegra234 in Tegra fuse and apbmisc drivers. It also adds support for Tegra241 which uses ACPI boot. Kartik (8): mm/util: Introduce kmemdup_array() to duplicate an array soc/tegra: fuse: Use dev_err_probe for probe failures soc/tegra: f

Re: [PATCH][next] wifi: brcmfmac: fweh: Add __counted_by for struct brcmf_fweh_queue_item and use struct_size()

2023-10-11 Thread Kalle Valo
"Gustavo A. R. Silva" 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 via CONFIG_UBSAN_BOUNDS (for > array indexing) and CONFIG_FORTIFY_SOURCE (

Re: [next] wifi: hostap: Add __counted_by for struct prism2_download_data and use struct_size()

2023-10-11 Thread Kalle Valo
"Gustavo A. R. Silva" 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 via CONFIG_UBSAN_BOUNDS (for > array indexing) and CONFIG_FORTIFY_SOURCE (