5.15.221-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 534/935 gpu: host1x: Avoid stack over-read in debug output helpers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit bc17ac285fb708f22a8fa2c0ed32eceb1d37e6d6 ]
host1x_debug_output() and host1x_debug_cont() used vsnprintf(), which returns the length the formatted string would have reached with an unbounded buffer. That return value was passed straight to o->fn as the number of bytes to emit.
This could cause a read past end of the output buffer if a call to host1x_debug_* produced a string longer than 256 bytes. This only affected the debugfs files as the printk debug sink ignores the number of bytes. In practice, this is very unlikely to occur.
Fix by switching to vscnprintf(), which returns the number of bytes actually written.
--- drivers/gpu/host1x/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/host1x/debug.c +2 -2
@@ -30,7 +30,7 @@ void host1x_debug_output(struct output *o, const char *fmt, ...)int len;va_start (args, fmt); - len =vsnprintf (o->buf,sizeof (o->buf), fmt, args); + len =vscnprintf (o->buf,sizeof (o->buf), fmt, args);va_end (args); o->fn (o->ctx, o->buf, len, false);
@@ -42,7 +42,7 @@ void host1x_debug_cont(struct output *o, const char *fmt, ...)int len;va_start (args, fmt); - len =vsnprintf (o->buf,sizeof (o->buf), fmt, args); + len =vscnprintf (o->buf,sizeof (o->buf), fmt, args);va_end (args); o->fn (o->ctx, o->buf, len, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 535/935 bpf: Sync tail_call_reachable with callee state on entry
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Lehui <[email protected]>
[ Upstream commit 3513ea9dab6c1a3d2dc8e6160c41f690206948b6 ]
Currently in check_max_stack_depth_subprog, when the verifier enters a new callee branch, the local tail_call_reachable is not properly synchronized with the callee's state.
Consider a main prog branching into multiple subprogs:
subprog0 -> tailcall
main <
subprog1 -> subprog2When the verifier finishes checking subprog0 and backtracks to main prog, the local tail_call_reachable state is left as true. As it proceeds to subprog1, this uncleared state leaks into the new branch, falsely marking subprog1 and subprog2 as tailcall reachable.
Fix this by explicitly syncing tail_call_reachable with the callee's has_tail_call state on entry. The caller's state is safely preserved and restored via the existing backtracking logic.
--- kernel/bpf/verifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/verifier.c +2 -2
@@ -3954,8 +3954,8 @@ static int check_max_stack_depth(struct bpf_verifier_env *env) i = next_insn; idx = sidx; -if (subprog[idx].has_tail_call) - tail_call_reachable = true; +/* sync tail_call_reachable with callee state on entry */ + tail_call_reachable = subprog[idx].has_tail_call; frame++;if (frame >=MAX_CALL_FRAMES ) {
Signature · 1 line
2.53.0
Re: [PATCH 5.15 535/935] bpf: Sync tail_call_reachable with callee state on entry
Please hold this patch unless 5.15 backports of upstream commits 01793ed86b5d ("bpf, verifier: Correct tail_call_reachable for bpf prog") and 54c27ea6dadb ("bpf: Fix tail_call_reachable leak") can also be included.
This patch resets tail_call_reachable on callee entry, but 5.15 lacks both the direct-tail-call initialization and the parent-state restoration it relies on. This can leave the root program falsely unmarked and make the x86 JIT omit required tail-call counter handling.
I reproduced this on 5.15.221-rc1 in QEMU: Linux permits 33 successful tail calls, so the test must stop after 34 program entries including the initial invocation. The unmodified rc1 reached 35, bypassing the limit.
With tested 5.15 adaptations of both commits applied, the same test stopped at the expected 34 entries.
Thanks,
Karl
Greg Kroah-Hartman
maintainerPATCH 536/935 crypto: sl3516 - drop invalid sg_dma_len checks before DMA mapping
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 3ae59a2eba64b3648f069aa52eeaaeefdfe4bb2f ]
sg_dma_len() is only valid after mapping the scatterlist with dma_map_sg(). However, sl3516_ce_need_fallback() checks it before the source and destination scatterlists are mapped. Thus, a stale DMA length that is not a multiple of 16 could incorrectly force a software fallback when CONFIG_NEED_SG_DMA_LENGTH=y.
Remove the invalid checks; the existing scatterlist length checks are sufficient.
--- drivers/crypto/gemini/sl3516-ce-cipher.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/crypto/gemini/sl3516-ce-cipher.c +0 -8
@@ -52,10 +52,6 @@ static bool sl3516_ce_need_fallback(struct skcipher_request *areq) ce->fallback_mod16++;return true; } -if ((sg_dma_len (sg) %16 ) !=0 ) { - ce->fallback_mod16++; -return true; - }if (!IS_ALIGNED (sg->offset,16 )) { ce->fallback_align16++;return true;
@@ -68,10 +64,6 @@ static bool sl3516_ce_need_fallback(struct skcipher_request *areq) ce->fallback_mod16++;return true; } -if ((sg_dma_len (sg) %16 ) !=0 ) { - ce->fallback_mod16++; -return true; - }if (!IS_ALIGNED (sg->offset,16 )) { ce->fallback_align16++;return true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 537/935 ACPI: move from strlcpy() with unused retval to strscpy()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit b75d2cd06b33956b7ec35c6316e717c25a196ee5 ]
Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script.
Stable-dep-of: d5c13047a132 ("ACPI: processor: idle: Expand _LPI package sanity checks")
--- drivers/acpi/bus.c | 4 ++-- drivers/acpi/processor_idle.c | 8 ++++---- drivers/acpi/utils.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/acpi/bus.c +2 -2
@@ -781,7 +781,7 @@ static bool acpi_of_modalias(struct acpi_device *adev, str = obj->string.pointer; chr =strchr (str,',' ); -strlcpy (modalias, chr ? chr +1 : str, len); +strscpy (modalias, chr ? chr +1 : str, len);return true; }
@@ -801,7 +801,7 @@ void acpi_set_modalias(struct acpi_device *adev, const char *default_id, char *modalias, size_t len) {if (!acpi_of_modalias (adev, modalias, len)) -strlcpy (modalias, default_id, len); +strscpy (modalias, default_id, len); }EXPORT_SYMBOL_GPL (acpi_set_modalias);
drivers/acpi/processor_idle.c +4 -4
@@ -796,7 +796,7 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr) state = &drv->states[count];snprintf (state->name,CPUIDLE_NAME_LEN ,"C%d" , i); -strlcpy (state->desc, cx->desc,CPUIDLE_DESC_LEN ); +strscpy (state->desc, cx->desc,CPUIDLE_DESC_LEN ); state->exit_latency = cx->latency; state->target_residency = cx->latency * latency_factor; state->enter = acpi_idle_enter;
@@ -965,7 +965,7 @@ static int acpi_processor_evaluate_lpi(acpi_handle handle, obj = pkg_elem +9 ;if (obj->type ==ACPI_TYPE_STRING ) -strlcpy (lpi_state->desc, obj->string.pointer, +strscpy (lpi_state->desc, obj->string.pointer,ACPI_CX_DESC_LEN ); lpi_state->index = state_idx;
@@ -1031,7 +1031,7 @@ static bool combine_lpi_states(struct acpi_lpi_state *local, result->arch_flags = parent->arch_flags; result->index = parent->index; -strlcpy (result->desc, local->desc,ACPI_CX_DESC_LEN ); +strscpy (result->desc, local->desc,ACPI_CX_DESC_LEN );strlcat (result->desc,"+" ,ACPI_CX_DESC_LEN );strlcat (result->desc, parent->desc,ACPI_CX_DESC_LEN );return true;
@@ -1207,7 +1207,7 @@ static int acpi_processor_setup_lpi_states(struct acpi_processor *pr) state = &drv->states[i];snprintf (state->name,CPUIDLE_NAME_LEN ,"LPI-%d" , i); -strlcpy (state->desc, lpi->desc,CPUIDLE_DESC_LEN ); +strscpy (state->desc, lpi->desc,CPUIDLE_DESC_LEN ); state->exit_latency = lpi->wake_latency; state->target_residency = lpi->min_residency;if (lpi->arch_flags)
drivers/acpi/utils.c +3 -3
@@ -840,7 +840,7 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)struct acpi_dev_match_info match = {};struct device *dev; -strlcpy (match.hid[0 ].id, hid,sizeof (match.hid[0 ].id)); +strscpy (match.hid[0 ].id, hid,sizeof (match.hid[0 ].id)); match.uid = uid; match.hrv = hrv;
@@ -873,7 +873,7 @@ acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const chastruct acpi_dev_match_info match = {};struct device *dev; -strlcpy (match.hid[0 ].id, hid,sizeof (match.hid[0 ].id)); +strscpy (match.hid[0 ].id, hid,sizeof (match.hid[0 ].id)); match.uid = uid; match.hrv = hrv;
@@ -923,7 +923,7 @@ EXPORT_SYMBOL(acpi_video_backlight_string);static int __init acpi_backlight (char *str) { -strlcpy (acpi_video_backlight_string, str, +strscpy (acpi_video_backlight_string, str,sizeof (acpi_video_backlight_string));return 1 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 538/935 ACPI: processor: idle: Expand _LPI package sanity checks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit d5c13047a132162d2649be876906ead691d12948 ]
The _LPI package sanity checks in acpi_processor_evaluate_lpi() miss a couple of things, so expand them by adding a buffer size check before retrieving a struct acpi_power_register from it (and skip the given state if the buffer is not large enough to hold a register structure) and making the function avoid copying the state description from the ACPI table if there are too few elements in the package supposed to hold it.
While at it, relocate and rephrase a comment about skipping _LPI state package elements [7-8].
--- drivers/acpi/processor_idle.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/acpi/processor_idle.c +21 -7
@@ -945,6 +945,13 @@ static int acpi_processor_evaluate_lpi(acpi_handle handle,if (obj->type ==ACPI_TYPE_BUFFER ) {struct acpi_power_register *reg; +if (obj->buffer.length <sizeof (*reg)) { +acpi_handle_debug (handle, +"Invalid register data for _LPI state %d\n" , + state_idx); +continue ; + } + reg = (struct acpi_power_register *)obj->buffer.pointer;if (reg->space_id !=ACPI_ADR_SPACE_SYSTEM_IO && reg->space_id !=ACPI_ADR_SPACE_FIXED_HARDWARE )
@@ -961,13 +968,6 @@ static int acpi_processor_evaluate_lpi(acpi_handle handle,continue ; } -/* elements[7,8] skipped for now i.e. Residency/Usage counter*/ - - obj = pkg_elem +9 ; -if (obj->type ==ACPI_TYPE_STRING ) -strscpy (lpi_state->desc, obj->string.pointer, -ACPI_CX_DESC_LEN ); - lpi_state->index = state_idx;if (obj_get_integer (pkg_elem +0 , &lpi_state->min_residency)) {pr_debug ("No min. residency found, assuming 10 us\n" );
@@ -990,6 +990,20 @@ static int acpi_processor_evaluate_lpi(acpi_handle handle,if (obj_get_integer (pkg_elem +5 , &lpi_state->enable_parent_state)) lpi_state->enable_parent_state =0 ; + +/* Skip elements [7-8] i.e. Residency/Usage counters. */ + +/* +* Avoid out-of-bounds access if the size of the package is less +* than expected. +*/ +if (element->package.count <10 ) +continue ; + + obj = pkg_elem +9 ; +if (obj->type ==ACPI_TYPE_STRING ) +strscpy (lpi_state->desc, obj->string.pointer, +ACPI_CX_DESC_LEN ); }acpi_handle_debug (handle,"Found %d power states\n" , state_idx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 539/935 usb: gadget: f_uac1_legacy: remove broken string configfs attributes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
[ Upstream commit 590d74ec8f488e06b9f1c0f8f0941f45531f3a55 ]
The UAC1_STR_ATTRIBUTE macro defines configfs show/store handlers for the fn_play, fn_cap, and fn_cntl string options. The store function contains an inverted null check on the kstrndup() return value.
This means every write attempt returns -ENOMEM on success and dereferences a NULL pointer on allocation failure. The attributes have been broken and unused for many years.
Remove the UAC1_STR_ATTRIBUTE macro and the three attributes it generated. The internal defaults (FILE_PCM_PLAYBACK, FILE_PCM_CAPTURE, FILE_CONTROL) set in f_audio_alloc_inst() are unaffected.
--- .../testing/configfs-usb-gadget-uac1_legacy | 3 - Documentation/usb/gadget-testing.rst | 3 - drivers/usb/gadget/function/f_uac1_legacy.c | 56 ------------------- drivers/usb/gadget/function/u_uac1_legacy.h | 3 - 4 files changed, 65 deletions(-)
Documentation/ABI/testing/configfs-usb-gadget-uac1_legacy +0 -3
@@ -5,8 +5,5 @@ Description: The attributes: audio_buf_size - audio buffer size - fn_cap - capture pcm device file name - fn_cntl - control device file name - fn_play - playback pcm device file name req_buf_size - ISO OUT endpoint request buffer size req_count - ISO OUT endpoint request count
Documentation/usb/gadget-testing.rst +0 -3
@@ -695,9 +695,6 @@ The uac1 function provides these attributes in its function directory: =============== ==================================== audio_buf_size audio buffer size - fn_cap capture pcm device file name - fn_cntl control device file name - fn_play playback pcm device file name req_buf_size ISO OUT endpoint request buffer size req_count ISO OUT endpoint request count =============== ====================================
drivers/usb/gadget/function/f_uac1_legacy.c +0 -56
72 lines not on this page · raw message
drivers/usb/gadget/function/u_uac1_legacy.h +0 -3
@@ -62,9 +62,6 @@ struct f_uac1_legacy_opts {char *fn_cap;char *fn_cntl; unsigned bound:1; - unsigned fn_play_alloc:1; - unsigned fn_cap_alloc:1; - unsigned fn_cntl_alloc:1;struct mutex lock;int refcnt; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 540/935 tty: hvc: restrict HVC_DCC to ARMv6+ and ARM64
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 782f4dbd1794b4f30dc116a7ca42c5962c409be8 ]
hvc_dcc drives the JTAG DCC via the ARMv6/v7 CP14 debug registers (mrc/mcr p14, 0, rX, c0, c1/c5, 0 in asm/dcc.h). That encoding is undefined on older ARM cores, and also on ARMv7-M, but HVC_DCC only depends on ARM, so it can be enabled on e.g. ARM926 (ARCH_MULTI_V5), where hvc_dcc_console_init() runs __dcc_putchar() at boot and takes an undefined-instruction trap before the console is up:
Internal error: Oops - undefined instruction: 0 [#1] ARM PC is at hvc_dcc_check+0x50/0x8c hvc_dcc_check from hvc_dcc_console_init+0x18/0x48 hvc_dcc_console_init from console_init+0x58/0x170 Kernel panic - not syncing: Fatal exception
Restrict HVC_DCC to the CPUs where that encoding is valid: the CPU_V6 || CPU_V6K || CPU_V7 set that arch/arm/include/debug/icedcc.S guards it with, plus ARM64.
--- drivers/tty/hvc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/hvc/Kconfig +1 -1
@@ -79,7 +79,7 @@ config HVC_UDBG config HVC_DCC bool "ARM JTAG DCC console" - depends on ARM || ARM64 + depends on (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || ARM64 select HVC_DRIVER select SERIAL_CORE_CONSOLE help
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 541/935 UDF symlink pathComponent header OOB read
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lee <[email protected]>
[ Upstream commit d23eb7380d1594cda31a5dc8487dd2a5c8def8c7 ]
udf_symlink_filler() can enter udf_pc_to_char() with a partial pathComponent header.
Validate that enough input remains for a complete pathComponent header before accessing it. Reject malformed symlink data that would otherwise make udf_pc_to_char() perform an out-of-bounds read.
--- fs/udf/symlink.c | 2 ++ 1 file changed, 2 insertions(+)
fs/udf/symlink.c +2 -0
@@ -40,6 +40,8 @@ static int udf_pc_to_char(struct super_block *sb, unsigned char *from,/* Reserve one byte for terminating \0 */ tolen--;while (elen < fromlen) { +if (fromlen - elen <sizeof (struct pathComponent )) +return -EIO ; pc = (struct pathComponent *)(from + elen); elen +=sizeof (struct pathComponent );switch (pc->componentType) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 542/935 uio: Fix stale info pointer in failed registration path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 67b6fc084b034a91c3ec7907a3fed89a2450f30b ]
After device_add(), the UIO device is visible to userspace and /dev/uioX can be opened. If a later setup step fails, __uio_register_device() unwinds the device but leaves idev->info pointing at the caller-owned struct uio_info.
That is unsafe when an opener races with the failed registration path. The open file keeps a reference to the uio_device, while the caller sees registration failure and may free its struct uio_info. Later file operations can then follow idev->info and dereference freed memory.
Handle post-device_add() failures like unregister: remove UIO attributes while the info pointer is still valid, then clear idev->info under info_lock and wake existing waiters/async users before removing the device and minor. This makes already-open file descriptors observe the same "device gone" state as normal uio_unregister_device().
--- drivers/uio/uio.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/uio/uio.c +5 -0
@@ -988,6 +988,11 @@ int __uio_register_device(struct module *owner, err_request_irq:uio_dev_del_attributes (idev); err_uio_dev_add_attributes: +mutex_lock (&idev->info_lock); + idev->info =NULL ; +mutex_unlock (&idev->info_lock); +wake_up_interruptible (&idev->wait); +kill_fasync (&idev->async_queue,SIGIO ,POLL_HUP );device_del (&idev->dev); err_device_create:uio_free_minor (idev->minor);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 543/935 accessibility: speakup: Fix incorrect string length computation in report_char_chartab_status()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit bce0e640623372520d9d90c42f33ddbfb576ce69 ]
snprintf() returns the "number of characters which *would* be generated for the given input", not the size *really* generated.
In order to avoid too large values for 'len' (and potential negative values for "sizeof(buf) - (len - 1)") use scnprintf() instead of snprintf().
--- drivers/accessibility/speakup/kobjects.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/accessibility/speakup/kobjects.c +3 -3
@@ -92,9 +92,9 @@ static void report_char_chartab_status(int reset, int received, int used,if (reset) {pr_info ("%s reset to defaults\n" , object_type[do_characters]); }else if (received) { - len =snprintf (buf,sizeof (buf), -" updated %d of %d %s\n" , - used, received, object_type[do_characters]); + len =scnprintf (buf,sizeof (buf), +" updated %d of %d %s\n" , + used, received, object_type[do_characters]);if (rejected) snprintf(buf + (len - 1), sizeof(buf) - (len - 1), " with %d reject%s\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 544/935 speakup: keyhelp: guard letter_offsets possible out-of-range indexing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Zhigulin <[email protected]>
[ Upstream commit 6a19ad4d68c95185308cd9e5d169b10a2cf236c8 ]
help_init() builds letter_offsets[] by using the first byte of each function name as an index via (start & 31) - 1. If function_names are overridden from sysfs (root) with a name starting outside [a–z], the index underflows or exceeds the array, leading to OOB write.
Function names can be overridden with the following commands as root:
modprobe speakup_soft
echo "0 _bad" > /sys/accessibility/speakup/i18n/function_names # then press Insert+2 on /dev/tty
This fix checks the first letter in help_init(), and if it is not in the [a–z] range the function returns an error to the caller. Eventually this error is propagated to drivers/accessibility/speakup/main.c:2217, which causes a bleep sound.
--- drivers/accessibility/speakup/keyhelp.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/accessibility/speakup/keyhelp.c +12 -5
@@ -8,6 +8,7 @@*/ #include <linux/keyboard.h> +#include <linux/ctype.h> #include "spk_priv.h" #include "speakup.h"
@@ -111,7 +112,7 @@ static void say_key(int key) spk_msg_get(MSG_KEYNAMES_START + (key - 1))); } -static int help_init (void ) +static void help_init (void ) {char start =SPACE ;int i;
@@ -120,13 +121,19 @@ static int help_init(void) state_tbl = spk_our_keys[0 ] +SHIFT_TBL_SIZE +2 ;for (i =0 ; i < num_funcs; i++) {char *cur_funcname =spk_msg_get (MSG_FUNCNAMES_START + i); +char first_letter; -if (start == *cur_funcname) + first_letter =tolower (*cur_funcname); + +/* Accept only 'a'..'z' to index letter_offsets[] safely */ +if (first_letter <'a' || first_letter >'z' ) +continue ; + +if (start == first_letter)continue ; - start = *cur_funcname; + start = first_letter; letter_offsets[(start &31 ) -1 ] = i; } -return 0 ; }int spk_handle_help (struct vc_data *vc,u_char type,u_char ch,u_short key)
@@ -144,7 +151,7 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)synth_printf ("%s\n" ,spk_msg_get (MSG_LEAVING_HELP ));return 1 ; } - ch |=32 ;/* lower case */ + ch =tolower (ch);if (ch <'a' || ch >'z' )return -1 ;if (letter_offsets[ch -'a' ] ==-1 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 545/935 misc: bcm-vk: Use acquire/release for msgq_inited
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
[ Upstream commit 61b101c6a150057b6d512421ed108aed16e822ea ]
bcm_vk_sync_msgq() fills the message queue information and then sets msgq_inited. Readers call bcm_vk_drv_access_ok() before accessing the message queues and their cached queue information.
atomic_set()/atomic_read() do not order those accesses. A reader can see msgq_inited set while still seeing stale queue information. Use release when publishing the initialized queues and acquire when checking the gate.
Keep the clear in bcm_vk_blk_drv_access() as atomic_set(). It closes the gate and does not publish queue state to readers.
--- drivers/misc/bcm-vk/bcm_vk_msg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/misc/bcm-vk/bcm_vk_msg.c +4 -2
@@ -108,7 +108,8 @@ u32 msgq_avail_space(const struct bcm_vk_msgq __iomem *msgq,bool bcm_vk_drv_access_ok (struct bcm_vk *vk) { -return (!!atomic_read (&vk->msgq_inited)); +/* Pair with the release store after message queue initialization. */ +return !!atomic_read_acquire (&vk->msgq_inited); }void bcm_vk_set_host_alert (struct bcm_vk *vk,u32 bit_mask)
@@ -501,7 +502,8 @@ int bcm_vk_sync_msgq(struct bcm_vk *vk, bool force_sync) msgq++; } } -atomic_set (&vk->msgq_inited,1 ); +/* Publish message queue info before allowing driver access. */ +atomic_set_release (&vk->msgq_inited,1 );return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 546/935 misc: rtsx: add missing write register handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gleb Markov <[email protected]>
[ Upstream commit 655faba1ccf195e22a7a83146ef6015e3271233c ]
If an error occurs at the stage of working with registers in conjunction with MCU_Block, it will not be processed.
The occurrence of errors at this stage may signal an impact on writes to the device's PCI registers and is a more global problem than a driver-level security problem, but adding a handler would be a good practice.
Add a missing error handling.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/misc/cardreader/rtsx_pcr.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/cardreader/rtsx_pcr.c +2 -0
@@ -1304,6 +1304,8 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)/* Gating real mcu clock */ err =rtsx_pci_write_register (pcr,RTS5261_FW_CFG1 ,RTS5261_MCU_CLOCK_GATING ,0 ); +if (err <0 ) +return err; err =rtsx_pci_write_register (pcr,RTS5261_REG_FPDCTL ,SSC_POWER_DOWN ,0 ); }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 547/935 misc: ad525x_dpot: Make ad_dpot_remove() return void
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 85385a51ceadfe79ae3b1eb5848fab6c3b917ea8 ]
Up to now ad_dpot_remove() returns zero unconditionally. Make it return void instead which makes it easier to see in the callers that there is no error to handle.
Also the return value of i2c and spi remove callbacks is ignored anyway.
Stable-dep-of: e3a8557e88eb ("misc: ad525x_dpot: use driver core groups for sysfs files")
--- drivers/misc/ad525x_dpot-i2c.c | 3 ++- drivers/misc/ad525x_dpot-spi.c | 3 ++- drivers/misc/ad525x_dpot.c | 4 +--- drivers/misc/ad525x_dpot.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/misc/ad525x_dpot-i2c.c +2 -1
@@ -69,7 +69,8 @@ static int ad_dpot_i2c_probe(struct i2c_client *client,static int ad_dpot_i2c_remove (struct i2c_client *client) { -return ad_dpot_remove (&client->dev); +ad_dpot_remove (&client->dev); +return 0 ; }static const struct i2c_device_id ad_dpot_id[] = {
drivers/misc/ad525x_dpot-spi.c +2 -1
@@ -92,7 +92,8 @@ static int ad_dpot_spi_probe(struct spi_device *spi)static int ad_dpot_spi_remove (struct spi_device *spi) { -return ad_dpot_remove (&spi->dev); +ad_dpot_remove (&spi->dev); +return 0 ; }static const struct spi_device_id ad_dpot_spi_id[] = {
drivers/misc/ad525x_dpot.c +1 -3
@@ -743,7 +743,7 @@ int ad_dpot_probe(struct device *dev, }EXPORT_SYMBOL (ad_dpot_probe); -int ad_dpot_remove (struct device *dev) +void ad_dpot_remove (struct device *dev) {struct dpot_data *data =dev_get_drvdata (dev);int i;
@@ -753,8 +753,6 @@ int ad_dpot_remove(struct device *dev)ad_dpot_remove_files (dev, data->feat, i);kfree (data); - -return 0 ; }EXPORT_SYMBOL (ad_dpot_remove);
drivers/misc/ad525x_dpot.h +1 -1
@@ -209,6 +209,6 @@ struct ad_dpot_bus_data {int ad_dpot_probe (struct device *dev,struct ad_dpot_bus_data *bdata,unsigned long devid,const char *name); -int ad_dpot_remove (struct device *dev); +void ad_dpot_remove (struct device *dev);#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 548/935 misc: ad525x_dpot: use driver core groups for sysfs files
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit e3a8557e88eb26278eda60bf64f2ef33ce7de8bf ]
ad_dpot_probe() creates per-RDAC sysfs files manually and then optionally creates the command sysfs group. This leaves probe responsible for rolling back partial sysfs state and makes remove responsible for matching every file that probe created.
Move the device attributes into driver core dev_groups for the I2C and SPI drivers and use an is_visible() callback to expose only the attributes supported by the probed device. With this shape, the driver core creates the sysfs files only after probe succeeds and removes them before the remove callback frees the driver data.
--- drivers/misc/ad525x_dpot-i2c.c | 1 + drivers/misc/ad525x_dpot-spi.c | 1 + drivers/misc/ad525x_dpot.c | 177 ++++++++++++++++++++------------- drivers/misc/ad525x_dpot.h | 3 + 4 files changed, 112 insertions(+), 70 deletions(-)
drivers/misc/ad525x_dpot-i2c.c +1 -0
@@ -106,6 +106,7 @@ MODULE_DEVICE_TABLE(i2c, ad_dpot_id);static struct i2c_driver ad_dpot_i2c_driver = { .driver = { .name ="ad_dpot" , + .dev_groups = ad_dpot_groups, }, .probe = ad_dpot_i2c_probe, .remove = ad_dpot_i2c_remove,
drivers/misc/ad525x_dpot-spi.c +1 -0
@@ -132,6 +132,7 @@ MODULE_DEVICE_TABLE(spi, ad_dpot_spi_id);static struct spi_driver ad_dpot_spi_driver = { .driver = { .name ="ad_dpot" , + .dev_groups = ad_dpot_groups, }, .probe = ad_dpot_spi_probe, .remove = ad_dpot_spi_remove,
drivers/misc/ad525x_dpot.c +107 -70
224 lines not on this page · raw message
drivers/misc/ad525x_dpot.h +3 -0
@@ -10,6 +10,8 @@#include <linux/types.h> +struct attribute_group ; +#define DPOT_CONF (features, wipers, max_pos, uid) \ (((features) << 18) | (((wipers) & 0xFF) << 10) | \ ((max_pos & 0xF) << 6) | (uid & 0x3F))
@@ -210,5 +212,6 @@ struct ad_dpot_bus_data {int ad_dpot_probe (struct device *dev,struct ad_dpot_bus_data *bdata,unsigned long devid,const char *name);void ad_dpot_remove (struct device *dev); +extern const struct attribute_group *ad_dpot_groups[];#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 549/935 ppdev: prevent overflow when setting port timeout
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 3c0cf801ea2fa40daa5e7d1e6d32adca5ff75ad9 ]
PPSETTIME64 supplies the timeval fields as s64 values, but pp_set_timeout() narrows tv_usec to int and calculates tv_sec * HZ in a signed long. Large positive values can therefore be truncated or overflow and install an unintended timeout.
Keep both fields as s64, reject a non-canonical microsecond value, and use timespec64_to_jiffies() to cap excessively large timeouts at MAX_JIFFY_OFFSET. This is a behavior change because both PPSETTIME ioctls could previously accept values with tv_usec >= USEC_PER_SEC. The validation follows the precedent set by sock_set_timeout().
--- drivers/char/ppdev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/char/ppdev.c +6 -4
@@ -340,15 +340,17 @@ static enum ieee1284_phase init_phase(int mode)return IEEE1284_PH_FWD_IDLE ; } -static int pp_set_timeout (struct pardevice *pdev,long tv_sec,int tv_usec) +static int pp_set_timeout (struct pardevice *pdev,s64 tv_sec,s64 tv_usec) { +struct timespec64 ts;long to_jiffies; -if ((tv_sec <0 ) || (tv_usec <0 )) +if (tv_sec <0 || tv_usec <0 || tv_usec >=USEC_PER_SEC )return -EINVAL ; - to_jiffies =usecs_to_jiffies (tv_usec); - to_jiffies += tv_sec *HZ ; + ts.tv_sec = tv_sec; + ts.tv_nsec = tv_usec *NSEC_PER_USEC ; + to_jiffies =timespec64_to_jiffies (&ts);if (to_jiffies <=0 )return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 550/935 char: xilinx_hwicap: unregister class on init errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit e7e12b4cc0f0c3a2782aea084d4215e23f5512b3 ]
hwicap_module_init() registers icap_class before reserving the character-device region and registering the platform driver. If either of those later steps fails, the init path must undo the successful class registration before returning an error.
Route the chrdev registration failure through a class unwind label, and let the platform-driver registration failure fall through the existing chrdev unwind before unregistering the class. The normal module exit path is unchanged.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/char/xilinx_hwicap/xilinx_hwicap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/char/xilinx_hwicap/xilinx_hwicap.c +4 -1
@@ -864,7 +864,7 @@ static int __init hwicap_module_init(void)HWICAP_DEVICES , DRIVER_NAME);if (retval <0 ) -return retval; + goto failed_class; retval =platform_driver_register (&hwicap_platform_driver);if (retval)
@@ -875,6 +875,9 @@ static int __init hwicap_module_init(void) failed:unregister_chrdev_region (devt,HWICAP_DEVICES ); + failed_class: +class_unregister (&icap_class); +return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 551/935 vfio/pci: clear vdev->msi_perm after freeing it on init failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit dc77acfeb979dded39b247b60fef0399536bfa77 ]
vfio_msi_cap_len() lazily allocates the per-device MSI permission table:
vdev->msi_perm = kmalloc_obj(struct perm_bits, GFP_KERNEL_ACCOUNT);
if (!vdev->msi_perm)
return -ENOMEM;
ret = init_pci_cap_msi_perm(vdev->msi_perm, len, flags);
if (ret) {
kfree(vdev->msi_perm);
return ret; /* vdev->msi_perm left dangling */
}When init_pci_cap_msi_perm() -> alloc_perm_bits() fails with -ENOMEM, the error path frees vdev->msi_perm but leaves the freed pointer stored in it. vdev->msi_perm is not re-zeroed later because struct vfio_pci_core_device is per-device and persists across open/close cycles, and the vfio_config_init() error path returns without calling vfio_config_free(). So the dangling pointer outlives the failed open.
That leads to two use-after-frees on the same device:
1. Reuse. The next vfio_config_init() sees the stale pointer at "if (vdev->msi_perm) return len;" and reuses the freed object. MSI config accesses in vfio_pci_config_rw_single() then dereference and call the freed perm->readfn / perm->writefn function pointers.
2. Double free. A later vfio_config_free() runs free_perm_bits() and kfree() on the already-freed object.
Fix it by NULLing vdev->msi_perm after the kfree(), matching the NULL-after-free discipline already used in free_perm_bits() and vfio_config_free().
BUG: KASAN: slab-use-after-free in vfio_pci_config_rw_single (drivers/vfio/pci/vfio_pci_config.c:1961) Read of size 8 at addr ffff88800fcc88d0 by task exploit/143 Call Trace: ... kasan_report (mm/kasan/report.c:595) vfio_pci_config_rw_single (drivers/vfio/pci/vfio_pci_config.c:1961) vfio_pci_config_rw (drivers/vfio/pci/vfio_pci_config.c:1986) vfio_pci_rw (drivers/vfio/pci/vfio_pci_core.c:1599) vfs_read (fs/read_write.c:572) __x64_sys_pread64 (fs/read_write.c:764) do_syscall_64 (arch/x86/entry/syscall_64.c:94) ...
Followed on device close by a double free of the same object:
Oops: general protection fault, probably for non-canonical address
0x1f63e0e8000008: 0000 [#1] SMP KASAN NOPTI
RIP: 0010:kfree (mm/slub.c:6711)
Call Trace:
vfio_config_free (drivers/vfio/pci/vfio_pci_config.c:1861)
vfio_pci_core_disable (drivers/vfio/pci/vfio_pci_core.c:685)
vfio_pci_core_close_device (drivers/vfio/pci/vfio_pci_core.c:777)
vfio_df_close (drivers/vfio/vfio_main.c:602)
vfio_device_fops_release (drivers/vfio/vfio_main.c:648)
__fput (fs/file_table.c:512)
__x64_sys_close (fs/open.c:1496)
do_syscall_64 (arch/x86/entry/syscall_64.c:94)
...
Kernel panic - not syncing: Fatal exception--- drivers/vfio/pci/vfio_pci_config.c | 1 + 1 file changed, 1 insertion(+)
drivers/vfio/pci/vfio_pci_config.c +1 -0
@@ -1219,6 +1219,7 @@ static int vfio_msi_cap_len(struct vfio_pci_core_device *vdev, u8 pos) ret =init_pci_cap_msi_perm (vdev->msi_perm, len, flags);if (ret) {kfree (vdev->msi_perm); + vdev->msi_perm =NULL ;return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 552/935 soc: ti: knav_qmss_queue: Implement resource cleanup in remove()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Md Shofiqul Islam <[email protected]>
[ Upstream commit 10a1969353b20caa50c320717e054601631c0d3e ]
Implement the TODO in knav_queue_remove() by stopping PDSPs and freeing queue regions and queue ranges before disabling runtime PM, mirroring the cleanup performed in the probe error path.
Set device_ready to false before cleanup to prevent any further use of the device during teardown.
This ensures resources are released on driver unbind and avoids leaking queue/region state.
Stable-dep-of: 3c8178627599 ("soc: ti: knav_qmss: Remove debugfs file on teardown")
--- drivers/soc/ti/knav_qmss_queue.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/soc/ti/knav_qmss_queue.c +6 -1
@@ -1888,7 +1888,12 @@ static int knav_queue_probe(struct platform_device *pdev)static int knav_queue_remove (struct platform_device *pdev) { -/* TODO: Free resources */ +struct knav_device *kdev =platform_get_drvdata (pdev); + + device_ready = false; +knav_queue_stop_pdsps (kdev); +knav_queue_free_regions (kdev); +knav_free_queue_ranges (kdev);pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 553/935 soc: ti: knav_qmss: Remove debugfs file on teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 3c817862759913097f11467ed4ed2bbf974dabaf ]
knav_queue_probe() creates the global qmss debugfs file whose show callback reads the global knav_qdev state. knav_queue_remove() tears down the queue manager resources but leaves the debugfs file published.
Save the debugfs dentry in struct knav_device and remove it during teardown before the resources used by the show callback are released. While touching the debugfs_create_file() call, spell the unchanged read- only file mode as 0444.
--- drivers/soc/ti/knav_qmss.h | 1 + drivers/soc/ti/knav_qmss_queue.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/soc/ti/knav_qmss.h +1 -0
@@ -304,6 +304,7 @@ struct knav_device {struct list_head pools;struct list_head pdsps;struct list_head qmgrs; +struct dentry *debugfs_file;enum qmss_version version; };
drivers/soc/ti/knav_qmss_queue.c +5 -2
@@ -1872,8 +1872,9 @@ static int knav_queue_probe(struct platform_device *pdev) goto err; } -debugfs_create_file ("qmss" ,S_IFREG |S_IRUGO ,NULL ,NULL , - &knav_queue_debug_fops); + knav_qdev->debugfs_file = +debugfs_create_file ("qmss" ,0444 ,NULL ,NULL , + &knav_queue_debug_fops); device_ready = true;return 0 ;
@@ -1891,6 +1892,8 @@ static int knav_queue_remove(struct platform_device *pdev)struct knav_device *kdev =platform_get_drvdata (pdev); device_ready = false; +debugfs_remove (kdev->debugfs_file); + kdev->debugfs_file =NULL ;knav_queue_stop_pdsps (kdev);knav_queue_free_regions (kdev);knav_free_queue_ranges (kdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 554/935 mtd: mtdswap: Avoid freeing registered blktrans device twice
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 779aa4c66a96bf43d2d62982ea1a9096a9128d87 ]
In mtdswap_add_mtd(), debugfs setup failure after successful blktrans registration can free mbd_dev twice.
add_mtd_blktrans_dev() initializes the blktrans device reference and publishes the disk. Once that succeeds, del_mtd_blktrans_dev() tears the disk down and drops the blktrans reference; when that reference reaches zero, blktrans_dev_release() frees the mtd_blktrans_dev.
The debugfs failure path called del_mtd_blktrans_dev(mbd_dev), then fell through the common cleanup label and called kfree(mbd_dev) again. Clear the local pointer after deregistration so the common cleanup can still release the mtdswap state without freeing the blktrans object twice.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/mtd/mtdswap.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/mtdswap.c +1 -0
@@ -1453,6 +1453,7 @@ static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) debugfs_failed:del_mtd_blktrans_dev (mbd_dev); + mbd_dev =NULL ; cleanup:mtdswap_cleanup (d);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 555/935 mtd: part: reject MTDPART_OFS_RETAIN in mtd_add_partition()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: zhouminqiang <[email protected]>
[ Upstream commit b759d5bb6265419344ee9729fd0dc07ad85719d8 ]
mtd_add_partition() does not reject the special offset value MTDPART_OFS_RETAIN (-3), which leads to a WARN_ON in add_mtd_device() when called through the BLKPG ioctl on NAND devices. The RETAIN value depends on cur_offset being the end of the previous partition, but in the dynamic partition path cur_offset equals the offset argument itself, causing undefined behavior.
Commit 5daa7b21496a ("mtd: prepare partition add and del functions for ioctl requests") introduced mtd_add_partition() and correctly rejected MTDPART_OFS_APPEND (-1) and MTDPART_OFS_NXTBLK (-2), since those special offsets rely on cur_offset tracking the previous partition's end. However, commit 1a31368bf92e ("mtd: add a flags for partitions which should just leave smth. after them") later added MTDPART_OFS_RETAIN (-3) for the static
partition table path without updating mtd_add_partition() to also reject this value.
With offset=-3 passed via BLKPG, the RETAIN size calculation in allocate_partition() underflows (parent_size - 0xFFFFFFFFFFFFFFFD = parent_size + 3). If the underflow result does not appear to leave enough space, allocate_partition() jumps to out_register via goto, skipping erasesize initialization. This results in erasesize=0, which triggers:
WARN_ON((!mtd->erasesize || !master->_erase) &&
!(mtd->flags & MTD_NO_ERASE))
in add_mtd_device(). If the underflow result appears to leave enough space, a bogus partition size is calculated, but the "out of reach" sanity check catches the invalid offset and creates a disabled empty partition (offset=0, size=0) instead of returning an error.
Fix this by adding MTDPART_OFS_RETAIN to the rejection list in mtd_add_partition(), consistent with the existing handling of APPEND and NXTBLK.
--- drivers/mtd/mtdpart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/mtdpart.c +2 -1
@@ -247,7 +247,8 @@ int mtd_add_partition(struct mtd_info *parent, const char *name,/* the direct offset is expected */ if (offset ==MTDPART_OFS_APPEND || - offset ==MTDPART_OFS_NXTBLK ) + offset ==MTDPART_OFS_NXTBLK || + offset ==MTDPART_OFS_RETAIN )return -EINVAL ;if (length ==MTDPART_SIZ_FULL )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 556/935 perf ui hists: Fix uninitialized stack memory free on pstack allocation failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit d5fdde1c426922efabe86a515f0782b3eba40577 ]
Fixes heap corruption by initializing the options and actions arrays before the pstack allocation check, preventing an uninitialized stack pointer from being passed to free_popup_options() if the allocation fails.
--- tools/perf/ui/browsers/hists.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/ui/browsers/hists.c +3 -3
@@ -3005,15 +3005,15 @@ static int evsel__hists_browse(struct evsel *evsel, int nr_events, const char *h browser->min_pcnt = min_pcnt;hist_browser__update_nr_entries (browser); +memset (options,0 ,sizeof (options)); +memset (actions,0 ,sizeof (actions)); + browser->pstack =pstack__new (3 );if (browser->pstack ==NULL ) goto out;ui_helpline__push (helpline); -memset (options,0 ,sizeof (options)); -memset (actions,0 ,sizeof (actions)); -if (symbol_conf.col_width_list_str)perf_hpp__set_user_width (symbol_conf.col_width_list_str);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 557/935 software node: Fix software_node_get_reference_args() with index -1
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alban Bedel <[email protected]>
[ Upstream commit ba3dedcf3bd47017307595a7e54924198f018246 ]
The bounds check for the index passed to software_node_get_reference_args() was failing when passed UINT_MAX, this in turn would lead to an out of bound access in the property array. Fix the bound check to also cover the UINT_MAX case.
--- drivers/base/swnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/swnode.c +1 -1
@@ -524,7 +524,7 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,if (prop->is_inline)return -EINVAL ; -if ((index +1 ) *sizeof (*ref) > prop->length) +if (index >= prop->length /sizeof (*ref))return -ENOENT ; ref_array = prop->pointer;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 558/935 driver core: soc: remove layering violation for the soc_bus
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 90be1f15c39858a4f0f4346c39fa150697d231c1 ]
The soc_bus code pokes around in the internal bus structures assuming that it "knows" if a field is not set that it has not been registered yet. That isn't a safe assumption, so just remove the layering violation entirely and keep track if the bus has been registered or not ourselves.
Stable-dep-of: 45dfa004893d ("driver core: soc: Unregister bus on early device registration failure")
--- drivers/base/soc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/base/soc.c +3 -1
@@ -30,6 +30,7 @@ struct soc_device {static struct bus_type soc_bus_type = { .name ="soc" , }; +static bool soc_bus_registered; static DEVICE_ATTR(machine, 0444, soc_info_show, NULL); static DEVICE_ATTR(family, 0444, soc_info_show, NULL);
@@ -117,7 +118,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attrconst struct attribute_group **soc_attr_groups;int ret; -if (!soc_bus_type.p) { +if (!soc_bus_registered) {if (early_soc_dev_attr)return ERR_PTR (-EBUSY ); early_soc_dev_attr = soc_dev_attr;
@@ -183,6 +184,7 @@ static int __init soc_bus_register(void) ret =bus_register (&soc_bus_type);if (ret)return ret; + soc_bus_registered = true;if (early_soc_dev_attr)return PTR_ERR (soc_device_register (early_soc_dev_attr));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 559/935 driver core: soc: Unregister bus on early device registration failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 45dfa004893dfeae182ec27eddbd153c6d4ddbf9 ]
soc_bus_register() registers the SoC bus before registering a deferred early SoC device. If soc_device_register() fails in that path, the function returns the error directly and leaves the bus registered.
Store the returned SoC device pointer explicitly so the success and error cases are handled separately. On failure, clear soc_bus_registered and unregister the bus before returning the error.
--- drivers/base/soc.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/base/soc.c +13 -2
@@ -179,6 +179,7 @@ EXPORT_SYMBOL_GPL(soc_device_unregister);static int __init soc_bus_register (void ) { +struct soc_device *soc_dev;int ret; ret =bus_register (&soc_bus_type);
@@ -186,10 +187,20 @@ static int __init soc_bus_register(void)return ret; soc_bus_registered = true; -if (early_soc_dev_attr) -return PTR_ERR (soc_device_register (early_soc_dev_attr)); +if (early_soc_dev_attr) { + soc_dev =soc_device_register (early_soc_dev_attr); +if (IS_ERR (soc_dev)) { + ret =PTR_ERR (soc_dev); + goto err_unregister_bus; + } + }return 0 ; + +err_unregister_bus: + soc_bus_registered = false; +bus_unregister (&soc_bus_type); +return ret; }core_initcall (soc_bus_register);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 560/935 dmaengine: dw-edma: Serialize abort state updates
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit dd80e259f65d932634e26d366570d71669ef6654 ]
dw_edma_abort_interrupt() drops vc.lock before changing request and status. issue_pending() can acquire the lock in that small window, observe the old busy state, and skip starting queued descriptors. Then the abort handler overwrites the channel status as idle, leaving the new descriptors stranded for good.
Keep descriptor completion and the state transition in the same critical section.
--- drivers/dma/dw-edma/dw-edma-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/dw-edma/dw-edma-core.c +1 -1
@@ -632,9 +632,9 @@ static void dw_edma_abort_interrupt(struct dw_edma_chan *chan)list_del (&vd->node);vchan_cookie_complete (vd); } -spin_unlock_irqrestore (&chan->vc.lock, flags); chan->request =EDMA_REQ_NONE ; chan->status =EDMA_ST_IDLE ; +spin_unlock_irqrestore (&chan->vc.lock, flags); }static irqreturn_t dw_edma_interrupt (int irq,void *data,bool write)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 561/935 dmaengine: dw-edma: Serialize channel state checks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit f7d1619f3e10c619b62c6cd6d95371b5c526c85a ]
pause() and resume() read and update channel state without holding vc.lock, while the interrupt handlers update the same state under it. Take the same lock around those state checks so that request, status, and configured stay consistent.
For example, pause() can observe EDMA_ST_BUSY right before the interrupt handler completes the final descriptor and moves the channel to EDMA_ST_IDLE, and then record EDMA_REQ_PAUSE on an already idle channel. No further interrupt will acknowledge the request, and since issue_pending() requires EDMA_REQ_NONE, the channel is wedged for good: terminate_all() leaves the stale request behind, so even reconfiguring the channel does not recover it.
issue_pending() already runs under vc.lock, but it tests configured before taking it. Move that test under the lock as well, so configured, request, and status are evaluated as one channel-state snapshot.
--- drivers/dma/dw-edma/dw-edma-core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/dma/dw-edma/dw-edma-core.c +6 -4
@@ -216,6 +216,8 @@ static int dw_edma_device_pause(struct dma_chan *dchan)struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan);int err =0 ; +guard (spinlock_irqsave)(&chan->vc.lock); +if (!chan->configured) err = -EPERM ;else if (chan->status !=EDMA_ST_BUSY )
@@ -233,6 +235,8 @@ static int dw_edma_device_resume(struct dma_chan *dchan)struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan);int err =0 ; +guard (spinlock_irqsave)(&chan->vc.lock); +if (!chan->configured) { err = -EPERM ; }else if (chan->status !=EDMA_ST_PAUSE ) {
@@ -282,11 +286,9 @@ static void dw_edma_device_issue_pending(struct dma_chan *dchan)struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan);unsigned long flags; -if (!chan->configured) -return ; -spin_lock_irqsave (&chan->vc.lock, flags); -if (vchan_issue_pending (&chan->vc) && chan->request ==EDMA_REQ_NONE && +if (chan->configured &&vchan_issue_pending (&chan->vc) && + chan->request ==EDMA_REQ_NONE && chan->status ==EDMA_ST_IDLE ) { chan->status =EDMA_ST_BUSY ;dw_edma_start_transfer (chan);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 562/935 dmaengine: dw-edma: Clear stale requests on termination
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit c0d9c6275adcca7c0ca5f4270bf88026f9864bd1 ]
terminate_all() can finish immediately when the channel is unconfigured, paused, idle, or already stopped in hardware. A pending PAUSE request can survive these paths and block issue_pending() even after termination.
Clear the request whenever termination leaves the channel idle. A running channel keeps its STOP request until the interrupt handler consumes it.
--- drivers/dma/dw-edma/dw-edma-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/dma/dw-edma/dw-edma-core.c +2 -0
@@ -277,6 +277,8 @@ static int dw_edma_device_terminate_all(struct dma_chan *dchan) }else { chan->request =EDMA_REQ_STOP ; } +if (chan->status ==EDMA_ST_IDLE ) + chan->request =EDMA_REQ_NONE ;return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 563/935 ASoC: meson: Keep link pointers valid on realloc failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 2aaa41cf974f83a6fb105422bac4e2f107150774 ]
meson_card_reallocate_links() grows the DAI link and private data arrays with two consecutive krealloc() calls and updates the owner pointers only after both calls have succeeded.
A successful krealloc() may move the data: it frees the old block and returns a new one. When that happens for the link array and the second krealloc() then fails, card->dai_link still points to the block that krealloc() already freed, and the error path frees the new block too. The probe error path then calls meson_card_clean_references(), which dereferences card->dai_link and kfree()s it again, resulting in a use-after-free and a double free.
Commit card->dai_link and card->num_links right after the first krealloc() succeeds, so the pointer always refers to a valid allocation that meson_card_clean_references() can walk and free. krealloc() with __GFP_ZERO zero-initializes the added entries, so walking them on the error path is safe. With both failure paths reduced to a plain return, drop the goto labels and the error message.
--- sound/soc/meson/meson-card-utils.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
sound/soc/meson/meson-card-utils.c +6 -11
@@ -50,25 +50,20 @@ int meson_card_reallocate_links(struct snd_soc_card *card, num_links *sizeof (*priv->card.dai_link), GFP_KERNEL | __GFP_ZERO);if (!links) - goto err_links; +return -ENOMEM ; + + priv->card.dai_link = links; + priv->card.num_links = num_links; ldata =krealloc (priv->link_data, num_links *sizeof (*priv->link_data),GFP_KERNEL | __GFP_ZERO); +/* meson_card_clean_references() will free the links on this error path */ if (!ldata) - goto err_ldata; +return -ENOMEM ; - priv->card.dai_link = links; priv->link_data = ldata; - priv->card.num_links = num_links;return 0 ; - -err_ldata: -kfree (links); -err_links: -dev_err (priv->card.dev,"failed to allocate links\n" ); -return -ENOMEM ; - }EXPORT_SYMBOL_GPL (meson_card_reallocate_links);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 564/935 arm64: dts: amlogic: meson-axg-s400: enable mipi_pcie_analog_dphy for PCIe
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Yan <[email protected]>
[ Upstream commit 7f1d0cc86cb70fa550163b6f70fd1d484c03218e ]
The PCIe PHY node references mipi_pcie_analog_dphy via its phys property. Enable this analog PHY node to make PCIe functionally viable.
--- arch/arm64/boot/dts/amlogic/meson-axg-s400.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/amlogic/meson-axg-s400.dts +4 -0
@@ -434,6 +434,10 @@ gpio_speaker: gpio-controller@1f { }; }; +&mipi_pcie_analog_dphy { + status = "okay"; +}; + &pdm { pinctrl-0 = <&pdm_dclk_a14_pins>, <&pdm_din0_pins>, <&pdm_din1_pins>, <&pdm_din2_pins>, <&pdm_din3_pins>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 565/935 RDMA/hfi1: Propagate sdma_txinit_ahg() errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danila Chernetsov <[email protected]>
[ Upstream commit 091c6162c022cbdfb64219708a71728cfd1d4600 ]
set_txreq_header_ahg() ignores the return value of sdma_txinit_ahg().
If sdma_txinit_ahg() fails, it returns before initializing tx->txreq. However, set_txreq_header_ahg() ignores the error and returns the AHG change count, causing the caller to continue processing the request as though initialization had succeeded.
Propagate sdma_txinit_ahg() failures to the caller and abort request processing when initialization fails.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/hw/hfi1/user_sdma.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/infiniband/hw/hfi1/user_sdma.c +8 -5
@@ -1059,6 +1059,7 @@ static int set_txreq_header_ahg(struct user_sdma_request *req, struct user_sdma_txreq *tx, u32 datalen) {u32 ahg[AHG_KDETH_ARRAY_SIZE ]; +int ret;int idx =0 ;u8 omfactor;/* KDETH.OM */ struct hfi1_user_sdma_pkt_q *pq = req->pq;
@@ -1163,11 +1164,13 @@ static int set_txreq_header_ahg(struct user_sdma_request *req,trace_hfi1_sdma_user_header_ahg (pq->dd, pq->ctxt, pq->subctxt, req->info.comp_idx, req->sde->this_idx, req->ahg_idx, ahg, idx, tidval); -sdma_txinit_ahg (&tx->txreq, -SDMA_TXREQ_F_USE_AHG , - datalen, req->ahg_idx, idx, - ahg,sizeof (req->hdr), - user_sdma_txreq_cb); + ret =sdma_txinit_ahg (&tx->txreq, +SDMA_TXREQ_F_USE_AHG , + datalen, req->ahg_idx, idx, + ahg,sizeof (req->hdr), + user_sdma_txreq_cb); +if (ret) +return ret;return idx; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 566/935 RDMA/srpt: Fix srpt_alloc_rw_ctxs() unwind counters
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: TanZheng <[email protected]>
[ Upstream commit b38f98e176050850f41bb6415f3a71400056623e ]
When srpt_alloc_rw_ctxs() fails partway through a multi-buffer indirect descriptor, the unwind path destroys RDMA contexts but leaves stale n_rw_ctx and n_rdma values (and a dangling rw_ctxs pointer). Later sq_wr_avail accounting in srpt_queue_response() or srpt_write_pending() can then subtract the wrong number of send queue credits.
Reset the counters and clear rw_ctxs after freeing the heap allocation before returning an error.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/infiniband/ulp/srpt/ib_srpt.c +7 -0
@@ -900,6 +900,7 @@ static int srpt_alloc_rw_ctxs(struct srpt_send_ioctx *ioctx,struct srpt_rdma_ch *ch = ioctx->ch;struct scatterlist *prev =NULL ;unsigned prev_nents; +u8 n_rdma, n_rw_ctx;int ret, i;if (nbufs ==1 ) {
@@ -911,6 +912,9 @@ static int srpt_alloc_rw_ctxs(struct srpt_send_ioctx *ioctx,return -ENOMEM ; } + n_rw_ctx = ioctx->n_rw_ctx; + n_rdma = ioctx->n_rdma; +for (i = ioctx->n_rw_ctx; i < nbufs; i++, db++) {struct srpt_rw_ctx *ctx = &ioctx->rw_ctxs[i];u64 remote_addr =be64_to_cpu (db->va);
@@ -957,6 +961,9 @@ static int srpt_alloc_rw_ctxs(struct srpt_send_ioctx *ioctx, }if (ioctx->rw_ctxs != &ioctx->s_rw_ctx)kfree (ioctx->rw_ctxs); + ioctx->rw_ctxs =NULL ; + ioctx->n_rw_ctx = n_rw_ctx; + ioctx->n_rdma = n_rdma;return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 567/935 irqchip/gic-v3-its: Prevent leak in its_vpe_irq_domain_alloc()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
[ Upstream commit 325ff3e78c64cd619d52b99f7c8b09a3f31e1495 ]
When its_irq_gic_domain_alloc() fails, the following its_vpe_irq_domain_free() fails to invoke its_vep_teardown() for the corresponding interrupt, which leaks the resource.
Invoke its_vpe_teardown() in the error handling path to avoid the leak.
[ tglx: Massaged change log ]
--- drivers/irqchip/irq-gic-v3-its.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +10 -1
@@ -4464,6 +4464,13 @@ static int its_vpe_init(struct its_vpe *vpe)static void its_vpe_teardown (struct its_vpe *vpe) { +/* +* If vpt_page is NULL, then its_vpe_init() has failed, and +* there is nothing to do as no resource has been allocated. +*/ +if (vpe->vpt_page ==NULL ) +return ; +its_vpe_db_proxy_unmap (vpe);its_vpe_id_free (vpe->vpe_id);its_free_pending_table (vpe->vpt_page);
@@ -4542,8 +4549,10 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virqset_bit (i, bitmap); } -if (err) +if (err) { +its_vpe_teardown (vm->vpes[i]);its_vpe_irq_domain_free (domain, virq, i); + }return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 568/935 ACPI: processor: validate MADT IOAPIC entry bounds
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 2c50ffdc73f3a70d745d249f509fc290754121e6 ]
The IOAPIC hotplug lookup parses both MADT and _MAT records directly. The MADT walk previously used a subtable's declared length to advance the cursor after only locating a generic header. The _MAT path likewise passed a generic header to the IOAPIC helper.
Validate that a current record has a complete generic header, that its declared length is contained in the available record range, and that a typed IOAPIC record contains the full fixed IOAPIC body before reading its fields. Use the same relation for both MADT and _MAT provider paths.
--- drivers/acpi/processor_core.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-)
drivers/acpi/processor_core.c +25 -6
@@ -262,11 +262,26 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)EXPORT_SYMBOL_GPL (acpi_get_cpuid);#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC -static int get_ioapic_id (struct acpi_subtable_header *entry,u32 gsi_base, +static bool madt_entry_is_valid (struct acpi_subtable_header *entry, +unsigned long end) +{ +unsigned long start = (unsigned long )entry; + +if (start >= end || end - start <sizeof (*entry)) +return false; + +return entry->length >=sizeof (*entry) && entry->length <= end - start; +} + +static int get_ioapic_id (struct acpi_subtable_header *entry, +const unsigned long end,u32 gsi_base,u64 *phys_addr,int *ioapic_id) {struct acpi_madt_io_apic *ioapic = (struct acpi_madt_io_apic *)entry; +if (!madt_entry_is_valid (entry, end) ||BAD_MADT_ENTRY (ioapic, end)) +return 0 ; +if (ioapic->global_irq_base != gsi_base)return 0 ;
@@ -287,17 +302,19 @@ static int parse_madt_ioapic_entry(u32 gsi_base, u64 *phys_addr)return apic_id; entry = (unsigned long )madt; +if (madt->header.length <sizeof (*madt)) +return apic_id; madt_end = entry + madt->header.length;/* Parse all entries looking for a match. */ entry +=sizeof (struct acpi_table_madt ); -while (entry +sizeof (struct acpi_subtable_header ) < madt_end) { +while (madt_entry_is_valid ((struct acpi_subtable_header *)entry, + madt_end)) { hdr = (struct acpi_subtable_header *)entry;if (hdr->type ==ACPI_MADT_TYPE_IO_APIC && -get_ioapic_id (hdr, gsi_base, phys_addr, &apic_id)) +get_ioapic_id (hdr, madt_end, gsi_base, phys_addr, &apic_id))break ; -else - entry += hdr->length; + entry += hdr->length; }return apic_id;
@@ -324,7 +341,9 @@ static int parse_mat_ioapic_entry(acpi_handle handle, u32 gsi_base, header = (struct acpi_subtable_header *)obj->buffer.pointer;if (header->type ==ACPI_MADT_TYPE_IO_APIC ) -get_ioapic_id (header, gsi_base, phys_addr, &apic_id); +get_ioapic_id (header, + (unsigned long )header + obj->buffer.length, + gsi_base, phys_addr, &apic_id); exit:kfree (buffer.pointer);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 569/935 ACPI: PCI: Clear driver_data on all paths that free the acpi_pci_root
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Pei <[email protected]>
[ Upstream commit 8a742141f7ab84975aa758b775567ef4740ef0cf ]
acpi_pci_root_add() assigns the freshly allocated root to device->driver_data before dmar_device_add() and pci_acpi_scan_root(). Both failure paths reach the end: label where root is kfree()'d, but only the pci_acpi_scan_root() path clears driver_data first.
When dmar_device_add() fails during a hot-add, root is freed while device->driver_data still points at it. The ACPI core does not clear driver_data on attach failure, so a later acpi_pci_find_root() call may dereference this dangling pointer.
acpi_pci_root_remove() has the same problem: it frees root without clearing device->driver_data, leaving a dangling pointer behind after the root bridge is removed.
Move the NULL assignment to the shared end: label so every error path in acpi_pci_root_add() clears driver_data before freeing root, and clear it in acpi_pci_root_remove() as well, so the object is never left reachable through driver_data after being freed.
--- drivers/acpi/pci_root.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/pci_root.c +2 -1
@@ -599,7 +599,6 @@ static int acpi_pci_root_add(struct acpi_device *device,dev_err (&device->dev,"Bus %04x:%02x not present in PCI namespace\n" , root->segment, (unsigned int )root->secondary.start); - device->driver_data =NULL ; result = -ENODEV ; goto remove_dmar; }
@@ -635,6 +634,7 @@ static int acpi_pci_root_add(struct acpi_device *device,if (hotadd)dmar_device_remove (handle); end: + device->driver_data =NULL ;kfree (root);return result; }
@@ -658,6 +658,7 @@ static void acpi_pci_root_remove(struct acpi_device *device)pci_unlock_rescan_remove (); + device->driver_data =NULL ;kfree (root); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 570/935 ext4: fix out-of-bounds read in ext4_read_inline_dir()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 9333cc809f0a89e001b814155a6cb8903a6274df ]
ext4_read_inline_dir() can read a dirent header past the end of its inline buffer, triggering a slab-out-of-bounds read during getdents64():
BUG: KASAN: slab-out-of-bounds in __ext4_check_dir_entry Read of size 2 at addr ffff88800f3dd23c by task exploit/148 ... __ext4_check_dir_entry ext4_read_inline_dir iterate_dir
The dirent payload lives in a buffer of exactly inline_size bytes:
dir_buf = kmalloc(inline_size, GFP_NOFS);
but iteration runs in a position space extra_offset bytes larger (extra_size = extra_offset + inline_size) so the synthetic "." and ".." land at their block-dir offsets. A dirent is formed at "dir_buf + pos - extra_offset", yet the ext4_check_dir_entry() length argument uses the larger extra_size. A position whose dirent header would extend past extra_size is therefore accepted, and the rescan loop's rec_len probe and ext4_check_dir_entry() dereference de->rec_len before the entry is rejected.
Reject a position whose minimum-size dirent header would not fit within extra_size before forming de, in both the rescan and main loops, and pass inline_size rather than extra_size to ext4_check_dir_entry() so the length check matches the physical buffer.
--- fs/ext4/inline.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/ext4/inline.c +10 -1
@@ -1586,6 +1586,8 @@ int ext4_read_inline_dir(struct file *file,/* for other entry, the real offset in * the buf has to be tuned accordingly. */ +if (i +ext4_dir_rec_len (1 ,NULL ) > extra_size) +break ; de = (struct ext4_dir_entry_2 *) (dir_buf + i - extra_offset);/* It's too expensive to do a full
@@ -1620,10 +1622,17 @@ int ext4_read_inline_dir(struct file *file,continue ; } +/* +* de lives at dir_buf + ctx->pos - extra_offset, within the +* kmalloc(inline_size) buffer. Make sure its header fits before +* ext4_check_dir_entry() dereferences de->rec_len. +*/ +if (ctx->pos +ext4_dir_rec_len (1 ,NULL ) > extra_size) + goto out; de = (struct ext4_dir_entry_2 *) (dir_buf + ctx->pos - extra_offset);if (ext4_check_dir_entry (inode, file, de, iloc.bh, dir_buf, - extra_size, ctx->pos)) + inline_size, ctx->pos)) goto out; if (le32_to_cpu(de->inode)) { if (!dir_emit(ctx, de->name, de->name_len,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 571/935 ext4: skip extra isize expansion during mount to prevent deadlock
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yun Zhou <[email protected]>
[ Upstream commit 7461c60b9c6a839b13ad4c3490681a0cf5aa0637 ]
ext4_try_to_expand_extra_isize() is called from __ext4_mark_inode_dirty() while holding an active jbd2 handle. During mount (!SB_ACTIVE), the expand path may move xattrs to external blocks and release ea_inodes via iput(). When !SB_ACTIVE, iput() calls write_inode_now() which acquires s_writepages_rwsem, creating a circular lock dependency:
s_writepages_rwsem --> jbd2_handle --> xattr_sem --> s_writepages_rwsem
This can be triggered via:
ext4_process_orphan() -> ext4_truncate() -> ext4_mark_inode_dirty()
-> ext4_try_to_expand_extra_isize()
or:
ext4_evict_inode() -> ext4_mark_inode_dirty()
-> ext4_try_to_expand_extra_isize()
Skip expansion when !SB_ACTIVE. This is a minor loss of functionality (extra isize won't grow for these inodes during mount), which e2fsck can resolve later if needed.
--- fs/ext4/inode.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/ext4/inode.c +10 -0
@@ -5948,6 +5948,16 @@ static int ext4_try_to_expand_extra_isize(struct inode *inode,if (ext4_test_inode_state (inode,EXT4_STATE_NO_EXPAND ))return -EOVERFLOW ; +/* +* Skip expansion during mount (!SB_ACTIVE). Expanding extra isize +* may move xattrs to external blocks and release ea_inodes via iput. +* When !SB_ACTIVE, iput triggers write_inode_now() which acquires +* s_writepages_rwsem, causing a deadlock with the caller's active +* jbd2 handle (lock order: s_writepages_rwsem -> jbd2_handle). +*/ +if (unlikely (!(inode->i_sb->s_flags &SB_ACTIVE ))) +return -EBUSY ; +/* * In nojournal mode, we can immediately attempt to expand * the inode. When journaled, we first need to obtain extra
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 572/935 RDMA/srpt: Pass the mapped task attribute to target_init_cmd()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit ef63cc441703412628a517dda354f3e51fe2dc92 ]
srpt_handle_cmd() maps the initiator-supplied srp_cmd->task_attr into cmd->sam_task_attr, but then hands a hardcoded TCM_SIMPLE_TAG to target_init_cmd().
Pass the already mapped cmd->sam_task_attr instead, so target core sees the attribute the initiator requested.
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +1 -1
@@ -1544,7 +1544,7 @@ static void srpt_handle_cmd(struct srpt_rdma_ch *ch, rc =target_init_cmd (cmd, ch->sess, &send_ioctx->sense_data[0 ],scsilun_to_int (&srp_cmd->lun), data_len, -TCM_SIMPLE_TAG , dir,TARGET_SCF_ACK_KREF ); + cmd->sam_task_attr, dir,TARGET_SCF_ACK_KREF );if (rc !=0 ) {pr_debug ("target_submit_cmd() returned %d for tag %#llx\n" , rc, srp_cmd->tag);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 573/935 RDMA/nldev: Split nldev_stat_set_mode_doit out of nldev_stat_set_doit
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aharon Landau <[email protected]>
[ Upstream commit 822cf785ac6d9120386f59964d6d029f3f04a8e3 ]
In order to allow expansion of the set command with more set options, take the set mode out of the main set function.
Stable-dep-of: 709ba0e5311b ("RDMA/core: Fix use after free in ib_query_qp()")
--- drivers/infiniband/core/nldev.c | 116 +++++++++++++++++++------------- 1 file changed, 70 insertions(+), 46 deletions(-)
drivers/infiniband/core/nldev.c +70 -46
@@ -1891,24 +1891,67 @@ static int nldev_set_sys_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,return err; } +static int nldev_stat_set_mode_doit (struct sk_buff *msg, +struct netlink_ext_ack *extack, +struct nlattr *tb[], +struct ib_device *device,u32 port) +{ +u32 mode, mask =0 , qpn, cntn =0 ; +int ret; + +/* Currently only counter for QP is supported */ +if (nla_get_u32 (tb[RDMA_NLDEV_ATTR_STAT_RES ]) !=RDMA_NLDEV_ATTR_RES_QP ) +return -EINVAL ; + + mode =nla_get_u32 (tb[RDMA_NLDEV_ATTR_STAT_MODE ]); +if (mode ==RDMA_COUNTER_MODE_AUTO ) { +if (tb[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK ]) + mask =nla_get_u32 ( + tb[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK ]); +return rdma_counter_set_auto_mode (device, port, mask, extack); + } + +if (!tb[RDMA_NLDEV_ATTR_RES_LQPN ]) +return -EINVAL ; + + qpn =nla_get_u32 (tb[RDMA_NLDEV_ATTR_RES_LQPN ]); +if (tb[RDMA_NLDEV_ATTR_STAT_COUNTER_ID ]) { + cntn =nla_get_u32 (tb[RDMA_NLDEV_ATTR_STAT_COUNTER_ID ]); + ret =rdma_counter_bind_qpn (device, port, qpn, cntn); +if (ret) +return ret; + }else { + ret =rdma_counter_bind_qpn_alloc (device, port, qpn, &cntn); +if (ret) +return ret; + } + +if (nla_put_u32 (msg,RDMA_NLDEV_ATTR_STAT_COUNTER_ID , cntn) || +nla_put_u32 (msg,RDMA_NLDEV_ATTR_RES_LQPN , qpn)) { + ret = -EMSGSIZE ; + goto err_fill; + } + +return 0 ; + +err_fill: +rdma_counter_unbind_qpn (device, port, qpn, cntn); +return ret; +} +static int nldev_stat_set_doit (struct sk_buff *skb,struct nlmsghdr *nlh,struct netlink_ext_ack *extack) { -u32 index, port, mode, mask =0 , qpn, cntn =0 ;struct nlattr *tb[RDMA_NLDEV_ATTR_MAX ];struct ib_device *device;struct sk_buff *msg; +u32 index, port;int ret; - ret =nlmsg_parse (nlh,0 , tb,RDMA_NLDEV_ATTR_MAX -1 , - nldev_policy, extack); -/* Currently only counter for QP is supported */ -if (ret || !tb[RDMA_NLDEV_ATTR_STAT_RES ] || - !tb[RDMA_NLDEV_ATTR_DEV_INDEX ] || - !tb[RDMA_NLDEV_ATTR_PORT_INDEX ] || !tb[RDMA_NLDEV_ATTR_STAT_MODE ]) -return -EINVAL ; - -if (nla_get_u32 (tb[RDMA_NLDEV_ATTR_STAT_RES ]) !=RDMA_NLDEV_ATTR_RES_QP ) + ret =nlmsg_parse (nlh,0 , tb,RDMA_NLDEV_ATTR_MAX -1 , nldev_policy, + extack); +if (ret || !tb[RDMA_NLDEV_ATTR_DEV_INDEX ] || + !tb[RDMA_NLDEV_ATTR_PORT_INDEX ])return -EINVAL ; index =nla_get_u32 (tb[RDMA_NLDEV_ATTR_DEV_INDEX ]);
@@ -1919,59 +1962,40 @@ static int nldev_stat_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh, port =nla_get_u32 (tb[RDMA_NLDEV_ATTR_PORT_INDEX ]);if (!rdma_is_port_valid (device, port)) { ret = -EINVAL ; - goto err; + goto err_put_device; + } + +if (!tb[RDMA_NLDEV_ATTR_STAT_MODE ]) { + ret = -EINVAL ; + goto err_put_device; } msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!msg) { ret = -ENOMEM ; - goto err; + goto err_put_device; } nlh =nlmsg_put (msg,NETLINK_CB (skb).portid, nlh->nlmsg_seq,RDMA_NL_GET_TYPE (RDMA_NL_NLDEV ,RDMA_NLDEV_CMD_STAT_SET ),0 ,0 ); - - mode =nla_get_u32 (tb[RDMA_NLDEV_ATTR_STAT_MODE ]); -if (mode ==RDMA_COUNTER_MODE_AUTO ) { -if (tb[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK ]) - mask =nla_get_u32 ( - tb[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK ]); - ret =rdma_counter_set_auto_mode (device, port, mask, extack); -if (ret) - goto err_msg; - }else { -if (!tb[RDMA_NLDEV_ATTR_RES_LQPN ]) - goto err_msg; - qpn =nla_get_u32 (tb[RDMA_NLDEV_ATTR_RES_LQPN ]); -if (tb[RDMA_NLDEV_ATTR_STAT_COUNTER_ID ]) { - cntn =nla_get_u32 (tb[RDMA_NLDEV_ATTR_STAT_COUNTER_ID ]); - ret =rdma_counter_bind_qpn (device, port, qpn, cntn); - }else { - ret =rdma_counter_bind_qpn_alloc (device, port, - qpn, &cntn); - } -if (ret) - goto err_msg; - -if (fill_nldev_handle (msg, device) || -nla_put_u32 (msg,RDMA_NLDEV_ATTR_PORT_INDEX , port) || -nla_put_u32 (msg,RDMA_NLDEV_ATTR_STAT_COUNTER_ID , cntn) || -nla_put_u32 (msg,RDMA_NLDEV_ATTR_RES_LQPN , qpn)) { - ret = -EMSGSIZE ; - goto err_fill; - } +if (fill_nldev_handle (msg, device) || +nla_put_u32 (msg,RDMA_NLDEV_ATTR_PORT_INDEX , port)) { + ret = -EMSGSIZE ; + goto err_free_msg; } + ret =nldev_stat_set_mode_doit (msg, extack, tb, device, port); +if (ret) + goto err_free_msg; +nlmsg_end (msg, nlh);ib_device_put (device);return rdma_nl_unicast (sock_net (skb->sk), msg,NETLINK_CB (skb).portid); -err_fill: -rdma_counter_unbind_qpn (device, port, qpn, cntn); -err_msg: +err_free_msg:nlmsg_free (msg); -err: +err_put_device:ib_device_put (device);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 574/935 RDMA/restrack: Fix typos in the comments
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kalesh AP <[email protected]>
[ Upstream commit d43358cda7c4696e08880aaa58a7df82e471fa7c ]
Fix couple of occurrences of the misspelled word "reource" in the comments with the correct spelling "resource".
Stable-dep-of: 709ba0e5311b ("RDMA/core: Fix use after free in ib_query_qp()")
--- drivers/infiniband/core/restrack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/core/restrack.c +2 -2
@@ -168,7 +168,7 @@ void rdma_restrack_new(struct rdma_restrack_entry *res,EXPORT_SYMBOL (rdma_restrack_new);/** -* rdma_restrack_add() - add object to the reource tracking database +* rdma_restrack_add() - add object to the resource tracking database * @res: resource entry */ void rdma_restrack_add (struct rdma_restrack_entry *res)
@@ -267,7 +267,7 @@ int rdma_restrack_put(struct rdma_restrack_entry *res)EXPORT_SYMBOL (rdma_restrack_put);/** -* rdma_restrack_del() - delete object from the reource tracking database +* rdma_restrack_del() - delete object from the resource tracking database * @res: resource entry */ void rdma_restrack_del (struct rdma_restrack_entry *res)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 575/935 RDMA/core: Add driver APIs pre_destroy_cq() and post_destroy_cq()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Zhang <[email protected]>
[ Upstream commit 5a2a5b65d5d67279be9e1f0e4b9baf39ee594cb1 ]
Currently in ib_free_cq, it disables IRQ or cancel the CQ work before driver destroy_cq. This isn't good as a new IRQ or a CQ work can be submitted immediately after disabling IRQ or canceling CQ work, which may run concurrently with destroy_cq and cause crashes.
The right flow should be:
1. Driver disables CQ to make sure no new CQ event will be submitted;
2. Disables IRQ or Cancels CQ work in core layer, to make sure no CQ
polling work is running;
3. Free all resources to destroy the CQ.
This patch adds 2 driver APIs:
- pre_destroy_cq(): Disable a CQ to prevent it from generating any new work completions, but not free any kernel resources;
- post_destroy_cq(): Free all kernel resources.
In ib_free_cq, the IRQ is disabled or CQ work is canceled after pre_destroy_cq, and before post_destroy_cq.
Stable-dep-of: 29dc2f8e1c97 ("RDMA/core: Fix potential use after free in ib_free_cq()")
--- drivers/infiniband/core/cq.c | 12 ++++++++++-- drivers/infiniband/core/device.c | 2 ++ include/rdma/ib_verbs.h | 9 +++++++++ 3 files changed, 21 insertions(+), 2 deletions(-)
drivers/infiniband/core/cq.c +10 -2
@@ -318,13 +318,18 @@ EXPORT_SYMBOL(__ib_alloc_cq_any);*/ void ib_free_cq (struct ib_cq *cq) { -int ret; +int ret =0 ;if (WARN_ON_ONCE (atomic_read (&cq->usecnt)))return ;if (WARN_ON_ONCE (cq->cqe_used))return ; +if (cq->device->ops.pre_destroy_cq) { + ret = cq->device->ops.pre_destroy_cq (cq); +WARN_ONCE (ret,"Disable of kernel CQ shouldn't fail" ); + } +switch (cq->poll_ctx) {case IB_POLL_DIRECT :break ;
@@ -341,7 +346,10 @@ void ib_free_cq(struct ib_cq *cq)rdma_dim_destroy (cq);trace_cq_free (cq); - ret = cq->device->ops.destroy_cq (cq,NULL ); +if (cq->device->ops.post_destroy_cq) + cq->device->ops.post_destroy_cq (cq); +else + ret = cq->device->ops.destroy_cq (cq,NULL );WARN_ONCE (ret,"Destroy of kernel CQ shouldn't fail" );rdma_restrack_del (&cq->res);kfree (cq->wc);
drivers/infiniband/core/device.c +2 -0
@@ -2736,8 +2736,10 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)SET_DEVICE_OP (dev_ops, modify_srq);SET_DEVICE_OP (dev_ops, modify_wq);SET_DEVICE_OP (dev_ops, peek_cq); +SET_DEVICE_OP (dev_ops, pre_destroy_cq);SET_DEVICE_OP (dev_ops, poll_cq);SET_DEVICE_OP (dev_ops, port_groups); +SET_DEVICE_OP (dev_ops, post_destroy_cq);SET_DEVICE_OP (dev_ops, post_recv);SET_DEVICE_OP (dev_ops, post_send);SET_DEVICE_OP (dev_ops, post_srq_recv);
include/rdma/ib_verbs.h +9 -0
@@ -2452,6 +2452,15 @@ struct ib_device_ops {int (*modify_cq)(struct ib_cq *cq,u16 cq_count,u16 cq_period);int (*destroy_cq)(struct ib_cq *cq,struct ib_udata *udata);int (*resize_cq)(struct ib_cq *cq,int cqe,struct ib_udata *udata); +/** +* pre_destroy_cq - Prevent a cq from generating any new work +* completions, but not free any kernel resources +*/ +int (*pre_destroy_cq)(struct ib_cq *cq); +/** +* post_destroy_cq - Free all kernel resources +*/ +void (*post_destroy_cq)(struct ib_cq *cq);struct ib_mr *(*get_dma_mr)(struct ib_pd *pd,int mr_access_flags); struct ib_mr *(*reg_user_mr)(struct ib_pd *pd, u64 start, u64 length, u64 virt_addr, int mr_access_flags,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 576/935 RDMA/core: Fix potential use after free in ib_free_cq()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 29dc2f8e1c97372c2871a70088707933515fbd5b ]
When accessing a CQ via the netlink path the only synchronization mechanism for the said CQ is rdma_restrack_get(). Currently, rdma_restrack_del() is invoked at the end of ib_free_cq(), which is too late, since by that point vendor-specific resources associated with the CQ might already be freed. This can leave a short window where the CQ remains accessible through restrack, leading to a potential use-after-free.
Fix this by moving the rdma_restrack_del() call to be before the freeing of the vendor-specific resources ensuring that the CQ is removed from restrack before its internal resources are released.
This guarantees that no new users hold references to a CQ that is in the process of destruction.
--- drivers/infiniband/core/cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/cq.c +1 -1
@@ -325,6 +325,7 @@ void ib_free_cq(struct ib_cq *cq)if (WARN_ON_ONCE (cq->cqe_used))return ; +rdma_restrack_del (&cq->res);if (cq->device->ops.pre_destroy_cq) { ret = cq->device->ops.pre_destroy_cq (cq);WARN_ONCE (ret,"Disable of kernel CQ shouldn't fail" );
@@ -351,7 +352,6 @@ void ib_free_cq(struct ib_cq *cq)else ret = cq->device->ops.destroy_cq (cq,NULL );WARN_ONCE (ret,"Destroy of kernel CQ shouldn't fail" ); -rdma_restrack_del (&cq->res);kfree (cq->wc);kfree (cq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 577/935 iommu/arm-smmu: Add missing pm_runtime_disable() in qcom_iommu_device_probe
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaoqian Lin <[email protected]>
[ Upstream commit 93665e0275a2e2badfcfca5ada3b78b22df4a01a ]
If the probe fails, we should use pm_runtime_disable() to balance pm_runtime_enable().
Add missing pm_runtime_disable() for error handling.
Stable-dep-of: c579f18e7959 ("iommu/qcom: Remove sysfs device on probe failure path")
--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/iommu/arm/arm-smmu/qcom_iommu.c +7 -3
@@ -835,20 +835,20 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) ret =devm_of_platform_populate (dev);if (ret) {dev_err (dev,"Failed to populate iommu contexts\n" ); -return ret; + goto err_pm_disable; } ret =iommu_device_sysfs_add (&qcom_iommu->iommu, dev,NULL ,dev_name (dev));if (ret) {dev_err (dev,"Failed to register iommu in sysfs\n" ); -return ret; + goto err_pm_disable; } ret =iommu_device_register (&qcom_iommu->iommu, &qcom_iommu_ops, dev);if (ret) {dev_err (dev,"Failed to register iommu\n" ); -return ret; + goto err_pm_disable; }bus_set_iommu (&platform_bus_type, &qcom_iommu_ops);
@@ -860,6 +860,10 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) }return 0 ; + +err_pm_disable: +pm_runtime_disable (dev); +return ret; }static int qcom_iommu_device_remove (struct platform_device *pdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 578/935 iommu/qcom: Remove sysfs device on probe failure path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
[ Upstream commit c579f18e79599c16168925cb149e1db3f29eea5f ]
In qcom_iommu_device_probe(), if iommu_device_register() fails, the sysfs device created by iommu_device_sysfs_add() is not released. Add a goto label to do the cleanup.
--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu/qcom_iommu.c +3 -1
@@ -848,7 +848,7 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) ret =iommu_device_register (&qcom_iommu->iommu, &qcom_iommu_ops, dev);if (ret) {dev_err (dev,"Failed to register iommu\n" ); - goto err_pm_disable; + goto err_sysfs_remove; }bus_set_iommu (&platform_bus_type, &qcom_iommu_ops);
@@ -861,6 +861,8 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)return 0 ; +err_sysfs_remove: +iommu_device_sysfs_remove (&qcom_iommu->iommu); err_pm_disable:pm_runtime_disable (dev);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 579/935 iommu/qcom: Fix inverted fault report check in qcom_iommu_fault()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit 1f33b8208a1978b0c0d6ad60a47fe4bb7a235e58 ]
report_iommu_fault() returns 0 when a fault handler successfully handles the fault, and -ENOSYS when no handler is installed. The condition '!report_iommu_fault()' evaluates to true (printing "Unhandled context fault") precisely when the fault *was* handled, and stays silent when no handler is present — the opposite of what is intended.
Remove the '!' so the driver logs unhandled faults correctly.
--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu/qcom_iommu.c +1 -1
@@ -210,7 +210,7 @@ static irqreturn_t qcom_iommu_fault(int irq, void *dev) fsynr =iommu_readl (ctx,ARM_SMMU_CB_FSYNR0 ); iova =iommu_readq (ctx,ARM_SMMU_CB_FAR ); -if (!report_iommu_fault (ctx->domain, ctx->dev, iova,0 )) { +if (report_iommu_fault (ctx->domain, ctx->dev, iova,0 )) { dev_err_ratelimited(ctx->dev, "Unhandled context fault: fsr=0x%x, " "iova=0x%016llx, fsynr=0x%x, cb=%d\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 580/935 thermal: int340x_thermal: Consolidate priv->data_vault checks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit e9a7c526c29b0ae60c888b335bd6cf6e2ee80154 ]
It is sufficient to check priv->data_vault once in the error code path of int3400_thermal_probe(), so do that.
Stable-dep-of: d83dc9ce57a7 ("thermal: intel: int3400: clean up ODVP on probe failures")
--- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +2 -3
@@ -557,9 +557,8 @@ static int int3400_thermal_probe(struct platform_device *pdev) free_sysfs:cleanup_odvp (priv); -if (priv->data_vault) { -if (!ZERO_OR_NULL_PTR (priv->data_vault)) -sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group); +if (!ZERO_OR_NULL_PTR (priv->data_vault)) { +sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group);kfree (priv->data_vault); } free_uuid:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 581/935 thermal: intel: int3400: clean up ODVP on probe failures
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit d83dc9ce57a746a6dca28439bcc0575d26fa6986 ]
evaluate_odvp() creates per-ODVP sysfs files before the thermal zone and later probe resources are registered. The current unwind path only calls cleanup_odvp() from the late sysfs failure path, so failures after evaluate_odvp() but before that label, including thermal_tripless_zone_device_register() failures, leave the ODVP files and storage behind.
Move the ODVP cleanup to the common ART/TRT unwind path so every failure after evaluate_odvp() releases the ODVP state. Also clear the cached ODVP pointers in cleanup_odvp(), because evaluate_odvp() can already call it for partial setup failures while probe continues.
--- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3 -1
@@ -293,8 +293,10 @@ static void cleanup_odvp(struct int3400_thermal_priv *priv)kfree (priv->odvp_attrs[i].attr.attr.name); }kfree (priv->odvp_attrs); + priv->odvp_attrs =NULL ; }kfree (priv->odvp); + priv->odvp =NULL ; priv->odvp_count =0 ; }
@@ -556,7 +558,6 @@ static int int3400_thermal_probe(struct platform_device *pdev)return 0 ; free_sysfs: -cleanup_odvp (priv);if (!ZERO_OR_NULL_PTR (priv->data_vault)) {sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group);kfree (priv->data_vault);
@@ -570,6 +571,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)acpi_thermal_rel_misc_device_remove (priv->adev->handle);thermal_zone_device_unregister (priv->thermal); free_art_trt: +cleanup_odvp (priv);kfree (priv->trts);kfree (priv->arts); free_priv:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 582/935 ext4: drain in-flight DIO before buffered write fallback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 15cdefd0c0522f9d5e12d947fa04f4c11649b699 ]
generic/746 started failing intermittently on ext3 (no-extent inodes). The test triggers 'Page cache invalidation failure on direct I/O' warnings and subsequent fsync returns -EIO. Adding a 50ms delay between ext4_buffered_write_iter() and filemap_write_and_wait_range() in ext4_dio_write_iter() makes the race almost always reproducible.
On no-extent inodes, DIO writes to holes cannot use unwritten extents, so ext4_iomap_alloc() leaves m_flags=0 and ext4_map_blocks() returns 0. The iomap layer then returns -ENOTBLK, causing fallback to buffered I/O.
The fallback path in ext4_dio_write_iter() calls ext4_buffered_write_iter() which dirties pages, then does flush and invalidate. However, there's an unprotected window between ext4_buffered_write_iter() returning (with inode lock released) and the subsequent flush+invalidate.
Concurrent async DIO completions from other threads can run kiocb_invalidate_post_direct_write() during this window. If pages have been re-dirtied, post-invalidation finds dirty pages and triggers the warning, setting -EIO in the error sequence.
Consider a file with two 4k extents: [hole][written]. Thread A does DIO to the written extent, while thread B does DIO spanning both:
kworker A (4k DIO, allocated block) kworker B (8k DIO, fallback)
----------------------------------- ----------------------------
inode_lock_shared() inode_lock_shared()
iomap_dio_rw(): iomap_dio_rw():
kiocb_invalidate_pages -> clean iomap_begin -> -ENOTBLK
submit_bio (async) dio->size = 0 inode_unlock_shared() inode_unlock_shared()
[bio pending in block layer] /* fallback: lock released */
ext4_buffered_write_iter()
inode_lock(exclusive)
generic_perform_write()
-> dirty pages [0, 8k]
inode_unlock(exclusive)
/* pages dirty, no lock */
[bio completes] filemap_write_and_wait_range()
iomap_dio_complete() -> flush dirty pages
kiocb_invalidate_post_direct_write() invalidate_mapping_pages()
invalidate_inode_pages2_range()
-> finds dirty page!
-> dio_warn_stale_pagecache()
-> errseq_set(-EIO)This issue can be triggered through normal I/O paths, not just intentionally overlapping DIO writes from userspace. For example, generic/746 uses a loop device where multiple kworkers issue concurrent I/O to the backing file. Additionally, when block_size < folio_size, non-overlapping DIO writes that share a large folio can also trigger the race.
Add inode_dio_wait() in ext4_buffered_write_iter() before ext4_write_checks() to drain all in-flight DIO. This ensures that all DIO clears existing pages before submitting IO (via kiocb_invalidate_pages()), all BIO waits for all DIO to complete (via inode_dio_wait()), and ext4_write_checks() observes the inode size after all completed DIO so that ext4_block_zero_eof() does not race with in-flight DIO, thus eliminating the race.
--- fs/ext4/file.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/ext4/file.c +7 -0
@@ -260,6 +260,13 @@ static ssize_t ext4_buffered_write_iter(struct kiocb *iocb,return -EOPNOTSUPP ;inode_lock (inode); + +/* +* Prevent concurrent direct I/O and buffered I/O to the same file +* range. Wait for in-flight DIO to finish before dirtying pages. +*/ +inode_dio_wait (inode); + ret =ext4_write_checks (iocb, from);if (ret <=0 ) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 583/935 wifi: ath6kl: avoid buffer overreads in WMI event handlers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit f57314aade9d74d30f3360ec5ef85a83654748be ]
The following WMI event handlers currently read from the event buffer without first verifying that the message was large enough to hold the expected event:ath6kl_wmi_scan_complete_rx() ath6kl_wmi_addba_req_event_rx() ath6kl_wmi_delba_req_event_rx()
Add length checks to prevent overread.
--- drivers/net/wireless/ath/ath6kl/wmi.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/wmi.c +15 -2
@@ -1296,6 +1296,9 @@ static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len, {struct wmi_scan_complete_event *ev; +if (len <sizeof (*ev)) +return -EINVAL ; + ev = (struct wmi_scan_complete_event *) datap;ath6kl_scan_complete_evt (vif,a_sle32_to_cpu (ev->status));
@@ -3386,7 +3389,12 @@ static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap,static int ath6kl_wmi_addba_req_event_rx (struct wmi *wmi,u8 *datap,int len,struct ath6kl_vif *vif) { -struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; +struct wmi_addba_req_event *cmd; + +if (len <sizeof (*cmd)) +return -EINVAL ; + + cmd = (struct wmi_addba_req_event *)datap;aggr_recv_addba_req_evt (vif, cmd->tid,le16_to_cpu (cmd->st_seq_no), cmd->win_sz);
@@ -3397,7 +3405,12 @@ static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len,static int ath6kl_wmi_delba_req_event_rx (struct wmi *wmi,u8 *datap,int len,struct ath6kl_vif *vif) { -struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; +struct wmi_delba_event *cmd; + +if (len <sizeof (*cmd)) +return -EINVAL ; + + cmd = (struct wmi_delba_event *)datap;aggr_recv_delba_req_evt (vif, cmd->tid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 584/935 wifi: ath11k: Correctly copy the hint BSSID in WMI scan request
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 6fe2dddf59bbb2a96be0fcf23a205807b25ac173 ]
Currently, in ath11k_wmi_send_scan_start_cmd(), the logic to populate the hint_bssid copies the BSSID in the wrong direction, from the firmware message to the argument buffer. Swap the parameters so that the BSSID is correctly populated in the firmware message from the argument buffer.
This issue was reported on ath12k, but exists in ath11k as well.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/wmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/wmi.c +2 -2
@@ -2209,8 +2209,8 @@ int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,for (i =0 ; i < params->num_hint_bssid; ++i) { hint_bssid->freq_flags = params->hint_bssid[i].freq_flags; -ether_addr_copy (¶ms->hint_bssid[i].bssid.addr[0 ], - &hint_bssid->bssid.addr[0 ]); +ether_addr_copy (&hint_bssid->bssid.addr[0 ], + ¶ms->hint_bssid[i].bssid.addr[0 ]); hint_bssid++; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 585/935 ath11k: add trace log support
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Venkateswara Naralasetty <[email protected]>
[ Upstream commit fb12305aff12e735e599c79514dde5dac40f5a59 ]
This change is to add trace log support for,
* WMI events
* WMI commands
* ath11k_dbg messages
* ath11k_dbg_dump messages
* ath11k_log_info messages
* ath11k_log_warn messages
* ath11k_log_err messages
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-00652-QCAHKSWPL_SILICONZ-1
Stable-dep-of: 9ef9dd30058c ("wifi: ath11k: Avoid buffer overread in ath11k_wmi_tlv_op_rx()")
--- drivers/net/wireless/ath/ath11k/debug.c | 12 +- drivers/net/wireless/ath/ath11k/debug.h | 3 +- drivers/net/wireless/ath/ath11k/trace.c | 1 + drivers/net/wireless/ath/ath11k/trace.h | 172 ++++++++++++++++++++++++ drivers/net/wireless/ath/ath11k/wmi.c | 4 + 5 files changed, 187 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath11k/debug.c +8 -4
@@ -17,7 +17,7 @@ void ath11k_info(struct ath11k_base *ab, const char *fmt, ...)va_start (args, fmt); vaf.va = &args;dev_info (ab->dev,"%pV" , &vaf); -/* TODO: Trace the log */ +trace_ath11k_log_info (ab, &vaf);va_end (args); }EXPORT_SYMBOL (ath11k_info);
@@ -32,7 +32,7 @@ void ath11k_err(struct ath11k_base *ab, const char *fmt, ...)va_start (args, fmt); vaf.va = &args;dev_err (ab->dev,"%pV" , &vaf); -/* TODO: Trace the log */ +trace_ath11k_log_err (ab, &vaf);va_end (args); }EXPORT_SYMBOL (ath11k_err);
@@ -47,7 +47,7 @@ void ath11k_warn(struct ath11k_base *ab, const char *fmt, ...)va_start (args, fmt); vaf.va = &args;dev_warn_ratelimited (ab->dev,"%pV" , &vaf); -/* TODO: Trace the log */ +trace_ath11k_log_warn (ab, &vaf);va_end (args); }EXPORT_SYMBOL (ath11k_warn);
@@ -68,7 +68,7 @@ void __ath11k_dbg(struct ath11k_base *ab, enum ath11k_debug_mask mask,if (ath11k_debug_mask & mask)dev_printk (KERN_DEBUG , ab->dev,"%pV" , &vaf); -/* TODO: trace log */ +trace_ath11k_log_dbg (ab, mask, &vaf);va_end (args); }
@@ -100,6 +100,10 @@ void ath11k_dbg_dump(struct ath11k_base *ab,dev_printk (KERN_DEBUG , ab->dev,"%s\n" , linebuf); } } + +/* tracing code doesn't like null strings */ +trace_ath11k_log_dbg_dump (ab, msg ? msg :"" , prefix ? prefix :"" , + buf, len); }EXPORT_SYMBOL (ath11k_dbg_dump);
drivers/net/wireless/ath/ath11k/debug.h +2 -1
@@ -60,7 +60,8 @@ static inline void ath11k_dbg_dump(struct ath11k_base *ab,#define ath11k_dbg (ar, dbg_mask, fmt, ...) \ do { \ - if (ath11k_debug_mask & dbg_mask) \ + if ((ath11k_debug_mask & dbg_mask) || \ + trace_ath11k_log_dbg_enabled()) \ __ath11k_dbg(ar, dbg_mask, fmt, ##__VA_ARGS__); \ } while (0)
drivers/net/wireless/ath/ath11k/trace.c +1 -0
@@ -7,3 +7,4 @@#define CREATE_TRACE_POINTS #include "trace.h" +EXPORT_SYMBOL (__tracepoint_ath11k_log_dbg);
drivers/net/wireless/ath/ath11k/trace.h +172 -0
190 lines not on this page · raw message
drivers/net/wireless/ath/ath11k/wmi.c +4 -0
@@ -249,6 +249,8 @@ static int ath11k_wmi_cmd_send_nowait(struct ath11k_pdev_wmi *wmi, struct sk_buf cmd_hdr = (struct wmi_cmd_hdr *)skb->data; cmd_hdr->cmd_id = cmd; +trace_ath11k_wmi_cmd (ab, cmd_id, skb->data, skb->len); +memset (skb_cb,0 ,sizeof (*skb_cb)); ret =ath11k_htc_send (&ab->htc, wmi->eid, skb);
@@ -6998,6 +7000,8 @@ static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb) cmd_hdr = (struct wmi_cmd_hdr *)skb->data; id =FIELD_GET (WMI_CMD_HDR_CMD_ID , (cmd_hdr->cmd_id)); +trace_ath11k_wmi_event (ab, id, skb->data, skb->len); +if (skb_pull (skb,sizeof (struct wmi_cmd_hdr )) ==NULL ) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 586/935 wifi: ath11k: Avoid buffer overread in ath11k_wmi_tlv_op_rx()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 9ef9dd30058cc9223c72f711dca1a28a5947d0c5 ]
Currently, in ath11k_wmi_tlv_op_rx(), the firmware buffer is read without first verifying that the buffer has enough data to hold a header. This could result in a buffer overread.
Add an upfront length check before dereferencing skb->data as a wmi_cmd_hdr. The check is placed before the trace_ath11k_wmi_event() call to preserve the existing trace semantics (tracing the full raw WMI event including the header), unlike the analogous ath12k fix which could use skb_pull_data() directly.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/wmi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/wmi.c +4 -2
@@ -6997,13 +6997,15 @@ static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb)struct wmi_cmd_hdr *cmd_hdr;enum wmi_tlv_event_id id; +if (skb->len <sizeof (*cmd_hdr)) + goto out; + cmd_hdr = (struct wmi_cmd_hdr *)skb->data; id =FIELD_GET (WMI_CMD_HDR_CMD_ID , (cmd_hdr->cmd_id));trace_ath11k_wmi_event (ab, id, skb->data, skb->len); -if (skb_pull (skb,sizeof (struct wmi_cmd_hdr )) ==NULL ) - goto out; +skb_pull (skb,sizeof (*cmd_hdr));switch (id) {/* Process all the WMI events here */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 587/935 ext4: fix buffer_head leak in ext4_init_orphan_info
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanghui Yang <[email protected]>
[ Upstream commit 05704335803b69c1bfa8637b7ada942bf2ee8a41 ]
ext4_init_orphan_info() reads orphan file blocks with ext4_bread() and stores the returned buffer_head in oi->of_binfo[i].ob_bh.
If ext4_bread() succeeds but the orphan block magic or checksum validation fails, the function jumps to out_free. However, the old out_free loop starts releasing buffers from i - 1, so the current buffer_head at index i is skipped.
This leaks the buffer_head reference obtained by ext4_bread() on the bad magic and bad checksum error paths.
Fix this by tracking the number of successfully read buffer_heads and releasing exactly those buffer_heads on the error path.
--- fs/ext4/orphan.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/ext4/orphan.c +6 -2
@@ -573,6 +573,7 @@ int ext4_init_orphan_info(struct super_block *sb)int i, j;int ret;int free; +int loaded =0 ;__le32 *bdata;int inodes_per_ob =ext4_inodes_per_orphan_block (sb);struct ext4_orphan_block_tail *ot;
@@ -616,6 +617,7 @@ int ext4_init_orphan_info(struct super_block *sb) ret = -EIO ; goto out_free; } + loaded++; ot =ext4_orphan_block_tail (sb, oi->of_binfo[i].ob_bh);if (le32_to_cpu (ot->ob_magic) !=EXT4_ORPHAN_BLOCK_MAGIC ) {ext4_error (sb,"orphan file block %d: bad magic" , i);
@@ -638,8 +640,10 @@ int ext4_init_orphan_info(struct super_block *sb)iput (inode);return 0 ; out_free: -for (i--; i >=0 ; i--) -brelse (oi->of_binfo[i].ob_bh); +while (loaded >0 ) { + loaded--; +brelse (oi->of_binfo[loaded].ob_bh); + }kvfree (oi->of_binfo); out_put:iput (inode);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 588/935 ext4: check dir entry fits before reading the hash trailer in ext4_search_dir()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit c7e6b863d298f56522d0d08554bbea7f142e6588 ]
For casefolded encrypted directories ext4 stores an 8-byte hash trailer after the name (EXT4_DIRENT_HASHES()), at an offset derived from de->name_len. On the sb_no_casefold_compat_fallback() path ext4_match() reads that trailer, but ext4_search_dir()'s by-hand pre-check only tests de->name + de->name_len <= dlimit, which proves the name fits, not the rounded trailer. A crafted entry whose name ends at the block boundary passes the check while EXT4_DIRENT_HASHES(de) lands past the block end, so ext4_match() reads out of bounds on an ordinary lookup. KASAN reports it as a use-after-free when the page after the directory block holds a freed object:
BUG: KASAN: use-after-free in ext4_match (fs/ext4/namei.c:1435) Read of size 4 at addr ffff888010458000 by task exploit Call Trace: ext4_match (fs/ext4/namei.c:1435) ext4_search_dir (fs/ext4/namei.c:1470) __ext4_find_entry (fs/ext4/namei.c:1268 fs/ext4/namei.c:1632) ext4_lookup (fs/ext4/namei.c:1703 fs/ext4/namei.c:1769) ... filename_lookup (fs/namei.c:2842) vfs_statx (fs/stat.c:353) __do_sys_newfstatat (fs/stat.c:538) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
Require, for hash-in-dirent directories, that the whole entry including the rounded trailer fits before calling ext4_match(). This is the same bound ext4_check_dir_entry() already enforces via ext4_dir_rec_len(), so no well-formed entry is rejected. The other caller, ext4_find_dest_de(), runs ext4_check_dir_entry() first and is unaffected.
--- fs/ext4/namei.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ext4/namei.c +2 -0
@@ -1542,6 +1542,8 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size,/* this code is executed quadratically often */ /* do minimal checking `by hand' */ if (de->name + de->name_len <= dlimit && + (!ext4_hash_in_dirent (dir) || + (char *)de +ext4_dir_rec_len (de->name_len, dir) <= dlimit) &&ext4_match (dir, fname, de)) {/* found a match - just to be sure, do * a full check */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 589/935 ARM: dts: allwinner: a10: Fix PMU interrupt
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andre Przywara <[email protected]>
[ Upstream commit eb7051f756460d7b951e94d9656e31ebb631ba28 ]
The Performance Monitoring Unit of the Cortex-A8 cores in the Allwinner A10 SoC is connected to interrupt line 66, not 3. This is shown in the manual (where interrupt 3 is assigned to UART2, also in our .dtsi), but has also been confirmed by triggering an PMU overflow interrupt and inspecting the IRQ controller status registers (from U-Boot). Please note that "perf stat" does not use interrupts, this might explain why this evaded the initial testing.
--- arch/arm/boot/dts/sun4i-a10.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/sun4i-a10.dtsi +1 -1
@@ -186,7 +186,7 @@ de: display-engine { pmu { compatible = "arm,cortex-a8-pmu"; - interrupts = <3>; + interrupts = <66>; }; reserved-memory {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 590/935 perf cs-etm: Flush thread stacks after decoder reset
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit ea5075e3776846d4941dddf1549426ebd3feb81f ]
Perf resets the CoreSight decoder when moving to a new AUX trace buffer, this causes trace discontinunity globally.
For callchain synthesis, keeping thread-stack state after decoder reset can leave stale call/return history attached to threads that are decoded later, producing incorrect synthesized callchains.
Flush all host thread stacks after a decoder reset. When virtualization is present, flush the guest thread stacks as well.
Stable-dep-of: ec99be8a31db ("perf cs-etm: Avoid truncating AUX buffer sizes to int")
--- tools/perf/util/cs-etm.c | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
tools/perf/util/cs-etm.c +45 -0
@@ -1637,6 +1637,45 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq,return 0 ; } + +static int cs_etm__flush_stack_cb (struct thread *thread, +void *data__maybe_unused ) +{ +thread_stack__flush (thread); +return 0 ; +} + +static void cs_etm__flush_machine_stack (struct cs_etm_queue *etmq,pid_t pid) +{ +struct machine *machine; + + machine =machines__find (&etmq->etm->session->machines, pid); +if (machine) +machine__for_each_thread (machine, cs_etm__flush_stack_cb,NULL ); +} + +static void cs_etm__flush_all_stack (struct cs_etm_queue *etmq) +{ +enum cs_etm_pid_fmt pid_fmt =cs_etm__get_pid_fmt (etmq); + +if (!etmq->etm->synth_opts.last_branch) +return ; + +switch (pid_fmt) { +case CS_ETM_PIDFMT_CTXTID2 : +/* Clear the guest stack if virtualization is supported */ +cs_etm__flush_machine_stack (etmq,DEFAULT_GUEST_KERNEL_ID ); + fallthrough; +case CS_ETM_PIDFMT_CTXTID : +cs_etm__flush_machine_stack (etmq,HOST_KERNEL_ID ); +break ; +case CS_ETM_PIDFMT_NONE : +default : +break ; + + } +} +/* * cs_etm__get_data_block: Fetch a block from the auxtrace_buffer queue * if need be.
@@ -1659,6 +1698,12 @@ static int cs_etm__get_data_block(struct cs_etm_queue *etmq) ret =cs_etm_decoder__reset (etmq->decoder);if (ret)return ret; + +/* +* Since the decoder is reset, this causes a global trace +* discontinuity. Flush all thread stacks. +*/ +cs_etm__flush_all_stack (etmq); }return etmq->buf_len;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 591/935 perf cs-etm: Avoid truncating AUX buffer sizes to int
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit ec99be8a31db999a4f866be74ea7db61dbb19f24 ]
cs_etm__get_trace() returns an int, but it used to return etmq->buf_len on success. That value comes from auxtrace_buffer::size, which is a size_t. For a large AUX trace block, returning the byte count through an int can overflow and make a valid buffer look like a negative error.
The callers do not need the actual byte count from cs_etm__get_trace(). The buffer length is already stored in the etmq->buf_len. The callers only need to distinguish three states:
< 0: error
= 0: no more AUX buffers
Quoted 1 line
0: data is available
Make cs_etm__get_trace() return 0 for all non-error cases and use etmq->buf_len to indicate whether a new buffer was found. Then make cs_etm__get_data_block() return 1 whenever data is available, instead of returning the buffer length.
Also refactor cs_etm__get_data_block() to make its return value semantics clearer.
--- tools/perf/util/cs-etm.c | 46 +++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-)
tools/perf/util/cs-etm.c +26 -20
@@ -1089,8 +1089,7 @@ cs_etm__get_trace(struct cs_etm_queue *etmq) etmq->buf_used =0 ; etmq->buf_len = aux_buffer->size; etmq->buf = aux_buffer->data; - -return etmq->buf_len; +return 0 ; } static void cs_etm__set_pid_tid_cpu(struct cs_etm_auxtrace *etm,
@@ -1687,26 +1686,33 @@ static int cs_etm__get_data_block(struct cs_etm_queue *etmq) {int ret; -if (!etmq->buf_len) { - ret =cs_etm__get_trace (etmq); -if (ret <=0 ) -return ret; -/* -* We cannot assume consecutive blocks in the data file -* are contiguous, reset the decoder to force re-sync. -*/ - ret =cs_etm_decoder__reset (etmq->decoder); -if (ret) -return ret; +/* The current block is not finished */ +if (etmq->buf_len) +return 1 ; -/* -* Since the decoder is reset, this causes a global trace -* discontinuity. Flush all thread stacks. -*/ -cs_etm__flush_all_stack (etmq); - } + ret =cs_etm__get_trace (etmq); +if (ret <0 ) +return ret; + +/* No more buffer to read */ +if (!etmq->buf_len) +return 0 ; + +/* +* We cannot assume consecutive blocks in the data file +* are contiguous, reset the decoder to force re-sync. +*/ + ret =cs_etm_decoder__reset (etmq->decoder); +if (ret) +return ret; + +/* +* Since the decoder is reset, this causes a global trace +* discontinuity. Flush all thread stacks. +*/ +cs_etm__flush_all_stack (etmq); -return etmq->buf_len; +return 1 ; } static bool cs_etm__is_svc_instr(struct cs_etm_queue *etmq, u8 trace_chan_id,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 592/935 leds: pca9532: Fix phantom device registration on missing hardware
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmo Chou <[email protected]>
[ Upstream commit 8d6b6c05b8e33d11e3fb3203309385e1a9cceecd ]
The initial PWM and PSC register writes in pca9532_configure() do not check the return values of i2c_smbus_write_byte_data(). If the I2C device is physically absent from the bus, the write fails with -ENXIO. However, the driver ignores this error and allows probe() to complete successfully.
This results in the registration of phantom LED class devices and gpiochips backed by non-existent hardware. Subsequent GPIO reads from these phantom chips return bogus values (due to -ENXIO being truncated to an unsigned char in pca9532_gpio_get_value()), silently corrupting hardware state tracking in userspace.
Propagate the I2C write failures back to probe() so the driver core can gracefully abort binding and release devres-managed resources.
--- drivers/leds/leds-pca9532.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/leds/leds-pca9532.c +8 -4
@@ -360,10 +360,14 @@ static int pca9532_configure(struct i2c_client *client,for (i =0 ; i <2 ; i++) { data->pwm[i] = pdata->pwm[i]; data->psc[i] = pdata->psc[i]; -i2c_smbus_write_byte_data (client,PCA9532_REG_PWM (maxleds, i), - data->pwm[i]); -i2c_smbus_write_byte_data (client,PCA9532_REG_PSC (maxleds, i), - data->psc[i]); + err =i2c_smbus_write_byte_data (client,PCA9532_REG_PWM (maxleds, i), + data->pwm[i]); +if (err <0 ) +return err; + err =i2c_smbus_write_byte_data (client,PCA9532_REG_PSC (maxleds, i), + data->psc[i]); +if (err <0 ) +return err; }for (i =0 ; i < data->chip_info->num_leds; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 593/935 drm/tve200: add OF module alias for autoloading
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Can Peng <[email protected]>
[ Upstream commit b6c3585f2058e0fbfa8cb403458f5cc6cf5c5e06 ]
The TVE200 DRM driver can be built as a module and uses tve200_of_match as its OF match table, but the table is not exported for module alias generation.
Add the MODULE_DEVICE_TABLE(of, ...) entry so modpost can generate OF module aliases for OF based module autoloading.
--- drivers/gpu/drm/tve200/tve200_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/tve200/tve200_drv.c +1 -0
@@ -257,6 +257,7 @@ static const struct of_device_id tve200_of_match[] = { }, {}, }; +MODULE_DEVICE_TABLE (of, tve200_of_match);static struct platform_driver tve200_driver = { .driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 594/935 netfilter: nf_nat_sip: rewind offset when NAT shrinks the packet
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 16aecbe3036f6097c26b51b12e4c1cf207769690 ]
sashiko says:
If map_addr() changes the packet length, such as when the public NAT IP string is shorter or longer than the internal IP, coff will still point to the offset relative to the pre-mangled packet.
If the packet shrinks, coff could overshoot the correct position, potentially causing the next ct_sip_parse_header_uri() call to silently skip bytes and miss subsequent Contact headers. Could this lead to a failure to NAT those subsequent headers and leak internal network details?
--- net/netfilter/nf_nat_sip.c | 5 +++++ 1 file changed, 5 insertions(+)
net/netfilter/nf_nat_sip.c +5 -0
@@ -267,12 +267,17 @@ static unsigned int nf_nat_sip(struct sk_buff *skb, unsigned int protoff, SIP_HDR_CONTACT, &in_header, &matchoff, &matchlen, &addr, &port) > 0) { +int old_len = skb->len, delta; +if (!map_addr (skb, protoff, dataoff, dptr, datalen, matchoff, matchlen, &addr, port)) {nf_ct_helper_log (skb, ct,"cannot mangle contact" );return NF_DROP ; } + + delta = (int )skb->len - old_len; + coff += delta; } if (!map_sip_addr(skb, protoff, dataoff, dptr, datalen, SIP_HDR_FROM) ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 595/935 fs/ntfs3: fix out-of-bounds read of INDEX_ROOT in reparse/objid init
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Wu <[email protected]>
[ Upstream commit 2064bc663f89e61b8681c1fb9d1ce445de72063d ]
ntfs_reparse_init() and ntfs_objid_init() parse the index root of the $Extend/$Reparse and $Extend/$ObjId metafiles (the INDEX_ROOT attributes named $R and $O). They read its type and rule fields through resident_data(), which does not check that the resident attribute is large enough to hold them.
mi_enum_attr() accepts a resident attribute with data_off == asize and data_size == 0. For such an attribute placed last in its MFT record, resident_data() returns a pointer to the end of the record_size buffer, so reading root->type / root->rule reads past the allocation.
Use resident_data_ex(attr, sizeof(struct INDEX_ROOT)) and bail out when it returns NULL, as ntfs_security_init() already does for $SDH / $SII.
The attribute is only parsed while mounting a crafted image, so this needs CAP_SYS_ADMIN.
BUG: KASAN: slab-out-of-bounds in ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306) Read of size 4 at addr ffff88801219dc00 by task mount ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306) ntfs_fill_super (fs/ntfs3/super.c:1604) get_tree_bdev_flags (fs/super.c:1703) vfs_get_tree (fs/super.c:1758) path_mount (fs/namespace.c:4131) __x64_sys_mount (fs/namespace.c:4360)
--- fs/ntfs3/fsntfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/ntfs3/fsntfs.c +4 -4
@@ -2310,8 +2310,8 @@ int ntfs_reparse_init(struct ntfs_sb_info *sbi) goto out; } - root_r =resident_data (attr); -if (root_r->type !=ATTR_ZERO || + root_r =resident_data_ex (attr,sizeof (struct INDEX_ROOT )); +if (!root_r || root_r->type !=ATTR_ZERO || root_r->rule !=NTFS_COLLATION_TYPE_UINTS ) { err = -EINVAL ; goto out;
@@ -2348,8 +2348,8 @@ int ntfs_objid_init(struct ntfs_sb_info *sbi) goto out; } - root =resident_data (attr); -if (root->type !=ATTR_ZERO || + root =resident_data_ex (attr,sizeof (struct INDEX_ROOT )); +if (!root || root->type !=ATTR_ZERO || root->rule !=NTFS_COLLATION_TYPE_UINTS ) { err = -EINVAL ; goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 596/935 arm64: dts: rockchip: Add gru-scarlet-dumo board
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit 5707e34166f546bf1fcdfd3da600e8187d04d937 ]
Dumo is another variant of Scarlet, also known as the ASUS Chromebook Tablet CT100. This is almost the same as Scarlet-Innolux, but uses a board-specific calibration variant for the WiFi module.
Add a new device tree for it.
Stable-dep-of: a761818d9ee1 ("arm64: dts: rockchip: Fix Gru WLAN sideband interrupt")
--- arch/arm64/boot/dts/rockchip/Makefile | 1 + .../dts/rockchip/rk3399-gru-scarlet-dumo.dts | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 arch/arm64/boot/dts/rockchip/rk3399-gru-scarlet-dumo.dts
arch/arm64/boot/dts/rockchip/Makefile +1 -0
@@ -24,6 +24,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-ficus.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-firefly.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-gru-bob.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-gru-kevin.dtb +dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-gru-scarlet-dumo.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-gru-scarlet-inx.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-gru-scarlet-kd.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-hugsun-x99.dtb
arch/arm64/boot/dts/rockchip/rk3399-gru-scarlet-dumo.dts new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 597/935 arm64: dts: rockchip: Fix PCI node addresses on rk3399-gru
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Herring <[email protected]>
[ Upstream commit c13c823a78b77ea0e5f1f73112d910e259911101 ]
The rk3399-gru PCI node addresses are wrong.
In rk3399-gru-scarlet, the bus number in the address should be 0. This is because bus number assignment is dynamic and not known up front. For FDT, the bus number is simply ignored.
In rk3399-gru-chromebook, the addresses are simply invalid. The first "reg" entry must be the configuration space for the device. The entry should be all 0s except for device/slot and function numbers. The existing 64-bit memory space (0x83000000) entries are not valid because they must have the BAR address in the lower byte of the first cell.
Warnings for these are enabled by adding the missing 'device_type = "pci"' for the root port node.
Stable-dep-of: a761818d9ee1 ("arm64: dts: rockchip: Fix Gru WLAN sideband interrupt")
--- arch/arm64/boot/dts/rockchip/rk3399-gru-chromebook.dtsi | 3 +-- arch/arm64/boot/dts/rockchip/rk3399-gru-scarlet-dumo.dts | 4 ++-- arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 1 + 3 files changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-gru-chromebook.dtsi +1 -2
@@ -327,8 +327,7 @@ wacky_spi_audio: spi2@0 { &pci_rootport { mvl_wifi: wifi@0,0 { compatible = "pci1b4b,2b42"; - reg = <0x83010000 0x0 0x00000000 0x0 0x00100000 - 0x83010000 0x0 0x00100000 0x0 0x00100000>; + reg = <0x0000 0x0 0x0 0x0 0x0>; interrupt-parent = <&gpio0>; interrupts = <8 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default";
arch/arm64/boot/dts/rockchip/rk3399-gru-scarlet-dumo.dts +2 -2
@@ -34,8 +34,8 @@ &mipi_panel { &pci_rootport { wifi@0,0 { compatible = "qcom,ath10k"; - reg = <0x00010000 0x0 0x00000000 0x0 0x00000000>, - <0x03010010 0x0 0x00000000 0x0 0x00200000>; + reg = <0x00000000 0x0 0x00000000 0x0 0x00000000>, + <0x03000010 0x0 0x00000000 0x0 0x00200000>; qcom,ath10k-calibration-variant = "GO_DUMO"; }; };
arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi +1 -0
@@ -461,6 +461,7 @@ pci_rootport: pcie@0,0 { #address-cells = <3>; #size-cells = <2>; ranges; + device_type = "pci"; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 598/935 arm64: dts: rockchip: Fix Gru WLAN sideband interrupt
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
[ Upstream commit a761818d9ee11183df0aefd16bf9fe46cc1c4c6d ]
The Marvell WLAN host wake interrupt is wired to GPIO0 8 and is not one of the PCI INTx interrupts. The PCI device schema therefore interprets the two-cell GPIO interrupt specifier as an invalid PCI interrupt and reports dtbs_check warnings:
pcie@0,0: wifi@0,0:interrupts:0:0: 8 is not one of [1, 2, 3, 4] pcie@0,0: wifi@0,0:interrupts:0: [8, 8] is too long
Describe the sideband interrupt with interrupts-extended, which explicitly carries the interrupt controller and removes the ambiguity.
--- arch/arm64/boot/dts/rockchip/rk3399-gru-chromebook.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-gru-chromebook.dtsi +1 -2
@@ -328,8 +328,7 @@ &pci_rootport { mvl_wifi: wifi@0,0 { compatible = "pci1b4b,2b42"; reg = <0x0000 0x0 0x0 0x0 0x0>; - interrupt-parent = <&gpio0>; - interrupts = <8 IRQ_TYPE_LEVEL_LOW>; + interrupts-extended = <&gpio0 8 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&wlan_host_wake_l>; wakeup-source;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 599/935 ARM: lpc32xx: only run SoC init on LPC32xx hardware
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 717ea4000867e6dffee5e1ed92150a9704ae9f68 ]
lpc32xx_check_uid() and lpc32xx_pm_init() are arch_initcalls that poke LPC32xx-only registers. Since the multiplatform conversion they also run on other ARCH_MULTI_V5 boards where access faults e.g. on versatile:
Unable to handle kernel paging request at virtual address f4004130 PC is at lpc32xx_check_uid+0x2c/0x9c
Drop the arch_initcall() registrations and call both functions directly from lpc3250_machine_init(), the machine's .init_machine hook. The calls are placed in link order (common.c, pm.c, phy3250.c) to keep their previous relative ordering.
--- arch/arm/mach-lpc32xx/common.c | 5 +---- arch/arm/mach-lpc32xx/common.h | 2 ++ arch/arm/mach-lpc32xx/phy3250.c | 2 ++ arch/arm/mach-lpc32xx/pm.c | 5 +---- 4 files changed, 6 insertions(+), 8 deletions(-)
arch/arm/mach-lpc32xx/common.c +1 -4
@@ -106,7 +106,7 @@ void __init lpc32xx_map_io(void)iotable_init (lpc32xx_io_desc,ARRAY_SIZE (lpc32xx_io_desc)); } -static int __init lpc32xx_check_uid (void ) +void __init lpc32xx_check_uid (void ) {u32 uid[4 ];
@@ -119,7 +119,4 @@ static int __init lpc32xx_check_uid(void) system_serial_low = uid[0 ]; system_serial_high = uid[1 ]; } - -return 1 ; } -arch_initcall (lpc32xx_check_uid);
arch/arm/mach-lpc32xx/common.h +2 -0
@@ -16,6 +16,8 @@* Other arch specific structures and functions */ extern void __init lpc32xx_map_io (void ); +extern void __init lpc32xx_check_uid (void ); +extern void __init lpc32xx_pm_init (void );extern void __init lpc32xx_serial_init (void );/*
arch/arm/mach-lpc32xx/phy3250.c +2 -0
@@ -71,6 +71,8 @@ static const struct of_dev_auxdata lpc32xx_auxdata_lookup[] __initconst = {static void __init lpc3250_machine_init (void ) { +lpc32xx_check_uid (); +lpc32xx_pm_init ();lpc32xx_serial_init ();of_platform_default_populate (NULL , lpc32xx_auxdata_lookup,NULL );
arch/arm/mach-lpc32xx/pm.c +1 -4
@@ -120,7 +120,7 @@ static const struct platform_suspend_ops lpc32xx_pm_ops = {#define EMC_DYN_MEM_CTRL_OFS 0x20#define EMC_SRMMC (1 << 3)#define EMC_CTRL_REG io_p2v(LPC32XX_EMC_BASE + EMC_DYN_MEM_CTRL_OFS) -static int __init lpc32xx_pm_init (void ) +void __init lpc32xx_pm_init (void ) {/* * Setup SDRAM self-refresh clock to automatically disable o
@@ -129,7 +129,4 @@ static int __init lpc32xx_pm_init(void)__raw_writel (__raw_readl (EMC_CTRL_REG ) |EMC_SRMMC ,EMC_CTRL_REG );suspend_set_ops (&lpc32xx_pm_ops); - -return 0 ; } -arch_initcall (lpc32xx_pm_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 600/935 power: supply: sbs-battery: Use a per-device serial number buffer
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Babanpreet Singh <[email protected]>
[ Upstream commit 6027892925b8d19d2245c2d077e2ae35b49cc2b1 ]
sbs_get_battery_serial_number() formats the battery serial number into sbs_serial[], a single file-scope buffer shared by every sbs-battery instance, and points val->strval at it.
Nothing restricts this driver to one instance. It binds per I2C client, and sbs-manager registers one muxed I2C channel per supported battery specifically so that the smart battery driver can be bound to each of them, so several sbs-battery instances on one system is a supported configuration.
The power supply core reads strval after the driver's get_property() callback has returned: power_supply_show_property() fills a local union power_supply_propval, then formats it with sysfs_emit(). Two concurrent POWER_SUPPLY_PROP_SERIAL_NUMBER reads on different batteries therefore race for the shared buffer - battery B's sprintf() can land between battery A filling the buffer and the core reading it, and battery A then reports battery B's serial number.
Move the buffer into struct sbs_info so that each battery formats into its own storage. It is deliberately not added to the chip->strings[]
array: those entries hold the cached constant strings that sbs_invalidate_cached_props() clears on presence changes, whereas the serial number is re-read from its word register on every access.
--- drivers/power/supply/sbs-battery.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/power/supply/sbs-battery.c +4 -3
@@ -216,6 +216,7 @@ struct sbs_info {u32 flags;int technology;char strings[NR_STRING_BUFFERS ][I2C_SMBUS_BLOCK_MAX +1 ]; +char serial[5 ]; }; static char *sbs_get_string_buf(struct sbs_info *chip,
@@ -820,18 +821,18 @@ static int sbs_get_battery_capacity(struct i2c_client *client,return 0 ; } -static char sbs_serial[5 ];static int sbs_get_battery_serial_number (struct i2c_client *client,union power_supply_propval *val) { +struct sbs_info *chip =i2c_get_clientdata (client);int ret; ret =sbs_read_word_data (client, sbs_data[REG_SERIAL_NUMBER ].addr);if (ret <0 )return ret; -sprintf (sbs_serial,"%04x" , ret); - val->strval = sbs_serial; +sprintf (chip->serial,"%04x" , ret); + val->strval = chip->serial;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 601/935 crypto: keembay - Initialize completion before requesting IRQ
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit fce20289dd622cc7ab78d72c8a979a9f8b7cb10e ]
kmb_ocs_aes_probe() requests the device IRQ before initializing irq_completion. Once the handler is registered it can run immediately, and ocs_aes_irq_handler() unconditionally calls complete(). An interrupt in this window would therefore use an uninitialized completion.
Initialize the completion before requesting the IRQ, as the sibling OCS HCU and ECC drivers already do.
--- drivers/crypto/keembay/keembay-ocs-aes-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/keembay/keembay-ocs-aes-core.c +2 -2
@@ -1626,6 +1626,8 @@ static int kmb_ocs_aes_probe(struct platform_device *pdev)if (IS_ERR (aes_dev->base_reg))return PTR_ERR (aes_dev->base_reg); +init_completion (&aes_dev->irq_completion); +/* Get and request IRQ */ aes_dev->irq =platform_get_irq (pdev,0 );if (aes_dev->irq <0 )
@@ -1643,8 +1645,6 @@ static int kmb_ocs_aes_probe(struct platform_device *pdev)list_add_tail (&aes_dev->list, &ocs_aes.dev_list);spin_unlock (&ocs_aes.lock); -init_completion (&aes_dev->irq_completion); -/* Initialize crypto engine */ aes_dev->engine =crypto_engine_alloc_init (dev, true);if (!aes_dev->engine) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 602/935 crypto: keembay - publish OF module alias for OCS AES/SM4
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Can Peng <[email protected]>
[ Upstream commit 0a94091e29f914e4f233a208599ca4055882c01b ]
The Keem Bay OCS AES/SM4 driver has an OF match table wired to .of_match_table, but does not export the table with MODULE_DEVICE_TABLE().
Although the match table lives in keembay-ocs-aes-core.o, that object is part of the composite keembay-ocs-aes module. Add the missing MODULE_DEVICE_TABLE(of, ...) entry so modpost can generate OF module alias information for OF based module autoloading.
This is a source-level fix. It does not claim dynamic hardware reproduction; the evidence is the driver-owned match table, its use by the platform driver, and the missing module alias publication.
--- drivers/crypto/keembay/keembay-ocs-aes-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/keembay/keembay-ocs-aes-core.c +1 -0
@@ -1574,6 +1574,7 @@ static const struct of_device_id kmb_ocs_aes_of_match[] = { }, {} }; +MODULE_DEVICE_TABLE (of, kmb_ocs_aes_of_match);static int kmb_ocs_aes_remove (struct platform_device *pdev) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 603/935 RDMA/mlx5: Fix integer overflow of user QP buffer size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maher Sanalla <[email protected]>
[ Upstream commit dec47e4b0fe34afdf38caa72b4408ba95502e5de ]
set_user_buf_size() computes the QP buffer size by left-shifting the user-supplied rq.wqe_cnt and rq.wqe_shift values as signed integers. A sufficiently large rq.wqe_cnt causes signed integer overflow, which is undefined behavior, and yields a small or negative buf_size, causing ib_umem_get() to map a buffer smaller than the hardware will actually write into.
Replace the shifts and addition with check_shl_overflow() and check_add_overflow(), rejecting invalid user inputs.
Moreover, guard the identical shift computing qp->sq.offset in _create_user_qp() before set_user_buf_size() is reached.
--- drivers/infiniband/hw/mlx5/qp.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +20 -5
@@ -590,6 +590,7 @@ static int set_user_buf_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr) {int desc_sz =1 << qp->sq.wqe_shift; +int rq_buf_size, sq_buf_size;if (desc_sz >MLX5_CAP_GEN (dev->mdev, max_wqe_sz_sq)) { mlx5_ib_warn(dev, "desc_sz %d, max_sq_desc_sz %d\n",
@@ -614,11 +615,21 @@ static int set_user_buf_size(struct mlx5_ib_dev *dev,if (attr->qp_type ==IB_QPT_RAW_PACKET || qp->flags &IB_QP_CREATE_SOURCE_QPN ) { - base->ubuffer.buf_size = qp->rq.wqe_cnt << qp->rq.wqe_shift; - qp->raw_packet_qp.sq.ubuffer.buf_size = qp->sq.wqe_cnt <<6 ; +if (check_shl_overflow (qp->rq.wqe_cnt, qp->rq.wqe_shift, + &base->ubuffer.buf_size)) +return -EINVAL ; +if (check_shl_overflow (qp->sq.wqe_cnt,6 , + &qp->raw_packet_qp.sq.ubuffer.buf_size)) +return -EINVAL ; }else { - base->ubuffer.buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) + - (qp->sq.wqe_cnt <<6 ); +if (check_shl_overflow (qp->rq.wqe_cnt, qp->rq.wqe_shift, + &rq_buf_size)) +return -EINVAL ; +if (check_shl_overflow (qp->sq.wqe_cnt,6 , &sq_buf_size)) +return -EINVAL ; +if (check_add_overflow (rq_buf_size, sq_buf_size, + &base->ubuffer.buf_size)) +return -EINVAL ; }return 0 ;
@@ -941,7 +952,11 @@ static int _create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd, qp->rq.offset =0 ; qp->sq.wqe_shift =ilog2 (MLX5_SEND_WQE_BB ); - qp->sq.offset = qp->rq.wqe_cnt << qp->rq.wqe_shift; +if (check_shl_overflow (qp->rq.wqe_cnt, qp->rq.wqe_shift, + &qp->sq.offset)) { + err = -EINVAL ; + goto err_bfreg; + } err =set_user_buf_size (dev, qp, ucmd, base, attr);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 604/935 isofs: release zisofs block pointer buffer head
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit 2f7dd9b86fe4076059e6a4a2a2c5d565afd76b9e ]
zisofs_fill_pages() reads the compressed block pointer table. The error paths release the current buffer_head, the loop also releases the old buffer_head when it advances. However, the success path leaves the last buffer_head referenced. Release it before returning success.
--- fs/isofs/compress.c | 1 + 1 file changed, 1 insertion(+)
fs/isofs/compress.c +1 -0
@@ -293,6 +293,7 @@ static int zisofs_fill_pages(struct inode *inode, int full_page, int pcount,memzero_page (*pages, poffset,PAGE_SIZE - poffset);SetPageUptodate (*pages); } +brelse (bh);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 605/935 w1: ds2482: Fix signedness bug in ds2482_w1_triplet()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Babanpreet Singh <[email protected]>
[ Upstream commit 4d3721b204f961e905714954ff95633337b768e3 ]
ds2482_wait_1wire_idle() returns the status register value (0..255) on success, or a negative value on I2C failure: -1 when selecting the status register fails, or a negative errno from i2c_smbus_read_byte().
ds2482_w1_triplet() feeds that result into "return (status >> 5);" without checking for errors, and the function returns u8. For a negative status the arithmetic shift keeps the sign and the u8 truncation fabricates a triplet result whose meaning depends on the errno value: -1 and -EIO happen to become 0xff, whose set low bits make w1_search() abort, but -ETIMEDOUT (-110 >> 5 = -4) becomes 0xfc - "devices responded on both branches, wrote 1" - and -EOPNOTSUPP (-95 >> 5 = -3) becomes 0xfd - "only the zero branch responded". w1_search() then continues the ROM search with a fabricated direction bit instead of aborting, and the corrupted id is either rejected by the ROM CRC (existing device missed) or registers a phantom slave.
The function already defines an in-band error value: status is initialized to (3 << 5), which decodes to 3 (both branch bits set, "no device responded") and makes w1_search() terminate the search when sending the triplet command fails. Decode a negative status to the same value.
Found by smatch:drivers/w1/masters/ds2482.c:314 ds2482_w1_triplet() warn: signedness bug returning '(-67108864)'
--- drivers/w1/masters/ds2482.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/w1/masters/ds2482.c +4 -0
@@ -312,6 +312,10 @@ static u8 ds2482_w1_triplet(void *data, u8 dbit)mutex_unlock (&pdev->access_lock); +/* On bus error, decode to 3 (no device responded) to abort the search */ +if (status <0 ) + status =3 <<5 ; +/* Decode the status */ return (status >>5 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 606/935 remoteproc: Use unbounded workqueue for recovery work
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit cab8300b5621a54aa25306ff800c27fa5a4632d7 ]
There could be a scenario when there is too much load on a core (n number of tasks which is affined) or in a case when multiple rproc subsystem is going for recovery, they queue their recovery work to one core so even though subsystem are independent their recovery will be delayed if one of the subsystem recovery work is taking more time in completing.
If we make this queue unbounded, the recovery work could be picked on any cpu. This patch is trying to address this.
Stable-dep-of: 74ee3b2f5767 ("remoteproc: Prevent crash handling to race with rproc_del()")
--- drivers/remoteproc/remoteproc_core.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/remoteproc/remoteproc_core.c +13 -2
@@ -59,6 +59,7 @@ static int rproc_release_carveout(struct rproc *rproc,/* Unique indices for remoteproc devices */ static DEFINE_IDA (rproc_dev_index); +static struct workqueue_struct *rproc_recovery_wq;static const char *const rproc_crash_names[] = { [RPROC_MMUFAULT ] ="mmufault" ,
@@ -2760,8 +2761,7 @@ void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type)dev_err (&rproc->dev,"crash detected in %s: type %s\n" , rproc->name,rproc_crash_to_string (type)); -/* Have a worker handle the error; ensure system is not suspended */ -queue_work (system_freezable_wq, &rproc->crash_handler); +queue_work (rproc_recovery_wq, &rproc->crash_handler); }EXPORT_SYMBOL (rproc_report_crash);
@@ -2810,6 +2810,13 @@ static void __exit rproc_exit_panic(void)static int __init remoteproc_init (void ) { + rproc_recovery_wq =alloc_workqueue ("rproc_recovery_wq" , +WQ_UNBOUND |WQ_FREEZABLE ,0 ); +if (!rproc_recovery_wq) { +pr_err ("remoteproc: creation of rproc_recovery_wq failed\n" ); +return -ENOMEM ; + } +rproc_init_sysfs ();rproc_init_debugfs ();rproc_init_cdev ();
@@ -2823,9 +2830,13 @@ static void __exit remoteproc_exit(void) {ida_destroy (&rproc_dev_index); +if (!rproc_recovery_wq) +return ; +rproc_exit_panic ();rproc_exit_debugfs ();rproc_exit_sysfs (); +destroy_workqueue (rproc_recovery_wq); }module_exit (remoteproc_exit);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 607/935 remoteproc: core: Attach rproc asynchronously in rproc_add() path via schedule_work()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jingyi Wang <[email protected]>
[ Upstream commit 026a3fada43261e403c6c4d9bda9501547e3f108 ]
Unlike the remoteproc firmware load path where rproc_add() call rproc_auto_boot_callback() asynchronously and ignores the return value of rproc_boot(), the attach path calls rproc_boot() synchronously and propagates its return value back to rproc_add(). This means a failure during rproc_attach() causes rproc_add() to fail and triggers resource release, removing the remoteproc from sysfs and making it unavailable for recovery or further boot attempts.
Align the remoteproc attach path with the firmware load path by introducing attach_work and scheduling rproc_boot() asynchronously via schedule_work(). This keeps the remoteproc registered and available in sysfs even if the initial attach attempt fails, and avoids blocking rproc_add() on the attach result.
Stable-dep-of: 74ee3b2f5767 ("remoteproc: Prevent crash handling to race with rproc_del()")
--- drivers/remoteproc/remoteproc_core.c | 20 ++++++++++++-------- include/linux/remoteproc.h | 2 ++ 2 files changed, 14 insertions(+), 8 deletions(-)
drivers/remoteproc/remoteproc_core.c +12 -8
@@ -1788,18 +1788,21 @@ static void rproc_auto_boot_callback(const struct firmware *fw, void *context)release_firmware (fw); } +static void rproc_attach_work (struct work_struct *work) +{ + struct rproc *rproc = container_of(work, struct rproc, attach_work); + +rproc_boot (rproc); +} +static int rproc_trigger_auto_boot (struct rproc *rproc) {int ret; -/* -* Since the remote processor is in a detached state, it has already -* been booted by another entity. As such there is no point in waiting -* for a firmware image to be loaded, we can simply initiate the process -* of attaching to it immediately. -*/ -if (rproc->state ==RPROC_DETACHED ) -return rproc_boot (rproc); +if (rproc->state ==RPROC_DETACHED ) { +schedule_work (&rproc->attach_work); +return 0 ; + }/* * We're initiating an asynchronous firmware loading, so we can
@@ -2570,6 +2573,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,INIT_LIST_HEAD (&rproc->dump_segments);INIT_WORK (&rproc->crash_handler, rproc_crash_handler_work); +INIT_WORK (&rproc->attach_work, rproc_attach_work); rproc->state =RPROC_OFFLINE ;
include/linux/remoteproc.h +2 -0
@@ -512,6 +512,7 @@ struct rproc_dump_segment {* @subdevs: list of subdevices, to following the running state * @notifyids: idr for dynamically assigning rproc-wide unique notify ids * @index: index of this rproc device +* @attach_work: workqueue for attaching rproc * @crash_handler: workqueue for handling a crash * @crash_cnt: crash counter * @recovery_disabled: flag that state if recovery was disabled
@@ -552,6 +553,7 @@ struct rproc {struct list_head subdevs;struct idr notifyids;int index; +struct work_struct attach_work;struct work_struct crash_handler;unsigned int crash_cnt;bool recovery_disabled;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 608/935 remoteproc: Prevent crash handling to race with rproc_del()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
[ Upstream commit 74ee3b2f5767447c57959994341e5b95f1079977 ]
There's no synchronization between rproc_crash_handler_work() and rproc_del(), as such it's possible for a driver to be removed while crash-handler work is scheduled, or even executing - resulting in use-after-free issues.
To avoid this the scheduled work need to be cancelled and synchronized against before the removal proceeds.
In order to ensure that this doesn't race with the reporting, and thereby scheduling new work, a "deleting" flag is introduced. This is similar to the RPROC_DELETE state that was introduced to ensure that "start" didn't race with rproc_del(), but the existing mechanism can not be used as it's valid to call rproc_report_crash() in atomic context - and the "state" is protected by a mutex.
In the event that work is cancelled the pm_stay_awake() is left unbalanced and need to be unrolled.
The blocking and cancelling of crash-handler work prior to the actual rproc_shutdown() call does have the explicit side-effect that crashes resulting from the shutdown process will not enter the crash-handling path, and as such will not generate devcoredumps etc. Due to the existing mutual exclusion between these code paths there's no concrete reduction in functionality, but further work would be needed to handle this case.
--- drivers/remoteproc/remoteproc_core.c | 42 +++++++++++++++++++++------ drivers/remoteproc/remoteproc_sysfs.c | 1 - include/linux/remoteproc.h | 13 +++++---- 3 files changed, 41 insertions(+), 15 deletions(-)
drivers/remoteproc/remoteproc_core.c +33 -9
@@ -1913,6 +1913,11 @@ int rproc_trigger_recovery(struct rproc *rproc)if (ret)return ret; +if (READ_ONCE (rproc->deleting)) { + ret = -ENODEV ; + goto unlock_mutex; + } +/* State could have changed before we got the mutex */ if (rproc->state !=RPROC_CRASHED ) goto unlock_mutex;
@@ -1959,6 +1964,11 @@ static void rproc_crash_handler_work(struct work_struct *work)mutex_lock (&rproc->lock); +if (READ_ONCE (rproc->deleting)) { +mutex_unlock (&rproc->lock); + goto out; + } +if (rproc->state ==RPROC_CRASHED ) {/* handle only the first crash detected */ mutex_unlock (&rproc->lock);
@@ -2014,9 +2024,9 @@ int rproc_boot(struct rproc *rproc)return ret; } -if (rproc->state ==RPROC_DELETED ) { +if (READ_ONCE (rproc->deleting)) { ret = -ENODEV ; -dev_err (dev,"can't boot deleted rproc %s\n" , rproc->name); +dev_err (dev,"can't boot deleting rproc %s\n" , rproc->name); goto unlock_mutex; }
@@ -2572,8 +2582,9 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,INIT_LIST_HEAD (&rproc->subdevs);INIT_LIST_HEAD (&rproc->dump_segments); -INIT_WORK (&rproc->crash_handler, rproc_crash_handler_work);INIT_WORK (&rproc->attach_work, rproc_attach_work); +INIT_WORK (&rproc->crash_handler, rproc_crash_handler_work); +spin_lock_init (&rproc->crash_handler_lock); rproc->state =RPROC_OFFLINE ;
@@ -2633,16 +2644,21 @@ EXPORT_SYMBOL(rproc_put);*/ int rproc_del (struct rproc *rproc) { +unsigned long flags; +if (!rproc)return -EINVAL ; +spin_lock_irqsave (&rproc->crash_handler_lock, flags); +WRITE_ONCE (rproc->deleting, true); +spin_unlock_irqrestore (&rproc->crash_handler_lock, flags); + +if (cancel_work_sync (&rproc->crash_handler)) +pm_relax (rproc->dev.parent); +/* TODO: make sure this works with rproc->power > 1 */ rproc_shutdown (rproc); -mutex_lock (&rproc->lock); - rproc->state =RPROC_DELETED ; -mutex_unlock (&rproc->lock); -rproc_delete_debug_dir (rproc);/* the rproc is downref'ed as soon as it's removed from the klist */
@@ -2754,18 +2770,26 @@ EXPORT_SYMBOL(rproc_get_by_child);*/ void rproc_report_crash (struct rproc *rproc,enum rproc_crash_type type) { +unsigned long flags; +if (!rproc) {pr_err ("NULL rproc pointer\n" );return ; } +spin_lock_irqsave (&rproc->crash_handler_lock, flags); +if (READ_ONCE (rproc->deleting)) { +spin_unlock_irqrestore (&rproc->crash_handler_lock, flags); +return ; + } +/* Prevent suspend while the remoteproc is being recovered */ pm_stay_awake (rproc->dev.parent); +queue_work (rproc_recovery_wq, &rproc->crash_handler); +spin_unlock_irqrestore (&rproc->crash_handler_lock, flags);dev_err (&rproc->dev,"crash detected in %s: type %s\n" , rproc->name,rproc_crash_to_string (type)); - -queue_work (rproc_recovery_wq, &rproc->crash_handler); }EXPORT_SYMBOL (rproc_report_crash);
drivers/remoteproc/remoteproc_sysfs.c +0 -1
@@ -168,7 +168,6 @@ static const char * const rproc_state_string[] = { [RPROC_SUSPENDED] = "suspended", [RPROC_RUNNING] = "running", [RPROC_CRASHED] = "crashed", - [RPROC_DELETED] = "deleted", [RPROC_ATTACHED] = "attached", [RPROC_DETACHED] = "detached", [RPROC_LAST] = "invalid",
include/linux/remoteproc.h +8 -5
@@ -37,6 +37,7 @@#include <linux/types.h> #include <linux/mutex.h> +#include <linux/spinlock.h> #include <linux/virtio.h> #include <linux/cdev.h> #include <linux/completion.h>
@@ -412,7 +413,6 @@ struct rproc_ops {* a message. * @RPROC_RUNNING: device is up and running * @RPROC_CRASHED: device has crashed; need to start recovery -* @RPROC_DELETED: device is deleted * @RPROC_ATTACHED: device has been booted by another entity and the core * has attached to it * @RPROC_DETACHED: device has been booted by another entity and waiting
@@ -430,10 +430,9 @@ enum rproc_state {RPROC_SUSPENDED =1 ,RPROC_RUNNING =2 ,RPROC_CRASHED =3 , -RPROC_DELETED =4 , -RPROC_ATTACHED =5 , -RPROC_DETACHED =6 , - RPROC_LAST = 7, +RPROC_ATTACHED =4 , +RPROC_DETACHED =5 , + RPROC_LAST = 6, };/**
@@ -514,6 +513,8 @@ struct rproc_dump_segment {* @index: index of this rproc device * @attach_work: workqueue for attaching rproc * @crash_handler: workqueue for handling a crash +* @crash_handler_lock: serializes crash handler queueing and deletion +* @deleting: remoteproc deletion has begun * @crash_cnt: crash counter * @recovery_disabled: flag that state if recovery was disabled * @max_notifyid: largest allocated notify id.
@@ -555,6 +556,8 @@ struct rproc {int index;struct work_struct attach_work;struct work_struct crash_handler; +spinlock_t crash_handler_lock; +bool deleting;unsigned int crash_cnt;bool recovery_disabled;int max_notifyid;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 609/935 staging: rtl8723bs: use kfree_sensitive() for key material
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivy Lopez <[email protected]>
[ Upstream commit d205dfa8cb825f1954ca1cfa474fc50bf06ee4aa ]
The set_stakey_parm struct contains a 16-byte encryption key. Use kfree_sensitive() instead of kfree() to ensure the key material is zeroed before the memory is freed, preventing potential information leaks.
--- drivers/staging/rtl8723bs/core/rtw_cmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +4 -4
@@ -933,7 +933,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_if (enqueue) { ph2c =rtw_zmalloc (sizeof (struct cmd_obj ));if (!ph2c) { -kfree (psetstakey_para); +kfree_sensitive (psetstakey_para); res = _FAIL; goto exit; }
@@ -941,7 +941,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ psetstakey_rsp =rtw_zmalloc (sizeof (struct set_stakey_rsp ));if (!psetstakey_rsp) {kfree (ph2c); -kfree (psetstakey_para); +kfree_sensitive (psetstakey_para); res = _FAIL; goto exit; }
@@ -952,7 +952,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ res =rtw_enqueue_cmd (pcmdpriv, ph2c); }else {set_stakey_hdl (padapter, (u8 *)psetstakey_para); -kfree (psetstakey_para); +kfree_sensitive (psetstakey_para); } exit:return res;
@@ -992,7 +992,7 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu psetstakey_rsp =rtw_zmalloc (sizeof (struct set_stakey_rsp ));if (!psetstakey_rsp) {kfree (ph2c); -kfree (psetstakey_para); +kfree_sensitive (psetstakey_para); res = _FAIL; goto exit; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 610/935 fs/ntfs3: reject restart table growth beyond U16_MAX entries
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 111f8d74a19d85942ecbb3aba78f6f3c88e59391 ]
During $LogFile replay, log_replay() indexes the transaction table by the transact_id taken from the log record header. check_log_rec() only verifies that transact_id is non-zero and properly aligned, not its magnitude, so a crafted image can request an arbitrarily large index.
alloc_rsttbl_from_idx() grows the table to cover that index via extend_rsttbl(), which passes the new entry count to init_rsttbl():
rt = init_rsttbl(esize, used + add);
used + add is computed as u32 but init_rsttbl() takes a u16, and the count is stored in struct RESTART_TABLE as a __le16. When used + add exceeds U16_MAX it is truncated, init_rsttbl() allocates a table far smaller than the index requires, and alloc_rsttbl_from_idx() then dereferences and writes at the original, untruncated offset -- an out-of-bounds access past the allocation, reachable by mounting a crafted NTFS image.
BUG: KASAN: use-after-free in alloc_rsttbl_from_idx (fs/ntfs3/fslog.c:950) Read of size 4 at addr ffff8880327ffff8 by task exploit alloc_rsttbl_from_idx (fs/ntfs3/fslog.c:950) log_replay (fs/ntfs3/fslog.c:4562) ntfs_loadlog_and_replay (fs/ntfs3/fsntfs.c:324) ntfs_fill_super (fs/ntfs3/super.c:1393) get_tree_bdev_flags vfs_get_tree path_mount __x64_sys_mount
A restart table is limited to U16_MAX entries by its __le16 count, so a larger growth request is invalid input. Reject it in extend_rsttbl(); all callers already handle a NULL return.
--- fs/ntfs3/fslog.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/fslog.c +3 -0
@@ -875,6 +875,9 @@ static inline struct RESTART_TABLE *extend_rsttbl(struct RESTART_TABLE *tbl,u32 used =le16_to_cpu (tbl->used);struct RESTART_TABLE *rt; +if (used + add >U16_MAX ) +return NULL ; + rt =init_rsttbl (esize, used + add);if (!rt)return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 611/935 RDMA/efa: Fix PBL chunk length computation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonatan Nachum <[email protected]>
[ Upstream commit 229b42d7450c1cf96f45ec39ebb69211b06bc036 ]
On register MR, when creating the PBL, if it's an indirect PBL we create a chunk list to hold the PBL pages pointers. Each chunk is 4KB in size and can hold 510 addresses (EFA_PTRS_PER_CHUNK) and has a 12-byte control buffer at the end of it holding the next chunk's pointer and its length.
If the PBL number of pages is a multiple of EFA_PTRS_PER_CHUNK, the calculated last chunk length is wrongly computed as 0, even though that chunk is fully populated with 510 real page pointers. This wrong length is used both to DMA map the chunk and is propagated to the device, causing the device to see the chunk as empty and reject the memory registration.
Fix the calculation so it will be performed only if the number of pages isn't a multiple of EFA_PTRS_PER_CHUNK, if it is, its already handled in the above loop correctly.
Also prevent out-of-bounds reach in the chunks array in such scenario.
--- drivers/infiniband/hw/efa/efa_verbs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/infiniband/hw/efa/efa_verbs.c +9 -4
@@ -1223,9 +1223,11 @@ static int pbl_chunk_list_create(struct efa_dev *dev, struct pbl_context *pbl) chunk_list->chunks[i].length =EFA_CHUNK_USED_SIZE ; } - chunk_list->chunks[chunk_list_size -1 ].length = - ((page_cnt %EFA_PTRS_PER_CHUNK ) *EFA_CHUNK_PAYLOAD_PTR_SIZE ) + -EFA_CHUNK_PTR_SIZE ; + +if (page_cnt %EFA_PTRS_PER_CHUNK !=0 ) + chunk_list->chunks[chunk_list_size -1 ].length = + ((page_cnt %EFA_PTRS_PER_CHUNK ) *EFA_CHUNK_PAYLOAD_PTR_SIZE ) + +EFA_CHUNK_PTR_SIZE ;/* fill the dma addresses of sg list pages to chunks: */ chunk_idx =0 ;
@@ -1237,9 +1239,12 @@ static int pbl_chunk_list_create(struct efa_dev *dev, struct pbl_context *pbl)rdma_block_iter_dma_address (&biter);if (payload_idx ==EFA_PTRS_PER_CHUNK ) { + payload_idx =0 ; chunk_idx++; +if (chunk_idx >= chunk_list_size) +break ; + cur_chunk_buf = chunk_list->chunks[chunk_idx].buf; - payload_idx =0 ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 612/935 arm64: dts: allwinner: sun50i-a64-pinephone: Fix mpu6050 mount matrix
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ondrej Jirman <[email protected]>
[ Upstream commit dfc735fd93e4814e65894916ec5f807f25a391d1 ]
The current mount matrix for mpu6050 is wrong. The mount matrix is a simple transform from the sensor coordinate space to the device coordinate space described in DT, where, looking at the screen, X points to the right, Y to the top, and Z towards the user.
The mpu6050 is mounted like this (looking at the screen from the front; the sensor is on the near side of the PCB, so its Z axis points towards the user; o marks the pin 1 corner):
+Xs
^
|
+------+
+Ys <--| |
| o |
+------+so this gives:
Xd = -Ys [0, -1, 0] Yd = Xs [1, 0, 0] Zd = Zs [0, 0, 1]
--- arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi +2 -2
@@ -200,8 +200,8 @@ accelerometer@68 { interrupts = <7 5 IRQ_TYPE_EDGE_RISING>; /* PH5 */ vdd-supply = <®_dldo1>; vddio-supply = <®_dldo1>; - mount-matrix = "0", "1", "0", - "-1", "0", "0", + mount-matrix = "0", "-1", "0", + "1", "0", "0", "0", "0", "1"; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 613/935 clk: tegra: tegra124-emc: put EMC node on register failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit f726279f5eab813f9a8b6f38ddf2a4b062d038ff ]
tegra124_clk_register_emc() stores a device node reference returned by of_parse_phandle() in tegra->emc_node.
If clk_register() fails, the function returns an error before that reference can be consumed and released by the normal runtime path. The tegra_clk_emc object is freed on this failure path, but freeing the object does not drop the OF node reference stored in it.
Drop the EMC node reference before freeing the tegra_clk_emc object. of_node_put() is safe for a NULL node, so this also covers the case where the phandle is absent.
--- drivers/clk/tegra/clk-tegra124-emc.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/tegra/clk-tegra124-emc.c +1 -0
@@ -539,6 +539,7 @@ struct clk *tegra124_clk_register_emc(void __iomem *base, struct device_node *np clk =clk_register (NULL , &tegra->hw);if (IS_ERR (clk)) { +of_node_put (tegra->emc_node);kfree (tegra);return clk; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 614/935 clk: palmas: Manage external-control prepare with devm
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit ccda84fcbf3a972973f772384935928f41817b3a ]
palmas_clks_init_configure() prepares the clock when an external control pin is configured. The current driver only drops that prepare reference when external control configuration fails.
If provider registration fails after that point, or if the driver is later removed, the prepare reference remains held.
Register a device-managed action after clk_prepare() succeeds. This balances the prepare reference on subsequent probe failure and driver removal.
--- drivers/clk/clk-palmas.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/clk/clk-palmas.c +13 -1
@@ -195,6 +195,13 @@ static void palmas_clks_get_clk_data(struct platform_device *pdev, cinfo->ext_control_pin = prop; } +static void palmas_clks_unprepare_ext_control (void *data) +{ +struct palmas_clock_info *cinfo = data; + +clk_unprepare (cinfo->hw.clk); +} +static int palmas_clks_init_configure (struct palmas_clock_info *cinfo) {int ret;
@@ -215,13 +222,18 @@ static int palmas_clks_init_configure(struct palmas_clock_info *cinfo)return ret; } + ret =devm_add_action_or_reset (cinfo->dev, + palmas_clks_unprepare_ext_control, + cinfo); +if (ret) +return ret; + ret =palmas_ext_control_req_config (cinfo->palmas, cinfo->clk_desc->sleep_reqstr_id, cinfo->ext_control_pin, true);if (ret <0 ) {dev_err (cinfo->dev,"Ext config for %s failed, %d\n" , cinfo->clk_desc->clk_name, ret); -clk_unprepare (cinfo->hw.clk);return ret; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 615/935 clk/x86: pmc_atom: add kasprintf return value check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: longlong yan <[email protected]>
[ Upstream commit 18e9d14cbac33db1c1fb933c26a736eef53dd538 ]
The kasprintf() function returns NULL on memory allocation failure, but the code in plt_clk_register() was not checking this return value. If kasprintf fails, init.name would be NULL and could cause NULL pointer dereference when clkdev_hw_create() uses it.
Add proper error checking for the kasprintf() return value and return ERR_PTR(-ENOMEM) on failure.
--- drivers/clk/x86/clk-pmc-atom.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/x86/clk-pmc-atom.c +3 -0
@@ -171,6 +171,9 @@ static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id,return ERR_PTR (-ENOMEM ); init.name =kasprintf (GFP_KERNEL ,"%s_%d" ,PLT_CLK_NAME_BASE , id); +if (!init.name) +return ERR_PTR (-ENOMEM ); + init.ops = &plt_clk_ops; init.flags =0 ; init.parent_names = parent_names;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 616/935 nilfs2: fix infinite loop in nilfs_clean_segments()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Crofts <[email protected]>
[ Upstream commit ce5a5ad1a8330a2fcfdd9ec2ab341be739e89a18 ]
syzbot reported a hung task in nilfs_transaction_begin(). This occurs because the cleaner ioctl falls into an infinite loop if nilfs_segctor_construct() repeatedly returns -EROFS (e.g. the device is remounted as read-only after an I/O error).
Currently in nilfs_clean_segments(), if err is non-zero, it logs the error and sleeps but doesn't abort when it encounters a terminal error like -EROFS. This causes the thread to loop forever.
Fix this by breaking out of the loop if nilfs_segctor_construct() returns -EROFS. This matches the behaviour in nilfs_segctor_write_out(), which also handles -EROFS.
--- fs/nilfs2/segment.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nilfs2/segment.c +4 -0
@@ -2554,6 +2554,10 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,break ;nilfs_warn (sb,"error %d cleaning segments" , err); + +if (unlikely (err == -EROFS )) + goto out_unlock; +set_current_state (TASK_INTERRUPTIBLE );schedule_timeout (sci->sc_interval); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 617/935 nilfs2: prevent out-of-bounds read in super root block parsing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lee <[email protected]>
[ Upstream commit 7cb2f76a6a2ba2130b577cb8ac13e1e46c4fc689 ]
super-root inode metadata size is trusted before nilfs_read_inode_common().
Reject super-root inode sizes whose computed on-disk footprint exceeds the filesystem block size. This prevents malformed filesystem images from making nilfs_read_inode_common() read past the end of the super-root block.
[ryusuke: clarify the commit title]
--- fs/nilfs2/the_nilfs.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/nilfs2/the_nilfs.c +6 -0
@@ -450,6 +450,12 @@ static int nilfs_store_disk_layout(struct the_nilfs *nilfs, nilfs->ns_inode_size);return -EINVAL ; } +if (NILFS_SR_BYTES (nilfs->ns_inode_size) > nilfs->ns_blocksize) { +nilfs_err (nilfs->ns_sb, +"too large inode size for super root: %d bytes" , + nilfs->ns_inode_size); +return -EINVAL ; + } nilfs->ns_first_ino =le32_to_cpu (sbp->s_first_ino);if (nilfs->ns_first_ino <NILFS_USER_INO ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 618/935 scsi: smartpqi: Capture controller reason codes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Murthy Bhat <[email protected]>
[ Upstream commit 5d1f03e6f49ae80d417dc72d1ee16a3379e2c026 ]
In some rare cases, the driver can halt the controller. Add a reason code describing why the controller was halted. Store this reason code in a controller register to aid in debugging the issue.
Stable-dep-of: 225548863f0a ("scsi: smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches.")
--- drivers/scsi/smartpqi/smartpqi.h | 25 +++++++++++++++-- drivers/scsi/smartpqi/smartpqi_init.c | 40 ++++++++++++++++++--------- drivers/scsi/smartpqi/smartpqi_sis.c | 9 ++++-- drivers/scsi/smartpqi/smartpqi_sis.h | 3 +- 4 files changed, 57 insertions(+), 20 deletions(-)
drivers/scsi/smartpqi/smartpqi.h +22 -3
@@ -82,9 +82,11 @@ struct pqi_ctrl_registers {__le32 sis_product_identifier;/* B4h */ u8 reserved5[0xbc - (0xb4 +sizeof (__le32))];__le32 sis_firmware_status;/* BCh */ -u8 reserved6[0x1000 - (0xbc +sizeof (__le32))]; +u8 reserved6[0xcc - (0xbc +sizeof (__le32))]; +__le32 sis_ctrl_shutdown_reason_code;/* CCh */ +u8 reserved7[0x1000 - (0xcc +sizeof (__le32))];__le32 sis_mailbox[8 ];/* 1000h */ -u8 reserved7[0x4000 - (0x1000 + (sizeof (__le32) *8 ))]; +u8 reserved8[0x4000 - (0x1000 + (sizeof (__le32) *8 ))];/* * The PQI spec states that the PQI registers should be at * offset 0 from the PCIe BAR 0. However, we can't map
@@ -102,6 +104,21 @@ struct pqi_ctrl_registers {#define PQI_DEVICE_REGISTERS_OFFSET 0x4000 +/* shutdown reasons for taking the controller offline */ +enum pqi_ctrl_shutdown_reason { +PQI_IQ_NOT_DRAINED_TIMEOUT =1 , +PQI_LUN_RESET_TIMEOUT =2 , +PQI_IO_PENDING_POST_LUN_RESET_TIMEOUT =3 , +PQI_NO_HEARTBEAT =4 , +PQI_FIRMWARE_KERNEL_NOT_UP =5 , +PQI_OFA_RESPONSE_TIMEOUT =6 , +PQI_INVALID_REQ_ID =7 , +PQI_UNMATCHED_REQ_ID =8 , +PQI_IO_PI_OUT_OF_RANGE =9 , +PQI_EVENT_PI_OUT_OF_RANGE =10 , +PQI_UNEXPECTED_IU_TYPE =11 +}; +enum pqi_io_path {RAID_PATH =0 ,AIO_PATH =1
@@ -850,7 +867,8 @@ struct pqi_config_table_firmware_features {#define PQI_FIRMWARE_FEATURE_TMF_IU_TIMEOUT 14#define PQI_FIRMWARE_FEATURE_RAID_BYPASS_ON_ENCRYPTED_NVME 15#define PQI_FIRMWARE_FEATURE_UNIQUE_WWID_IN_REPORT_PHYS_LUN 16 -#define PQI_FIRMWARE_FEATURE_MAXIMUM 16 +#define PQI_FIRMWARE_FEATURE_FW_TRIAGE 17 +#define PQI_FIRMWARE_FEATURE_MAXIMUM 17struct pqi_config_table_debug {struct pqi_config_table_section_header header;
@@ -1297,6 +1315,7 @@ struct pqi_ctrl_info { u8 raid_iu_timeout_supported : 1; u8 tmf_iu_timeout_supported : 1; u8 unique_wwid_in_report_phys_lun_supported : 1; + u8 firmware_triage_supported : 1; u8 enable_r1_writes : 1; u8 enable_r5_writes : 1; u8 enable_r6_writes : 1;
drivers/scsi/smartpqi/smartpqi_init.c +27 -13
@@ -54,7 +54,8 @@ MODULE_DESCRIPTION("Driver for Microchip Smart Family Controller version "MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL" ); -static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info); +static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info, +enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason);static void pqi_ctrl_offline_worker (struct work_struct *work);static int pqi_scan_scsi_devices (struct pqi_ctrl_info *ctrl_info);static void pqi_scan_start (struct Scsi_Host *shost);
@@ -226,7 +227,7 @@ static inline void pqi_check_ctrl_health(struct pqi_ctrl_info *ctrl_info) {if (ctrl_info->controller_online)if (!sis_is_firmware_running (ctrl_info)) -pqi_take_ctrl_offline (ctrl_info); +pqi_take_ctrl_offline (ctrl_info,PQI_FIRMWARE_KERNEL_NOT_UP ); }static inline bool pqi_is_hba_lunid (u8 *scsi3addr)
@@ -3163,9 +3164,10 @@ static int pqi_interpret_task_management_response(struct pqi_ctrl_info *ctrl_infreturn rc; } -static inline void pqi_invalid_response (struct pqi_ctrl_info *ctrl_info) +static inline void pqi_invalid_response (struct pqi_ctrl_info *ctrl_info, +enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason) { -pqi_take_ctrl_offline (ctrl_info); +pqi_take_ctrl_offline (ctrl_info, ctrl_shutdown_reason); }static int pqi_process_io_intr (struct pqi_ctrl_info *ctrl_info,struct pqi_queue_group *queue_group)
@@ -3183,7 +3185,7 @@ static int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info, struct pqi_queuewhile (1 ) { oq_pi =readl (queue_group->oq_pi);if (oq_pi >= ctrl_info->num_elements_per_oq) { -pqi_invalid_response (ctrl_info); +pqi_invalid_response (ctrl_info,PQI_IO_PI_OUT_OF_RANGE );dev_err (&ctrl_info->pci_dev->dev,"I/O interrupt: producer index (%u) out of range (0-%u): consumer index: %u\n" , oq_pi, ctrl_info->num_elements_per_oq -1 , oq_ci);
@@ -3198,7 +3200,7 @@ static int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info, struct pqi_queue request_id =get_unaligned_le16 (&response->request_id);if (request_id >= ctrl_info->max_io_slots) { -pqi_invalid_response (ctrl_info); +pqi_invalid_response (ctrl_info,PQI_INVALID_REQ_ID );dev_err (&ctrl_info->pci_dev->dev,"request ID in response (%u) out of range (0-%u): producer index: %u consumer index: %u\n" , request_id, ctrl_info->max_io_slots -1 , oq_pi, oq_ci);
@@ -3207,7 +3209,7 @@ static int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info, struct pqi_queue io_request = &ctrl_info->io_request_pool[request_id];if (atomic_read (&io_request->refcount) ==0 ) { -pqi_invalid_response (ctrl_info); +pqi_invalid_response (ctrl_info,PQI_UNMATCHED_REQ_ID );dev_err (&ctrl_info->pci_dev->dev,"request ID in response (%u) does not match an outstanding I/O request: producer index: %u consumer index: %u\n" , request_id, oq_pi, oq_ci);
@@ -3243,7 +3245,7 @@ static int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info, struct pqi_queuepqi_process_io_error (response->header.iu_type, io_request);break ;default : -pqi_invalid_response (ctrl_info); +pqi_invalid_response (ctrl_info,PQI_UNEXPECTED_IU_TYPE );dev_err (&ctrl_info->pci_dev->dev,"unexpected IU type: 0x%x: producer index: %u consumer index: %u\n" , response->header.iu_type, oq_pi, oq_ci);
@@ -3425,7 +3427,7 @@ static void pqi_process_soft_reset(struct pqi_ctrl_info *ctrl_info)pqi_ofa_free_host_buffer (ctrl_info);pqi_ctrl_ofa_done (ctrl_info);pqi_ofa_ctrl_unquiesce (ctrl_info); -pqi_take_ctrl_offline (ctrl_info); +pqi_take_ctrl_offline (ctrl_info,PQI_OFA_RESPONSE_TIMEOUT );break ; } }
@@ -3550,7 +3552,7 @@ static void pqi_heartbeat_timer_handler(struct timer_list *t)dev_err (&ctrl_info->pci_dev->dev,"no heartbeat detected - last heartbeat count: %u\n" , heartbeat_count); -pqi_take_ctrl_offline (ctrl_info); +pqi_take_ctrl_offline (ctrl_info,PQI_NO_HEARTBEAT );return ; } }else {
@@ -3614,7 +3616,7 @@ static int pqi_process_event_intr(struct pqi_ctrl_info *ctrl_info)while (1 ) { oq_pi =readl (event_queue->oq_pi);if (oq_pi >=PQI_NUM_EVENT_QUEUE_ELEMENTS ) { -pqi_invalid_response (ctrl_info); +pqi_invalid_response (ctrl_info,PQI_EVENT_PI_OUT_OF_RANGE );dev_err (&ctrl_info->pci_dev->dev,"event interrupt: producer index (%u) out of range (0-%u): consumer index: %u\n" , oq_pi,PQI_NUM_EVENT_QUEUE_ELEMENTS -1 , oq_ci);
@@ -7332,7 +7334,10 @@ static void pqi_ctrl_update_feature_flags(struct pqi_ctrl_info *ctrl_info, ctrl_info->unique_wwid_in_report_phys_lun_supported = firmware_feature->enabled;break ; +case PQI_FIRMWARE_FEATURE_FW_TRIAGE : + ctrl_info->firmware_triage_supported = firmware_feature->enabled;pqi_save_fw_triage_setting (ctrl_info, firmware_feature->enabled); +break ; }pqi_firmware_feature_status (ctrl_info, firmware_feature);
@@ -7428,6 +7433,11 @@ static struct pqi_firmware_feature pqi_firmware_features[] = { .feature_bit = PQI_FIRMWARE_FEATURE_UNIQUE_WWID_IN_REPORT_PHYS_LUN, .feature_status = pqi_ctrl_update_feature_flags, }, + { + .feature_name = "Firmware Triage", + .feature_bit = PQI_FIRMWARE_FEATURE_FW_TRIAGE, + .feature_status = pqi_ctrl_update_feature_flags, + }, }; static void pqi_process_firmware_features(
@@ -7528,6 +7538,7 @@ static void pqi_ctrl_reset_config(struct pqi_ctrl_info *ctrl_info) ctrl_info->raid_iu_timeout_supported = false; ctrl_info->tmf_iu_timeout_supported = false; ctrl_info->unique_wwid_in_report_phys_lun_supported = false; + ctrl_info->firmware_triage_supported = false; }static int pqi_process_config_table (struct pqi_ctrl_info *ctrl_info)
@@ -8474,7 +8485,8 @@ static void pqi_ctrl_offline_worker(struct work_struct *work)pqi_take_ctrl_offline_deferred (ctrl_info); } -static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info) +static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info, +enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason) {if (!ctrl_info->controller_online)return ;
@@ -8483,7 +8495,7 @@ static void pqi_take_ctrl_offline(struct pqi_ctrl_info *ctrl_info) ctrl_info->pqi_mode_enabled = false;pqi_ctrl_block_requests (ctrl_info);if (!pqi_disable_ctrl_shutdown) -sis_shutdown_ctrl (ctrl_info); +sis_shutdown_ctrl (ctrl_info, ctrl_shutdown_reason);pci_disable_device (ctrl_info->pci_dev);dev_err (&ctrl_info->pci_dev->dev,"controller offline\n" );schedule_work (&ctrl_info->ctrl_offline_work);
@@ -9318,6 +9330,8 @@ static void __attribute__((unused)) verify_structures(void) sis_product_identifier) != 0xb4);BUILD_BUG_ON (offsetof(struct pqi_ctrl_registers , sis_firmware_status) !=0xbc ); +BUILD_BUG_ON (offsetof(struct pqi_ctrl_registers , + sis_ctrl_shutdown_reason_code) !=0xcc );BUILD_BUG_ON (offsetof(struct pqi_ctrl_registers , sis_mailbox) !=0x1000 ); BUILD_BUG_ON(offsetof(struct pqi_ctrl_registers,
drivers/scsi/smartpqi/smartpqi_sis.c +6 -3
@@ -397,14 +397,17 @@ void sis_enable_intx(struct pqi_ctrl_info *ctrl_info)sis_set_doorbell_bit (ctrl_info,SIS_ENABLE_INTX ); } -void sis_shutdown_ctrl (struct pqi_ctrl_info *ctrl_info) +void sis_shutdown_ctrl (struct pqi_ctrl_info *ctrl_info, +enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason) {if (readl (&ctrl_info->registers->sis_firmware_status) &SIS_CTRL_KERNEL_PANIC )return ; -writel (SIS_TRIGGER_SHUTDOWN , - &ctrl_info->registers->sis_host_to_ctrl_doorbell); +if (ctrl_info->firmware_triage_supported) +writel (ctrl_shutdown_reason, &ctrl_info->registers->sis_ctrl_shutdown_reason_code); + +writel (SIS_TRIGGER_SHUTDOWN , &ctrl_info->registers->sis_host_to_ctrl_doorbell); }int sis_pqi_reset_quiesce (struct pqi_ctrl_info *ctrl_info)
drivers/scsi/smartpqi/smartpqi_sis.h +2 -1
@@ -21,7 +21,8 @@ int sis_get_pqi_capabilities(struct pqi_ctrl_info *ctrl_info);int sis_init_base_struct_addr (struct pqi_ctrl_info *ctrl_info);void sis_enable_msix (struct pqi_ctrl_info *ctrl_info);void sis_enable_intx (struct pqi_ctrl_info *ctrl_info); -void sis_shutdown_ctrl (struct pqi_ctrl_info *ctrl_info); +void sis_shutdown_ctrl (struct pqi_ctrl_info *ctrl_info, +enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason);int sis_pqi_reset_quiesce (struct pqi_ctrl_info *ctrl_info);int sis_reenable_sis_mode (struct pqi_ctrl_info *ctrl_info);void sis_write_driver_scratch (struct pqi_ctrl_info *ctrl_info,u32 value);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 619/935 scsi: core: Register sysfs attributes earlier
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 92c4b58b15c56298b1b225c1d2e533165b3e32af ]
A quote from Documentation/driver-api/driver-model/device.rst:
"Word of warning: While the kernel allows device_create_file() and device_remove_file() to be called on a device at any time, userspace has strict expectations on when attributes get created. When a new device is registered in the kernel, a uevent is generated to notify userspace (like udev) that a new device is available. If attributes are added after the device is registered, then userspace won't get notified and userspace will not know about the new attributes."
Hence register SCSI host sysfs attributes before the SCSI host shost_dev uevent is emitted instead of after that event has been emitted.
Stable-dep-of: 225548863f0a ("scsi: smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches.")
--- drivers/scsi/hosts.c | 23 ++++++++++- drivers/scsi/scsi_priv.h | 4 +- drivers/scsi/scsi_sysfs.c | 81 +++++++++++++++++++------------------- include/scsi/scsi_device.h | 7 ++++ include/scsi/scsi_host.h | 12 ++++++ 5 files changed, 84 insertions(+), 43 deletions(-)
drivers/scsi/hosts.c +21 -2
@@ -387,7 +387,7 @@ static struct device_type scsi_host_type = {struct Scsi_Host *scsi_host_alloc (struct scsi_host_template *sht,int privsize) {struct Scsi_Host *shost; -int index; +int index, i, j =0 ; shost =kzalloc (sizeof (struct Scsi_Host ) + privsize,GFP_KERNEL );if (!shost)
@@ -492,7 +492,26 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) shost->shost_dev.parent = &shost->shost_gendev; shost->shost_dev.class = &shost_class;dev_set_name (&shost->shost_dev,"host%d" , shost->host_no); - shost->shost_dev.groups = scsi_sysfs_shost_attr_groups; + shost->shost_dev.groups = shost->shost_dev_attr_groups; + shost->shost_dev_attr_groups[j++] = &scsi_shost_attr_group; +if (sht->shost_attrs) { + shost->lld_attr_group = (struct attribute_group ){ + .attrs =scsi_convert_dev_attrs (&shost->shost_gendev, + sht->shost_attrs) + }; +if (shost->lld_attr_group.attrs) + shost->shost_dev_attr_groups[j++] = + &shost->lld_attr_group; + } +if (sht->shost_groups) { +for (i =0 ; sht->shost_groups[i] && + j <ARRAY_SIZE (shost->shost_dev_attr_groups); + i++, j++) { + shost->shost_dev_attr_groups[j] = + sht->shost_groups[i]; + } + } +WARN_ON_ONCE (j >=ARRAY_SIZE (shost->shost_dev_attr_groups)); shost->ehandler =kthread_run (scsi_error_handler, shost,"scsi_eh_%d" , shost->host_no);
drivers/scsi/scsi_priv.h +3 -1
@@ -138,13 +138,15 @@ extern int scsi_sysfs_add_sdev(struct scsi_device *);extern int scsi_sysfs_add_host (struct Scsi_Host *);extern int scsi_sysfs_register (void );extern void scsi_sysfs_unregister (void ); +struct attribute **scsi_convert_dev_attrs (struct device *dev, +struct device_attribute **dev_attr);extern void scsi_sysfs_device_initialize (struct scsi_device *);extern int scsi_sysfs_target_initialize (struct scsi_device *);extern struct scsi_transport_template blank_transport_template;extern void __scsi_remove_device (struct scsi_device *);extern struct bus_type scsi_bus_type; -extern const struct attribute_group *scsi_sysfs_shost_attr_groups[]; +extern const struct attribute_group scsi_shost_attr_group;/* scsi_netlink.c */ #ifdef CONFIG_SCSI_NETLINK
drivers/scsi/scsi_sysfs.c +41 -40
133 lines not on this page · raw message
include/scsi/scsi_device.h +7 -0
@@ -226,6 +226,13 @@ struct scsi_device {struct device sdev_gendev, sdev_dev; +struct attribute_group lld_attr_group; +/* +* The array size 6 provides space for one attribute group for the +* SCSI core, four attribute groups defined by SCSI LLDs and one +* terminating NULL pointer. +*/ +const struct attribute_group *gendev_attr_groups[6 ];struct execute_work ew;/* used to get process context on put */ struct work_struct requeue_work;
include/scsi/scsi_host.h +12 -0
@@ -483,6 +483,11 @@ struct scsi_host_template {*/ struct device_attribute **sdev_attrs; +/* +* Pointer to the SCSI host sysfs attribute groups, NULL terminated. +*/ +const struct attribute_group **shost_groups; +/* * Pointer to the SCSI device attribute groups for this host, * NULL terminated.
@@ -698,6 +703,13 @@ struct Scsi_Host {/* ldm bits */ struct device shost_gendev, shost_dev; +struct attribute_group lld_attr_group; +/* +* The array size 3 provides space for one attribute group defined by +* the SCSI core, one attribute group defined by the SCSI LLD and one +* terminating NULL pointer. +*/ +const struct attribute_group *shost_dev_attr_groups[3 ];/* * Points to the transport data (if any) which is allocated
Signature · 1 line
2.53.0
[regression] 'scsi: core: Register sysfs attributes earlier' in 5.15.221 broke booting
Quoted 20 lines · Greg Kroah-Hartman
5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit
92c4b58b15c56298b1b225c1d2e533165b3e32af]A quote from
Documentation/driver-api/driver-model/device.rst:
"Word of warning: While the kernel allowsdevice_create_file()anddevice_remove_file()to be called on a device at any time, userspace has strict expectations on when attributes get created. When a new device is registered in the kernel, a uevent is generated to notify userspace (like udev) that a new device is available. If attributes are added after the device is registered, then userspace won't get notified and userspace will not know about the new attributes."Hence register SCSI host sysfs attributes before the SCSI host
shost_devuevent is emitted instead of after that event has been emitted.
Quoted 6 lines
Cc Greg Kroah-Hartman <[email protected]>Reviewed-by Benjamin Block <[email protected]>Signed-off-by Bart Van Assche <[email protected]>Signed-off-by Martin K. Petersen <[email protected]>Stable-dep-of:
225548863f0a("scsi: smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches.")
This 5.15.y change according to
https://bugzilla.kernel.org/show_bug.cgi?id=222016#c5 broke booting on sata devices for two people; the second reporter indentified it to be the culprit:
"""
I have a similar problem with 5.15.221, but in my case all the SATA hard drives on 2 different units are gone. 'fdisk -l' shows only the remaining NVMe device.
After some investigation, I stumbled over this commit here:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=694e1b6aabe4cd359b42c44b54c409c3147b6020
scsi: core: Register sysfs attributes earlier
This was the culprit on my 2 machines. After reverting this commit on 5.15.221 and recompiling the kernel, everything went back to normal. """
Ciao, Thorsten
Quoted 253 lines
Signed-off-by Sasha Levin <[email protected]>--- drivers/scsi/hosts.c | 23 ++++++++++- drivers/scsi/scsi_priv.h | 4 +- drivers/scsi/scsi_sysfs.c | 81 +++++++++++++++++++------------------- include/scsi/scsi_device.h | 7 ++++ include/scsi/scsi_host.h | 12 ++++++ 5 files changed, 84 insertions(+), 43 deletions(-)drivers/scsi/hosts.c +21
-2@@ -387,7 +387,7 @@ static struct device_type scsi_host_type = {struct Scsi_Host *scsi_host_alloc (struct scsi_host_template *sht,int privsize) {struct Scsi_Host *shost; -int index; +int index, i, j =0 ; shost =kzalloc (sizeof (struct Scsi_Host ) + privsize,GFP_KERNEL );if (!shost)@@ -492,7 +492,26 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) shost->shost_dev.parent = &shost->shost_gendev; shost->shost_dev.class = &shost_class;dev_set_name (&shost->shost_dev,"host%d" , shost->host_no); - shost->shost_dev.groups = scsi_sysfs_shost_attr_groups; + shost->shost_dev.groups = shost->shost_dev_attr_groups; + shost->shost_dev_attr_groups[j++] = &scsi_shost_attr_group; +if (sht->shost_attrs) { + shost->lld_attr_group = (struct attribute_group ){ + .attrs =scsi_convert_dev_attrs (&shost->shost_gendev, + sht->shost_attrs) + }; +if (shost->lld_attr_group.attrs) + shost->shost_dev_attr_groups[j++] = + &shost->lld_attr_group; + } +if (sht->shost_groups) { +for (i =0 ; sht->shost_groups[i] && + j <ARRAY_SIZE (shost->shost_dev_attr_groups); + i++, j++) { + shost->shost_dev_attr_groups[j] = + sht->shost_groups[i]; + } + } +WARN_ON_ONCE (j >=ARRAY_SIZE (shost->shost_dev_attr_groups)); shost->ehandler =kthread_run (scsi_error_handler, shost,"scsi_eh_%d" , shost->host_no);drivers/scsi/scsi_priv.h +3
-1@@ -138,13 +138,15 @@ extern int scsi_sysfs_add_sdev(struct scsi_device *);extern int scsi_sysfs_add_host (struct Scsi_Host *);extern int scsi_sysfs_register (void );extern void scsi_sysfs_unregister (void ); +struct attribute **scsi_convert_dev_attrs (struct device *dev, +struct device_attribute **dev_attr);extern void scsi_sysfs_device_initialize (struct scsi_device *);extern int scsi_sysfs_target_initialize (struct scsi_device *);extern struct scsi_transport_template blank_transport_template;extern void __scsi_remove_device (struct scsi_device *);extern struct bus_type scsi_bus_type; -extern const struct attribute_group *scsi_sysfs_shost_attr_groups[]; +extern const struct attribute_group scsi_shost_attr_group;/* scsi_netlink.c */ #ifdef CONFIG_SCSI_NETLINK drivers/scsi/scsi_sysfs.c +41
-40@@ -424,15 +424,10 @@ static struct attribute *scsi_sysfs_shost_attrs[] = { NULL }; -static struct attribute_group scsi_shost_attr_group = { +const struct attribute_group scsi_shost_attr_group = { .attrs = scsi_sysfs_shost_attrs, }; -const struct attribute_group *scsi_sysfs_shost_attr_groups[] = { - &scsi_shost_attr_group, -NULL -}; -static void scsi_device_cls_release (struct device *class_dev) {struct scsi_device *sdev;@@ -1358,7 +1353,7 @@ static int scsi_target_add(struct scsi_target *starget)**/ int scsi_sysfs_add_sdev (struct scsi_device *sdev) { -int error, i; +int error;struct scsi_target *starget = sdev->sdev_target; error =scsi_target_add (starget);@@ -1412,23 +1407,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) } } -/* add additional host specific attributes */ -if (sdev->host->hostt->sdev_attrs) { -for (i =0 ; sdev->host->hostt->sdev_attrs[i]; i++) { - error =device_create_file (&sdev->sdev_gendev, - sdev->host->hostt->sdev_attrs[i]); -if (error) -return error; - } - } - -if (sdev->host->hostt->sdev_groups) { - error =sysfs_create_groups (&sdev->sdev_gendev.kobj, - sdev->host->hostt->sdev_groups); -if (error) -return error; - } -scsi_autopm_put_device (sdev);return error; }@@ -1468,10 +1446,6 @@ void __scsi_remove_device(struct scsi_device *sdev)if (res !=0 )return ; -if (sdev->host->hostt->sdev_groups) -sysfs_remove_groups (&sdev->sdev_gendev.kobj, - sdev->host->hostt->sdev_groups); -if (IS_ENABLED (CONFIG_BLK_DEV_BSG ) && sdev->bsg_dev)bsg_unregister_queue (sdev->bsg_dev);device_unregister (&sdev->sdev_dev);@@ -1611,23 +1585,31 @@ EXPORT_SYMBOL(scsi_register_interface);**/ int scsi_sysfs_add_host (struct Scsi_Host *shost) { -int error, i; - -/* add host specific attributes */ -if (shost->hostt->shost_attrs) { -for (i =0 ; shost->hostt->shost_attrs[i]; i++) { - error =device_create_file (&shost->shost_dev, - shost->hostt->shost_attrs[i]); -if (error) -return error; - } - } -transport_register_device (&shost->shost_gendev);transport_configure_device (&shost->shost_gendev);return 0 ; } +/* +* Convert an array of struct device_attribute pointers into an array of +* struct attribute pointers. +*/ +struct attribute **scsi_convert_dev_attrs (struct device *dev, +struct device_attribute **dev_attr) +{ +struct attribute **attrs; +int i; + +for (i =0 ; dev_attr[i]; i++) + ; + attrs =devm_kzalloc (dev, (i +1 ) *sizeof (*attrs),GFP_KERNEL ); +if (!attrs) +return NULL ; +for (i =0 ; dev_attr[i]; i++) + attrs[i] = &dev_attr[i]->attr; +return attrs; +} +static struct device_type scsi_dev_type = { .name ="scsi_device" , .release = scsi_device_dev_release,@@ -1636,8 +1618,10 @@ static struct device_type scsi_dev_type = {void scsi_sysfs_device_initialize (struct scsi_device *sdev) { +int i, j =0 ;unsigned long flags;struct Scsi_Host *shost = sdev->host; +struct scsi_host_template *hostt = shost->hostt;struct scsi_target *starget = sdev->sdev_target;device_initialize (&sdev->sdev_gendev);@@ -1645,6 +1629,23 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev) sdev->sdev_gendev.type = &scsi_dev_type;dev_set_name (&sdev->sdev_gendev,"%d:%d:%d:%llu" , sdev->host->host_no, sdev->channel, sdev->id, sdev->lun); + sdev->gendev_attr_groups[j++] = &scsi_sdev_attr_group; +if (hostt->sdev_attrs) { + sdev->lld_attr_group = (struct attribute_group ){ + .attrs =scsi_convert_dev_attrs (&sdev->sdev_gendev, + hostt->sdev_attrs) + }; +if (sdev->lld_attr_group.attrs) + sdev->gendev_attr_groups[j++] = &sdev->lld_attr_group; + } +if (hostt->sdev_groups) { +for (i =0 ; hostt->sdev_groups[i] && + j <ARRAY_SIZE (sdev->gendev_attr_groups); + i++, j++) { + sdev->gendev_attr_groups[j] = hostt->sdev_groups[i]; + } + } +WARN_ON_ONCE (j >=ARRAY_SIZE (sdev->gendev_attr_groups));device_initialize (&sdev->sdev_dev); sdev->sdev_dev.parent =get_device (&sdev->sdev_gendev);include/scsi/scsi_device.h +7
-0@@ -226,6 +226,13 @@ struct scsi_device {struct device sdev_gendev, sdev_dev; +struct attribute_group lld_attr_group; +/* +* The array size 6 provides space for one attribute group for the +* SCSI core, four attribute groups defined by SCSI LLDs and one +* terminating NULL pointer. +*/ +const struct attribute_group *gendev_attr_groups[6 ];struct execute_work ew;/* used to get process context on put */ struct work_struct requeue_work;include/scsi/scsi_host.h +5
-0@@ -483,6 +483,11 @@ struct scsi_host_template {*/ struct device_attribute **sdev_attrs; +/* +* Pointer to the SCSI host sysfs attribute groups, NULL terminated. +*/ +const struct attribute_group **shost_groups; +/* * Pointer to the SCSI device attribute groups for this host, * NULL terminated. @@ -698,6 +703,13 @@ struct Scsi_Host {/* ldm bits */ struct device shost_gendev, shost_dev;
include/scsi/scsi_host.h struct Scsi_Host { · line 715
Quoted 10 lines
include/scsi/scsi_host.h +7
-0+struct attribute_group lld_attr_group; +/* +* The array size 3 provides space for one attribute group defined by +* the SCSI core, one attribute group defined by the SCSI LLD and one +* terminating NULL pointer. +*/ +const struct attribute_group *shost_dev_attr_groups[3 ];/* * Points to the transport data (if any) which is allocated
#regzbot introduced: 694e1b6aabe4cd
#regzbot dup: https://bugzilla.kernel.org/show_bug.cgi?id=222016
#regzbot title: partitions not recognized on sata devices
Sasha Levin
maintainerRe: [regression] 'scsi: core: Register sysfs attributes earlier' in 5.15.221 broke booting
Quoted 4 lines
This 5.15.y change according to
https://bugzilla.kernel.org/show_bug.cgi?id=222016#c5 broke booting on sata devices for two people; the second reporter indentified it to be the culprit:
I have reverted it on 5.15, together with the rest of the chain it came in with, so the tree is back to its pre 5.15.221 state for the SCSI core sysfs registration and smartpqi. 6.1 and newer are unaffected, they carry the upstream follow-up in their base release.
One consequence worth stating here: this also takes 225548863f0a ("scsi:
smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches.") back out of 5.15, since that fix is what pulled the chain in. It does not apply on its own on that tree, so 5.15 needs a purpose built backport before it can return.
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 620/935 scsi: smartpqi: Switch to attribute groups
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 64fc9015fbeb041ed0b2ebf645764c06e0ad7753 ]
struct device supports attribute groups directly but does not support struct device_attribute directly. Hence switch to attribute groups.
Stable-dep-of: 225548863f0a ("scsi: smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches.")
--- drivers/scsi/smartpqi/smartpqi_init.c | 46 +++++++++++++++------------ 1 file changed, 25 insertions(+), 21 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +25 -21
@@ -6664,20 +6664,22 @@ static DEVICE_ATTR(enable_r5_writes, 0644, static DEVICE_ATTR(enable_r6_writes, 0644, pqi_host_enable_r6_writes_show, pqi_host_enable_r6_writes_store); -static struct device_attribute *pqi_shost_attrs[] = { - &dev_attr_driver_version, - &dev_attr_firmware_version, - &dev_attr_model, - &dev_attr_serial_number, - &dev_attr_vendor, - &dev_attr_rescan, - &dev_attr_lockup_action, - &dev_attr_enable_stream_detection, - &dev_attr_enable_r5_writes, - &dev_attr_enable_r6_writes, +static struct attribute *pqi_shost_attrs[] = { + &dev_attr_driver_version.attr, + &dev_attr_firmware_version.attr, + &dev_attr_model.attr, + &dev_attr_serial_number.attr, + &dev_attr_vendor.attr, + &dev_attr_rescan.attr, + &dev_attr_lockup_action.attr, + &dev_attr_enable_stream_detection.attr, + &dev_attr_enable_r5_writes.attr, + &dev_attr_enable_r6_writes.attr,NULL }; +ATTRIBUTE_GROUPS (pqi_shost); +static ssize_t pqi_unique_id_show (struct device *dev,struct device_attribute *attr,char *buffer) {
@@ -6948,17 +6950,19 @@ static DEVICE_ATTR(ssd_smart_path_enabled, 0444, pqi_ssd_smart_path_enabled_show static DEVICE_ATTR(raid_level, 0444, pqi_raid_level_show, NULL); static DEVICE_ATTR(raid_bypass_cnt, 0444, pqi_raid_bypass_cnt_show, NULL); -static struct device_attribute *pqi_sdev_attrs[] = { - &dev_attr_lunid, - &dev_attr_unique_id, - &dev_attr_path_info, - &dev_attr_sas_address, - &dev_attr_ssd_smart_path_enabled, - &dev_attr_raid_level, - &dev_attr_raid_bypass_cnt, +static struct attribute *pqi_sdev_attrs[] = { + &dev_attr_lunid.attr, + &dev_attr_unique_id.attr, + &dev_attr_path_info.attr, + &dev_attr_sas_address.attr, + &dev_attr_ssd_smart_path_enabled.attr, + &dev_attr_raid_level.attr, + &dev_attr_raid_bypass_cnt.attr,NULL }; +ATTRIBUTE_GROUPS (pqi_sdev); +static struct scsi_host_template pqi_driver_template = { .module =THIS_MODULE , .name =DRIVER_NAME_SHORT ,
@@ -6973,8 +6977,8 @@ static struct scsi_host_template pqi_driver_template = { .slave_configure = pqi_slave_configure, .slave_destroy = pqi_slave_destroy, .map_queues = pqi_map_queues, - .sdev_attrs = pqi_sdev_attrs, - .shost_attrs = pqi_shost_attrs, + .sdev_groups = pqi_sdev_groups, + .shost_groups = pqi_shost_groups, };static int pqi_register_scsi (struct pqi_ctrl_info *ctrl_info)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 621/935 scsi: smartpqi: Fix BUILD_BUG_ON() statements
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike McGowen <[email protected]>
[ Upstream commit 5e6935864d814c3a62dd0945fd155634481f11c2 ]
Add calls to the functions at the beginning driver initialization.
The BUILD_BUG_ON() statements that are currently in functions named verify_structures() in the modules smartpqi_init.c and smartpqi_sis.c do not work as currently implemented.
Stable-dep-of: 225548863f0a ("scsi: smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches.")
--- drivers/scsi/smartpqi/smartpqi_init.c | 5 ++++- drivers/scsi/smartpqi/smartpqi_sis.c | 2 +- drivers/scsi/smartpqi/smartpqi_sis.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +4 -1
@@ -54,6 +54,7 @@ MODULE_DESCRIPTION("Driver for Microchip Smart Family Controller version "MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL" ); +static void pqi_verify_structures (void );static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info,enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason);static void pqi_ctrl_offline_worker (struct work_struct *work);
@@ -9295,6 +9296,8 @@ static int __init pqi_init(void)int rc;pr_info (DRIVER_NAME "\n" ); +pqi_verify_structures (); +sis_verify_structures (); pqi_sas_transport_template =sas_attach_transport (&pqi_sas_transport_functions);if (!pqi_sas_transport_template)
@@ -9318,7 +9321,7 @@ static void __exit pqi_cleanup(void)module_init (pqi_init);module_exit (pqi_cleanup); -static void __attribute__((unused))verify_structures (void ) +static void pqi_verify_structures (void ) {BUILD_BUG_ON (offsetof(struct pqi_ctrl_registers , sis_host_to_ctrl_doorbell) !=0x20 );
drivers/scsi/smartpqi/smartpqi_sis.c +1 -1
@@ -479,7 +479,7 @@ int sis_wait_for_fw_triage_completion(struct pqi_ctrl_info *ctrl_info)return rc; } -static void __attribute__((unused))verify_structures (void ) +void sis_verify_structures (void ) {BUILD_BUG_ON (offsetof(struct sis_base_struct , revision) !=0x0 );
drivers/scsi/smartpqi/smartpqi_sis.h +1 -0
@@ -12,6 +12,7 @@#if !defined(_SMARTPQI_SIS_H)#define _SMARTPQI_SIS_H +void sis_verify_structures (void );int sis_wait_for_ctrl_ready (struct pqi_ctrl_info *ctrl_info);int sis_wait_for_ctrl_ready_resume (struct pqi_ctrl_info *ctrl_info);bool sis_is_firmware_running (struct pqi_ctrl_info *ctrl_info);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 622/935 scsi: smartpqi: Stop using the SCSI pointer
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit c1ea387d998ab524291f1b78f8faa4618decd36d ]
Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd.
Stable-dep-of: 225548863f0a ("scsi: smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches.")
--- drivers/scsi/smartpqi/smartpqi_init.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +12 -2
@@ -54,6 +54,15 @@ MODULE_DESCRIPTION("Driver for Microchip Smart Family Controller version "MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL" ); +struct pqi_cmd_priv { +int this_residual; +}; + +static struct pqi_cmd_priv *pqi_cmd_priv (struct scsi_cmnd *cmd) +{ +return scsi_cmd_priv (cmd); +} +static void pqi_verify_structures (void );static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info,enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason);
@@ -5390,7 +5399,7 @@ static void pqi_aio_io_complete(struct pqi_io_request *io_request,scsi_dma_unmap (scmd);if (io_request->status == -EAGAIN ||pqi_raid_bypass_retry_needed (io_request)) {set_host_byte (scmd,DID_IMM_RETRY ); - scmd->SCp.this_residual++; +pqi_cmd_priv (scmd)->this_residual++; }pqi_free_io_request (io_request);
@@ -5614,7 +5623,7 @@ static inline bool pqi_is_bypass_eligible_request(struct scsi_cmnd *scmd)if (blk_rq_is_passthrough (scsi_cmd_to_rq (scmd)))return false; -return scmd->SCp.this_residual ==0 ; +return pqi_cmd_priv (scmd)->this_residual ==0 ; }/*
@@ -6980,6 +6989,7 @@ static struct scsi_host_template pqi_driver_template = { .map_queues = pqi_map_queues, .sdev_groups = pqi_sdev_groups, .shost_groups = pqi_shost_groups, + .cmd_size = sizeof(struct pqi_cmd_priv), };static int pqi_register_scsi (struct pqi_ctrl_info *ctrl_info)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 623/935 scsi: smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches.
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Strahan <[email protected]>
[ Upstream commit 225548863f0a2350c6f34231ca56710c3dd1a5d5 ]
On recent Linux kernels the driver can enter a retry loop on the AIO fast path when a request is retried, looping until timeout. A diagnostic path that takes a physical drive offline on AIO-bypass failure is also never entered on affected kernels.
Register a per-command initialization callback with the SCSI core. Its presence causes the core to skip the per-dispatch clear, so the retry marker now survives across the requeue and the AIO-to-RAID fallback proceeds as intended. The driver takes over the marker's lifetime: it is zeroed at tag allocation, preserved across the retry requeue so the error path can act on it, and cleared on terminal completion so the tag starts clean on its next use.
--- drivers/scsi/smartpqi/smartpqi_init.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +18 -0
@@ -63,6 +63,12 @@ static struct pqi_cmd_priv *pqi_cmd_priv(struct scsi_cmnd *cmd)return scsi_cmd_priv (cmd); } +static int pqi_init_cmd_priv (struct Scsi_Host *shost,struct scsi_cmnd *cmd) +{ +memset (pqi_cmd_priv (cmd),0 ,sizeof (struct pqi_cmd_priv )); +return 0 ; +} +static void pqi_verify_structures (void );static void pqi_take_ctrl_offline (struct pqi_ctrl_info *ctrl_info,enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason);
@@ -5635,6 +5641,17 @@ void pqi_prep_for_scsi_done(struct scsi_cmnd *scmd) {struct pqi_scsi_dev *device; +/* +* Clear the AIO-retry marker on final completion so the tag +* starts clean on its next dispatch. On DID_IMM_RETRY leave +* it intact: pqi_aio_io_complete() sets DID_IMM_RETRY and +* bumps the marker to steer the requeue onto the RAID path, +* and pqi_process_raid_io_error() consumes the non-zero +* marker to offline a misbehaving drive. +*/ +if (host_byte (scmd->result) !=DID_IMM_RETRY ) +pqi_cmd_priv (scmd)->this_residual =0 ; +if (!scmd->device) {set_host_byte (scmd,DID_NO_CONNECT );return ;
@@ -6990,6 +7007,7 @@ static struct scsi_host_template pqi_driver_template = { .sdev_groups = pqi_sdev_groups, .shost_groups = pqi_shost_groups, .cmd_size = sizeof(struct pqi_cmd_priv), + .init_cmd_priv = pqi_init_cmd_priv, };static int pqi_register_scsi (struct pqi_ctrl_info *ctrl_info)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 624/935 RDMA/mlx5: Fix stack out-of-bounds read in cc_params debugfs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 03826bc1fa6c90405bf05831f2b501a8368dcd27 ]
get_param() reads a congestion parameter as a u32 but formats it with the signed "%d" into an 11-byte stack buffer. A value with bit 31 set, such as 0x80000000, renders as "-2147483648\n" whose full length is 12. snprintf() stores only 11 bytes yet returns 12, so simple_read_from_buffer() treats 12 bytes as valid and reads one byte past lbuf[].
Size the buffer for the widest unsigned decimal, format with "%u" to match the u32, and use scnprintf() so the length passed to simple_read_from_buffer() reflects the bytes actually stored.
--- drivers/infiniband/hw/mlx5/cong.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/cong.c +2 -4
@@ -377,15 +377,13 @@ static ssize_t get_param(struct file *filp, char __user *buf, size_t count,int offset = param->offset;u32 var =0 ;int ret; -char lbuf[11 ]; +char lbuf[12 ]; ret =mlx5_ib_get_cc_params (param->dev, param->port_num, offset, &var);if (ret)return ret; - ret =snprintf (lbuf,sizeof (lbuf),"%d\n" , var); -if (ret <0 ) -return ret; + ret =scnprintf (lbuf,sizeof (lbuf),"%u\n" , var);return simple_read_from_buffer (buf, count, pos, lbuf, ret); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 625/935 RDMA/mlx5: Send cong param changes to the resolved port mdev
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 033a79e308e4fe832b0924347eda8c4364055174 ]
mlx5_ib_set_cc_params() resolves the port-specific mlx5_core_dev via mlx5_ib_get_native_port_mdev() but issued MLX5_CMD_OP_MODIFY_CONG_PARAMS through dev->mdev. On an affiliated secondary RoCE port those pointers refer to different devices, so a write to the secondary port's cc_params debugfs file either altered the master port or failed with a master-side command error, while the read path already used the resolved mdev and returned the unchanged secondary value.
Issue the command to the resolved mdev, the same device whose capabilities were checked when its debugfs directory was created. It is already referenced by the get/put pair, so its lifetime is safe.
--- drivers/infiniband/hw/mlx5/cong.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/cong.c +1 -1
@@ -339,7 +339,7 @@ static int mlx5_ib_set_cc_params(struct mlx5_ib_dev *dev, u32 port_num,MLX5_SET (field_select_r_roce_rp, field, field_select_r_roce_rp, attr_mask); - err =mlx5_cmd_exec_in (dev->mdev, modify_cong_params, in); + err =mlx5_cmd_exec_in (mdev, modify_cong_params, in);kvfree (in); alloc_err:mlx5_ib_put_native_port_mdev (dev, port_num +1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 626/935 RDMA/cxgb4: free STAG index when TPT entry write fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit fdfb5cea4bf070cdb31d997efd87bb684df041fd ]
write_tpt_entry() allocates a new STAG index with c4iw_get_resource() and bumps stats.stag.cur before programming the entry. When write_adapter_mem() fails, it returns the error without releasing the index or reversing the statistic. No MR is inserted into rhp->mrs, so deregistration never reclaims it, leaking the index until device teardown.
Record whether this call allocated the index and, on a failed write, return it to tpt_table and decrement stats.stag.cur. Key the rollback on both the write error and that flag, not the error alone: a non-reset update carries a caller-owned STAG that this call did not allocate and must not free.
--- drivers/infiniband/hw/cxgb4/mem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/cxgb4/mem.c +3 -1
@@ -277,6 +277,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,int err;struct fw_ri_tpte *tpt;u32 stag_idx; +bool stag_idx_allocated = false;static atomic_t key;if (c4iw_fatal_error (rdev))
@@ -299,6 +300,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,return -ENOMEM ; }mutex_lock (&rdev->stats.lock); + stag_idx_allocated = true; rdev->stats.stag.cur +=32 ;if (rdev->stats.stag.cur > rdev->stats.stag.max) rdev->stats.stag.max = rdev->stats.stag.cur;
@@ -333,7 +335,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry, (rdev->lldi.vr->stag.start >>5 ), sizeof(*tpt), tpt, skb, wr_waitp); -if (reset_tpt_entry) { +if (reset_tpt_entry || (err && stag_idx_allocated)) {c4iw_put_resource (&rdev->resource.tpt_table, stag_idx);mutex_lock (&rdev->stats.lock); rdev->stats.stag.cur -=32 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 627/935 IB/isert: reject PDUs declaring more data than was received
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit 957f92ea4022fb6af4618271615a2a21a7b5bef9 ]
isert_recv_done() hands each received PDU to the opcode handlers without ever looking at wc->byte_len, the number of bytes the HCA actually placed in the receive descriptor. The handlers then copy that many bytes - the data-segment length the initiator declared in the BHS (ntoh24(hdr->dlength), via the derived unsol_data_len / imm_data_len) - out of the fixed-size descriptor:
isert_handle_iscsi_dataout():
sg_copy_from_buffer(sg_start, sg_nents, isert_get_data(rx_desc),
unsol_data_len);
isert_handle_scsi_cmd():
sg_copy_from_buffer(cmd->se_cmd.t_data_sg, sg_nents,
isert_get_data(rx_desc), imm_data_len);Because the declared length is never checked against wc->byte_len, an initiator can declare a data segment larger than the bytes it actually sent (and larger than the descriptor) and cause an out-of-bounds read of the receive buffer.
Nothing upstream of isert closes this door:
- __iscsit_check_dataout_hdr() bounds the inbound payload against conn_ops->MaxXmitDataSegmentLength (MXDSL) - a transmit parameter, used here for the inbound check.
- iscsi_set_connection_parameters() sets ops->MaxXmitDataSegmentLength = ops->TargetRecvDataSegmentLength; and TARGETRECVDATASEGMENTLENGTH is absent from the min()-clamp list in iscsi_check_acceptor_state(), so the value the initiator declares is adopted verbatim (type range 512..16777215). The initiator effectively raises its own ceiling.
- isert never clamps the negotiated value to its own fixed receive descriptor (ISER_RX_SIZE, 9216 bytes), so the target core's bound and the descriptor size are unrelated.
The imm_data_len == data_len path is more than an over-read: it aliases the receive descriptor via sg_set_buf() and passes it to the backend as the data source for the SCSI WRITE, so an over-declared length causes heap contents past the descriptor to be written through the backend to the backing store. The backend is the victim of the oversized scatterlist isert hands it, not the cause; no read-back of the written bytes was demonstrated.
Trigger: after login completes (full feature phase), an initiator that has declared a large TargetRecvDataSegmentLength and a FirstBurstLength that permits unsolicited/immediate data sends a PDU whose declared data-segment length exceeds what was received. With KASAN:
BUG: KASAN: slab-out-of-bounds in sg_copy_buffer+0x150/0x1c0 Read of size 4096 at addr ffff888109720800 by task kworker/1:0H/25 Workqueue: ib-comp-wq ib_cq_poll_work Call Trace: sg_copy_buffer+0x150/0x1c0 isert_recv_done+0xba6/0x2390 __ib_process_cq+0xe1/0x390 ib_cq_poll_work+0x46/0x150
isert_recv_done+0xba6 resolves to isert_handle_iscsi_dataout() (ib_isert.c:1160), inlined through isert_rx_opcode().
Validate wc->byte_len against the framing in isert_recv_done() before the PDU reaches any handler, and reinstate the connection if it is short. Because the test compares without subtracting the header length, it also rejects PDUs shorter than the iSER and iSCSI headers, which would otherwise be parsed out of stale descriptor contents. The login handler rejects PDUs shorter than ISER_HEADERS_LEN (commit 29e7b925ae6d ("IB/isert: Reject login PDUs shorter than ISER_HEADERS_LEN")) but does not bound the declared length either; that is fixed in the next patch. The data handlers had no length check at all.
isert reads the data segment from a fixed offset: isert_get_data() returns the iSER header plus ISER_HEADERS_LEN and makes no adjustment for an AHS. The bytes the handlers touch are therefore exactly [ISER_HEADERS_LEN, ISER_HEADERS_LEN + dlength), and comparing that sum against wc->byte_len bounds precisely the region that is read. An AHS term would only make the test stricter without bounding anything further, and cannot cause a false reject: a PDU carrying an AHS is longer, not shorter.
This is a memory-safety fix that verifies the bytes that were actually received; it does not touch RFC 7145 length negotiation and is not the MaxXmitDataSegmentLength negotiation redesign raised in the 2017 "[Query]
iSER-Target: QP errors observed on increasing MaxXmitDataSegmentLength" discussion. That redesign is explicitly out of scope here.
The patched kernel rejects the malformed DataOut PDU and both immediate-data variants with "PDU declares ... bytes were received" and continues to pass normal traffic with no regression.
Reproduced with soft-RoCE (rdma_rxe) and a raw rdma_cm/ibv initiator; no kernel-side test hooks were needed.
--- drivers/infiniband/ulp/isert/ib_isert.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/infiniband/ulp/isert/ib_isert.c +15 -0
@@ -1338,6 +1338,21 @@ isert_recv_done(struct ib_cq *cq, struct ib_wc *wc)ib_dma_sync_single_for_cpu (ib_dev, rx_desc->dma_addr,ISER_RX_SIZE ,DMA_FROM_DEVICE ); +/* +* The data segment length declared in the BHS is attacker controlled +* and is used further down to read that many bytes out of the fixed +* size receive descriptor, so it has to be checked against the number +* of bytes that were actually received. Comparing without subtracting +* also rejects PDUs shorter than the iSER and iSCSI headers, which +* would otherwise be parsed out of stale descriptor contents. +*/ +if (unlikely (wc->byte_len <ISER_HEADERS_LEN +ntoh24 (hdr->dlength))) { +isert_err ("PDU declares %u data bytes but only %u bytes were received\n" , +ntoh24 (hdr->dlength), wc->byte_len); +iscsit_cause_connection_reinstatement (isert_conn->conn,0 ); +return ; + } +isert_dbg ("DMA: 0x%llx, iSCSI opcode: 0x%02x, ITT: 0x%08x, flags: 0x%02x dlen: %d\n" , rx_desc->dma_addr, hdr->opcode, hdr->itt, hdr->flags, (int )(wc->byte_len -ISER_HEADERS_LEN ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 628/935 IB/isert: reject login PDUs declaring more data than was received
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit 2488b5b4827e5415768afc8daf097e8eb83c98df ]
isert_login_recv_done() records how many bytes the HCA actually placed in the login buffer, but nothing compares that against the length the login PDU's BHS declares. isert_rx_login_req() copies min(login_req_len, MAX_KEY_VALUE_PAIRS) bytes into login->req_buf, and the login code then reads the declared length back out of that buffer - for the first PDU in iscsi_target_locate_portal(),
payload_length = ntoh24(login_req->dlength); tmpbuf = kmemdup_nul(login->req_buf, payload_length, GFP_KERNEL);
and for the ones after it in iscsi_decode_text_input(), reached from iscsi_target_do_login().
login->req_buf is a fixed MAX_KEY_VALUE_PAIRS (8192) byte allocation, so an initiator that declares more than it sends reads off the end of it, before authentication and with the length under its control:
BUG: KASAN: slab-out-of-bounds in kmemdup_nul+0x43/0x80 Read of size 8193 at addr ffff8881056a8000 by task iscsi_np/167 __asan_memcpy+0x23/0x60 kmemdup_nul+0x43/0x80 iscsi_target_locate_portal+0x48d/0x1180 iscsi_target_login_thread+0x19a9/0x3350 Allocated by task 167: __kmalloc_cache_noprof+0x158/0x370 iscsi_target_login_thread+0x971/0x3350 which belongs to the cache kmalloc-8k of size 8192 allocated 8192-byte region
Falsifying the second login PDU instead reaches the other reader, on the same buffer:
BUG: KASAN: slab-out-of-bounds in kmemdup_nul+0x43/0x80 Read of size 8193 at addr ffff888104d10000 by task kworker/1:1/50 Workqueue: isert_login_wq iscsi_target_do_login_rx __asan_memcpy+0x23/0x60 kmemdup_nul+0x43/0x80 iscsi_decode_text_input+0xc6/0x11c0 iscsi_target_do_login+0x261/0x1470 iscsi_target_do_login_rx+0x51d/0x7d0
iscsit over TCP is not exposed: iscsit_get_login_rx() validates the declared length with iscsi_target_check_login_request() and then reads exactly that many bytes off the socket, so the declared length governs how much arrives rather than how much is copied out of an already-filled buffer. isert does not call iscsi_target_check_login_request() at all.
Reject a login PDU whose declared DataSegmentLength exceeds what was received, in both paths that reach isert_rx_login_req():isert_get_login_rx() for the first login PDU and isert_login_recv_done() for the ones after it. dlength <= login_req_len is allowed because the received count can include up to three bytes of iSCSI padding.
Once the check is in place the copy out can no longer exceed the copy in:
the posted login SGE is ISER_RX_PAYLOAD_SIZE, so login_req_len cannot exceed MAX_KEY_VALUE_PAIRS and the min() in isert_rx_login_req() is login_req_len.
Like the existing short-PDU check added by 29e7b925ae6d, the reject in isert_login_recv_done() returns without completing login_req_comp, so a malformed subsequent PDU leaves the login to be torn down by the login timer rather than failing immediately. The first-PDU path returns an error and fails straight away.
Reproduced on 7.2.0-rc4 with soft-RoCE (rdma_rxe) under KASAN, using an initiator that sends the real key=value payload while declaring 8193 in the BHS, on the first login PDU and on the second in separate runs. The reported read size tracks the declared value exactly; 16384 and 61440 behave the same. Unpatched 3 of 3 runs report on each of the two paths, patched 0 of 3 on both, run alternately in a single session, and a normal login still completes on the patched build.
--- drivers/infiniband/ulp/isert/ib_isert.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/isert/ib_isert.c +24 -1
@@ -975,6 +975,21 @@ isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,return 0 ; } +static int +isert_check_login_req (struct isert_conn *isert_conn) +{ +struct iscsi_hdr *hdr =isert_get_iscsi_hdr (isert_conn->login_desc); +u32 dlength =ntoh24 (hdr->dlength); + +if (unlikely (dlength > (u32 )isert_conn->login_req_len)) { +isert_dbg ("login PDU declares %u data bytes but only %d were received\n" , + dlength, isert_conn->login_req_len); +return -EINVAL ; + } + +return 0 ; +} +static void isert_rx_login_req (struct isert_conn *isert_conn) {
@@ -1414,8 +1429,12 @@ isert_login_recv_done(struct ib_cq *cq, struct ib_wc *wc)if (isert_conn->conn) {struct iscsi_login *login = isert_conn->conn->conn_login; -if (login && !login->first_request) +if (login && !login->first_request) { +if (isert_check_login_req (isert_conn)) +return ; +isert_rx_login_req (isert_conn); + } }mutex_lock (&isert_conn->mutex);
@@ -2380,6 +2399,10 @@ isert_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login)if (!login->first_request)return 0 ; + ret =isert_check_login_req (isert_conn); +if (ret) +return ret; +isert_rx_login_req (isert_conn);isert_info ("before login_comp conn: %p\n" , conn);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 629/935 nvme-fc: unmap cmd_iu DMA on rsp_iu mapping failure in init_request
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit f49d0c3a8d56a7cda1628ae17341a4a42063563c ]
__nvme_fc_init_request() maps cmd_iu and then rsp_iu for DMA. If the rsp_iu mapping fails, the original code only recorded the error and fell
through: it left the already-mapped cmd_iu unmapped and still marked the op as FCPOP_STATE_IDLE before returning. Since blk-mq does not call .exit_request() when .init_request() fails, the cmd_iu mapping is leaked for every op whose rsp_iu mapping fails.
Jump to an error path on rsp_iu mapping failure that unmaps cmd_iu and returns the error without marking the op idle, so it stays in the FCPOP_STATE_UNINIT state set by the initial memset().
--- drivers/nvme/host/fc.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/nvme/host/fc.c +6 -0
@@ -2100,9 +2100,15 @@ __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl,dev_err (ctrl->dev,"FCP Op failed - rspiu dma mapping failed.\n" ); ret = -EFAULT ; + goto out_unmap; }atomic_set (&op->state,FCPOP_STATE_IDLE ); +return 0 ; + +out_unmap: +fc_dma_unmap_single (ctrl->lport->dev, op->fcp_req.cmddma, +sizeof (op->cmd_iu),DMA_TO_DEVICE ); out_on_error:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 630/935 wifi: rtlwifi: pci: fix error path in rtl_pci_probe()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
[ Upstream commit 3c2999d13eeb222ae56631aeb7ca248090f2b210 ]
In the last error path in rtl_pci_probe(), the cleanup functions are skipped due to a wrong goto label. Moreover, the successful call to rtl_init_rfkill(), ieee80211_register_hw(), rtl_debug_add_one() have to be reverted. Fix this issue by updating the labels and adding the relevant cleanup functions to the last error path.
--- drivers/net/wireless/realtek/rtlwifi/pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtlwifi/pci.c +5 -1
@@ -2228,13 +2228,17 @@ int rtl_pci_probe(struct pci_dev *pdev,rtl_dbg (rtlpriv,COMP_INIT ,DBG_DMESG ,"%s: failed to register IRQ handler\n" ,wiphy_name (hw->wiphy)); - goto fail3; + goto fail6; } rtlpci->irq_alloc =1 ;set_bit (RTL_STATUS_INTERFACE_START , &rtlpriv->status);return 0 ; +fail6: +rtl_deinit_rfkill (hw); +rtl_debug_remove_one (hw); +ieee80211_unregister_hw (hw); fail5:rtl_pci_deinit (hw); fail4:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 631/935 bus: mhi: host: Flush the posted write after writing to MHI_SOC_RESET_REQ_OFFSET
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 24f4423cbc89548def2b05ae86de6175086dbf94 ]
mhi_soc_reset() tries to reset the device by writing to the MHI_SOC_RESET_REQ_OFFSET register. But it doesn't do a read-back to ensure that the write gets flushed to the device before returning to the caller.
This may lead to the delay (if implemented) on the caller to be insufficient, if the posted write doesn't reach the device before the delay.
So add a read-back after writing to the MHI_SOC_RESET_REQ_OFFSET register.
--- drivers/bus/mhi/host/main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/bus/mhi/host/main.c +6 -0
@@ -167,6 +167,9 @@ EXPORT_SYMBOL_GPL(mhi_get_mhi_state);void mhi_soc_reset (struct mhi_controller *mhi_cntrl) { +int __maybe_unused ret; +u32 tmp; +if (mhi_cntrl->reset) { mhi_cntrl->reset (mhi_cntrl);return ;
@@ -175,6 +178,9 @@ void mhi_soc_reset(struct mhi_controller *mhi_cntrl)/* Generic MHI SoC reset */ mhi_write_reg (mhi_cntrl, mhi_cntrl->regs,MHI_SOC_RESET_REQ_OFFSET ,MHI_SOC_RESET_REQ ); +/* Flush the posted write to the device (ignore return value) */ + ret =mhi_read_reg (mhi_cntrl, mhi_cntrl->regs,MHI_SOC_RESET_REQ_OFFSET , + &tmp); }EXPORT_SYMBOL_GPL (mhi_soc_reset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 632/935 md/raid5-ppl: fix use-after-free in ppl_do_flush()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sajal Gupta <[email protected]>
[ Upstream commit 371f7a1b392edc8b7cf449cc7713179b588f2d0e ]
The loop in ppl_do_flush() continues iterating after calling ppl_io_unit_finished(), touching io->pending_flushes and leading to a use-after-free.
Add a break statement to stop the loop once io is freed.
--- drivers/md/raid5-ppl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/raid5-ppl.c +3 -1
@@ -654,8 +654,10 @@ static void ppl_do_flush(struct ppl_io_unit *io) log->disk_flush_bitmap =0 ;for (i = flushed_disks ; i < raid_disks; i++) { -if (atomic_dec_and_test (&io->pending_flushes)) +if (atomic_dec_and_test (&io->pending_flushes)) {ppl_io_unit_finished (io); +break ; + } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 633/935 selftests/zram: fix kernel_gte() for POSIX sh
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cheng-Han Wu <[email protected]>
[ Upstream commit 649ba27dfac784427a01f9c95c09ecbcb88900d8 ]
Commit fc4eb486a59d ("selftests/zram: Skip max_comp_streams interface on newer kernel") added kernel_gte() to zram_lib.sh. The function uses the bash-specific [[ ... ]] conditional, but zram selftests source this file while running under /bin/sh.
On systems where /bin/sh is dash, such as Debian, the following test fails:
dash -c '
kernel_major=6; kernel_minor=1; major=6; minor=0
if [ $kernel_major -gt $major ]; then
echo ok
elif [[ $kernel_major -eq $major && $kernel_minor -ge $minor ]]; then
echo ok
fi'with:
dash: 5: [[: not found
Use separate POSIX test expressions joined by && instead.
--- tools/testing/selftests/zram/zram_lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/zram/zram_lib.sh +1 -1
@@ -37,7 +37,7 @@ kernel_gte() if [ $kernel_major -gt $major ]; then return 0 - elif [[ $kernel_major -eq $major && $kernel_minor -ge $minor ]]; then + elif [ $kernel_major -eq $major ] && [ $kernel_minor -ge $minor ]; then return 0 fi
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 634/935 power: supply: isp1704_charger: cancel work on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit 60c5b8a9ef4dbc5d69bbc1a960fe55826cb3b643 ]
The USB notifier and initial VBUS detection can schedule isp->work. The remove path unregisters the notifier and power supply, but does not wait for queued or running work before tearing down the power supply state.
Cancel the work after unregistering the notifier. Do this before unregistering the power supply.
This issue was found by a static analysis tool.
--- drivers/power/supply/isp1704_charger.c | 1 + 1 file changed, 1 insertion(+)
drivers/power/supply/isp1704_charger.c +1 -0
@@ -482,6 +482,7 @@ static int isp1704_charger_remove(struct platform_device *pdev)struct isp1704_charger *isp =platform_get_drvdata (pdev);usb_unregister_notifier (isp->phy, &isp->nb); +cancel_work_sync (&isp->work);power_supply_unregister (isp->psy);isp1704_charger_set_power (isp,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 635/935 power: supply: sc2731_charger: Convert to platform remove callback returning void
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 0569d4cfa800ba303647dbf8170d1e89bdee3ed9 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() is renamed to .remove().
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: dfc859bb8d33 ("power: supply: sc2731_charger: cancel work on remove")
--- drivers/power/supply/sc2731_charger.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/power/supply/sc2731_charger.c +2 -4
@@ -511,13 +511,11 @@ static int sc2731_charger_probe(struct platform_device *pdev)return 0 ; } -static int sc2731_charger_remove (struct platform_device *pdev) +static void sc2731_charger_remove (struct platform_device *pdev) {struct sc2731_charger_info *info =platform_get_drvdata (pdev);usb_unregister_notifier (info->usb_phy, &info->usb_notify); - -return 0 ; }static const struct of_device_id sc2731_charger_of_match[] = {
@@ -532,7 +530,7 @@ static struct platform_driver sc2731_charger_driver = { .of_match_table = sc2731_charger_of_match, }, .probe = sc2731_charger_probe, - .remove = sc2731_charger_remove, + .remove_new = sc2731_charger_remove, };module_platform_driver (sc2731_charger_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 636/935 power: supply: sc2731_charger: cancel work on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit dfc859bb8d332c525872f1a44028137724fa1998 ]
The USB notifier and initial charger detection can schedule info->work. The remove path unregisters the notifier, but does not cancel queued or running work before the devm-allocated driver data is released.
Set the platform drvdata used by remove, then cancel the work after unregistering the notifier.
This issue was found by a static analysis tool.
--- drivers/power/supply/sc2731_charger.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/power/supply/sc2731_charger.c +2 -0
@@ -466,6 +466,7 @@ static int sc2731_charger_probe(struct platform_device *pdev)mutex_init (&info->lock); info->dev = &pdev->dev;INIT_WORK (&info->work, sc2731_charger_work); +platform_set_drvdata (pdev, info); info->regmap =dev_get_regmap (pdev->dev.parent,NULL );if (!info->regmap) {
@@ -516,6 +517,7 @@ static void sc2731_charger_remove(struct platform_device *pdev)struct sc2731_charger_info *info =platform_get_drvdata (pdev);usb_unregister_notifier (info->usb_phy, &info->usb_notify); +cancel_work_sync (&info->work); }static const struct of_device_id sc2731_charger_of_match[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 637/935 bpf: Fix potential UAF in bpf_netns_link_update_prog
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Lehui <[email protected]>
[ Upstream commit 5c5997836381010fc5907b36bc17d3b19407e933 ]
In bpf_netns_link_update_prog, the checks for old_prog and prog type are currently performed locklessly before acquiring netns_bpf_mutex. This creates a race condition that can lead to a UAF issue.
If two threads concurrently execute BPF_LINK_UPDATE on the same netns link, the following execution path can trigger a UAF:
CPU0 CPU1bpf_netns_link_update_prog
if (old_prog && old_prog != link->prog)
return -EPERM;
bpf_netns_link_update_prog
if (old_prog && old_prog != link->prog)
...
old_prog = xchg(&link->prog, new_prog);
bpf_prog_put(old_prog); if (new_prog->type != link->prog->type) <-- trigger UAF
Fix this by moving the old_prog and prog->type checks inside the netns_bpf_mutex critical section. Meanwhile, use guard() to simplify lock management and avoid all the goto jumping.
--- kernel/bpf/net_namespace.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
kernel/bpf/net_namespace.c +6 -11
@@ -171,33 +171,28 @@ static int bpf_netns_link_update_prog(struct bpf_link *link,struct net *net;int idx, ret; +guard (mutex)(&netns_bpf_mutex); +if (old_prog && old_prog != link->prog)return -EPERM ;if (new_prog->type != link->prog->type)return -EINVAL ; -mutex_lock (&netns_bpf_mutex); - net = net_link->net; -if (!net || !check_net (net)) { +if (!net || !check_net (net))/* Link auto-detached or netns dying */ - ret = -ENOLINK ; - goto out_unlock; - } +return -ENOLINK ; run_array =rcu_dereference_protected (net->bpf.run_array[type],lockdep_is_held (&netns_bpf_mutex)); idx =link_index (net, type, net_link); ret =bpf_prog_array_update_at (run_array, idx, new_prog);if (ret) - goto out_unlock; +return ret; old_prog =xchg (&link->prog, new_prog);bpf_prog_put (old_prog); - -out_unlock: -mutex_unlock (&netns_bpf_mutex); -return ret; +return 0 ; } static int bpf_netns_link_fill_info(const struct bpf_link *link,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 638/935 lib/test_hmm: fail dmirror_fault() when the mirrored mm is gone
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislav Kinsburskii <[email protected]>
[ Upstream commit 6a8024511ddf4877435c34fb3d6028aa8e590649 ]
dmirror_fault() is called from the dmirror_read() and dmirror_write() retry loops after dmirror_do_read() or dmirror_do_write() finds a missing device page table entry.
If the mirrored mm has already exited, mmget_not_zero() fails. The current code returns 0 in that case, which tells the caller that faulting succeeded even though no page was faulted and no device page table entry was installed. The caller then retries the same address, hits -ENOENT again, and can loop forever without making progress.
Return -EFAULT instead, so the ioctl fails when the mirrored mm is no longer faultable.
--- lib/test_hmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_hmm.c +1 -1
@@ -297,7 +297,7 @@ static int dmirror_fault(struct dmirror *dmirror, unsigned long start,/* Since the mm is for the mirrored process, get a reference first. */ if (!mmget_not_zero (mm)) -return 0 ; +return -EFAULT ;for (addr = start; addr < end; addr = range.end) { range.start = addr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 639/935 clk: qcom: Return expected ENOMEM error on dynamic allocation failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 22d9257f08913b6eec3e8ece4d13d9c41f14428b ]
If a dynamic memory allocation fails, the returned error code in clock controller driver probe functions on a few legacy platforms should be set to -ENOMEM instead of -EINVAL.
--- drivers/clk/qcom/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/common.c +2 -2
@@ -148,7 +148,7 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,if (!node) { fixed =devm_kzalloc (dev,sizeof (*fixed),GFP_KERNEL );if (!fixed) -return -EINVAL ; +return -ENOMEM ; fixed->fixed_rate = rate; fixed->hw.init = &init_data;
@@ -165,7 +165,7 @@ static int _qcom_cc_register_board_clk(struct device *dev, const char *path,if (add_factor) { factor =devm_kzalloc (dev,sizeof (*factor),GFP_KERNEL );if (!factor) -return -EINVAL ; +return -ENOMEM ; factor->mult = factor->div =1 ; factor->hw.init = &init_data;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 640/935 iommu/dma: Check atomic pool allocation result directly
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aneesh Kumar K.V (Arm) <[email protected]>
[ Upstream commit af95a0ebc0a0db0762be75f51eadf770bad01aaa ]
The non-blocking, non-coherent allocation path uses dma_alloc_from_pool(), which returns the allocated page and fills cpu_addr only on success.
Do not rely on cpu_addr to detect allocation failure in this path. Check the returned page directly before using it for the IOMMU mapping.
--- drivers/iommu/dma-iommu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/iommu/dma-iommu.c +8 -5
@@ -1208,13 +1208,16 @@ static void *iommu_dma_alloc(struct device *dev, size_t size, }if (IS_ENABLED (CONFIG_DMA_DIRECT_REMAP ) && - !gfpflags_allow_blocking (gfp) && !coherent) + !gfpflags_allow_blocking (gfp) && !coherent) { page =dma_alloc_from_pool (dev,PAGE_ALIGN (size), &cpu_addr, - gfp,NULL ); -else + gfp,NULL ); +if (!page) +return NULL ; + }else { cpu_addr =iommu_dma_alloc_pages (dev, size, &page, gfp, attrs); -if (!cpu_addr) -return NULL ; +if (!cpu_addr) +return NULL ; + } *handle =__iommu_dma_map (dev,page_to_phys (page), size, ioprot, dev->coherent_dma_mask);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 641/935 i3c: dw: avoid shift-out-of-bounds when DAA assigns no devices
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 038cf48b3170af26a70bf2dee4f8c3ac910f5176 ]
On an empty bus ENTDAA assigns nothing, so cmd->rx_len (the count of addresses left unassigned) equals master->maxdevs.
The GENMASK() index master->maxdevs - cmd->rx_len - 1 then becomes -1, which trips up UBSAN. This happens every time on boot on a Gigabyte/AMD server:
UBSAN: shift-out-of-bounds in drivers/i3c/master/dw-i3c-master.c:905:12
shift exponent 64 is too large for 64-bit type 'long unsigned int'
CPU: 7 UID: 0 PID: 963 Comm: (udev-worker) Not tainted 7.0.11-200.fc44.x86_64 #1 PREEMPT(lazy)
Hardware name: Giga Computing E163-Z34-AAH1-000/MZ33-DC1-000, BIOS R32_F45 04/01/2026
Call Trace:
<TASK>
dump_stack_lvl+0x5d/0x80
ubsan_epilogue+0x5/0x2b
__ubsan_handle_shift_out_of_bounds.cold+0xd7/0x1ab
dw_i3c_master_daa.cold+0x1b/0x96 [dw_i3c_master]
i3c_master_do_daa_ext.part.0+0x3e/0xf0 [i3c]Skip the mask when no new device was assigned.
--- drivers/i3c/master/dw-i3c-master.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/i3c/master/dw-i3c-master.c +9 -1
@@ -810,7 +810,15 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)if (!wait_for_completion_timeout (&xfer->comp,XFER_TIMEOUT ))dw_i3c_master_dequeue_xfer (master, xfer); - newdevs =GENMASK (master->maxdevs - cmd->rx_len -1 ,0 ); +/* +* cmd->rx_len holds the number of addresses ENTDAA left unassigned. +* On an empty bus rx_len == maxdevs, so avoid GENMASK(-1, 0). +*/ +if (cmd->rx_len >= master->maxdevs) + newdevs =0 ; +else + newdevs =GENMASK (master->maxdevs - cmd->rx_len -1 ,0 ); + newdevs &= ~olddevs;for (pos =0 ; pos < master->maxdevs; pos++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 642/935 i3c: master: Fix device_register() error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 74be657d98a8d684c0475f3cbd450ef2a30ffc73 ]
When device_register() fails in i3c_master_register_new_i3c_devs(), put_device() is called to drop the reference taken by device_register(). That drops the last reference, so the device's release callback i3c_device_release() runs and frees the i3c_device.
Two problems follow from that:
i3c_device_release() does WARN_ON(i3cdev->desc), so it warns because desc->dev->desc still points back at the descriptor. Clear it before calling put_device().
After put_device() frees the i3c_device, desc->dev is left pointing at freed memory, so clear desc->dev as well. That prevents, for example, i3c_master_unregister_i3c_devs() seeing desc->dev as non-NULL and dereferencing it.
--- drivers/i3c/master.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/i3c/master.c +2 -0
@@ -1509,7 +1509,9 @@ i3c_master_register_new_i3c_devs(struct i3c_master_controller *master)if (ret) {dev_err (&master->dev,"Failed to add I3C device (err = %d)\n" , ret); + desc->dev->desc =NULL ;put_device (&desc->dev->dev); + desc->dev =NULL ; } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 643/935 locking/lockdep: Fix NULL pointer dereference in __lock_set_class()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naveen Kumar Chaudhary <[email protected]>
[ Upstream commit 7577e00b9ab506202b9f1a33de3cc8cc6413a4db ]
register_lock_class() can return NULL when the lock class pool is exhausted, graph_lock() fails, or key validation fails. However, __lock_set_class() uses the return value directly in pointer arithmetic without a NULL check:
class = register_lock_class(lock, subclass, 0); hlock->class_idx = class - lock_classes;
If class is NULL, this computes a wild offset that corrupts hlock->class_idx. The subsequent reacquire_held_locks() call will invoke hlock_class() with this corrupted index, leading to a NULL or out-of-bounds pointer dereference.
Add the missing NULL check, consistent with how __lock_acquire() already handles this case at the same call site.
--- kernel/locking/lockdep.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/locking/lockdep.c +2 -0
@@ -5202,6 +5202,8 @@ __lock_set_class(struct lockdep_map *lock, const char *name, lock->wait_type_outer, lock->lock_type); class =register_lock_class (lock, subclass,0 ); +if (!class) +return 0 ; hlock->class_idx = class - lock_classes; curr->lockdep_depth = i;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 644/935 misc: vmc_vmci: Fix potential memory leak in vmci_event_subscribe()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
[ Upstream commit 210854a96ef18b09b45a2a59ff14ca06dfe5ad4d ]
The memory allocated for struct vmci_subscription (sub) is not freed in the error path when have_new_id is false. Fix that by adding a kfree() call, and moving the read of sub->id to a point before freeing.
--- drivers/misc/vmw_vmci/vmci_event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/vmw_vmci/vmci_event.c +2 -2
@@ -179,16 +179,16 @@ int vmci_event_subscribe(u32 event, } } + *new_subscription_id = sub->id;if (have_new_id) {list_add_rcu (&sub->node, &subscriber_array[event]); retval =VMCI_SUCCESS ; }else { +kfree (sub); retval =VMCI_ERROR_NO_RESOURCES ; }mutex_unlock (&subscriber_mutex); - - *new_subscription_id = sub->id;return retval; }EXPORT_SYMBOL_GPL (vmci_event_subscribe);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 645/935 fanotify: report full event length for FIONREAD
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit 68615158c12de36220446dfea5cfdf9ba6c19690 ]
fanotify_ioctl(FIONREAD) reports the number of bytes available to read from the event queue. It currently accounts only FAN_EVENT_METADATA_LEN for each queued event.
That underestimates events that carry additional information records, such as FAN_REPORT_DFID_NAME events. A userspace program that uses FIONREAD to size its read buffer can receive a length that is smaller than the next event. Reading with that buffer then fails with -EINVAL, while a larger buffer succeeds and reports a larger metadata.event_len.
Use fanotify_event_len() when summing queued events so FIONREAD includes all info records.
--- fs/notify/fanotify/fanotify_user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/notify/fanotify/fanotify_user.c +4 -1
@@ -908,11 +908,13 @@ static long fanotify_ioctl(struct file *file, unsigned int cmd, unsigned long ar {struct fsnotify_group *group;struct fsnotify_event *fsn_event; +unsigned int info_mode;void __user *p;int ret = -ENOTTY ;size_t send_len =0 ; group = file->private_data; + info_mode =FAN_GROUP_FLAG (group,FANOTIFY_INFO_MODES ); p = (void __user *) arg;
@@ -920,7 +922,8 @@ static long fanotify_ioctl(struct file *file, unsigned int cmd, unsigned long arcase FIONREAD :spin_lock (&group->notification_lock);list_for_each_entry (fsn_event, &group->notification_list, list) - send_len +=FAN_EVENT_METADATA_LEN ; + send_len +=fanotify_event_len (info_mode, +FANOTIFY_E (fsn_event));spin_unlock (&group->notification_lock); ret =put_user (send_len, (int __user *) p);break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 646/935 wifi: mt76: mt76x02: do not WARN on invalid rx descriptor length
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Devin Wittmayer <[email protected]>
[ Upstream commit 81497634d9f872fd3e8b03aada55574afff6f174 ]
The MPDU length in the rx descriptor comes from the hardware. In monitor mode with the fcsfail filter enabled, the hardware passes up corrupted frames, and a corrupted frame can report a length larger than the received buffer. The bounds check correctly discards such frames, but its WARN_ON_ONCE wrapper means any over-the-air garbage frame taints the kernel, and panics it on the first such frame when panic_on_warn is set.
Drop the WARN and discard the frame silently, matching what commit c2d4c8723dbf ("mt76x2: remove some harmless WARN_ONs in tx status and rx path") did for the neighboring rx and tx status paths.
Observed immediately on rx with an MT7612U in fcsfail monitor mode on a busy channel.
--- drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +1 -1
@@ -850,7 +850,7 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb, } } -if (WARN_ON_ONCE (len > skb->len)) +if (len > skb->len)return -EINVAL ;pskb_trim (skb, len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 647/935 wifi: mt76: mt792x: Fix memory leak in SDIO TX path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eason Lai <[email protected]>
[ Upstream commit 808f2767d4217a5b96f674288573b9b89d432eed ]
When tx_prepare_skb() returns an error in the SDIO TX path, the skb is not freed, leading to a memory leak. This can occur when zero-length frames (such as WNM NULL frames) are dropped to prevent potential hardware TX hangs.
Fix this by properly releasing the skb with ieee80211_tx_status_ext() when tx_prepare_skb() fails.
--- drivers/net/wireless/mediatek/mt76/sdio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/sdio.c +10 -1
@@ -246,6 +246,10 @@ mt76s_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q, enum mt76_txq_id qid, struct sk_buff *skb, struct mt76_wcid *wcid, struct ieee80211_sta *sta) { + struct ieee80211_tx_status status = { + .sta = sta, + }; +struct mt76_tx_info tx_info = { .skb = skb, };
@@ -257,8 +261,13 @@ mt76s_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q, skb->prev = skb->next =NULL ; err = dev->drv->tx_prepare_skb (dev,NULL , qid, wcid, sta, &tx_info); -if (err <0 ) +if (err <0 ) { + status.skb = tx_info.skb; +spin_lock_bh (&dev->rx_lock); +ieee80211_tx_status_ext (dev->hw, &status); +spin_unlock_bh (&dev->rx_lock);return err; + } q->entry[q->head].skb = tx_info.skb; q->entry[q->head].buf_sz = len;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 648/935 wifi: mt76: mt7915: avoid nss underflow in mt7915_mcu_get_sta_nss
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit 4a2f4be532e3ea4e2b536e411793a05aaa51af25 ]
If a peer's VHT/HE MCS map has no supported spatial stream (all fields 0x3), the loop exits with nss == 0 and the function returned (u8)-1 (255), which was then written into the firmware sta_rec_bf beamforming fields. Clamp the result to 0.
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
@@ -206,7 +206,7 @@ mt7915_mcu_get_sta_nss(u16 mcs_map)break ; } -return nss -1 ; +return nss ? nss -1 :0 ; } static void
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 649/935 wifi: mt76: mt7915: use little-endian for bss_info_ra wire fields
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit 04280d0a56be4264720e7b205daaa332c715e5ec ]
train_up_high_thres, train_up_rule_rssi and low_traffic_thres were declared as host-native short in a firmware-facing TLV and assigned host-order constants, so on a big-endian host the firmware received byte-swapped rate-adaptation thresholds. Declare them __le16 and convert with cpu_to_le16().
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 6 +++--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +3 -3
@@ -1008,9 +1008,9 @@ mt7915_mcu_bss_ra_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, ra->rx_streams = max_nss; ra->algo =4 ; ra->train_up_rule =2 ; - ra->train_up_high_thres =110 ; - ra->train_up_rule_rssi =-70 ; - ra->low_traffic_thres =2 ; + ra->train_up_high_thres =cpu_to_le16 (110 ); + ra->train_up_rule_rssi =cpu_to_le16 (-70 ); + ra->low_traffic_thres =cpu_to_le16 (2 ); ra->phy_cap =cpu_to_le32 (0xfdf ); ra->interval =cpu_to_le32 (500 ); ra->fast_interval =cpu_to_le32 (100 );
drivers/net/wireless/mediatek/mt76/mt7915/mcu.h +3 -3
@@ -526,9 +526,9 @@ struct bss_info_ra {u8 antenna_idx;u8 train_up_rule;u8 rsv[3 ]; -unsigned short train_up_high_thres; -short train_up_rule_rssi; -unsigned short low_traffic_thres; +__le16 train_up_high_thres; +__le16 train_up_rule_rssi; +__le16 low_traffic_thres;__le16 max_phyrate;__le32 phy_cap;__le32 interval;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 650/935 perf: arm_spe: Make wakeup range check overflow safe
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit fcc5eaea2d234162dfb8258372dd897bc2a1b862 ]
The current code checks whether the wakeup point is in the current writable range by comparing it with handle->head + handle->size.
The perf AUX head is a monotonically increasing index, so that addition can overflow when head is close to ULONG_MAX. In that case, a wakeup point which is still inside the free space range can be missed.
Use unsigned subtraction to compare the distance from head to wakeup against the handle->size. This can dismiss the issue when addition overflow.
This is unlikely to happen in practice, but the change makes the watermark check logically correct.
--- drivers/perf/arm_spe_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/arm_spe_pmu.c +1 -1
@@ -457,7 +457,7 @@ static u64 __arm_spe_pmu_next_off(struct perf_output_handle *handle)* the page boundary following it. Keep the tail boundary if * that's lower. */ -if (handle->wakeup < (handle->head + handle->size) && head <= wakeup) +if ((handle->wakeup - handle->head) < handle->size && head <= wakeup) limit =min (limit,round_up (wakeup,PAGE_SIZE ));if (limit > head)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 651/935 drm/msm/dsi: Drop dev_pm_opp_set_rate(0)
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 06b7ba206561619bb34116f49e0ef26b867ce3aa ]
dev_pm_opp_set_rate(0) removes the vote specified in required-opps but does not actually park the clock, making it run without the necessary power backing. Drop the explicit call to it.
Every call site of ops->link_clk_disable() is followed by pm_runtime_put(), so the power vote will be rescinded if deemed safe.
Patchwork: https://patchwork.freedesktop.org/patch/742783/
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/msm/dsi/dsi_host.c +0 -2
@@ -656,8 +656,6 @@ int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host)void dsi_link_clk_disable_6g (struct msm_dsi_host *msm_host) { -/* Drop the performance state vote */ -dev_pm_opp_set_rate (&msm_host->pdev->dev,0 );clk_disable_unprepare (msm_host->esc_clk);clk_disable_unprepare (msm_host->pixel_clk);if (msm_host->byte_intf_clk)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 652/935 wifi: ath11k: fix leak in ath11k_service_ready_ext_event()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 0293be2212d319d59589082461abf2a9b626cd1c ]
Currently, during ath11k_service_ready_ext_event() processing, svc_rdy_ext.mac_phy_caps can be allocated during TLV parsing. This is a temporary allocation that is freed on the success path, but not on the error path. If parsing succeeds far enough to allocate mac_phy_caps and then fails on a later TLV, the allocation leaks. So free the allocation on the error path.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/wmi.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath11k/wmi.c +1 -0
@@ -4355,6 +4355,7 @@ static int ath11k_service_ready_ext_event(struct ath11k_base *ab,return 0 ; err: +kfree (svc_rdy_ext.mac_phy_caps);ath11k_wmi_free_dbring_caps (ab);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 653/935 regulator: core: use system_freezable_wq for init complete work
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joy Zou <[email protected]>
[ Upstream commit 03eab318cedd6ae34ecd34533cd986edf5237164 ]
schedule_delayed_work() uses system_wq, which is non-freezable, allowing regulator_init_complete_work to run concurrently with system suspend. This work fires ~30s after boot to disable unused regulators via I2C. When it races with PM suspend, the I2C adapter may already be suspended, triggering a -ESHUTDOWN warning in __i2c_transfer():
WARNING: ... at __i2c_transfer+0x36c/0x3c8
Call trace: __i2c_transfer i2c_transfer regmap_i2c_write _regmap_update_bits regulator_disable_regmap _regulator_do_disable regulator_late_cleanup regulator_init_complete_work_function process_one_work
Switch to system_freezable_wq so the work is frozen before any device is suspended, eliminating the race.
--- drivers/regulator/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/regulator/core.c +4 -2
@@ -26,6 +26,7 @@#include <linux/regulator/driver.h> #include <linux/regulator/machine.h> #include <linux/module.h> +#include <linux/workqueue.h> #define CREATE_TRACE_POINTS #include <trace/events/regulator.h>
@@ -6245,8 +6246,9 @@ static int __init regulator_init_complete(void)* we'd only do this on systems that need it, and a kernel * command line option might be useful. */ -schedule_delayed_work (®ulator_init_complete_work, -msecs_to_jiffies (30000 )); +queue_delayed_work (system_freezable_wq, + ®ulator_init_complete_work, +msecs_to_jiffies (30000 ));return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 654/935 perf machine: Guard against NULL strlist in machines__findnew()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit e27b96d0a34e1dc87affecf221a99fee8f6c5afc ]
The static 'seen' strlist caches guestmount paths that have already been reported as inaccessible, to avoid repeating the error message. If strlist__new() fails (OOM), 'seen' stays NULL and the next call dereferences it via strlist__has_entry() and strlist__add().
Guard both calls so that on allocation failure the error message is still printed (just not deduplicated) instead of crashing.
--- tools/perf/util/machine.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/util/machine.c +3 -2
@@ -355,9 +355,10 @@ struct machine *machines__findnew(struct machines *machines, pid_t pid)if (!seen) seen =strlist__new (NULL ,NULL ); -if (!strlist__has_entry (seen, path)) { +if (!seen || !strlist__has_entry (seen, path)) {pr_err ("Can't access file %s\n" , path); -strlist__add (seen, path); +if (seen) +strlist__add (seen, path); } machine =NULL ; goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 655/935 perf machine: Use snprintf() for guestmount path construction
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit fe63d3bca288c5bb983304efd5fc3a5ff3183403 ]
machines__findnew() and machines__create_guest_kernel_maps() use sprintf() to build paths by prepending symbol_conf.guestmount. Both write into PATH_MAX stack buffers, but guestmount comes from user configuration and is not length-checked. A guestmount path at or near PATH_MAX causes a stack buffer overflow.
Switch to snprintf() with sizeof() to prevent overflow. The subsequent access()/fopen() calls will fail on a truncated path.
Stable-dep-of: cc6abe0012bf ("perf machine: Check snprintf truncation in machines__findnew()")
--- tools/perf/util/machine.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/machine.c +4 -4
@@ -348,7 +348,7 @@ struct machine *machines__findnew(struct machines *machines, pid_t pid)if ((pid !=HOST_KERNEL_ID ) && (pid !=DEFAULT_GUEST_KERNEL_ID ) && (symbol_conf.guestmount)) { -sprintf (path,"%s/%d" , symbol_conf.guestmount, pid); +snprintf (path,sizeof (path),"%s/%d" , symbol_conf.guestmount, pid);if (access (path,R_OK )) {static struct strlist *seen;
@@ -1261,9 +1261,9 @@ int machines__create_guest_kernel_maps(struct machines *machines) namelist[i]->d_name);continue ; } -sprintf (path,"%s/%s/proc/kallsyms" , - symbol_conf.guestmount, - namelist[i]->d_name); +snprintf (path,sizeof (path),"%s/%s/proc/kallsyms" , + symbol_conf.guestmount, + namelist[i]->d_name); ret =access (path,R_OK );if (ret) {pr_debug ("Can't access file %s\n" , path);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 656/935 perf machine: Check snprintf truncation in machines__findnew()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit cc6abe0012bf8c04af8275266f8ed7c55ba4a5fb ]
The guestmount path is built with snprintf() into a PATH_MAX buffer without checking the return value. If symbol_conf.guestmount is long enough to cause truncation, the truncated path could match a different directory, causing the wrong guest to be associated with the pid.
Check for truncation and bail out early.
--- tools/perf/util/machine.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/perf/util/machine.c +6 -1
@@ -348,7 +348,12 @@ struct machine *machines__findnew(struct machines *machines, pid_t pid)if ((pid !=HOST_KERNEL_ID ) && (pid !=DEFAULT_GUEST_KERNEL_ID ) && (symbol_conf.guestmount)) { -snprintf (path,sizeof (path),"%s/%d" , symbol_conf.guestmount, pid); +if (snprintf (path,sizeof (path),"%s/%d" , + symbol_conf.guestmount, pid) >= (int )sizeof (path)) { +pr_err ("Guest path too long for pid %d\n" , pid); + machine =NULL ; + goto out; + }if (access (path,R_OK )) {static struct strlist *seen;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 657/935 perf machine: Dont abort guest map creation on first inaccessible dir
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit b687e1a418fb819ef83c362d84c216a6a841e3b0 ]
machines__create_guest_kernel_maps() jumps to the failure label when one guest directory's kallsyms file fails access(), skipping all remaining valid guest directories. An inaccessible directory is not fatal — other guests may still be reachable.
Replace 'goto failure' with 'continue' so the loop processes all directories, and remove the now-unreferenced failure label.
--- tools/perf/util/machine.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
tools/perf/util/machine.c +2 -4
@@ -1269,14 +1269,12 @@ int machines__create_guest_kernel_maps(struct machines *machines)snprintf (path,sizeof (path),"%s/%s/proc/kallsyms" , symbol_conf.guestmount, namelist[i]->d_name); - ret =access (path,R_OK ); -if (ret) { +if (access (path,R_OK )) {pr_debug ("Can't access file %s\n" , path); - goto failure; +continue ; }machines__create_kernel_maps (machines, pid); } -failure:free (namelist); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 658/935 perf machine: Reset errno before strtol in guest kernel map creation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 29ec46e43f6ca7d6a6651db724d4ffd820f46e8b ]
machines__create_guest_kernel_maps() checks errno == ERANGE after strtol() to detect overflow, but does not clear errno first. A stale ERANGE from an earlier library call (e.g. scandir internals) causes valid numeric directory names to be incorrectly skipped.
Set errno = 0 before strtol() so only the current conversion can trigger the ERANGE check.
--- tools/perf/util/machine.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/machine.c +1 -0
@@ -1258,6 +1258,7 @@ int machines__create_guest_kernel_maps(struct machines *machines)/* Filter out . and .. */ continue ; } + errno =0 ; pid = (pid_t )strtol (namelist[i]->d_name, &endp,10 ); if ((*endp != '\0') || (endp == namelist[i]->d_name) ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 659/935 perf machine: Free scandir entries in guest kernel map creation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit f53bf58dcd11e1cb088d3b91a035fef77062094b ]
machines__create_guest_kernel_maps() calls scandir() which allocates both the namelist array and each individual dirent entry. The code frees the namelist array but not the individual entries, leaking memory proportional to the number of directories under guestmount.
Free each namelist[i] after it is no longer needed.
--- tools/perf/util/machine.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/util/machine.c +4 -0
@@ -1256,6 +1256,7 @@ int machines__create_guest_kernel_maps(struct machines *machines)for (i =0 ; i < items; i++) {if (!isdigit (namelist[i]->d_name[0 ])) {/* Filter out . and .. */ +free (namelist[i]);continue ; } errno =0 ;
@@ -1265,6 +1266,7 @@ int machines__create_guest_kernel_maps(struct machines *machines) (errno == ERANGE)) {pr_debug ("invalid directory (%s). Skipping.\n" , namelist[i]->d_name); +free (namelist[i]);continue ; } snprintf(path, sizeof(path), "%s/%s/proc/kallsyms",
@@ -1272,9 +1274,11 @@ int machines__create_guest_kernel_maps(struct machines *machines) namelist[i]->d_name);if (access (path,R_OK )) {pr_debug ("Can't access file %s\n" , path); +free (namelist[i]);continue ; }machines__create_kernel_maps (machines, pid); +free (namelist[i]); }free (namelist); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 660/935 perf machine: Check snprintf truncation for guest kallsyms path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit d04ef71492fad7230d474efe33d05f4c0563d409 ]
machines__create_guest_kernel_maps() builds the guest kallsyms path with snprintf() without checking the return value. A truncated path could pass the access() check if a prefix directory happens to contain a file named "kallsyms", leading to the wrong file being used for symbol resolution.
Check for truncation and skip the directory.
--- tools/perf/util/machine.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/perf/util/machine.c +8 -3
@@ -1269,9 +1269,14 @@ int machines__create_guest_kernel_maps(struct machines *machines)free (namelist[i]);continue ; } -snprintf (path,sizeof (path),"%s/%s/proc/kallsyms" , - symbol_conf.guestmount, - namelist[i]->d_name); +if (snprintf (path,sizeof (path),"%s/%s/proc/kallsyms" , + symbol_conf.guestmount, + namelist[i]->d_name) >= (int )sizeof (path)) { +pr_debug ("Guest kallsyms path too long for %s. Skipping.\n" , + namelist[i]->d_name); +free (namelist[i]); +continue ; + }if (access (path,R_OK )) {pr_debug ("Can't access file %s\n" , path);free (namelist[i]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 661/935 wifi: ath10k: snoc: use memcpy_fromio() for MSA ramdump
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linghui Wu <[email protected]>
[ Upstream commit 4f25071afe9218aaae1c63fbf75e229aa6405319 ]
On WCN3990/SNOC the MSA region is mapped with devm_memremap(MEMREMAP_WT). On arm64 such a mapping is not Normal-cacheable, so unaligned accesses to it are not permitted. ath10k_msa_dump_memory() copies the region with a plain memcpy(), whose optimized __pi_memcpy_generic implementation issues wide/unaligned loads. This triggers an alignment fault (FSC=0x21) Oops in ath10k_snoc_fw_crashed_dump() while collecting the devcoredump:
Unable to handle kernel paging request ... FSC=0x21: alignment fault pc : __pi_memcpy_generic lr : ath10k_snoc_fw_crashed_dump [ath10k_snoc]
The Oops both leaves the firmware RAM dump buffer zeroed (no dump is captured) and crashes the kernel, which in turn breaks modem SSR recovery.
Use memcpy_fromio(), which only performs accesses that are valid for such a device-memory mapping. The generic memcpy_fromio() implementation aligns the source before issuing word-sized reads and stores the destination with put_unaligned(), so it is also safe for the coherent DMA allocation used on the non-reserved-memory path. ath11k and ath12k use the same pattern when copying target memory into crash dumps, so call it unconditionally here too.
The MEMREMAP_WT pointer is a plain void *, so an explicit __iomem cast is needed; use __force to keep sparse happy.
Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.3.7.c5-00107-QCAHLSWMTPL-1
--- drivers/net/wireless/ath/ath10k/snoc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/snoc.c +7 -2
@@ -5,6 +5,7 @@#include <linux/bits.h> #include <linux/clk.h> +#include <linux/io.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h>
@@ -1457,11 +1458,15 @@ static void ath10k_msa_dump_memory(struct ath10k *ar, hdr->length =cpu_to_le32 (ar->msa.mem_size);if (current_region->len < ar->msa.mem_size) { -memcpy (buf, ar->msa.vaddr, current_region->len); +memcpy_fromio (buf, + (const void __iomem __force *)ar->msa.vaddr, + current_region->len);ath10k_warn (ar,"msa dump length is less than msa size %x, %x\n" , current_region->len, ar->msa.mem_size); }else { -memcpy (buf, ar->msa.vaddr, ar->msa.mem_size); +memcpy_fromio (buf, + (const void __iomem __force *)ar->msa.vaddr, + ar->msa.mem_size); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 662/935 iommu/arm-smmu-v3: Convert to use atomic poll timeout
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pranjal Shrivastava <[email protected]>
[ Upstream commit eced8058c82a3a81ae480a6546e2da32100dddfa ]
The arm_smmu_write_reg_sync() helper is currently implemented using readl_relaxed_poll_timeout() (that relies on usleep_range() internally) which becomes a critical issue when used in the gerror irq handler.
If the SMMU hits a gerror and enters Service Failure Mode (GERROR_SFM_ERR), the gerror handler calls arm_smmu_device_disable() in hard-irq context. This becomes a problem as arm_smmu_device_disable() inevitably calls arm_smmu_write_reg_sync() which might attempt to sleep inside a hard-irq context.
Fix this by converting the arm_smmu_write_reg_sync to use the readl_relaxed_poll_timeout_atomic() polling helper.
(Discovered while running Sashiko locally on another patch series).
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +3 -2
@@ -3161,8 +3161,9 @@ static int arm_smmu_write_reg_sync(struct arm_smmu_device *smmu, u32 val,u32 reg;writel_relaxed (val, smmu->base + reg_off); -return readl_relaxed_poll_timeout (smmu->base + ack_off, reg, reg == val, -1 ,ARM_SMMU_POLL_TIMEOUT_US ); +return readl_relaxed_poll_timeout_atomic (smmu->base + ack_off, reg, + reg == val,1 , +ARM_SMMU_POLL_TIMEOUT_US ); }/* GBPA is "special" */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 663/935 wifi: mac80211: send TWT teardown to peer after setup TX failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit a28fcce6ee74be8a4526e6cfa16dc7786d62a784 ]
When an AP's TWT Setup response is not acknowledged, ieee80211_s1g_tx_twt_setup_fail() asks the driver to tear down the local agreement and sends a TWT teardown action as the peer notification. It uses the response SA as the destination, but ieee80211_s1g_send_twt_setup() built that response with SA set to the AP's address. The teardown is therefore queued with DA, SA and BSSID all set to the AP address and never reaches the station.
The in-tree driver callbacks update local hardware state and emit no action frame. The station receives no notification that mac80211 asked the driver to remove the agreement and can keep following the TWT schedule, leaving the peers' power-save state desynchronized.
Address the teardown to the response DA, the station to which the failed response was sent. This also matches the station lookup the transmit status path already performs on the same frame.
--- net/mac80211/s1g.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/s1g.c +1 -1
@@ -146,7 +146,7 @@ ieee80211_s1g_tx_twt_setup_fail(struct ieee80211_sub_if_data *sdata,drv_twt_teardown_request (sdata->local, sdata, &sta->sta, flowid); -ieee80211_s1g_send_twt_teardown (sdata, mgmt->sa, sdata->vif.addr, +ieee80211_s1g_send_twt_teardown (sdata, mgmt->da, sdata->vif.addr, flowid); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 664/935 wifi: zd1211rw: reject secondary interfaces to prevent conflicts
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slawomir Stepien <[email protected]>
[ Upstream commit 0e4532ec658606f76f62eb277e7a933919d36cbb ]
The zd1211rw driver is designed for single-function Wi-Fi dongles and hardcodes its USB endpoints. When a malformed USB device exposes multiple interfaces that match the driver's device ID, the driver blindly binds to all of them.
During probe(), the driver calls usb_reset_device(), which iterates over all interfaces and invokes the pre_reset() callback for each bound interface. Since multiple interfaces are bound to zd1211rw, pre_reset() is called sequentially for each instance, acquiring their respective &mac->chip.mutex. Because all instances initialize their mutexes with the same lock class, lockdep detects a task acquiring a lock of the same class it already holds and flags it as a possible recursive deadlock:
WARNING: possible recursive locking detected kworker/0:1/11 is trying to acquire lock:ffff88810371dde0 (&chip->mutex){+.+.}-{4:4}, at:zd_chip_disable_rxtx+0x20/0x50 drivers/net/wireless/zydas/zd1211rw/zd_chip.c:1465
but task is already holding lock:ffff8881138ddde0 (&chip->mutex){+.+.}-{4:4}, at: pre_reset+0x28c/0x380 drivers/net/wireless/zydas/zd1211rw/zd_usb.c:1505
Fix this by explicitly rejecting secondary interfaces (bInterfaceNumber !=
0) during probe(). This ensures that only a single instance of the driver binds to the device, eliminating the recursive locking scenario.
--- drivers/net/wireless/zydas/zd1211rw/zd_usb.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/wireless/zydas/zd1211rw/zd_usb.c +8 -0
@@ -1352,6 +1352,14 @@ static int probe(struct usb_interface *intf, const struct usb_device_id *id)struct zd_usb *usb;struct ieee80211_hw *hw =NULL ; +/* +* ZD1211 devices are single-function. Reject secondary interfaces +* to prevent multiple instances from conflicting on hardcoded endpoints +* and triggering recursive locking warnings. +*/ +if (intf->cur_altsetting->desc.bInterfaceNumber !=0 ) +return -ENODEV ; +print_id (udev);if (id->driver_info &DEVICE_INSTALLER )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 665/935 wifi: mac80211: skip unused probe response countdown offsets
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit fd2bf5e718108c00732eb07fd94a5d8830f62a9f ]
mac80211 copies cfg80211's variable-length countdown offset list into a zero-initialized fixed-size array, leaving unused entries at zero. The beacon branch already skips those zero entries, but the AP probe-response branch writes through them unconditionally.
When a probe-response template has no countdown offset, the write through an unused zero entry overwrites resp->data[0], corrupting the first byte of the template. cfg80211 already bounds explicitly supplied non-zero offsets in nl80211_parse_counter_offsets(), so this is a zero-sentinel bug, not an out-of-bounds write.
Skip zero probe-response offsets, matching the beacon path.
--- net/mac80211/tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/tx.c +2 -1
@@ -4862,7 +4862,8 @@ static void ieee80211_set_beacon_cntdwn(struct ieee80211_sub_if_data *sdata,if (sdata->vif.type ==NL80211_IFTYPE_AP && resp) {u16 *resp_offsets = resp->cntdwn_counter_offsets; - resp->data[resp_offsets[i]] = count; +if (resp_offsets[i]) + resp->data[resp_offsets[i]] = count; } }rcu_read_unlock ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 666/935 firmware: google: Add bounds checks in coreboot_table_populate()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Titouan Ameline de Cadeville <[email protected]>
[ Upstream commit 7b1a1af4556a4f95ef273e91435fe804cbfcd223 ]
coreboot_table_populate() iterates over firmware-provided table entries with no validation that the entries stay within the mapped memory region. A corrupt table with a large entry->size advances ptr_entry past the mapped region, causing an out-of-bounds read on the next iteration.
Add a check before dereferencing ptr_entry to ensure the entry header is readable, and a second check after reading entry->size to ensure the full entry stays within the mapped region.
Pass len from coreboot_table_probe() into coreboot_table_populate() to make the mapped region size available for validation.
Stable-dep-of: a58a57a1076f ("firmware: coreboot: Validate table bounds")
--- drivers/firmware/google/coreboot_table.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/firmware/google/coreboot_table.c +9 -2
@@ -81,16 +81,20 @@ void coreboot_driver_unregister(struct coreboot_driver *driver) }EXPORT_SYMBOL (coreboot_driver_unregister); -static int coreboot_table_populate (struct device *dev,void *ptr) +static int coreboot_table_populate (struct device *dev,void *ptr,resource_size_t len) {int i, ret;void *ptr_entry;struct coreboot_device *device;struct coreboot_table_entry *entry;struct coreboot_table_header *header = ptr; +void *ptr_end; + ptr_end = ptr + len; ptr_entry = ptr + header->header_bytes;for (i =0 ; i < header->table_entries; i++) { +if (ptr_entry +sizeof (*entry) > ptr_end) +return -EINVAL ; entry = ptr_entry;if (entry->size <sizeof (*entry)) {
@@ -98,6 +102,9 @@ static int coreboot_table_populate(struct device *dev, void *ptr)return -EINVAL ; } +if (ptr_entry + entry->size > ptr_end) +return -EINVAL ; + device =kzalloc (sizeof (device->dev) + entry->size,GFP_KERNEL );if (!device)return -ENOMEM ;
@@ -154,7 +161,7 @@ static int coreboot_table_probe(struct platform_device *pdev)if (!ptr)return -ENOMEM ; - ret =coreboot_table_populate (dev, ptr); + ret =coreboot_table_populate (dev, ptr, len);memunmap (ptr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 667/935 firmware: coreboot: Validate table bounds
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laxman Acharya Padhya <[email protected]>
[ Upstream commit a58a57a1076f8c5dae0327e3710899478c3be901 ]
The existing coreboot_table_populate() bounds checks limit individual entries to the mapped length. However, coreboot_table_probe() replaces the platform resource length with header and table sizes supplied by firmware before mapping the full table.
A malformed table can overflow the 32-bit size addition or advertise an extent beyond the resource, causing the driver to map and parse memory outside the resource. A resource shorter than the fixed header is also mapped as though it contained a complete header.
Reject resources shorter than the fixed header. After validating the signature, require a complete header, calculate the advertised extent with overflow checking, and reject extents beyond the resource before remapping the table.
--- drivers/firmware/google/coreboot_table.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/firmware/google/coreboot_table.c +13 -4
@@ -130,6 +130,7 @@ static int coreboot_table_populate(struct device *dev, void *ptr, resource_size_static int coreboot_table_probe (struct platform_device *pdev) {resource_size_t len; +resource_size_t table_span;struct coreboot_table_header *header;struct resource *res;struct device *dev = &pdev->dev;
@@ -141,7 +142,7 @@ static int coreboot_table_probe(struct platform_device *pdev)return -EINVAL ; len =resource_size (res); -if (!res->start || !len) +if (!res->start || len <sizeof (*header))return -EINVAL ;/* Check just the header first to make sure things are sane */
@@ -149,19 +150,27 @@ static int coreboot_table_probe(struct platform_device *pdev)if (!header)return -ENOMEM ; - len = header->header_bytes + header->table_bytes; ret =strncmp (header->signature,"LBIO" ,sizeof (header->signature)); + +if (!ret && + (header->header_bytes <sizeof (*header) || +check_add_overflow ((resource_size_t )header->header_bytes, + (resource_size_t )header->table_bytes, + &table_span) || + table_span > len)) + ret = -EINVAL ; +memunmap (header);if (ret) {dev_warn (dev,"coreboot table missing or corrupt!\n" );return -ENODEV ; } - ptr =memremap (res->start, len,MEMREMAP_WB ); + ptr =memremap (res->start, table_span,MEMREMAP_WB );if (!ptr)return -ENOMEM ; - ret =coreboot_table_populate (dev, ptr, len); + ret =coreboot_table_populate (dev, ptr, table_span);memunmap (ptr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 668/935 powerpc/smp: add NULL guard for cause_ipi in smp_muxed_ipi_message_pass
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gou Hao <[email protected]>
[ Upstream commit 5aabc192702defb8950e7c81b05c3f4ca8ee43ec ]
smp_muxed_ipi_message_pass() calls smp_ops->cause_ipi() without checking whether it has been set.
On platforms using muxed IPI (e.g. powernv/pseries), smp_ops->cause_ipi is initialized to NULL in the static smp_ops and only assigned during the platform smp_probe() handler. If the IPI subsystem fails to initialize -- for example when xive_init_ipis() fails and xive_smp_probe() returns an error -- the probe handler returns early and cause_ipi is never set. Any subsequent IPI send (e.g. arch_smp_send_reschedule()) would dereference the NULL pointer.
Add a NULL check to avoid the crash in that situation.
--- arch/powerpc/kernel/smp.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/kernel/smp.c +3 -0
@@ -296,6 +296,9 @@ void smp_muxed_ipi_set_message(int cpu, int msg)void smp_muxed_ipi_message_pass (int cpu,int msg) { +if (!smp_ops->cause_ipi) +return ; +smp_muxed_ipi_set_message (cpu, msg);/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 669/935 MIPS: ptrace: Fix syscall skipping via PTRACE_SYSCALL
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Bogendoerfer <[email protected]>
[ Upstream commit 5475c03fa25f31cfd5f8c7e552f8d10347bbaad9 ]
If tracer wanted to skip a syscall return value was always overwritten with -ENOSYS. Fix this by checking against original syscall number and only return -ENOSYS, if it is negative.
--- arch/mips/kernel/ptrace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/mips/kernel/ptrace.c +5 -1
@@ -1312,8 +1312,12 @@ long arch_ptrace(struct task_struct *child, long request,*/ asmlinkage long syscall_trace_enter (struct pt_regs *regs) { +long syscall; +user_exit (); + syscall =current_thread_info ()->syscall; +if (test_thread_flag (TIF_SYSCALL_TRACE )) {if (tracehook_report_syscall_entry (regs))return -1 ;
@@ -1349,7 +1353,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs)* Negative syscall numbers are mistaken for rejected syscalls, but * won't have had the return value set appropriately, so we do so now. */ -if (current_thread_info ()->syscall <0 ) +if (syscall <0 )syscall_set_return_value (current, regs, -ENOSYS ,0 );return current_thread_info ()->syscall; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 670/935 serial: amba-pl011: unprepare console clock on unregister
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 7f93da9d78d433c37836d85de475c5d884ad58ed ]
pl011_console_setup() calls clk_prepare() on the UART clock, but the console provides no matching teardown, so the clock is never unprepared when the console is unregistered -- via the sysfs "console" attribute or a driver unbind. Each re-registration prepares the clock again, leaking one prepare reference per cycle.
Even where preparing the clock has no hardware effect, the stale reference leaves the clock framework's prepare count unbalanced. For providers with prepare/unprepare operations or runtime-PM integration, it may also retain resources after the console is unregistered.
Add a console .exit() callback that clk_unprepare()s the clock, balancing the clk_prepare() in pl011_console_setup().
--- drivers/tty/serial/amba-pl011.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/tty/serial/amba-pl011.c +10 -0
@@ -2470,6 +2470,15 @@ static int pl011_console_setup(struct console *co, char *options)return uart_set_options (&uap->port, co, baud, parity, bits, flow); } +static int pl011_console_exit (struct console *co) +{ +struct uart_amba_port *uap = amba_ports[co->index]; + +clk_unprepare (uap->clk); + +return 0 ; +} +/** * pl011_console_match - non-standard console matching * @co: registering console
@@ -2536,6 +2545,7 @@ static struct console amba_console = { .write = pl011_console_write, .device = uart_console_device, .setup = pl011_console_setup, + .exit = pl011_console_exit, .match = pl011_console_match, .flags = CON_PRINTBUFFER | CON_ANYTIME, .index = -1,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 671/935 tty: clear cdev pointer after cdev_add() failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 6645856f0df3aeecd45519cb611415b4b89c2223 ]
tty_cdev_add() drops the cdev reference when cdev_add() fails, but leaves driver->cdevs[index] pointing to freed memory. tty_unregister_device() later passes that stale pointer to cdev_del(), causing a use-after-free.
Clear the slot after dropping the reference.
--- drivers/tty/tty_io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/tty/tty_io.c +3 -1
@@ -3194,8 +3194,10 @@ static int tty_cdev_add(struct tty_driver *driver, dev_t dev, driver->cdevs[index]->ops = &tty_fops; driver->cdevs[index]->owner = driver->owner; err =cdev_add (driver->cdevs[index], dev, count); -if (err) +if (err) {kobject_put (&driver->cdevs[index]->kobj); + driver->cdevs[index] =NULL ; + }return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 672/935 HID: split apart hid_device_probe to make logic more apparent
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
[ Upstream commit 207733f9266194b3cd90ddae723a1f82eb64030b ]
hid_device_probe() has a complex flow and locks and unlocks a mutex. Move the most of the logic into __hid_device_probe() and hid_check_device_match() and leave the locking in hid_device_probe() which makes the code more clear.
Stable-dep-of: 207853d46f7e ("HID: synchronize input before cleaning up a failed probe")
--- drivers/hid/hid-core.c | 101 ++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 47 deletions(-)
drivers/hid/hid-core.c +54 -47
@@ -2316,64 +2316,71 @@ bool hid_compare_device_paths(struct hid_device *hdev_a, }EXPORT_SYMBOL_GPL (hid_compare_device_paths); +static bool hid_check_device_match (struct hid_device *hdev, +struct hid_driver *hdrv, +const struct hid_device_id **id) +{ + *id =hid_match_device (hdev, hdrv); +if (!*id) +return -ENODEV ; + +if (hdrv->match) +return hdrv->match (hdev, hid_ignore_special_drivers); + +/* +* hid-generic implements .match(), so we must be dealing with a +* different HID driver here, and can simply check if +* hid_ignore_special_drivers is set or not. +*/ +return !hid_ignore_special_drivers; +} + +static int __hid_device_probe (struct hid_device *hdev,struct hid_driver *hdrv) +{ +const struct hid_device_id *id; +int ret; + +if (!hid_check_device_match (hdev, hdrv, &id)) +return -ENODEV ; + +/* reset the quirks that has been previously set */ + hdev->quirks =hid_lookup_quirk (hdev); + hdev->driver = hdrv; + +if (hdrv->probe) { + ret = hdrv->probe (hdev, id); + }else {/* default probe */ + ret =hid_open_report (hdev); +if (!ret) + ret =hid_hw_start (hdev,HID_CONNECT_DEFAULT ); + } + +if (ret) { +hid_close_report (hdev); + hdev->driver =NULL ; + } + +return ret; +} +static int hid_device_probe (struct device *dev) { -struct hid_driver *hdrv =to_hid_driver (dev->driver);struct hid_device *hdev =to_hid_device (dev); -const struct hid_device_id *id; +struct hid_driver *hdrv =to_hid_driver (dev->driver);int ret =0 ; -if (down_interruptible (&hdev->driver_input_lock)) { - ret = -EINTR ; - goto end; - } - hdev->io_started = false; +if (down_interruptible (&hdev->driver_input_lock)) +return -EINTR ; + hdev->io_started = false;clear_bit (ffs (HID_STAT_REPROBED ), &hdev->status); -if (!hdev->driver) { - id =hid_match_device (hdev, hdrv); -if (id ==NULL ) { - ret = -ENODEV ; - goto unlock; - } +if (!hdev->driver) + ret =__hid_device_probe (hdev, hdrv); -if (hdrv->match) { -if (!hdrv->match (hdev, hid_ignore_special_drivers)) { - ret = -ENODEV ; - goto unlock; - } - }else { -/* -* hid-generic implements .match(), so if -* hid_ignore_special_drivers is set, we can safely -* return. -*/ -if (hid_ignore_special_drivers) { - ret = -ENODEV ; - goto unlock; - } - } - -/* reset the quirks that has been previously set */ - hdev->quirks =hid_lookup_quirk (hdev); - hdev->driver = hdrv; -if (hdrv->probe) { - ret = hdrv->probe (hdev, id); - }else {/* default probe */ - ret =hid_open_report (hdev); -if (!ret) - ret =hid_hw_start (hdev,HID_CONNECT_DEFAULT ); - } -if (ret) { -hid_close_report (hdev); - hdev->driver =NULL ; - } - } -unlock:if (!hdev->io_started)up (&hdev->driver_input_lock); -end: +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 673/935 HID: ensure timely release of driver-allocated resources
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
[ Upstream commit 62c68e7cee332e08e625af3bca3318814086490d ]
More and more drivers rely on devres to manage their resources, however if bus' probe() and release() methods are not trivial and control some of resources as well (for example enable or disable clocks, or attach device to a power domain), we need to make sure that driver-allocated resources are released immediately after driver's remove() method returns, and not postponed until driver core gets around to releasing resources.
In case of HID we should not try to close the report and release associated memory until after all devres callbacks are executed. To fix that we open a new devres group before calling driver's probe() and explicitly release it when we return from driver's remove().
This is similar to what we did for I2C bus in commit 5b5475826c52 ("i2c:
ensure timely release of driver-allocated resources"). It is tempting to try and move this into driver core, but actually doing so is challenging, we need to split bus' remove() method into pre- and post-remove methods, which would make the logic even less clear.
Stable-dep-of: 207853d46f7e ("HID: synchronize input before cleaning up a failed probe")
--- drivers/hid/hid-core.c | 17 +++++++++++++++++ include/linux/hid.h | 1 + 2 files changed, 18 insertions(+)
drivers/hid/hid-core.c +17 -0
@@ -2343,6 +2343,10 @@ static int __hid_device_probe(struct hid_device *hdev, struct hid_driver *hdrv)if (!hid_check_device_match (hdev, hdrv, &id))return -ENODEV ; + hdev->devres_group_id =devres_open_group (&hdev->dev,NULL ,GFP_KERNEL ); +if (!hdev->devres_group_id) +return -ENOMEM ; +/* reset the quirks that has been previously set */ hdev->quirks =hid_lookup_quirk (hdev); hdev->driver = hdrv;
@@ -2355,7 +2359,16 @@ static int __hid_device_probe(struct hid_device *hdev, struct hid_driver *hdrv) ret =hid_hw_start (hdev,HID_CONNECT_DEFAULT ); } +/* +* Note that we are not closing the devres group opened above so +* even resources that were attached to the device after probe is +* run are released when hid_device_remove() is executed. This is +* needed as some drivers would allocate additional resources, +* for example when updating firmware. +*/ +if (ret) { +devres_release_group (&hdev->dev, hdev->devres_group_id);hid_close_report (hdev); hdev->driver =NULL ; }
@@ -2398,6 +2411,10 @@ static void hid_device_remove(struct device *dev) hdrv->remove (hdev); else /* default remove */hid_hw_stop (hdev ); + +/* Release all devres resources allocated by the driver */ +devres_release_group (&hdev->dev, hdev->devres_group_id); +hid_close_report (hdev); hdev->driver =NULL ; }
include/linux/hid.h +1 -0
@@ -603,6 +603,7 @@ struct hid_device { /* device report descriptor */struct semaphore driver_input_lock;/* protects the current driver */ struct device dev;/* device */ struct hid_driver *driver; +void *devres_group_id;/* ID of probe devres group */ struct hid_ll_driver *ll_driver;struct mutex ll_open_lock;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 674/935 HID: synchronize input before cleaning up a failed probe
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yousef Alhouseen <[email protected]>
[ Upstream commit 207853d46f7ef2e28042344a1468da8754c3ddbf ]
hid_device_io_start() allows reports to run concurrently with probe. If the probe subsequently fails, __hid_device_probe() releases driver resources and clears hdev->driver without first excluding those report callbacks.
For example, a report may enter hidraw_report_event() while the failure path frees the associated hidraw object, leading to a use-after-free when the report takes the object's list lock.
Stop input before performing failed-probe cleanup. This reacquires driver_input_lock and waits for any report callback already in progress.
--- drivers/hid/hid-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/hid-core.c +2 -0
@@ -2368,6 +2368,8 @@ static int __hid_device_probe(struct hid_device *hdev, struct hid_driver *hdrv)*/ if (ret) { +if (hdev->io_started) +hid_device_io_stop (hdev);devres_release_group (&hdev->dev, hdev->devres_group_id);hid_close_report (hdev); hdev->driver =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 675/935 HID: i2c-hid: Switch i2c_hid_parse() to goto style error handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
[ Upstream commit aa69d6974185e9f7a552ba982540a38e34f69690 ]
Switch i2c_hid_parse() to goto style error handling.
This is a preparation patch for removing the need for I2C_HID_QUIRK_NO_IRQ_AFTER_RESET by making i2c-hid behave more like Windows.
Note this changes the descriptor read error path to propagate the actual i2c_hid_read_register() error code (which is always negative) instead of hardcoding a -EIO return.
Stable-dep-of: 8da0f0951dee ("HID: i2c-hid: Fix "(null)" output when reading report descriptor fails")
--- drivers/hid/i2c-hid/i2c-hid-core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/hid/i2c-hid/i2c-hid-core.c +6 -8
@@ -748,23 +748,21 @@ static int i2c_hid_parse(struct hid_device *hid) rdesc, rsize);if (ret) {hid_err (hid,"reading report descriptor failed\n" ); -kfree (rdesc); -return -EIO ; + goto out; } }i2c_hid_dbg (ihid,"Report Descriptor: %*ph\n" , rsize, rdesc); ret =hid_parse_report (hid, rdesc, rsize); +if (ret) +dbg_hid ("parsing report descriptor failed\n" ); + +out:if (!use_override)kfree (rdesc); -if (ret) { -dbg_hid ("parsing report descriptor failed\n" ); -return ret; - } - -return 0 ; +return ret; }static int i2c_hid_start (struct hid_device *hid)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 676/935 HID: i2c-hid: Fix "(null)" output when reading report descriptor fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ai Chao <[email protected]>
[ Upstream commit 8da0f0951deec9f0728ed2d9c54ded1c344b7542 ]
When i2c-hid fails to read the HID report descriptor during device initialization, the error message prints as:
hid (null): reading report descriptor failed
The HID device name is set in hid_add_device() after calling hdev->ll_driver->parse(), so when i2c_hid_parse() fails and calls hid_err(), the device name has not been set yet, resulting in "(null)" output.
Use dev_err(&client->dev, ...) instead of hid_err(hid, ...) because the I2C client device is fully initialized with a proper name, providing meaningful error messages for debugging.
Before: hid (null): reading report descriptor failed After: i2c_hid i2c-TPD0001:00: reading report descriptor failed
--- drivers/hid/i2c-hid/i2c-hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/i2c-hid/i2c-hid-core.c +1 -1
@@ -747,7 +747,7 @@ static int i2c_hid_parse(struct hid_device *hid) ret =i2c_hid_command (client, &hid_report_descr_cmd, rdesc, rsize);if (ret) { -hid_err (hid,"reading report descriptor failed\n" ); +dev_err (&client->dev,"reading report descriptor failed\n" ); goto out; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 677/935 HID: lg4ff: validate report length before fixed offsets
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiancheng Huang <[email protected]>
[ Upstream commit be00988cce4ed44db1e61231d0ab71a64bab44cd ]
lg4ff_raw_event() rewrites fixed report offsets when combined pedals are enabled. It currently assumes that each product report contains every source and destination byte used by the rewrite.
Return without rewriting a short report before each product-specific access. Apply the same bound to the computed offset path.
--- drivers/hid/hid-lg4ff.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/hid/hid-lg4ff.c +8 -0
@@ -336,6 +336,8 @@ int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report,if (entry->wdata.combine) {switch (entry->wdata.product_id) {case USB_DEVICE_ID_LOGITECH_WHEEL : +if (size <7 ) +return 0 ; rd[5 ] = rd[3 ]; rd[6 ] =0x7F ;return 1 ;
@@ -343,10 +345,14 @@ int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report,case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG :case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL :case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2 : +if (size <6 ) +return 0 ; rd[4 ] = rd[3 ]; rd[5 ] =0x7F ;return 1 ;case USB_DEVICE_ID_LOGITECH_DFP_WHEEL : +if (size <7 ) +return 0 ; rd[5 ] = rd[4 ]; rd[6 ] =0x7F ;return 1 ;
@@ -366,6 +372,8 @@ int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report, }/* Compute a combined axis when wheel does not supply it */ +if (size <= offset +1 ) +return 0 ; rd[offset] = (0xFF + rd[offset] - rd[offset+1 ]) >>1 ; rd[offset+1 ] =0x7F ;return 1 ;
Signature · 1 line
2.53.0