[PATCH] PM / QOS: Use kcalloc() instead of kzalloc()

2024-01-05 Thread Erick Archer
Use 2-factor multiplication argument form kcalloc() instead of kzalloc(). Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- drivers/base/power/qos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/power/qos.c b/drivers/base/power

[PATCH] ASoC: ti: Use devm_kcalloc() instead of devm_kzalloc()

2024-01-06 Thread Erick Archer
Use 2-factor multiplication argument form devm_kcalloc() instead of devm_kzalloc(). Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- sound/soc/ti/j721e-evm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/ti/j721e-evm.c b/sound

[PATCH] ASoC: qcom: Use devm_kcalloc() instead of devm_kzalloc()

2024-01-06 Thread Erick Archer
Use 2-factor multiplication argument form devm_kcalloc() instead of devm_kzalloc(). Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- sound/soc/qcom/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom

[PATCH v2] ASoC: ti: j721e-evm: Use devm_kcalloc() instead of devm_kzalloc()

2024-01-09 Thread Erick Archer
Use 2-factor multiplication argument form devm_kcalloc() instead of devm_kzalloc(). Link: https://github.com/KSPP/linux/issues/162 Reviewed-by: Gustavo A. R. Silva Acked-by: Peter Ujfalusi Signed-off-by: Erick Archer --- Changes in v2: - Fix the commit title adding "j721e-evm" ---

[PATCH] scsi: csiostor: Use kcalloc() instead of kzalloc()

2024-01-12 Thread Erick Archer
Use 2-factor multiplication argument form kcalloc() instead of kzalloc(). Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- drivers/scsi/csiostor/csio_init.c | 15 +-- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/csiostor

[PATCH v2] scsi: csiostor: Use kcalloc() instead of kzalloc()

2024-01-14 Thread Erick Archer
Signed-off-by: Erick Archer --- Changes in v2: - Update the changelog text describing the sizeof() changes (Gustavo A. R. Silva) Version 1: Link: https://lore.kernel.org/linux-hardening/20240112182603.11048-1-erick.arc...@gmx.com/ --- drivers/scsi/csiostor/csio_init.c | 15 +-- 1 file

[PATCH] eventfs: Use kcalloc() instead of kzalloc()

2024-01-14 Thread Erick Archer
Use 2-factor multiplication argument form kcalloc() instead of kzalloc(). Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- fs/tracefs/event_inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs

[PATCH v2] eventfs: Use kcalloc() instead of kzalloc()

2024-01-15 Thread Erick Archer
[1] https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- Changes in v2: - Update the commit message to better explain the changes (Mark Rutland) Previous versions:

[PATCH] perf/x86/amd/uncore: Use kcalloc*() instead of kzalloc*()

2024-01-16 Thread Erick Archer
[1] https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- arch/x86/events/amd/uncore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/

[PATCH] wifi: iwlegacy: Use kcalloc() instead of kzalloc()

2024-01-19 Thread Erick Archer
github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- drivers/net/wireless/intel/iwlegacy/common.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c index 17570d62c896..9d

[PATCH] staging: rtl8723bs: Use kcalloc() instead of kzalloc()

2024-01-19 Thread Erick Archer
github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 1f

[PATCH] pinctrl: pinctrl-zynqmp: Use devm_kcalloc() instead of devm_kzalloc()

2024-01-19 Thread Erick Archer
ion. Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- drivers/pinctrl/pinctrl-zynqmp.c | 8 1 file changed, 4 insertions(+), 4 deletions(-)

[PATCH] Documentation: power: Use kcalloc() instead of kzalloc()

2024-01-20 Thread Erick Archer
he kzalloc() function. Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- Documentation/power/opp.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) di

[PATCH] MIPS: Alchemy: Use kcalloc() instead of kzalloc()

2024-01-20 Thread Erick Archer
nk: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- arch/mips/alchemy/common/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a

[PATCH] riscv: Use kcalloc() instead of kzalloc()

2024-01-20 Thread Erick Archer
github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- arch/riscv/kernel/cpufeature.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 89920f84d0a3..549a76e34c4e 100644 --- a/arch/riscv/kernel/cp

[PATCH] bus: mhi: ep: Use kcalloc() instead of kzalloc()

2024-01-20 Thread Erick Archer
nk: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- drivers/bus/mhi/ep/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drive

Re: [PATCH] Documentation: power: Use kcalloc() instead of kzalloc()

2024-01-21 Thread Erick Archer
On Sat, Jan 20, 2024 at 01:05:27PM +0100, Erick Archer wrote: > As noted in the "Deprecated Interfaces, Language Features, Attributes, > and Conventions" documentation [1], size calculations (especially > multiplication) should not be performed in memory allocator (or similar) &

[PATCH] clk: hisilicon: Use devm_kcalloc() instead of devm_kzalloc()

2024-01-21 Thread Erick Archer
ion. Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer --- drivers/clk/hisilicon/clk-hi3559a.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) di

Re: [PATCH] staging: rtl8723bs: Use kcalloc() instead of kzalloc()

2024-01-22 Thread Erick Archer
Hi Dan, On Mon, Jan 22, 2024 at 09:55:11AM +0300, Dan Carpenter wrote: > On Fri, Jan 19, 2024 at 06:39:00PM +0100, Erick Archer wrote: > > As noted in the "Deprecated Interfaces, Language Features, Attributes, > > and Conventions" documentation [1], size

Re: [PATCH] bus: mhi: ep: Use kcalloc() instead of kzalloc()

2024-01-28 Thread Erick Archer
Hi Dan, On Mon, Jan 22, 2024 at 10:15:20AM +0300, Dan Carpenter wrote: > This code does not have an integer overflow, but it might have a > different memory corruption bug. I don't see this possible memory corruption bug. More info below. > On Sat, Jan 20, 2024 at 04:25:18PM +0100

[PATCH v2] bus: mhi: ep: Use kcalloc() instead of kzalloc()

2024-01-28 Thread Erick Archer
eadability. This patch has no effect on runtime behavior. Link: https://github.com/KSPP/linux/issues/162 [1] Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Reviewed-by: Gustavo A. R. Silva Signed-off-by: Erick Archer --- Changes i

[PATCH] dmaengine: pl08x: Use kcalloc() instead of kzalloc()

2024-01-28 Thread Erick Archer
el.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Signed-off-by: Erick Archer --- drivers/dma/amba-pl08x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index eea8bd33b4b7..e4076

Re: [PATCH] bus: mhi: ep: Use kcalloc() instead of kzalloc()

2024-02-02 Thread Erick Archer
Hi Dan, On Mon, Jan 29, 2024 at 08:20:26AM +0300, Dan Carpenter wrote: > On Sun, Jan 28, 2024 at 11:29:33AM +0100, Erick Archer wrote: > > > It's a bit concerning that ->event_rings is set multiple times, but only > > > allocated one time. It's either u

[PATCH] irqchip/bcm-6345-l1: Prefer struct_size over open coded arithmetic

2024-02-09 Thread Erick Archer
ated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/162 [2] Signed-off-by: Erick Archer --- drivers/irqchip/irq-bcm6345-l1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-bcm6345-l1.c b/drivers/irqchip/ir

[PATCH] irqchip/irq-bcm7038-l1: Prefer struct_size over open coded arithmetic

2024-02-09 Thread Erick Archer
/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/162 [2] Signed-off-by: Erick Archer --- drivers/irqchip/irq-bcm7038-l1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-bc

[PATCH] mtd: rawnand: Prefer struct_size over open coded arithmetic

2024-02-10 Thread Erick Archer
el.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- drivers/mtd/nand/raw/mtk_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/mtk

[PATCH v2] mtd: rawnand: Prefer struct_size over open coded arithmetic

2024-02-11 Thread Erick Archer
el.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Reviewed-by: Gustavo A. R. Silva Signed-off-by: Erick Archer --- Changes in v2: - Add the "Reviewed-by:" tag. - Fix a spelling error in the commit m

[PATCH] RDMA/uverbs: Remove flexible arrays from struct *_filter

2024-02-11 Thread Erick Archer
o get the size of these structures. Therefore, the trailing flexible arrays can also be removed. Link: https://github.com/KSPP/linux/issues/202 [1] Signed-off-by: Erick Archer --- Hi everyone, This patch has not been tested. This has only been built-tested. Regards, Erick --- drivers/infiniband/cor

[PATCH] iommu/vt-d: Use kcalloc() instead of kzalloc()

2024-02-11 Thread Erick Archer
nux/issues/162 [1] Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [2] Signed-off-by: Erick Archer --- drivers/iommu/intel/perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/perf.c b/dri

[PATCH] iommu/mtk_iommu: Use devm_kcalloc() instead of devm_kzalloc()

2024-02-11 Thread Erick Archer
-allocator-arguments [2] Signed-off-by: Erick Archer --- drivers/iommu/mtk_iommu.c| 2 +- drivers/iommu/mtk_iommu_v1.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 7abe9e85a570..9aae6eb604b1 100644

[PATCH v2] RDMA/uverbs: Remove flexible arrays from struct *_filter

2024-02-17 Thread Erick Archer
has also changed (this struct contains the struct ib_flow_ipv6_filter). This is also not a problem since it is only used to set the size of the "union ib_flow_spec", which can store all the "ib_flow_spec_*" structures. Link: https://github.com/KSPP/linux/issues/202 [1] Signed-off

[PATCH] greybus: audio: apbridgea: Remove flexible array from struct audio_apbridgea_hdr

2024-02-17 Thread Erick Archer
} __packed; struct audio_apbridgea_*_request { struct audio_apbridgea_hdr hdr; ... } __packed; In this case, the trailing flexible array can be removed because it is never used. Link: https://github.com/KSPP/linux/issues/202 [1] Signed-off-by: Erick Archer --- Hi everyone, I'm not s

[PATCH] net: wwan: t7xx: Prefer struct_size over open coded arithmetic

2024-02-24 Thread Erick Archer
t/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- drivers/net/wwan/t7xx/t7xx_port_proxy.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wwan/t7xx/t7

[PATCH] mwl8k: Avoid overlapping composite structs that contain flex-arrays

2024-03-16 Thread Erick Archer
tructures and change some variable names and types to achieve the desired goal. Link: https://github.com/KSPP/linux/issues/202 [1] Signed-off-by: Erick Archer --- Hi everyone, This patch is based on my understanding of the code. Any comments would be greatly appreciated. Also, I have veri

Re: [PATCH] mwl8k: Avoid overlapping composite structs that contain flex-arrays

2024-03-17 Thread Erick Archer
Hi Gustavo, On Sat, Mar 16, 2024 at 12:59:11PM -0600, Gustavo A. R. Silva wrote: > > [..] > > > > > Link: https://github.com/KSPP/linux/issues/202 [1] > > Signed-off-by: Erick Archer > > --- > > Hi everyone, > > > > This patch is based on my u

[PATCH] perf/x86/rapl: Prefer struct_size over open coded arithmetic

2024-03-17 Thread Erick Archer
el.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- arch/x86/events/rapl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/events/rapl.c

[PATCH] perf/x86/intel/uncore: Prefer struct_size over open coded arithmetic

2024-03-30 Thread Erick Archer
was detected with the help of Coccinelle, and audited and modified manually. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- Hi, The Coccinelle s

[PATCH v2] dmaengine: pl08x: Use kcalloc() instead of kzalloc()

2024-03-30 Thread Erick Archer
el.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Reviewed-by: Gustavo A. R. Silva Signed-off-by: Erick Archer --- Changes in v2: - Add the "Reviewed-by:" tag. - Rebase against linux-next. Previous versions: v1 -> https://lore.kernel.org/linu

[PATCH v2] perf/x86/amd/uncore: Use kcalloc*() instead of kzalloc*()

2024-03-30 Thread Erick Archer
[1] https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments Link: https://github.com/KSPP/linux/issues/162 Reviewed-by: Gustavo A. R. Silva Signed-off-by: Erick Archer --- Changes in v2: - Add the "Reviewed-by:" tag. - Rebase against l

[PATCH v3] scsi: csiostor: Use kcalloc() instead of kzalloc()

2024-03-30 Thread Erick Archer
Reviewed-by: Gustavo A. R. Silva Signed-off-by: Erick Archer --- Changes in v2: - Update the changelog text describing the sizeof() changes (Gustavo A. R. Silva) Changes in v3: - Add the "Reviewed-by:" tag. - Rebase against linux-next. Version 1: Link: https://lore.kernel.org/linux

[PATCH] mtd: maps: sa1100-flash: Prefer struct_size over open coded arithmetic

2024-03-30 Thread Erick Archer
elle, and audited and modified manually. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- Hi, The Coccinelle script used to detect this code patt

Re: [PATCH v2] perf/x86/amd/uncore: Use kcalloc*() instead of kzalloc*()

2024-03-31 Thread Erick Archer
Hi Ingo, On Sat, Mar 30, 2024 at 10:11:23PM +0100, Ingo Molnar wrote: > > * Erick Archer wrote: > > > As noted in the "Deprecated Interfaces, Language Features, Attributes, > > and Conventions" documentation [1], size calculations (especially > > multi

[PATCH] RDMA/mana_ib: Add flex array to struct mana_cfg_rx_steer_req_v2

2024-03-31 Thread Erick Archer
rray_size" helper to compute the size of these trailing elements in the "memcpy" function. Link: https://www.kernel.org/doc/html/next/process/deprecated.html#zero-length-and-one-element-arrays [1] Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic

Re: [PATCH] RDMA/mana_ib: Add flex array to struct mana_cfg_rx_steer_req_v2

2024-04-01 Thread Erick Archer
Hi Gustavo, On Sun, Mar 31, 2024 at 08:53:07PM -0600, Gustavo A. R. Silva wrote: > > > On 31/03/24 09:04, Erick Archer wrote: > > The "struct mana_cfg_rx_steer_req_v2" uses a dynamically sized set of > > trailing elements. Specifically, it uses a "mana_handle

[PATCH v2] RDMA/mana_ib: Add flex array to struct mana_cfg_rx_steer_req_v2

2024-04-01 Thread Erick Archer
ited and modified manually. Link: https://www.kernel.org/doc/html/next/process/deprecated.html#zero-length-and-one-element-arrays [1] Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [2] Signed-off-by: Erick Archer --- Changes in v2:

[PATCH v3 0/3] RDMA/mana_ib: Add flex array to struct mana_cfg_rx_steer_req_v2

2024-04-06 Thread Erick Archer
msg = "WARNING: verify allocation on line %s" % (p1[0].line) coccilib.report.print_report(p1[0],msg) Link: https://www.kernel.org/doc/html/next/process/deprecated.html#zero-length-and-one-element-arrays [1] Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-a

[PATCH v3 1/3] net: mana: Add flex array to struct mana_cfg_rx_steer_req_v2

2024-04-06 Thread Erick Archer
cated.html#zero-length-and-one-element-arrays [1] Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [2] Signed-off-by: Erick Archer --- include/net/mana/mana.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/net/mana/mana.h b

[PATCH v3 2/3] RDMA/mana_ib: Prefer struct_size over open coded arithmetic

2024-04-06 Thread Erick Archer
re readable and safer. This code was detected with the help of Coccinelle, and audited and modified manually. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off

[PATCH v3 3/3] net: mana: Avoid open coded arithmetic

2024-04-06 Thread Erick Archer
l.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- drivers/net/ethernet/microsoft/mana/mana_en.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a

Re: [PATCH v2] dmaengine: pl08x: Use kcalloc() instead of kzalloc()

2024-04-07 Thread Erick Archer
Hi Vinod, On Sun, Apr 07, 2024 at 05:09:39PM +0530, Vinod Koul wrote: > On 30-03-24, 16:23, Erick Archer wrote: > > This is an effort to get rid of all multiplications from allocation > > functions in order to prevent integer overflows [1]. > > > > Here the multi

Re: [PATCH] perf/x86/intel/uncore: Prefer struct_size over open coded arithmetic

2024-04-27 Thread Erick Archer
On Sat, Mar 30, 2024 at 03:32:59PM +0100, Erick Archer wrote: > This is an effort to get rid of all multiplications from allocation > functions in order to prevent integer overflows [1][2]. > > As the "box" variable is a pointer to "struct intel_uncore_box" and >

Re: [PATCH v3] scsi: csiostor: Use kcalloc() instead of kzalloc()

2024-04-27 Thread Erick Archer
On Sat, Mar 30, 2024 at 05:17:53PM +0100, Erick Archer wrote: > Use 2-factor multiplication argument form kcalloc() instead > of kzalloc(). > > Also, it is preferred to use sizeof(*pointer) instead of > sizeof(type) due to the type of the variable can change and > one needs not

[PATCH] Input: ff-core - prefer struct_size over open coded arithmetic

2024-04-27 Thread Erick Archer
https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- Hi, The Coccinelle script used to detect this code pattern is the following: virtual report @rule1@ type t1; type t2; identifier i0; identifier i1; identifier i2; identifier ALLOC =~ "kmalloc|kzalloc|kmalloc_node|kz

[PATCH v3] perf/x86/amd/uncore: Use kcalloc*() instead of kzalloc*()

2024-04-27 Thread Erick Archer
: https://github.com/KSPP/linux/issues/162 [1] Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [2] Reviewed-by: Gustavo A. R. Silva Signed-off-by: Erick Archer --- Changes in v3: - Update the commit message to better explain the changes

[PATCH] sctp: prefer struct_size over open coded arithmetic

2024-04-27 Thread Erick Archer
ce. This way, the code is more readable and safer. This code was detected with the help of Coccinelle, and audited and modified manually. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/is

[PATCH] tty: rfcomm: prefer struct_size over open coded arithmetic

2024-04-28 Thread Erick Archer
hub.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- Hi, The Coccinelle script used to detect this code pattern is the following: virtual report @rule1@ type t1; type t2; identifier i0; identifier i1; identifier i2; identifier ALLOC =~ "kmalloc|kzalloc|kmalloc_node|k

[PATCH] perf/ring_buffer: Prefer struct_size over open coded arithmetic

2024-04-29 Thread Erick Archer
udited and modified manually. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- Hi, The Coccinelle script used to detect this code pattern

Re: [PATCH] sctp: prefer struct_size over open coded arithmetic

2024-05-01 Thread Erick Archer
Hi Kees and Xin, On Mon, Apr 29, 2024 at 10:45:20AM -0700, Kees Cook wrote: > On Sat, Apr 27, 2024 at 07:23:36PM +0200, Erick Archer wrote: > > This is an effort to get rid of all multiplications from allocation > > functions in order to prevent integer overflows [1][2]. >

[PATCH] sctp: annotate struct sctp_assoc_ids with __counted_by()

2024-05-01 Thread Erick Archer
). Suggested-by: Kees Cook Signed-off-by: Erick Archer --- include/uapi/linux/sctp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h index b7d91d4cf0db..836173e73401 100644 --- a/include/uapi/linux/sctp.h +++ b/include/uapi

Re: [PATCH] perf/ring_buffer: Prefer struct_size over open coded arithmetic

2024-05-01 Thread Erick Archer
On Tue, Apr 30, 2024 at 11:15:04AM +0200, Peter Zijlstra wrote: > On Mon, Apr 29, 2024 at 07:40:58PM +0200, Erick Archer wrote: > > This is an effort to get rid of all multiplications from allocation > > functions in order to prevent integer overflows [1][2]. > > S

Re: [PATCH] perf/ring_buffer: Prefer struct_size over open coded arithmetic

2024-05-04 Thread Erick Archer
On Mon, Apr 29, 2024 at 07:40:58PM +0200, Erick Archer wrote: > > > > > This is an effort to get rid of all multiplications from allocation > > > > > functions in order to prevent integer overflows [1][2]. > > > > > > > > So personally I detest

[PATCH v2] perf/ring_buffer: Prefer struct_size over open coded arithmetic

2024-05-05 Thread Erick Archer
with the help of Coccinelle, and audited and modified manually. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- Changes in v2: - Annotate &quo

Re: [PATCH v2] perf/ring_buffer: Prefer struct_size over open coded arithmetic

2024-05-05 Thread Erick Archer
On Sun, May 05, 2024 at 05:24:55PM +0200, Christophe JAILLET wrote: > Le 05/05/2024 à 16:15, Erick Archer a écrit : > > diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c > > index 4013408ce012..080537eff69f 100644 > > --- a/kernel/events/ring_buffer.c &g

[PATCH] uapi: stddef.h: Provide UAPI macros for __counted_by_{le, be}

2024-05-06 Thread Erick Archer
Provide UAPI macros for UAPI structs that will gain annotations for __counted_by_{le, be} attributes. Signed-off-by: Erick Archer --- include/uapi/linux/stddef.h | 8 1 file changed, 8 insertions(+) diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h index

[PATCH v2] uapi: stddef.h: Provide UAPI macros for __counted_by_{le, be}

2024-05-07 Thread Erick Archer
. Link: https://lore.kernel.org/r/20240327142241.1745989-2-aleksander.loba...@intel.com Suggested-by: Sven Eckelmann Signed-off-by: Erick Archer --- Changes in v2: - Add the "Suggested_by:" tag. - Update the commit message to better explain the goal (Miguel Ojeda). Previous versions: v1 -&

Re: [PATCH v2] perf/ring_buffer: Prefer struct_size over open coded arithmetic

2024-05-09 Thread Erick Archer
Hi Kees and Christophe, First of all, thanks for the reviews, comments and advices. On Mon, May 06, 2024 at 09:23:15AM -0700, Kees Cook wrote: > On Sun, May 05, 2024 at 07:31:24PM +0200, Erick Archer wrote: > > On Sun, May 05, 2024 at 05:24:55PM +0200, Christophe JAILLET wrote: >

Re: [PATCH] uapi: stddef.h: Provide UAPI macros for __counted_by_{le, be}

2024-05-11 Thread Erick Archer
Hi Alexander, On Tue, May 07, 2024 at 02:58:15PM +0200, Alexander Lobakin wrote: > From: Erick Archer > Date: Mon, 6 May 2024 19:42:08 +0200 > > > Provide UAPI macros for UAPI structs that will gain annotations for > > __counted_by_{le, be} attributes. > > Pls

Re: [PATCH v3] scsi: csiostor: Use kcalloc() instead of kzalloc()

2024-05-11 Thread Erick Archer
Hi Martin, Kees and Finn, On Sat, Mar 30, 2024 at 05:17:53PM +0100, Erick Archer wrote: > Use 2-factor multiplication argument form kcalloc() instead > of kzalloc(). > > Also, it is preferred to use sizeof(*pointer) instead of > sizeof(type) due to the type of the variable can c

[PATCH v3] perf/ring_buffer: Prefer struct_size over open coded arithmetic

2024-05-11 Thread Erick Archer
d after the "nr_pages" assignment. This way, the code is more safer. This code was detected with the help of Coccinelle, and audited and modified manually. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: h

Re: [PATCH] perf/x86/intel/uncore: Prefer struct_size over open coded arithmetic

2024-05-11 Thread Erick Archer
Hi everyone, On Sat, Mar 30, 2024 at 03:32:59PM +0100, Erick Archer wrote: > This is an effort to get rid of all multiplications from allocation > functions in order to prevent integer overflows [1][2]. > > As the "box" variable is a pointer to "struct intel_uncore_box

[PATCH] perf/x86/amd/uncore: Add flex array to struct amd_uncore_ctx

2024-05-11 Thread Erick Archer
ux/issues/160 [2] Suggested-by: Christophe JAILLET Signed-off-by: Erick Archer --- Hi, This patch can be considered v4 of this other one [1]. However, since the patch has completely changed due to the addition of the flex array, I have decided to make a new series and remove the "Reviewed-by:&q

Re: [PATCH v3] scsi: csiostor: Use kcalloc() instead of kzalloc()

2024-05-11 Thread Erick Archer
Hi James, On Sat, May 11, 2024 at 01:18:46PM +0200, Erick Archer wrote: > Hi Martin, Kees and Finn, > > On Sat, Mar 30, 2024 at 05:17:53PM +0100, Erick Archer wrote: > > Use 2-factor multiplication argument form kcalloc() instead > > of kzalloc(). > > > > Al

[PATCH v2] tty: rfcomm: prefer struct_size over open coded arithmetic

2024-05-12 Thread Erick Archer
arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- Changes in v2: - Add the __counted_by() attribute (Kees Cook). - Refactor the list_for_each_entry() loop to use di[n] instead of (di + n) (Kees Cook). Previous versio

[PATCH] Bluetooth: hci_core: Prefer struct_size over open coded arithmetic

2024-05-12 Thread Erick Archer
l#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- include/net/bluetooth/hci_sock.h | 2 +- net/bluetooth/hci_core.c | 15 ++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --gi

[PATCH] net: prestera: Add flex arrays to some structs

2024-05-12 Thread Erick Archer
oded-arithmetic-in-allocator-arguments [2] Signed-off-by: Erick Archer --- .../ethernet/marvell/prestera/prestera_hw.c | 83 +-- 1 file changed, 37 insertions(+), 46 deletions(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.c b/drivers/net/ethernet

Re: [PATCH v2] tty: rfcomm: prefer struct_size over open coded arithmetic

2024-05-13 Thread Erick Archer
Hi Kees, Jiri and Luiz, First of all, thanks for the reviews. On Mon, May 13, 2024 at 12:29:04PM -0400, Luiz Augusto von Dentz wrote: > Hi Jiri, Eric, > > On Mon, May 13, 2024 at 1:07 AM Jiri Slaby wrote: > > > > On 12. 05. 24, 13:17, Erick Archer wrote: > > > T

Re: [PATCH] Bluetooth: hci_core: Prefer struct_size over open coded arithmetic

2024-05-13 Thread Erick Archer
Hi Kees and Luiz, First of all, thanks for the reviews. On Mon, May 13, 2024 at 12:31:29PM -0400, Luiz Augusto von Dentz wrote: > Hi Eric, > > On Sun, May 12, 2024 at 11:08 PM Kees Cook wrote: > > > > On Sun, May 12, 2024 at 04:17:06PM +0200, Erick Archer wrote: > >

[PATCH v3 0/2] tty: rfcomm: refactor rfcomm_get_dev_list() function

2024-05-17 Thread Erick Archer
ous versions: v2 -> https://lore.kernel.org/linux-hardening/as8pr02mb7237262c62b054fabd7229168b...@as8pr02mb7237.eurprd02.prod.outlook.com/ v1 -> https://lore.kernel.org/linux-hardening/as8pr02mb723725e0069f7ae8f64e876e8b...@as8pr02mb7237.eurprd02.prod.outlook.com/ --- Erick Archer (2): tty: rfcomm: prefer

[PATCH v3 1/2] tty: rfcomm: prefer struct_size over open coded arithmetic

2024-05-17 Thread Erick Archer
he code is more readable and safer. This code was detected with the help of Coccinelle, and audited and modified manually. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] R

[PATCH v3 2/2] tty: rfcomm: prefer array indexing over pointer arithmetic

2024-05-17 Thread Erick Archer
Refactor the list_for_each_entry() loop of rfcomm_get_dev_list() function to use array indexing instead of pointer arithmetic. This way, the code is more readable and idiomatic. Reviewed-by: Kees Cook Signed-off-by: Erick Archer --- net/bluetooth/rfcomm/tty.c | 12 ++-- 1 file changed

[PATCH v2 0/2] Bluetooth: hci_core: Refactor hci_get_dev_list() function

2024-05-18 Thread Erick Archer
/160 [2] --- Changes in v2: - Add the "Reviewed-by:" tags. - Split the changes in two commits (Luiz Augusto von Dentz). Previous versions: v1 -> https://lore.kernel.org/linux-hardening/as8pr02mb7237ecd397bdb7f529adc7468b...@as8pr02mb7237.eurprd02.prod.outlook.com/ --- Erick Archer

[PATCH v2 1/2] Bluetooth: hci_core: Prefer struct_size over open coded arithmetic

2024-05-18 Thread Erick Archer
/issues/160 [2] Reviewed-by: Kees Cook Signed-off-by: Erick Archer --- include/net/bluetooth/hci_sock.h | 2 +- net/bluetooth/hci_core.c | 11 --- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/hci_sock.h b/include/net/bluetooth/hci_sock.h ind

[PATCH v2 2/2] Bluetooth: hci_core: Prefer array indexing over pointer arithmetic

2024-05-18 Thread Erick Archer
Refactor the list_for_each_entry() loop of hci_get_dev_list() function to use array indexing instead of pointer arithmetic. This way, the code is more readable and idiomatic. Reviewed-by: Kees Cook Signed-off-by: Erick Archer --- net/bluetooth/hci_core.c | 4 ++-- 1 file changed, 2 insertions

[PATCH] Bluetooth: Use sizeof(*pointer) instead of sizeof(type)

2024-05-24 Thread Erick Archer
It is preferred to use sizeof(*pointer) instead of sizeof(type) due to the type of the variable can change and one needs not change the former (unlike the latter). This patch has no effect on runtime behavior. Signed-off-by: Erick Archer --- drivers/bluetooth/btrtl.c | 2 +- drivers

[PATCH] Input: keyboard - use sizeof(*pointer) instead of sizeof(type)

2024-05-24 Thread Erick Archer
It is preferred to use sizeof(*pointer) instead of sizeof(type) due to the type of the variable can change and one needs not change the former (unlike the latter). This patch has no effect on runtime behavior. Signed-off-by: Erick Archer --- drivers/input/keyboard/atkbd.c | 2 +- drivers

[RFC] HID: ishtp-hid-client: replace fake-flex arrays with flex-array members

2024-05-26 Thread Erick Archer
nd safer. Link: https://www.kernel.org/doc/html/next/process/deprecated.html#zero-length-and-one-element-arrays [1] Closes: https://github.com/KSPP/linux/issues/333 Signed-off-by: Erick Archer --- Hi, The idea behind this patch is extracted from the ones sent by Gustavo A. R. Silva [1] but

[PATCH] wifi: brcm80211: use sizeof(*pointer) instead of sizeof(type)

2024-05-26 Thread Erick Archer
It is preferred to use sizeof(*pointer) instead of sizeof(type) due to the type of the variable can change and one needs not change the former (unlike the latter). This patch has no effect on runtime behavior. Signed-off-by: Erick Archer --- .../broadcom/brcm80211/brcmfmac/bcmsdh.c | 4

[PATCH v2] wifi: brcm80211: use sizeof(*pointer) instead of sizeof(type)

2024-05-27 Thread Erick Archer
Spriel Signed-off-by: Erick Archer --- Changes in v2: - Remove some redundant NULL initializations (Arend van Spriel). - Refactor a bit the logic of "phy_lcn.c" (Arend van Spriel). - Add the "Acked-by:" tag. Previous versions: v1 -> https://lore.ker

Re: [PATCH] sctp: annotate struct sctp_assoc_ids with __counted_by()

2024-06-01 Thread Erick Archer
Hi, On Wed, May 01, 2024 at 07:01:22PM +0200, Erick Archer 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_BOUND

[PATCH v4 0/3] Hardening perf subsystem

2024-06-01 Thread Erick Archer
pared to the previous version, of the second rb_alloc() function to gain __counted_by() coverage (Kees Cook and Christophe JAILLET). Changes in v2: - Annotate "struct perf_buffer" with __counted_by() attribute (Kees Cook). - Refactor the logic to gain __counted_by() coverage (Kee

[PATCH v4 1/3] perf/x86/amd/uncore: Add flex array to struct amd_uncore_ctx

2024-06-01 Thread Erick Archer
ux/issues/160 [2] Suggested-by: Christophe JAILLET Reviewed-by: Kees Cook Signed-off-by: Erick Archer --- arch/x86/events/amd/uncore.c | 18 +- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index 0fafe233b

[PATCH v4 2/3] perf/x86/intel/uncore: Prefer struct_size over open coded arithmetic

2024-06-01 Thread Erick Archer
was detected with the help of Coccinelle, and audited and modified manually. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Reviewed-by: Kees Cook Signed-off-by: Erick Archer ---

[PATCH v4 3/3] perf/ring_buffer: Prefer struct_size over open coded arithmetic

2024-06-01 Thread Erick Archer
d after the "nr_pages" assignment. This way, the code is more safer. This code was detected with the help of Coccinelle, and audited and modified manually. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https:

[PATCH] nvdimm/btt: use sizeof(*pointer) instead of sizeof(type)

2024-06-02 Thread Erick Archer
It is preferred to use sizeof(*pointer) instead of sizeof(type) due to the type of the variable can change and one needs not change the former (unlike the latter). This patch has no effect on runtime behavior. Signed-off-by: Erick Archer --- drivers/nvdimm/btt.c | 4 ++-- 1 file changed, 2

[PATCH] soc: fsl: qe: use sizeof(*pointer) instead of sizeof(type)

2024-06-02 Thread Erick Archer
It is preferred to use sizeof(*pointer) instead of sizeof(type) due to the type of the variable can change and one needs not change the former (unlike the latter). This patch has no effect on runtime behavior. Signed-off-by: Erick Archer --- drivers/soc/fsl/qe/ucc_fast.c | 2 +- drivers/soc/fsl

[PATCH] auxdisplay: Use sizeof(*pointer) instead of sizeof(type)

2024-06-02 Thread Erick Archer
It is preferred to use sizeof(*pointer) instead of sizeof(type) due to the type of the variable can change and one needs not change the former (unlike the latter). This patch has no effect on runtime behavior. Signed-off-by: Erick Archer --- drivers/auxdisplay/arm-charlcd.c | 2 +- drivers

[PATCH 0/2] atmel: at76c50x: improve code robustness

2024-06-02 Thread Erick Archer
_FORTIFY_SOURCE (for strcpy/memcpy-family functions). This way, the code is more readable and safer. Regards, Erick Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] --- Erick

[PATCH 1/2] atmel: at76c50x: use sizeof(*pointer) instead of sizeof(type)

2024-06-02 Thread Erick Archer
It is preferred to use sizeof(*pointer) instead of sizeof(type) due to the type of the variable can change and one needs not change the former (unlike the latter). This patch has no effect on runtime behavior. At the same time remove some redundant NULL initializations. Signed-off-by: Erick

[PATCH 2/2] atmel: at76c50x: prefer struct_size over open coded arithmetic

2024-06-02 Thread Erick Archer
arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/160 [2] Signed-off-by: Erick Archer --- drivers/net/wireless/atmel/at76c50x-usb.c | 12 ++-- drivers/net/wireless/atmel/at76c50x-usb.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/driver

[PATCH] input: misc: use sizeof(*pointer) instead of sizeof(type)

2024-06-02 Thread Erick Archer
It is preferred to use sizeof(*pointer) instead of sizeof(type) due to the type of the variable can change and one needs not change the former (unlike the latter). This patch has no effect on runtime behavior. Signed-off-by: Erick Archer --- drivers/input/misc/88pm80x_onkey.c | 2 +- drivers

  1   2   >