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

2024-05-11 Thread Kees Cook
On Sat, May 11, 2024 at 04:51:54PM +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]. > > The "struct amd_uncore_ctx" can be refactored to use a flex array for > the "events" member. This way,

[GIT PULL] hardening updates for 6.10-rc1

2024-05-11 Thread Kees Cook
Hi Linus, Please pull these hardening updates for 6.10-rc1. The bulk of the changes here are related to refactoring and expanding the KUnit tests for string helper and fortify behavior. Some trivial strncpy replacements in fs/ were carried in my tree. Also some fixes to SCSI string handling were

Re: [RFC] Mitigating unexpected arithmetic overflow

2024-05-11 Thread Dan Carpenter
I'm pretty sure we've tried using a sanitizer before and it had too many false positives. So your solution is to annotate all the false positives? There are two main issue which make integer overflows complicated from a static analysis perspective. 1) Places where it's intentional or we don't

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(). > > > > Also, it is preferred to use

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

2024-05-11 Thread Erick Archer
This is an effort to get rid of all multiplications from allocation functions in order to prevent integer overflows [1][2]. The "struct amd_uncore_ctx" can be refactored to use a flex array for the "events" member. This way, the allocation/freeing of the memory can be simplified. Specifically,

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" and > this structure ends

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

2024-05-11 Thread Erick Archer
This is an effort to get rid of all multiplications from allocation functions in order to prevent integer overflows [1][2]. As the "rb" variable is a pointer to "struct perf_buffer" and this structure ends in a flexible array: struct perf_buffer { [...] void*data_pages[]; };

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 change and > one

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 add me to Cc next time. Ok. >