[PATCH -next 2/2] lib/string_choices: Add wrapper for str_false_true()

2024-08-22 Thread Hongbo Li
There are many "false" : "true" format in the kernel tree, so we add str_false_true() as well. Signed-off-by: Hongbo Li --- include/linux/string_choices.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h index 7c74497caf2b..ebcc5

[PATCH -next 0/2] Add str_true_false()/str_false_true() helper

2024-08-22 Thread Hongbo Li
Add str_true_false()/str_false_true() helper to "true" or "false" string literal. And we found more than 10 cases currently exist in the tree. So these helpers can be used for these cases. Hongbo Li (2): lib/string_choices: Add str_true_false() helper lib/string_choices: Add wrapper for str_fa

[PATCH -next 1/2] lib/string_choices: Add str_true_false() helper

2024-08-22 Thread Hongbo Li
Add str_true_false() helper to return "true" or "false" string literal. Signed-off-by: Hongbo Li --- include/linux/string_choices.h | 5 + 1 file changed, 5 insertions(+) diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h index 1320bcdcb89c..7c74497caf2b 100644 ---

Re: [PATCH v3] slab: Introduce kmalloc_obj() and family

2024-08-22 Thread Przemek Kitszel
On 8/23/24 01:13, Kees Cook wrote: (...) For cases where the total size of the allocation is needed, the kmalloc_obj_sz(), kmalloc_objs_sz(), and kmalloc_flex_sz() family of macros can be used. For example: info->size = struct_size(ptr, flex_member, count); ptr = kmalloc(info->s

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

2024-08-22 Thread Kees Cook
On Tue, Jun 11, 2024 at 11:26:25PM -0700, srinivas pandruvada wrote: > On Sat, 2024-06-08 at 11:56 +0200, Erick Archer wrote: > > Hi Srinivas, > > First of all, thanks for looking at this ;) > > > > On Sat, Jun 08, 2024 at 01:42:54AM -0700, srinivas pandruvada wrote: > > > On Sun, 2024-05-26 at 15

Re: [PATCH] leds: gpio: Set num_leds after allocation

2024-08-22 Thread Kees Cook
On Thu, Jul 25, 2024 at 11:22:40AM +0100, Lee Jones wrote: > On Tue, 16 Jul 2024, Gustavo A. R. Silva wrote: > > > > > > > On 16/07/24 15:24, Kees Cook wrote: > > > With the new __counted_by annotation, the "num_leds" variable needs to > > > valid for accesses to the "leds" array. This requireme

Re: [PATCH] x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments()

2024-08-22 Thread Kees Cook
On Thu, Jul 11, 2024 at 02:01:53PM -0700, Dave Hansen wrote: > On 7/8/24 13:22, Kees Cook wrote: > ... > > diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h > > index 2fc7bc3863ff..7c488ff0c764 100644 > > --- a/arch/x86/include/asm/syscall.h > > +++ b/arch/x86/include/asm

Re: [PATCH] string: Check for "nonstring" attribute on strscpy() arguments

2024-08-22 Thread Kees Cook
On Mon, 05 Aug 2024 14:43:44 -0700, Kees Cook wrote: > GCC already checks for arguments that are marked with the "nonstring"[1] > attribute when used on standard C String API functions (e.g. strcpy). Gain > this compile-time checking also for the kernel's primary string copying > function, strscpy(

Re: [PATCH] string: Check for "nonstring" attribute on strscpy() arguments

2024-08-22 Thread Kees Cook
On Tue, Aug 06, 2024 at 12:29:30PM +0200, Przemek Kitszel wrote: > On 8/5/24 23:43, Kees Cook wrote: > > GCC already checks for arguments that are marked with the "nonstring"[1] > > attribute when used on standard C String API functions (e.g. strcpy). Gain > > this compile-time checking also for th

Re: [PATCH 0/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt

2024-08-22 Thread Kees Cook
On Wed, 10 Jul 2024 16:09:11 -0700, Kees Cook wrote: > This replaces the 1-element "fake" flexible array in struct > hfi_session_release_buffer_pkt with a modern flexible array and adds > the __counted_by annotation that was identified during the analysis. > > Thanks! > > -Kees > > [...] Applie

Re: [PATCH] virt: vbox: struct vmmdev_hgcm_pagelist: Replace 1-element array with flexible array

2024-08-22 Thread Kees Cook
On Wed, 10 Jul 2024 16:15:55 -0700, Kees Cook wrote: > Replace the deprecated[1] use of a 1-element array in > struct vmmdev_hgcm_pagelist with a modern flexible array. As this is > UAPI, we cannot trivially change the size of the struct, so use a union > to retain the old first element's size, but

[PATCH v3] slab: Introduce kmalloc_obj() and family

2024-08-22 Thread Kees Cook
Introduce type-aware kmalloc-family helpers to replace the common idioms for single, array, and flexible object allocations: ptr = kmalloc(sizeof(*ptr), gfp); ptr = kzalloc(sizeof(*ptr), gfp); ptr = kmalloc_array(count, sizeof(*ptr), gfp); ptr = kcalloc(count, sizeo

Re: [PATCH][next] wifi: mwifiex: Fix memcpy() field-spanning write warning in mwifiex_cmd_802_11_scan_ext()

2024-08-22 Thread Brian Norris
On Wed, Aug 21, 2024 at 03:23:51PM -0600, Gustavo A. R. Silva wrote: > Replace one-element array with a flexible-array member in > `struct host_cmd_ds_802_11_scan_ext`. > > With this, fix the following warning: > > elo 16 17:51:58 surfacebook kernel: [ cut here ] > elo 16

Re: [PATCH 5/5] slab: Allocate and use per-call-site caches

2024-08-22 Thread Kees Cook
On Sat, Aug 17, 2024 at 09:30:58AM +0800, Xiu Jianfeng wrote: > Hi Kees, > > On 2024/8/9 15:33, Kees Cook wrote: > > Use separate per-call-site kmem_cache or kmem_buckets. These are > > allocated on demand to avoid wasting memory for unused caches. > > > > A few caches need to be allocated very e

Re: [PATCH][next] xen/pci: Avoid -Wflex-array-member-not-at-end warning

2024-08-22 Thread Kees Cook
On Tue, Aug 20, 2024 at 06:50:56PM -0600, Gustavo A. R. Silva wrote: > Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of > a flexible structure where the size of the flexible-array member > is known at compile-time, and refactor the rest of the code, > accordingly. > > So, with this

Re: [PATCH][next] wifi: ath12k: Avoid -Wflex-array-member-not-at-end warnings

2024-08-22 Thread Jeff Johnson
On 8/22/2024 9:51 AM, Kalle Valo wrote: > "Gustavo A. R. Silva" wrote: > >> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are >> getting ready to enable it, globally. >> >> Move the conflicting declaration to the end of the structure. Notice >> that `struct ieee80211_chanctx_con

Re: [PATCH][next] wifi: ath12k: Avoid -Wflex-array-member-not-at-end warnings

2024-08-22 Thread Kalle Valo
"Gustavo A. R. Silva" wrote: > -Wflex-array-member-not-at-end was introduced in GCC-14, and we are > getting ready to enable it, globally. > > Move the conflicting declaration to the end of the structure. Notice > that `struct ieee80211_chanctx_conf` is a flexible structure --a > structure that

Re: [PATCH][next] wifi: ath11k: Avoid -Wflex-array-member-not-at-end warnings

2024-08-22 Thread Kalle Valo
Jeff Johnson writes: > On 8/9/2024 9:20 AM, Gustavo A. R. Silva wrote: > >> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are >> getting ready to enable it, globally. >> >> Move the conflicting declaration to the end of the structure. Notice >> that `struct ieee80211_chanctx_co

Re: [PATCH][next] wifi: mwifiex: Fix memcpy() field-spanning write warning in mwifiex_cmd_802_11_scan_ext()

2024-08-22 Thread Andy Shevchenko
On Wed, Aug 21, 2024 at 03:23:51PM -0600, Gustavo A. R. Silva wrote: > Replace one-element array with a flexible-array member in > `struct host_cmd_ds_802_11_scan_ext`. > > With this, fix the following warning: > > elo 16 17:51:58 surfacebook kernel: [ cut here ] > elo 16

Re: [PATCH v2] ksmbd: Replace one-element arrays with flexible-array members

2024-08-22 Thread Namjae Jeon
On Wed, Aug 21, 2024 at 4:15 AM Thorsten Blum wrote: > > Replace the deprecated one-element arrays with flexible-array members > in the structs copychunk_ioctl_req and smb2_ea_info_req. > > There are no binary differences after this conversion. > > Link: https://github.com/KSPP/linux/issues/79 > S

Re: [PATCH][next] wifi: iwlegacy: Avoid multiple -Wflex-array-member-not-at-end warnings

2024-08-22 Thread Kalle Valo
"Gustavo A. R. Silva" wrote: > -Wflex-array-member-not-at-end was introduced in GCC-14, and we are > getting ready to enable it, globally. > > So, in order to avoid ending up with a flexible-array member in the > middle of multiple other structs, we use the `__struct_group()` > helper to create