Re: [PATCH 1/5] chelsio/l2t: Annotate struct l2t_data with __counted_by

2023-09-29 Thread Christophe JAILLET
Le 29/09/2023 à 20:11, Kees Cook a écrit : Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_F

Re: [PATCH] md/md-linear: Annotate struct linear_conf with __counted_by

2023-09-29 Thread Kees Cook
On Fri, Sep 29, 2023 at 04:40:13PM -0700, Song Liu wrote: > On Fri, Sep 29, 2023 at 12:21 PM Kees Cook wrote: > > > > On Fri, 15 Sep 2023 13:03:28 -0700, Kees Cook wrote: > > > Prepare for the coming implementation by GCC and Clang of the __counted_by > > > attribute. Flexible array members annota

Re: [PATCH] md/md-linear: Annotate struct linear_conf with __counted_by

2023-09-29 Thread Song Liu
On Fri, Sep 29, 2023 at 12:21 PM Kees Cook wrote: > > On Fri, 15 Sep 2023 13:03:28 -0700, Kees Cook wrote: > > Prepare for the coming implementation by GCC and Clang of the __counted_by > > attribute. Flexible array members annotated with __counted_by can have > > their accesses bounds-checked at

Re: [PATCH RESEND v5 7/8] arm64: dts: Add DTS for Marvell PXA1908 and samsung,coreprimevelte

2023-09-29 Thread Linus Walleij
On Fri, Sep 29, 2023 at 5:42 PM Duje Mihanović wrote: > Add DTS for Marvell PXA1908 SoC and Samsung Galaxy Core Prime Value > Edition LTE, a smartphone based on said SoC. > > Signed-off-by: Duje Mihanović (...) > +&pmx { > + pinctrl-single,gpio-range = <&range 55 55 0>, > +

Re: [PATCH] x86/tdx: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Fri, Sep 29, 2023 at 11:14:14PM +0200, Ingo Molnar wrote: > > * Kees Cook wrote: > > > On Mon, 11 Sep 2023 18:27:25 +, Justin Stitt wrote: > > > `strncpy` is deprecated and we should prefer more robust string apis. > > > > > > In this case, `message.str` is not expected to be NUL-termina

Re: [PATCH RESEND v5 2/8] clk: mmp: Switch to use struct u32_fract instead of custom one

2023-09-29 Thread Linus Walleij
On Fri, Sep 29, 2023 at 5:42 PM Duje Mihanović wrote: > From: Andy Shevchenko > > The struct mmp_clk_factor_tbl repeats the generic struct u32_fract. > Kill the custom one and use the generic one instead. > > Signed-off-by: Andy Shevchenko > Tested-by: Duje Mihanović > Signed-off-by: Duje Miha

Re: [PATCH] x86/tdx: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Fri, Sep 29, 2023 at 02:27:39PM -0700, Dave Hansen wrote: > On 9/29/23 11:33, Kees Cook wrote: > > On Mon, 11 Sep 2023 18:27:25 +, Justin Stitt wrote: > >> `strncpy` is deprecated and we should prefer more robust string apis. > >> > >> In this case, `message.str` is not expected to be NUL-te

Re: [PATCH] x86/tdx: refactor deprecated strncpy

2023-09-29 Thread Dave Hansen
On 9/29/23 11:33, Kees Cook wrote: > On Mon, 11 Sep 2023 18:27:25 +, Justin Stitt wrote: >> `strncpy` is deprecated and we should prefer more robust string apis. >> >> In this case, `message.str` is not expected to be NUL-terminated as it >> is simply a buffer of characters residing in a union

Re: [PATCH] x86/tdx: refactor deprecated strncpy

2023-09-29 Thread Ingo Molnar
* Kees Cook wrote: > On Mon, 11 Sep 2023 18:27:25 +, Justin Stitt wrote: > > `strncpy` is deprecated and we should prefer more robust string apis. > > > > In this case, `message.str` is not expected to be NUL-terminated as it > > is simply a buffer of characters residing in a union which a

Re: [PATCH] IB/hfi1: replace deprecated strncpy

2023-09-29 Thread Kees Cook
On Tue, Sep 26, 2023 at 07:56:34AM -0500, Dean Luick wrote: > On 9/23/2023 10:20 PM, Kees Cook wrote: > > On Fri, Sep 22, 2023 at 09:25:39AM -0500, Dean Luick wrote: > >> On 9/22/2023 5:29 AM, Leon Romanovsky wrote: > >>> > >>> On Thu, 21 Sep 2023 07:17:47 +, Justin Stitt wrote: > `strncpy

Re: [PATCH 0/5] chelsio: Annotate structs with __counted_by

2023-09-29 Thread Kees Cook
On Fri, Sep 29, 2023 at 11:11:44AM -0700, Kees Cook wrote: > Hi, > > This annotates several chelsio structures with the coming __counted_by > attribute for bounds checking of flexible arrays at run-time. For more > details, > see commit dd06e72e68bc ("Compiler Attributes: Add __counted_by macro")

Re: [PATCH] isdn: kcapi: replace deprecated strncpy with strscpy_pad

2023-09-29 Thread Kees Cook
On Fri, 22 Sep 2023 11:49:14 +, 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. > > `buf` is used in this context as a data buffer with 64 bytes of memory > to be

Re: [PATCH] isdn: replace deprecated strncpy with strscpy

2023-09-29 Thread Kees Cook
On Fri, 22 Sep 2023 11:58:06 +, 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 `iclock->name` to be NUL-terminated based on its use within > printk:

Re: [PATCH] nfs41: Annotate struct nfs4_file_layout_dsaddr with __counted_by

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 13:14:27 -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexi

Re: [PATCH] NFS/flexfiles: Annotate struct nfs4_ff_layout_segment with __counted_by

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 13:14:39 -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexi

Re: [PATCH] usb: Annotate struct urb_priv with __counted_by

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 12:58:16 -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexi

Re: [PATCH] md/md-linear: Annotate struct linear_conf with __counted_by

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 13:03:28 -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexi

Re: [PATCH] usb: gadget: f_midi: Annotate struct f_midi with __counted_by

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 12:59:39 -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexi

Re: [PATCH] usb: gadget: f_fs: Annotate struct ffs_buffer with __counted_by

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 12:58:49 -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexi

Re: [PATCH] ocfs2: Annotate struct ocfs2_slot_info with __counted_by

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 13:15:23 -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexi

Re: [PATCH] afs: Annotate struct afs_permits with __counted_by

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 13:14:56 -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexi

Re: [PATCH] ceph: Annotate struct ceph_osd_request with __counted_by

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 13:15:17 -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexi

Re: [PATCH] afs: Annotate struct afs_addr_list with __counted_by

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 13:14:49 -0700, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexi

Re: [PATCH][next] ASoC: SOF: ipc4-topology: Use size_add() in call to struct_size()

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 13:09:11 -0600, Gustavo A. R. Silva wrote: > If, for any reason, the open-coded arithmetic causes a wraparound, > the protection that `struct_size()` adds against potential integer > overflows is defeated. Fix this by hardening call to `struct_size()` > with `size_add()`. > >

Re: [PATCH][next] usb: atm: Use size_add() in call to struct_size()

2023-09-29 Thread Kees Cook
On Fri, 15 Sep 2023 13:20:14 -0600, Gustavo A. R. Silva wrote: > If, for any reason, the open-coded arithmetic causes a wraparound, > the protection that `struct_size()` adds against potential integer > overflows is defeated. Fix this by hardening call to `struct_size()` > with `size_add()`. > >

Re: [PATCH v4] EDAC/mc_sysfs: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Mon, 18 Sep 2023 07:47:29 +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We've already calculated bounds, possible truncation with '\0' or '\n' > and manually NUL-terminated. The situation is now just a literal byte > copy from one bu

Re: [PATCH] hwmon: (asus_wmi_sensors) refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Thu, 14 Sep 2023 23:10:34 +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We should prefer more robust and less ambiguous string interfaces. > > A suitable replacement is `strscpy` [2] due to the fact that it > guarantees NUL-terminat

Re: [PATCH v2] hwmon: (ibmpowernv) refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Tue, 19 Sep 2023 05:22:51 +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > A suitable replacement is `memcpy` as we've already precisely calculated > the number of bytes to copy while `buf` has been explicitly > zero-initialized: > |

Re: [PATCH] HID: uhid: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Mon, Sep 18, 2023 at 09:37:53AM +0200, David Rheinsberg wrote: > Hey > > On Fri, Sep 15, 2023, at 10:48 PM, Kees Cook wrote: > > On Fri, Sep 15, 2023 at 09:36:23AM +0200, David Rheinsberg wrote: > >> Hi > >> > >> On Fri, Sep 15, 2023, at 7:13 AM, Kees Cook wrote: > >> >> - /* @hid is zer

Re: [PATCH] auxdisplay: panel: refactor deprecated strncpy

2023-09-29 Thread Miguel Ojeda
On Fri, Sep 29, 2023 at 8:42 PM Kees Cook wrote: > > Applied to for-next/hardening, thanks! Thanks for picking it up! Cheers, Miguel

Re: [PATCH] HID: prodikeys: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Thu, 14 Sep 2023 22:20:55 +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We should prefer more robust and less ambiguous string interfaces. > > A suitable replacement is `strscpy` [2] due to the fact that it guarantees > NUL-terminat

Re: [PATCH] firmware: tegra: bpmp: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Wed, 13 Sep 2023 19:38:44 +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We should prefer more robust and less ambiguous string interfaces. > > It seems like the filename stored at `namevirt` is expected to be > NUL-terminated. > >

Re: [PATCH] cpuidle: dt: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Wed, 13 Sep 2023 00:23:19 +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We should prefer more robust and less ambiguous string interfaces. > > A suitable replacement is `strscpy` [2] due to the fact that it guarantees > NUL-terminat

Re: [PATCH] cpufreq: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Wed, 13 Sep 2023 00:07:21 +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We should prefer more robust and less ambiguous string interfaces. > > Both `policy->last_governor` and `default_governor` are expected to be > NUL-terminated w

Re: [PATCH] bus: fsl-mc: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Tue, 12 Sep 2023 22:52:04 +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We need to prefer more robust and less ambiguous string interfaces. > > `obj_desc->(type|label)` are expected to be NUL-terminated strings as > per "include/lin

Re: [PATCH] auxdisplay: panel: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Mon, 11 Sep 2023 20:51:04 +, Justin Stitt wrote: > `strncpy` is deprecated and as such we should prefer more robust and > less ambiguous interfaces. > > In this case, all of `press_str`, `repeat_str` and `release_str` are > explicitly marked as nonstring: > | struct { /* valid when type

Re: [PATCH] x86/tdx: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Mon, 11 Sep 2023 18:27:25 +, Justin Stitt wrote: > `strncpy` is deprecated and we should prefer more robust string apis. > > In this case, `message.str` is not expected to be NUL-terminated as it > is simply a buffer of characters residing in a union which allows for > named fields represen

Re: [PATCH] um,ethertap: refactor deprecated strncpy

2023-09-29 Thread Kees Cook
On Mon, 11 Sep 2023 17:52:44 +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > `gate_buf` should always be NUL-terminated and does not require > NUL-padding. It is used as a string arg inside an argv array given to > `run_helper()`. Due to

Re: [PATCH][next] net: sched: cls_u32: Fix allocation in u32_init()

2023-09-29 Thread Kees Cook
On Mon, Aug 21, 2023 at 11:48:02AM -0700, Jakub Kicinski wrote: > On Mon, 21 Aug 2023 10:35:29 -0400 Jamal Hadi Salim wrote: > > > Sure, but why are you doing this? And how do you know the change is > > > correct? > > > > > > There are 2 other instances where we allocate 1 entry or +1 entry. > > >

[PATCH 0/5] chelsio: Annotate structs with __counted_by

2023-09-29 Thread Kees Cook
Hi, This annotates several chelsio structures with the coming __counted_by attribute for bounds checking of flexible arrays at run-time. For more details, see commit dd06e72e68bc ("Compiler Attributes: Add __counted_by macro"). Thanks! -Kees Kees Cook (5): chelsio/l2t: Annotate struct l2t_dat

[PATCH 2/5] cxgb4: Annotate struct clip_tbl with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 3/5] cxgb4: Annotate struct cxgb4_tc_u32_table with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 5/5] cxgb4: Annotate struct smt_data with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 4/5] cxgb4: Annotate struct sched_table with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 1/5] chelsio/l2t: Annotate struct l2t_data with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 5/5] mlxsw: spectrum_span: Annotate struct mlxsw_sp_span with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 3/5] mlxsw: spectrum: Annotate struct mlxsw_sp_counter_pool with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 4/5] mlxsw: spectrum_router: Annotate struct mlxsw_sp_nexthop_group_info with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 2/5] mlxsw: core: Annotate struct mlxsw_env with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 1/5] mlxsw: Annotate struct mlxsw_linecards with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 0/5] mlxsw: Annotate structs with __counted_by

2023-09-29 Thread Kees Cook
Hi, This annotates several mlxsw structures with the coming __counted_by attribute for bounds checking of flexible arrays at run-time. For more details, see commit dd06e72e68bc ("Compiler Attributes: Add __counted_by macro"). Thanks! -Kees Kees Cook (5): mlxsw: Annotate struct mlxsw_linecards

[PATCH 1/7] RDMA: Annotate struct rdma_hw_stats with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 3/7] RDMA/usnic: Annotate struct usnic_uiom_chunk with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 0/7] RDMA: Annotate structs with __counted_by

2023-09-29 Thread Kees Cook
Hi, This annotates several structures with the coming __counted_by attribute for bounds checking of flexible arrays at run-time. For more details, see commit dd06e72e68bc ("Compiler Attributes: Add __counted_by macro"). Thanks! -Kees Kees Cook (7): RDMA: Annotate struct rdma_hw_stats with __c

[PATCH 7/7] IB/hfi1: Annotate struct tid_rb_node with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 5/7] IB/srp: Annotate struct srp_fr_pool with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 6/7] IB/mthca: Annotate struct mthca_icm_table with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 2/7] RDMA/core: Annotate struct ib_pkey_cache with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

[PATCH 4/7] RDMA/siw: Annotate struct siw_pbl with __counted_by

2023-09-29 Thread Kees Cook
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct

Re: [PATCH][next] media: usb: siano: Fix undefined behavior bug in struct smsusb_urb_t

2023-09-29 Thread Jann Horn
On Fri, Sep 29, 2023 at 7:29 PM Kees Cook wrote: > On Fri, Sep 29, 2023 at 05:42:11PM +0200, Gustavo A. R. Silva wrote: > > `struct urb` is a flexible structure, which means that it contains a > > flexible-array member at the bottom. This could potentially lead to an > > overwrite of the object `w

Re: [PATCH] mm: Fix vm_brk_flags() to not bail out while holding lock

2023-09-29 Thread Liam R. Howlett
* Kees Cook [230929 13:19]: > From: Sebastian Ott > > Calling vm_brk_flags() with flags set other than VM_EXEC > will exit the function without releasing the mmap_write_lock. > > Just do the sanity check before the lock is acquired. This > doesn't fix an actual issue since no caller sets a flag

Re: [PATCH][next] media: usb: siano: Fix undefined behavior bug in struct smsusb_urb_t

2023-09-29 Thread Kees Cook
On Fri, Sep 29, 2023 at 05:42:11PM +0200, Gustavo A. R. Silva wrote: > `struct urb` is a flexible structure, which means that it contains a > flexible-array member at the bottom. This could potentially lead to an > overwrite of the object `wq` at run-time with the contents of `urb`. > > Fix this b

Re: [PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct midi_runtime

2023-09-29 Thread Kees Cook
On Fri, Sep 29, 2023 at 06:06:32PM +0200, Gustavo A. R. Silva wrote: > `struct urb` is a flexible structure, which means that it contains a > flexible-array member at the bottom. This could potentially lead to an > overwrite of the objects following `out_urb` in `struct midi_runtime`, > among them

Re: [PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct comm_runtime

2023-09-29 Thread Kees Cook
On Fri, Sep 29, 2023 at 05:59:22PM +0200, Gustavo A. R. Silva wrote: > `struct urb` is a flexible structure, which means that it contains a > flexible-array member at the bottom. This could potentially lead to an > overwrite of the objects following `receiver` in `struct comm_runtime`, > among them

[PATCH] mm: Fix vm_brk_flags() to not bail out while holding lock

2023-09-29 Thread Kees Cook
From: Sebastian Ott Calling vm_brk_flags() with flags set other than VM_EXEC will exit the function without releasing the mmap_write_lock. Just do the sanity check before the lock is acquired. This doesn't fix an actual issue since no caller sets a flag other than VM_EXEC. Cc: Andrew Morton Cc

Re: [PATCH v4 0/6] binfmt_elf: Support segments with 0 filesz and misaligned starts

2023-09-29 Thread Kees Cook
On Fri, Sep 29, 2023 at 01:33:50PM +0200, Sebastian Ott wrote: > Hello Kees, > > On Thu, 28 Sep 2023, Kees Cook wrote: > > This is the continuation of the work Eric started for handling > > "p_memsz > p_filesz" in arbitrary segments (rather than just the last, > > BSS, segment). I've added the sug

Re: [PATCH v4 0/6] binfmt_elf: Support segments with 0 filesz and misaligned starts

2023-09-29 Thread Kees Cook
On Fri, Sep 29, 2023 at 12:58:18PM +0100, Pedro Falcato wrote: > So on that end, you can take my > > Tested-by: Pedro Falcato Thanks! -- Kees Cook

Re: [PATCH v4 4/6] binfmt_elf: Use elf_load() for library

2023-09-29 Thread Kees Cook
On Fri, Sep 29, 2023 at 01:12:13PM +0100, Pedro Falcato wrote: > On Fri, Sep 29, 2023 at 4:24 AM Kees Cook wrote: > > > > While load_elf_library() is a libc5-ism, we can still replace most of > > its contents with elf_load() as well, further simplifying the code. > > While I understand you want t

Re: [PATCH][next] media: usb: siano: Fix undefined behavior bug in struct smsusb_urb_t

2023-09-29 Thread Jann Horn
On Fri, Sep 29, 2023 at 5:42 PM Gustavo A. R. Silva wrote: > `struct urb` is a flexible structure, which means that it contains a > flexible-array member at the bottom. This could potentially lead to an > overwrite of the object `wq` at run-time with the contents of `urb`. > > Fix this by placing

[PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct midi_runtime

2023-09-29 Thread Gustavo A. R. Silva
`struct urb` is a flexible structure, which means that it contains a flexible-array member at the bottom. This could potentially lead to an overwrite of the objects following `out_urb` in `struct midi_runtime`, among them a function pointer. Fix this by placing the declaration of object `out_urb`

[PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct comm_runtime

2023-09-29 Thread Gustavo A. R. Silva
`struct urb` is a flexible structure, which means that it contains a flexible-array member at the bottom. This could potentially lead to an overwrite of the objects following `receiver` in `struct comm_runtime`, among them some function pointers. Fix this by placing the declaration of object `rece

[PATCH RESEND v5 4/8] clk: mmp: Add Marvell PXA1908 clock driver

2023-09-29 Thread Duje Mihanović
Add driver for Marvell PXA1908 clock controller blocks. The SoC has numerous clock controller blocks, currently supporting APBC, APBCP, MPMU and APMU. Signed-off-by: Duje Mihanović --- drivers/clk/mmp/Makefile | 2 +- drivers/clk/mmp/clk-of-pxa1908.c | 328 +

[PATCH RESEND v5 0/8] Initial Marvell PXA1908 support

2023-09-29 Thread Duje Mihanović
Hello, This series adds initial support for the Marvell PXA1908 SoC and "samsung,coreprimevelte", a smartphone using the SoC. USB works and the phone can boot a rootfs from an SD card, but there are some warnings in the dmesg: During SMP initialization: [0.006519] CPU features: SANITY CHECK:

[PATCH RESEND v5 2/8] clk: mmp: Switch to use struct u32_fract instead of custom one

2023-09-29 Thread Duje Mihanović
From: Andy Shevchenko The struct mmp_clk_factor_tbl repeats the generic struct u32_fract. Kill the custom one and use the generic one instead. Signed-off-by: Andy Shevchenko Tested-by: Duje Mihanović Signed-off-by: Duje Mihanović --- drivers/clk/mmp/clk-frac.c | 57

[PATCH RESEND v5 7/8] arm64: dts: Add DTS for Marvell PXA1908 and samsung,coreprimevelte

2023-09-29 Thread Duje Mihanović
Add DTS for Marvell PXA1908 SoC and Samsung Galaxy Core Prime Value Edition LTE, a smartphone based on said SoC. Signed-off-by: Duje Mihanović --- arch/arm64/boot/dts/marvell/Makefile | 3 + .../dts/marvell/pxa1908-samsung-coreprimevelte.dts | 333 + arch/arm6

[PATCH RESEND v5 5/8] dt-bindings: marvell: Document PXA1908 SoC

2023-09-29 Thread Duje Mihanović
Add dt binding for the Marvell PXA1908 SoC. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Duje Mihanović --- Documentation/devicetree/bindings/arm/mrvl/mrvl.yaml | 5 + 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/mrvl/mrvl.yaml b/Documentation/devi

[PATCH RESEND v5 3/8] dt-bindings: clock: Add Marvell PXA1908 clock bindings

2023-09-29 Thread Duje Mihanović
Add dt bindings and documentation for the Marvell PXA1908 clock controller. Signed-off-by: Duje Mihanović --- .../devicetree/bindings/clock/marvell,pxa1908.yaml | 48 include/dt-bindings/clock/marvell,pxa1908.h| 88 ++ 2 files changed, 136 insertions(+)

[PATCH RESEND v5 1/8] gpio: pxa: disable pinctrl calls for MMP_GPIO

2023-09-29 Thread Duje Mihanović
Similarly to PXA3xx and MMP2, pinctrl-single isn't capable of setting pin direction on MMP either. Fixes: a770d946371e ("gpio: pxa: add pin control gpio direction and request") Signed-off-by: Duje Mihanović Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-pxa.c | 1 + 1 file changed, 1 insert

[PATCH RESEND v5 8/8] MAINTAINERS: add myself as Marvell PXA1908 maintainer

2023-09-29 Thread Duje Mihanović
Add myself as the maintainer for Marvell PXA1908 SoC support. Signed-off-by: Duje Mihanović --- MAINTAINERS | 9 + 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 0f966f05fb0d..6f5233f3904b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2299,6 +2299,15 @@ F:

[PATCH RESEND v5 6/8] arm64: Kconfig.platforms: Add config for Marvell PXA1908 platform

2023-09-29 Thread Duje Mihanović
Add ARCH_MMP configuration option for Marvell PXA1908 SoC. Signed-off-by: Duje Mihanović --- arch/arm64/Kconfig.platforms | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms index 6069120199bb..b417cae42c84 100644 --- a/arc

Re: [PATCH v4 0/6] binfmt_elf: Support segments with 0 filesz and misaligned starts

2023-09-29 Thread Eric W. Biederman
Sebastian Ott writes: > Hello Kees, > > On Thu, 28 Sep 2023, Kees Cook wrote: >> This is the continuation of the work Eric started for handling >> "p_memsz > p_filesz" in arbitrary segments (rather than just the last, >> BSS, segment). I've added the suggested changes: >> >> - drop unused "elf_bs

[PATCH][next] media: usb: siano: Fix undefined behavior bug in struct smsusb_urb_t

2023-09-29 Thread Gustavo A. R. Silva
`struct urb` is a flexible structure, which means that it contains a flexible-array member at the bottom. This could potentially lead to an overwrite of the object `wq` at run-time with the contents of `urb`. Fix this by placing object `urb` at the end of `struct smsusb_urb_t`. Fixes: dd47fbd40e6

Re: [PATCH v4 0/6] binfmt_elf: Support segments with 0 filesz and misaligned starts

2023-09-29 Thread Eric W. Biederman
Pedro Falcato writes: > On Fri, Sep 29, 2023 at 4:24 AM Kees Cook wrote: >> >> Hi, >> >> This is the continuation of the work Eric started for handling >> "p_memsz > p_filesz" in arbitrary segments (rather than just the last, >> BSS, segment). I've added the suggested changes: >> >> - drop unus

Re: [PATCH v4 4/6] binfmt_elf: Use elf_load() for library

2023-09-29 Thread Eric W. Biederman
Pedro Falcato writes: > On Fri, Sep 29, 2023 at 4:24 AM Kees Cook wrote: >> >> While load_elf_library() is a libc5-ism, we can still replace most of >> its contents with elf_load() as well, further simplifying the code. > > While I understand you want to break as little as possible (as the ELF >

Re: [PATCH v4 1/6] binfmt_elf: Support segments with 0 filesz and misaligned starts

2023-09-29 Thread Eric W. Biederman
Pedro Falcato writes: > On Fri, Sep 29, 2023 at 4:24 AM Kees Cook wrote: >> >> From: "Eric W. Biederman" >> >> Implement a helper elf_load() that wraps elf_map() and performs all >> of the necessary work to ensure that when "memsz > filesz" the bytes >> described by "memsz > filesz" are zeroed.

Re: [PATCH v4 4/6] binfmt_elf: Use elf_load() for library

2023-09-29 Thread Pedro Falcato
On Fri, Sep 29, 2023 at 4:24 AM Kees Cook wrote: > > While load_elf_library() is a libc5-ism, we can still replace most of > its contents with elf_load() as well, further simplifying the code. While I understand you want to break as little as possible (as the ELF loader maintainer), I'm wondering

Re: [PATCH v4 1/6] binfmt_elf: Support segments with 0 filesz and misaligned starts

2023-09-29 Thread Pedro Falcato
On Fri, Sep 29, 2023 at 4:24 AM Kees Cook wrote: > > From: "Eric W. Biederman" > > Implement a helper elf_load() that wraps elf_map() and performs all > of the necessary work to ensure that when "memsz > filesz" the bytes > described by "memsz > filesz" are zeroed. > > An outstanding issue is if

Re: [PATCH v4 0/6] binfmt_elf: Support segments with 0 filesz and misaligned starts

2023-09-29 Thread Pedro Falcato
On Fri, Sep 29, 2023 at 4:24 AM Kees Cook wrote: > > Hi, > > This is the continuation of the work Eric started for handling > "p_memsz > p_filesz" in arbitrary segments (rather than just the last, > BSS, segment). I've added the suggested changes: > > - drop unused "elf_bss" variable > - refacto

Re: [PATCH v4 0/6] binfmt_elf: Support segments with 0 filesz and misaligned starts

2023-09-29 Thread Sebastian Ott
Hello Kees, On Thu, 28 Sep 2023, Kees Cook wrote: This is the continuation of the work Eric started for handling "p_memsz > p_filesz" in arbitrary segments (rather than just the last, BSS, segment). I've added the suggested changes: - drop unused "elf_bss" variable - refactor load_elf_interp()