Re: [PATCH 4/6] mfd: max77759: add Maxim MAX77759 core mfd driver

2025-02-24 Thread Christophe JAILLET
Le 24/02/2025 à 11:28, André Draszik a écrit : The Maxim MAX77759 is a companion Power Management IC for USB Type-C applications with Battery Charger, Fuel Gauge, temperature sensors, USB Type-C Port Controller (TCPC), NVMEM, and additional GPIO interfaces. Fuel Gauge and TCPC have separate and

Re: [PATCH] wifi: iwlwifi: mvm: Fix __counted_by usage in cfg80211_wowlan_nd_*

2024-06-20 Thread Christophe JAILLET
Le 20/06/2024 à 20:08, Gustavo A. R. Silva a écrit : On 6/20/24 12:02, Gustavo A. R. Silva wrote: My understanding is that 'match', is allocated by :  match = kzalloc(struct_size(match, channels, n_channels), GFP_KERNEL); So match->n_channels is *0* when iwl_mvm_query_set_freqs() is c

Re: [PATCH] wifi: iwlwifi: mvm: Fix __counted_by usage in cfg80211_wowlan_nd_*

2024-06-20 Thread Christophe JAILLET
Le 19/06/2024 à 23:12, Kees Cook a écrit : Both struct cfg80211_wowlan_nd_match and struct cfg80211_wowlan_nd_info pre-allocate space for channels and matches, but then may end up using fewer that the full allocation. Shrink the associated counter (n_channels and n_matches) after counting the res

Re: [PATCH v3 2/3] leds: sy7802: Add support for Silergy SY7802 flash LED controller

2024-06-13 Thread Christophe JAILLET
Le 12/06/2024 à 23:01, André Apitzsch via B4 Relay a écrit : From: André Apitzsch The SY7802 is a current-regulated charge pump which can regulate two current levels for Flash and Torch modes. It is a high-current synchronous boost converter with 2-channel high side current sources. Each chann

[PATCH 2/2 net-next] libceph: Use __counted_by() in struct ceph_snap_context

2024-05-19 Thread Christophe JAILLET
Annotate the 'snaps' flexible array in "struct ceph_snap_context" with __counted_by() so that additional checks can be made, if enabled. Signed-off-by: Christophe JAILLET --- Compile tested only --- include/linux/ceph/libceph.h | 2 +- 1 file changed, 1 insertion(+), 1 delet

[PATCH] RDMA/irdma: Annotate flexible array with __counted_by() in struct irdma_qvlist_info

2024-05-19 Thread Christophe JAILLET
'num_vectors' is used to count the number of elements in the 'qv_info' flexible array in "struct irdma_qvlist_info". So annotate it with __counted_by() to make it explicit and enable some additional checks. This allocation is done in irdma_save_msix_info(). Sig

Re: [PATCH v2] perf/ring_buffer: Prefer struct_size over open coded arithmetic

2024-05-06 Thread Christophe JAILLET
Le 06/05/2024 à 18:23, Kees Cook a écrit : On Sun, May 05, 2024 at 07:31:24PM +0200, Erick Archer wrote: On Sun, May 05, 2024 at 05:24:55PM +0200, Christophe JAILLET wrote: Le 05/05/2024 à 16:15, Erick Archer a écrit : diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c

Re: [PATCH v2] perf/ring_buffer: Prefer struct_size over open coded arithmetic

2024-05-05 Thread Christophe JAILLET
Le 05/05/2024 à 16:15, Erick Archer a écrit : This is an effort to get rid of all multiplications from allocation functions in order to prevent integer overflows [1][2]. As the "rb" variable is a pointer to "struct perf_buffer" and this structure ends in a flexible array: struct perf_buffer {

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

2024-05-04 Thread Christophe JAILLET
Le 23/04/2024 à 14:32, Amelie Delaunay a écrit : STM32 DMA3 driver supports the 3 hardware configurations of the STM32 DMA3 controller: - LPDMA (Low Power): 4 channels, no FIFO - GPDMA (General Purpose): 16 channels, FIFO from 8 to 32 bytes - HPDMA (High Performance): 16 channels, FIFO from 8 to

Re: [PATCH v2 2/3] leds: sy7802: Add support for Silergy SY7802 flash LED controller

2024-05-02 Thread Christophe JAILLET
Le 01/04/2024 à 23:23, André Apitzsch via B4 Relay a écrit : From: André Apitzsch Add support for SY7802 flash LED controller. It can support up to 1.8A flash current. Signed-off-by: André Apitzsch --- drivers/leds/flash/Kconfig | 11 + drivers/leds/flash/Makefile | 1 + dri

Re: [PATCH] printk: cleanup deprecated uses of strncpy/strcpy

2024-05-01 Thread Christophe JAILLET
Le 02/05/2024 à 01:18, Justin Stitt a écrit : On Wed, May 1, 2024 at 2:39 PM Christophe JAILLET wrote: Hi, Nit: The { } around each branch can now also be removed. There was one line before and there's one line now. In the block after the "else", yes, but now the block af

Re: [PATCH] printk: cleanup deprecated uses of strncpy/strcpy

2024-05-01 Thread Christophe JAILLET
Le 30/04/2024 à 01:06, Justin Stitt a écrit : Cleanup some deprecated uses of strncpy() and strcpy() [1]. There doesn't seem to be any bugs with the current code but the readability of this code could benefit from a quick makeover while removing some deprecated stuff as a benefit. The most inte

Re: [PATCH v3] perf/x86/amd/uncore: Use kcalloc*() instead of kzalloc*()

2024-04-29 Thread Christophe JAILLET
Le 27/04/2024 à 18:45, Erick Archer a écrit : This is an effort to get rid of all multiplications from allocation functions in order to prevent integer overflows [1]. Here the multiplication is obviously safe. However, using kcalloc*() is more appropriate [2] and improves readability. This patch

Re: [PATCH v5] checkpatch: add check for snprintf to scnprintf

2024-04-23 Thread Christophe JAILLET
Le 22/04/2024 à 23:33, Justin Stitt a écrit : I am going to quote Lee Jones who has been doing some snprintf -> scnprintf refactorings: "There is a general misunderstanding amongst engineers that {v}snprintf() returns the length of the data *actually* encoded into the destination array. However

Re: [PATCH v4] checkpatch: add check for snprintf to scnprintf

2024-04-11 Thread Christophe JAILLET
Le 08/04/2024 à 22:53, Justin Stitt a écrit : I am going to quote Lee Jones who has been doing some snprintf -> scnprintf refactorings: "There is a general misunderstanding amongst engineers that {v}snprintf() returns the length of the data *actually* encoded into the destination array. However

[PATCH] pstore/zone: Don't clear memory twice

2024-03-09 Thread Christophe JAILLET
There is no need to call memset(..., 0, ...) on memory allocated by kcalloc(). It is already zeroed. Remove the redundant call. Signed-off-by: Christophe JAILLET --- fs/pstore/zone.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/pstore/zone.c b/fs/pstore/zone.c index abca117725c8

[PATCH] md/md-multipath: Convert "struct mpconf" to flexible array

2023-12-03 Thread Christophe JAILLET
ted_by() for additional safety Signed-off-by: Christophe JAILLET --- On my x86_64 system, with configured with allmodconfig, I have: Before the change: = struct mpconf { struct mddev * mddev;/* 0 8 */ struct multipath_info *

Re: [PATCH v2 3/3] kernfs: Convert kernfs_path_from_node_locked() from strlcpy() to strscpy()

2023-11-30 Thread Christophe JAILLET
Le 30/11/2023 à 21:12, Kees Cook a écrit : One of the last remaining users of strlcpy() in the kernel is kernfs_path_from_node_locked(), which passes back the problematic "length we _would_ have copied" return value to indicate truncation. Convert the chain of all callers to use the negative ret

[PATCH 1/2] mux: Turn 'mux' into a flexible array in 'struct mux_chip'

2023-11-26 Thread Christophe JAILLET
w possible to use __counted_by() and struct_size() for additional safety. The address for the 'priv' memory is computed with mux_chip_priv(). It should work as good with a flexible array. Signed-off-by: Christophe JAILLET --- The struct_size() goodies only work if sizeof_priv is 0. Ad

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-11-05 Thread Christophe JAILLET
Le 01/10/2023 à 23:22, Kees Cook a écrit : On Sun, Oct 01, 2023 at 02:05:46PM -0700, Kees Cook wrote: On Sun, Oct 01, 2023 at 09:14:02PM +0200, Julia Lawall wrote: Kees, You can try the following. Cool! Yeah, this finds the example: drivers/comedi/drivers/rti800.c:74: struct comedi_lrange:

[PATCH net] net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show()

2023-10-21 Thread Christophe JAILLET
array. In order to fix it, use snprintf() instead. Fixes: 7302b9d90117 ("ieee802154/adf7242: Driver for ADF7242 MAC IEEE802154") Signed-off-by: Christophe JAILLET --- drivers/net/ieee802154/adf7242.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ie

[PATCH v2] EDAC/thunderx: Fix some potential buffer overflow in thunderx_ocx_com_threaded_isr()

2023-10-21 Thread Christophe JAILLET
396f932 ("EDAC, thunderx: Add Cavium ThunderX EDAC driver") Signed-off-by: Christophe JAILLET --- This is cross-compile tested only. Review with care. v2: remove some other erroneous usage of strncat() --- drivers/edac/thunderx_edac.c | 44 1 f

[PATCH] EDAC/thunderx: Fix some potential buffer overflow in thunderx_ocx_com_threaded_isr()

2023-10-21 Thread Christophe JAILLET
396f932 ("EDAC, thunderx: Add Cavium ThunderX EDAC driver") Signed-off-by: Christophe JAILLET --- This is cross-compile tested only. Review with care. --- drivers/edac/thunderx_edac.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drive

Re: [PATCH v5 4/8] soc/tegra: fuse: Add tegra_acpi_init_apbmisc()

2023-10-15 Thread Christophe JAILLET
Le 16/10/2023 à 07:34, Kartik a écrit : In preparation to ACPI support in Tegra fuse driver add function tegra_acpi_init_apbmisc() to initialize tegra-apbmisc driver. Also, document the reason of calling tegra_init_apbmisc() at early init. Note that function tegra_acpi_init_apbmisc() is not plac

Re: [PATCH v2 2/2] net: openvswitch: Annotate struct mask_array with __counted_by

2023-10-15 Thread Christophe JAILLET
Le 15/10/2023 à 06:53, Julia Lawall a écrit : On Sat, 14 Oct 2023, Kees Cook wrote: On Sat, Oct 14, 2023 at 08:34:53AM +0200, Christophe JAILLET wrote: Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by

[PATCH v2 2/2] net: openvswitch: Annotate struct mask_array with __counted_by

2023-10-13 Thread Christophe JAILLET
functions). Signed-off-by: Christophe JAILLET --- v2: Fix the subject [Ilya Maximets] fix the field name used with __counted_by [Ilya Maximets] v1: https://lore.kernel.org/all/f66ddcf1ef9328f10292ea75a17b584359b6cde3.1696156198.git.christophe.jail...@wanadoo.fr/ This patch is part of a work

Re: [ovs-dev] [PATCH net-next 2/2] net: openvswitch: Annotate struct mask_array with __counted_byUse struct_size()

2023-10-09 Thread Christophe JAILLET
Le 02/10/2023 à 18:51, Ilya Maximets a écrit : On 10/1/23 13:07, Christophe JAILLET 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

[PATCH] VMCI: Annotate struct vmci_handle_arr with __counted_by

2023-10-07 Thread Christophe JAILLET
functions). Signed-off-by: Christophe JAILLET --- This patch is part of a work done in parallel of what is currently worked on by Kees Cook. My patches are only related to corner cases that do NOT match the semantic of his Coccinelle script[1]. In this case, something similar to struct_size() is

[PATCH 2/2] dmaengine: pxa_dma: Annotate struct pxad_desc_sw with __counted_by

2023-10-07 Thread Christophe JAILLET
dma_pool_alloc() call. Signed-off-by: Christophe JAILLET --- This patch is part of a work done in parallel of what is currently worked on by Kees Cook. My patches are only related to corner cases that do NOT match the semantic of his Coccinelle script[1]. [1] https://github.com/kees/kernel-tools/blob

[PATCH 1/2] dmaengine: pxa_dma: Remove an erroneous BUG_ON() in pxad_free_desc()

2023-10-07 Thread Christophe JAILLET
e for loop, i is -1 and the loop will not be executed. (both i and sw_desc->nb_desc are 'int') Fixes: a57e16cf0333 ("dmaengine: pxa: add pxa dmaengine driver") Signed-off-by: Christophe JAILLET --- drivers/dma/pxa_dma.c | 1 - 1 file changed, 1 deletion(-) diff --gi

[PATCH net-next 2/2] net: openvswitch: Annotate struct mask_array with __counted_byUse struct_size()

2023-10-01 Thread Christophe JAILLET
functions). Signed-off-by: Christophe JAILLET --- This patch is part of a work done in parallel of what is currently worked on by Kees Cook. My patches are only related to corner cases that do NOT match the semantic of his Coccinelle script[1]. In this case, in tbl_mask_array_alloc(), several things

[PATCH net-next 1/2] net: openvswitch: Use struct_size()

2023-10-01 Thread Christophe JAILLET
Use struct_size() instead of hand writing it. This is less verbose and more robust. Signed-off-by: Christophe JAILLET --- This is IMHO more readable, even if not perfect. However (untested): + new = kzalloc(size_add(struct_size(new, masks, size), size_mul

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-10-01 Thread Christophe JAILLET
Le 01/10/2023 à 09:25, Julia Lawall a écrit : This is not found due to the regular expression used for the name of the alloc function. Maybe you could drop it entirely? Maybe you could just check for alloc somewhere in the string? That's how I found it. I simplified a lot Kees's script and l

[PATCH] mtd: rawnand: rockchip: Use struct_size()

2023-10-01 Thread Christophe JAILLET
CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). Also remove a useless comment about the position of a flex-array in a structure. Signed-off-by: Christophe JAILLET --- This patch is part of a work done in parallel of what is currently

[PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-09-30 Thread Christophe JAILLET
functions). Signed-off-by: Christophe JAILLET --- This patch is part of a work done in parallel of what is currently worked on by Kees Cook. My patches are only related to corner cases that do NOT match the semantic of his Coccinelle script[1]. In this case, it is been spotted because of

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