Re: [PATCH 60/82] powerpc: Refactor intentional wrap-around test

2024-02-11 Thread Michael Ellerman
Kees Cook writes: > In an effort to separate intentional arithmetic wrap-around from > unexpected wrap-around, we need to refactor places that depend on this > kind of math. One of the most common code patterns of this is: > > VAR + value < VAR > > Notably, this is considered "undefined beha

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

2024-02-11 Thread Erick Archer
This is an effort to get rid of all multiplications from allocation functions in order to prevent integer overflows [1]. Here the multiplication is obviously safe because MTK_PROTECT_PA_ALIGN is defined as a literal value of 256 or 128. For the "mtk_iommu.c" file: 256 For the "mtk_iommu_v1.c" fil

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

2024-02-11 Thread Erick Archer
This is an effort to get rid of all multiplications from allocation functions in order to prevent integer overflows [1]. Here the multiplication is obviously safe because DMAR_LATENCY_NUM is the number of latency types defined in the "latency_type" enum. enum latency_type { DMAR_LATENCY_I

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

2024-02-11 Thread Erick Archer
When a struct containing a flexible array is included in another struct, and there is a member after the struct-with-flex-array, there is a possibility of memory overlap. These cases must be audited [1]. See: struct inner { ... int flex[]; }; struct outer { ... str

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

2024-02-11 Thread Uwe Kleine-König
On Sun, Feb 11, 2024 at 10:16:33AM +0100, Erick Archer wrote: > This is an effort to get rid of all multiplications from allocation > functions in order to prevent integer overflows [1]. > > As the "chip" variable is a pointer to "struct mtk_nfc_nand_chip" and > this structure ends in a flexible a

Re: [PATCH] sh: Fix build with CONFIG_UBSAN=y

2024-02-11 Thread John Paul Adrian Glaubitz
Hi Kees, On Fri, 2024-02-02 at 12:06 +0100, John Paul Adrian Glaubitz wrote: > > When I use GCC 13.2 (I'm specifically on Ubuntu 23.10) and the randconfig > > linked from the report: > > https://download.01.org/0day-ci/archive/20240131/202401310416.s8hlilnc-...@intel.com/config > > (which is notab

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

2024-02-11 Thread Erick Archer
This is an effort to get rid of all multiplications from allocation functions in order to prevent integer overflows [1]. As the "chip" variable is a pointer to "struct mtk_nfc_nand_chip" and this structure ends in a flexible array: struct mtk_nfc_nand_chip { [...] u8 sels[] __coun