Re: [RFC] Mitigating unexpected arithmetic overflow

2024-05-17 Thread Jonas Oberhauser
Am 5/8/2024 um 10:07 PM schrieb Linus Torvalds: And no, the answer is ABSOLUTELY NOT to add cognitive load on kernel developers by adding yet more random helper types and/or functions. Just to show an option without "more types and helper functions", one could also instead add a coverage r

Re: [PATCH] ntp: remove accidental integer wrap-around

2024-05-17 Thread Thomas Gleixner
On Thu, May 16 2024 at 16:40, Justin Stitt wrote: > On Tue, May 14, 2024 at 3:38 AM Thomas Gleixner wrote: >> So how can 0xf42400 + 50/1000 overflow in the first place? >> >> It can't unless time_maxerror is somehow initialized to a bogus >> value and indeed it is: >> >> process_adjtimex_modes

Re: [PATCH 05/12] dmaengine: Add STM32 DMA3 support

2024-05-17 Thread Amelie Delaunay
On 5/16/24 19:09, Frank Li wrote: On Thu, May 16, 2024 at 05:25:58PM +0200, Amelie Delaunay wrote: On 5/15/24 20:56, Frank Li wrote: On Tue, Apr 23, 2024 at 02:32:55PM +0200, Amelie Delaunay wrote: STM32 DMA3 driver supports the 3 hardware configurations of the STM32 DMA3 controller: ... +

[PATCH v2] wifi: mac80211: Avoid address calculations via out of bounds array indexing

2024-05-17 Thread Kenton Groombridge
req->n_channels must be set before req->channels[] can be used. This patch fixes one of the issues encountered in [1]. [ 83.964252] [ cut here ] [ 83.964255] UBSAN: array-index-out-of-bounds in net/mac80211/scan.c:364:4 [ 83.964258] index 0 is out of range for type '

Re: [PATCH 05/12] dmaengine: Add STM32 DMA3 support

2024-05-17 Thread Frank Li
On Fri, May 17, 2024 at 11:42:17AM +0200, Amelie Delaunay wrote: > On 5/16/24 19:09, Frank Li wrote: > > On Thu, May 16, 2024 at 05:25:58PM +0200, Amelie Delaunay wrote: > > > On 5/15/24 20:56, Frank Li wrote: > > > > On Tue, Apr 23, 2024 at 02:32:55PM +0200, Amelie Delaunay wrote: > > > > > STM32

[PATCH 2/2] wifi: mac80211: fix UBSAN noise in ieee80211_prep_hw_scan()

2024-05-17 Thread Dmitry Antipov
When testing the previous patch with CONFIG_UBSAN_BOUNDS, I've noticed the following: UBSAN: array-index-out-of-bounds in net/mac80211/scan.c:372:4 index 0 is out of range for type 'struct ieee80211_channel *[]' CPU: 0 PID: 1435 Comm: wpa_supplicant Not tainted 6.9.0+ #1 Hardware name: LENOVO 20UN

[PATCH 1/2] wifi: cfg80211: use __counted_by where appropriate

2024-05-17 Thread Dmitry Antipov
Annotate 'sub_specs' of 'struct cfg80211_sar_specs', 'channels' of 'struct cfg80211_sched_scan_request', 'channels' of 'struct cfg80211_wowlan_nd_match', and 'matches' of 'struct cfg80211_wowlan_nd_info' with '__counted_by' attribute. Briefly tested with clang 18.1.1 and CONFIG_UBSAN_BOUNDS running

[PATCH v3 0/2] tty: rfcomm: refactor rfcomm_get_dev_list() function

2024-05-17 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 "dl" variable is a pointer to "struct rfcomm_dev_list_req" and this structure ends in a flexible array: struct rfcomm_dev_list_req { [...] struct rf

[PATCH v3 1/2] tty: rfcomm: prefer struct_size over open coded arithmetic

2024-05-17 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 "dl" variable is a pointer to "struct rfcomm_dev_list_req" and this structure ends in a flexible array: struct rfcomm_dev_list_req { [...] struct rf

[PATCH v3 2/2] tty: rfcomm: prefer array indexing over pointer arithmetic

2024-05-17 Thread Erick Archer
Refactor the list_for_each_entry() loop of rfcomm_get_dev_list() function to use array indexing instead of pointer arithmetic. This way, the code is more readable and idiomatic. Reviewed-by: Kees Cook Signed-off-by: Erick Archer --- net/bluetooth/rfcomm/tty.c | 12 ++-- 1 file changed,

Re: [PATCH] arm64: smp: smp_send_stop() and crash_smp_send_stop() should try non-NMI first

2024-05-17 Thread Doug Anderson
Hi, On Fri, Apr 12, 2024 at 6:55 AM Will Deacon wrote: > > Hi Doug, > > I'm doing some inbox Spring cleaning! No worries. I got your reply while I was on a bunch of business travel and finally cleared stuff out enough to take a look again. ;-) > On Thu, Dec 07, 2023 at 05:02:56PM -0800, Dougla

Re: [PATCH] arm64: smp: smp_send_stop() and crash_smp_send_stop() should try non-NMI first

2024-05-17 Thread Doug Anderson
Hi, On Thu, Dec 7, 2023 at 5:03 PM Douglas Anderson wrote: > > When testing hard lockup handling on my sc7180-trogdor-lazor device > with pseudo-NMI enabled, with serial console enabled and with kgdb > disabled, I found that the stack crawls printed to the serial console > ended up as a jumbled m

[PATCH v2] ntp: remove accidental integer wrap-around

2024-05-17 Thread Justin Stitt
Using syzkaller alongside the newly reintroduced signed integer overflow sanitizer spits out this report: UBSAN: signed-integer-overflow in ../kernel/time/ntp.c:461:16 9223372036854775807 + 500 cannot be represented in type 'long' Call Trace: dump_stack_lvl+0x93/0xd0 handle_overflow+0x171/0x1b

Re: [PATCH v3] fs: fix unintentional arithmetic wraparound in offset calculation

2024-05-17 Thread Justin Stitt
Hi, On Thu, May 16, 2024 at 6:13 PM Matthew Wilcox wrote: > > On Fri, May 17, 2024 at 12:29:06AM +, Justin Stitt wrote: > > When running syzkaller with the newly reintroduced signed integer > > overflow sanitizer we encounter this report: > > why do you keep saying it's unintentional? it's c

Re: [PATCH v2] wifi: mac80211: Avoid address calculations via out of bounds array indexing

2024-05-17 Thread Simon Horman
On Fri, May 17, 2024 at 10:54:20AM -0400, Kenton Groombridge wrote: > req->n_channels must be set before req->channels[] can be used. > > This patch fixes one of the issues encountered in [1]. > > [ 83.964252] [ cut here ] > [ 83.964255] UBSAN: array-index-out-of-bound

Re: [RFC] Mitigating unexpected arithmetic overflow

2024-05-17 Thread Kees Cook
On Thu, May 16, 2024 at 02:51:34PM -0600, Theodore Ts'o wrote: > On Thu, May 16, 2024 at 12:48:47PM -0700, Justin Stitt wrote: > > > > It is incredibly important that the exact opposite approach is taken; > > we need to be annotating (or adding type qualifiers to) the _expected_ > > overflow cases

Re: [PATCH v3] fs: fix unintentional arithmetic wraparound in offset calculation

2024-05-17 Thread Kees Cook
On Fri, May 17, 2024 at 02:26:47AM +0100, Al Viro wrote: > On Fri, May 17, 2024 at 02:13:22AM +0100, Matthew Wilcox wrote: > > On Fri, May 17, 2024 at 12:29:06AM +, Justin Stitt wrote: > > > When running syzkaller with the newly reintroduced signed integer > > > overflow sanitizer we encounter

Re: [RFC] Mitigating unexpected arithmetic overflow

2024-05-17 Thread Fangrui Song
On Thu, May 16, 2024 at 12:49 PM Justin Stitt wrote: > > Hi, > > On Thu, May 16, 2024 at 7:09 AM Peter Zijlstra wrote: > > > > On Thu, May 16, 2024 at 06:30:32AM -0700, Kees Cook wrote: > > > > > > I am a broken record. :) This is _not_ about undefined behavior. > > > > And yet you introduced CON

Re: [PATCH v2] ntp: safeguard against time_constant overflow case

2024-05-17 Thread Thomas Gleixner
Justin! On Fri, May 17 2024 at 00:47, Justin Stitt wrote: > if (txc->modes & ADJ_TIMECONST) { > - time_constant = txc->constant; > - if (!(time_status & STA_NANO)) > + if (!(time_status & STA_NANO) && time_constant < MAXTC) > time_con

Re: [RFC] Mitigating unexpected arithmetic overflow

2024-05-17 Thread Theodore Ts'o
On Fri, May 17, 2024 at 02:15:01PM -0700, Kees Cook wrote: > On Thu, May 16, 2024 at 02:51:34PM -0600, Theodore Ts'o wrote: > > On Thu, May 16, 2024 at 12:48:47PM -0700, Justin Stitt wrote: > > > > > > It is incredibly important that the exact opposite approach is taken; > > > we need to be annota

Re: [RFC] Mitigating unexpected arithmetic overflow

2024-05-17 Thread Matthew Wilcox
On Wed, May 08, 2024 at 11:11:35PM -0700, Kees Cook wrote: > Or even just simple math between u8s: > > while (xas->xa_offset == 255) { > xas->xa_offset = xas->xa_node->offset - 1; > > Is it expecting to wrap (truncate)? How is it distinguished from > the "num