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

2024-02-02 Thread Manivannan Sadhasivam
On Sun, Jan 28, 2024 at 12:27:22PM +0100, 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 multiplication is obviously safe because the "event_rings" > member never can have a value

Re: [PATCH v5] iio: sx9324: avoid copying property strings

2024-02-02 Thread Stephen Boyd
Quoting Justin Stitt (2024-02-01 10:55:03) > We're doing some needless string copies when trying to assign the proper > `prop` string. We can make `prop` a const char* and simply assign to > string literals. > > For the case where a format string is used, let's extract the parsing > logic out into

Re: [GIT PULL] Enable -Wstringop-overflow globally

2024-02-02 Thread Linus Torvalds
On Thu, 1 Feb 2024 at 23:53, Arnd Bergmann wrote: > > I did a creduce pass on this warning when it first showed up > and opened a gcc bug report as well as a driver workaround: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113214 >

Re: [PATCH] wifi: brcmfmac: Adjust n_channels usage for __counted_by

2024-02-02 Thread Arend Van Spriel
On 2/2/2024 11:34 AM, Kalle Valo wrote: Arend Van Spriel writes: On 2/2/2024 10:58 AM, Arend Van Spriel wrote: On 2/1/2024 11:04 AM, Kalle Valo wrote: Kees Cook wrote: After commit e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by"), the compiler may

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 unnecessary or there is a potential > > >

Re: [PATCH] wifi: brcmfmac: Adjust n_channels usage for __counted_by

2024-02-02 Thread Kalle Valo
Kees Cook wrote: > After commit e3eac9f32ec0 ("wifi: cfg80211: Annotate struct > cfg80211_scan_request with __counted_by"), the compiler may enforce > dynamic array indexing of req->channels to stay below n_channels. As a > result, n_channels needs to be increased _before_ accessing the newly >

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

2024-02-02 Thread John Paul Adrian Glaubitz
Hi Kees, On Fri, 2024-02-02 at 02:32 -0800, Kees Cook wrote: > On Wed, Jan 31, 2024 at 12:19:22PM +0100, John Paul Adrian Glaubitz wrote: > > Hi Kees, > > > > On Wed, 2024-01-31 at 12:03 +0100, John Paul Adrian Glaubitz wrote: > > > Hi Kees, > > > > > > On Tue, 2024-01-30 at 15:27 -0800, Kees

Re: [PATCH] ubsan: Silence W=1 warnings in self-test

2024-02-02 Thread Marco Elver
On Fri, 2 Feb 2024 at 11:41, Kees Cook wrote: > > On Fri, Feb 02, 2024 at 10:57:11AM +0100, Marco Elver wrote: > > On Fri, 2 Feb 2024 at 10:46, Kees Cook wrote: > > > > > > Silence a handful of W=1 warnings in the UBSan selftest, which set > > > variables without using them. For example: > > > >

Re: [PATCH] ubsan: Silence W=1 warnings in self-test

2024-02-02 Thread Kees Cook
On Fri, Feb 02, 2024 at 10:57:11AM +0100, Marco Elver wrote: > On Fri, 2 Feb 2024 at 10:46, Kees Cook wrote: > > > > Silence a handful of W=1 warnings in the UBSan selftest, which set > > variables without using them. For example: > > > >lib/test_ubsan.c:101:6: warning: variable 'val1' set

Re: [PATCH] wifi: brcmfmac: Adjust n_channels usage for __counted_by

2024-02-02 Thread Kalle Valo
Arend Van Spriel writes: > On 2/2/2024 10:58 AM, Arend Van Spriel wrote: > >> On 2/1/2024 11:04 AM, Kalle Valo wrote: >>> Kees Cook wrote: >>> After commit e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by"), the compiler may enforce dynamic

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

2024-02-02 Thread Kees Cook
On Wed, Jan 31, 2024 at 12:19:22PM +0100, John Paul Adrian Glaubitz wrote: > Hi Kees, > > On Wed, 2024-01-31 at 12:03 +0100, John Paul Adrian Glaubitz wrote: > > Hi Kees, > > > > On Tue, 2024-01-30 at 15:27 -0800, Kees Cook wrote: > > > The early boot stub for sh had UBSan instrumentation

Re: [PATCH] wifi: brcmfmac: Adjust n_channels usage for __counted_by

2024-02-02 Thread Arend Van Spriel
On 2/2/2024 10:58 AM, Arend Van Spriel wrote: On 2/1/2024 11:04 AM, Kalle Valo wrote: Kees Cook wrote: After commit e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by"), the compiler may enforce dynamic array indexing of req->channels to stay below

Re: [PATCH] ubsan: Silence W=1 warnings in self-test

2024-02-02 Thread Marco Elver
On Fri, 2 Feb 2024 at 10:46, Kees Cook wrote: > > Silence a handful of W=1 warnings in the UBSan selftest, which set > variables without using them. For example: > >lib/test_ubsan.c:101:6: warning: variable 'val1' set but not used > [-Wunused-but-set-variable] > 101 | int val1 =

Re: [PATCH] wifi: brcmfmac: Adjust n_channels usage for __counted_by

2024-02-02 Thread Arend Van Spriel
On 2/1/2024 11:04 AM, Kalle Valo wrote: Kees Cook wrote: After commit e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by"), the compiler may enforce dynamic array indexing of req->channels to stay below n_channels. As a result, n_channels needs to be

[PATCH v2] MAINTAINERS: Add UBSAN section

2024-02-02 Thread Kees Cook
The kernel hardening efforts have continued to depend more and more heavily on UBSAN, so make an actual MAINTAINERS entry for it. Cc: Andrey Ryabinin Acked-by: Andrey Konovalov Acked-by: Marco Elver Signed-off-by: Kees Cook --- v2: - add kasan-dev, drop Andrey Ryabinin v1:

Re: [PATCH] MAINTAINERS: Add UBSAN section

2024-02-02 Thread Kees Cook
On Tue, Jan 30, 2024 at 03:46:38PM -0800, Kees Cook wrote: > The kernel hardening efforts have continued to depend more and more > heavily on UBSAN, so make an actual MAINTAINERS entry for it. > > Cc: Andrey Ryabinin I don't see Andrey on lkml in almost a year, so I'll drop the entry for now.

Re: [PATCH v2 2/5] overflow: Expand check_add_overflow() for pointer addition

2024-02-02 Thread Kees Cook
On Wed, Jan 31, 2024 at 09:35:35AM +0100, Rasmus Villemoes wrote: > On 30/01/2024 23.06, Kees Cook wrote: > > [...] > > diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h > > index 6f1ca49306d2..d27b58fddfaa 100644 > > --- a/include/linux/compiler_types.h > > +++

[PATCH] ubsan: Silence W=1 warnings in self-test

2024-02-02 Thread Kees Cook
Silence a handful of W=1 warnings in the UBSan selftest, which set variables without using them. For example: lib/test_ubsan.c:101:6: warning: variable 'val1' set but not used [-Wunused-but-set-variable] 101 | int val1 = 10; | ^ Reported-by: kernel test

Re: [PATCH v2 2/5] overflow: Expand check_add_overflow() for pointer addition

2024-02-02 Thread Kees Cook
On Thu, Feb 01, 2024 at 10:19:15AM +0100, Przemek Kitszel wrote: > On 1/30/24 23:06, Kees Cook wrote: > > The check_add_overflow() helper is mostly a wrapper around > > __builtin_add_overflow(), but GCC and Clang refuse to operate on pointer > > arguments that would normally be allowed if the