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

2024-03-18 Thread Gustavo A. R. Silva
On 18/03/24 17:40, Kees Cook wrote: On Sun, Mar 17, 2024 at 05:44:42PM +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 "rapl_pmus" variable is a pointer to "struct rapl_pmus" and thi

Re: [PATCH v2] soc: qcom: cmd-db: replace deprecated strncpy with strtomem

2024-03-18 Thread Bjorn Andersson
On Mon, Mar 18, 2024 at 10:49:23PM +, Justin Stitt wrote: > strncpy() is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > I don't mind changing the strncpy() in this function, but I don't think th

Re: [PATCH][next] stddef: Introduce struct_group_tagged_attr() helper macro

2024-03-18 Thread Gustavo A. R. Silva
On 3/18/24 17:53, Kees Cook wrote: On Mon, Mar 18, 2024 at 05:00:33PM -0600, Gustavo A. R. Silva wrote: We need a new `struct_group()` helper that allows for both having the struct be tagged, and specifying struct attributes like `__packed` or `__align(x)`. This new helper will initially be

Re: [PATCH][next] stddef: Introduce struct_group_tagged_attr() helper macro

2024-03-18 Thread Kees Cook
On Mon, Mar 18, 2024 at 05:00:33PM -0600, Gustavo A. R. Silva wrote: > We need a new `struct_group()` helper that allows for both having the > struct be tagged, and specifying struct attributes like `__packed` > or `__align(x)`. > > This new helper will initially be used to address > -Wflex-array-

Re: [PATCH v2] soc: qcom: cmd-db: replace deprecated strncpy with strtomem

2024-03-18 Thread Kees Cook
On Mon, Mar 18, 2024 at 10:49:23PM +, Justin Stitt wrote: > strncpy() is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > @query is already marked as __nonstring and doesn't need to be > NUL-term

Re: [PATCH] soc: qcom: cmd-db: replace deprecated strncpy with memcpy

2024-03-18 Thread Kees Cook
On Mon, Mar 18, 2024 at 03:47:38PM -0700, Justin Stitt wrote: > Gotcha, I was operating under the assumption that we needed to know > the size of id at compile time. Apparently __builtin_object_size(_, 1) > will return SIZE_T_MAX if we don't know the size of something. Sending > a v2. Yeah, it onl

Re: [PATCH] x86, relocs: Ignore relocations in .notes section on walk_relocs

2024-03-18 Thread Kees Cook
On Mon, Mar 18, 2024 at 10:56:12PM +0100, Borislav Petkov wrote: > On Mon, Mar 18, 2024 at 02:40:50PM -0700, Kees Cook wrote: > > Applied to for-next/hardening > > Why? > > This is a patch that should go through the tip tree, if at all. The commit it refs to landed via -hardening, so I was takin

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

2024-03-18 Thread Kees Cook
On Sun, Mar 17, 2024 at 05:44:42PM +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 "rapl_pmus" variable is a pointer to "struct rapl_pmus" and > this structure ends in a flexible a

[PATCH] usb: gadget: mv_u3d: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
strscpy(ep->name, name); ep->ep.name = ep->name; ep->ep.caps.type_iso = true; --- base-commit: bf3a69c6861ff4dc7892d895c87074af7bc1c400 change-id: 20240318-strncpy-drivers-usb-gadget-udc-mv_u3d_core-c-50ea7422311c Best regards, -- Justin Stitt

[PATCH] usb: gadget: u_ether: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
%')) return -EINVAL; - strncpy(net->name, tmp, sizeof(net->name)); + strscpy(net->name, tmp); dev->ifname_set = true; return 0; --- base-commit: bf3a69c6861ff4dc7892d895c87074af7bc1c400 change-id: 20240318-strncpy-drivers-usb-gadget-function-u_ether-c-125ed8336ca5 Best regards, -- Justin Stitt

[PATCH] tty: n_gsm: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
me */ /* reconfigure dlci for network */ dlci->prev_adaption = dlci->adaption; --- base-commit: bf3a69c6861ff4dc7892d895c87074af7bc1c400 change-id: 20240318-strncpy-drivers-tty-n_gsm-c-ab1336e0e196 Best regards, -- Justin Stitt

[PATCH][next] stddef: Introduce struct_group_tagged_attr() helper macro

2024-03-18 Thread Gustavo A. R. Silva
We need a new `struct_group()` helper that allows for both having the struct be tagged, and specifying struct attributes like `__packed` or `__align(x)`. This new helper will initially be used to address -Wflex-array-member-not-at-end warnings, where a tagged struct is used to separate the flexibl

[PATCH v2] soc: qcom: cmd-db: replace deprecated strncpy with strtomem

2024-03-18 Thread Justin Stitt
strncpy() is deprecated for use on NUL-terminated destination strings [1] and as such we should prefer more robust and less ambiguous string interfaces. @query is already marked as __nonstring and doesn't need to be NUL-terminated. Since @id is a string, we can use the self-describing string API s

Re: [PATCH] soc: qcom: cmd-db: replace deprecated strncpy with memcpy

2024-03-18 Thread Justin Stitt
On Mon, Mar 18, 2024 at 2:52 PM Kees Cook wrote: > > On Thu, Mar 14, 2024 at 10:29:37PM +, Justin Stitt wrote: > > strncpy() is deprecated for use on NUL-terminated destination strings > > [1] and as such we should prefer more robust and less ambiguous string > > interfaces. > > > > @query is

[PATCH] thermal: intel: int340x_thermal: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
.string, psvts[i].limit.string, + strscpy(psvt_user[i].limit.string, psvts[i].limit.string, ACPI_LIMIT_STR_MAX_LEN); else psvt_user[i].limit.integer = psvts[i].limit.integer; --- base-commit: bf3a69c6861ff

[PATCH] scsi: target: core: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
strscpy(p_buf, buf, p_buf_len); else pr_debug("%s", buf); --- base-commit: bf3a69c6861ff4dc7892d895c87074af7bc1c400 change-id: 20240318-strncpy-drivers-target-target_core_transport-c-1950554ec04e Best regards, -- Justin Stitt

Re: [PATCH] x86, relocs: Ignore relocations in .notes section on walk_relocs

2024-03-18 Thread Borislav Petkov
On Mon, Mar 18, 2024 at 02:40:50PM -0700, Kees Cook wrote: > Applied to for-next/hardening Why? This is a patch that should go through the tip tree, if at all. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette

Re: [PATCH] ubsan: Remove unused function

2024-03-18 Thread Kees Cook
On Fri, Mar 15, 2024 at 09:53:47AM +0800, Jiapeng Chong wrote: > The function are defined in the test_ubsan.c file, but not called > elsewhere, so delete the unused function. > > lib/test_ubsan.c:137:28: warning: unused variable 'skip_ubsan_array'. > > Reported-by: Abaci Robot > Closes: https://

Re: [PATCH] soc: qcom: cmd-db: replace deprecated strncpy with memcpy

2024-03-18 Thread Kees Cook
On Thu, Mar 14, 2024 at 10:29:37PM +, Justin Stitt wrote: > strncpy() is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > @query is already marked as __nonstring and doesn't need to be > NUL-term

Re: [PATCH] scsi: target: replace deprecated strncpy with strscpy

2024-03-18 Thread Kees Cook
On Mon, Mar 18, 2024 at 09:32:01PM +, Justin Stitt wrote: > strncpy() is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > We expect db_root and db_root_stage to be NUL-terminated based on its > i

Re: [PATCH] x86, relocs: Ignore relocations in .notes section on walk_relocs

2024-03-18 Thread Kees Cook
On Sun, 17 Mar 2024 23:05:47 +0800, Guixiong Wei wrote: > The commit aaa8736370db ("x86, relocs: Ignore relocations in > .notes section") only ignore .note section on print_absolute_relocs, > but it also need to add on walk_relocs to avoid relocations in .note > section. > > Applied to for-next/

[PATCH] scsi: target: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
strncpy() is deprecated for use on NUL-terminated destination strings [1] and as such we should prefer more robust and less ambiguous string interfaces. We expect db_root and db_root_stage to be NUL-terminated based on its immediate use with pr_debug which expects a C-string argument (%s). Moreove

Re: [PATCH RFC kspp-next 0/3] compiler_types: add Endianness-dependent __counted_by_{le,be}

2024-03-18 Thread Kees Cook
On Mon, Mar 18, 2024 at 02:03:51PM +0100, Alexander Lobakin wrote: > include/linux/compiler_types.h | 11 ++ > drivers/net/ethernet/intel/idpf/virtchnl2.h | 24 ++--- > 2 files changed, 23 insertions(+), 12 deletions(-) Oh, I see the Subject says "kspp-next" -

Re: [PATCH RFC kspp-next 0/3] compiler_types: add Endianness-dependent __counted_by_{le,be}

2024-03-18 Thread Kees Cook
On Mon, Mar 18, 2024 at 02:03:51PM +0100, Alexander Lobakin wrote: > Some structures contain flexible arrays at the end and the counter for > them, but the counter has explicit Endianness and thus __counted_by() > can't be used directly. > > To increase test coverage for potential problems without

[PATCH RFC kspp-next 3/3] idpf: sprinkle __counted_by{,_le}() in the virtchnl2 header

2024-03-18 Thread Alexander Lobakin
Both virtchnl2.h and its consumer idpf_virtchnl.c are very error-prone. There are 10 structures with flexible arrays at the end, but 9 of them has flex member counter in Little Endian. Make the code a bit more robust by applying __counted_by_le() to those 9. LE platforms is the main target for this

[PATCH RFC kspp-next 2/3] idpf: make virtchnl2.h self-contained

2024-03-18 Thread Alexander Lobakin
To ease maintaining of virtchnl2.h, which already is messy enough, make it self-contained by adding missing if_ether.h include due to %ETH_ALEN usage. At the same time, virtchnl2_lan_desc.h is not anywhere in the file, so remove this include to speed up preprocessing. Signed-off-by: Alexander Loba

[PATCH RFC kspp-next 1/3] compiler_types: add Endianness-dependent __counted_by_{le,be}

2024-03-18 Thread Alexander Lobakin
Some structures contain flexible arrays at the end and the counter for them, but the counter has explicit Endianness and thus __counted_by() can't be used directly. To increase test coverage for potential problems without breaking anything, introduce __counted_by_{le,be} defined depending on platfo

[PATCH RFC kspp-next 0/3] compiler_types: add Endianness-dependent __counted_by_{le,be}

2024-03-18 Thread Alexander Lobakin
Some structures contain flexible arrays at the end and the counter for them, but the counter has explicit Endianness and thus __counted_by() can't be used directly. To increase test coverage for potential problems without breaking anything, introduce __counted_by_{le,be} defined depending on platf

Re: [PATCH AUTOSEL 6.1 10/12] enic: Avoid false positive under FORTIFY_SOURCE

2024-03-18 Thread Sasha Levin
On Mon, Mar 11, 2024 at 10:03:35PM +0100, Pavel Machek wrote: Hi! From: Kees Cook [ Upstream commit 40b9385dd8e6a0515e1c9cd06a277483556b7286 ] FORTIFY_SOURCE has been ignoring 0-sized destinations while the kernel code base has been converted to flexible arrays. In order to enforce the 0-siz

Re: [PATCH v2 1/2] landlock: Extend documentation for kernel support

2024-03-18 Thread Alejandro Colomar
Hi Mickaël, Günther, Sorry for the delay! On Thu, Mar 07, 2024 at 11:21:57AM +0100, Mickaël Salaün wrote: > CCing Alejandro > > On Tue, Feb 27, 2024 at 05:32:20PM +0100, Günther Noack wrote: > > On Tue, Feb 27, 2024 at 12:05:49PM +0100, Mickaël Salaün wrote: > > > Extend the kernel support secti