Re: [PATCH v3 3/4] string: Allow 2-argument strscpy_pad()

2024-02-07 Thread Kees Cook
On Wed, Feb 07, 2024 at 12:51:51AM +, Justin Stitt wrote: > Hi, > > On Tue, Feb 06, 2024 at 06:22:18AM -0800, Kees Cook wrote: > > Similar to strscpy(), update strscpy_pad()'s 3rd argument to be > > optional when the destination is a compile-time known size array. > > This patch is diff'd aga

Re: [PATCH v4 2/3] overflow: Introduce wrapping_add(), wrapping_sub(), and wrapping_mul()

2024-02-07 Thread Kees Cook
On Tue, Feb 06, 2024 at 10:54:06AM -0600, Gustavo A. R. Silva wrote: > > > On 2/6/24 04:31, Kees Cook wrote: > > Provide helpers that will perform wrapping addition, subtraction, or > > multiplication without tripping the arithmetic wrap-around sanitizers. The > > first argument is the type under

Re: [PATCH v2] wifi: mwifiex: Refactor 1-element array into flexible array in struct mwifiex_ie_types_chan_list_param_set

2024-02-07 Thread Kees Cook
On Tue, Feb 06, 2024 at 02:32:32PM -0600, Gustavo A. R. Silva wrote: > > > On 2/6/24 12:39, Kees Cook wrote: > > struct mwifiex_ie_types_chan_list_param_set::chan_scan_param is treated > > as a flexible array, so convert it into one so that it doesn't trip the > > array bounds sanitizer[1]. Only

[PATCH v3] wifi: mwifiex: Refactor 1-element array into flexible array in struct mwifiex_ie_types_chan_list_param_set

2024-02-07 Thread Kees Cook
struct mwifiex_ie_types_chan_list_param_set::chan_scan_param is treated as a flexible array, so convert it into one so that it doesn't trip the array bounds sanitizer[1]. Only a few places were using sizeof() on the whole struct, so adjust those to follow the calculation pattern to avoid including

Removing more str APIs (was Re: [PATCH v3 4/4] um: Convert strscpy() usage to 2-argument style)

2024-02-07 Thread Kees Cook
On Tue, Feb 06, 2024 at 05:02:16PM +0200, Andy Shevchenko wrote: > On Tue, Feb 6, 2024 at 4:22 PM Kees Cook wrote: > > > > The ARCH=um build has its own idea about strscpy()'s definition. Adjust > > the callers to remove the redundant sizeof() arguments ahead of treewide > > changes, since it need

Re: [PATCH v3] ubsan: Reintroduce signed overflow sanitizer

2024-02-07 Thread Kees Cook
On Wed, Feb 07, 2024 at 01:45:28AM +, Justin Stitt wrote: > I wouldn't mind also seeing a test_ubsan_div_overflow test case here. > > It has some quirky behavior and it'd be nice to test that the sanitizers > properly capture it. > > Check out this Godbolt: https://godbolt.org/z/qG5f1j6n1 >

[PATCH v5 0/3] overflow: Introduce wrapping helpers

2024-02-07 Thread Kees Cook
v5: drop redundant checks (gustavo) v4: https://lore.kernel.org/linux-hardening/20240206102354.make.081-k...@kernel.org/ v3: https://lore.kernel.org/all/20240205090854.make.507-k...@kernel.org/ v2: https://lore.kernel.org/all/20240130220218.it.154-k...@kernel.org/ v1: https://lore.kernel.org/lkml/

[PATCH v5 2/3] overflow: Introduce wrapping_add(), wrapping_sub(), and wrapping_mul()

2024-02-07 Thread Kees Cook
Provide helpers that will perform wrapping addition, subtraction, or multiplication without tripping the arithmetic wrap-around sanitizers. The first argument is the type under which the wrap-around should happen with. In other words, these two calls will get very different results: wrappi

[PATCH v5 1/3] overflow: Adjust check_*_overflow() kern-doc to reflect results

2024-02-07 Thread Kees Cook
The check_*_overflow() helpers will return results with potentially wrapped-around values. These values have always been checked by the selftests, so avoid the confusing language in the kern-doc. The idea of "safe for use" was relative to the expectation of whether or not the caller wants a wrapped

[PATCH v5 3/3] overflow: Introduce wrapping_inc() and wrapping_dec()

2024-02-07 Thread Kees Cook
This allows replacements of the idioms "var += offset" and "var -= offset" with the wrapping_inc() and wrapping_dec() helpers respectively. They will avoid wrap-around sanitizer instrumentation. Add to the selftests to validate behavior and lack of side-effects. Cc: Rasmus Villemoes Cc: Marco El

Re: [PATCH v5 3/3] overflow: Introduce wrapping_inc() and wrapping_dec()

2024-02-07 Thread Andy Shevchenko
On Wed, Feb 7, 2024 at 5:24 PM Kees Cook wrote: > > This allows replacements of the idioms "var += offset" and "var -= offset" > with the wrapping_inc() and wrapping_dec() helpers respectively. They > will avoid wrap-around sanitizer instrumentation. > > Add to the selftests to validate behavior a

Re: [PATCH v5 3/3] overflow: Introduce wrapping_inc() and wrapping_dec()

2024-02-07 Thread Kees Cook
On Wed, Feb 07, 2024 at 05:31:54PM +0200, Andy Shevchenko wrote: > On Wed, Feb 7, 2024 at 5:24 PM Kees Cook wrote: > > > > This allows replacements of the idioms "var += offset" and "var -= offset" > > with the wrapping_inc() and wrapping_dec() helpers respectively. They > > will avoid wrap-around

Re: [PATCH v5 3/3] overflow: Introduce wrapping_inc() and wrapping_dec()

2024-02-07 Thread Andy Shevchenko
On Wed, Feb 07, 2024 at 08:08:14AM -0800, Kees Cook wrote: > On Wed, Feb 07, 2024 at 05:31:54PM +0200, Andy Shevchenko wrote: > > On Wed, Feb 7, 2024 at 5:24 PM Kees Cook wrote: > > > > > > This allows replacements of the idioms "var += offset" and "var -= offset" > > > with the wrapping_inc() and

Re: [PATCH v3] wifi: mwifiex: Refactor 1-element array into flexible array in struct mwifiex_ie_types_chan_list_param_set

2024-02-07 Thread Gustavo A. R. Silva
On 2/7/24 04:30, Kees Cook wrote: struct mwifiex_ie_types_chan_list_param_set::chan_scan_param is treated as a flexible array, so convert it into one so that it doesn't trip the array bounds sanitizer[1]. Only a few places were using sizeof() on the whole struct, so adjust those to follow the

Re: [RFC] string: Allow 2-argument strscpy()

2024-02-07 Thread Pavel Machek
Hi! > > Using sizeof(dst) is the overwhelmingly common case for strscpy(). > > Instead of requiring this everywhere, allow a 2-argument version to be > > used that will use the sizeof() internally. > > Yeah, this is definitely the case. I have a ton of patches replacing > strncpy with strscpy [1]

Re: KFENCE: included in x86 defconfig?

2024-02-07 Thread Marco Elver
[Cc'ing a bunch more people to get input] Hi Matt, On Wed, 7 Feb 2024 at 17:16, Matthieu Baerts wrote: [...] > When talking to Jakub about the kernel config used by the new CI for the > net tree [1], Jakub suggested [2] to check if KFENCE could not be > enabled by default for x86 architecture. >

Re: [PATCH v5 2/3] overflow: Introduce wrapping_add(), wrapping_sub(), and wrapping_mul()

2024-02-07 Thread Marco Elver
On Wed, 7 Feb 2024 at 16:24, Kees Cook wrote: > > Provide helpers that will perform wrapping addition, subtraction, or > multiplication without tripping the arithmetic wrap-around sanitizers. The > first argument is the type under which the wrap-around should happen > with. In other words, these t

Re: KFENCE: included in x86 defconfig?

2024-02-07 Thread Borislav Petkov
On Wed, Feb 07, 2024 at 07:05:31PM +0100, Marco Elver wrote: > I think this would belong into some "hardening" config - while KFENCE > is not a mitigation (due to sampling) it has the performance > characteristics of unintrusive hardening techniques, so I think it > would be a good fit. I think tha

Re: KFENCE: included in x86 defconfig?

2024-02-07 Thread Matthieu Baerts
Hi Marco, Thank you for your reply! On 07/02/2024 19:05, Marco Elver wrote: > [Cc'ing a bunch more people to get input] > > Hi Matt, > > On Wed, 7 Feb 2024 at 17:16, Matthieu Baerts wrote: > [...] >> When talking to Jakub about the kernel config used by the new CI for the >> net tree [1], Jaku

Re: KFENCE: included in x86 defconfig?

2024-02-07 Thread Matthieu Baerts
Hi Boris, Thank you for your reply. On 07/02/2024 19:16, Borislav Petkov wrote: > On Wed, Feb 07, 2024 at 07:05:31PM +0100, Marco Elver wrote: >> I think this would belong into some "hardening" config - while KFENCE >> is not a mitigation (due to sampling) it has the performance >> characteristic

Re: KFENCE: included in x86 defconfig?

2024-02-07 Thread Borislav Petkov
On Wed, Feb 07, 2024 at 07:35:53PM +0100, Matthieu Baerts wrote: > Sorry, I'm sure I understand your suggestion: do you mean not including > KFENCE in hardening.config either, but in another one? > > For the networking tests, we are already merging .config files, e.g. the > debug.config one. We ar

Re: [PATCH v2] x86/tdx: replace deprecated strncpy with strtomem_pad

2024-02-07 Thread Andy Shevchenko
On Wed, Oct 04, 2023 at 09:32:54AM +0200, Ingo Molnar wrote: ... > > Note: Ingo Molnar has some concerns about the comment being out of sync > > [1] but I believe the comment still has a place as we can still > > theoretically copy 64 bytes into our destination buffer without a > > NUL-byte. The

Re: KFENCE: included in x86 defconfig?

2024-02-07 Thread Matthieu Baerts
On 07/02/2024 20:04, Borislav Petkov wrote: > On Wed, Feb 07, 2024 at 07:35:53PM +0100, Matthieu Baerts wrote: >> Sorry, I'm sure I understand your suggestion: do you mean not including >> KFENCE in hardening.config either, but in another one? >> >> For the networking tests, we are already merging

Re: KFENCE: included in x86 defconfig?

2024-02-07 Thread Marco Elver
On Wed, 7 Feb 2024 at 23:12, Matthieu Baerts wrote: > > On 07/02/2024 20:04, Borislav Petkov wrote: > > On Wed, Feb 07, 2024 at 07:35:53PM +0100, Matthieu Baerts wrote: > >> Sorry, I'm sure I understand your suggestion: do you mean not including > >> KFENCE in hardening.config either, but in anoth

Re: KFENCE: included in x86 defconfig?

2024-02-07 Thread Jakub Kicinski
On Wed, 7 Feb 2024 20:04:44 +0100 Borislav Petkov wrote: > On Wed, Feb 07, 2024 at 07:35:53PM +0100, Matthieu Baerts wrote: > > Sorry, I'm sure I understand your suggestion: do you mean not including > > KFENCE in hardening.config either, but in another one? > > > > For the networking tests, we ar

Re: KFENCE: included in x86 defconfig?

2024-02-07 Thread Marco Elver
On Thu, 8 Feb 2024 at 00:33, Jakub Kicinski wrote: > > On Wed, 7 Feb 2024 20:04:44 +0100 Borislav Petkov wrote: > > On Wed, Feb 07, 2024 at 07:35:53PM +0100, Matthieu Baerts wrote: > > > Sorry, I'm sure I understand your suggestion: do you mean not including > > > KFENCE in hardening.config either