5.15.203-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 266/570 sched: idle: Consolidate the handling of two special cases
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 f4c31b07b136839e0fb3026f8a5b6543e3b14d2f ]
There are two special cases in the idle loop that are handled inconsistently even though they are analogous.
The first one is when a cpuidle driver is absent and the default CPU idle time power management implemented by the architecture code is used. In that case, the scheduler tick is stopped every time before invoking default_idle_call().
The second one is when a cpuidle driver is present, but there is only one idle state in its table. In that case, the scheduler tick is never stopped at all.
Since each of these approaches has its drawbacks, reconcile them with the help of one simple heuristic. Namely, stop the tick if the CPU has been woken up by it in the previous iteration of the idle loop, or let it tick otherwise.
--- kernel/sched/idle.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
kernel/sched/idle.c +21 -9
@@ -158,6 +158,14 @@ static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev,return cpuidle_enter (drv, dev, next_state); } +static void idle_call_stop_or_retain_tick (bool stop_tick) +{ +if (stop_tick ||tick_nohz_tick_stopped ()) +tick_nohz_idle_stop_tick (); +else +tick_nohz_idle_retain_tick (); +} +/** * cpuidle_idle_call - the main idle function *
@@ -167,7 +175,7 @@ static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev,* set, and it returns with polling set. If it ever stops polling, it * must clear the polling bit. */ -static void cpuidle_idle_call (void ) +static void cpuidle_idle_call (bool stop_tick) {struct cpuidle_device *dev =cpuidle_get_device ();struct cpuidle_driver *drv =cpuidle_get_cpu_driver (dev);
@@ -189,7 +197,7 @@ static void cpuidle_idle_call(void)*/ if (cpuidle_not_available (drv, dev)) { -tick_nohz_idle_stop_tick (); +idle_call_stop_or_retain_tick (stop_tick);default_idle_call (); goto exit_idle;
@@ -224,17 +232,19 @@ static void cpuidle_idle_call(void) next_state =cpuidle_find_deepest_state (drv, dev, max_latency_ns);call_cpuidle (drv, dev, next_state); }else if (drv->state_count >1 ) { -bool stop_tick = true; +/* +* stop_tick is expected to be true by default by cpuidle +* governors, which allows them to select idle states with +* target residency above the tick period length. +*/ + stop_tick = true;/* * Ask the cpuidle framework to choose a convenient idle state. */ next_state =cpuidle_select (drv, dev, &stop_tick); -if (stop_tick ||tick_nohz_tick_stopped ()) -tick_nohz_idle_stop_tick (); -else -tick_nohz_idle_retain_tick (); +idle_call_stop_or_retain_tick (stop_tick); entered_state =call_cpuidle (drv, dev, next_state);/*
@@ -242,7 +252,7 @@ static void cpuidle_idle_call(void)*/ cpuidle_reflect (dev, entered_state); }else { -tick_nohz_idle_retain_tick (); +idle_call_stop_or_retain_tick (stop_tick);/* * If there is only a single idle state (or none), there is
@@ -270,6 +280,7 @@ static void cpuidle_idle_call(void)static void do_idle (void ) {int cpu =smp_processor_id (); +bool got_tick = false;/* * Check if we need to update blocked load
@@ -312,8 +323,9 @@ static void do_idle(void)tick_nohz_idle_restart_tick ();cpu_idle_poll (); }else { -cpuidle_idle_call (); +cpuidle_idle_call (got_tick); } + got_tick =tick_nohz_idle_got_tick ();arch_cpu_idle_exit (); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 267/570 PM: runtime: Fix a race condition related to device removal
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 29ab768277617452d88c0607c9299cdc63b6e9ff ]
The following code in pm_runtime_work() may dereference the dev->parent pointer after the parent device has been freed:
/* Maybe the parent is now able to suspend. */
if (parent && !parent->power.ignore_children) {
spin_unlock(&dev->power.lock);
spin_lock(&parent->power.lock);
rpm_idle(parent, RPM_ASYNC);
spin_unlock(&parent->power.lock);
spin_lock(&dev->power.lock);
}Fix this by inserting a flush_work() call in pm_runtime_remove().
Without this patch blktest block/001 triggers the following complaint sporadically:
BUG: KASAN: slab-use-after-free in lock_acquire+0x70/0x160 Read of size 1 at addr ffff88812bef7198 by task kworker/u553:1/3081 Workqueue: pm pm_runtime_work Call Trace: <TASK> dump_stack_lvl+0x61/0x80 print_address_description.constprop.0+0x8b/0x310 print_report+0xfd/0x1d7 kasan_report+0xd8/0x1d0 __kasan_check_byte+0x42/0x60 lock_acquire.part.0+0x38/0x230 lock_acquire+0x70/0x160 _raw_spin_lock+0x36/0x50 rpm_suspend+0xc6a/0xfe0 rpm_idle+0x578/0x770 pm_runtime_work+0xee/0x120 process_one_work+0xde3/0x1410 worker_thread+0x5eb/0xfe0 kthread+0x37b/0x480 ret_from_fork+0x6cb/0x920 ret_from_fork_asm+0x11/0x20 </TASK> Allocated by task 4314: kasan_save_stack+0x2a/0x50 kasan_save_track+0x18/0x40 kasan_save_alloc_info+0x3d/0x50 __kasan_kmalloc+0xa0/0xb0 __kmalloc_noprof+0x311/0x990 scsi_alloc_target+0x122/0xb60 [scsi_mod] __scsi_scan_target+0x101/0x460 [scsi_mod] scsi_scan_channel+0x179/0x1c0 [scsi_mod] scsi_scan_host_selected+0x259/0x2d0 [scsi_mod] store_scan+0x2d2/0x390 [scsi_mod] dev_attr_store+0x43/0x80 sysfs_kf_write+0xde/0x140 kernfs_fop_write_iter+0x3ef/0x670 vfs_write+0x506/0x1470 ksys_write+0xfd/0x230 __x64_sys_write+0x76/0xc0 x64_sys_call+0x213/0x1810 do_syscall_64+0xee/0xfc0 entry_SYSCALL_64_after_hwframe+0x4b/0x53 Freed by task 4314: kasan_save_stack+0x2a/0x50 kasan_save_track+0x18/0x40 kasan_save_free_info+0x3f/0x50 __kasan_slab_free+0x67/0x80 kfree+0x225/0x6c0 scsi_target_dev_release+0x3d/0x60 [scsi_mod] device_release+0xa3/0x220 kobject_cleanup+0x105/0x3a0 kobject_put+0x72/0xd0 put_device+0x17/0x20 scsi_device_dev_release+0xacf/0x12c0 [scsi_mod] device_release+0xa3/0x220 kobject_cleanup+0x105/0x3a0 kobject_put+0x72/0xd0 put_device+0x17/0x20 scsi_device_put+0x7f/0xc0 [scsi_mod] sdev_store_delete+0xa5/0x120 [scsi_mod] dev_attr_store+0x43/0x80 sysfs_kf_write+0xde/0x140 kernfs_fop_write_iter+0x3ef/0x670 vfs_write+0x506/0x1470 ksys_write+0xfd/0x230 __x64_sys_write+0x76/0xc0 x64_sys_call+0x213/0x1810
--- drivers/base/power/runtime.c | 1 + 1 file changed, 1 insertion(+)
drivers/base/power/runtime.c +1 -0
@@ -1774,6 +1774,7 @@ void pm_runtime_reinit(struct device *dev)void pm_runtime_remove (struct device *dev) {__pm_runtime_disable (dev, false); +flush_work (&dev->power.work);pm_runtime_reinit (dev); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 268/570 net/smc: Only save the original clcsock callback functions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wen Gu <[email protected]>
[ Upstream commit 97b9af7a70936e331170c79040cc9bf20071b566 ]
Both listen and fallback process will save the current clcsock callback functions and establish new ones. But if both of them happen, the saved callback functions will be overwritten.
So this patch introduces some helpers to ensure that only save the original callback functions of clcsock.
Stable-dep-of: 6d5e4538364b ("net/smc: fix NULL dereference and UAF in smc_tcp_syn_recv_sock()")
--- net/smc/af_smc.c | 55 +++++++++++++++++++++++++++++---------------- net/smc/smc.h | 29 ++++++++++++++++++++++++ net/smc/smc_close.c | 3 ++- 3 files changed, 67 insertions(+), 20 deletions(-)
net/smc/af_smc.c +36 -19
@@ -300,6 +300,7 @@ static struct sock *smc_sock_alloc(struct net *net, struct socket *sock, sk->sk_prot->hash (sk);sk_refcnt_debug_inc (sk);mutex_init (&smc->clcsock_release_lock); +smc_init_saved_callbacks (smc);return sk; }
@@ -696,9 +697,24 @@ static void smc_fback_error_report(struct sock *clcsk)smc_fback_forward_wakeup (smc, clcsk, smc->clcsk_error_report); } +static void smc_fback_replace_callbacks (struct smc_sock *smc) +{ +struct sock *clcsk = smc->clcsock->sk; + + clcsk->sk_user_data = (void *)((uintptr_t )smc |SK_USER_DATA_NOCOPY ); + +smc_clcsock_replace_cb (&clcsk->sk_state_change, smc_fback_state_change, + &smc->clcsk_state_change); +smc_clcsock_replace_cb (&clcsk->sk_data_ready, smc_fback_data_ready, + &smc->clcsk_data_ready); +smc_clcsock_replace_cb (&clcsk->sk_write_space, smc_fback_write_space, + &smc->clcsk_write_space); +smc_clcsock_replace_cb (&clcsk->sk_error_report, smc_fback_error_report, + &smc->clcsk_error_report); +} +static int smc_switch_to_fallback (struct smc_sock *smc,int reason_code) { -struct sock *clcsk;int rc =0 ;mutex_lock (&smc->clcsock_release_lock);
@@ -706,10 +722,7 @@ static int smc_switch_to_fallback(struct smc_sock *smc, int reason_code) rc = -EBADF ; goto out; } - clcsk = smc->clcsock->sk; -if (smc->use_fallback) - goto out; smc->use_fallback = true; smc->fallback_rsn = reason_code;smc_stat_fallback (smc);
@@ -723,18 +736,7 @@ static int smc_switch_to_fallback(struct smc_sock *smc, int reason_code)* in smc sk->sk_wq and they should be woken up * as clcsock's wait queue is woken up. */ - smc->clcsk_state_change = clcsk->sk_state_change; - smc->clcsk_data_ready = clcsk->sk_data_ready; - smc->clcsk_write_space = clcsk->sk_write_space; - smc->clcsk_error_report = clcsk->sk_error_report; - - clcsk->sk_state_change = smc_fback_state_change; - clcsk->sk_data_ready = smc_fback_data_ready; - clcsk->sk_write_space = smc_fback_write_space; - clcsk->sk_error_report = smc_fback_error_report; - - smc->clcsock->sk->sk_user_data = - (void *)((uintptr_t )smc |SK_USER_DATA_NOCOPY ); +smc_fback_replace_callbacks (smc); } out:mutex_unlock (&smc->clcsock_release_lock);
@@ -1388,6 +1390,19 @@ static int smc_clcsock_accept(struct smc_sock *lsmc, struct smc_sock **new_smc)* function; switch it back to the original sk_data_ready function */ new_clcsock->sk->sk_data_ready = lsmc->clcsk_data_ready; + +/* if new clcsock has also inherited the fallback-specific callback +* functions, switch them back to the original ones. +*/ +if (lsmc->use_fallback) { +if (lsmc->clcsk_state_change) + new_clcsock->sk->sk_state_change = lsmc->clcsk_state_change; +if (lsmc->clcsk_write_space) + new_clcsock->sk->sk_write_space = lsmc->clcsk_write_space; +if (lsmc->clcsk_error_report) + new_clcsock->sk->sk_error_report = lsmc->clcsk_error_report; + } + (*new_smc)->clcsock = new_clcsock; out:return rc;
@@ -2122,10 +2137,10 @@ static int smc_listen(struct socket *sock, int backlog)/* save original sk_data_ready function and establish * smc-specific sk_data_ready function */ - smc->clcsk_data_ready = smc->clcsock->sk->sk_data_ready; - smc->clcsock->sk->sk_data_ready = smc_clcsock_data_ready; smc->clcsock->sk->sk_user_data = (void *)((uintptr_t )smc |SK_USER_DATA_NOCOPY ); +smc_clcsock_replace_cb (&smc->clcsock->sk->sk_data_ready, + smc_clcsock_data_ready, &smc->clcsk_data_ready);/* save original ops */ smc->ori_af_ops =inet_csk (smc->clcsock->sk)->icsk_af_ops;
@@ -2137,7 +2152,9 @@ static int smc_listen(struct socket *sock, int backlog) rc =kernel_listen (smc->clcsock, backlog);if (rc) { - smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready; +smc_clcsock_restore_cb (&smc->clcsock->sk->sk_data_ready, + &smc->clcsk_data_ready); + smc->clcsock->sk->sk_user_data =NULL ; goto out; } sk->sk_max_ack_backlog = backlog;
net/smc/smc.h +29 -0
@@ -269,12 +269,41 @@ static inline struct smc_sock *smc_sk(const struct sock *sk)return (struct smc_sock *)sk; } +static inline void smc_init_saved_callbacks (struct smc_sock *smc) +{ + smc->clcsk_state_change =NULL ; + smc->clcsk_data_ready =NULL ; + smc->clcsk_write_space =NULL ; + smc->clcsk_error_report =NULL ; +} +static inline struct smc_sock *smc_clcsock_user_data (const struct sock *clcsk) {return (struct smc_sock *) ((uintptr_t )clcsk->sk_user_data & ~SK_USER_DATA_NOCOPY ); } +/* save target_cb in saved_cb, and replace target_cb with new_cb */ +static inline void smc_clcsock_replace_cb (void (**target_cb)(struct sock *), +void (*new_cb)(struct sock *), +void (**saved_cb)(struct sock *)) +{ +/* only save once */ +if (!*saved_cb) + *saved_cb = *target_cb; + *target_cb = new_cb; +} + +/* restore target_cb to saved_cb, and reset saved_cb to NULL */ +static inline void smc_clcsock_restore_cb (void (**target_cb)(struct sock *), +void (**saved_cb)(struct sock *)) +{ +if (!*saved_cb) +return ; + *target_cb = *saved_cb; + *saved_cb =NULL ; +} +extern struct workqueue_struct *smc_hs_wq;/* wq for handshake work */ extern struct workqueue_struct *smc_close_wq;/* wq for close work */
net/smc/smc_close.c +2 -1
@@ -212,7 +212,8 @@ int smc_close_active(struct smc_sock *smc) sk->sk_state =SMC_CLOSED ; sk->sk_state_change (sk);/* wake up accept */ if (smc->clcsock && smc->clcsock->sk) { - smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready; +smc_clcsock_restore_cb (&smc->clcsock->sk->sk_data_ready, + &smc->clcsk_data_ready); smc->clcsock->sk->sk_user_data =NULL ; rc =kernel_sock_shutdown (smc->clcsock,SHUT_RDWR ); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 269/570 net/smc: Fix slab-out-of-bounds issue in fallback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wen Gu <[email protected]>
[ Upstream commit 0558226cebee256aa3f8ec0cc5a800a10bf120a6 ]
syzbot reported a slab-out-of-bounds/use-after-free issue, which was caused by accessing an already freed smc sock in fallback-specific callback functions of clcsock.
This patch fixes the issue by restoring fallback-specific callback functions to original ones and resetting clcsock sk_user_data to NULL before freeing smc sock.
Meanwhile, this patch introduces sk_callback_lock to make the access and assignment to sk_user_data mutually exclusive.
Stable-dep-of: 6d5e4538364b ("net/smc: fix NULL dereference and UAF in smc_tcp_syn_recv_sock()")
--- net/smc/af_smc.c | 80 ++++++++++++++++++++++++++++++++------------- net/smc/smc_close.c | 2 ++ 2 files changed, 59 insertions(+), 23 deletions(-)
net/smc/af_smc.c +57 -23
@@ -170,11 +170,27 @@ struct proto smc_proto6 = { };EXPORT_SYMBOL_GPL (smc_proto6); +static void smc_fback_restore_callbacks (struct smc_sock *smc) +{ +struct sock *clcsk = smc->clcsock->sk; + +write_lock_bh (&clcsk->sk_callback_lock); + clcsk->sk_user_data =NULL ; + +smc_clcsock_restore_cb (&clcsk->sk_state_change, &smc->clcsk_state_change); +smc_clcsock_restore_cb (&clcsk->sk_data_ready, &smc->clcsk_data_ready); +smc_clcsock_restore_cb (&clcsk->sk_write_space, &smc->clcsk_write_space); +smc_clcsock_restore_cb (&clcsk->sk_error_report, &smc->clcsk_error_report); + +write_unlock_bh (&clcsk->sk_callback_lock); +} +static void smc_restore_fallback_changes (struct smc_sock *smc) {if (smc->clcsock->file) {/* non-accepted sockets have no file yet */ smc->clcsock->file->private_data = smc->sk.sk_socket; smc->clcsock->file =NULL ; +smc_fback_restore_callbacks (smc); } }
@@ -659,48 +675,57 @@ static void smc_fback_forward_wakeup(struct smc_sock *smc, struct sock *clcsk,static void smc_fback_state_change (struct sock *clcsk) { -struct smc_sock *smc = -smc_clcsock_user_data (clcsk); +struct smc_sock *smc; -if (!smc) -return ; -smc_fback_forward_wakeup (smc, clcsk, smc->clcsk_state_change); +read_lock_bh (&clcsk->sk_callback_lock); + smc =smc_clcsock_user_data (clcsk); +if (smc) +smc_fback_forward_wakeup (smc, clcsk, + smc->clcsk_state_change); +read_unlock_bh (&clcsk->sk_callback_lock); }static void smc_fback_data_ready (struct sock *clcsk) { -struct smc_sock *smc = -smc_clcsock_user_data (clcsk); +struct smc_sock *smc; -if (!smc) -return ; -smc_fback_forward_wakeup (smc, clcsk, smc->clcsk_data_ready); +read_lock_bh (&clcsk->sk_callback_lock); + smc =smc_clcsock_user_data (clcsk); +if (smc) +smc_fback_forward_wakeup (smc, clcsk, + smc->clcsk_data_ready); +read_unlock_bh (&clcsk->sk_callback_lock); }static void smc_fback_write_space (struct sock *clcsk) { -struct smc_sock *smc = -smc_clcsock_user_data (clcsk); +struct smc_sock *smc; -if (!smc) -return ; -smc_fback_forward_wakeup (smc, clcsk, smc->clcsk_write_space); +read_lock_bh (&clcsk->sk_callback_lock); + smc =smc_clcsock_user_data (clcsk); +if (smc) +smc_fback_forward_wakeup (smc, clcsk, + smc->clcsk_write_space); +read_unlock_bh (&clcsk->sk_callback_lock); }static void smc_fback_error_report (struct sock *clcsk) { -struct smc_sock *smc = -smc_clcsock_user_data (clcsk); +struct smc_sock *smc; -if (!smc) -return ; -smc_fback_forward_wakeup (smc, clcsk, smc->clcsk_error_report); +read_lock_bh (&clcsk->sk_callback_lock); + smc =smc_clcsock_user_data (clcsk); +if (smc) +smc_fback_forward_wakeup (smc, clcsk, + smc->clcsk_error_report); +read_unlock_bh (&clcsk->sk_callback_lock); }static void smc_fback_replace_callbacks (struct smc_sock *smc) {struct sock *clcsk = smc->clcsock->sk; +write_lock_bh (&clcsk->sk_callback_lock); clcsk->sk_user_data = (void *)((uintptr_t )smc |SK_USER_DATA_NOCOPY ); smc_clcsock_replace_cb(&clcsk->sk_state_change, smc_fback_state_change,
@@ -711,6 +736,8 @@ static void smc_fback_replace_callbacks(struct smc_sock *smc) &smc->clcsk_write_space);smc_clcsock_replace_cb (&clcsk->sk_error_report, smc_fback_error_report, &smc->clcsk_error_report); + +write_unlock_bh (&clcsk->sk_callback_lock); }static int smc_switch_to_fallback (struct smc_sock *smc,int reason_code)
@@ -2095,17 +2122,20 @@ static void smc_tcp_listen_work(struct work_struct *work)static void smc_clcsock_data_ready (struct sock *listen_clcsock) { -struct smc_sock *lsmc = -smc_clcsock_user_data (listen_clcsock); +struct smc_sock *lsmc; +read_lock_bh (&listen_clcsock->sk_callback_lock); + lsmc =smc_clcsock_user_data (listen_clcsock);if (!lsmc) -return ; + goto out; lsmc->clcsk_data_ready (listen_clcsock);if (lsmc->sk.sk_state ==SMC_LISTEN ) {sock_hold (&lsmc->sk);/* sock_put in smc_tcp_listen_work() */ if (!queue_work (smc_hs_wq, &lsmc->tcp_listen_work))sock_put (&lsmc->sk); } +out: +read_unlock_bh (&listen_clcsock->sk_callback_lock); }static int smc_listen (struct socket *sock,int backlog)
@@ -2137,10 +2167,12 @@ static int smc_listen(struct socket *sock, int backlog)/* save original sk_data_ready function and establish * smc-specific sk_data_ready function */ +write_lock_bh (&smc->clcsock->sk->sk_callback_lock); smc->clcsock->sk->sk_user_data = (void *)((uintptr_t )smc |SK_USER_DATA_NOCOPY );smc_clcsock_replace_cb (&smc->clcsock->sk->sk_data_ready, smc_clcsock_data_ready, &smc->clcsk_data_ready); +write_unlock_bh (&smc->clcsock->sk->sk_callback_lock);/* save original ops */ smc->ori_af_ops =inet_csk (smc->clcsock->sk)->icsk_af_ops;
@@ -2152,9 +2184,11 @@ static int smc_listen(struct socket *sock, int backlog) rc =kernel_listen (smc->clcsock, backlog);if (rc) { +write_lock_bh (&smc->clcsock->sk->sk_callback_lock);smc_clcsock_restore_cb (&smc->clcsock->sk->sk_data_ready, &smc->clcsk_data_ready); smc->clcsock->sk->sk_user_data =NULL ; +write_unlock_bh (&smc->clcsock->sk->sk_callback_lock); goto out; } sk->sk_max_ack_backlog = backlog;
net/smc/smc_close.c +2 -0
@@ -212,9 +212,11 @@ int smc_close_active(struct smc_sock *smc) sk->sk_state =SMC_CLOSED ; sk->sk_state_change (sk);/* wake up accept */ if (smc->clcsock && smc->clcsock->sk) { +write_lock_bh (&smc->clcsock->sk->sk_callback_lock);smc_clcsock_restore_cb (&smc->clcsock->sk->sk_data_ready, &smc->clcsk_data_ready); smc->clcsock->sk->sk_user_data =NULL ; +write_unlock_bh (&smc->clcsock->sk->sk_callback_lock); rc =kernel_sock_shutdown (smc->clcsock,SHUT_RDWR ); }smc_close_cleanup_listen (sk);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 270/570 net/smc: fix NULL dereference and UAF in smc_tcp_syn_recv_sock()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 6d5e4538364b9ceb1ac2941a4deb86650afb3538 ]
Syzkaller reported a panic in smc_tcp_syn_recv_sock() [1].
smc_tcp_syn_recv_sock() is called in the TCP receive path (softirq) via icsk_af_ops->syn_recv_sock on the clcsock (TCP listening socket). It reads sk_user_data to get the smc_sock pointer. However, when the SMC listen socket is being closed concurrently, smc_close_active() sets clcsock->sk_user_data to NULL under sk_callback_lock, and then the smc_sock itself can be freed via sock_put() in smc_release().
This leads to two issues:
1) NULL pointer dereference: sk_user_data is NULL when accessed.
2) Use-after-free: sk_user_data is read as non-NULL, but the smc_sock is freed before its fields (e.g., queued_smc_hs, ori_af_ops) are accessed.
The race window looks like this (the syzkaller crash [1] triggers via the SYN cookie path: tcp_get_cookie_sock() -> smc_tcp_syn_recv_sock(), but the normal tcp_check_req() path has the same race):
CPU A (softirq) CPU B (process ctx)
tcp_v4_rcv()
TCP_NEW_SYN_RECV:
sk = req->rsk_listener
sock_hold(sk)
/* No lock on listener */
smc_close_active():
write_lock_bh(cb_lock)
sk_user_data = NULL
write_unlock_bh(cb_lock)
...
smc_clcsock_release()
sock_put(smc->sk) x2
-> smc_sock freed!
tcp_check_req()
smc_tcp_syn_recv_sock():
smc = user_data(sk)
-> NULL or dangling
smc->queued_smc_hs
-> crash!Note that the clcsock and smc_sock are two independent objects with separate refcounts. TCP stack holds a reference on the clcsock, which keeps it alive, but this does NOT prevent the smc_sock from being freed.
Fix this by using RCU and refcount_inc_not_zero() to safely access smc_sock. Since smc_tcp_syn_recv_sock() is called in the TCP three-way handshake path, taking read_lock_bh on sk_callback_lock is too heavy and would not survive a SYN flood attack. Using rcu_read_lock() is much more lightweight.
- Set SOCK_RCU_FREE on the SMC listen socket so that smc_sock freeing is deferred until after the RCU grace period. This guarantees the memory is still valid when accessed inside rcu_read_lock().
- Use rcu_read_lock() to protect reading sk_user_data.
- Use refcount_inc_not_zero(&smc->sk.sk_refcnt) to pin the smc_sock. If the refcount has already reached zero (close path completed), it returns false and we bail out safely.
Note: smc_hs_congested() has a similar lockless read of sk_user_data without rcu_read_lock(), but it only checks for NULL and accesses the global smc_hs_wq, never dereferencing any smc_sock field, so it is not affected.
Reproducer was verified with mdelay injection and smc_run, the issue no longer occurs with this patch applied.
[1] https://syzkaller.appspot.com/bug?extid=827ae2bfb3a3529333e9
--- net/smc/af_smc.c | 23 +++++++++++++++++------ net/smc/smc.h | 5 +++++ net/smc/smc_close.c | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-)
net/smc/af_smc.c +17 -6
@@ -81,7 +81,14 @@ static struct sock *smc_tcp_syn_recv_sock(const struct sock *sk,struct smc_sock *smc;struct sock *child; - smc =smc_clcsock_user_data (sk); +rcu_read_lock (); + smc =smc_clcsock_user_data_rcu (sk); +if (!smc || !refcount_inc_not_zero (&smc->sk.sk_refcnt)) { +rcu_read_unlock (); + smc =NULL ; + goto drop; + } +rcu_read_unlock ();if (READ_ONCE (sk->sk_ack_backlog) +atomic_read (&smc->queued_smc_hs) > sk->sk_max_ack_backlog)
@@ -103,11 +110,14 @@ static struct sock *smc_tcp_syn_recv_sock(const struct sock *sk,if (inet_csk (child)->icsk_af_ops ==inet_csk (sk)->icsk_af_ops)inet_csk (child)->icsk_af_ops = smc->ori_af_ops; } +sock_put (&smc->sk);return child; drop:dst_release (dst);tcp_listendrop (sk); +if (smc) +sock_put (&smc->sk);return NULL ; }
@@ -175,7 +185,7 @@ static void smc_fback_restore_callbacks(struct smc_sock *smc)struct sock *clcsk = smc->clcsock->sk;write_lock_bh (&clcsk->sk_callback_lock); - clcsk->sk_user_data =NULL ; +rcu_assign_sk_user_data (clcsk,NULL );smc_clcsock_restore_cb (&clcsk->sk_state_change, &smc->clcsk_state_change);smc_clcsock_restore_cb (&clcsk->sk_data_ready, &smc->clcsk_data_ready);
@@ -726,7 +736,7 @@ static void smc_fback_replace_callbacks(struct smc_sock *smc)struct sock *clcsk = smc->clcsock->sk;write_lock_bh (&clcsk->sk_callback_lock); - clcsk->sk_user_data = (void *)((uintptr_t )smc |SK_USER_DATA_NOCOPY ); +__rcu_assign_sk_user_data_with_flags (clcsk, smc,SK_USER_DATA_NOCOPY );smc_clcsock_replace_cb (&clcsk->sk_state_change, smc_fback_state_change, &smc->clcsk_state_change);
@@ -2168,8 +2178,8 @@ static int smc_listen(struct socket *sock, int backlog)* smc-specific sk_data_ready function */ write_lock_bh (&smc->clcsock->sk->sk_callback_lock); - smc->clcsock->sk->sk_user_data = - (void *)((uintptr_t )smc |SK_USER_DATA_NOCOPY ); +__rcu_assign_sk_user_data_with_flags (smc->clcsock->sk, smc, +SK_USER_DATA_NOCOPY );smc_clcsock_replace_cb (&smc->clcsock->sk->sk_data_ready, smc_clcsock_data_ready, &smc->clcsk_data_ready);write_unlock_bh (&smc->clcsock->sk->sk_callback_lock);
@@ -2187,10 +2197,11 @@ static int smc_listen(struct socket *sock, int backlog)write_lock_bh (&smc->clcsock->sk->sk_callback_lock);smc_clcsock_restore_cb (&smc->clcsock->sk->sk_data_ready, &smc->clcsk_data_ready); - smc->clcsock->sk->sk_user_data =NULL ; +rcu_assign_sk_user_data (smc->clcsock->sk,NULL );write_unlock_bh (&smc->clcsock->sk->sk_callback_lock); goto out; } +sock_set_flag (sk,SOCK_RCU_FREE ); sk->sk_max_ack_backlog = backlog; sk->sk_ack_backlog =0 ; sk->sk_state =SMC_LISTEN ;
net/smc/smc.h +5 -0
@@ -283,6 +283,11 @@ static inline struct smc_sock *smc_clcsock_user_data(const struct sock *clcsk) ((uintptr_t )clcsk->sk_user_data & ~SK_USER_DATA_NOCOPY ); } +static inline struct smc_sock *smc_clcsock_user_data_rcu (const struct sock *clcsk) +{ +return (struct smc_sock *)rcu_dereference_sk_user_data (clcsk); +} +/* save target_cb in saved_cb, and replace target_cb with new_cb */ static inline void smc_clcsock_replace_cb(void (**target_cb)(struct sock *), void (*new_cb)(struct sock *),
net/smc/smc_close.c +1 -1
@@ -215,7 +215,7 @@ int smc_close_active(struct smc_sock *smc)write_lock_bh (&smc->clcsock->sk->sk_callback_lock);smc_clcsock_restore_cb (&smc->clcsock->sk->sk_data_ready, &smc->clcsk_data_ready); - smc->clcsock->sk->sk_user_data =NULL ; +rcu_assign_sk_user_data (smc->clcsock->sk,NULL );write_unlock_bh (&smc->clcsock->sk->sk_callback_lock); rc =kernel_sock_shutdown (smc->clcsock,SHUT_RDWR ); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 271/570 net: usb: aqc111: Do not perform PM inside suspend callback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikola Z. Ivanov <[email protected]>
[ Upstream commit 069c8f5aebe4d5224cf62acc7d4b3486091c658a ]
syzbot reports "task hung in rpm_resume"
This is caused by aqc111_suspend calling
the PM variant of its write_cmd routine.
The simplified call trace looks like this:
rpm_suspend()
usb_suspend_both() - here udev->dev.power.runtime_status == RPM_SUSPENDING
aqc111_suspend() - called for the usb device interface
aqc111_write32_cmd()
usb_autopm_get_interface()
pm_runtime_resume_and_get()
rpm_resume() - here we call rpm_resume() on our parent
rpm_resume() - Here we wait for a status change that will never happen.
At this point we block another task which holds rtnl_lock and locks up the whole networking stack.
Fix this by replacing the write_cmd calls with their _nopm variants
--- drivers/net/usb/aqc111.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/usb/aqc111.c +6 -6
@@ -1400,14 +1400,14 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)aqc111_write16_cmd_nopm (dev,AQ_ACCESS_MAC ,SFR_MEDIUM_STATUS_MODE ,2 , ®16); -aqc111_write_cmd (dev,AQ_WOL_CFG ,0 ,0 , -WOL_CFG_SIZE , &wol_cfg); -aqc111_write32_cmd (dev,AQ_PHY_OPS ,0 ,0 , - &aqc111_data->phy_cfg); +aqc111_write_cmd_nopm (dev,AQ_WOL_CFG ,0 ,0 , +WOL_CFG_SIZE , &wol_cfg); +aqc111_write32_cmd_nopm (dev,AQ_PHY_OPS ,0 ,0 , + &aqc111_data->phy_cfg); }else { aqc111_data->phy_cfg |=AQ_LOW_POWER ; -aqc111_write32_cmd (dev,AQ_PHY_OPS ,0 ,0 , - &aqc111_data->phy_cfg); +aqc111_write32_cmd_nopm (dev,AQ_PHY_OPS ,0 ,0 , + &aqc111_data->phy_cfg);/* Disable RX path */ aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 272/570 igc: fix missing update of skb->tail in igc_xmit_frame()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kohei Enju <[email protected]>
[ Upstream commit 0ffba246652faf4a36aedc66059c2f94e4c83ea5 ]
igc_xmit_frame() misses updating skb->tail when the packet size is shorter than the minimum one.
Use skb_put_padto() in alignment with other Intel Ethernet drivers.
--- drivers/net/ethernet/intel/igc/igc_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/igc/igc_main.c +2 -5
@@ -1666,11 +1666,8 @@ static netdev_tx_t igc_xmit_frame(struct sk_buff *skb,/* The minimum packet size with TCTL.PSP set is 17 so pad the skb * in order to meet this minimum size requirement. */ -if (skb->len <17 ) { -if (skb_padto (skb,17 )) -return NETDEV_TX_OK ; - skb->len =17 ; - } +if (skb_put_padto (skb,17 )) +return NETDEV_TX_OK ;return igc_xmit_frame_ring (skb,igc_tx_queue_mapping (adapter, skb)); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 273/570 wifi: mac80211: fix NULL deref in mesh_matches_local()
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 c73bb9a2d33bf81f6eecaa0f474b6c6dbe9855bd ]
mesh_matches_local() unconditionally dereferences ie->mesh_config to compare mesh configuration parameters. When called from mesh_rx_csa_frame(), the parsed action-frame elements may not contain a Mesh Configuration IE, leaving ie->mesh_config NULL and triggering a kernel NULL pointer dereference.
The other two callers are already safe:
- ieee80211_mesh_rx_bcn_presp() checks !elems->mesh_config before calling mesh_matches_local()
- mesh_plink_get_event() is only reached through
mesh_process_plink_frame(), which checks !elems->mesh_config, too
mesh_rx_csa_frame() is the only caller that passes raw parsed elements to mesh_matches_local() without guarding mesh_config. An adjacent attacker can exploit this by sending a crafted CSA action frame that includes a valid Mesh ID IE but omits the Mesh Configuration IE, crashing the kernel.
The captured crash log:
Oops: general protection fault, probably for non-canonical address ... KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] Workqueue: events_unbound cfg80211_wiphy_work [...] Call Trace: <TASK> ? __pfx_mesh_matches_local (net/mac80211/mesh.c:65) ieee80211_mesh_rx_queued_mgmt (net/mac80211/mesh.c:1686) [...] ieee80211_iface_work (net/mac80211/iface.c:1754 net/mac80211/iface.c:1802) [...] cfg80211_wiphy_work (net/wireless/core.c:426) process_one_work (net/kernel/workqueue.c:3280) ? assign_work (net/kernel/workqueue.c:1219) worker_thread (net/kernel/workqueue.c:3352) ? __pfx_worker_thread (net/kernel/workqueue.c:3385) kthread (net/kernel/kthread.c:436) [...] ret_from_fork_asm (net/arch/x86/entry/entry_64.S:255) </TASK>
This patch adds a NULL check for ie->mesh_config at the top of mesh_matches_local() to return false early when the Mesh Configuration IE is absent.
--- net/mac80211/mesh.c | 3 +++ 1 file changed, 3 insertions(+)
net/mac80211/mesh.c +3 -0
@@ -75,6 +75,9 @@ bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,* - MDA enabled * - Power management control on fc */ +if (!ie->mesh_config) +return false; + if (!(ifmsh->mesh_id_len == ie->mesh_id_len && memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 && (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) &&
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 274/570 wifi: wlcore: Return -ENOMEM instead of -EAGAIN if there is not enough headroom
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit deb353d9bb009638b7762cae2d0b6e8fdbb41a69 ]
Since upstream commit e75665dd0968 ("wifi: wlcore: ensure skb headroom before skb_push"), wl1271_tx_allocate() and with it wl1271_prepare_tx_frame() returns -EAGAIN if pskb_expand_head() fails. However, in wlcore_tx_work_locked(), a return value of -EAGAIN from wl1271_prepare_tx_frame() is interpreted as the aggregation buffer being full. This causes the code to flush the buffer, put the skb back at the head of the queue, and immediately retry the same skb in a tight while loop.
Because wlcore_tx_work_locked() holds wl->mutex, and the retry happens immediately with GFP_ATOMIC, this will result in an infinite loop and a CPU soft lockup. Return -ENOMEM instead so the packet is dropped and the loop terminates.
The problem was found by an experimental code review agent based on gemini-3.1-pro while reviewing backports into v6.18.y.
--- drivers/net/wireless/ti/wlcore/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ti/wlcore/tx.c +1 -1
@@ -213,7 +213,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct wl12xx_vif *wlvif,if (skb_headroom (skb) < (total_len - skb->len) &&pskb_expand_head (skb, (total_len - skb->len),0 ,GFP_ATOMIC )) {wl1271_free_tx_id (wl, id); -return -EAGAIN ; +return -ENOMEM ; } desc =skb_push (skb, total_len - skb->len);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 275/570 ACPI: processor: Fix previous acpi_processor_errata_piix4() fix
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 bf504b229cb8d534eccbaeaa23eba34c05131e25 ]
After commi f132e089fe89 ("ACPI: processor: Fix NULL-pointer dereference in acpi_processor_errata_piix4()"), device pointers may be dereferenced after dropping references to the device objects pointed to by them, which may cause a use-after-free to occur.
Moreover, debug messages about enabling the errata may be printed if the errata flags corresponding to them are unset.
Address all of these issues by moving message printing to the points in the code where the errata flags are set.
--- drivers/acpi/acpi_processor.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/acpi/acpi_processor.c +8 -7
@@ -96,6 +96,10 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev) PCI_ANY_ID, PCI_ANY_ID, NULL);if (ide_dev) { errata.piix4.bmisx =pci_resource_start (ide_dev,4 ); +if (errata.piix4.bmisx) +dev_dbg (&ide_dev->dev, +"Bus master activity detection (BM-IDE) erratum enabled\n" ); +pci_dev_put (ide_dev); }
@@ -114,20 +118,17 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)if (isa_dev) {pci_read_config_byte (isa_dev,0x76 , &value1);pci_read_config_byte (isa_dev,0x77 , &value2); -if ((value1 &0x80 ) || (value2 &0x80 )) +if ((value1 &0x80 ) || (value2 &0x80 )) { errata.piix4.fdma =1 ; +dev_dbg (&isa_dev->dev, +"Type-F DMA livelock erratum (C3 disabled)\n" ); + }pci_dev_put (isa_dev); }break ; } -if (ide_dev) -dev_dbg (&ide_dev->dev,"Bus master activity detection (BM-IDE) erratum enabled\n" ); - -if (isa_dev) -dev_dbg (&isa_dev->dev,"Type-F DMA livelock erratum (C3 disabled)\n" ); -return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 276/570 net: macb: fix uninitialized rx_fs_lock
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
[ Upstream commit 34b11cc56e4369bc08b1f4c4a04222d75ed596ce ]
If hardware doesn't support RX Flow Filters, rx_fs_lock spinlock is not initialized leading to the following assertion splat triggerable via set_rxnfc callback.
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe you didn't initialize this object before use? turning off the locking correctness validator.
CPU: 1 PID: 949 Comm: syz.0.6 Not tainted 6.1.164+ #113 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.1-0-g3208b098f51a-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x8d/0xba lib/dump_stack.c:106 assign_lock_key kernel/locking/lockdep.c:974 [inline] register_lock_class+0x141b/0x17f0 kernel/locking/lockdep.c:1287 __lock_acquire+0x74f/0x6c40 kernel/locking/lockdep.c:4928 lock_acquire kernel/locking/lockdep.c:5662 [inline] lock_acquire+0x190/0x4b0 kernel/locking/lockdep.c:5627 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x33/0x50 kernel/locking/spinlock.c:162 gem_del_flow_filter drivers/net/ethernet/cadence/macb_main.c:3562 [inline] gem_set_rxnfc+0x533/0xac0 drivers/net/ethernet/cadence/macb_main.c:3667 ethtool_set_rxnfc+0x18c/0x280 net/ethtool/ioctl.c:961 __dev_ethtool net/ethtool/ioctl.c:2956 [inline] dev_ethtool+0x229c/0x6290 net/ethtool/ioctl.c:3095 dev_ioctl+0x637/0x1070 net/core/dev_ioctl.c:510 sock_do_ioctl+0x20d/0x2c0 net/socket.c:1215 sock_ioctl+0x577/0x6d0 net/socket.c:1320 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x18c/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:46 [inline] do_syscall_64+0x35/0x80 arch/x86/entry/common.c:76 entry_SYSCALL_64_after_hwframe+0x6e/0xd8
A more straightforward solution would be to always initialize rx_fs_lock, just like rx_fs_list. However, in this case the driver set_rxnfc callback would return with a rather confusing error code, e.g. -EINVAL. So deny set_rxnfc attempts directly if the RX filtering feature is not supported by hardware.
--- drivers/net/ethernet/cadence/macb_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/cadence/macb_main.c +3 -0
@@ -3572,6 +3572,9 @@ static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)struct macb *bp =netdev_priv (netdev);int ret; +if (!(netdev->hw_features &NETIF_F_NTUPLE )) +return -EOPNOTSUPP ; +switch (cmd->cmd) {case ETHTOOL_SRXCLSRLINS : if ((cmd->fs.location >= bp->max_tuples)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 277/570 udp_tunnel: fix NULL deref caused by udp_sock_create6 when CONFIG_IPV6=n
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 b3a6df291fecf5f8a308953b65ca72b7fc9e015d ]
When CONFIG_IPV6 is disabled, the udp_sock_create6() function returns 0 (success) without actually creating a socket. Callers such as fou_create() then proceed to dereference the uninitialized socket pointer, resulting in a NULL pointer dereference.
The captured NULL deref crash:
BUG: kernel NULL pointer dereference, address: 0000000000000018
RIP: 0010:fou_nl_add_doit (net/ipv4/fou_core.c:590 net/ipv4/fou_core.c:764)
[...]
Call Trace:
<TASK>
genl_family_rcv_msg_doit.constprop.0 (net/netlink/genetlink.c:1114)
genl_rcv_msg (net/netlink/genetlink.c:1194 net/netlink/genetlink.c:1209)
[...]
netlink_rcv_skb (net/netlink/af_netlink.c:2550)
genl_rcv (net/netlink/genetlink.c:1219)
netlink_unicast (net/netlink/af_netlink.c:1319 net/netlink/af_netlink.c:1344)
netlink_sendmsg (net/netlink/af_netlink.c:1894)
__sock_sendmsg (net/socket.c:727 (discriminator 1) net/socket.c:742 (discriminator 1))
__sys_sendto (./include/linux/file.h:62 (discriminator 1) ./include/linux/file.h:83 (discriminator 1) net/socket.c:2183 (discriminator 1))
__x64_sys_sendto (net/socket.c:2213 (discriminator 1) net/socket.c:2209 (discriminator 1) net/socket.c:2209 (discriminator 1))
do_syscall_64 (arch/x86/entry/syscall_64.c:63 (discriminator 1) arch/x86/entry/syscall_64.c:94 (discriminator 1))
entry_SYSCALL_64_after_hwframe (net/arch/x86/entry/entry_64.S:130)This patch makes udp_sock_create6 return -EPFNOSUPPORT instead, so callers correctly take their error paths. There is only one caller of the vulnerable function and only privileged users can trigger it.
--- include/net/udp_tunnel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/udp_tunnel.h +1 -1
@@ -47,7 +47,7 @@ int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,static inline int udp_sock_create6 (struct net *net,struct udp_port_cfg *cfg,struct socket **sockp) { -return 0 ; +return -EPFNOSUPPORT ; }#endif
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 278/570 net: bonding: fix NULL deref in bond_debug_rlb_hash_show
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 605b52497bf89b3b154674deb135da98f916e390 ]
rlb_clear_slave intentionally keeps RLB hash-table entries on the rx_hashtbl_used_head list with slave set to NULL when no replacement slave is available. However, bond_debug_rlb_hash_show visites client_info->slave without checking if it's NULL.
Other used-list iterators in bond_alb.c already handle this NULL-slave state safely:
- rlb_update_client returns early on !client_info->slave
- rlb_req_update_slave_clients, rlb_clear_slave, and rlb_rebalance compare slave values before visiting
- lb_req_update_subnet_clients continues if slave is NULL
The following NULL deref crash can be trigger inbond_debug_rlb_hash_show:
[ 1.289791] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 1.292058] RIP: 0010:bond_debug_rlb_hash_show (drivers/net/bonding/bond_debugfs.c:41) [ 1.293101] RSP: 0018:ffffc900004a7d00 EFLAGS: 00010286 [ 1.293333] RAX: 0000000000000000 RBX: ffff888102b48200 RCX: ffff888102b48204 [ 1.293631] RDX: ffff888102b48200 RSI: ffffffff839daad5 RDI: ffff888102815078 [ 1.293924] RBP: ffff888102815078 R08: ffff888102b4820e R09: 0000000000000000 [ 1.294267] R10: 0000000000000000 R11: 0000000000000000 R12: ffff888100f929c0 [ 1.294564] R13: ffff888100f92a00 R14: 0000000000000001 R15: ffffc900004a7ed8 [ 1.294864] FS: 0000000001395380(0000) GS:ffff888196e75000(0000) knlGS:0000000000000000 [ 1.295239] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1.295480] CR2: 0000000000000000 CR3: 0000000102adc004 CR4: 0000000000772ef0 [ 1.295897] Call Trace: [ 1.296134] seq_read_iter (fs/seq_file.c:231) [ 1.296341] seq_read (fs/seq_file.c:164) [ 1.296493] full_proxy_read (fs/debugfs/file.c:378 (discriminator 1)) [ 1.296658] vfs_read (fs/read_write.c:572) [ 1.296981] ksys_read (fs/read_write.c:717) [ 1.297132] do_syscall_64 (arch/x86/entry/syscall_64.c:63 (discriminator 1) arch/x86/entry/syscall_64.c:94 (discriminator 1)) [ 1.297325] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
Add a NULL check and print "(none)" for entries with no assigned slave.
--- drivers/net/bonding/bond_debugfs.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/bonding/bond_debugfs.c +11 -5
@@ -34,11 +34,17 @@ static int bond_debug_rlb_hash_show(struct seq_file *m, void *v)for (; hash_index !=RLB_NULL_INDEX ; hash_index = client_info->used_next) { client_info = &(bond_info->rx_hashtbl[hash_index]); -seq_printf (m,"%-15pI4 %-15pI4 %-17pM %s\n" , - &client_info->ip_src, - &client_info->ip_dst, - &client_info->mac_dst, - client_info->slave->dev->name); +if (client_info->slave) +seq_printf (m,"%-15pI4 %-15pI4 %-17pM %s\n" , + &client_info->ip_src, + &client_info->ip_dst, + &client_info->mac_dst, + client_info->slave->dev->name); +else +seq_printf (m,"%-15pI4 %-15pI4 %-17pM (none)\n" , + &client_info->ip_src, + &client_info->ip_dst, + &client_info->mac_dst); }spin_unlock_bh (&bond->mode_lock);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 279/570 nfnetlink_osf: validate individual option lengths in fingerprints
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 dbdfaae9609629a9569362e3b8f33d0a20fd783c ]
nfnl_osf_add_callback() validates opt_num bounds and string NUL-termination but does not check individual option length fields. A zero-length option causes nf_osf_match_one() to enter the option matching loop even when foptsize sums to zero, which matches packets with no TCP options where ctx->optp is NULL:
Oops: general protection fault KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:nf_osf_match_one (net/netfilter/nfnetlink_osf.c:98) Call Trace: nf_osf_match (net/netfilter/nfnetlink_osf.c:227) xt_osf_match_packet (net/netfilter/xt_osf.c:32) ipt_do_table (net/ipv4/netfilter/ip_tables.c:293) nf_hook_slow (net/netfilter/core.c:623) ip_local_deliver (net/ipv4/ip_input.c:262) ip_rcv (net/ipv4/ip_input.c:573)
Additionally, an MSS option (kind=2) with length < 4 causes out-of-bounds reads when nf_osf_match_one() unconditionally accesses optp[2] and optp[3] for MSS value extraction. While RFC 9293 section 3.2 specifies that the MSS option is always exactly 4 bytes (Kind=2, Length=4), the check uses "< 4" rather than "!= 4" because lengths greater than 4 do not cause memory safety issues -- the buffer is guaranteed to be at least foptsize bytes by the ctx->optsize == foptsize check.
Reject fingerprints where any option has zero length, or where an MSS option has length less than 4, at add time rather than trusting these values in the packet matching hot path.
--- net/netfilter/nfnetlink_osf.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
net/netfilter/nfnetlink_osf.c +13 -0
@@ -302,7 +302,9 @@ static int nfnl_osf_add_callback(struct sk_buff *skb, {struct nf_osf_user_finger *f;struct nf_osf_finger *kf =NULL , *sf; +unsigned int tot_opt_len =0 ;int err =0 ; +int i;if (!capable (CAP_NET_ADMIN ))return -EPERM ;
@@ -318,6 +320,17 @@ static int nfnl_osf_add_callback(struct sk_buff *skb,if (f->opt_num >ARRAY_SIZE (f->opt))return -EINVAL ; +for (i =0 ; i < f->opt_num; i++) { +if (!f->opt[i].length || f->opt[i].length >MAX_IPOPTLEN ) +return -EINVAL ; +if (f->opt[i].kind ==OSFOPT_MSS && f->opt[i].length <4 ) +return -EINVAL ; + + tot_opt_len += f->opt[i].length; +if (tot_opt_len >MAX_IPOPTLEN ) +return -EINVAL ; + } +if (!memchr (f->genre,0 ,MAXGENRELEN ) || !memchr (f->subtype,0 ,MAXGENRELEN ) || !memchr (f->version,0 ,MAXGENRELEN ))
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 280/570 net: mvpp2: guard flow control update with global_tx_fc in buffer switching
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Hammad Ijaz <[email protected]>
[ Upstream commit 8a63baadf08453f66eb582fdb6dd234f72024723 ]
mvpp2_bm_switch_buffers() unconditionally calls mvpp2_bm_pool_update_priv_fc() when switching between per-cpu and shared buffer pool modes. This function programs CM3 flow control registers via mvpp2_cm3_read()/mvpp2_cm3_write(), which dereference priv->cm3_base without any NULL check.
When the CM3 SRAM resource is not present in the device tree (the third reg entry added by commit 60523583b07c ("dts: marvell: add CM3 SRAM memory to cp11x ethernet device tree")), priv->cm3_base remains NULL and priv->global_tx_fc is false. Any operation that triggers mvpp2_bm_switch_buffers(), for example an MTU change that crosses the jumbo frame threshold, will crash:
Unable to handle kernel NULL pointer dereference at
virtual address 0000000000000000
Mem abort info:
ESR = 0x0000000096000006
EC = 0x25: DABT (current EL), IL = 32 bits
pc : readl+0x0/0x18
lr : mvpp2_cm3_read.isra.0+0x14/0x20
Call trace:
readl+0x0/0x18
mvpp2_bm_pool_update_fc+0x40/0x12c
mvpp2_bm_pool_update_priv_fc+0x94/0xd8
mvpp2_bm_switch_buffers.isra.0+0x80/0x1c0
mvpp2_change_mtu+0x140/0x380
__dev_set_mtu+0x1c/0x38
dev_set_mtu_ext+0x78/0x118
dev_set_mtu+0x48/0xa8
dev_ifsioc+0x21c/0x43c
dev_ioctl+0x2d8/0x42c
sock_ioctl+0x314/0x378Every other flow control call site in the driver already guards hardware access with either priv->global_tx_fc or port->tx_fc. mvpp2_bm_switch_buffers() is the only place that omits this check.
Add the missing priv->global_tx_fc guard to both the disable and re-enable calls in mvpp2_bm_switch_buffers(), consistent with the rest of the driver.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 -2
@@ -5006,7 +5006,7 @@ static int mvpp2_bm_switch_buffers(struct mvpp2 *priv, bool percpu)if (priv->percpu_pools) numbufs = port->nrxqs *2 ; -if (change_percpu) +if (change_percpu && priv->global_tx_fc)mvpp2_bm_pool_update_priv_fc (priv, false);for (i =0 ; i < numbufs; i++)
@@ -5023,7 +5023,7 @@ static int mvpp2_bm_switch_buffers(struct mvpp2 *priv, bool percpu)mvpp2_open (port->dev); } -if (change_percpu) +if (change_percpu && priv->global_tx_fc)mvpp2_bm_pool_update_priv_fc (priv, true);return 0 ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 281/570 net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anas Iqbal <[email protected]>
[ Upstream commit b48731849609cbd8c53785a48976850b443153fd ]
Smatch reports:drivers/net/dsa/bcm_sf2.c:997 bcm_sf2_sw_resume() warn:
'priv->clk' from clk_prepare_enable() not released on lines: 983,990.
The clock enabled by clk_prepare_enable() in bcm_sf2_sw_resume() is not released if bcm_sf2_sw_rst() or bcm_sf2_cfp_resume() fails.
Add the missing clk_disable_unprepare() calls in the error paths to properly release the clock resource.
--- drivers/net/dsa/bcm_sf2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/dsa/bcm_sf2.c +6 -2
@@ -962,15 +962,19 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds) ret =bcm_sf2_sw_rst (priv);if (ret) {pr_err ("%s: failed to software reset switch\n" , __func__); +if (!priv->wol_ports_mask) +clk_disable_unprepare (priv->clk);return ret; }bcm_sf2_crossbar_setup (priv); ret =bcm_sf2_cfp_resume (ds); -if (ret) +if (ret) { +if (!priv->wol_ports_mask) +clk_disable_unprepare (priv->clk);return ret; - + }if (priv->hw_params.num_gphy ==1 )bcm_sf2_gphy_enable_set (ds, true);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 282/570 icmp: fix NULL pointer dereference in icmp_tag_validation()
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 614aefe56af8e13331e50220c936fc0689cf5675 ]
icmp_tag_validation() unconditionally dereferences the result of rcu_dereference(inet_protos[proto]) without checking for NULL. The inet_protos[] array is sparse -- only about 15 of 256 protocol numbers have registered handlers. When ip_no_pmtu_disc is set to 3 (hardened PMTU mode) and the kernel receives an ICMP Fragmentation Needed error with a quoted inner IP header containing an unregistered protocol number, the NULL dereference causes a kernel panic in softirq context.
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] RIP: 0010:icmp_unreach (net/ipv4/icmp.c:1085 net/ipv4/icmp.c:1143) Call Trace: <IRQ> icmp_rcv (net/ipv4/icmp.c:1527) ip_protocol_deliver_rcu (net/ipv4/ip_input.c:207) ip_local_deliver_finish (net/ipv4/ip_input.c:242) ip_local_deliver (net/ipv4/ip_input.c:262) ip_rcv (net/ipv4/ip_input.c:573) __netif_receive_skb_one_core (net/core/dev.c:6164) process_backlog (net/core/dev.c:6628) handle_softirqs (kernel/softirq.c:561) </IRQ>
Add a NULL check before accessing icmp_strict_tag_validation. If the protocol has no registered handler, return false since it cannot perform strict tag validation.
--- net/ipv4/icmp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv4/icmp.c +3 -1
@@ -845,10 +845,12 @@ static void icmp_socket_deliver(struct sk_buff *skb, u32 info)static bool icmp_tag_validation (int proto) { +const struct net_protocol *ipprot;bool ok;rcu_read_lock (); - ok =rcu_dereference (inet_protos[proto])->icmp_strict_tag_validation; + ipprot =rcu_dereference (inet_protos[proto]); + ok = ipprot ? ipprot->icmp_strict_tag_validation : false;rcu_read_unlock ();return ok; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 283/570 hwmon: (pmbus/isl68137) Fix unchecked return value and use sysfs_emit()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanman Pradhan <[email protected]>
commit 86259558e422b250aa6aa57163a6d759074573f5 upstream.
isl68137_avs_enable_show_page() uses the return value of pmbus_read_byte_data() without checking for errors. If the I2C transaction fails, a negative error code is passed through bitwise operations, producing incorrect output.
Add an error check to propagate the return value if it is negative. Additionally, modernize the callback by replacing sprintf() with sysfs_emit().
--- drivers/hwmon/pmbus/isl68137.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/hwmon/pmbus/isl68137.c +5 -2
@@ -80,8 +80,11 @@ static ssize_t isl68137_avs_enable_show_ {int val =pmbus_read_byte_data (client, page,PMBUS_OPERATION ); -return sprintf (buf,"%d\n" , - (val &ISL68137_VOUT_AVS ) ==ISL68137_VOUT_AVS ?1 :0 ); +if (val <0 ) +return val; + +return sysfs_emit (buf,"%d\n" , + (val &ISL68137_VOUT_AVS ) ==ISL68137_VOUT_AVS ); } static ssize_t isl68137_avs_enable_store_page(struct i2c_client *client,
Greg Kroah-Hartman
maintainerPATCH 284/570 i2c: fsi: Fix a potential leak in fsi_i2c_probe()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
commit be627abcc0d5dbd5882873bd85fbc18aa3d189ed upstream.
In the commit in Fixes:, when the code has been updated to use an explicit for loop, instead of for_each_available_child_of_node(), the assumption that a reference to a device_node structure would be released at each iteration has been broken.
Now, an explicit of_node_put() is needed to release the reference.
--- drivers/i2c/busses/i2c-fsi.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-fsi.c +1 -0
@@ -728,6 +728,7 @@ static int fsi_i2c_probe(struct device * rc =i2c_add_adapter (&port->adapter);if (rc <0 ) {dev_err (dev,"Failed to register adapter: %d\n" , rc); +of_node_put (np);kfree (port);continue ; }
Greg Kroah-Hartman
maintainerPATCH 285/570 mtd: rawnand: serialize lock/unlock against other NAND operations
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kamal Dasu <[email protected]>
[ Upstream commit bab2bc6e850a697a23b9e5f0e21bb8c187615e95 ]
nand_lock() and nand_unlock() call into chip->ops.lock_area/unlock_area without holding the NAND device lock. On controllers that implement SET_FEATURES via multiple low-level PIO commands, these can race with concurrent UBI/UBIFS background erase/write operations that hold the device lock, resulting in cmd_pending conflicts on the NAND controller.
Add nand_get_device()/nand_release_device() around the lock/unlock operations to serialize them against all other NAND controller access.
--- drivers/mtd/nand/raw/nand_base.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/nand_base.c +12 -2
@@ -4680,11 +4680,16 @@ static void nand_shutdown(struct mtd_info *mtd)static int nand_lock (struct mtd_info *mtd,loff_t ofs,uint64_t len) {struct nand_chip *chip =mtd_to_nand (mtd); +int ret;if (!chip->ops.lock_area)return -ENOTSUPP ; -return chip->ops.lock_area (chip, ofs, len); +nand_get_device (chip); + ret = chip->ops.lock_area (chip, ofs, len); +nand_release_device (chip); + +return ret; }/**
@@ -4696,11 +4701,16 @@ static int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)static int nand_unlock (struct mtd_info *mtd,loff_t ofs,uint64_t len) {struct nand_chip *chip =mtd_to_nand (mtd); +int ret;if (!chip->ops.unlock_area)return -ENOTSUPP ; -return chip->ops.unlock_area (chip, ofs, len); +nand_get_device (chip); + ret = chip->ops.unlock_area (chip, ofs, len); +nand_release_device (chip); + +return ret; }/* Set default functions */
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 286/570 mtd: rawnand: brcmnand: skip DMA during panic write
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kamal Dasu <[email protected]>
[ Upstream commit da9ba4dcc01e7cf52b7676f0ee9607b8358c2171 ]
When oops_panic_write is set, the driver disables interrupts and switches to PIO polling mode but still falls through into the DMA path. DMA cannot be used reliably in panic context, so make the DMA path an else branch to ensure only PIO is used during panic writes.
--- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +2 -4
@@ -2399,14 +2399,12 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip,for (i =0 ; i < ctrl->max_oob; i +=4 )oob_reg_write (ctrl, i,0xffffffff ); -if (mtd->oops_panic_write) +if (mtd->oops_panic_write) {/* switch to interrupt polling and PIO mode */ disable_ctrl_irqs (ctrl); - -if (use_dma (ctrl) && (has_edu (ctrl) || !oob) &&flash_dma_buf_ok (buf)) { + }else if (use_dma (ctrl) && (has_edu (ctrl) || !oob) &&flash_dma_buf_ok (buf)) {if (ctrl->dma_trans (host, addr, (u32 *)buf, oob, mtd->writesize,CMD_PROGRAM_PAGE )) - ret = -EIO ; goto out;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 287/570 ksmbd: fix use-after-free of share_conf in compound request
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
[ Upstream commit c33615f995aee80657b9fdfbc4ee7f49c2bd733d ]
smb2_get_ksmbd_tcon() reuses work->tcon in compound requests without validating tcon->t_state. ksmbd_tree_conn_lookup() checks t_state == TREE_CONNECTED on the initial lookup path, but the compound reuse path bypasses this check entirely.
If a prior command in the compound (SMB2_TREE_DISCONNECT) sets t_state to TREE_DISCONNECTED and frees share_conf via ksmbd_share_config_put(), subsequent commands dereference the freed share_conf through work->tcon->share_conf.
KASAN report:
[ 4.144653] ================================================================== [ 4.145059] BUG: KASAN: slab-use-after-free in smb2_write+0xc74/0xe70 [ 4.145415] Read of size 4 at addr ffff88810430c194 by task kworker/1:1/44 [ 4.145772] [ 4.145867] CPU: 1 UID: 0 PID: 44 Comm: kworker/1:1 Not tainted 7.0.0-rc3+ #60 PREEMPTLAZY [ 4.145871] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 4.145875] Workqueue: ksmbd-io handle_ksmbd_work [ 4.145888] Call Trace: [ 4.145892] <TASK> [ 4.145894] dump_stack_lvl+0x64/0x80 [ 4.145910] print_report+0xce/0x660 [ 4.145919] ? __pfx__raw_spin_lock_irqsave+0x10/0x10 [ 4.145928] ? smb2_write+0xc74/0xe70 [ 4.145931] kasan_report+0xce/0x100 [ 4.145934] ? smb2_write+0xc74/0xe70 [ 4.145937] smb2_write+0xc74/0xe70 [ 4.145939] ? __pfx_smb2_write+0x10/0x10 [ 4.145942] ? _raw_spin_unlock+0xe/0x30 [ 4.145945] ? ksmbd_smb2_check_message+0xeb2/0x24c0 [ 4.145948] ? smb2_tree_disconnect+0x31c/0x480 [ 4.145951] handle_ksmbd_work+0x40f/0x1080 [ 4.145953] process_one_work+0x5fa/0xef0 [ 4.145962] ? assign_work+0x122/0x3e0 [ 4.145964] worker_thread+0x54b/0xf70 [ 4.145967] ? __pfx_worker_thread+0x10/0x10 [ 4.145970] kthread+0x346/0x470 [ 4.145976] ? recalc_sigpending+0x19b/0x230 [ 4.145980] ? __pfx_kthread+0x10/0x10 [ 4.145984] ret_from_fork+0x4fb/0x6c0 [ 4.145992] ? __pfx_ret_from_fork+0x10/0x10 [ 4.145995] ? __switch_to+0x36c/0xbe0 [ 4.145999] ? __pfx_kthread+0x10/0x10 [ 4.146003] ret_from_fork_asm+0x1a/0x30 [ 4.146013] </TASK> [ 4.146014] [ 4.149858] Allocated by task 44: [ 4.149953] kasan_save_stack+0x33/0x60 [ 4.150061] kasan_save_track+0x14/0x30 [ 4.150169] __kasan_kmalloc+0x8f/0xa0 [ 4.150274] ksmbd_share_config_get+0x1dd/0xdd0 [ 4.150401] ksmbd_tree_conn_connect+0x7e/0x600 [ 4.150529] smb2_tree_connect+0x2e6/0x1000 [ 4.150645] handle_ksmbd_work+0x40f/0x1080 [ 4.150761] process_one_work+0x5fa/0xef0 [ 4.150873] worker_thread+0x54b/0xf70 [ 4.150978] kthread+0x346/0x470 [ 4.151071] ret_from_fork+0x4fb/0x6c0 [ 4.151176] ret_from_fork_asm+0x1a/0x30 [ 4.151286] [ 4.151332] Freed by task 44: [ 4.151418] kasan_save_stack+0x33/0x60 [ 4.151526] kasan_save_track+0x14/0x30 [ 4.151634] kasan_save_free_info+0x3b/0x60 [ 4.151751] __kasan_slab_free+0x43/0x70 [ 4.151861] kfree+0x1ca/0x430 [ 4.151952] __ksmbd_tree_conn_disconnect+0xc8/0x190 [ 4.152088] smb2_tree_disconnect+0x1cd/0x480 [ 4.152211] handle_ksmbd_work+0x40f/0x1080 [ 4.152326] process_one_work+0x5fa/0xef0 [ 4.152438] worker_thread+0x54b/0xf70 [ 4.152545] kthread+0x346/0x470 [ 4.152638] ret_from_fork+0x4fb/0x6c0 [ 4.152743] ret_from_fork_asm+0x1a/0x30 [ 4.152853] [ 4.152900] The buggy address belongs to the object at ffff88810430c180 [ 4.152900] which belongs to the cache kmalloc-96 of size 96 [ 4.153226] The buggy address is located 20 bytes inside of [ 4.153226] freed 96-byte region [ffff88810430c180, ffff88810430c1e0) [ 4.153549] [ 4.153596] The buggy address belongs to the physical page: [ 4.153750] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff88810430ce80 pfn:0x10430c [ 4.154000] flags: 0x100000000000200(workingset|node=0|zone=2) [ 4.154160] page_type: f5(slab) [ 4.154251] raw: 0100000000000200 ffff888100041280 ffff888100040110 ffff888100040110 [ 4.154461] raw: ffff88810430ce80 0000000800200009 00000000f5000000 0000000000000000 [ 4.154668] page dumped because: kasan: bad access detected [ 4.154820] [ 4.154866] Memory state around the buggy address: [ 4.155002] ffff88810430c080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 4.155196] ffff88810430c100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 4.155391] >ffff88810430c180: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc [ 4.155587] ^ [ 4.155693] ffff88810430c200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 4.155891] ffff88810430c280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 4.156087] ==================================================================
Add the same t_state validation to the compound reuse path, consistent with ksmbd_tree_conn_lookup().
--- fs/ksmbd/smb2pdu.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ksmbd/smb2pdu.c +2 -0
@@ -116,6 +116,8 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)pr_err ("The first operation in the compound does not have tcon\n" );return -EINVAL ; } +if (work->tcon->t_state !=TREE_CONNECTED ) +return -ENOENT ;if (tree_id !=UINT_MAX && work->tcon->id != tree_id) {pr_err ("tree id(%u) is different with id(%u) in first operation\n" , tree_id, work->tcon->id);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 288/570 drm/i915/gt: Check set_default_submission() before deferencing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rahul Bukte <[email protected]>
[ Upstream commit 0162ab3220bac870e43e229e6e3024d1a21c3f26 ]
When the i915 driver firmware binaries are not present, the set_default_submission pointer is not set. This pointer is dereferenced during suspend anyways.
Add a check to make sure it is set before dereferencing.
[ 23.289926] PM: suspend entry (deep) [ 23.293558] Filesystems sync: 0.000 seconds [ 23.298010] Freezing user space processes [ 23.302771] Freezing user space processes completed (elapsed 0.000 seconds) [ 23.309766] OOM killer disabled. [ 23.313027] Freezing remaining freezable tasks [ 23.318540] Freezing remaining freezable tasks completed (elapsed 0.001 seconds) [ 23.342038] serial 00:05: disabled [ 23.345719] serial 00:02: disabled [ 23.349342] serial 00:01: disabled [ 23.353782] sd 0:0:0:0: [sda] Synchronizing SCSI cache [ 23.358993] sd 1:0:0:0: [sdb] Synchronizing SCSI cache [ 23.361635] ata1.00: Entering standby power mode [ 23.368863] ata2.00: Entering standby power mode [ 23.445187] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 23.452194] #PF: supervisor instruction fetch in kernel mode [ 23.457896] #PF: error_code(0x0010) - not-present page [ 23.463065] PGD 0 P4D 0 [ 23.465640] Oops: Oops: 0010 [#1] SMP NOPTI [ 23.469869] CPU: 8 UID: 0 PID: 211 Comm: kworker/u48:18 Tainted: G S W 6.19.0-rc4-00020-gf0b9d8eb98df #10 PREEMPT(voluntary) [ 23.482512] Tainted: [S]=CPU_OUT_OF_SPEC, [W]=WARN [ 23.496511] Workqueue: async async_run_entry_fn [ 23.501087] RIP: 0010:0x0 [ 23.503755] Code: Unable to access opcode bytes at 0xffffffffffffffd6. [ 23.510324] RSP: 0018:ffffb4a60065fca8 EFLAGS: 00010246 [ 23.515592] RAX: 0000000000000000 RBX: ffff9f428290e000 RCX: 000000000000000f [ 23.522765] RDX: 0000000000000000 RSI: 0000000000000282 RDI: ffff9f428290e000 [ 23.529937] RBP: ffff9f4282907070 R08: ffff9f4281130428 R09: 00000000ffffffff [ 23.537111] R10: 0000000000000000 R11: 0000000000000001 R12: ffff9f42829070f8 [ 23.544284] R13: ffff9f4282906028 R14: ffff9f4282900000 R15: ffff9f4282906b68 [ 23.551457] FS: 0000000000000000(0000) GS:ffff9f466b2cf000(0000) knlGS:0000000000000000 [ 23.559588] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 23.565365] CR2: ffffffffffffffd6 CR3: 000000031c230001 CR4: 0000000000f70ef0 [ 23.572539] PKRU: 55555554 [ 23.575281] Call Trace: [ 23.577770] <TASK> [ 23.579905] intel_engines_reset_default_submission+0x42/0x60 [ 23.585695] __intel_gt_unset_wedged+0x191/0x200 [ 23.590360] intel_gt_unset_wedged+0x20/0x40 [ 23.594675] gt_sanitize+0x15e/0x170 [ 23.598290] i915_gem_suspend_late+0x6b/0x180 [ 23.602692] i915_drm_suspend_late+0x35/0xf0 [ 23.607008] ? __pfx_pci_pm_suspend_late+0x10/0x10 [ 23.611843] dpm_run_callback+0x78/0x1c0 [ 23.615817] device_suspend_late+0xde/0x2e0 [ 23.620037] async_suspend_late+0x18/0x30 [ 23.624082] async_run_entry_fn+0x25/0xa0 [ 23.628129] process_one_work+0x15b/0x380 [ 23.632182] worker_thread+0x2a5/0x3c0 [ 23.635973] ? __pfx_worker_thread+0x10/0x10 [ 23.640279] kthread+0xf6/0x1f0 [ 23.643464] ? __pfx_kthread+0x10/0x10 [ 23.647263] ? __pfx_kthread+0x10/0x10 [ 23.651045] ret_from_fork+0x131/0x190 [ 23.654837] ? __pfx_kthread+0x10/0x10 [ 23.658634] ret_from_fork_asm+0x1a/0x30 [ 23.662597] </TASK> [ 23.664826] Modules linked in: [ 23.667914] CR2: 0000000000000000 [ 23.671271] ------------[ cut here ]------------
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +2 -1
@@ -1363,7 +1363,8 @@ void intel_engines_reset_default_submission(struct intel_gt *gt)if (engine->sanitize) engine->sanitize (engine); - engine->set_default_submission (engine); +if (engine->set_default_submission) + engine->set_default_submission (engine); } }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 289/570 lib/bootconfig: check xbc_init_node() return in override path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Law <[email protected]>
[ Upstream commit bb288d7d869e86d382f35a0e26242c5ccb05ca82 ]
The ':=' override path in xbc_parse_kv() calls xbc_init_node() to re-initialize an existing value node but does not check the return value. If xbc_init_node() fails (data offset out of range), parsing silently continues with stale node data.
Add the missing error check to match the xbc_add_node() call path which already checks for failure.
In practice, a bootconfig using ':=' to override a value near the 32KB data limit could silently retain the old value, meaning a security-relevant boot parameter override (e.g., a trace filter or debug setting) would not take effect as intended.
--- lib/bootconfig.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/bootconfig.c +2 -1
@@ -646,7 +646,8 @@ static int __init xbc_parse_kv(char **k, char *v, int op)if (op ==':' ) {unsigned short nidx = child->next; -xbc_init_node (child, v,XBC_VALUE ); +if (xbc_init_node (child, v,XBC_VALUE ) <0 ) +return xbc_parse_error ("Failed to override value" , v); child->next = nidx;/* keep subkeys */ goto array; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 290/570 tools/bootconfig: fix fd leak in load_xbc_file() on fstat failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Law <[email protected]>
[ Upstream commit 3b2c2ab4ceb82af484310c3087541eab00ea288b ]
If fstat() fails after open() succeeds, the function returns without closing the file descriptor. Also preserve errno across close(), since close() may overwrite it before the error is returned.
--- tools/bootconfig/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tools/bootconfig/main.c +5 -2
@@ -156,8 +156,11 @@ static int load_xbc_file(const char *path, char **buf)if (fd <0 )return -errno; ret =fstat (fd, &stat); -if (ret <0 ) -return -errno; +if (ret <0 ) { + ret = -errno; +close (fd); +return ret; + } ret =load_xbc_fd (fd, buf, stat.st_size);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 291/570 netfilter: nf_tables: de-constify set commit ops function argument
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit 256001672153af5786c6ca148114693d7d76d836 upstream.
The set backend using this already has to work around this via ugly cast, don't spread this pattern.
--- include/net/netfilter/nf_tables.h | 2 +- net/netfilter/nft_set_pipapo.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-)
include/net/netfilter/nf_tables.h +1 -1
@@ -455,7 +455,7 @@ struct nft_set_ops {const struct nft_set *set, const struct nft_set_elem *elem, unsigned int flags); -void (*commit)(const struct nft_set *set); +void (*commit)(struct nft_set *set);void (*abort)(const struct nft_set *set);u64 (*privsize)(const struct nlattr *const nla[],const struct nft_set_desc *desc);
net/netfilter/nft_set_pipapo.c +3 -4
@@ -1587,12 +1587,11 @@ static void nft_pipapo_gc_deactivate(str/** * pipapo_gc() - Drop expired entries from set, destroy start and end elements -* @_set: nftables API set representation +* @set: nftables API set representation * @m: Matching data */ -static void pipapo_gc (const struct nft_set *_set,struct nft_pipapo_match *m) +static void pipapo_gc (struct nft_set *set,struct nft_pipapo_match *m) { -struct nft_set *set = (struct nft_set *) _set;struct nft_pipapo *priv =nft_set_priv (set);struct net *net =read_pnet (&set->net);u64 tstamp =nft_net_tstamp (net);
@@ -1707,7 +1706,7 @@ static void pipapo_reclaim_match(struct* We also need to create a new working copy for subsequent insertions and * deletions. */ -static void nft_pipapo_commit (const struct nft_set *set) +static void nft_pipapo_commit (struct nft_set *set) {struct nft_pipapo *priv =nft_set_priv (set);struct nft_pipapo_match *new_clone, *old;
Greg Kroah-Hartman
maintainerPATCH 292/570 netfilter: nft_set_pipapo: split gc into unlink and reclaim phase
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit 9df95785d3d8302f7c066050117b04cd3c2048c2 upstream.
Yiming Qian reports Use-after-free in the pipapo set type:
Under a large number of expired elements, commit-time GC can run for a very long time in a non-preemptible context, triggering soft lockup warnings and RCU stall reports (local denial of service).
We must split GC in an unlink and a reclaim phase.
We cannot queue elements for freeing until pointers have been swapped. Expired elements are still exposed to both the packet path and userspace dumpers via the live copy of the data structure.
call_rcu() does not protect us: dump operations or element lookups starting after call_rcu has fired can still observe the free'd element, unless the commit phase has made enough progress to swap the clone and live pointers before any new reader has picked up the old version.
This a similar approach as done recently for the rbtree backend in commit 35f83a75529a ("netfilter: nft_set_rbtree: don't gc elements on insert").
--- include/net/netfilter/nf_tables.h | 5 +++ net/netfilter/nf_tables_api.c | 5 --- net/netfilter/nft_set_pipapo.c | 51 ++++++++++++++++++++++++++++++++------ net/netfilter/nft_set_pipapo.h | 2 + 4 files changed, 50 insertions(+), 13 deletions(-)
include/net/netfilter/nf_tables.h +5 -0
@@ -1655,6 +1655,11 @@ struct nft_trans_gc {struct rcu_head rcu; }; +static inline int nft_trans_gc_space (const struct nft_trans_gc *trans) +{ +return NFT_TRANS_GC_BATCHCOUNT - trans->count; +} +struct nft_trans_gc *nft_trans_gc_alloc (struct nft_set *set,unsigned int gc_seq,gfp_t gfp);void nft_trans_gc_destroy (struct nft_trans_gc *trans);
net/netfilter/nf_tables_api.c +0 -5
@@ -9146,11 +9146,6 @@ static void nft_trans_gc_queue_work(struschedule_work (&trans_gc_work); } -static int nft_trans_gc_space (struct nft_trans_gc *trans) -{ -return NFT_TRANS_GC_BATCHCOUNT - trans->count; -} -struct nft_trans_gc *nft_trans_gc_queue_async (struct nft_trans_gc *gc,unsigned int gc_seq,gfp_t gfp) {
net/netfilter/nft_set_pipapo.c +43 -8
110 lines not on this page · raw message
net/netfilter/nft_set_pipapo.h +2 -0
@@ -165,6 +165,7 @@ struct nft_pipapo_match {* @width: Total bytes to be matched for one packet, including padding * @dirty: Working copy has pending insertions or deletions * @last_gc: Timestamp of last garbage collection run, jiffies +* @gc_head: list of nft_trans_gc to queue up for mem reclaim */ struct nft_pipapo {struct nft_pipapo_match __rcu *match;
@@ -172,6 +173,7 @@ struct nft_pipapo {int width;bool dirty;unsigned long last_gc; +struct list_head gc_head; };struct nft_pipapo_elem ;
Greg Kroah-Hartman
maintainerPATCH 293/570 xen/privcmd: restrict usage in unprivileged domU
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit 453b8fb68f3641fea970db88b7d9a153ed2a37e8 upstream.
The Xen privcmd driver allows to issue arbitrary hypercalls from user space processes. This is normally no problem, as access is usually limited to root and the hypervisor will deny any hypercalls affecting other domains.
In case the guest is booted using secure boot, however, the privcmd driver would be enabling a root user process to modify e.g. kernel memory contents, thus breaking the secure boot feature.
The only known case where an unprivileged domU is really needing to use the privcmd driver is the case when it is acting as the device model for another guest. In this case all hypercalls issued via the privcmd driver will target that other guest.
Fortunately the privcmd driver can already be locked down to allow only hypercalls targeting a specific domain, but this mode can be activated from user land only today.
The target domain can be obtained from Xenstore, so when not running in dom0 restrict the privcmd driver to that target domain from the beginning, resolving the potential problem of breaking secure boot.
This is XSA-482
--- drivers/xen/privcmd.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-)
drivers/xen/privcmd.c +57 -3
@@ -10,6 +10,7 @@#define pr_fmt (fmt) "xen:" KBUILD_MODNAME ": " fmt#include <linux/kernel.h> +#include <linux/kstrtox.h> #include <linux/module.h> #include <linux/sched.h> #include <linux/slab.h>
@@ -24,6 +25,8 @@#include <linux/seq_file.h> #include <linux/miscdevice.h> #include <linux/moduleparam.h> +#include <linux/notifier.h> +#include <linux/wait.h> #include <asm/xen/hypervisor.h> #include <asm/xen/hypercall.h>
@@ -37,6 +40,7 @@#include <xen/page.h> #include <xen/xen-ops.h> #include <xen/balloon.h> +#include <xen/xenbus.h> #include "privcmd.h"
@@ -59,6 +63,11 @@ struct privcmd_data {domid_t domid; }; +/* DOMID_INVALID implies no restriction */ +static domid_t target_domain =DOMID_INVALID ; +static bool restrict_wait; +static DECLARE_WAIT_QUEUE_HEAD (restrict_wait_wq); + static int privcmd_vma_range_is_mapped( struct vm_area_struct *vma, unsigned long addr,
@@ -877,13 +886,16 @@ static long privcmd_ioctl(struct file *fstatic int privcmd_open (struct inode *ino,struct file *file) { -struct privcmd_data *data =kzalloc (sizeof (*data),GFP_KERNEL ); +struct privcmd_data *data; + +if (wait_event_interruptible (restrict_wait_wq, !restrict_wait) <0 ) +return -EINTR ; + data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ; -/* DOMID_INVALID implies no restriction */ - data->domid =DOMID_INVALID ; + data->domid = target_domain; file->private_data = data;return 0 ;
@@ -976,6 +988,45 @@ static struct miscdevice privcmd_dev = { .fops = &xen_privcmd_fops, }; +static int init_restrict (struct notifier_block *notifier, +unsigned long event, +void *data) +{ +char *target; +unsigned int domid; + +/* Default to an guaranteed unused domain-id. */ + target_domain =DOMID_IDLE ; + + target =xenbus_read (XBT_NIL ,"target" ,"" ,NULL ); +if (IS_ERR (target) ||kstrtouint (target,10 , &domid)) { +pr_err ("No target domain found, blocking all hypercalls\n" ); + goto out; + } + + target_domain = domid; + + out: +if (!IS_ERR (target)) +kfree (target); + + restrict_wait = false; +wake_up_all (&restrict_wait_wq); + +return NOTIFY_DONE ; +} + +static struct notifier_block xenstore_notifier = { + .notifier_call = init_restrict, +}; + +static void __init restrict_driver (void ) +{ + restrict_wait = true; + +register_xenstore_notifier (&xenstore_notifier); +} +static int __init privcmd_init (void ) {int err;
@@ -983,6 +1034,9 @@ static int __init privcmd_init(void)if (!xen_domain ())return -ENODEV ; +if (!xen_initial_domain ()) +restrict_driver (); + err =misc_register (&privcmd_dev);if (err !=0 ) {pr_err ("Could not register Xen privcmd device\n" );
Greg Kroah-Hartman
maintainerPATCH 294/570 xen/privcmd: add boot control for restricted usage in domU
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit 1613462be621ad5103ec338a7b0ca0746ec4e5f1 upstream.
When running in an unprivileged domU under Xen, the privcmd driver is restricted to allow only hypercalls against a target domain, for which the current domU is acting as a device model.
Add a boot parameter "unrestricted" to allow all hypercalls (the hypervisor will still refuse destructive hypercalls affecting other guests).
Make this new parameter effective only in case the domU wasn't started using secure boot, as otherwise hypercalls targeting the domU itself might result in violating the secure boot functionality.
This is achieved by adding another lockdown reason, which can be tested to not being set when applying the "unrestricted" option.
This is part of XSA-482
--- drivers/xen/privcmd.c | 13 +++++++++++++ include/linux/security.h | 1 + security/security.c | 1 + 3 files changed, 15 insertions(+)
drivers/xen/privcmd.c +13 -0
@@ -26,6 +26,7 @@#include <linux/miscdevice.h> #include <linux/moduleparam.h> #include <linux/notifier.h> +#include <linux/security.h> #include <linux/wait.h> #include <asm/xen/hypervisor.h>
@@ -59,6 +60,11 @@ module_param_named(dm_op_buf_max_size, pMODULE_PARM_DESC (dm_op_buf_max_size,"Maximum size of a dm_op hypercall buffer" ); +static bool unrestricted; +module_param (unrestricted, bool,0 ); +MODULE_PARM_DESC (unrestricted, +"Don't restrict hypercalls to target domain if running in a domU" ); +struct privcmd_data {domid_t domid; };
@@ -1022,6 +1028,13 @@ static struct notifier_block xenstore_nostatic void __init restrict_driver (void ) { +if (unrestricted) { +if (security_locked_down (LOCKDOWN_XEN_USER_ACTIONS )) +pr_warn ("Kernel is locked down, parameter \"unrestricted\" ignored\n" ); +else +return ; + } + restrict_wait = true;register_xenstore_notifier (&xenstore_notifier);
include/linux/security.h +1 -0
@@ -122,6 +122,7 @@ enum lockdown_reason {LOCKDOWN_XMON_WR ,LOCKDOWN_BPF_WRITE_USER ,LOCKDOWN_DBG_WRITE_KERNEL , +LOCKDOWN_XEN_USER_ACTIONS ,LOCKDOWN_INTEGRITY_MAX ,LOCKDOWN_KCORE , LOCKDOWN_KPROBES,
security/security.c +1 -0
@@ -60,6 +60,7 @@ const char *const lockdown_reasons[LOCKD [LOCKDOWN_XMON_WR] = "xmon write access", [LOCKDOWN_BPF_WRITE_USER] = "use of bpf to write user RAM", [LOCKDOWN_DBG_WRITE_KERNEL] = "use of kgdb/kdb to write kernel RAM", + [LOCKDOWN_XEN_USER_ACTIONS] = "Xen guest user action", [LOCKDOWN_INTEGRITY_MAX] = "integrity", [LOCKDOWN_KCORE] = "/proc/kcore access", [LOCKDOWN_KPROBES] = "use of kprobes",
Greg Kroah-Hartman
maintainerPATCH 295/570 sh: platform_early: remove pdev->driver_override check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danilo Krummrich <[email protected]>
[ Upstream commit c5f60e3f07b6609562d21efda878e83ce8860728 ]
In commit 507fd01d5333 ("drivers: move the early platform device support to arch/sh") platform_match() was copied over to the sh platform_early code, accidentally including the driver_override check.
This check does not make sense for platform_early, as sysfs is not even available in first place at this point in the boot process, hence remove the check.
--- arch/sh/drivers/platform_early.c | 4 ---- 1 file changed, 4 deletions(-)
arch/sh/drivers/platform_early.c +0 -4
@@ -26,10 +26,6 @@ static int platform_match(struct device *dev, struct device_driver *drv)struct platform_device *pdev =to_platform_device (dev);struct platform_driver *pdrv =to_platform_driver (drv); -/* When driver_override is set, only bind to the matching driver */ -if (pdev->driver_override) -return !strcmp (pdev->driver_override, drv->name); -/* Then try to match against the id table */ if (pdrv->id_table)return platform_match_id (pdrv->id_table, pdev) !=NULL ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 296/570 bpf: Release module BTF IDR before module unload
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit 146bd2a87a65aa407bb17fac70d8d583d19aba06 ]
Gregory reported in [0] that the global_map_resize test when run in repeatedly ends up failing during program load. This stems from the fact that BTF reference has not dropped to zero after the previous run's module is unloaded, and the older module's BTF is still discoverable and visible. Later, in libbpf, load_module_btfs() will find the ID for this stale BTF, open its fd, and then it will be used during program load where later steps taking module reference using btf_try_get_module() fail since the underlying module for the BTF is gone.
Logically, once a module is unloaded, it's associated BTF artifacts should become hidden. The BTF object inside the kernel may still remain alive as long its reference counts are alive, but it should no longer be discoverable.
To fix this, let us call btf_free_id() from the MODULE_STATE_GOING case for the module unload to free the BTF associated IDR entry, and disable its discovery once module unload returns to user space. If a race happens during unload, the outcome is non-deterministic anyway. However, user space should be able to rely on the guarantee that once it has synchronously established a successful module unload, no more stale artifacts associated with this module can be obtained subsequently.
Note that we must be careful to not invoke btf_free_id() in btf_put() when btf_is_module() is true now. There could be a window where the module unload drops a non-terminal reference, frees the IDR, but the same ID gets reused and the second unconditional btf_free_id() ends up releasing an unrelated entry.
To avoid a special case for btf_is_module() case, set btf->id to zero to make btf_free_id() idempotent, such that we can unconditionally invoke it from btf_put(), and also from the MODULE_STATE_GOING case. Since zero is an invalid IDR, the idr_remove() should be a noop.
Note that we can be sure that by the time we reach final btf_put() for btf_is_module() case, the btf_free_id() is already done, since the module itself holds the BTF reference, and it will call this function for the BTF before dropping its own reference.
[0]: https://lore.kernel.org/bpf/[email protected]
--- kernel/bpf/btf.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
kernel/bpf/btf.c +20 -4
@@ -1501,7 +1501,16 @@ static void btf_free_id(struct btf *btf)* of the _bh() version. */ spin_lock_irqsave (&btf_idr_lock, flags); -idr_remove (&btf_idr, btf->id); +if (btf->id) { +idr_remove (&btf_idr, btf->id); +/* +* Clear the id here to make this function idempotent, since it will get +* called a couple of times for module BTFs: on module unload, and then +* the final btf_put(). btf_alloc_id() starts IDs with 1, so we can use +* 0 as sentinel value. +*/ +WRITE_ONCE (btf->id,0 ); + }spin_unlock_irqrestore (&btf_idr_lock, flags); }
@@ -5890,7 +5899,7 @@ static void bpf_btf_show_fdinfo(struct seq_file *m, struct file *filp) {const struct btf *btf = filp->private_data; -seq_printf (m,"btf_id:\t%u\n" , btf->id); +seq_printf (m,"btf_id:\t%u\n" ,READ_ONCE (btf->id)); }#endif
@@ -5985,7 +5994,7 @@ int btf_get_info_by_fd(const struct btf *btf,if (copy_from_user (&info, uinfo, info_copy))return -EFAULT ; - info.id = btf->id; + info.id =READ_ONCE (btf->id); ubtf =u64_to_user_ptr (info.btf); btf_copy =min_t (u32, btf->data_size, info.btf_size);if (copy_to_user (ubtf, btf->data, btf_copy))
@@ -6048,7 +6057,7 @@ int btf_get_fd_by_id(u32 id)u32 btf_obj_id (const struct btf *btf) { -return btf->id; +return READ_ONCE (btf->id); }bool btf_is_kernel (const struct btf *btf)
@@ -6185,6 +6194,13 @@ static int btf_module_notify(struct notifier_block *nb, unsigned long op,if (btf_mod->module != module)continue ; +/* +* For modules, we do the freeing of BTF IDR as soon as +* module goes away to disable BTF discovery, since the +* btf_try_get_module() on such BTFs will fail. This may +* be called again on btf_put(), but it's ok to do so. +*/ +btf_free_id (btf_mod->btf);list_del (&btf_mod->list);if (btf_mod->sysfs_attr)sysfs_remove_bin_file (btf_kobj, btf_mod->sysfs_attr);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 297/570 HID: asus: avoid memory leak in asus_report_fixup()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Günther Noack <[email protected]>
[ Upstream commit 2bad24c17742fc88973d6aea526ce1353f5334a3 ]
The asus_report_fixup() function was returning a newly allocated kmemdup()-allocated buffer, but never freeing it. Switch to devm_kzalloc() to ensure the memory is managed and freed automatically when the device is removed.
The caller of report_fixup() does not take ownership of the returned pointer, but it is permitted to return a pointer whose lifetime is at least that of the input buffer.
Also fix a harmless out-of-bounds read by copying only the original descriptor size.
--- drivers/hid/hid-asus.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/hid/hid-asus.c +11 -4
@@ -1224,14 +1224,21 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,*/ if (*rsize == rsize_orig && rdesc[offs] ==0x09 && rdesc[offs +1 ] ==0x76 ) { - *rsize = rsize_orig +1 ; - rdesc =kmemdup (rdesc, *rsize,GFP_KERNEL ); -if (!rdesc) -return NULL ; +__u8 *new_rdesc; + + new_rdesc =devm_kzalloc (&hdev->dev, rsize_orig +1 , +GFP_KERNEL ); +if (!new_rdesc) +return rdesc;hid_info (hdev,"Fixing up %s keyb report descriptor\n" , drvdata->quirks &QUIRK_T100CHI ?"T100CHI" :"T90CHI" ); + +memcpy (new_rdesc, rdesc, rsize_orig); + *rsize = rsize_orig +1 ; + rdesc = new_rdesc; +memmove (rdesc + offs +4 , rdesc + offs +2 ,12 ); rdesc[offs] =0x19 ; rdesc[offs +1 ] =0x00 ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 298/570 platform/x86: intel-hid: Add Dell 14 Plus 2-in-1 to dmi_vgbs_allow_list
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Metz <[email protected]>
[ Upstream commit 6b3fa0615cd8432148581de62a52f83847af3d70 ]
The Dell 14 Plus 2-in-1 (model DB04250) requires the VGBS allow list entry to correctly enable the tablet mode switch. Without this, the chassis state is not reported, and the hinge rotation only emits unknown scancodes.
Verified on Dell 14 Plus 2-in-1 DB04250.
--- drivers/platform/x86/intel/hid.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/platform/x86/intel/hid.c +6 -0
@@ -156,6 +156,12 @@ static const struct dmi_system_id dmi_vgbs_allow_list[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Dell Pro Rugged 12 Tablet RA02260"), }, }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell 14 Plus 2-in-1 DB04250"), + }, + }, { } };
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 299/570 nvme-pci: cap queue creation to used queues
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit 4735b510a00fb2d4ac9e8d21a8c9552cb281f585 ]
If the user reduces the special queue count at runtime and resets the controller, we need to reduce the number of queues and interrupts requested accordingly rather than start with the pre-allocated queue count.
--- drivers/nvme/host/pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/nvme/host/pci.c +7 -1
@@ -2306,7 +2306,13 @@ static int nvme_setup_io_queues(struct nvme_dev *dev) dev->nr_write_queues = write_queues; dev->nr_poll_queues = poll_queues; - nr_io_queues = dev->nr_allocated_queues -1 ; +/* +* The initial number of allocated queue slots may be too large if the +* user reduced the special queue parameters. Cap the value to the +* number we need for this round. +*/ + nr_io_queues =min (nvme_max_io_queues (dev), + dev->nr_allocated_queues -1 ); result =nvme_set_queue_count (&dev->ctrl, &nr_io_queues);if (result <0 )return result;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 300/570 platform/x86: intel-hid: Enable 5-button array on ThinkPad X1 Fold 16 Gen 1
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leif Skunberg <[email protected]>
[ Upstream commit b38d478dad79e61e8a65931021bdfd7a71741212 ]
The Lenovo ThinkPad X1 Fold 16 Gen 1 has physical volume up/down buttons that are handled through the intel-hid 5-button array interface. The firmware does not advertise 5-button array support via HEBC, so the driver relies on a DMI allowlist to enable it.
Add the ThinkPad X1 Fold 16 Gen 1 to the button_array_table so the volume buttons work out of the box.
--- drivers/platform/x86/intel/hid.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/platform/x86/intel/hid.c +7 -0
@@ -102,6 +102,13 @@ static const struct dmi_system_id button_array_table[] = { DMI_MATCH(DMI_PRODUCT_FAMILY, "ThinkPad X1 Tablet Gen 2"), }, }, + { + .ident = "Lenovo ThinkPad X1 Fold 16 Gen 1", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), + DMI_MATCH(DMI_PRODUCT_FAMILY, "ThinkPad X1 Fold 16 Gen 1"), + }, + }, { .ident ="Microsoft Surface Go 3" , .matches = {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 301/570 platform/x86: touchscreen_dmi: Add quirk for y-inverted Goodix touchscreen on SUPI S10
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 7d87ed70fc95482c12edf9493c249b6413be485e ]
The touchscreen on the SUPI S10 tablet reports inverted Y coordinates, causing touch input to be mirrored vertically relative to the display.
Add a quirk to set the "touchscreen-inverted-y" boolean device-property on the touchscreen device, so that the goodix_ts driver will fixup the coordinates.
--- drivers/platform/x86/touchscreen_dmi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/platform/x86/touchscreen_dmi.c +18 -0
@@ -402,6 +402,16 @@ static const struct ts_dmi_data gdix1002_00_upside_down_data = { .properties = gdix1001_upside_down_props, }; +static const struct property_entry gdix1001_y_inverted_props[] = { +PROPERTY_ENTRY_BOOL ("touchscreen-inverted-y" ), + { } +}; + +static const struct ts_dmi_data gdix1001_y_inverted_data = { + .acpi_name ="GDIX1001" , + .properties = gdix1001_y_inverted_props, +}; +static const struct property_entry gp_electronic_t701_props[] = {PROPERTY_ENTRY_U32 ("touchscreen-size-x" ,960 ),PROPERTY_ENTRY_U32 ("touchscreen-size-y" ,640 ),
@@ -1631,6 +1641,14 @@ const struct dmi_system_id touchscreen_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_SKU, "PN20170413488"), }, }, + { +/* SUPI S10 */ + .driver_data = (void *)&gdix1001_y_inverted_data, + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"SUPI" ), + DMI_MATCH(DMI_PRODUCT_NAME, "S10"), + }, + }, {/* Techbite Arc 11.6 */ .driver_data = (void *)&techbite_arc_11_6_data,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 302/570 nvme-pci: ensure were polling a polled queue
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit 166e31d7dbf6aa44829b98aa446bda5c9580f12a ]
A user can change the polled queue count at run time. There's a brief window during a reset where a hipri task may try to poll that queue before the block layer has updated the queue maps, which would race with the now interrupt driven queue and may cause double completions.
--- drivers/nvme/host/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/pci.c +2 -1
@@ -1096,7 +1096,8 @@ static int nvme_poll(struct blk_mq_hw_ctx *hctx)struct nvme_queue *nvmeq = hctx->driver_data;bool found; -if (!nvme_cqe_pending (nvmeq)) +if (!test_bit (NVMEQ_POLLED , &nvmeq->flags) || + !nvme_cqe_pending (nvmeq))return 0 ;spin_lock (&nvmeq->cq_poll_lock);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 303/570 HID: magicmouse: fix battery reporting for Apple Magic Trackpad 2
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julius Lehmann <[email protected]>
[ Upstream commit 5f3518d77419255f8b12bb23c8ec22acbeb6bc5b ]
Battery reporting does not work for the Apple Magic Trackpad 2 if it is connected via USB. The current hid descriptor fixup code checks for a hid descriptor length of exactly 83 bytes. If the hid descriptor is larger, which is the case for newer apple mice, the fixup is not applied.
This fix checks for hid descriptor sizes greater/equal 83 bytes which applies the fixup for newer devices as well.
--- drivers/hid/hid-magicmouse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-magicmouse.c +1 -1
@@ -930,7 +930,7 @@ static __u8 *magicmouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,*/ if ((is_usb_magicmouse2 (hdev->vendor, hdev->product) ||is_usb_magictrackpad2 (hdev->vendor, hdev->product)) && - *rsize ==83 && rdesc[46 ] ==0x84 && rdesc[58 ] ==0x85 ) { + *rsize >=83 && rdesc[46 ] ==0x84 && rdesc[58 ] ==0x85 ) {hid_info (hdev,"fixing up magicmouse battery report descriptor\n" ); *rsize = *rsize -1 ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 304/570 HID: magicmouse: avoid memory leak in magicmouse_report_fixup()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Günther Noack <[email protected]>
[ Upstream commit 91e8c6e601bdc1ccdf886479b6513c01c7e51c2c ]
The magicmouse_report_fixup() function was returning a newly kmemdup()-allocated buffer, but never freeing it.
The caller of report_fixup() does not take ownership of the returned pointer, but it *is* permitted to return a sub-portion of the input rdesc, whose lifetime is managed by the caller.
--- drivers/hid/hid-magicmouse.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/hid/hid-magicmouse.c +1 -3
@@ -934,9 +934,7 @@ static __u8 *magicmouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,hid_info (hdev,"fixing up magicmouse battery report descriptor\n" ); *rsize = *rsize -1 ; - rdesc =kmemdup (rdesc +1 , *rsize,GFP_KERNEL ); -if (!rdesc) -return NULL ; + rdesc = rdesc +1 ; rdesc[0 ] =0x05 ; rdesc[1 ] =0x01 ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 305/570 net: usb: r8152: add TRENDnet TUC-ET2G
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Valentin Spreckels <[email protected]>
[ Upstream commit 15fba71533bcdfaa8eeba69a5a5a2927afdf664a ]
The TRENDnet TUC-ET2G is a RTL8156 based usb ethernet adapter. Add its vendor and product IDs.
--- drivers/net/usb/r8152.c | 1 + include/linux/usb/r8152.h | 1 + 2 files changed, 2 insertions(+)
drivers/net/usb/r8152.c +1 -0
@@ -9857,6 +9857,7 @@ static const struct usb_device_id rtl8152_table[] = { { USB_DEVICE(VENDOR_ID_DLINK, 0xb301) }, { USB_DEVICE(VENDOR_ID_DELL, 0xb097) }, { USB_DEVICE(VENDOR_ID_ASUS, 0x1976) }, + { USB_DEVICE(VENDOR_ID_TRENDNET, 0xe02b) }, {} };
include/linux/usb/r8152.h +1 -0
@@ -32,6 +32,7 @@#define VENDOR_ID_DLINK 0x2001#define VENDOR_ID_DELL 0x413c#define VENDOR_ID_ASUS 0x0b05 +#define VENDOR_ID_TRENDNET 0x20f4#if IS_REACHABLE (CONFIG_USB_RTL8152 )extern u8 rtl8152_get_version (struct usb_interface *intf);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 306/570 HID: mcp2221: cancel last I2C command on read error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Romain Sioen <[email protected]>
[ Upstream commit e31b556c0ba21f20c298aa61181b96541140b7b9 ]
When an I2C SMBus read operation fails, the MCP2221 internal state machine may not reset correctly, causing subsequent transactions to fail.
By adding a short delay and explicitly cancelling the last command, we ensure the device is ready for the next operation.
Fix an issue where i2cdetect was not able to detect all devices correctly on the bus.
--- drivers/hid/hid-mcp2221.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/hid-mcp2221.c +2 -0
@@ -319,6 +319,8 @@ static int mcp_i2c_smbus_read(struct mcp2221 *mcp,usleep_range (90 ,100 ); retries++; }else { +usleep_range (980 ,1000 ); +mcp_cancel_last_cmd (mcp);return ret; } }else {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 307/570 module: Fix kernel panic when a symbol st_shndx is out of bounds
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ihor Solodrai <[email protected]>
[ Upstream commit f9d69d5e7bde2295eb7488a56f094ac8f5383b92 ]
The module loader doesn't check for bounds of the ELF section index in simplify_symbols():
for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
const char *name = info->strtab + sym[i].st_name;
switch (sym[i].st_shndx) {
case SHN_COMMON:
[...]
default:
/* Divert to percpu allocation if a percpu var. */
if (sym[i].st_shndx == info->index.pcpu)
secbase = (unsigned long)mod_percpu(mod);
else
/** HERE --> **/ secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
sym[i].st_value += secbase;
break;
}
}A symbol with an out-of-bounds st_shndx value, for example 0xffff (known as SHN_XINDEX or SHN_HIRESERVE), may cause a kernel panic:
BUG: unable to handle page fault for address: ... RIP: 0010:simplify_symbols+0x2b2/0x480 ... Kernel panic - not syncing: Fatal exception
This can happen when module ELF is legitimately using SHN_XINDEX or when it is corrupted.
Add a bounds check in simplify_symbols() to validate that st_shndx is within the valid range before using it.
This issue was discovered due to a bug in llvm-objcopy, see relevant discussion for details [1].
[1] https://lore.kernel.org/linux-modules/[email protected]/
--- kernel/module.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/module.c +7 -0
@@ -2347,6 +2347,13 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)break ;default : +if (sym[i].st_shndx >= info->hdr->e_shnum) { +pr_err ("%s: Symbol %s has an invalid section index %u (max %u)\n" , + mod->name, name, sym[i].st_shndx, info->hdr->e_shnum -1 ); + ret = -ENOEXEC ; +break ; + } +/* Divert to percpu allocation if a percpu var. */ if (sym[i].st_shndx == info->index.pcpu) secbase = (unsigned long )mod_percpu (mod);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 308/570 ASoC: fsl_easrc: Fix event generation in fsl_easrc_iec958_set_reg()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit 31ddc62c1cd92e51b9db61d7954b85ae2ec224da ]
ALSA controls should return 1 if the value in the control changed but the control put operation fsl_easrc_set_reg() only returns 0 or a negative error code, causing ALSA to not generate any change events. Add a suitable check by using regmap_update_bits_check() with the underlying regmap, this is more clearly and simply correct than trying to verify that one of the generic ops is exactly equivalent to this one.
--- sound/soc/fsl/fsl_easrc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/fsl/fsl_easrc.c +6 -3
@@ -93,14 +93,17 @@ static int fsl_easrc_set_reg(struct snd_kcontrol *kcontrol,struct snd_soc_component *component =snd_kcontrol_chip (kcontrol);struct soc_mreg_control *mc = (struct soc_mreg_control *)kcontrol->private_value; +struct fsl_asrc *easrc =snd_soc_component_get_drvdata (component);unsigned int regval = ucontrol->value.integer.value[0 ]; +bool changed;int ret; - ret =snd_soc_component_write (component, mc->regbase, regval); -if (ret <0 ) + ret =regmap_update_bits_check (easrc->regmap, mc->regbase, +GENMASK (31 ,0 ), regval, &changed); +if (ret !=0 )return ret; -return 0 ; +return changed; }#define SOC_SINGLE_REG_RW (xname, xreg) \
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 309/570 ASoC: fsl_easrc: Fix event generation in fsl_easrc_iec958_put_bits()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit 54a86cf48eaa6d1ab5130d756b718775e81e1748 ]
ALSA controls should return 1 if the value in the control changed but the control put operation fsl_easrc_iec958_put_bits() unconditionally returns 0, causing ALSA to not generate any change events. This is detected by mixer-test with large numbers of messages in the form:
No event generated for Context 3 IEC958 CS5 Context 3 IEC958 CS5.0 orig 5224 read 5225, is_volatile 0
Add a suitable check.
--- sound/soc/fsl/fsl_easrc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/fsl/fsl_easrc.c +4 -1
@@ -52,10 +52,13 @@ static int fsl_easrc_iec958_put_bits(struct snd_kcontrol *kcontrol,struct soc_mreg_control *mc = (struct soc_mreg_control *)kcontrol->private_value;unsigned int regval = ucontrol->value.integer.value[0 ]; +int ret; + + ret = (easrc_priv->bps_iec958[mc->regbase] != regval); easrc_priv->bps_iec958[mc->regbase] = regval; -return 0 ; +return ret; } static int fsl_easrc_iec958_get_bits(struct snd_kcontrol *kcontrol,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 310/570 dma-buf: Include ioctl.h in UAPI header
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Isaac J. Manjarres <[email protected]>
[ Upstream commit a116bac87118903925108e57781bbfc7a7eea27b ]
include/uapi/linux/dma-buf.h uses several macros from ioctl.h to define its ioctl commands. However, it does not include ioctl.h itself. So, if userspace source code tries to include the dma-buf.h file without including ioctl.h, it can result in build failures.
Therefore, include ioctl.h in the dma-buf UAPI header.
--- include/uapi/linux/dma-buf.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/dma-buf.h +1 -0
@@ -20,6 +20,7 @@#ifndef _DMA_BUF_UAPI_H_#define _DMA_BUF_UAPI_H_ +#include <linux/ioctl.h> #include <linux/types.h> /**
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 311/570 ALSA: hda/realtek: Add headset jack quirk for Thinkpad X390
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uzair Mughal <[email protected]>
[ Upstream commit 542127f6528ca7cc3cf61e1651d6ccb58495f953 ]
The Lenovo ThinkPad X390 (ALC257 codec, subsystem ID 0x17aa2288) does not report headset button press events. Headphone insertion is detected (SW_HEADPHONE_INSERT), but pressing the inline microphone button on a headset produces no input events.
Add a SND_PCI_QUIRK entry that maps this subsystem ID to ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK, which enables headset jack button detection through alc_fixup_headset_jack() and ThinkPad ACPI integration. This is the same fixup used by similar ThinkPad models (P1 Gen 3, X1 Extreme Gen 3).
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9608,6 +9608,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x224c ,"Thinkpad" ,ALC298_FIXUP_TPT470_DOCK ),SND_PCI_QUIRK (0x17aa ,0x224d ,"Thinkpad" ,ALC298_FIXUP_TPT470_DOCK ),SND_PCI_QUIRK (0x17aa ,0x225d ,"Thinkpad T480" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ), +SND_PCI_QUIRK (0x17aa ,0x2288 ,"Thinkpad X390" ,ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK ),SND_PCI_QUIRK (0x17aa ,0x2292 ,"Thinkpad X1 Carbon 7th" ,ALC285_FIXUP_THINKPAD_HEADSET_JACK ),SND_PCI_QUIRK (0x17aa ,0x22be ,"Thinkpad X1 Carbon 8th" ,ALC285_FIXUP_THINKPAD_HEADSET_JACK ), SND_PCI_QUIRK(0x17aa, 0x22c1, "Thinkpad P1 Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK),
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 312/570 xfrm: call xdo_dev_state_delete during state update
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 7d2fc41f91bc69acb6e01b0fa23cd7d0109a6a23 ]
When we update an SA, we construct a new state and call xdo_dev_state_add, but never insert it. The existing state is updated, then we immediately destroy the new state. Since we haven't added it, we don't go through the standard state delete code, and we're skipping removing it from the device (but xdo_dev_state_free will get called when we destroy the temporary state).
This is similar to commit c5d4d7d83165 ("xfrm: Fix deletion of offloaded SAs on failure.").
--- net/xfrm/xfrm_state.c | 1 + 1 file changed, 1 insertion(+)
net/xfrm/xfrm_state.c +1 -0
@@ -1770,6 +1770,7 @@ int xfrm_state_update(struct xfrm_state *x) err =0 ; x->km.state =XFRM_STATE_DEAD ; +xfrm_dev_state_delete (x);__xfrm_state_put (x); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 313/570 xfrm: Fix the usage of skb->sk
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steffen Klassert <[email protected]>
[ Upstream commit 1620c88887b16940e00dbe57dd38c74eda9bad9e ]
xfrm assumed to always have a full socket at skb->sk. This is not always true, so fix it by converting to a full socket before it is used.
Stable-dep-of: 0c0eef8ccd24 ("esp: fix skb leak with espintcp and async crypto")
--- net/ipv4/esp4.c | 2 +- net/ipv6/esp6.c | 2 +- net/ipv6/xfrm6_output.c | 4 ++-- net/xfrm/xfrm_interface_core.c | 2 +- net/xfrm/xfrm_output.c | 7 ++++--- net/xfrm/xfrm_policy.c | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-)
net/ipv4/esp4.c +1 -1
@@ -278,7 +278,7 @@ static void esp_output_done(struct crypto_async_request *base, int err) x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP)esp_output_tail_tcp (x, skb); else - xfrm_output_resume(skb->sk, skb, err); +xfrm_output_resume (skb_to_full_sk (skb ),skb ,err ); } }
net/ipv6/esp6.c +1 -1
@@ -315,7 +315,7 @@ static void esp_output_done(struct crypto_async_request *base, int err) x->encap && x->encap->encap_type == TCP_ENCAP_ESPINTCP)esp_output_tail_tcp (x, skb); else - xfrm_output_resume(skb->sk, skb, err); +xfrm_output_resume (skb_to_full_sk (skb ),skb ,err ); } }
net/ipv6/xfrm6_output.c +2 -2
@@ -82,14 +82,14 @@ static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb) toobig = skb->len > mtu && !skb_is_gso (skb); -if (toobig &&xfrm6_local_dontfrag (skb->sk)) { +if (toobig &&xfrm6_local_dontfrag (sk)) {xfrm6_local_rxpmtu (skb, mtu);kfree_skb (skb);return -EMSGSIZE ; }else if (toobig &&xfrm6_noneed_fragment (skb)) { skb->ignore_df =1 ; goto skip_frag; - }else if (!skb->ignore_df && toobig && skb->sk) { + }else if (!skb->ignore_df && toobig && sk) {xfrm_local_error (skb, mtu);kfree_skb (skb);return -EMSGSIZE ;
net/xfrm/xfrm_interface_core.c +1 -1
@@ -369,7 +369,7 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)skb_dst_set (skb, dst); skb->dev = tdev; - err =dst_output (xi->net, skb->sk, skb); + err =dst_output (xi->net,skb_to_full_sk (skb), skb);if (net_xmit_eval (err) ==0 ) {dev_sw_netstats_tx_add (dev,1 , length); }else {
net/xfrm/xfrm_output.c +4 -3
@@ -781,7 +781,7 @@ static int xfrm4_tunnel_check_size(struct sk_buff *skb) !skb_gso_validate_network_len(skb, ip_skb_dst_mtu(skb->sk, skb)))) { skb->protocol =htons (ETH_P_IP ); -if (skb->sk) +if (skb->sk &&sk_fullsock (skb->sk))xfrm_local_error (skb, mtu);else icmp_send(skb, ICMP_DEST_UNREACH,
@@ -817,6 +817,7 @@ static int xfrm6_tunnel_check_size(struct sk_buff *skb) {int mtu, ret =0 ;struct dst_entry *dst =skb_dst (skb); +struct sock *sk =skb_to_full_sk (skb);if (skb->ignore_df) goto out;
@@ -831,9 +832,9 @@ static int xfrm6_tunnel_check_size(struct sk_buff *skb) skb->dev = dst->dev; skb->protocol =htons (ETH_P_IPV6 ); -if (xfrm6_local_dontfrag (skb->sk)) +if (xfrm6_local_dontfrag (sk)) ipv6_stub->xfrm6_local_rxpmtu (skb, mtu); -else if (skb->sk) +else if (sk)xfrm_local_error (skb, mtu);else icmpv6_send (skb,ICMPV6_PKT_TOOBIG ,0 , mtu);
net/xfrm/xfrm_policy.c +1 -1
@@ -2856,7 +2856,7 @@ static void xfrm_policy_queue_process(struct timer_list *t)skb_dst_drop (skb);skb_dst_set (skb, dst); -dst_output (net, skb->sk, skb); +dst_output (net,skb_to_full_sk (skb), skb); } out:
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 314/570 esp: fix skb leak with espintcp and async crypto
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 0c0eef8ccd2413b0a10eb6bbd3442333b1e64dd2 ]
When the TX queue for espintcp is full, esp_output_tail_tcp will return an error and not free the skb, because with synchronous crypto, the common xfrm output code will drop the packet for us.
With async crypto (esp_output_done), we need to drop the skb when esp_output_tail_tcp returns an error.
--- net/ipv4/esp4.c | 9 ++++++--- net/ipv6/esp6.c | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-)
net/ipv4/esp4.c +6 -3
@@ -275,10 +275,13 @@ static void esp_output_done(struct crypto_async_request *base, int err)xfrm_dev_resume (skb); }else {if (!err && - x->encap && x->encap->encap_type ==TCP_ENCAP_ESPINTCP ) -esp_output_tail_tcp (x, skb); -else + x->encap && x->encap->encap_type ==TCP_ENCAP_ESPINTCP ) { + err =esp_output_tail_tcp (x, skb); +if (err != -EINPROGRESS ) +kfree_skb (skb); + }else {xfrm_output_resume (skb_to_full_sk (skb), skb, err); + } } }
net/ipv6/esp6.c +6 -3
@@ -312,10 +312,13 @@ static void esp_output_done(struct crypto_async_request *base, int err)xfrm_dev_resume (skb); }else {if (!err && - x->encap && x->encap->encap_type ==TCP_ENCAP_ESPINTCP ) -esp_output_tail_tcp (x, skb); -else + x->encap && x->encap->encap_type ==TCP_ENCAP_ESPINTCP ) { + err =esp_output_tail_tcp (x, skb); +if (err != -EINPROGRESS ) +kfree_skb (skb); + }else {xfrm_output_resume (skb_to_full_sk (skb), skb, err); + } } }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 315/570 af_key: validate families in pfkey_send_migrate()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit eb2d16a7d599dc9d4df391b5e660df9949963786 ]
syzbot was able to trigger a crash in skb_put() [1]
Issue is that pfkey_send_migrate() does not check old/new families, and that set_ipsecrequest() @family argument was truncated, thus possibly overfilling the skb.
Validate families early, do not wait set_ipsecrequest().
[1]
skbuff: skb_over_panic: text:ffffffff8a752120 len:392 put:16 head:ffff88802a4ad040 data:ffff88802a4ad040 tail:0x188 end:0x180 dev:<NULL>
kernel BUG at net/core/skbuff.c:214 !
Call Trace: <TASK> skb_over_panic net/core/skbuff.c:219 [inline] skb_put+0x159/0x210 net/core/skbuff.c:2655 skb_put_zero include/linux/skbuff.h:2788 [inline] set_ipsecrequest net/key/af_key.c:3532 [inline] pfkey_send_migrate+0x1270/0x2e50 net/key/af_key.c:3636 km_migrate+0x155/0x260 net/xfrm/xfrm_state.c:2848 xfrm_migrate+0x2140/0x2450 net/xfrm/xfrm_policy.c:4705 xfrm_do_migrate+0x8ff/0xaa0 net/xfrm/xfrm_user.c:3150
--- net/key/af_key.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
net/key/af_key.c +12 -7
@@ -3518,7 +3518,7 @@ static int set_sadb_kmaddress(struct sk_buff *skb, const struct xfrm_kmaddress *static int set_ipsecrequest (struct sk_buff *skb,uint8_t proto,uint8_t mode,int level, -uint32_t reqid,uint8_t family, +uint32_t reqid,sa_family_t family,const xfrm_address_t *src,const xfrm_address_t *dst) {struct sadb_x_ipsecrequest *rq;
@@ -3583,12 +3583,17 @@ static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,/* ipsecrequests */ for (i =0 , mp = m; i < num_bundles; i++, mp++) { -/* old locator pair */ - size_pol +=sizeof (struct sadb_x_ipsecrequest ) + -pfkey_sockaddr_pair_size (mp->old_family); -/* new locator pair */ - size_pol +=sizeof (struct sadb_x_ipsecrequest ) + -pfkey_sockaddr_pair_size (mp->new_family); +int pair_size; + + pair_size =pfkey_sockaddr_pair_size (mp->old_family); +if (!pair_size) +return -EINVAL ; + size_pol +=sizeof (struct sadb_x_ipsecrequest ) + pair_size; + + pair_size =pfkey_sockaddr_pair_size (mp->new_family); +if (!pair_size) +return -EINVAL ; + size_pol +=sizeof (struct sadb_x_ipsecrequest ) + pair_size; } size +=sizeof (struct sadb_msg ) + size_pol;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 316/570 can: statistics: add missing atomic access in hot path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Hartkopp <[email protected]>
[ Upstream commit 46eee1661aa9b49966e6c43d07126fe408edda57 ]
Commit 80b5f90158d1 ("can: statistics: use atomic access in hot path") fixed a KCSAN issue in can_receive() but missed to convert the 'matches' variable used in can_rcv_filter().
--- net/can/af_can.c | 4 ++-- net/can/af_can.h | 2 +- net/can/proc.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-)
net/can/af_can.c +2 -2
@@ -469,7 +469,7 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id, rcv->can_id = can_id; rcv->mask = mask; - rcv->matches =0 ; +atomic_long_set (&rcv->matches,0 ); rcv->func = func; rcv->data = data; rcv->ident = ident;
@@ -573,7 +573,7 @@ EXPORT_SYMBOL(can_rx_unregister);static inline void deliver (struct sk_buff *skb,struct receiver *rcv) { rcv->func (skb, rcv->data); - rcv->matches++; +atomic_long_inc (&rcv->matches); }static int can_rcv_filter (struct can_dev_rcv_lists *dev_rcv_lists,struct sk_buff *skb)
net/can/af_can.h +1 -1
@@ -52,7 +52,7 @@ struct receiver {struct hlist_node list;canid_t can_id;canid_t mask; -unsigned long matches; +atomic_long_t matches;void (*func)(struct sk_buff *skb,void *data);void *data;char *ident;
net/can/proc.c +2 -1
@@ -196,7 +196,8 @@ static void can_print_rcvlist(struct seq_file *m, struct hlist_head *rx_list," %-5s %03x %08x %pK %pK %8ld %s\n" ;seq_printf (m, fmt,DNAME (dev), r->can_id, r->mask, - r->func, r->data, r->matches, r->ident); + r->func, r->data,atomic_long_read (&r->matches), + r->ident); } }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 317/570 Bluetooth: L2CAP: Validate PDU length before reading SDU length in l2cap_ecred_data_rcv()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
[ Upstream commit c65bd945d1c08c3db756821b6bf9f1c4a77b29c6 ]
l2cap_ecred_data_rcv() reads the SDU length field from skb->data using get_unaligned_le16() without first verifying that skb contains at least L2CAP_SDULEN_SIZE (2) bytes. When skb->len is less than 2, this reads past the valid data in the skb.
The ERTM reassembly path correctly calls pskb_may_pull() before reading the SDU length (l2cap_reassemble_sdu, L2CAP_SAR_START case). Apply the same validation to the Enhanced Credit Based Flow Control data path.
--- net/bluetooth/l2cap_core.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bluetooth/l2cap_core.c +5 -0
@@ -7650,6 +7650,11 @@ static int l2cap_ecred_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)if (!chan->sdu) {u16 sdu_len; +if (!pskb_may_pull (skb,L2CAP_SDULEN_SIZE )) { + err = -EINVAL ; + goto failed; + } + sdu_len =get_unaligned_le16 (skb->data);skb_pull (skb,L2CAP_SDULEN_SIZE );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 318/570 Bluetooth: SCO: Fix use-after-free in sco_recv_frame() due to missing sock_hold
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
[ Upstream commit 598dbba9919c5e36c54fe1709b557d64120cb94b ]
sco_recv_frame() reads conn->sk under sco_conn_lock() but immediately releases the lock without holding a reference to the socket. A concurrent close() can free the socket between the lock release and the subsequent sk->sk_state access, resulting in a use-after-free.
Other functions in the same file (sco_sock_timeout(), sco_conn_del()) correctly use sco_sock_hold() to safely hold a reference under the lock.
Fix by using sco_sock_hold() to take a reference before releasing the lock, and adding sock_put() on all exit paths.
--- net/bluetooth/sco.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
net/bluetooth/sco.c +7 -3
@@ -311,7 +311,7 @@ static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb)struct sock *sk;sco_conn_lock (conn); - sk = conn->sk; + sk =sco_sock_hold (conn);sco_conn_unlock (conn);if (!sk)
@@ -320,11 +320,15 @@ static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb)BT_DBG ("sk %p len %u" , sk, skb->len);if (sk->sk_state !=BT_CONNECTED ) - goto drop; + goto drop_put; -if (!sock_queue_rcv_skb (sk, skb)) +if (!sock_queue_rcv_skb (sk, skb)) { +sock_put (sk);return ; + } +drop_put: +sock_put (sk); drop:kfree_skb (skb); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 319/570 Bluetooth: hci_ll: Fix firmware leak on error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anas Iqbal <[email protected]>
[ Upstream commit 31148a7be723aa9f2e8fbd62424825ab8d577973 ]
Smatch reports:
drivers/bluetooth/hci_ll.c:587 download_firmware() warn:
'fw' from request_firmware() not released on lines: 544.
In download_firmware(), if request_firmware() succeeds but the returned firmware content is invalid (no data or zero size), the function returns without releasing the firmware, resulting in a resource leak.
Fix this by calling release_firmware() before returning when request_firmware() succeeded but the firmware content is invalid.
--- drivers/bluetooth/hci_ll.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/hci_ll.c +2 -0
@@ -541,6 +541,8 @@ static int download_firmware(struct ll_device *lldev)if (err || !fw->data || !fw->size) {bt_dev_err (lldev->hu.hdev,"request_firmware failed(errno %d) for %s" , err, bts_scr_name); +if (!err) +release_firmware (fw);return -EINVAL ; } ptr = (void *)fw->data;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 320/570 Bluetooth: L2CAP: Fix null-ptr-deref on l2cap_sock_ready_cb
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helen Koike <[email protected]>
[ Upstream commit b6552e0503973daf6f23bd6ed9273ef131ee364f ]
Before using sk pointer, check if it is null.
Fix the following:
KASAN: null-ptr-deref in range [0x0000000000000260-0x0000000000000267] CPU: 0 UID: 0 PID: 5985 Comm: kworker/0:5 Not tainted 7.0.0-rc4-00029-ga989fde763f4 #1 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.17.0-9.fc43 06/10/2025 Workqueue: events l2cap_info_timeout RIP: 0010:kasan_byte_accessible+0x12/0x30 Code: 79 ff ff ff 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 40 d6 48 c1 ef 03 48 b8 00 00 00 00 00 fc ff df <0f> b6 04 07 3c 08 0f 92 c0 c3 cc cce veth0_macvtap: entered promiscuous mode RSP: 0018:ffffc90006e0f808 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: ffffffff89746018 RCX: 0000000080000001 RDX: 0000000000000000 RSI: ffffffff89746018 RDI: 000000000000004c RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000 R10: dffffc0000000000 R11: ffffffff8aae3e70 R12: 0000000000000000 R13: 0000000000000260 R14: 0000000000000260 R15: 0000000000000001 FS: 0000000000000000(0000) GS:ffff8880983c2000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00005582615a5008 CR3: 000000007007e000 CR4: 0000000000752ef0 PKRU: 55555554 Call Trace: <TASK> __kasan_check_byte+0x12/0x40 lock_acquire+0x79/0x2e0 lock_sock_nested+0x48/0x100 ? l2cap_sock_ready_cb+0x46/0x160 l2cap_sock_ready_cb+0x46/0x160 l2cap_conn_start+0x779/0xff0 ? __pfx_l2cap_conn_start+0x10/0x10 ? l2cap_info_timeout+0x60/0xa0 ? __pfx___mutex_lock+0x10/0x10 l2cap_info_timeout+0x68/0xa0 ? process_scheduled_works+0xa8d/0x18c0 process_scheduled_works+0xb6e/0x18c0 ? __pfx_process_scheduled_works+0x10/0x10 ? assign_work+0x3d5/0x5e0 worker_thread+0xa53/0xfc0 kthread+0x388/0x470 ? __pfx_worker_thread+0x10/0x10 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x51e/0xb90 ? __pfx_ret_from_fork+0x10/0x10 veth1_macvtap: entered promiscuous mode ? __switch_to+0xc7d/0x1450 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]--- batman_adv: batadv0: Interface activated: batadv_slave_0 batman_adv: batadv0: Interface activated: batadv_slave_1 netdevsim netdevsim7 netdevsim0: set [1, 0] type 2 family 0 port 6081 - 0 netdevsim netdevsim7 netdevsim1: set [1, 0] type 2 family 0 port 6081 - 0 netdevsim netdevsim7 netdevsim2: set [1, 0] type 2 family 0 port 6081 - 0 netdevsim netdevsim7 netdevsim3: set [1, 0] type 2 family 0 port 6081 - 0 RIP: 0010:kasan_byte_accessible+0x12/0x30 Code: 79 ff ff ff 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 40 d6 48 c1 ef 03 48 b8 00 00 00 00 00 fc ff df <0f> b6 04 07 3c 08 0f 92 c0 c3 cc cce ieee80211 phy39: Selected rate control algorithm 'minstrel_ht' RSP: 0018:ffffc90006e0f808 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: ffffffff89746018 RCX: 0000000080000001 RDX: 0000000000000000 RSI: ffffffff89746018 RDI: 000000000000004c RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000 R10: dffffc0000000000 R11: ffffffff8aae3e70 R12: 0000000000000000 R13: 0000000000000260 R14: 0000000000000260 R15: 0000000000000001 FS: 0000000000000000(0000) GS:ffff8880983c2000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f7e16139e9c CR3: 000000000e74e000 CR4: 0000000000752ef0 PKRU: 55555554 Kernel panic - not syncing: Fatal exception
--- net/bluetooth/l2cap_sock.c | 3 +++ 1 file changed, 3 insertions(+)
net/bluetooth/l2cap_sock.c +3 -0
@@ -1649,6 +1649,9 @@ static void l2cap_sock_ready_cb(struct l2cap_chan *chan)struct sock *sk = chan->data;struct sock *parent; +if (!sk) +return ; +lock_sock (sk); parent =bt_sk (sk)->parent;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 321/570 pinctrl: mediatek: common: Fix probe failure for devices without EINT
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Leonardo Scorcia <[email protected]>
[ Upstream commit 8f9f64c8f90dca07d3b9f1d7ce5d34ccd246c9dd ]
Some pinctrl devices like mt6397 or mt6392 don't support EINT at all, but the mtk_eint_init function is always called and returns -ENODEV, which then bubbles up and causes probe failure.
To address this only call mtk_eint_init if EINT pins are present.
Tested on Xiaomi Mi Smart Clock x04g (mt6392).
--- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +6 -3
@@ -1110,9 +1110,12 @@ int mtk_pctrl_init(struct platform_device *pdev, goto chip_error; } - ret =mtk_eint_init (pctl, pdev); -if (ret) - goto chip_error; +/* Only initialize EINT if we have EINT pins */ +if (data->eint_hw.ap_num >0 ) { + ret =mtk_eint_init (pctl, pdev); +if (ret) + goto chip_error; + }return 0 ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 322/570 ionic: fix persistent MAC address override on PF
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohammad Heib <[email protected]>
[ Upstream commit cbcb3cfcdc436d6f91a3d95ecfa9c831abe14aed ]
The use of IONIC_CMD_LIF_SETATTR in the MAC address update path causes the ionic firmware to update the LIF's identity in its persistent state. Since the firmware state is maintained across host warm boots and driver reloads, any MAC change on the Physical Function (PF) becomes "sticky.
This is problematic because it causes ethtool -P to report the user-configured MAC as the permanent factory address, which breaks system management tools that rely on a stable hardware identity.
While Virtual Functions (VFs) need this hardware-level programming to properly handle MAC assignments in guest environments, the PF should maintain standard transient behavior. This patch gates the ionic_program_mac call using is_virtfn so that PF MAC changes remain local to the netdev filters and do not overwrite the firmware's permanent identity block.
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +11 -6
@@ -1763,13 +1763,18 @@ static int ionic_set_mac_address(struct net_device *netdev, void *sa)if (ether_addr_equal (netdev->dev_addr, mac))return 0 ; - err =ionic_program_mac (lif, mac); -if (err <0 ) -return err; +/* Only program macs for virtual functions to avoid losing the permanent +* Mac across warm reset/reboot. +*/ +if (lif->ionic->pdev->is_virtfn) { + err =ionic_program_mac (lif, mac); +if (err <0 ) +return err; -if (err >0 ) -netdev_dbg (netdev,"%s: SET and GET ATTR Mac are not equal-due to old FW running\n" , - __func__); +if (err >0 ) +netdev_dbg (netdev,"%s: SET and GET ATTR Mac are not equal-due to old FW running\n" , + __func__); + } err =eth_prepare_mac_addr_change (netdev, addr);if (err)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 323/570 nfc: nci: fix circular locking dependency in nci_close_device
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 4527025d440ce84bf56e75ce1df2e84cb8178616 ]
nci_close_device() flushes rx_wq and tx_wq while holding req_lock. This causes a circular locking dependency because nci_rx_work() running on rx_wq can end up taking req_lock too:
nci_rx_work -> nci_rx_data_packet -> nci_data_exchange_complete
-> __sk_destruct -> rawsock_destruct -> nfc_deactivate_target
-> nci_deactivate_target -> nci_request -> mutex_lock(&ndev->req_lock)Move the flush of rx_wq after req_lock has been released. This should safe (I think) because NCI_UP has already been cleared and the transport is closed, so the work will see it and return -ENETDOWN.
NIPA has been hitting this running the nci selftest with a debug kernel on roughly 4% of the runs.
--- net/nfc/nci/core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/nfc/nci/core.c +6 -4
@@ -574,8 +574,7 @@ static int nci_close_device(struct nci_dev *ndev)skb_queue_purge (&ndev->rx_q);skb_queue_purge (&ndev->tx_q); -/* Flush RX and TX wq */ -flush_workqueue (ndev->rx_wq); +/* Flush TX wq, RX wq flush can't be under the lock */ flush_workqueue (ndev->tx_wq);/* Reset device */
@@ -587,13 +586,13 @@ static int nci_close_device(struct nci_dev *ndev) msecs_to_jiffies(NCI_RESET_TIMEOUT));/* After this point our queues are empty -* and no works are scheduled. +* rx work may be running but will see that NCI_UP was cleared */ ndev->ops->close (ndev);clear_bit (NCI_INIT , &ndev->flags); -/* Flush cmd wq */ +/* Flush cmd and tx wq */ flush_workqueue (ndev->cmd_wq);del_timer_sync (&ndev->cmd_timer);
@@ -603,6 +602,9 @@ static int nci_close_device(struct nci_dev *ndev)mutex_unlock (&ndev->req_lock); +/* rx_work may take req_lock via nci_deactivate_target */ +flush_workqueue (ndev->rx_wq); +return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 324/570 net: openvswitch: Avoid releasing netdev before teardown completes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 7c770dadfda5cbbde6aa3c4363ed513f1d212bf8 ]
The patch cited in the Fixes tag below changed the teardown code for OVS ports to no longer unconditionally take the RTNL. After this change, the netdev_destroy() callback can proceed immediately to the call_rcu() invocation if the IFF_OVS_DATAPATH flag is already cleared on the netdev.
The ovs_netdev_detach_dev() function clears the flag before completing the unregistration, and if it gets preempted after clearing the flag (as can happen on an -rt kernel), netdev_destroy() can complete and the device can be freed before the unregistration completes. This leads to a splat like:
[ 998.393867] Oops: general protection fault, probably for non-canonical address 0xff00000001000239: 0000 [#1] SMP PTI [ 998.393877] CPU: 42 UID: 0 PID: 55177 Comm: ip Kdump: loaded Not tainted 6.12.0-211.1.1.el10_2.x86_64+rt #1 PREEMPT_RT [ 998.393886] Hardware name: Dell Inc. PowerEdge R740/0JMK61, BIOS 2.24.0 03/27/2025 [ 998.393889] RIP: 0010:dev_set_promiscuity+0x8d/0xa0 [ 998.393901] Code: 00 00 75 d8 48 8b 53 08 48 83 ba b0 02 00 00 00 75 ca 48 83 c4 08 5b c3 cc cc cc cc 48 83 bf 48 09 00 00 00 75 91 48 8b 47 08 <48> 83 b8 b0 02 00 00 00 74 97 eb 81 0f 1f 80 00 00 00 00 90 90 90 [ 998.393906] RSP: 0018:ffffce5864a5f6a0 EFLAGS: 00010246 [ 998.393912] RAX: ff00000000ffff89 RBX: ffff894d0adf5a05 RCX: 0000000000000000 [ 998.393917] RDX: 0000000000000000 RSI: 00000000ffffffff RDI: ffff894d0adf5a05 [ 998.393921] RBP: ffff894d19252000 R08: ffff894d19252000 R09: 0000000000000000 [ 998.393924] R10: ffff894d19252000 R11: ffff894d192521b8 R12: 0000000000000006 [ 998.393927] R13: ffffce5864a5f738 R14: 00000000ffffffe2 R15: 0000000000000000 [ 998.393931] FS: 00007fad61971800(0000) GS:ffff894cc0140000(0000) knlGS:0000000000000000 [ 998.393936] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 998.393940] CR2: 000055df0a2a6e40 CR3: 000000011c7fe003 CR4: 00000000007726f0 [ 998.393944] PKRU: 55555554 [ 998.393946] Call Trace: [ 998.393949] <TASK> [ 998.393952] ? show_trace_log_lvl+0x1b0/0x2f0 [ 998.393961] ? show_trace_log_lvl+0x1b0/0x2f0 [ 998.393975] ? dp_device_event+0x41/0x80 [openvswitch] [ 998.394009] ? __die_body.cold+0x8/0x12 [ 998.394016] ? die_addr+0x3c/0x60 [ 998.394027] ? exc_general_protection+0x16d/0x390 [ 998.394042] ? asm_exc_general_protection+0x26/0x30 [ 998.394058] ? dev_set_promiscuity+0x8d/0xa0 [ 998.394066] ? ovs_netdev_detach_dev+0x3a/0x80 [openvswitch] [ 998.394092] dp_device_event+0x41/0x80 [openvswitch] [ 998.394102] notifier_call_chain+0x5a/0xd0 [ 998.394106] unregister_netdevice_many_notify+0x51b/0xa60 [ 998.394110] rtnl_dellink+0x169/0x3e0 [ 998.394121] ? rt_mutex_slowlock.constprop.0+0x95/0xd0 [ 998.394125] rtnetlink_rcv_msg+0x142/0x3f0 [ 998.394128] ? avc_has_perm_noaudit+0x69/0xf0 [ 998.394130] ? __pfx_rtnetlink_rcv_msg+0x10/0x10 [ 998.394132] netlink_rcv_skb+0x50/0x100 [ 998.394138] netlink_unicast+0x292/0x3f0 [ 998.394141] netlink_sendmsg+0x21b/0x470 [ 998.394145] ____sys_sendmsg+0x39d/0x3d0 [ 998.394149] ___sys_sendmsg+0x9a/0xe0 [ 998.394156] __sys_sendmsg+0x7a/0xd0 [ 998.394160] do_syscall_64+0x7f/0x170 [ 998.394162] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 998.394165] RIP: 0033:0x7fad61bf4724 [ 998.394188] Code: 89 02 b8 ff ff ff ff eb bb 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3 0f 1e fa 80 3d c5 e9 0c 00 00 74 13 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 48 83 ec 28 89 54 24 1c 48 89 [ 998.394189] RSP: 002b:00007ffd7e2f7cb8 EFLAGS: 00000202 ORIG_RAX: 000000000000002e [ 998.394191] RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007fad61bf4724 [ 998.394193] RDX: 0000000000000000 RSI: 00007ffd7e2f7d20 RDI: 0000000000000003 [ 998.394194] RBP: 00007ffd7e2f7d90 R08: 0000000000000010 R09: 000000000000003f [ 998.394195] R10: 000055df11558010 R11: 0000000000000202 R12: 00007ffd7e2f8380 [ 998.394196] R13: 0000000069b233d7 R14: 000055df0a256040 R15: 0000000000000000 [ 998.394200] </TASK>
To fix this, reorder the operations in ovs_netdev_detach_dev() to only clear the flag after completing the other operations, and introduce an smp_wmb() to make the ordering requirement explicit. The smp_wmb() is paired with a full smp_mb() in netdev_destroy() to make sure the call_rcu() invocation does not happen before the unregister operations are visible.
--- net/openvswitch/vport-netdev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/openvswitch/vport-netdev.c +8 -1
@@ -145,11 +145,15 @@ static void vport_netdev_free(struct rcu_head *rcu)void ovs_netdev_detach_dev (struct vport *vport) {ASSERT_RTNL (); - vport->dev->priv_flags &= ~IFF_OVS_DATAPATH ;netdev_rx_handler_unregister (vport->dev);netdev_upper_dev_unlink (vport->dev,netdev_master_upper_dev_get (vport->dev));dev_set_promiscuity (vport->dev,-1 ); + +/* paired with smp_mb() in netdev_destroy() */ +smp_wmb (); + + vport->dev->priv_flags &= ~IFF_OVS_DATAPATH ; }static void netdev_destroy (struct vport *vport)
@@ -168,6 +172,9 @@ static void netdev_destroy(struct vport *vport)rtnl_unlock (); } +/* paired with smp_wmb() in ovs_netdev_detach_dev() */ +smp_mb (); +call_rcu (&vport->rcu, vport_netdev_free); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 325/570 openvswitch: validate MPLS set/set_masked payload length
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Yang <[email protected]>
[ Upstream commit 546b68ac893595877ffbd7751e5c55fd1c43ede6 ]
validate_set() accepted OVS_KEY_ATTR_MPLS as variable-sized payload for SET/SET_MASKED actions. In action handling, OVS expects fixed-size MPLS key data (struct ovs_key_mpls).
Use the already normalized key_len (masked case included) and reject non-matching MPLS action key sizes.
Reject invalid MPLS action payload lengths early.
--- net/openvswitch/flow_netlink.c | 2 ++ 1 file changed, 2 insertions(+)
net/openvswitch/flow_netlink.c +2 -0
@@ -2908,6 +2908,8 @@ static int validate_set(const struct nlattr *a,case OVS_KEY_ATTR_MPLS :if (!eth_p_mpls (eth_type))return -EINVAL ; +if (key_len !=sizeof (struct ovs_key_mpls )) +return -EINVAL ;break ;case OVS_KEY_ATTR_SCTP :
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 326/570 net/smc: fix double-free of smc_spd_priv when tee() duplicates splice pipe buffer
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qi Tang <[email protected]>
[ Upstream commit 24dd586bb4cbba1889a50abe74143817a095c1c9 ]
smc_rx_splice() allocates one smc_spd_priv per pipe_buffer and stores the pointer in pipe_buffer.private. The pipe_buf_operations for these buffers used .get = generic_pipe_buf_get, which only increments the page reference count when tee(2) duplicates a pipe buffer. The smc_spd_priv pointer itself was not handled, so after tee() both the original and the cloned pipe_buffer share the same smc_spd_priv *.
When both pipes are subsequently released, smc_rx_pipe_buf_release() is called twice against the same object:
1st call: kfree(priv) sock_put(sk) smc_rx_update_cons() [correct] 2nd call: kfree(priv) sock_put(sk) smc_rx_update_cons() [UAF]
KASAN reports a slab-use-after-free in smc_rx_pipe_buf_release(), which then escalates to a NULL-pointer dereference and kernel panic via smc_rx_update_consumer() when it chases the freed priv->smc pointer:
BUG: KASAN: slab-use-after-free in smc_rx_pipe_buf_release+0x78/0x2a0 Read of size 8 at addr ffff888004a45740 by task smc_splice_tee_/74 Call Trace: <TASK> dump_stack_lvl+0x53/0x70 print_report+0xce/0x650 kasan_report+0xc6/0x100 smc_rx_pipe_buf_release+0x78/0x2a0 free_pipe_info+0xd4/0x130 pipe_release+0x142/0x160 __fput+0x1c6/0x490 __x64_sys_close+0x4f/0x90 do_syscall_64+0xa6/0x1a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> BUG: kernel NULL pointer dereference, address: 0000000000000020 RIP: 0010:smc_rx_update_consumer+0x8d/0x350 Call Trace: <TASK> smc_rx_pipe_buf_release+0x121/0x2a0 free_pipe_info+0xd4/0x130 pipe_release+0x142/0x160 __fput+0x1c6/0x490 __x64_sys_close+0x4f/0x90 do_syscall_64+0xa6/0x1a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> Kernel panic - not syncing: Fatal exception
Beyond the memory-safety problem, duplicating an SMC splice buffer is semantically questionable: smc_rx_update_cons() would advance the consumer cursor twice for the same data, corrupting receive-window accounting. A refcount on smc_spd_priv could fix the double-free, but the cursor-accounting issue would still need to be addressed separately.
The .get callback is invoked by both tee(2) and splice_pipe_to_pipe() for partial transfers; both will now return -EFAULT. Users who need to duplicate SMC socket data must use a copy-based read path.
--- net/smc/smc_rx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/smc/smc_rx.c +8 -1
@@ -130,9 +130,16 @@ static void smc_rx_pipe_buf_release(struct pipe_inode_info *pipe,sock_put (sk); } +static bool smc_rx_pipe_buf_get (struct pipe_inode_info *pipe, +struct pipe_buffer *buf) +{ +/* smc_spd_priv in buf->private is not shareable; disallow cloning. */ +return false; +} +static const struct pipe_buf_operations smc_pipe_ops = { .release = smc_rx_pipe_buf_release, - .get = generic_pipe_buf_get + .get = smc_rx_pipe_buf_get, }; static void smc_rx_spd_release(struct splice_pipe_desc *spd,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 327/570 rtnetlink: count IFLA_INFO_SLAVE_KIND in if_nlmsg_size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit ee00a12593ffb69db4dd1a1c00ecb0253376874a ]
rtnl_link_get_slave_info_data_size counts IFLA_INFO_SLAVE_DATA, but rtnl_link_slave_info_fill adds both IFLA_INFO_SLAVE_DATA and IFLA_INFO_SLAVE_KIND.
--- net/core/rtnetlink.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/core/rtnetlink.c +6 -3
@@ -532,11 +532,14 @@ static size_t rtnl_link_get_slave_info_data_size(const struct net_device *dev) goto out; ops = master_dev->rtnl_link_ops; -if (!ops || !ops->get_slave_size) +if (!ops) + goto out; + size +=nla_total_size (strlen (ops->kind) +1 );/* IFLA_INFO_SLAVE_KIND */ +if (!ops->get_slave_size) goto out;/* IFLA_INFO_SLAVE_DATA + nested data */ - size =nla_total_size (sizeof (struct nlattr )) + - ops->get_slave_size (master_dev, dev); + size +=nla_total_size (sizeof (struct nlattr )) + + ops->get_slave_size (master_dev, dev); out:rcu_read_unlock ();
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 328/570 platform/olpc: olpc-xo175-ec: Fix overflow error message to print inlen
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit 2061f7b042f88d372cca79615f8425f3564c0b40 ]
The command length check validates inlen (> 5), but the error message incorrectly printed resp_len. Print inlen so the log reflects the actual command length.
--- drivers/platform/olpc/olpc-xo175-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/olpc/olpc-xo175-ec.c +1 -1
@@ -482,7 +482,7 @@ static int olpc_xo175_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *resp,dev_dbg (dev,"CMD %x, %zd bytes expected\n" , cmd, resp_len);if (inlen >5 ) { -dev_err (dev,"command len %zd too big!\n" , resp_len); +dev_err (dev,"command len %zd too big!\n" , inlen);return -EOVERFLOW ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 329/570 net: fix fanout UAF in packet_release() via NETDEV_UP race
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yochai Eisenrich <[email protected]>
[ Upstream commit 42156f93d123436f2a27c468f18c966b7e5db796 ]
packet_release() has a race window where NETDEV_UP can re-register a socket into a fanout group's arr[] array. The re-registration is not cleaned up by fanout_release(), leaving a dangling pointer in the fanout array.packet_release() does NOT zero po->num in its bind_lock section. After releasing bind_lock, po->num is still non-zero and po->ifindex still matches the bound device. A concurrent packet_notifier(NETDEV_UP) that already found the socket in sklist can re-register the hook. For fanout sockets, this re-registration calls __fanout_link(sk, po) which adds the socket back into f->arr[] and increments f->num_members, but does NOT increment f->sk_ref.
The fix sets po->num to zero in packet_release while bind_lock is held to prevent NETDEV_UP from linking, preventing the race window.
This bug was found following an additional audit with Claude Code based on CVE-2025-38617.
--- net/packet/af_packet.c | 1 + 1 file changed, 1 insertion(+)
net/packet/af_packet.c +1 -0
@@ -3147,6 +3147,7 @@ static int packet_release(struct socket *sock)spin_lock (&po->bind_lock);unregister_prot_hook (sk, false); +WRITE_ONCE (po->num,0 );packet_cached_dev_reset (po);if (po->prot_hook.dev) {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 330/570 net: enetc: fix the output issue of ethtool --show-ring
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Fang <[email protected]>
[ Upstream commit 70b439bf06f6a12e491f827fa81a9887a11501f9 ]
Currently, enetc_get_ringparam() only provides rx_pending and tx_pending, but 'ethtool --show-ring' no longer displays these fields. Because the ringparam retrieval path has moved to the new netlink interface, where rings_fill_reply() emits the *x_pending only if the *x_max_pending values are non-zero. So rx_max_pending and tx_max_pending to are added to enetc_get_ringparam() to fix the issue.
Note that the maximum tx/rx ring size of hardware is 64K, but we haven't added set_ringparam() to make the ring size configurable. To avoid users mistakenly believing that the ring size can be increased, so set the *x_max_pending to priv->*x_bd_count.
--- drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +2 -0
@@ -566,6 +566,8 @@ static void enetc_get_ringparam(struct net_device *ndev, {struct enetc_ndev_priv *priv =netdev_priv (ndev); + ring->rx_max_pending = priv->rx_bd_count; + ring->tx_max_pending = priv->tx_bd_count; ring->rx_pending = priv->rx_bd_count; ring->tx_pending = priv->tx_bd_count;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 331/570 dma-mapping: add missing `inline` for `dma_free_attrs`
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miguel Ojeda <[email protected]>
[ Upstream commit 2cdaff22ed26f1e619aa2b43f27bb84f2c6ef8f8 ]
Under an UML build for an upcoming series [1], I got -Wstatic-in-inline for dma_free_attrs:
BINDGEN rust/bindings/bindings_generated.rs - due to target missing
In file included from rust/helpers/helpers.c:59:
rust/helpers/dma.c:17:2: warning: static function 'dma_free_attrs' is used in an inline function with external linkage [-Wstatic-in-inline]
17 | dma_free_attrs(dev, size, cpu_addr, dma_handle, attrs);
| ^
rust/helpers/dma.c:12:1: note: use 'static' to give inline function 'rust_helper_dma_free_attrs' internal linkage
12 | __rust_helper void rust_helper_dma_free_attrs(struct device *dev, size_t size,
| ^
| static
The issue is that dma_free_attrs was not marked inline when it was introduced alongside the rest of the stubs.
Thus mark it.
--- include/linux/dma-mapping.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/dma-mapping.h +2 -2
@@ -218,8 +218,8 @@ static inline void *dma_alloc_attrs(struct device *dev, size_t size, {return NULL ; } -static void dma_free_attrs (struct device *dev,size_t size,void *cpu_addr, -dma_addr_t dma_handle,unsigned long attrs) +static inline void dma_free_attrs (struct device *dev,size_t size, +void *cpu_addr,dma_addr_t dma_handle,unsigned long attrs) { } static inline void *dmam_alloc_attrs(struct device *dev, size_t size,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 332/570 Bluetooth: L2CAP: Fix ERTM re-init and zero pdu_len infinite loop
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
[ Upstream commit 25f420a0d4cfd61d3d23ec4b9c56d9f443d91377 ]
l2cap_config_req() processes CONFIG_REQ for channels in BT_CONNECTED state to support L2CAP reconfiguration (e.g. MTU changes). However, since both CONF_INPUT_DONE and CONF_OUTPUT_DONE are already set from the initial configuration, the reconfiguration path falls through to l2cap_ertm_init(), which re-initializes tx_q, srej_q, srej_list, and retrans_list without freeing the previous allocations and sets chan->sdu to NULL without freeing the existing skb. This leaks all previously allocated ERTM resources.
Additionally, l2cap_parse_conf_req() does not validate the minimum value of remote_mps derived from the RFC max_pdu_size option. A zero value propagates to l2cap_segment_sdu() where pdu_len becomes zero, causing the while loop to never terminate since len is never decremented, exhausting all available memory.
Fix the double-init by skipping l2cap_ertm_init() and l2cap_chan_ready() when the channel is already in BT_CONNECTED state, while still allowing the reconfiguration parameters to be updated through l2cap_parse_conf_req(). Also add a pdu_len zero check in l2cap_segment_sdu() as a safeguard.
--- net/bluetooth/l2cap_core.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
net/bluetooth/l2cap_core.c +12 -7
@@ -2541,6 +2541,9 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan,/* Remote device may have requested smaller PDUs */ pdu_len =min_t (size_t, pdu_len, chan->remote_mps); +if (!pdu_len) +return -EINVAL ; +if (len <= pdu_len) { sar =L2CAP_SAR_UNSEGMENTED ; sdu_len =0 ;
@@ -4515,14 +4518,16 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,if (test_bit (CONF_INPUT_DONE , &chan->conf_state)) {set_default_fcs (chan); -if (chan->mode ==L2CAP_MODE_ERTM || - chan->mode ==L2CAP_MODE_STREAMING ) - err =l2cap_ertm_init (chan); +if (chan->state !=BT_CONNECTED ) { +if (chan->mode ==L2CAP_MODE_ERTM || + chan->mode ==L2CAP_MODE_STREAMING ) + err =l2cap_ertm_init (chan); -if (err <0 ) -l2cap_send_disconn_req (chan, -err); -else -l2cap_chan_ready (chan); +if (err <0 ) +l2cap_send_disconn_req (chan, -err); +else +l2cap_chan_ready (chan); + } goto unlock; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 333/570 Bluetooth: btusb: clamp SCO altsetting table indices
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 129fa608b6ad08b8ab7178eeb2ec272c993aaccc ]
btusb_work() maps the number of active SCO links to USB alternate settings through a three-entry lookup table when CVSD traffic uses transparent voice settings. The lookup currently indexes alts[] with data->sco_num - 1 without first constraining sco_num to the number of available table entries.
While the table only defines alternate settings for up to three SCO links, data->sco_num comes from hci_conn_num() and is used directly. Cap the lookup to the last table entry before indexing it so the driver keeps selecting the highest supported alternate setting without reading past alts[].
--- drivers/bluetooth/btusb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bluetooth/btusb.c +4 -1
@@ -1845,8 +1845,11 @@ static void btusb_work(struct work_struct *work)if (data->air_mode ==HCI_NOTIFY_ENABLE_SCO_CVSD ) {if (hdev->voice_setting &0x0020 ) {static const int alts[3 ] = {2 ,4 ,5 }; +unsigned int sco_idx; - new_alts = alts[data->sco_num -1 ]; + sco_idx = min_t(unsigned int, data->sco_num - 1, +ARRAY_SIZE (alts) -1 ); + new_alts = alts[sco_idx]; }else { new_alts = data->sco_num; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 334/570 netfilter: nfnetlink_log: fix uninitialized padding leak in NFULA_PAYLOAD
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 52025ebaa29f4eb4ed8bf92ce83a68f24ab7fdf7 ]
__build_packet_message() manually constructs the NFULA_PAYLOAD netlink attribute using skb_put() and skb_copy_bits(), bypassing the standard nla_reserve()/nla_put() helpers. While nla_total_size(data_len) bytes are allocated (including NLA alignment padding), only data_len bytes of actual packet data are copied. The trailing nla_padlen(data_len) bytes (1-3 when data_len is not 4-byte aligned) are never initialized, leaking stale heap contents to userspace via the NFLOG netlink socket.
Replace the manual attribute construction with nla_reserve(), which handles the tailroom check, header setup, and padding zeroing via __nla_reserve(). The subsequent skb_copy_bits() fills in the payload data on top of the properly initialized attribute.
--- net/netfilter/nfnetlink_log.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
net/netfilter/nfnetlink_log.c +2 -6
@@ -636,15 +636,11 @@ __build_packet_message(struct nfnl_log_net *log,if (data_len) {struct nlattr *nla; -int size =nla_attr_size (data_len); -if (skb_tailroom (inst->skb) <nla_total_size (data_len)) + nla =nla_reserve (inst->skb,NFULA_PAYLOAD , data_len); +if (!nla) goto nla_put_failure; - nla =skb_put (inst->skb,nla_total_size (data_len)); - nla->nla_type =NFULA_PAYLOAD ; - nla->nla_len = size; -if (skb_copy_bits (skb,0 ,nla_data (nla), data_len))BUG (); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 335/570 netfilter: ip6t_rt: reject oversized addrnr in rt_mt6_check()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ren Wei <[email protected]>
[ Upstream commit 9d3f027327c2fa265f7f85ead41294792c3296ed ]
Reject rt match rules whose addrnr exceeds IP6T_RT_HOPS.
rt_mt6() expects addrnr to stay within the bounds of rtinfo->addrs[]. Validate addrnr during rule installation so malformed rules are rejected before the match logic can use an out-of-range value.
--- net/ipv6/netfilter/ip6t_rt.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv6/netfilter/ip6t_rt.c +4 -0
@@ -157,6 +157,10 @@ static int rt_mt6_check(const struct xt_mtchk_param *par)pr_debug ("unknown flags %X\n" , rtinfo->invflags);return -EINVAL ; } +if (rtinfo->addrnr >IP6T_RT_HOPS ) { +pr_debug ("too many addresses specified\n" ); +return -EINVAL ; + } if ((rtinfo->flags & (IP6T_RT_RES | IP6T_RT_FST_MASK)) && (!(rtinfo->flags & IP6T_RT_TYP) || (rtinfo->rt_type != 0) ||
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 336/570 netfilter: nf_conntrack_expect: skip expectations in other netns via proc
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 3db5647984de03d9cae0dcddb509b058351f0ee4 ]
Skip expectations that do not reside in this netns.
Similar to e77e6ff502ea ("netfilter: conntrack: do not dump other netns's conntrack entries via proc").
--- net/netfilter/nf_conntrack_expect.c | 4 ++++ 1 file changed, 4 insertions(+)
net/netfilter/nf_conntrack_expect.c +4 -0
@@ -627,11 +627,15 @@ static int exp_seq_show(struct seq_file *s, void *v) {struct nf_conntrack_expect *expect;struct nf_conntrack_helper *helper; +struct net *net =seq_file_net (s);struct hlist_node *n = v;char *delim ="" ; expect = hlist_entry(n, struct nf_conntrack_expect, hnode); +if (!net_eq (nf_ct_exp_net (expect), net)) +return 0 ; +if (expect->timeout.function)seq_printf (s,"%ld " ,timer_pending (&expect->timeout) ? (long )(expect->timeout.expires - jiffies)/HZ :0 );
Signature · 1 line
2.51.0
Re: [PATCH 5.15 336/570] netfilter: nf_conntrack_expect: skip expectations in other netns via proc
Hi,
Quoted 4 lines · Greg Kroah-Hartman
5.15-stable review patch. If anyone has any objections, please let me know.
------------------
Quoted 9 lines
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit
3db5647984de03d9cae0dcddb509b058351f0ee4]Skip expectations that do not reside in this netns.
Similar to
e77e6ff502ea("netfilter: conntrack: do not dump other netns's conntrack entries via proc").
AI assisted review spotted a probable issue: I have gone through the analysis and the summary is:
I think this fix relies on commit: 02a3231b6d82 ("netfilter: nf_conntrack_expect: store netns and zone in expectation")
This references commit explicitly states:
" This patch is required by the follow up fix not to dump expectations that do not belong
to this netns." which is this patch.
Also part of patch series 4 and 5: https://lore.kernel.org/all/[email protected]/
Given that we haven't taken 02a3231b6d82 ("netfilter: nf_conntrack_expect: store netns and zone in expectation") to 5.15.y should we drop this ?
Why ? Without it, the 5.15 backport still uses master-conntrack-derived context instead of expectation-owned stored netns/zone state
i.e Upstream has:
possible_net_t net;
static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp)
{
return read_pnet(&exp->net);
}Downstream has:
static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp)
{
return nf_ct_net(exp->master);
}I don't know the internals of this fully, but looks like we might not want to take this fix without 02a3231b6d82 ("netfilter: nf_conntrack_expect: store netns and zone in expectation")
Thanks,
Harshit
Quoted 28 lines
Fixes 9b03f38d0487 ("netfilter: netns nf_conntrack: per-netns expectations")Signed-off-by Florian Westphal <[email protected]>Signed-off-by Pablo Neira Ayuso <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- net/netfilter/nf_conntrack_expect.c | 4 ++++ 1 file changed, 4 insertions(+)net/netfilter/nf_conntrack_expect.c +4
-0@@ -627,11 +627,15 @@ static int exp_seq_show(struct seq_file *s, void *v) {struct nf_conntrack_expect *expect;struct nf_conntrack_helper *helper; +struct net *net =seq_file_net (s);struct hlist_node *n = v;char *delim ="" ; expect = hlist_entry(n, struct nf_conntrack_expect, hnode); +if (!net_eq (nf_ct_exp_net (expect), net)) +return 0 ; +if (expect->timeout.function)seq_printf (s,"%ld " ,timer_pending (&expect->timeout) ? (long )(expect->timeout.expires - jiffies)/HZ :0 );
Re: [PATCH 5.15 336/570] netfilter: nf_conntrack_expect: skip expectations in other netns via proc
Quoted 50 lines · Harshit Mogalapalli
Hi,
Quoted 4 lines · Greg Kroah-Hartman
5.15-stable review patch. If anyone has any objections, please let me know.
------------------
Quoted 9 lines
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit
3db5647984de03d9cae0dcddb509b058351f0ee4]Skip expectations that do not reside in this netns.
Similar to
e77e6ff502ea("netfilter: conntrack: do not dump other netns's conntrack entries via proc").AI assisted review spotted a probable issue: I have gone through the analysis and the summary is:
I think this fix relies on commit:
02a3231b6d82("netfilter:nf_conntrack_expect: store netns and zone in expectation")This references commit explicitly states:
" This patch is required by the follow up fix not to dump expectations that do not belong
to this netns." which is this patch.Also part of patch series 4 and 5:
https://lore.kernel.org/all/[email protected]/Given that we haven't taken
02a3231b6d82("netfilter:nf_conntrack_expect:
store netns and zone in expectation") to 5.15.y should we drop this ?Why ? Without it, the 5.15 backport still uses master-conntrack-derived context instead of expectation-owned stored netns/zone state
i.e Upstream has:
possible_net_tnet;static inline struct net *nf_ct_exp_net(struct
nf_conntrack_expect*exp){ return read_pnet(&exp->net); }Downstream has:
static inline struct net *nf_ct_exp_net(struct
nf_conntrack_expect*exp)
Quoted 8 lines
{ return nf_ct_net(exp->master); }I don't know the internals of this fully, but looks like we might not want to take this fix without
02a3231b6d82("netfilter:nf_conntrack_expect:
store netns and zone in expectation")
Yes:
02a3231b6d82 ("netfilter: nf_conntrack_expect: store netns and zone in expectation")
is good to have as a Stable-Dep.
Quoted 35 lines
Thanks,
HarshitQuoted 26 lines
Fixes 9b03f38d0487 ("netfilter: netns nf_conntrack: per-netns expectations")Signed-off-by Florian Westphal <[email protected]>Signed-off-by Pablo Neira Ayuso <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- net/netfilter/nf_conntrack_expect.c | 4 ++++ 1 file changed, 4 insertions(+)net/netfilter/nf_conntrack_expect.c +4
-0@@ -627,11 +627,15 @@ static int exp_seq_show(struct seq_file *s, void *v) {struct nf_conntrack_expect *expect;struct nf_conntrack_helper *helper; +struct net *net =seq_file_net (s);struct hlist_node *n = v;char *delim ="" ; expect = hlist_entry(n, struct nf_conntrack_expect, hnode); +if (!net_eq (nf_ct_exp_net (expect), net)) +return 0 ; +if (expect->timeout.function)seq_printf (s,"%ld " ,timer_pending (&expect->timeout) ? (long )(expect->timeout.expires - jiffies)/HZ :0 );
Sasha Levin
maintainerRe: [PATCH 5.15 336/570] netfilter: nf_conntrack_expect: skip expectations in other netns via proc
Quoted 2 lines
02a3231b6d82("netfilter:nf_conntrack_expect: store netns and zone in expectation") is good to have as a Stable-Dep.
Dropped from the 5.15 and 5.10 queues until 02a3231b6d82 is properly backported, thanks.
Greg Kroah-Hartman
maintainerPATCH 337/570 netfilter: nf_conntrack_sip: fix use of uninitialized rtp_addr in process_sdp
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 6a2b724460cb67caed500c508c2ae5cf012e4db4 ]
process_sdp() declares union nf_inet_addr rtp_addr on the stack and passes it to the nf_nat_sip sdp_session hook after walking the SDP media descriptions. However rtp_addr is only initialized inside the media loop when a recognized media type with a non-zero port is found.
If the SDP body contains no m= lines, only inactive media sections (m=audio 0 ...) or only unrecognized media types, rtp_addr is never assigned. Despite that, the function still calls hooks->sdp_session() with &rtp_addr, causing nf_nat_sdp_session() to format the stale stack value as an IP address and rewrite the SDP session owner and connection lines with it.
With CONFIG_INIT_STACK_ALL_ZERO (default on most distributions) this results in the session-level o= and c= addresses being rewritten to 0.0.0.0 for inactive SDP sessions. Without stack auto-init the rewritten address is whatever happened to be on the stack.
Fix this by pre-initializing rtp_addr from the session-level connection address (caddr) when available, and tracking via a have_rtp_addr flag whether any valid address was established. Skip the sdp_session hook entirely when no valid address exists.
--- net/netfilter/nf_conntrack_sip.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/netfilter/nf_conntrack_sip.c +10 -4
@@ -1040,6 +1040,7 @@ static int process_sdp(struct sk_buff *skb, unsigned int protoff,unsigned int port;const struct sdp_media_type *t;int ret =NF_ACCEPT ; +bool have_rtp_addr = false; hooks =rcu_dereference (nf_nat_sip_hooks);
@@ -1056,8 +1057,11 @@ static int process_sdp(struct sk_buff *skb, unsigned int protoff, caddr_len =0 ;if (ct_sip_parse_sdp_addr (ct, *dptr, sdpoff, *datalen,SDP_HDR_CONNECTION ,SDP_HDR_MEDIA , - &matchoff, &matchlen, &caddr) >0 ) + &matchoff, &matchlen, &caddr) >0 ) { caddr_len = matchlen; +memcpy (&rtp_addr, &caddr,sizeof (rtp_addr)); + have_rtp_addr = true; + } mediaoff = sdpoff;for (i =0 ; i <ARRAY_SIZE (sdp_media_types); ) {
@@ -1091,9 +1095,11 @@ static int process_sdp(struct sk_buff *skb, unsigned int protoff, &matchoff, &matchlen, &maddr) > 0) { maddr_len = matchlen;memcpy (&rtp_addr, &maddr,sizeof (rtp_addr)); - } else if (caddr_len) + have_rtp_addr = true; + } else if (caddr_len) {memcpy (&rtp_addr, &caddr,sizeof (rtp_addr)); - else { + have_rtp_addr = true; + } else {nf_ct_helper_log (skb, ct,"cannot parse SDP message" );return NF_DROP ; }
@@ -1125,7 +1131,7 @@ static int process_sdp(struct sk_buff *skb, unsigned int protoff,/* Update session connection and owner addresses */ hooks =rcu_dereference (nf_nat_sip_hooks); -if (hooks && ct->status &IPS_NAT_MASK ) +if (hooks && ct->status &IPS_NAT_MASK && have_rtp_addr) ret = hooks->sdp_session (skb, protoff, dataoff, dptr, datalen, sdpoff, &rtp_addr);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 338/570 netlink: introduce NLA_POLICY_MAX_BE
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 08724ef69907214ce622344fe4945412e38368f0 ]
netlink allows to specify allowed ranges for integer types. Unfortunately, nfnetlink passes integers in big endian, so the existing NLA_POLICY_MAX() cannot be used.
At the moment, nfnetlink users, such as nf_tables, need to resort to programmatic checking via helpers such as nft_parse_u32_check().
This is both cumbersome and error prone. This adds NLA_POLICY_MAX_BE which adds range check support for BE16, BE32 and BE64 integers.
Stable-dep-of: 8f15b5071b45 ("netfilter: ctnetlink: use netlink policy range checks")
--- include/net/netlink.h | 9 +++++++++ lib/nlattr.c | 31 +++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-)
include/net/netlink.h +9 -0
@@ -325,6 +325,7 @@ struct nla_policy {struct netlink_range_validation_signed *range_signed;struct {s16 min, max; +u8 network_byte_order:1 ; };int (*validate)(const struct nlattr *attr,struct netlink_ext_ack *extack);
@@ -418,6 +419,14 @@ struct nla_policy { .type = NLA_ENSURE_INT_OR_BINARY_TYPE(tp), \ .validation_type = NLA_VALIDATE_MAX, \ .max = _max, \ + .network_byte_order = 0, \ +} + +#define NLA_POLICY_MAX_BE (tp, _max) { \ + .type = NLA_ENSURE_UINT_TYPE(tp), \ + .validation_type = NLA_VALIDATE_MAX, \ + .max = _max, \ + .network_byte_order = 1, \ }#define NLA_POLICY_MASK (tp, _mask) { \
lib/nlattr.c +27 -4
@@ -160,6 +160,31 @@ void nla_get_range_unsigned(const struct nla_policy *pt, } } +static u64 nla_get_attr_bo (const struct nla_policy *pt, +const struct nlattr *nla) +{ +switch (pt->type) { +case NLA_U16 : +if (pt->network_byte_order) +return ntohs (nla_get_be16 (nla)); + +return nla_get_u16 (nla); +case NLA_U32 : +if (pt->network_byte_order) +return ntohl (nla_get_be32 (nla)); + +return nla_get_u32 (nla); +case NLA_U64 : +if (pt->network_byte_order) +return be64_to_cpu (nla_get_be64 (nla)); + +return nla_get_u64 (nla); + } + +WARN_ON_ONCE (1 ); +return 0 ; +} + static int nla_validate_range_unsigned(const struct nla_policy *pt, const struct nlattr *nla, struct netlink_ext_ack *extack,
@@ -173,12 +198,10 @@ static int nla_validate_range_unsigned(const struct nla_policy *pt, value =nla_get_u8 (nla);break ;case NLA_U16 : - value =nla_get_u16 (nla); -break ;case NLA_U32 : - value =nla_get_u32 (nla); -break ;case NLA_U64 : + value =nla_get_attr_bo (pt, nla); +break ;case NLA_MSECS : value =nla_get_u64 (nla);break ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 339/570 netfilter: nft_payload: reject out-of-range attributes via policy
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 e7af210e6dd0de633d3f4850383310cf57473bc8 ]
Now that nla_policy allows range checks for bigendian data make use of this to reject such attributes. At this time, reject happens later from the init or select_ops callbacks, but its prone to errors.
In the future, new attributes can be handled via NLA_POLICY_MAX_BE and exiting ones can be converted one by one.
Stable-dep-of: 8f15b5071b45 ("netfilter: ctnetlink: use netlink policy range checks")
--- net/netfilter/nft_payload.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nft_payload.c +3 -3
@@ -176,10 +176,10 @@ static const struct nla_policy nft_payload_policy[NFTA_PAYLOAD_MAX + 1] = { [NFTA_PAYLOAD_SREG] = { .type = NLA_U32 }, [NFTA_PAYLOAD_DREG] = { .type = NLA_U32 }, [NFTA_PAYLOAD_BASE] = { .type = NLA_U32 }, - [NFTA_PAYLOAD_OFFSET] = { .type = NLA_U32 }, - [NFTA_PAYLOAD_LEN] = { .type = NLA_U32 }, + [NFTA_PAYLOAD_OFFSET] = NLA_POLICY_MAX_BE(NLA_U32, 255), + [NFTA_PAYLOAD_LEN] = NLA_POLICY_MAX_BE(NLA_U32, 255), [NFTA_PAYLOAD_CSUM_TYPE] = { .type = NLA_U32 }, - [NFTA_PAYLOAD_CSUM_OFFSET] = { .type = NLA_U32 }, + [NFTA_PAYLOAD_CSUM_OFFSET] = NLA_POLICY_MAX_BE(NLA_U32, 255), [NFTA_PAYLOAD_CSUM_FLAGS] = { .type = NLA_U32 }, };
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 340/570 netlink: hide validation union fields from kdoc
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 7354c9024f2835f6122ed9612e21ab379df050f9 ]
Mark the validation fields as private, users shouldn't set them directly and they are too complicated to explain in a more succinct way (there's already a long explanation in the comment above).
The strict_start_type field is set directly and has a dedicated comment so move that above the "private" section.
Stable-dep-of: 8f15b5071b45 ("netfilter: ctnetlink: use netlink policy range checks")
--- include/net/netlink.h | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
include/net/netlink.h +18 -13
@@ -317,19 +317,10 @@ struct nla_policy {u8 validation_type;u16 len;union { -const u32 bitfield32_valid; -const u32 mask; -const char *reject_message; -const struct nla_policy *nested_policy; -struct netlink_range_validation *range; -struct netlink_range_validation_signed *range_signed; -struct { -s16 min, max; -u8 network_byte_order:1 ; - }; -int (*validate)(const struct nlattr *attr, -struct netlink_ext_ack *extack); -/* This entry is special, and used for the attribute at index 0 +/** +* @strict_start_type: first attribute to validate strictly +* +* This entry is special, and used for the attribute at index 0 * only, and specifies special data about the policy, namely it * specifies the "boundary type" where strict length validation * starts for any attribute types >= this value, also, strict
@@ -348,6 +339,20 @@ struct nla_policy {* was added to enforce strict validation from thereon. */ u16 strict_start_type; + +/* private: use NLA_POLICY_*() to set */ +const u32 bitfield32_valid; +const u32 mask; +const char *reject_message; +const struct nla_policy *nested_policy; +struct netlink_range_validation *range; +struct netlink_range_validation_signed *range_signed; +struct { +s16 min, max; +u8 network_byte_order:1 ; + }; +int (*validate)(const struct nlattr *attr, +struct netlink_ext_ack *extack); }; };
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 341/570 netlink: introduce bigendian integer types
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 ecaf75ffd5f5db320d8b1da0198eef5a5ce64a3f ]
Jakub reported that the addition of the "network_byte_order" member in struct nla_policy increases size of 32bit platforms.
Instead of scraping the bit from elsewhere Johannes suggested to add explicit NLA_BE types instead, so do this here.
NLA_POLICY_MAX_BE() macro is removed again, there is no need for it: NLA_POLICY_MAX(NLA_BE.., ..) will do the right thing.
NLA_BE64 can be added later.
Stable-dep-of: 8f15b5071b45 ("netfilter: ctnetlink: use netlink policy range checks")
--- include/net/netlink.h | 19 +++++++++-------- lib/nlattr.c | 41 ++++++++++++++----------------------- net/netfilter/nft_payload.c | 6 +++--- 3 files changed, 28 insertions(+), 38 deletions(-)
include/net/netlink.h +10 -9
@@ -181,6 +181,8 @@ enum {NLA_S64 ,NLA_BITFIELD32 ,NLA_REJECT , +NLA_BE16 , +NLA_BE32 , __NLA_TYPE_MAX, };
@@ -231,6 +233,7 @@ enum nla_policy_validation {* NLA_U32, NLA_U64, * NLA_S8, NLA_S16, * NLA_S32, NLA_S64, +* NLA_BE16, NLA_BE32, * NLA_MSECS Leaving the length field zero will verify the * given type fits, using it verifies minimum length * just like "All other"
@@ -261,6 +264,8 @@ enum nla_policy_validation {* NLA_U16, * NLA_U32, * NLA_U64, +* NLA_BE16, +* NLA_BE32, * NLA_S8, * NLA_S16, * NLA_S32,
@@ -349,7 +354,6 @@ struct nla_policy {struct netlink_range_validation_signed *range_signed;struct {s16 min, max; -u8 network_byte_order:1 ; };int (*validate)(const struct nlattr *attr,struct netlink_ext_ack *extack);
@@ -374,6 +378,8 @@ struct nla_policy { (tp == NLA_U8 || tp == NLA_U16 || tp == NLA_U32 || tp == NLA_U64)#define __NLA_IS_SINT_TYPE (tp) \ (tp == NLA_S8 || tp == NLA_S16 || tp == NLA_S32 || tp == NLA_S64) +#define __NLA_IS_BEINT_TYPE (tp) \ + (tp == NLA_BE16 || tp == NLA_BE32)#define __NLA_ENSURE (condition) BUILD_BUG_ON_ZERO(!(condition))#define NLA_ENSURE_UINT_TYPE (tp) \
@@ -387,6 +393,7 @@ struct nla_policy {#define NLA_ENSURE_INT_OR_BINARY_TYPE (tp) \ (__NLA_ENSURE(__NLA_IS_UINT_TYPE(tp) || \ __NLA_IS_SINT_TYPE(tp) || \ + __NLA_IS_BEINT_TYPE(tp) || \ tp == NLA_MSECS || \ tp == NLA_BINARY) + tp)#define NLA_ENSURE_NO_VALIDATION_PTR (tp) \
@@ -394,6 +401,8 @@ struct nla_policy { tp != NLA_REJECT && \ tp != NLA_NESTED && \ tp != NLA_NESTED_ARRAY) + tp) +#define NLA_ENSURE_BEINT_TYPE (tp) \ + (__NLA_ENSURE(__NLA_IS_BEINT_TYPE(tp)) + tp)#define NLA_POLICY_RANGE (tp, _min, _max) { \ .type = NLA_ENSURE_INT_OR_BINARY_TYPE(tp), \
@@ -424,14 +433,6 @@ struct nla_policy { .type = NLA_ENSURE_INT_OR_BINARY_TYPE(tp), \ .validation_type = NLA_VALIDATE_MAX, \ .max = _max, \ - .network_byte_order = 0, \ -} - -#define NLA_POLICY_MAX_BE (tp, _max) { \ - .type = NLA_ENSURE_UINT_TYPE(tp), \ - .validation_type = NLA_VALIDATE_MAX, \ - .max = _max, \ - .network_byte_order = 1, \ }#define NLA_POLICY_MASK (tp, _mask) { \
lib/nlattr.c +15 -26
77 lines not on this page · raw message
net/netfilter/nft_payload.c +3 -3
@@ -176,10 +176,10 @@ static const struct nla_policy nft_payload_policy[NFTA_PAYLOAD_MAX + 1] = { [NFTA_PAYLOAD_SREG] = { .type = NLA_U32 }, [NFTA_PAYLOAD_DREG] = { .type = NLA_U32 }, [NFTA_PAYLOAD_BASE] = { .type = NLA_U32 }, - [NFTA_PAYLOAD_OFFSET] = NLA_POLICY_MAX_BE(NLA_U32, 255), - [NFTA_PAYLOAD_LEN] = NLA_POLICY_MAX_BE(NLA_U32, 255), + [NFTA_PAYLOAD_OFFSET] = NLA_POLICY_MAX(NLA_BE32, 255), + [NFTA_PAYLOAD_LEN] = NLA_POLICY_MAX(NLA_BE32, 255), [NFTA_PAYLOAD_CSUM_TYPE] = { .type = NLA_U32 }, - [NFTA_PAYLOAD_CSUM_OFFSET] = NLA_POLICY_MAX_BE(NLA_U32, 255), + [NFTA_PAYLOAD_CSUM_OFFSET] = NLA_POLICY_MAX(NLA_BE32, 255), [NFTA_PAYLOAD_CSUM_FLAGS] = { .type = NLA_U32 }, };
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 342/570 netlink: allow be16 and be32 types in all uint policy checks
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 5fac9b7c16c50c6c7699517f582b56e3743f453a ]
__NLA_IS_BEINT_TYPE(tp) isn't useful. NLA_BE16/32 are identical to NLA_U16/32, the only difference is that it tells the netlink validation functions that byteorder conversion might be needed before comparing the value to the policy min/max ones.
After this change all policy macros that can be used with UINT types, such as NLA_POLICY_MASK() can also be used with NLA_BE16/32.
This will be used to validate nf_tables flag attributes which are in bigendian byte order.
Stable-dep-of: 8f15b5071b45 ("netfilter: ctnetlink: use netlink policy range checks")
--- include/net/netlink.h | 10 +++------- lib/nlattr.c | 6 ++++++ 2 files changed, 9 insertions(+), 7 deletions(-)
include/net/netlink.h +3 -7
@@ -374,12 +374,11 @@ struct nla_policy {#define NLA_POLICY_BITFIELD32 (valid) \ { .type = NLA_BITFIELD32, .bitfield32_valid = valid } -#define __NLA_IS_UINT_TYPE (tp) \ - (tp == NLA_U8 || tp == NLA_U16 || tp == NLA_U32 || tp == NLA_U64) +#define __NLA_IS_UINT_TYPE (tp) \ + (tp == NLA_U8 || tp == NLA_U16 || tp == NLA_U32 || \ + tp == NLA_U64 || tp == NLA_BE16 || tp == NLA_BE32)#define __NLA_IS_SINT_TYPE (tp) \ (tp == NLA_S8 || tp == NLA_S16 || tp == NLA_S32 || tp == NLA_S64) -#define __NLA_IS_BEINT_TYPE (tp) \ - (tp == NLA_BE16 || tp == NLA_BE32)#define __NLA_ENSURE (condition) BUILD_BUG_ON_ZERO(!(condition))#define NLA_ENSURE_UINT_TYPE (tp) \
@@ -393,7 +392,6 @@ struct nla_policy {#define NLA_ENSURE_INT_OR_BINARY_TYPE (tp) \ (__NLA_ENSURE(__NLA_IS_UINT_TYPE(tp) || \ __NLA_IS_SINT_TYPE(tp) || \ - __NLA_IS_BEINT_TYPE(tp) || \ tp == NLA_MSECS || \ tp == NLA_BINARY) + tp)#define NLA_ENSURE_NO_VALIDATION_PTR (tp) \
@@ -401,8 +399,6 @@ struct nla_policy { tp != NLA_REJECT && \ tp != NLA_NESTED && \ tp != NLA_NESTED_ARRAY) + tp) -#define NLA_ENSURE_BEINT_TYPE (tp) \ - (__NLA_ENSURE(__NLA_IS_BEINT_TYPE(tp)) + tp)#define NLA_POLICY_RANGE (tp, _min, _max) { \ .type = NLA_ENSURE_INT_OR_BINARY_TYPE(tp), \
lib/nlattr.c +6 -0
@@ -355,6 +355,12 @@ static int nla_validate_mask(const struct nla_policy *pt,case NLA_U64 : value =nla_get_u64 (nla);break ; +case NLA_BE16 : + value =ntohs (nla_get_be16 (nla)); +break ; +case NLA_BE32 : + value =ntohl (nla_get_be32 (nla)); +break ;default :return -EINVAL ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 343/570 netfilter: ctnetlink: use netlink policy range checks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit 8f15b5071b4548b0aafc03b366eb45c9c6566704 ]
Replace manual range and mask validations with netlink policy annotations in ctnetlink code paths, so that the netlink core rejects invalid values early and can generate extack errors.
- CTA_PROTOINFO_TCP_STATE: reject values > TCP_CONNTRACK_SYN_SENT2 at policy level, removing the manual >= TCP_CONNTRACK_MAX check.
- CTA_PROTOINFO_TCP_WSCALE_ORIGINAL/REPLY: reject values > TCP_MAX_WSCALE (14). The normal TCP option parsing path already clamps to this value, but the ctnetlink path accepted 0-255, causing undefined behavior when used as a u32 shift count.
- CTA_FILTER_ORIG_FLAGS/REPLY_FLAGS: use NLA_POLICY_MASK with CTA_FILTER_F_ALL, removing the manual mask checks.
- CTA_EXPECT_FLAGS: use NLA_POLICY_MASK with NF_CT_EXPECT_MASK, adding a new mask define grouping all valid expect flags.
Extracted from a broader nf-next patch by Florian Westphal, scoped to ctnetlink for the fixes tree.
--- .../uapi/linux/netfilter/nf_conntrack_common.h | 4 ++++ net/netfilter/nf_conntrack_netlink.c | 16 +++++----------- net/netfilter/nf_conntrack_proto_tcp.c | 10 +++------- 3 files changed, 12 insertions(+), 18 deletions(-)
include/uapi/linux/netfilter/nf_conntrack_common.h +4 -0
@@ -159,5 +159,9 @@ enum ip_conntrack_expect_events {#define NF_CT_EXPECT_INACTIVE 0x2#define NF_CT_EXPECT_USERSPACE 0x4 +#ifdef __KERNEL__ +#define NF_CT_EXPECT_MASK (NF_CT_EXPECT_PERMANENT | NF_CT_EXPECT_INACTIVE | \ + NF_CT_EXPECT_USERSPACE) +#endif #endif /* _UAPI_NF_CONNTRACK_COMMON_H */
net/netfilter/nf_conntrack_netlink.c +5 -11
@@ -872,8 +872,8 @@ struct ctnetlink_filter { };static const struct nla_policy cta_filter_nla_policy[CTA_FILTER_MAX +1 ] = { - [CTA_FILTER_ORIG_FLAGS ] = { .type =NLA_U32 }, - [CTA_FILTER_REPLY_FLAGS ] = { .type =NLA_U32 }, + [CTA_FILTER_ORIG_FLAGS ] =NLA_POLICY_MASK (NLA_U32 ,CTA_FILTER_F_ALL ), + [CTA_FILTER_REPLY_FLAGS ] =NLA_POLICY_MASK (NLA_U32 ,CTA_FILTER_F_ALL ), }; static int ctnetlink_parse_filter(const struct nlattr *attr,
@@ -887,17 +887,11 @@ static int ctnetlink_parse_filter(const struct nlattr *attr,if (ret)return ret; -if (tb[CTA_FILTER_ORIG_FLAGS ]) { +if (tb[CTA_FILTER_ORIG_FLAGS ]) filter->orig_flags =nla_get_u32 (tb[CTA_FILTER_ORIG_FLAGS ]); -if (filter->orig_flags & ~CTA_FILTER_F_ALL ) -return -EOPNOTSUPP ; - } -if (tb[CTA_FILTER_REPLY_FLAGS ]) { +if (tb[CTA_FILTER_REPLY_FLAGS ]) filter->reply_flags =nla_get_u32 (tb[CTA_FILTER_REPLY_FLAGS ]); -if (filter->reply_flags & ~CTA_FILTER_F_ALL ) -return -EOPNOTSUPP ; - }return 0 ; }
@@ -2642,7 +2636,7 @@ static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = { [CTA_EXPECT_HELP_NAME] = { .type = NLA_NUL_STRING, .len = NF_CT_HELPER_NAME_LEN - 1 }, [CTA_EXPECT_ZONE] = { .type = NLA_U16 }, - [CTA_EXPECT_FLAGS] = { .type = NLA_U32 }, + [CTA_EXPECT_FLAGS] = NLA_POLICY_MASK(NLA_BE32, NF_CT_EXPECT_MASK), [CTA_EXPECT_CLASS] = { .type = NLA_U32 }, [CTA_EXPECT_NAT] = { .type = NLA_NESTED }, [CTA_EXPECT_FN] = { .type = NLA_NUL_STRING },
net/netfilter/nf_conntrack_proto_tcp.c +3 -7
@@ -1325,9 +1325,9 @@ static int tcp_to_nlattr(struct sk_buff *skb, struct nlattr *nla, }static const struct nla_policy tcp_nla_policy[CTA_PROTOINFO_TCP_MAX +1 ] = { - [CTA_PROTOINFO_TCP_STATE ] = { .type =NLA_U8 }, - [CTA_PROTOINFO_TCP_WSCALE_ORIGINAL ] = { .type =NLA_U8 }, - [CTA_PROTOINFO_TCP_WSCALE_REPLY ] = { .type =NLA_U8 }, + [CTA_PROTOINFO_TCP_STATE ] =NLA_POLICY_MAX (NLA_U8 ,TCP_CONNTRACK_SYN_SENT2 ), + [CTA_PROTOINFO_TCP_WSCALE_ORIGINAL ] =NLA_POLICY_MAX (NLA_U8 ,TCP_MAX_WSCALE ), + [CTA_PROTOINFO_TCP_WSCALE_REPLY ] =NLA_POLICY_MAX (NLA_U8 ,TCP_MAX_WSCALE ), [CTA_PROTOINFO_TCP_FLAGS_ORIGINAL ] = { .len =sizeof (struct nf_ct_tcp_flags ) }, [CTA_PROTOINFO_TCP_FLAGS_REPLY ] = { .len =sizeof (struct nf_ct_tcp_flags ) }, };
@@ -1354,10 +1354,6 @@ static int nlattr_to_tcp(struct nlattr *cda[], struct nf_conn *ct)if (err <0 )return err; -if (tb[CTA_PROTOINFO_TCP_STATE ] && -nla_get_u8 (tb[CTA_PROTOINFO_TCP_STATE ]) >=TCP_CONNTRACK_MAX ) -return -EINVAL ; -spin_lock_bh (&ct->lock);if (tb[CTA_PROTOINFO_TCP_STATE ]) ct->proto.tcp.state =nla_get_u8 (tb[CTA_PROTOINFO_TCP_STATE ]);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 344/570 net: macb: use the current queue number for stats
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Valerio <[email protected]>
[ Upstream commit 72d96e4e24bbefdcfbc68bdb9341a05d8f5cb6e5 ]
There's a potential mismatch between the memory reserved for statistics and the amount of memory written.
gem_get_sset_count() correctly computes the number of stats based on the active queues, whereas gem_get_ethtool_stats() indiscriminately copies data using the maximum number of queues, and in the case the number of active queues is less than MACB_MAX_QUEUES, this results in a OOB write as observed in the KASAN splat.
==================================================================
BUG: KASAN: vmalloc-out-of-bounds in gem_get_ethtool_stats+0x54/0x78 [macb] Write of size 760 at addr ffff80008080b000 by task ethtool/1027
CPU: [...]
Tainted: [E]=UNSIGNED_MODULE
Hardware name: raspberrypi rpi/rpi, BIOS 2025.10 10/01/2025
Call trace:
show_stack+0x20/0x38 (C)
dump_stack_lvl+0x80/0xf8
print_report+0x384/0x5e0
kasan_report+0xa0/0xf0
kasan_check_range+0xe8/0x190
__asan_memcpy+0x54/0x98
gem_get_ethtool_stats+0x54/0x78 [macb
926c13f3af83b0c6fe64badb21ec87d5e93fcf65]
dev_ethtool+0x1220/0x38c0
dev_ioctl+0x4ac/0xca8
sock_do_ioctl+0x170/0x1d8
sock_ioctl+0x484/0x5d8
__arm64_sys_ioctl+0x12c/0x1b8
invoke_syscall+0xd4/0x258
el0_svc_common.constprop.0+0xb4/0x240
do_el0_svc+0x48/0x68
el0_svc+0x40/0xf8
el0t_64_sync_handler+0xa0/0xe8
el0t_64_sync+0x1b0/0x1b8
The buggy address belongs to a 1-page vmalloc region starting at
0xffff80008080b000 allocated at dev_ethtool+0x11f0/0x38c0
The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000
index:0xffff00000a333000 pfn:0xa333
flags: 0x7fffc000000000(node=0|zone=0|lastcpupid=0x1ffff)
raw: 007fffc000000000 0000000000000000 dead000000000122 0000000000000000
raw: ffff00000a333000 0000000000000000 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff80008080b080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff80008080b100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff80008080b180: 00 00 00 00 00 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
^
ffff80008080b200: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
ffff80008080b280: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
==================================================================Fix it by making sure the copied size only considers the active number of queues.
--- drivers/net/ethernet/cadence/macb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +1 -1
@@ -2977,7 +2977,7 @@ static void gem_get_ethtool_stats(struct net_device *dev,spin_lock_irq (&bp->stats_lock);gem_update_stats (bp);memcpy (data, &bp->ethtool_stats,sizeof (u64) - * (GEM_STATS_LEN +QUEUE_STATS_LEN *MACB_MAX_QUEUES )); + * (GEM_STATS_LEN +QUEUE_STATS_LEN * bp->num_queues));spin_unlock_irq (&bp->stats_lock); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 345/570 regmap: Synchronize cache for the page selector
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 09e70e4f119ff650d24c96161fd2f62ac7e424b0 ]
If the selector register is represented in each page, its value according to the debugfs is stale because it gets synchronized only after the real page switch happens. Hence the regmap cache initialisation from the HW inherits outdated data in the selector register.
Synchronize cache for the page selector just in time.
Before (offset followed by hexdump, the first byte is selector):
// Real registers
18: 05 ff 00 00 ff 0f 00 00 f0 00 00 00
...
// Virtual (per port)
40: 05 ff 00 00 e0 e0 00 00 00 00 00 1f
50: 00 ff 00 00 e0 e0 00 00 00 00 00 1f
60: 01 ff 00 00 ff ff 00 00 00 00 00 00
70: 02 ff 00 00 cf f3 00 00 00 00 00 0c
80: 03 ff 00 00 00 00 00 00 00 00 00 ff
90: 04 ff 00 00 ff 0f 00 00 f0 00 00 00After:
// Real registers
18: 05 ff 00 00 ff 0f 00 00 f0 00 00 00
...
// Virtual (per port)
40: 00 ff 00 00 e0 e0 00 00 00 00 00 1f
50: 01 ff 00 00 e0 e0 00 00 00 00 00 1f
60: 02 ff 00 00 ff ff 00 00 00 00 00 00
70: 03 ff 00 00 cf f3 00 00 00 00 00 0c
80: 04 ff 00 00 00 00 00 00 00 00 00 ff
90: 05 ff 00 00 ff 0f 00 00 f0 00 00 00--- drivers/base/regmap/regmap.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
drivers/base/regmap/regmap.c +26 -4
@@ -1629,6 +1629,7 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg, unsigned int val_num) {void *orig_work_buf; +unsigned int selector_reg;unsigned int win_offset;unsigned int win_page;bool page_chg;
@@ -1647,10 +1648,31 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg,return -EINVAL ; } -/* It is possible to have selector register inside data window. -In that case, selector register is located on every page and -it needs no page switching, when accessed alone. */ +/* +* Calculate the address of the selector register in the corresponding +* data window if it is located on every page. +*/ + page_chg =in_range (range->selector_reg, range->window_start, range->window_len); +if (page_chg) + selector_reg = range->range_min + win_page * range->window_len + + range->selector_reg - range->window_start; + +/* +* It is possible to have selector register inside data window. +* In that case, selector register is located on every page and it +* needs no page switching, when accessed alone. +* +* Nevertheless we should synchronize the cache values for it. +* This can't be properly achieved if the selector register is +* the first and the only one to be read inside the data window. +* That's why we update it in that case as well. +* +* However, we specifically avoid updating it for the default page, +* when it's overlapped with the real data window, to prevent from +* infinite looping. +*/ if (val_num >1 || + (page_chg && selector_reg != range->selector_reg) || range->window_start + win_offset != range->selector_reg) {/* Use separate work_buf during page switching */ orig_work_buf = map->work_buf;
@@ -1659,7 +1681,7 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg, ret =_regmap_update_bits (map, range->selector_reg, range->selector_mask, win_page << range->selector_shift, - &page_chg, false); +NULL , false); map->work_buf = orig_work_buf;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 346/570 RDMA/rw: Fall back to direct SGE on MR pool exhaustion
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 00da250c21b074ea9494c375d0117b69e5b1d0a4 ]
When IOMMU passthrough mode is active, ib_dma_map_sgtable_attrs() produces no coalescing: each scatterlist page maps 1:1 to a DMA entry, so sgt.nents equals the raw page count. A 1 MB transfer yields 256 DMA entries. If that count exceeds the device's max_sgl_rd threshold (an optimization hint from mlx5 firmware), rdma_rw_io_needs_mr() steers the operation into the MR registration path. Each such operation consumes one or more MRs from a pool sized at max_rdma_ctxs -- roughly one MR per concurrent context. Under write-intensive workloads that issue many concurrent RDMA READs, the pool is rapidly exhausted, ib_mr_pool_get() returns NULL, and rdma_rw_init_one_mr() returns -EAGAIN. Upper layer protocols treat this as a fatal DMA mapping failure and tear down the connection.
The max_sgl_rd check is a performance optimization, not a correctness requirement: the device can handle large SGE counts via direct posting, just less efficiently than with MR registration. When the MR pool cannot satisfy a request, falling back to the direct SGE (map_wrs) path avoids the connection reset while preserving the MR optimization for the common case where pool resources are available.
Add a fallback in rdma_rw_ctx_init() so that -EAGAIN from rdma_rw_init_mr_wrs() triggers direct SGE posting instead of propagating the error. iWARP devices, which mandate MR registration for RDMA READs, and force_mr debug mode continue to treat -EAGAIN as terminal.
--- drivers/infiniband/core/rw.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/infiniband/core/rw.c +18 -3
@@ -341,14 +341,29 @@ int rdma_rw_ctx_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num,if (rdma_rw_io_needs_mr (qp->device, port_num, dir, sg_cnt)) { ret =rdma_rw_init_mr_wrs (ctx, qp, port_num, sg, sg_cnt, sg_offset, remote_addr, rkey, dir); - }else if (sg_cnt >1 ) { +/* +* If MR init succeeded or failed for a reason other +* than pool exhaustion, that result is final. +* +* Pool exhaustion (-EAGAIN) from the max_sgl_rd +* optimization is recoverable: fall back to +* direct SGE posting. iWARP and force_mr require +* MRs unconditionally, so -EAGAIN is terminal. +*/ +if (ret != -EAGAIN || +rdma_protocol_iwarp (qp->device, port_num) || +unlikely (rdma_rw_force_mr)) + goto out; + } + +if (sg_cnt >1 ) ret =rdma_rw_init_map_wrs (ctx, qp, sg, sg_cnt, sg_offset, remote_addr, rkey, dir); - }else { +else ret =rdma_rw_init_single_wr (ctx, qp, sg, sg_offset, remote_addr, rkey, dir); - } +out:if (ret <0 ) goto out_unmap_sg;return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 347/570 RDMA/irdma: Update ibqp state to error if QP is already in error state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tatyana Nikolova <[email protected]>
[ Upstream commit 8c1f19a2225cf37b3f8ab0b5a8a5322291cda620 ]
In irdma_modify_qp() update ibqp state to error if the irdma QP is already in error state, otherwise the ibqp state which is visible to the consumer app remains stale.
--- drivers/infiniband/hw/irdma/verbs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/irdma/verbs.c +2 -0
@@ -1353,6 +1353,7 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr,case IB_QPS_ERR :case IB_QPS_RESET :if (iwqp->iwarp_state ==IRDMA_QP_STATE_ERROR ) { + iwqp->ibqp_state = attr->qp_state;spin_unlock_irqrestore (&iwqp->lock, flags);if (udata) { if (ib_copy_from_udata(&ureq, udata,
@@ -1549,6 +1550,7 @@ int irdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,case IB_QPS_ERR :case IB_QPS_RESET :if (iwqp->iwarp_state ==IRDMA_QP_STATE_ERROR ) { + iwqp->ibqp_state = attr->qp_state;spin_unlock_irqrestore (&iwqp->lock, flags);if (udata) { if (ib_copy_from_udata(&ureq, udata,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 348/570 RDMA/irdma: Remove a NOP wait_event() in irdma_modify_qp_roce()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tatyana Nikolova <[email protected]>
[ Upstream commit 5e8f0239731a83753473b7aa91bda67bbdff5053 ]
Remove a NOP wait_event() in irdma_modify_qp_roce() which is relevant for iWARP and likely a copy and paste artifact for RoCEv2. The wait event is for sending a reset on a TCP connection, after the reset has been requested in irdma_modify_qp(), which occurs only in iWarp mode.
--- drivers/infiniband/hw/irdma/verbs.c | 2 -- 1 file changed, 2 deletions(-)
drivers/infiniband/hw/irdma/verbs.c +0 -2
@@ -1275,8 +1275,6 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr, roce_info->rd_en = true; } -wait_event (iwqp->mod_qp_waitq, !atomic_read (&iwqp->hw_mod_qp_pend)); - ibdev_dbg(&iwdev->ibdev, "VERBS: caller: %pS qp_id=%d to_ibqpstate=%d ibqpstate=%d irdma_qpstate=%d attr_mask=0x%x\n", __builtin_return_address(0), ibqp->qp_num, attr->qp_state,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 349/570 RDMA/irdma: Clean up unnecessary dereference of event->cm_node
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Barrera <[email protected]>
[ Upstream commit b415399c9a024d574b65479636f0d4eb625b9abd ]
The cm_node is available and the usage of cm_node and event->cm_node seems arbitrary. Clean up unnecessary dereference of event->cm_node.
--- drivers/infiniband/hw/irdma/cm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/infiniband/hw/irdma/cm.c +6 -6
@@ -4171,21 +4171,21 @@ static void irdma_cm_event_handler(struct work_struct *work)irdma_cm_event_reset (event);break ;case IRDMA_CM_EVENT_CONNECTED : -if (!event->cm_node->cm_id || - event->cm_node->state !=IRDMA_CM_STATE_OFFLOADED ) +if (!cm_node->cm_id || + cm_node->state !=IRDMA_CM_STATE_OFFLOADED )break ;irdma_cm_event_connected (event);break ;case IRDMA_CM_EVENT_MPA_REJECT : -if (!event->cm_node->cm_id || +if (!cm_node->cm_id || cm_node->state ==IRDMA_CM_STATE_OFFLOADED )break ;irdma_send_cm_event (cm_node, cm_node->cm_id,IW_CM_EVENT_CONNECT_REPLY , -ECONNREFUSED );break ;case IRDMA_CM_EVENT_ABORTED : -if (!event->cm_node->cm_id || - event->cm_node->state ==IRDMA_CM_STATE_OFFLOADED ) +if (!cm_node->cm_id || + cm_node->state ==IRDMA_CM_STATE_OFFLOADED )break ;irdma_event_connect_error (event);break ;
@@ -4195,7 +4195,7 @@ static void irdma_cm_event_handler(struct work_struct *work)break ; } -irdma_rem_ref_cm_node (event->cm_node); +irdma_rem_ref_cm_node (cm_node);kfree (event); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 350/570 RDMA/irdma: Remove reset check from irdma_modify_qp_to_err()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tatyana Nikolova <[email protected]>
[ Upstream commit c45c6ebd693b944f1ffe429fdfb6cc1674c237be ]
During reset, irdma_modify_qp() to error should be called to disconnect the QP. Without this fix, if not preceded by irdma_modify_qp() to error, the API call irdma_destroy_qp() gets stuck waiting for the QP refcount to go to zero, because the cm_node associated with this QP isn't disconnected.
--- drivers/infiniband/hw/irdma/utils.c | 2 -- 1 file changed, 2 deletions(-)
drivers/infiniband/hw/irdma/utils.c +0 -2
@@ -2512,8 +2512,6 @@ void irdma_modify_qp_to_err(struct irdma_sc_qp *sc_qp)struct irdma_qp *qp = sc_qp->qp_uk.back_qp;struct ib_qp_attr attr; -if (qp->iwdev->rf->reset) -return ; attr.qp_state =IB_QPS_ERR ;if (rdma_protocol_roce (qp->ibqp.device,1 ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 351/570 RDMA/irdma: Fix deadlock during netdev reset with active connections
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anil Samal <[email protected]>
[ Upstream commit 6f52370970ac07d352a7af4089e55e0e6425f827 ]
Resolve deadlock that occurs when user executes netdev reset while RDMA applications (e.g., rping) are active. The netdev reset causes ice driver to remove irdma auxiliary driver, triggering device_delete and subsequent client removal. During client removal, uverbs_client waits for QP reference count to reach zero while cma_client holds the final reference, creating circular dependency and indefinite wait in iWARP mode. Skip QP reference count wait during device reset to prevent deadlock.
--- drivers/infiniband/hw/irdma/verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/irdma/verbs.c +2 -1
@@ -518,7 +518,8 @@ static int irdma_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) }irdma_qp_rem_ref (&iwqp->ibqp); -wait_for_completion (&iwqp->free_qp); +if (!iwdev->rf->reset) +wait_for_completion (&iwqp->free_qp);irdma_free_lsmm_rsrc (iwqp);irdma_cqp_qp_destroy_cmd (&iwdev->rf->sc_dev, &iwqp->sc_qp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 352/570 RDMA/irdma: Return EINVAL for invalid arp index error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tatyana Nikolova <[email protected]>
[ Upstream commit 7221f581eefa79ead06e171044f393fb7ee22f87 ]
When rdma_connect() fails due to an invalid arp index, user space rdma core reports ENOMEM which is confusing. Modify irdma_make_cm_node() to return the correct error code.
--- drivers/infiniband/hw/irdma/cm.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/infiniband/hw/irdma/cm.c +10 -7
@@ -2197,11 +2197,12 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev,int oldarpindex;int arpindex;struct net_device *netdev = iwdev->netdev; +int ret;/* create an hte and cm_node for this instance */ cm_node =kzalloc (sizeof (*cm_node),GFP_ATOMIC );if (!cm_node) -return NULL ; +return ERR_PTR (-ENOMEM );/* set our node specific transport info */ cm_node->ipv4 = cm_info->ipv4;
@@ -2296,8 +2297,10 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev, arpindex = -EINVAL ; } -if (arpindex <0 ) +if (arpindex <0 ) { + ret = -EINVAL ; goto err; + }ether_addr_copy (cm_node->rem_mac, iwdev->rf->arp_table[arpindex].mac_addr);
@@ -2308,7 +2311,7 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev, err:kfree (cm_node); -return NULL ; +return ERR_PTR (ret); }static void irdma_destroy_connection (struct irdma_cm_node *cm_node)
@@ -2969,8 +2972,8 @@ static int irdma_create_cm_node(struct irdma_cm_core *cm_core,/* create a CM connection node */ cm_node =irdma_make_cm_node (cm_core, iwdev, cm_info,NULL ); -if (!cm_node) -return -ENOMEM ; +if (IS_ERR (cm_node)) +return PTR_ERR (cm_node);/* set our node side to client (active) side */ cm_node->tcp_cntxt.client =1 ;
@@ -3167,9 +3170,9 @@ void irdma_receive_ilq(struct irdma_sc_vsi *vsi, struct irdma_puda_buf *rbuf) cm_info.cm_id = listener->cm_id; cm_node =irdma_make_cm_node (cm_core, iwdev, &cm_info, listener); -if (!cm_node) { +if (IS_ERR (cm_node)) {ibdev_dbg (&cm_core->iwdev->ibdev, -"CM: allocate node failed\n" ); +"CM: allocate node failed ret=%ld\n" ,PTR_ERR (cm_node));refcount_dec (&listener->refcnt);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 353/570 scsi: scsi_transport_sas: Fix the maximum channel scanning issue
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yihang Li <[email protected]>
[ Upstream commit d71afa9deb4d413232ba16d693f7d43b321931b4 ]
After commit 37c4e72b0651 ("scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans"), if the device supports multiple channels (0 to shost->max_channel), user_scan() invokes updated sas_user_scan() to perform the scan behavior for a specific transfer. However, when the user specifies shost->max_channel, it will return -EINVAL, which is not expected.
Fix and support specifying the scan shost->max_channel for scanning.
--- drivers/scsi/scsi_transport_sas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_transport_sas.c +1 -1
@@ -1732,7 +1732,7 @@ static int sas_user_scan(struct Scsi_Host *shost, uint channel,break ;default : -if (channel < shost->max_channel) { +if (channel <= shost->max_channel) { res =scsi_scan_host_selected (shost, channel, id, lun,SCSI_SCAN_MANUAL ); }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 354/570 x86/efi: efi_unmap_boot_services: fix calculation of ranges_to_free size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Rapoport (Microsoft) <[email protected]>
[ Upstream commit 217c0a5c177a3d4f7c8497950cbf5c36756e8bbb ]
ranges_to_free array should have enough room to store the entire EFI memmap plus an extra element for NULL entry.
The calculation of this array size wrongly adds 1 to the overall size instead of adding 1 to the number of elements.
Add parentheses to properly size the array.
--- arch/x86/platform/efi/quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/platform/efi/quirks.c +1 -1
@@ -416,7 +416,7 @@ void __init efi_unmap_boot_services(void)if (efi_enabled (EFI_DBG ))return ; - sz =sizeof (*ranges_to_free) * efi.memmap.nr_map +1 ; + sz =sizeof (*ranges_to_free) * (efi.memmap.nr_map +1 ); ranges_to_free =kzalloc (sz,GFP_KERNEL );if (!ranges_to_free) {pr_err ("Failed to allocate storage for freeable EFI regions\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 355/570 drm/i915/gmbus: fix spurious timeout on 512-byte burst reads
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samasth Norway Ananda <[email protected]>
[ Upstream commit 08441f10f4dc09fdeb64529953ac308abc79dd38 ]
When reading exactly 512 bytes with burst read enabled, the extra_byte_added path breaks out of the inner do-while without decrementing len. The outer while(len) then re-enters and gmbus_wait() times out since all data has been delivered. Decrement len before the break so the outer loop terminates correctly.
--- drivers/gpu/drm/i915/display/intel_gmbus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_gmbus.c +3 -1
@@ -432,8 +432,10 @@ gmbus_xfer_read_chunk(struct drm_i915_private *dev_priv, val =intel_de_read_fw (dev_priv,GMBUS3 ); do { - if (extra_byte_added && len == 1) + if (extra_byte_added && len == 1) { + len--; break; + } *buf++ = val & 0xff; val >>= 8;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 356/570 ASoC: Intel: catpt: Fix the device initialization
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cezary Rojewski <[email protected]>
[ Upstream commit 5a184f1cb43a8e035251c635f5c47da5dc3e3049 ]
The DMA mask shall be coerced before any buffer allocations for the device are done. At the same time explain why DMA mask of 31 bits is used in the first place.
--- sound/soc/intel/catpt/device.c | 10 +++++++++- sound/soc/intel/catpt/dsp.c | 3 --- 2 files changed, 9 insertions(+), 4 deletions(-)
sound/soc/intel/catpt/device.c +9 -1
@@ -275,7 +275,15 @@ static int catpt_acpi_probe(struct platform_device *pdev)if (IS_ERR (cdev->pci_ba))return PTR_ERR (cdev->pci_ba); -/* alloc buffer for storing DRAM context during dx transitions */ +/* +* As per design HOST is responsible for preserving firmware's runtime +* context during D0 -> D3 -> D0 transitions. Addresses used for DMA +* to/from HOST memory shall be outside the reserved range of 0xFFFxxxxx. +*/ + ret =dma_coerce_mask_and_coherent (cdev->dev,DMA_BIT_MASK (31 )); +if (ret) +return ret; + cdev->dxbuf_vaddr =dmam_alloc_coherent (dev,catpt_dram_size (cdev), &cdev->dxbuf_paddr,GFP_KERNEL );if (!cdev->dxbuf_vaddr)
sound/soc/intel/catpt/dsp.c +0 -3
@@ -125,9 +125,6 @@ int catpt_dmac_probe(struct catpt_dev *cdev) dmac->dev = cdev->dev; dmac->irq = cdev->irq; - ret =dma_coerce_mask_and_coherent (cdev->dev,DMA_BIT_MASK (31 )); -if (ret) -return ret;/* * Caller is responsible for putting device in D0 to allow * for I/O and memory access before probing DW.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 357/570 ACPICA: include/acpi/acpixf.h: Fix indentation
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 7a9d74e7e403cb2e60d4d00c05f2f3ab2a33d0c3 ]
A bunch of the functions declared in include/acpi/acpixf.h have their name aligned a space after the '(' of e.g. the ACPI_EXTERNAL_RETURN_STATUS(acpi_status line above rather then being directly aligned after the '('.
This breaks applying patches generated from the ACPICA upstream git, remove the extra space before the function-names and all the arguments to fix this.
Stable-dep-of: f6484cadbcaf ("ACPI: EC: clean up handlers on probe failure in acpi_ec_setup()")
--- include/acpi/acpixf.h | 120 +++++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 60 deletions(-)
include/acpi/acpixf.h +60 -60
@@ -587,82 +587,82 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_statusacpi_install_initialization_handler (acpi_init_handler handler, u32 function)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status - acpi_install_sci_handler(acpi_sci_handler - address, - void *context)) -ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status - acpi_remove_sci_handler(acpi_sci_handler - address)) + acpi_install_sci_handler(acpi_sci_handler + address, + void *context)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status - acpi_install_global_event_handler - (acpi_gbl_event_handler handler, - void *context)) + acpi_remove_sci_handler(acpi_sci_handler + address)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status - acpi_install_fixed_event_handler(u32 - acpi_event, - acpi_event_handler - handler, - void - *context)) + acpi_install_global_event_handler + (acpi_gbl_event_handler handler, + void *context)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status - acpi_remove_fixed_event_handler(u32 acpi_event, + acpi_install_fixed_event_handler(u32 + acpi_event, acpi_event_handler - handler)) -ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status - acpi_install_gpe_handler(acpi_handle - gpe_device, - u32 gpe_number, - u32 type, - acpi_gpe_handler - address, - void *context)) + handler, + void + *context)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status - acpi_install_gpe_raw_handler(acpi_handle - gpe_device, - u32 gpe_number, - u32 type, - acpi_gpe_handler - address, - void *context)) + acpi_remove_fixed_event_handler(u32 acpi_event, + acpi_event_handler + handler)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status - acpi_remove_gpe_handler(acpi_handle gpe_device, + acpi_install_gpe_handler(acpi_handle + gpe_device, u32 gpe_number, + u32 type, acpi_gpe_handler - address)) -ACPI_EXTERNAL_RETURN_STATUS(acpi_status - acpi_install_notify_handler(acpi_handle device, - u32 handler_type, - acpi_notify_handler - handler, + address, void *context)) +ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status + acpi_install_gpe_raw_handler(acpi_handle + gpe_device, + u32 gpe_number, + u32 type, + acpi_gpe_handler + address, + void *context)) +ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status + acpi_remove_gpe_handler(acpi_handle gpe_device, + u32 gpe_number, + acpi_gpe_handler + address)) ACPI_EXTERNAL_RETURN_STATUS(acpi_status - acpi_remove_notify_handler(acpi_handle device, + acpi_install_notify_handler(acpi_handle device, u32 handler_type, acpi_notify_handler - handler)) -ACPI_EXTERNAL_RETURN_STATUS(acpi_status - acpi_install_address_space_handler(acpi_handle - device, - acpi_adr_space_type - space_id, - acpi_adr_space_handler - handler, - acpi_adr_space_setup - setup, - void *context)) -ACPI_EXTERNAL_RETURN_STATUS(acpi_status - acpi_remove_address_space_handler(acpi_handle + handler, + void *context)) +ACPI_EXTERNAL_RETURN_STATUS(acpi_status + acpi_remove_notify_handler(acpi_handle device, + u32 handler_type, + acpi_notify_handler + handler)) +ACPI_EXTERNAL_RETURN_STATUS(acpi_status + acpi_install_address_space_handler(acpi_handle device, acpi_adr_space_type space_id, acpi_adr_space_handler - handler)) -ACPI_EXTERNAL_RETURN_STATUS(acpi_status - acpi_install_exception_handler - (acpi_exception_handler handler)) -ACPI_EXTERNAL_RETURN_STATUS(acpi_status - acpi_install_interface_handler - (acpi_interface_handler handler)) + handler, + acpi_adr_space_setup + setup, + void *context)) +ACPI_EXTERNAL_RETURN_STATUS(acpi_status + acpi_remove_address_space_handler(acpi_handle + device, + acpi_adr_space_type + space_id, + acpi_adr_space_handler + handler)) +ACPI_EXTERNAL_RETURN_STATUS(acpi_status + acpi_install_exception_handler + (acpi_exception_handler handler)) +ACPI_EXTERNAL_RETURN_STATUS(acpi_status + acpi_install_interface_handler + (acpi_interface_handler handler))/* * Global Lock interfaces
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 358/570 ACPICA: Allow address_space_handler Install and _REG execution as 2 separate steps
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 54c516aeb8b39eeae6450b7d8076d381568dca46 ]
ACPI-2.0 says that the EC op_region handler must be available immediately (like the standard default op_region handlers):
Quoting from the ACPI spec version 6.3: "6.5.4 _REG (Region) ...
2. OSPM must make Embedded Controller operation regions, accessed via the Embedded Controllers described in ECDT, available before executing any control method. These operation regions may become inaccessible after OSPM runs _REG(EmbeddedControl, 0)."
So the OS must probe the ECDT described EC and install the OpRegion handler before calling acpi_enable_subsystem() and acpi_initialize_objects().
This is a problem because calling acpi_install_address_space_handler() does not just install the op_region handler, it also runs the EC's _REG method. This _REG method may rely on initialization done by the _INI methods of one of the PCI / _SB root devices.
For the other early/default op_region handlers the op_region handler install and the _REG execution is split into 2 separate steps:
1. acpi_ev_install_region_handlers(), called early from acpi_load_tables()
2. acpi_ev_initialize_op_regions(), called from acpi_initialize_objects()
To fix the EC op_region issue, add 2 bew functions:
1. acpi_install_address_space_handler_no_reg()
2. acpi_execute_reg_methods()
to allow doing things in 2 steps for other op_region handlers, like the EC handler, too.
Note that the comment describing acpi_ev_install_region_handlers() even has an alinea describing this problem. Using the new methods allows users to avoid this problem.
Stable-dep-of: f6484cadbcaf ("ACPI: EC: clean up handlers on probe failure in acpi_ec_setup()")
--- drivers/acpi/acpica/evxfregn.c | 92 +++++++++++++++++++++++++++++++--- include/acpi/acpixf.h | 10 ++++ 2 files changed, 95 insertions(+), 7 deletions(-)
drivers/acpi/acpica/evxfregn.c +85 -7
@@ -20,13 +20,14 @@ ACPI_MODULE_NAME("evxfregn")/******************************************************************************* * -* FUNCTION: acpi_install_address_space_handler +* FUNCTION: acpi_install_address_space_handler_internal * * PARAMETERS: device - Handle for the device * space_id - The address space ID * handler - Address of the handler * setup - Address of the setup function * context - Value passed to the handler on each access +* Run_reg - Run _REG methods for this address space? * * RETURN: Status *
@@ -37,13 +38,16 @@ ACPI_MODULE_NAME("evxfregn")* are executed here, and these methods can only be safely executed after * the default handlers have been installed and the hardware has been * initialized (via acpi_enable_subsystem.) +* To avoid this problem pass FALSE for Run_Reg and later on call +* acpi_execute_reg_methods() to execute _REG. * ******************************************************************************/ -acpi_status -acpi_install_address_space_handler (acpi_handle device, -acpi_adr_space_type space_id, -acpi_adr_space_handler handler, -acpi_adr_space_setup setup,void *context) +static acpi_status +acpi_install_address_space_handler_internal (acpi_handle device, +acpi_adr_space_type space_id, +acpi_adr_space_handler handler, +acpi_adr_space_setup setup, +void *context,u8 run_reg) {struct acpi_namespace_node *node;acpi_status status;
@@ -80,14 +84,40 @@ acpi_install_address_space_handler(acpi_handle device,/* Run all _REG methods for this address space */ -acpi_ev_execute_reg_methods (node, space_id,ACPI_REG_CONNECT ); +if (run_reg) { +acpi_ev_execute_reg_methods (node, space_id,ACPI_REG_CONNECT ); + } unlock_and_exit: (void )acpi_ut_release_mutex (ACPI_MTX_NAMESPACE );return_ACPI_STATUS (status); } +acpi_status +acpi_install_address_space_handler (acpi_handle device, +acpi_adr_space_type space_id, +acpi_adr_space_handler handler, +acpi_adr_space_setup setup,void *context) +{ +return acpi_install_address_space_handler_internal (device, space_id, + handler, setup, + context, TRUE); +} +ACPI_EXPORT_SYMBOL (acpi_install_address_space_handler) +acpi_status +acpi_install_address_space_handler_no_reg (acpi_handle device, +acpi_adr_space_type space_id, +acpi_adr_space_handler handler, +acpi_adr_space_setup setup, +void *context) +{ +return acpi_install_address_space_handler_internal (device, space_id, + handler, setup, + context, FALSE); +} + +ACPI_EXPORT_SYMBOL (acpi_install_address_space_handler_no_reg)/******************************************************************************* *
@@ -226,3 +256,51 @@ acpi_remove_address_space_handler(acpi_handle device, }ACPI_EXPORT_SYMBOL (acpi_remove_address_space_handler) +/******************************************************************************* +* +* FUNCTION: acpi_execute_reg_methods +* +* PARAMETERS: device - Handle for the device +* space_id - The address space ID +* +* RETURN: Status +* +* DESCRIPTION: Execute _REG for all op_regions of a given space_id. +* +******************************************************************************/ +acpi_status +acpi_execute_reg_methods (acpi_handle device,acpi_adr_space_type space_id) +{ +struct acpi_namespace_node *node; +acpi_status status; + +ACPI_FUNCTION_TRACE (acpi_execute_reg_methods); + +/* Parameter validation */ + +if (!device) { +return_ACPI_STATUS (AE_BAD_PARAMETER ); + } + + status =acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE ); +if (ACPI_FAILURE (status)) { +return_ACPI_STATUS (status); + } + +/* Convert and validate the device handle */ + + node =acpi_ns_validate_handle (device); +if (node) { + +/* Run all _REG methods for this address space */ + +acpi_ev_execute_reg_methods (node, space_id,ACPI_REG_CONNECT ); + }else { + status =AE_BAD_PARAMETER ; + } + + (void )acpi_ut_release_mutex (ACPI_MTX_NAMESPACE ); +return_ACPI_STATUS (status); +} + +ACPI_EXPORT_SYMBOL (acpi_execute_reg_methods)
include/acpi/acpixf.h +10 -0
@@ -650,6 +650,16 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_statusacpi_adr_space_setup setup, void *context)) +ACPI_EXTERNAL_RETURN_STATUS(acpi_status + acpi_install_address_space_handler_no_reg + (acpi_handle device, acpi_adr_space_type space_id, + acpi_adr_space_handler handler, + acpi_adr_space_setup setup, + void *context)) +ACPI_EXTERNAL_RETURN_STATUS(acpi_status + acpi_execute_reg_methods(acpi_handle device, + acpi_adr_space_type + space_id)) ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_remove_address_space_handler(acpi_handle device,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 359/570 ACPI: EC: Fix EC address space handler unregistration
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 a5072078dbfaa9d70130805766dfa34bbb7bf2a7 ]
When an ECDT table is present the EC address space handler gets registered on the root node. So to unregister it properly the unregister call also must be done on the root node.
Store the ACPI handle used for the acpi_install_address_space_handler() call and use te same handle for the acpi_remove_address_space_handler() call.
Stable-dep-of: f6484cadbcaf ("ACPI: EC: clean up handlers on probe failure in acpi_ec_setup()")
--- drivers/acpi/ec.c | 4 +++- drivers/acpi/internal.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +3 -1
@@ -1513,6 +1513,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device)return -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); + ec->address_space_handler_holder = ec->handle; }if (!device)
@@ -1564,7 +1565,8 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device)static void ec_remove_handlers (struct acpi_ec *ec) {if (test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) { -if (ACPI_FAILURE (acpi_remove_address_space_handler (ec->handle, +if (ACPI_FAILURE (acpi_remove_address_space_handler ( + ec->address_space_handler_holder,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler)))pr_err ("failed to remove space handler\n" );clear_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags);
drivers/acpi/internal.h +1 -0
@@ -168,6 +168,7 @@ static inline void acpi_early_processor_osc(void) {}-------------------------------------------------------------------------- */ struct acpi_ec {acpi_handle handle; +acpi_handle address_space_handler_holder;int gpe;int irq;unsigned long command_addr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 360/570 ACPI: EC: Fix ECDT probe ordering issues
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 ab4620f58d38206687b9f99d9d2cc1d5a2640985 ]
ACPI-2.0 says that the EC OpRegion handler must be available immediately (like the standard default OpRegion handlers):
Quoting from the ACPI spec version 6.3: "6.5.4 _REG (Region) ...
2. OSPM must make Embedded Controller operation regions, accessed via the Embedded Controllers described in ECDT, available before executing any control method. These operation regions may become inaccessible after OSPM runs _REG(EmbeddedControl, 0)."
So acpi_bus_init() calls acpi_ec_ecdt_probe(), which calls acpi_install_address_space_handler() to install the EC's OpRegion handler, early on.
This not only installs the OpRegion handler, but also calls the EC's _REG method. The _REG method call is a problem because it may rely on initialization done by the _INI methods of one of the PCI / _SB root devs, see for example: https://bugzilla.kernel.org/show_bug.cgi?id=214899 .
Generally speaking _REG methods are executed when the ACPI-device they are part of has a driver bound to it. Where as _INI methods must be executed at table load time (according to the spec). The problem here is that the early acpi_install_address_space_handler() call causes the _REG handler to run too early.
To allow fixing this the ACPICA code now allows to split the OpRegion handler installation and the executing of _REG into 2 separate steps.
This commit uses this ACPICA functionality to fix the EC probe ordering by delaying the executing of _REG for ECDT described ECs till the matching EC device in the DSDT gets parsed and acpi_ec_add() for it gets called. This moves the calling of _REG for the EC on devices with an ECDT to the same point in time where it is called on devices without an ECDT table.
Stable-dep-of: f6484cadbcaf ("ACPI: EC: clean up handlers on probe failure in acpi_ec_setup()")
--- drivers/acpi/ec.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
drivers/acpi/ec.c +18 -10
@@ -96,6 +96,7 @@ enum {EC_FLAGS_QUERY_GUARDING ,/* Guard for SCI_EVT check */ EC_FLAGS_EVENT_HANDLER_INSTALLED ,/* Event handler installed */ EC_FLAGS_EC_HANDLER_INSTALLED ,/* OpReg handler installed */ +EC_FLAGS_EC_REG_CALLED ,/* OpReg ACPI _REG method called */ EC_FLAGS_QUERY_METHODS_INSTALLED ,/* _Qxx handlers installed */ EC_FLAGS_STARTED ,/* Driver is started */ EC_FLAGS_STOPPED, /* Driver is stopped */
@@ -1484,6 +1485,7 @@ static bool install_gpio_irq_event_handler(struct acpi_ec *ec)* ec_install_handlers - Install service callbacks and register query methods. * @ec: Target EC. * @device: ACPI device object corresponding to @ec. +* @call_reg: If _REG should be called to notify OpRegion availability * * Install a handler for the EC address space type unless it has been installed * already. If @device is not NULL, also look for EC query methods in the
@@ -1496,7 +1498,8 @@ static bool install_gpio_irq_event_handler(struct acpi_ec *ec)* -EPROBE_DEFER if GPIO IRQ acquisition needs to be deferred, * or 0 (success) otherwise. */ -static int ec_install_handlers (struct acpi_ec *ec,struct acpi_device *device) +static int ec_install_handlers (struct acpi_ec *ec,struct acpi_device *device, +bool call_reg) {acpi_status status;
@@ -1504,10 +1507,10 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device)if (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler (ec->handle, -ACPI_ADR_SPACE_EC , - &acpi_ec_space_handler, -NULL , ec); + status =acpi_install_address_space_handler_no_reg (ec->handle, +ACPI_ADR_SPACE_EC , + &acpi_ec_space_handler, +NULL , ec);if (ACPI_FAILURE (status)) {acpi_ec_stop (ec, false);return -ENODEV ;
@@ -1516,6 +1519,11 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device) ec->address_space_handler_holder = ec->handle; } +if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) { +acpi_execute_reg_methods (ec->handle,ACPI_ADR_SPACE_EC ); +set_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags); + } +if (!device)return 0 ;
@@ -1602,11 +1610,11 @@ static void ec_remove_handlers(struct acpi_ec *ec) } } -static int acpi_ec_setup (struct acpi_ec *ec,struct acpi_device *device) +static int acpi_ec_setup (struct acpi_ec *ec,struct acpi_device *device,bool call_reg) {int ret; - ret =ec_install_handlers (ec, device); + ret =ec_install_handlers (ec, device, call_reg);if (ret)return ret;
@@ -1668,7 +1676,7 @@ static int acpi_ec_add(struct acpi_device *device) } } - ret =acpi_ec_setup (ec, device); + ret =acpi_ec_setup (ec, device, true);if (ret) goto err;
@@ -1788,7 +1796,7 @@ void __init acpi_ec_dsdt_probe(void)* At this point, the GPE is not fully initialized, so do not to * handle the events. */ - ret =acpi_ec_setup (ec,NULL ); + ret =acpi_ec_setup (ec,NULL , true);if (ret) {acpi_ec_free (ec);return ;
@@ -1952,7 +1960,7 @@ void __init acpi_ec_ecdt_probe(void)* At this point, the namespace is not initialized, so do not find * the namespace objects, or handle the events. */ - ret =acpi_ec_setup (ec,NULL ); + ret =acpi_ec_setup (ec,NULL , false);if (ret) {acpi_ec_free (ec); goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 361/570 ACPI: EC: Install address space handler at the namespace root
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 60fa6ae6e6d09e377fce6f8d9b6f6a4d88769f63 ]
It is reported that _DSM evaluation fails in ucsi_acpi_dsm() on Lenovo IdeaPad Pro 5 due to a missing address space handler for the EC address space:
ACPI Error: No handler for Region [ECSI] (000000007b8176ee) [EmbeddedControl] (20230628/evregion-130)
This happens because if there is no ECDT, the EC driver only registers the EC address space handler for operation regions defined in the EC device scope of the ACPI namespace while the operation region being accessed by the _DSM in question is located beyond that scope.
To address this, modify the ACPI EC driver to install the EC address space handler at the root of the ACPI namespace for the first EC that can be found regardless of whether or not an ECDT is present.
Note that this change is consistent with some examples in the ACPI specification in which EC operation regions located outside the EC device scope are used (for example, see Section 9.17.15 in ACPI 6.5), so the current behavior of the EC driver is arguably questionable.
Stable-dep-of: f6484cadbcaf ("ACPI: EC: clean up handlers on probe failure in acpi_ec_setup()")
--- drivers/acpi/ec.c | 25 ++++++++++++++++--------- drivers/acpi/internal.h | 1 - 2 files changed, 16 insertions(+), 10 deletions(-)
drivers/acpi/ec.c +16 -9
@@ -1501,13 +1501,14 @@ static bool install_gpio_irq_event_handler(struct acpi_ec *ec)static int ec_install_handlers (struct acpi_ec *ec,struct acpi_device *device,bool call_reg) { +acpi_handle scope_handle = ec == first_ec ?ACPI_ROOT_OBJECT : ec->handle;acpi_status status;acpi_ec_start (ec, false);if (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (scope_handle,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);
@@ -1516,11 +1517,10 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,return -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) { -acpi_execute_reg_methods (ec->handle,ACPI_ADR_SPACE_EC ); +acpi_execute_reg_methods (scope_handle,ACPI_ADR_SPACE_EC );set_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags); }
@@ -1572,10 +1572,13 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,static void ec_remove_handlers (struct acpi_ec *ec) { +acpi_handle scope_handle = ec == first_ec ?ACPI_ROOT_OBJECT : ec->handle; +if (test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {if (ACPI_FAILURE (acpi_remove_address_space_handler ( - ec->address_space_handler_holder, -ACPI_ADR_SPACE_EC , &acpi_ec_space_handler))) + scope_handle, +ACPI_ADR_SPACE_EC , + &acpi_ec_space_handler)))pr_err ("failed to remove space handler\n" );clear_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); }
@@ -1614,14 +1617,18 @@ static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device, bool ca {int ret; - ret =ec_install_handlers (ec, device, call_reg); -if (ret) -return ret; -/* First EC capable of handling transactions */ if (!first_ec) first_ec = ec; + ret =ec_install_handlers (ec, device, call_reg); +if (ret) { +if (ec == first_ec) + first_ec =NULL ; + +return ret; + } +pr_info ("EC_CMD/EC_SC=0x%lx, EC_DATA=0x%lx\n" , ec->command_addr, ec->data_addr);
drivers/acpi/internal.h +0 -1
@@ -168,7 +168,6 @@ static inline void acpi_early_processor_osc(void) {}-------------------------------------------------------------------------- */ struct acpi_ec {acpi_handle handle; -acpi_handle address_space_handler_holder;int gpe;int irq;unsigned long command_addr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 362/570 ACPI: EC: clean up handlers on probe failure in acpi_ec_setup()
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 f6484cadbcaf26b5844b51bd7307a663dda48ef6 ]
When ec_install_handlers() returns -EPROBE_DEFER on reduced-hardware platforms, it has already started the EC and installed the address space handler with the struct acpi_ec pointer as handler context. However, acpi_ec_setup() propagates the error without any cleanup.
The caller acpi_ec_add() then frees the struct acpi_ec for non-boot instances, leaving a dangling handler context in ACPICA.
Any subsequent AML evaluation that accesses an EC OpRegion field dispatches into acpi_ec_space_handler() with the freed pointer, causing a use-after-free:
BUG: KASAN: slab-use-after-free in mutex_lock (kernel/locking/mutex.c:289) Write of size 8 at addr ffff88800721de38 by task init/1 Call Trace: <TASK> mutex_lock (kernel/locking/mutex.c:289) acpi_ec_space_handler (drivers/acpi/ec.c:1362) acpi_ev_address_space_dispatch (drivers/acpi/acpica/evregion.c:293) acpi_ex_access_region (drivers/acpi/acpica/exfldio.c:246) acpi_ex_field_datum_io (drivers/acpi/acpica/exfldio.c:509) acpi_ex_extract_from_field (drivers/acpi/acpica/exfldio.c:700) acpi_ex_read_data_from_field (drivers/acpi/acpica/exfield.c:327) acpi_ex_resolve_node_to_value (drivers/acpi/acpica/exresolv.c:392) </TASK> Allocated by task 1: acpi_ec_alloc (drivers/acpi/ec.c:1424) acpi_ec_add (drivers/acpi/ec.c:1692) Freed by task 1: kfree (mm/slub.c:6876) acpi_ec_add (drivers/acpi/ec.c:1751)
The bug triggers on reduced-hardware EC platforms (ec->gpe < 0) when the GPIO IRQ provider defers probing. Once the stale handler exists, any unprivileged sysfs read that causes AML to touch an EC OpRegion (battery, thermal, backlight) exercises the dangling pointer.
Fix this by calling ec_remove_handlers() in the error path of acpi_ec_setup() before clearing first_ec. ec_remove_handlers() checks each EC_FLAGS_* bit before acting, so it is safe to call regardless of how far ec_install_handlers() progressed:
-ENODEV (handler not installed): only calls acpi_ec_stop() -EPROBE_DEFER (handler installed): removes handler, stops EC
--- drivers/acpi/ec.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/acpi/ec.c +2 -0
@@ -1623,6 +1623,8 @@ static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device, bool ca ret =ec_install_handlers (ec, device, call_reg);if (ret) { +ec_remove_handlers (ec); +if (ec == first_ec) first_ec =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 363/570 hwmon: (adm1177) fix sysfs ABI violation and current unit conversion
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanman Pradhan <[email protected]>
[ Upstream commit bf08749a6abb6d1959bfdc0edc32c640df407558 ]
The adm1177 driver exposes the current alert threshold through hwmon_curr_max_alarm. This violates the hwmon sysfs ABI, where *_alarm attributes are read-only status flags and writable thresholds must use currN_max.
The driver also stores the threshold internally in microamps, while currN_max is defined in milliamps. Convert the threshold accordingly on both the read and write paths.
Widen the cached threshold and related calculations to 64 bits so that small shunt resistor values do not cause truncation or overflow. Also use 64-bit arithmetic for the mA/uA conversions, clamp writes to the range the hardware can represent, and propagate failures from adm1177_write_alert_thr() instead of silently ignoring them.
Update the hwmon documentation to reflect the attribute rename and the correct units returned by the driver.
--- Documentation/hwmon/adm1177.rst | 8 ++--- drivers/hwmon/adm1177.c | 54 +++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 27 deletions(-)
Documentation/hwmon/adm1177.rst +4 -4
@@ -27,10 +27,10 @@ for details. Sysfs entries ------------- -The following attributes are supported. Current maxim attribute +The following attributes are supported. Current maximum attribute is read-write, all other attributes are read-only. -in0_input Measured voltage in microvolts. +in0_input Measured voltage in millivolts. -curr1_input Measured current in microamperes. -curr1_max_alarm Overcurrent alarm in microamperes. +curr1_input Measured current in milliamperes. +curr1_max Overcurrent shutdown threshold in milliamperes.
drivers/hwmon/adm1177.c +31 -23
111 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 364/570 sysctl: fix uninitialized variable in proc_do_large_bitmap
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Buerg <[email protected]>
[ Upstream commit f63a9df7e3f9f842945d292a19d9938924f066f9 ]
proc_do_large_bitmap() does not initialize variable c, which is expected to be set to a trailing character by proc_get_long().
However, proc_get_long() only sets c when the input buffer contains a trailing character after the parsed value.
If c is not initialized it may happen to contain a '-'. If this is the case proc_do_large_bitmap() expects to be able to parse a second part of the input buffer. If there is no second part an unjustified -EINVAL will be returned.
Initialize c to 0 to prevent returning -EINVAL on valid input.
--- kernel/sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sysctl.c +1 -1
@@ -1528,7 +1528,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,unsigned long bitmap_len = table->maxlen;unsigned long *bitmap = *(unsigned long **) table->data;unsigned long *tmp_bitmap =NULL ; -char tr_a[] = {'-' ,',' ,'\n' }, tr_b[] = {',' ,'\n' ,0 }, c; +char tr_a[] = {'-' ,',' ,'\n' }, tr_b[] = {',' ,'\n' ,0 }, c =0 ;if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { *lenp =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 365/570 ASoC: adau1372: Fix unchecked clk_prepare_enable() return value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jihed Chaibi <[email protected]>
[ Upstream commit 326fe8104a4020d30080d37ac8b6b43893cdebca ]
adau1372_set_power() calls clk_prepare_enable() but discards the return value. If the clock enable fails, the driver proceeds to access registers on unpowered hardware, potentially causing silent corruption.
Make adau1372_set_power() return int and propagate the error from clk_prepare_enable(). Update adau1372_set_bias_level() to return the error directly for the STANDBY and OFF cases.
--- sound/soc/codecs/adau1372.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
sound/soc/codecs/adau1372.c +10 -7
@@ -781,15 +781,18 @@ static void adau1372_enable_pll(struct adau1372 *adau1372)dev_err (adau1372->dev,"Failed to lock PLL\n" ); } -static void adau1372_set_power (struct adau1372 *adau1372,bool enable) +static int adau1372_set_power (struct adau1372 *adau1372,bool enable) {if (adau1372->enabled == enable) -return ; +return 0 ;if (enable) {unsigned int clk_ctrl =ADAU1372_CLK_CTRL_MCLK_EN ; +int ret; -clk_prepare_enable (adau1372->mclk); + ret =clk_prepare_enable (adau1372->mclk); +if (ret) +return ret;if (adau1372->pd_gpio)gpiod_set_value (adau1372->pd_gpio,0 );
@@ -828,6 +831,8 @@ static void adau1372_set_power(struct adau1372 *adau1372, bool enable) } adau1372->enabled = enable; + +return 0 ; } static int adau1372_set_bias_level(struct snd_soc_component *component,
@@ -841,11 +846,9 @@ static int adau1372_set_bias_level(struct snd_soc_component *component,case SND_SOC_BIAS_PREPARE :break ;case SND_SOC_BIAS_STANDBY : -adau1372_set_power (adau1372, true); -break ; +return adau1372_set_power (adau1372, true);case SND_SOC_BIAS_OFF : -adau1372_set_power (adau1372, false); -break ; +return adau1372_set_power (adau1372, false); }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 366/570 ASoC: adau1372: Fix clock leak on PLL lock failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jihed Chaibi <[email protected]>
[ Upstream commit bfe6a264effcb6fe99ad7ceaf9e8c7439fc9555b ]
adau1372_enable_pll() was a void function that logged a dev_err() on PLL lock timeout but did not propagate the error. As a result, adau1372_set_power() would continue with adau1372->enabled set to true despite the PLL being unlocked, and the mclk left enabled with no corresponding disable on the error path.
Convert adau1372_enable_pll() to return int, using -ETIMEDOUT on lock timeout and propagating regmap errors directly. In adau1372_set_power(), check the return value and unwind in reverse order: restore regcache to cache-only mode, reassert GPIO power-down, and disable the clock before returning the error.
--- sound/soc/codecs/adau1372.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
sound/soc/codecs/adau1372.c +14 -3
@@ -761,7 +761,7 @@ static int adau1372_startup(struct snd_pcm_substream *substream, struct snd_soc_return 0 ; } -static void adau1372_enable_pll (struct adau1372 *adau1372) +static int adau1372_enable_pll (struct adau1372 *adau1372) {unsigned int val, timeout =0 ;int ret;
@@ -777,8 +777,12 @@ static void adau1372_enable_pll(struct adau1372 *adau1372) timeout++; }while (!(val &1 ) && timeout <3 ); -if (ret <0 || !(val &1 )) +if (ret <0 || !(val &1 )) {dev_err (adau1372->dev,"Failed to lock PLL\n" ); +return ret <0 ? ret : -ETIMEDOUT ; + } + +return 0 ; }static int adau1372_set_power (struct adau1372 *adau1372,bool enable)
@@ -806,7 +810,14 @@ static int adau1372_set_power(struct adau1372 *adau1372, bool enable)* accessed. */ if (adau1372->use_pll) { -adau1372_enable_pll (adau1372); + ret =adau1372_enable_pll (adau1372); +if (ret) { +regcache_cache_only (adau1372->regmap, true); +if (adau1372->pd_gpio) +gpiod_set_value (adau1372->pd_gpio,1 ); +clk_disable_unprepare (adau1372->mclk); +return ret; + } clk_ctrl |=ADAU1372_CLK_CTRL_CLKSRC ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 367/570 spi: spi-fsl-lpspi: fix teardown order issue (UAF)
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
[ Upstream commit b341c1176f2e001b3adf0b47154fc31589f7410e ]
There is a teardown order issue in the driver. The SPI controller is registered using devm_spi_register_controller(), which delays unregistration of the SPI controller until after the fsl_lpspi_remove() function returns.
As the fsl_lpspi_remove() function synchronously tears down the DMA channels, a running SPI transfer triggers the following NULL pointer dereference due to use after free:
| fsl_lpspi 42550000.spi: I/O Error in DMA RX
| Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 [...]
| Call trace: | fsl_lpspi_dma_transfer+0x260/0x340 [spi_fsl_lpspi] | fsl_lpspi_transfer_one+0x198/0x448 [spi_fsl_lpspi] | spi_transfer_one_message+0x49c/0x7c8 | __spi_pump_transfer_message+0x120/0x420 | __spi_sync+0x2c4/0x520 | spi_sync+0x34/0x60 | spidev_message+0x20c/0x378 [spidev] | spidev_ioctl+0x398/0x750 [spidev]
[...]
Switch from devm_spi_register_controller() to spi_register_controller() in fsl_lpspi_probe() and add the corresponding spi_unregister_controller() in fsl_lpspi_remove().
--- drivers/spi/spi-fsl-lpspi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-fsl-lpspi.c +2 -1
@@ -914,7 +914,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev)enable_irq (irq); } - ret =devm_spi_register_controller (&pdev->dev, controller); + ret =spi_register_controller (controller);if (ret <0 ) {dev_err_probe (&pdev->dev, ret,"spi_register_controller error\n" ); goto free_dma;
@@ -943,6 +943,7 @@ static int fsl_lpspi_remove(struct platform_device *pdev)struct fsl_lpspi_data *fsl_lpspi =spi_controller_get_devdata (controller); +spi_unregister_controller (controller);fsl_lpspi_dma_exit (controller);pm_runtime_dont_use_autosuspend (fsl_lpspi->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 368/570 s390/syscalls: Add spectre boundary for syscall dispatch table
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]>
commit 48b8814e25d073dd84daf990a879a820bad2bcbd upstream.
The s390 syscall number is directly controlled by userspace, but does not have an array_index_nospec() boundary to prevent access past the syscall function pointer tables.
--- arch/s390/kernel/syscall.c | 2 ++ 1 file changed, 2 insertions(+)
arch/s390/kernel/syscall.c +2 -0
@@ -13,6 +13,7 @@*/ #include <linux/errno.h> +#include <linux/nospec.h> #include <linux/sched.h> #include <linux/mm.h> #include <linux/fs.h>
@@ -141,6 +142,7 @@ static void do_syscall(struct pt_regs *rif (likely (nr >= NR_syscalls)) goto out;do { + nr =array_index_nospec (nr, NR_syscalls); regs->gprs[2 ] = current->thread.sys_call_table[nr](regs); }while (test_and_clear_pt_regs_flag (regs,PIF_EXECVE_PGSTE_RESTART )); out:
Greg Kroah-Hartman
maintainerPATCH 369/570 s390/barrier: Make array_index_mask_nospec() __always_inline
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasily Gorbik <[email protected]>
commit c5c0a268b38adffbb2e70e6957017537ff54c157 upstream.
Mark array_index_mask_nospec() as __always_inline to guarantee the mitigation is emitted inline regardless of compiler inlining decisions.
--- arch/s390/include/asm/barrier.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/include/asm/barrier.h +2 -2
@@ -56,8 +56,8 @@ do { \* @size: number of elements in array */ #define array_index_mask_nospec array_index_mask_nospec -static inline unsigned long array_index_mask_nospec (unsigned long index, -unsigned long size) +static __always_inline unsigned long array_index_mask_nospec (unsigned long index, +unsigned long size) {unsigned long mask;
Greg Kroah-Hartman
maintainerPATCH 370/570 can: gw: fix OOB heap access in cgw_csum_crc8_rel()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Norouzi <[email protected]>
commit b9c310d72783cc2f30d103eed83920a5a29c671a upstream.
cgw_csum_crc8_rel() correctly computes bounds-safe indices via calc_idx():
int from = calc_idx(crc8->from_idx, cf->len);
int to = calc_idx(crc8->to_idx, cf->len);
int res = calc_idx(crc8->result_idx, cf->len);
if (from < 0 || to < 0 || res < 0)
return;However, the loop and the result write then use the raw s8 fields directly instead of the computed variables:
for (i = crc8->from_idx; ...) /* BUG: raw negative index */
cf->data[crc8->result_idx] = ...; /* BUG: raw negative index */With from_idx = to_idx = result_idx = -64 on a 64-byte CAN FD frame, calc_idx(-64, 64) = 0 so the guard passes, but the loop iterates with i = -64, reading cf->data[-64], and the write goes to cf->data[-64]. This write might end up to 56 (7.0-rc) or 40 (<= 6.19) bytes before the start of the canfd_frame on the heap.
The companion function cgw_csum_xor_rel() uses from/to/res correctly throughout; fix cgw_csum_crc8_rel() to match.
Confirmed with KASAN on linux-7.0-rc2:
BUG: KASAN: slab-out-of-bounds in cgw_csum_crc8_rel+0x515/0x5b0 Read of size 1 at addr ffff8880076619c8 by task poc_cgw_oob/62
To configure the can-gw crc8 checksums CAP_NET_ADMIN is needed.
--- net/can/gw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/can/gw.c +3 -3
@@ -374,10 +374,10 @@ static void cgw_csum_crc8_rel(struct canreturn ;if (from <= to) { -for (i = crc8->from_idx; i <= crc8->to_idx; i++) +for (i = from; i <= to; i++) crc = crc8->crctab[crc ^ cf->data[i]]; }else { -for (i = crc8->from_idx; i >= crc8->to_idx; i--) +for (i = from; i >= to; i--) crc = crc8->crctab[crc ^ cf->data[i]]; }
@@ -396,7 +396,7 @@ static void cgw_csum_crc8_rel(struct canbreak ; } - cf->data[crc8->result_idx] = crc ^ crc8->final_xor_val; + cf->data[res] = crc ^ crc8->final_xor_val; } static void cgw_csum_crc8_pos(struct canfd_frame *cf,
Greg Kroah-Hartman
maintainerPATCH 371/570 cpufreq: conservative: Reset requested_freq on limits change
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viresh Kumar <[email protected]>
commit 6a28fb8cb28b9eb39a392e531d938a889eacafc5 upstream.
A recently reported issue highlighted that the cached requested_freq is not guaranteed to stay in sync with policy->cur. If the platform changes the actual CPU frequency after the governor sets one (e.g. due to platform-specific frequency scaling) and a re-sync occurs later, policy->cur may diverge from requested_freq.
This can lead to incorrect behavior in the conservative governor. For example, the governor may assume the CPU is already running at the maximum frequency and skip further increases even though there is still headroom.
Avoid this by resetting the cached requested_freq to policy->cur on detecting a change in policy limits.
--- drivers/cpufreq/cpufreq_conservative.c | 12 ++++++++++++ drivers/cpufreq/cpufreq_governor.c | 3 +++ drivers/cpufreq/cpufreq_governor.h | 1 + 3 files changed, 16 insertions(+)
drivers/cpufreq/cpufreq_conservative.c +12 -0
@@ -311,6 +311,17 @@ static void cs_start(struct cpufreq_poli dbs_info->requested_freq = policy->cur; } +static void cs_limits (struct cpufreq_policy *policy) +{ +struct cs_policy_dbs_info *dbs_info =to_dbs_info (policy->governor_data); + +/* +* The limits have changed, so may have the current frequency. Reset +* requested_freq to avoid any unintended outcomes due to the mismatch. +*/ + dbs_info->requested_freq = policy->cur; +} +static struct dbs_governor cs_governor = { .gov =CPUFREQ_DBS_GOVERNOR_INITIALIZER ("conservative" ), .kobj_type = { .default_attrs = cs_attributes },
@@ -320,6 +331,7 @@ static struct dbs_governor cs_governor = .init = cs_init, .exit = cs_exit, .start = cs_start, + .limits = cs_limits, };#define CPU_FREQ_GOV_CONSERVATIVE (cs_governor.gov)
drivers/cpufreq/cpufreq_governor.c +3 -0
@@ -561,6 +561,7 @@ EXPORT_SYMBOL_GPL(cpufreq_dbs_governor_svoid cpufreq_dbs_governor_limits (struct cpufreq_policy *policy) { +struct dbs_governor *gov =dbs_governor_of (policy);struct policy_dbs_info *policy_dbs;/* Protect gov->gdbs_data against cpufreq_dbs_governor_exit() */
@@ -572,6 +573,8 @@ void cpufreq_dbs_governor_limits(structmutex_lock (&policy_dbs->update_mutex);cpufreq_policy_apply_limits (policy);gov_update_sample_delay (policy_dbs,0 ); +if (gov->limits) + gov->limits (policy);mutex_unlock (&policy_dbs->update_mutex); out:
drivers/cpufreq/cpufreq_governor.h +1 -0
@@ -140,6 +140,7 @@ struct dbs_governor {int (*init)(struct dbs_data *dbs_data);void (*exit)(struct dbs_data *dbs_data);void (*start)(struct cpufreq_policy *policy); +void (*limits)(struct cpufreq_policy *policy); };static inline struct dbs_governor *dbs_governor_of (struct cpufreq_policy *policy)
Greg Kroah-Hartman
maintainerPATCH 372/570 media: mc, v4l2: serialize REINIT and REQBUFS with req_queue_mutex
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuchan Nam <[email protected]>
commit bef4f4a88b73e4cc550d25f665b8a9952af22773 upstream.
MEDIA_REQUEST_IOC_REINIT can run concurrently with VIDIOC_REQBUFS(0) queue teardown paths. This can race request object cleanup against vb2 queue cancellation and lead to use-after-free reports.
We already serialize request queueing against STREAMON/OFF with req_queue_mutex. Extend that serialization to REQBUFS, and also take the same mutex in media_request_ioctl_reinit() so REINIT is in the same exclusion domain.
This keeps request cleanup and queue cancellation from running in parallel for request-capable devices.
--- drivers/media/mc/mc-request.c | 5 +++++ drivers/media/v4l2-core/v4l2-ioctl.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/media/mc/mc-request.c +5 -0
@@ -190,6 +190,8 @@ static long media_request_ioctl_reinit(sstruct media_device *mdev = req->mdev;unsigned long flags; +mutex_lock (&mdev->req_queue_mutex); +spin_lock_irqsave (&req->lock, flags);if (req->state !=MEDIA_REQUEST_STATE_IDLE && req->state !=MEDIA_REQUEST_STATE_COMPLETE ) {
@@ -197,6 +199,7 @@ static long media_request_ioctl_reinit(s"request: %s not in idle or complete state, cannot reinit\n" , req->debug_str);spin_unlock_irqrestore (&req->lock, flags); +mutex_unlock (&mdev->req_queue_mutex);return -EBUSY ; }if (req->access_count) {
@@ -204,6 +207,7 @@ static long media_request_ioctl_reinit(s"request: %s is being accessed, cannot reinit\n" , req->debug_str);spin_unlock_irqrestore (&req->lock, flags); +mutex_unlock (&mdev->req_queue_mutex);return -EBUSY ; } req->state =MEDIA_REQUEST_STATE_CLEANING ;
@@ -214,6 +218,7 @@ static long media_request_ioctl_reinit(sspin_lock_irqsave (&req->lock, flags); req->state =MEDIA_REQUEST_STATE_IDLE ;spin_unlock_irqrestore (&req->lock, flags); +mutex_unlock (&mdev->req_queue_mutex);return 0 ; }
drivers/media/v4l2-core/v4l2-ioctl.c +3 -2
@@ -2926,13 +2926,14 @@ static long __video_do_ioctl(struct file vfh = file->private_data;/* -* We need to serialize streamon/off with queueing new requests. +* We need to serialize streamon/off/reqbufs with queueing new requests. * These ioctls may trigger the cancellation of a streaming * operation, and that should not be mixed with queueing a new * request at the same time. */ if (v4l2_device_supports_requests (vfd->v4l2_dev) && - (cmd ==VIDIOC_STREAMON || cmd ==VIDIOC_STREAMOFF )) { + (cmd ==VIDIOC_STREAMON || cmd ==VIDIOC_STREAMOFF || + cmd ==VIDIOC_REQBUFS )) { req_queue_lock = &vfd->v4l2_dev->mdev->req_queue_mutex;if (mutex_lock_interruptible (req_queue_lock))
Greg Kroah-Hartman
maintainerPATCH 373/570 virtio_net: Fix UAF on dst_ops when IFF_XMIT_DST_RELEASE is cleared and napi_tx is false
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: xietangxin <[email protected]>
commit ba8bda9a0896746053aa97ac6c3e08168729172c upstream.
A UAF issue occurs when the virtio_net driver is configured with napi_tx=N and the device's IFF_XMIT_DST_RELEASE flag is cleared
(e.g., during the configuration of tc route filter rules).
When IFF_XMIT_DST_RELEASE is removed from the net_device, the network stack expects the driver to hold the reference to skb->dst until the packet is fully transmitted and freed. In virtio_net with napi_tx=N, skbs may remain in the virtio transmit ring for an extended period.
If the network namespace is destroyed while these skbs are still pending, the corresponding dst_ops structure has freed. When a subsequent packet is transmitted, free_old_xmit() is triggered to clean up old skbs. It then calls dst_release() on the skb associated with the stale dst_entry. Since the dst_ops (referenced by the dst_entry) has already been freed, a UAF kernel paging request occurs.
fix it by adds skb_dst_drop(skb) in start_xmit to explicitly release the dst reference before the skb is queued in virtio_net.
Call Trace: Unable to handle kernel paging request at virtual address ffff80007e150000 CPU: 2 UID: 0 PID: 6236 Comm: ping Kdump: loaded Not tainted 7.0.0-rc1+ #6 PREEMPT ... percpu_counter_add_batch+0x3c/0x158 lib/percpu_counter.c:98 (P) dst_release+0xe0/0x110 net/core/dst.c:177 skb_release_head_state+0xe8/0x108 net/core/skbuff.c:1177 sk_skb_reason_drop+0x54/0x2d8 net/core/skbuff.c:1255 dev_kfree_skb_any_reason+0x64/0x78 net/core/dev.c:3469 napi_consume_skb+0x1c4/0x3a0 net/core/skbuff.c:1527 __free_old_xmit+0x164/0x230 drivers/net/virtio_net.c:611 [virtio_net] free_old_xmit drivers/net/virtio_net.c:1081 [virtio_net] start_xmit+0x7c/0x530 drivers/net/virtio_net.c:3329 [virtio_net] ...
Reproduction Steps:
NETDEV="enp3s0"
config_qdisc_route_filter() {
tc qdisc del dev $NETDEV root
tc qdisc add dev $NETDEV root handle 1: prio tc filter add dev $NETDEV parent 1:0 \
protocol ip prio 100 route to 100 flowid 1:1
ip route add 192.168.1.100/32 dev $NETDEV realm 100
}
test_ns() {
ip netns add testns
ip link set $NETDEV netns testns
ip netns exec testns ifconfig $NETDEV 10.0.32.46/24 ip netns exec testns ping -c 1 10.0.32.1
ip netns del testns
}
config_qdisc_route_filter
test_ns
sleep 2test_ns
--- drivers/net/virtio_net.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/virtio_net.c +1 -0
@@ -1831,6 +1831,7 @@ static netdev_tx_t start_xmit(struct sk_/* Don't wait up for transmitted skbs to be freed. */ if (!use_napi) {skb_orphan (skb); +skb_dst_drop (skb);nf_reset_ct (skb); }
Greg Kroah-Hartman
maintainerPATCH 374/570 erofs: add GFP_NOIO in the bio completion if needed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiucheng Xu <[email protected]>
commit c23df30915f83e7257c8625b690a1cece94142a0 upstream.
The bio completion path in the process context (e.g. dm-verity) will directly call into decompression rather than trigger another workqueue context for minimal scheduling latencies, which can then call vm_map_ram() with GFP_KERNEL.
Due to insufficient memory, vm_map_ram() may generate memory swapping I/O, which can cause submit_bio_wait to deadlock in some scenarios.
Trimmed down the call stack, as follows:
f2fs_submit_read_io
submit_bio //bio_list is initialized.
mmc_blk_mq_recovery
z_erofs_endio
vm_map_ram
__pte_alloc_kernel
__alloc_pages_direct_reclaim
shrink_folio_list
__swap_writepage
submit_bio_wait //bio_list is non-NULL, hang!!!
Use memalloc_noio_{save,restore}() to wrap up this path.
--- fs/erofs/zdata.c | 3 +++ 1 file changed, 3 insertions(+)
fs/erofs/zdata.c +3 -0
@@ -782,6 +782,7 @@ static void z_erofs_decompress_kickoff(s bool sync, int bios) {struct erofs_sb_info *const sbi =EROFS_SB (io->sb); +int gfp_flag;/* wake up the caller thread for sync decompression */ if (sync) {
@@ -802,7 +803,9 @@ static void z_erofs_decompress_kickoff(s sbi->opt.readahead_sync_decompress = true;return ; } + gfp_flag =memalloc_noio_save ();z_erofs_decompressqueue_work (&io->u.work); +memalloc_noio_restore (gfp_flag); }static bool z_erofs_page_is_invalidated (struct page *page)
Greg Kroah-Hartman
maintainerPATCH 375/570 alarmtimer: Fix argument order in alarm_timer_forward()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhan Xusheng <[email protected]>
commit 5d16467ae56343b9205caedf85e3a131e0914ad8 upstream.
alarm_timer_forward() passes arguments to alarm_forward() in the wrong order:
alarm_forward(alarm, timr->it_interval, now);
However, alarm_forward() is defined as:
u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
and uses the second argument as the current time:
delta = ktime_sub(now, alarm->node.expires);
Passing the interval as "now" results in incorrect delta computation, which can lead to missed expirations or incorrect overrun accounting.
This issue has been present since the introduction of alarm_timer_forward().
Fix this by swapping the arguments.
--- kernel/time/alarmtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/alarmtimer.c +1 -1
@@ -609,7 +609,7 @@ static s64 alarm_timer_forward(struct k_ {struct alarm *alarm = &timr->it.alarm.alarmtimer; -return alarm_forward (alarm, timr->it_interval, now); +return alarm_forward (alarm, now, timr->it_interval); }/**
Greg Kroah-Hartman
maintainerPATCH 376/570 scsi: ibmvfc: Fix OOB access in ibmvfc_discover_targets_done()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyllis Xu <[email protected]>
commit 61d099ac4a7a8fb11ebdb6e2ec8d77f38e77362f upstream.
A malicious or compromised VIO server can return a num_written value in the discover targets MAD response that exceeds max_targets. This value is stored directly in vhost->num_targets without validation, and is then used as the loop bound in ibmvfc_alloc_targets() to index into disc_buf[], which is only allocated for max_targets entries. Indices at or beyond max_targets access kernel memory outside the DMA-coherent allocation. The out-of-bounds data is subsequently embedded in Implicit Logout and PLOGI MADs that are sent back to the VIO server, leaking kernel memory.
Fix by clamping num_written to max_targets before storing it.
--- drivers/scsi/ibmvscsi/ibmvfc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/ibmvscsi/ibmvfc.c +2 -1
@@ -4926,7 +4926,8 @@ static void ibmvfc_discover_targets_doneswitch (mad_status) {case IBMVFC_MAD_SUCCESS :ibmvfc_dbg (vhost,"Discover Targets succeeded\n" ); - vhost->num_targets =be32_to_cpu (rsp->num_written); + vhost->num_targets =min_t (u32,be32_to_cpu (rsp->num_written), + max_targets);ibmvfc_set_host_action (vhost,IBMVFC_HOST_ACTION_ALLOC_TGTS );break ;case IBMVFC_MAD_FAILED :
Greg Kroah-Hartman
maintainerPATCH 377/570 scsi: ses: Handle positive SCSI error from ses_recv_diag()
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]>
commit 7a9f448d44127217fabc4065c5ba070d4e0b5d37 upstream.
ses_recv_diag() can return a positive value, which also means that an error happened, so do not only test for negative values.
--- drivers/scsi/ses.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ses.c +1 -1
@@ -184,7 +184,7 @@ static unsigned char *ses_get_page2_descunsigned char *type_ptr = ses_dev->page1_types;unsigned char *desc_ptr = ses_dev->page2 +8 ; -if (ses_recv_diag (sdev,2 , ses_dev->page2, ses_dev->page2_len) <0 ) +if (ses_recv_diag (sdev,2 , ses_dev->page2, ses_dev->page2_len))return NULL ;for (i =0 ; i < ses_dev->page1_num_types; i++, type_ptr +=4 ) {
Greg Kroah-Hartman
maintainerPATCH 378/570 jbd2: gracefully abort on checkpointing state corruptions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Milos Nikic <[email protected]>
commit bac3190a8e79beff6ed221975e0c9b1b5f2a21da upstream.
This patch targets two internal state machine invariants in checkpoint.c residing inside functions that natively return integer error codes.
- In jbd2_cleanup_journal_tail(): A blocknr of 0 indicates a severely corrupted journal superblock. Replaced the J_ASSERT with a WARN_ON_ONCE and a graceful journal abort, returning -EFSCORRUPTED.
- In jbd2_log_do_checkpoint(): Replaced the J_ASSERT_BH checking for an unexpected buffer_jwrite state. If the warning triggers, we explicitly drop the just-taken get_bh() reference and call __flush_batch() to safely clean up any previously queued buffers in the j_chkpt_bhs array, preventing a memory leak before returning -EFSCORRUPTED.
--- fs/jbd2/checkpoint.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
fs/jbd2/checkpoint.c +13 -2
@@ -279,7 +279,15 @@ restart:*/ BUFFER_TRACE (bh,"queue" );get_bh (bh); -J_ASSERT_BH (bh, !buffer_jwrite (bh)); +if (WARN_ON_ONCE (buffer_jwrite (bh))) { +put_bh (bh);/* drop the ref we just took */ +spin_unlock (&journal->j_list_lock); +/* Clean up any previously batched buffers */ +if (batch_count) +__flush_batch (journal, &batch_count); +jbd2_journal_abort (journal, -EFSCORRUPTED ); +return -EFSCORRUPTED ; + } journal->j_chkpt_bhs[batch_count++] = bh; transaction->t_chp_stats.cs_written++; transaction->t_checkpoint_list = jh->b_cpnext;
@@ -337,7 +345,10 @@ int jbd2_cleanup_journal_tail(journal_tif (!jbd2_journal_get_log_tail (journal, &first_tid, &blocknr))return 1 ; -J_ASSERT (blocknr !=0 ); +if (WARN_ON_ONCE (blocknr ==0 )) { +jbd2_journal_abort (journal, -EFSCORRUPTED ); +return -EFSCORRUPTED ; + }/* * We need to make sure that any blocks that were recently written out
Greg Kroah-Hartman
maintainerPATCH 379/570 xfs: stop reclaim before pushing AIL during unmount
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuto Ohnuki <[email protected]>
commit 4f24a767e3d64a5f58c595b5c29b6063a201f1e3 upstream.
The unmount sequence in xfs_unmount_flush_inodes() pushed the AIL while background reclaim and inodegc are still running. This is broken independently of any use-after-free issues - background reclaim and inodegc should not be running while the AIL is being pushed during unmount, as inodegc can dirty and insert inodes into the AIL during the flush, and background reclaim can race to abort and free dirty inodes.
Reorder xfs_unmount_flush_inodes() to stop inodegc and cancel background reclaim before pushing the AIL. Stop inodegc before cancelling m_reclaim_work because the inodegc worker can re-queue m_reclaim_work via xfs_inodegc_set_reclaimable.
--- fs/xfs/xfs_mount.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/xfs/xfs_mount.c +4 -3
@@ -535,8 +535,9 @@ xfs_check_summary_counts(* have been retrying in the background. This will prevent never-ending * retries in AIL pushing from hanging the unmount. * -* Finally, we can push the AIL to clean all the remaining dirty objects, then -* reclaim the remaining inodes that are still in memory at this point in time. +* Stop inodegc and background reclaim before pushing the AIL so that they +* are not running while the AIL is being flushed. Then push the AIL to +* clean all the remaining dirty objects and reclaim the remaining inodes. */ static void xfs_unmount_flush_inodes(
@@ -548,9 +549,9 @@ xfs_unmount_flush_inodes(set_bit (XFS_OPSTATE_UNMOUNTING , &mp->m_opstate); -xfs_ail_push_all_sync (mp->m_ail);xfs_inodegc_stop (mp);cancel_delayed_work_sync (&mp->m_reclaim_work); +xfs_ail_push_all_sync (mp->m_ail);xfs_reclaim_inodes (mp);xfs_health_unmount (mp); }
Greg Kroah-Hartman
maintainerPATCH 380/570 ext4: convert inline data to extents when truncate exceeds inline size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
commit ed9356a30e59c7cc3198e7fc46cfedf3767b9b17 upstream.
Add a check in ext4_setattr() to convert files from inline data storage to extent-based storage when truncate() grows the file size beyond the inline capacity. This prevents the filesystem from entering an inconsistent state where the inline data flag is set but the file size exceeds what can be stored inline.
Without this fix, the following sequence causes a kernel BUG_ON():
1. Mount filesystem with inode that has inline flag set and small size
2. truncate(file, 50MB) - grows size but inline flag remains set
3. sendfile() attempts to write data
4. ext4_write_inline_data() hits BUG_ON(write_size > inline_capacity)
The crash occurs because ext4_write_inline_data() expects inline storage to accommodate the write, but the actual inline capacity (~60 bytes for i_block + ~96 bytes for xattrs) is far smaller than the file size and write request.
The fix checks if the new size from setattr exceeds the inode's actual inline capacity (EXT4_I(inode)->i_inline_size) and converts the file to extent-based storage before proceeding with the size change.
This addresses the root cause by ensuring the inline data flag and file size remain consistent during truncate operations.
--- fs/ext4/inode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/ext4/inode.c +12 -0
@@ -5507,6 +5507,18 @@ int ext4_setattr(struct user_namespace *if (IS_I_VERSION (inode) && attr->ia_size != inode->i_size)inode_inc_iversion (inode); +/* +* If file has inline data but new size exceeds inline capacity, +* convert to extent-based storage first to prevent inconsistent +* state (inline flag set but size exceeds inline capacity). +*/ +if (ext4_has_inline_data (inode) && + attr->ia_size >EXT4_I (inode)->i_inline_size) { + error =ext4_convert_inline_data (inode); +if (error) + goto err_out; + } +if (shrink) {if (ext4_should_order_data (inode)) { error = ext4_begin_ordered_truncate(inode,
Greg Kroah-Hartman
maintainerPATCH 381/570 ext4: make recently_deleted() properly work with lazy itable initialization
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit bd060afa7cc3e0ad30afa9ecc544a78638498555 upstream.
recently_deleted() checks whether inode has been used in the near past. However this can give false positive result when inode table is not initialized yet and we are in fact comparing to random garbage (or stale itable block of a filesystem before mkfs). Ultimately this results in uninitialized inodes being skipped during inode allocation and possibly they are never initialized and thus e2fsck complains. Verify if the inode has been initialized before checking for dtime.
--- fs/ext4/ialloc.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/ext4/ialloc.c +6 -0
@@ -688,6 +688,12 @@ static int recently_deleted(struct superif (unlikely (!gdp))return 0 ; +/* Inode was never used in this filesystem? */ +if (ext4_has_group_desc_csum (sb) && + (gdp->bg_flags &cpu_to_le16 (EXT4_BG_INODE_UNINIT ) || + ino >=EXT4_INODES_PER_GROUP (sb) -ext4_itable_unused_count (sb, gdp))) +return 0 ; + bh =sb_find_get_block (sb,ext4_inode_table (sb, gdp) + (ino / inodes_per_block));if (!bh || !buffer_uptodate (bh))
Greg Kroah-Hartman
maintainerPATCH 382/570 ext4: avoid allocate block from corrupted group in ext4_mb_find_by_goal()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
commit 46066e3a06647c5b186cc6334409722622d05c44 upstream.
There's issue as follows:
...
EXT4-fs (mmcblk0p1): Delayed block allocation failed for inode 206 at logical offset 0 with max blocks 1 with error 117 EXT4-fs (mmcblk0p1): This should not happen!! Data will be lost
EXT4-fs (mmcblk0p1): Delayed block allocation failed for inode 206 at logical offset 0 with max blocks 1 with error 117 EXT4-fs (mmcblk0p1): This should not happen!! Data will be lost
EXT4-fs (mmcblk0p1): Delayed block allocation failed for inode 206 at logical offset 0 with max blocks 1 with error 117 EXT4-fs (mmcblk0p1): This should not happen!! Data will be lost
EXT4-fs (mmcblk0p1): Delayed block allocation failed for inode 206 at logical offset 0 with max blocks 1 with error 117 EXT4-fs (mmcblk0p1): This should not happen!! Data will be lost
EXT4-fs (mmcblk0p1): Delayed block allocation failed for inode 2243 at logical offset 0 with max blocks 1 with error 117 EXT4-fs (mmcblk0p1): This should not happen!! Data will be lost
EXT4-fs (mmcblk0p1): Delayed block allocation failed for inode 2239 at logical offset 0 with max blocks 1 with error 117 EXT4-fs (mmcblk0p1): This should not happen!! Data will be lost
EXT4-fs (mmcblk0p1): error count since last fsck: 1
EXT4-fs (mmcblk0p1): initial error at time 1765597433: ext4_mb_generate_buddy:760 EXT4-fs (mmcblk0p1): last error at time 1765597433: ext4_mb_generate_buddy:760
...
According to the log analysis, blocks are always requested from the corrupted block group. This may happen as follows:ext4_mb_find_by_goal
ext4_mb_load_buddy
ext4_mb_load_buddy_gfp
ext4_mb_init_cache
ext4_read_block_bitmap_nowait
ext4_wait_block_bitmap
ext4_validate_block_bitmap
if (!grp || EXT4_MB_GRP_BBITMAP_CORRUPT(grp))
return -EFSCORRUPTED; // There's no logs.
if (err)
return err; // Will return errorext4_lock_group(ac->ac_sb, group);
if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) // Unreachable
goto out;
After commit 9008a58e5dce ("ext4: make the bitmap read routines return real error codes") merged, Commit 163a203ddb36 ("ext4: mark block group as corrupt on block bitmap error") is no real solution for allocating blocks from corrupted block groups. This is because if 'EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info)' is true, then 'ext4_mb_load_buddy()' may return an error. This means that the block allocation will fail.
Therefore, check block group if corrupted when ext4_mb_load_buddy() returns error.
--- fs/ext4/mballoc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ext4/mballoc.c +5 -1
@@ -2280,8 +2280,12 @@ int ext4_mb_find_by_goal(struct ext4_allreturn 0 ; err =ext4_mb_load_buddy (ac->ac_sb, group, e4b); -if (err) +if (err) { +if (EXT4_MB_GRP_BBITMAP_CORRUPT (e4b->bd_info) && + !(ac->ac_flags &EXT4_MB_HINT_GOAL_ONLY )) +return 0 ;return err; + }ext4_lock_group (ac->ac_sb, group);if (unlikely (EXT4_MB_GRP_BBITMAP_CORRUPT (e4b->bd_info)))
Greg Kroah-Hartman
maintainerPATCH 383/570 ext4: reject mount if bigalloc with s_first_data_block != 0
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helen Koike <[email protected]>
commit 3822743dc20386d9897e999dbb990befa3a5b3f8 upstream.
bigalloc with s_first_data_block != 0 is not supported, reject mounting it.
--- fs/ext4/super.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/ext4/super.c +7 -0
@@ -3214,6 +3214,13 @@ int ext4_feature_set_ok(struct super_blo "extents feature\n");return 0 ; } +if (ext4_has_feature_bigalloc (sb) && +le32_to_cpu (EXT4_SB (sb)->s_es->s_first_data_block)) { +ext4_msg (sb,KERN_WARNING , +"bad geometry: bigalloc file system with non-zero " +"first_data_block\n" ); +return 0 ; + }#if !IS_ENABLED (CONFIG_QUOTA ) || !IS_ENABLED (CONFIG_QFMT_V2 ) if (!readonly && (ext4_has_feature_quota(sb) ||
Greg Kroah-Hartman
maintainerPATCH 384/570 ext4: fix iloc.bh leak in ext4_fc_replay_inode() error paths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit ec0a7500d8eace5b4f305fa0c594dd148f0e8d29 upstream.
During code review, Joseph found that ext4_fc_replay_inode() calls ext4_get_fc_inode_loc() to get the inode location, which holds a reference to iloc.bh that must be released via brelse().
However, several error paths jump to the 'out' label without releasing iloc.bh:
- ext4_handle_dirty_metadata() failure
- sync_dirty_buffer() failure
- ext4_mark_inode_used() failure
- ext4_iget() failure
Fix this by introducing an 'out_brelse' label placed just before the existing 'out' label to ensure iloc.bh is always released.
Additionally, make ext4_fc_replay_inode() propagate errors properly instead of always returning 0.
--- fs/ext4/fast_commit.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
fs/ext4/fast_commit.c +8 -5
@@ -1582,19 +1582,21 @@ static int ext4_fc_replay_inode(struct s/* Immediately update the inode on disk. */ ret =ext4_handle_dirty_metadata (NULL ,NULL , iloc.bh);if (ret) - goto out; + goto out_brelse; ret =sync_dirty_buffer (iloc.bh);if (ret) - goto out; + goto out_brelse; ret =ext4_mark_inode_used (sb, ino);if (ret) - goto out; + goto out_brelse;/* Given that we just wrote the inode on disk, this SHOULD succeed. */ inode =ext4_iget (sb, ino,EXT4_IGET_NORMAL );if (IS_ERR (inode)) {ext4_debug ("Inode not found." ); -return -EFSCORRUPTED ; + inode =NULL ; + ret = -EFSCORRUPTED ; + goto out_brelse; }/*
@@ -1610,13 +1612,14 @@ static int ext4_fc_replay_inode(struct sext4_inode_csum_set (inode,ext4_raw_inode (&iloc),EXT4_I (inode)); ret =ext4_handle_dirty_metadata (NULL ,NULL , iloc.bh);sync_dirty_buffer (iloc.bh); +out_brelse:brelse (iloc.bh); out:iput (inode);if (!ret)blkdev_issue_flush (sb->s_bdev); -return 0 ; +return ret; }/*
Greg Kroah-Hartman
maintainerPATCH 385/570 ext4: always drain queued discard work in ext4_mb_release()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 9ee29d20aab228adfb02ca93f87fb53c56c2f3af upstream.
While reviewing recent ext4 patch[1], Sashiko raised the following concern[2]:
Quoted 5 lines
If the filesystem is initially mounted with the discard option, deleting files will populate
sbi->s_discard_listand queues_discard_work. If it is then remounted with nodiscard, theEXT4_MOUNT_DISCARDflag is cleared, but the pendings_discard_workis neither cancelled nor flushed.
[1] https://lore.kernel.org/r/[email protected]/
[2] https://sashiko.dev/#/patchset/20260319094545.19291-1-qiang.zhang%40linux.dev
The concern was valid, but it had nothing to do with the patch[1]. One of the problems with Sashiko in its current (early) form is that it will detect pre-existing issues and report it as a problem with the patch that it is reviewing.
In practice, it would be hard to hit deliberately (unless you are a malicious syzkaller fuzzer), since it would involve mounting the file system with -o discard, and then deleting a large number of files, remounting the file system with -o nodiscard, and then immediately unmounting the file system before the queued discard work has a change to drain on its own.
Fix it because it's a real bug, and to avoid Sashiko from raising this concern when analyzing future patches to mballoc.c.
--- fs/ext4/mballoc.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
fs/ext4/mballoc.c +5 -7
@@ -3628,13 +3628,11 @@ int ext4_mb_release(struct super_block *struct kmem_cache *cachep =get_groupinfo_cache (sb->s_blocksize_bits);int count; -if (test_opt (sb,DISCARD )) { -/* -* wait the discard work to drain all of ext4_free_data -*/ -flush_work (&sbi->s_discard_work); -WARN_ON_ONCE (!list_empty (&sbi->s_discard_list)); - } +/* +* wait the discard work to drain all of ext4_free_data +*/ +flush_work (&sbi->s_discard_work); +WARN_ON_ONCE (!list_empty (&sbi->s_discard_list));if (sbi->s_group_info) {for (i =0 ; i < ngroups; i++) {
Greg Kroah-Hartman
maintainerPATCH 386/570 dmaengine: idxd: Fix not releasing workqueue on .release()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 3d33de353b1ff9023d5ec73b9becf80ea87af695 ]
The workqueue associated with an DSA/IAA device is not released when the object is freed.
--- drivers/dma/idxd/sysfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/idxd/sysfs.c +1 -0
@@ -1271,6 +1271,7 @@ static void idxd_conf_device_release(struct device *dev) {struct idxd_device *idxd =confdev_to_idxd (dev); +destroy_workqueue (idxd->wq);kfree (idxd->groups);kfree (idxd->wqs);kfree (idxd->engines);
Signature · 1 line
2.53.0
Re: [PATCH 5.15 386/570] dmaengine: idxd: Fix not releasing workqueue on .release()
Hi,
Quoted 26 lines · Greg Kroah-Hartman
5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinicius Costa Gomes <[email protected]>
[ Upstream commit
3d33de353b1ff9023d5ec73b9becf80ea87af695]The workqueue associated with an DSA/IAA device is not released when the object is freed.
Fixes 47c16ac27d4c ("dmaengine: idxd: fix idxd conf_dev 'struct device' lifetime")Reviewed-by Dave Jiang <[email protected]>Signed-off-by Vinicius Costa Gomes <[email protected]>Link https://patch.msgid.link/20260121-idxd-fix-flr-on-kernel-queues-v3-v3-7-7ed70658a9d1@intel.com open hereSigned-off-by Vinod Koul <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/dma/idxd/sysfs.c | 1 + 1 file changed, 1 insertion(+)drivers/dma/idxd/sysfs.c +0
-0
drivers/dma/idxd/sysfs.c static void idxd_conf_device_release(struct device *dev) · line 1274
Quoted 4 lines
drivers/dma/idxd/sysfs.c +1
-0@@ -1271,6 +1271,7 @@ static void idxd_conf_device_release(struct device *dev) {struct idxd_device *idxd =confdev_to_idxd (dev); +destroy_workqueue (idxd->wq);
I have run an AI assisted backport review and it spotted an issue: I have taken a look and the issues goes like:
in 5.15.y code base:
the remove() function is something like this:
get_device(idxd_confdev(idxd)); device_unregister(idxd_confdev(idxd)); ... destroy_workqueue(idxd->wq); ... put_device(idxd_confdev(idxd));
put_device() --> release() call and this patch tries to add destroy_workqueue(idxd->wq); so that's destroying it twice.
idxd_remove()
-> destroy_workqueue(idxd->wq) // first destroy
-> put_device(idxd_confdev(idxd))
-> idxd_conf_device_release()
-> destroy_workqueue(idxd->wq) // second destroyThis changed in ustream during the refactoring commit and followup fixes of commit: a409e919ca32 ("dmaengine: idxd: Refactor remove call with idxd_cleanup() helper"), so upstream (6.15-rc1 origin, it is backported to 6.6-rc1) doesn't have this problem. looks like we will have same problem in 6.1.y as well. I just checked, it has the same problem
Thanks,
Harshit
Quoted 3 lines
drivers/dma/idxd/sysfs.c +0
-0kfree (idxd->groups);kfree (idxd->wqs);kfree (idxd->engines);
Sasha Levin
maintainerRe: [PATCH 5.15 386/570] dmaengine: idxd: Fix not releasing workqueue on .release()
Quoted 5 lines
idxd_remove()
->destroy_workqueue(idxd->wq)// first destroy
-> put_device(idxd_confdev(idxd))-> idxd_conf_device_release() -> destroy_workqueue(idxd->wq) // second destroy
Makes sense. I'll drop it from 5.15. Thanks!
--
Thanks,
Sasha
Greg Kroah-Hartman
maintainerPATCH 387/570 phy: ti: j721e-wiz: Fix device node reference leak in wiz_get_lane_phy_types()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 584b457f4166293bdfa50f930228e9fb91a38392 ]
The serdes device_node is obtained using of_get_child_by_name(), which increments the reference count. However, it is never put, leading to a reference leak.
Add the missing of_node_put() calls to ensure the reference count is properly balanced.
--- drivers/phy/ti/phy-j721e-wiz.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/ti/phy-j721e-wiz.c +2 -0
@@ -1116,6 +1116,7 @@ static int wiz_get_lane_phy_types(struct device *dev, struct wiz *wiz)dev_err (dev,"%s: Reading \"reg\" from \"%s\" failed: %d\n" , __func__, subnode->name, ret); +of_node_put (serdes);return ret; }of_property_read_u32 (subnode,"cdns,num-lanes" , &num_lanes);
@@ -1128,6 +1129,7 @@ static int wiz_get_lane_phy_types(struct device *dev, struct wiz *wiz) wiz->lane_phy_type[i] = phy_type; } +of_node_put (serdes);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 388/570 dmaengine: xilinx: xilinx_dma: Fix dma_device directions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit e9cc95397bb7da13fe8a5b53a2f23cfaf9018ade ]
Unlike chan->direction , struct dma_device .directions field is a bitfield. Turn chan->direction into a bitfield to make it compatible with struct dma_device .directions .
--- drivers/dma/xilinx/xilinx_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/xilinx/xilinx_dma.c +1 -1
@@ -2862,7 +2862,7 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev,return -EINVAL ; } - xdev->common.directions |= chan->direction; + xdev->common.directions |=BIT (chan->direction);/* Request the interrupt */ chan->irq =irq_of_parse_and_map (node, chan->tdest);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 389/570 dmaengine: xilinx: xilinx_dma: Fix residue calculation for cyclic DMA
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit f61d145999d61948a23cd436ebbfa4c3b9ab8987 ]
The cyclic DMA calculation is currently entirely broken and reports residue only for the first segment. The problem is twofold.
First, when the first descriptor finishes, it is moved from active_list to done_list, but it is never returned back into the active_list. The xilinx_dma_tx_status() expects the descriptor to be in the active_list to report any meaningful residue information, which never happens after the first descriptor finishes. Fix this up in xilinx_dma_start_transfer() and if the descriptor is cyclic, lift it from done_list and place it back into active_list list.
Second, the segment .status fields of the descriptor remain dirty. Once the DMA did one pass on the descriptor, the .status fields are populated with data by the DMA, but the .status fields are not cleared before reuse during the next cyclic DMA round. The xilinx_dma_get_residue() recognizes that as if the descriptor was complete and had 0 residue, which is bogus. Reinitialize the status field before placing the descriptor back into the active_list.
--- drivers/dma/xilinx/xilinx_dma.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/dma/xilinx/xilinx_dma.c +22 -1
@@ -1513,8 +1513,29 @@ static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan)if (chan->err)return ; -if (list_empty (&chan->pending_list)) +if (list_empty (&chan->pending_list)) { +if (chan->cyclic) { +struct xilinx_dma_tx_descriptor *desc; +struct list_head *entry; + + desc =list_last_entry (&chan->done_list, + struct xilinx_dma_tx_descriptor, node); +list_for_each (entry, &desc->segments) { +struct xilinx_axidma_tx_segment *axidma_seg; +struct xilinx_axidma_desc_hw *axidma_hw; + axidma_seg =list_entry (entry, + struct xilinx_axidma_tx_segment, + node); + axidma_hw = &axidma_seg->hw; + axidma_hw->status =0 ; + } + +list_splice_tail_init (&chan->done_list, &chan->active_list); + chan->desc_pendingcount =0 ; + chan->idle = false; + }return ; + }if (!chan->idle)return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 390/570 dmaengine: xilinx: xilinx_dma: Fix unmasked residue subtraction
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit c7d812e33f3e8ca0fa9eeabf71d1c7bc3acedc09 ]
The segment .control and .status fields both contain top bits which are not part of the buffer size, the buffer size is located only in the bottom max_buffer_len bits. To avoid interference from those top bits, mask out the size using max_buffer_len first, and only then subtract the values.
--- drivers/dma/xilinx/xilinx_dma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/dma/xilinx/xilinx_dma.c +6 -6
@@ -964,16 +964,16 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan, struct xilinx_cdma_tx_segment, node); cdma_hw = &cdma_seg->hw; - residue += (cdma_hw->control - cdma_hw->status) & - chan->xdev->max_buffer_len; + residue += (cdma_hw->control & chan->xdev->max_buffer_len) - + (cdma_hw->status & chan->xdev->max_buffer_len); }else if (chan->xdev->dma_config->dmatype ==XDMA_TYPE_AXIDMA ) { axidma_seg =list_entry (entry, struct xilinx_axidma_tx_segment, node); axidma_hw = &axidma_seg->hw; - residue += (axidma_hw->control - axidma_hw->status) & - chan->xdev->max_buffer_len; + residue += (axidma_hw->control & chan->xdev->max_buffer_len) - + (axidma_hw->status & chan->xdev->max_buffer_len); }else { aximcdma_seg = list_entry(entry,
@@ -981,8 +981,8 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan, node); aximcdma_hw = &aximcdma_seg->hw; residue += - (aximcdma_hw->control - aximcdma_hw->status) & - chan->xdev->max_buffer_len; + (aximcdma_hw->control & chan->xdev->max_buffer_len) - + (aximcdma_hw->status & chan->xdev->max_buffer_len); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 391/570 btrfs: fix super block offset in error message in btrfs_validate_super()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Harmstone <[email protected]>
[ Upstream commit b52fe51f724385b3ed81e37e510a4a33107e8161 ]
Fix the superblock offset mismatch error message in btrfs_validate_super(): we changed it so that it considers all the superblocks, but the message still assumes we're only looking at the first one.
The change from %u to %llu is because we're changing from a constant to a u64.
--- fs/btrfs/disk-io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/disk-io.c +2 -2
@@ -2657,8 +2657,8 @@ int btrfs_validate_super(struct btrfs_fs_info *fs_info,if (mirror_num >=0 &&btrfs_super_bytenr (sb) !=btrfs_sb_offset (mirror_num)) { -btrfs_err (fs_info,"super offset mismatch %llu != %u" , -btrfs_super_bytenr (sb),BTRFS_SUPER_INFO_OFFSET ); +btrfs_err (fs_info,"super offset mismatch %llu != %llu" , +btrfs_super_bytenr (sb),btrfs_sb_offset (mirror_num)); ret = -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 392/570 btrfs: fix lost error when running device stats on multiple devices fs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 1c37d896b12dfd0d4c96e310b0033c6676933917 ]
Whenever we get an error updating the device stats item for a device in btrfs_run_dev_stats() we allow the loop to go to the next device, and if updating the stats item for the next device succeeds, we end up losing the error we had from the previous device.
Fix this by breaking out of the loop once we get an error and make sure it's returned to the caller. Since we are in the transaction commit path (and in the critical section actually), returning the error will result in a transaction abort.
--- fs/btrfs/volumes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/volumes.c +3 -2
@@ -8016,8 +8016,9 @@ int btrfs_run_dev_stats(struct btrfs_trans_handle *trans)smp_rmb (); ret =update_dev_stat_item (trans, device); -if (!ret) -atomic_sub (stats_cnt, &device->dev_stats_ccnt); +if (ret) +break ; +atomic_sub (stats_cnt, &device->dev_stats_ccnt); }mutex_unlock (&fs_devices->device_list_mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 393/570 dmaengine: idxd: Remove usage of the deprecated ida_simple_xx() API
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 1075ee66a8c19bfa375b19c236fd6a22a867f138 ]
ida_alloc() and ida_free() should be preferred to the deprecated ida_simple_get() and ida_simple_remove().
This is less verbose.
Note that the upper limit of ida_simple_get() is exclusive, but the one of ida_alloc_range() is inclusive. Sothis change allows one more device.
MINORMASK is ((1U << MINORBITS) - 1), so allowing MINORMASK as a maximum value makes sense. It is also consistent with other "ida_.*MINORMASK" and "ida_*MINOR()" usages.
Stable-dep-of: c311f5e92484 ("dmaengine: idxd: Fix freeing the allocated ida too late")
--- drivers/dma/idxd/cdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/idxd/cdev.c +2 -2
@@ -46,7 +46,7 @@ static void idxd_cdev_dev_release(struct device *dev)struct idxd_wq *wq = idxd_cdev->wq; cdev_ctx = &ictx[wq->idxd->data->type]; -ida_simple_remove (&cdev_ctx->minor_ida, idxd_cdev->minor); +ida_free (&cdev_ctx->minor_ida, idxd_cdev->minor);kfree (idxd_cdev); }
@@ -260,7 +260,7 @@ int idxd_wq_add_cdev(struct idxd_wq *wq) cdev = &idxd_cdev->cdev; dev =cdev_dev (idxd_cdev); cdev_ctx = &ictx[wq->idxd->data->type]; - minor =ida_simple_get (&cdev_ctx->minor_ida,0 ,MINORMASK ,GFP_KERNEL ); + minor =ida_alloc_max (&cdev_ctx->minor_ida,MINORMASK ,GFP_KERNEL );if (minor <0 ) {kfree (idxd_cdev);return minor;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 394/570 dmaengine: idxd: Fix freeing the allocated ida too late
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinicius Costa Gomes <[email protected]>
[ Upstream commit c311f5e9248471a950f0a524c2fd736414d98900 ]
It can happen that when the cdev .release() is called, the driver already called ida_destroy(). Move ida_free() to the _del() path.
We see with DEBUG_KOBJECT_RELEASE enabled and forcing an early PCI unbind.
--- drivers/dma/idxd/cdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/dma/idxd/cdev.c +4 -4
@@ -42,11 +42,7 @@ struct idxd_user_context {static void idxd_cdev_dev_release (struct device *dev) {struct idxd_cdev *idxd_cdev =dev_to_cdev (dev); -struct idxd_cdev_context *cdev_ctx; -struct idxd_wq *wq = idxd_cdev->wq; - cdev_ctx = &ictx[wq->idxd->data->type]; -ida_free (&cdev_ctx->minor_ida, idxd_cdev->minor);kfree (idxd_cdev); }
@@ -295,11 +291,15 @@ int idxd_wq_add_cdev(struct idxd_wq *wq)void idxd_wq_del_cdev (struct idxd_wq *wq) { +struct idxd_cdev_context *cdev_ctx;struct idxd_cdev *idxd_cdev; idxd_cdev = wq->idxd_cdev; wq->idxd_cdev =NULL ;cdev_device_del (&idxd_cdev->cdev,cdev_dev (idxd_cdev)); + + cdev_ctx = &ictx[wq->idxd->data->type]; +ida_free (&cdev_ctx->minor_ida, idxd_cdev->minor);put_device (cdev_dev (idxd_cdev)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 395/570 dmaengine: xilinx_dma: Program interrupt delay timeout
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Radhey Shyam Pandey <[email protected]>
[ Upstream commit 84b798fedf3fa8f0ab0c096593ba817abc454fe5 ]
Program IRQDelay for AXI DMA. The interrupt timeout mechanism causes the DMA engine to generate an interrupt after the delay time period has expired. It enables dmaengine to respond in real-time even though interrupt coalescing is configured. It also remove the placeholder for delay interrupt and merge it with frame completion interrupt. Since by default interrupt delay timeout is disabled this feature addition has no functional impact on VDMA, MCDMA and CDMA IP's.
Stable-dep-of: a17ce4bc6f4f ("dmaengine: xilinx_dma: Fix reset related timeout with two-channel AXIDMA")
--- drivers/dma/xilinx/xilinx_dma.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/dma/xilinx/xilinx_dma.c +11 -9
@@ -174,8 +174,10 @@#define XILINX_DMA_MAX_TRANS_LEN_MAX 23#define XILINX_DMA_V2_MAX_TRANS_LEN_MAX 26#define XILINX_DMA_CR_COALESCE_MAX GENMASK(23, 16) +#define XILINX_DMA_CR_DELAY_MAX GENMASK(31, 24)#define XILINX_DMA_CR_CYCLIC_BD_EN_MASK BIT(4)#define XILINX_DMA_CR_COALESCE_SHIFT 16 +#define XILINX_DMA_CR_DELAY_SHIFT 24#define XILINX_DMA_BD_SOP BIT(27)#define XILINX_DMA_BD_EOP BIT(26)#define XILINX_DMA_COALESCE_MAX 255
@@ -411,6 +413,7 @@ struct xilinx_dma_tx_descriptor {* @stop_transfer: Differentiate b/w DMA IP's quiesce * @tdest: TDEST value for mcdma * @has_vflip: S2MM vertical flip +* @irq_delay: Interrupt delay timeout */ struct xilinx_dma_chan {struct xilinx_dma_device *xdev;
@@ -449,6 +452,7 @@ struct xilinx_dma_chan {int (*stop_transfer)(struct xilinx_dma_chan *chan);u16 tdest;bool has_vflip; +u8 irq_delay; };/**
@@ -1559,6 +1563,9 @@ static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan)if (chan->has_sg)xilinx_write (chan,XILINX_DMA_REG_CURDESC , head_desc->async_tx.phys); + reg &= ~XILINX_DMA_CR_DELAY_MAX ; + reg |= chan->irq_delay <<XILINX_DMA_CR_DELAY_SHIFT ; +dma_ctrl_write (chan,XILINX_DMA_REG_DMACR , reg);xilinx_dma_start (chan);
@@ -1886,15 +1893,8 @@ static irqreturn_t xilinx_dma_irq_handler(int irq, void *data) } } -if (status &XILINX_DMA_DMASR_DLY_CNT_IRQ ) { -/* -* Device takes too long to do the transfer when user requires -* responsiveness. -*/ -dev_dbg (chan->dev,"Inter-packet latency too long\n" ); - } - -if (status &XILINX_DMA_DMASR_FRM_CNT_IRQ ) { +if (status & (XILINX_DMA_DMASR_FRM_CNT_IRQ | +XILINX_DMA_DMASR_DLY_CNT_IRQ )) {spin_lock (&chan->lock);xilinx_dma_complete_descriptor (chan); chan->idle = true;
@@ -2818,6 +2818,8 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev,/* Retrieve the channel properties from the device tree */ has_dre =of_property_read_bool (node,"xlnx,include-dre" ); +of_property_read_u8 (node,"xlnx,irq-delay" , &chan->irq_delay); + chan->genlock =of_property_read_bool (node,"xlnx,genlock-mode" ); err =of_property_read_u32 (node,"xlnx,datawidth" , &value);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 396/570 dmaengine: xilinx_dma: Fix reset related timeout with two-channel AXIDMA
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomi Valkeinen <[email protected]>
[ Upstream commit a17ce4bc6f4f9acf77ba416c36791a15602e53aa ]
A single AXIDMA controller can have one or two channels. When it has two channels, the reset for both are tied together: resetting one channel resets the other as well. This creates a problem where resetting one channel will reset the registers for both channels, including clearing interrupt enable bits for the other channel, which can then lead to timeouts as the driver is waiting for an interrupt which never comes.
The driver currently has a probe-time work around for this: when a channel is created, the driver also resets and enables the interrupts. With two channels the reset for the second channel will clear the interrupt enables for the first one. The work around in the driver is just to manually enable the interrupts again in xilinx_dma_alloc_chan_resources().
This workaround only addresses the probe-time issue. When channels are reset at runtime (e.g., in xilinx_dma_terminate_all() or during error recovery), there's no corresponding mechanism to restore the other channel's interrupt enables. This leads to one channel having its interrupts disabled while the driver expects them to work, causing timeouts and DMA failures.
A proper fix is a complicated matter, as we should not reset the other channel when it's operating normally. So, perhaps, there should be some kind of synchronization for a common reset, which is not trivial to implement. To add to the complexity, the driver also supports other DMA types, like VDMA, CDMA and MCDMA, which don't have a shared reset.
However, when the two-channel AXIDMA is used in the (assumably) normal use case, providing DMA for a single memory-to-memory device, the common reset is a bit smaller issue: when something bad happens on one channel, or when one channel is terminated, the assumption is that we also want to terminate the other channel. And thus resetting both at the same time is "ok".
With that line of thinking we can implement a bit better work around than just the current probe time work around: let's enable the AXIDMA interrupts at xilinx_dma_start_transfer() instead. This ensures interrupts are enabled whenever a transfer starts, regardless of any prior resets that may have cleared them.
This approach is also more logical: enable interrupts only when needed for a transfer, rather than at resource allocation time, and, I think, all the other DMA types should also use this model, but I'm reluctant to do such changes as I cannot test them.
The reset function still enables interrupts even though it's not needed for AXIDMA anymore, but it's common code for all DMA types (VDMA, CDMA, MCDMA), so leave it unchanged to avoid affecting other variants.
--- drivers/dma/xilinx/xilinx_dma.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/dma/xilinx/xilinx_dma.c +1 -8
@@ -1190,14 +1190,6 @@ static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan)dma_cookie_init (dchan); -if (chan->xdev->dma_config->dmatype ==XDMA_TYPE_AXIDMA ) { -/* For AXI DMA resetting once channel will reset the -* other channel as well so enable the interrupts here. -*/ -dma_ctrl_set (chan,XILINX_DMA_REG_DMACR , -XILINX_DMA_DMAXR_ALL_IRQ_MASK ); - } -if ((chan->xdev->dma_config->dmatype ==XDMA_TYPE_CDMA ) && chan->has_sg)dma_ctrl_set (chan,XILINX_DMA_REG_DMACR ,XILINX_CDMA_CR_SGMODE );
@@ -1565,6 +1557,7 @@ static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan) head_desc->async_tx.phys); reg &= ~XILINX_DMA_CR_DELAY_MAX ; reg |= chan->irq_delay <<XILINX_DMA_CR_DELAY_SHIFT ; + reg |=XILINX_DMA_DMAXR_ALL_IRQ_MASK ;dma_ctrl_write (chan,XILINX_DMA_REG_DMACR , reg);xilinx_dma_start (chan);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 397/570 futex: Clear stale exiting pointer in futex_lock_pi() retry path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 210d36d892de5195e6766c45519dfb1e65f3eb83 upstream.
Fuzzying/stressing futexes triggered:
WARNING: kernel/futex/core.c:825 at wait_for_owner_exiting+0x7a/0x80, CPU#11: futex_lock_pi_s/524
When futex_lock_pi_atomic() sees the owner is exiting, it returns -EBUSY and stores a refcounted task pointer in 'exiting'.
After wait_for_owner_exiting() consumes that reference, the local pointer is never reset to nil. Upon a retry, if futex_lock_pi_atomic() returns a different error, the bogus pointer is passed to wait_for_owner_exiting().
CPU0 CPU1 CPU2
futex_lock_pi(uaddr)
// acquires the PI futex
exit()
futex_cleanup_begin()
futex_state = EXITING;
futex_lock_pi(uaddr)
futex_lock_pi_atomic()
attach_to_pi_owner()
// observes EXITING
*exiting = owner; // takes ref
return -EBUSY
wait_for_owner_exiting(-EBUSY, owner)
put_task_struct(); // drops ref
// exiting still points to owner
goto retry;
futex_lock_pi_atomic()
lock_pi_update_atomic()
cmpxchg(uaddr)
*uaddr ^= WAITERS // whatever
// value changed
return -EAGAIN;
wait_for_owner_exiting(-EAGAIN, exiting) // stale
WARN_ON_ONCE(exiting)Fix this by resetting upon retry, essentially aligning it with requeue_pi.
--- kernel/futex/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/futex/core.c +2 -1
@@ -3029,9 +3029,9 @@ static int futex_lock_pi(u32 __user *uad ktime_t *time, int trylock) {struct hrtimer_sleeper timeout, *to; -struct task_struct *exiting =NULL ;struct rt_mutex_waiter rt_waiter;struct futex_hash_bucket *hb; +struct task_struct *exiting;struct futex_q q = futex_q_init;int res, ret;
@@ -3044,6 +3044,7 @@ static int futex_lock_pi(u32 __user *uad to =futex_setup_timer (time, &timeout, flags,0 ); retry: + exiting =NULL ; ret =get_futex_key (uaddr, flags &FLAGS_SHARED , &q.key,FUTEX_WRITE );if (unlikely (ret !=0 )) goto out;
Greg Kroah-Hartman
maintainerPATCH 398/570 HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benoît Sevens <[email protected]>
[ Upstream commit 2f1763f62909ccb6386ac50350fa0abbf5bb16a9 ]
The wacom_intuos_bt_irq() function processes Bluetooth HID reports without sufficient bounds checking. A maliciously crafted short report can trigger an out-of-bounds read when copying data into the wacom structure.
Specifically, report 0x03 requires at least 22 bytes to safely read the processed data and battery status, while report 0x04 (which falls through to 0x03) requires 32 bytes.
Add explicit length checks for these report IDs and log a warning if a short report is received.
--- drivers/hid/wacom_wac.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/hid/wacom_wac.c +10 -0
@@ -1258,10 +1258,20 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)switch (data[0 ]) {case 0x04 : +if (len <32 ) { +dev_warn (wacom->pen_input->dev.parent, +"Report 0x04 too short: %zu bytes\n" , len); +break ; + }wacom_intuos_bt_process_data (wacom, data + i); i +=10 ; fallthrough;case 0x03 : +if (i ==1 && len <22 ) { +dev_warn (wacom->pen_input->dev.parent, +"Report 0x03 too short: %zu bytes\n" , len); +break ; + }wacom_intuos_bt_process_data (wacom, data + i); i +=10 ;wacom_intuos_bt_process_data (wacom, data + i);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 399/570 atm: lec: fix use-after-free in sock_def_readable()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
[ Upstream commit 922814879542c2e397b0e9641fd36b8202a8e555 ]
A race condition exists between lec_atm_close() setting priv->lecd to NULL and concurrent access to priv->lecd in send_to_lecd(), lec_handle_bridge(), and lec_atm_send(). When the socket is freed via RCU while another thread is still using it, a use-after-free occurs in sock_def_readable() when accessing the socket's wait queue.
The root cause is that lec_atm_close() clears priv->lecd without any synchronization, while callers dereference priv->lecd without any protection against concurrent teardown.
Fix this by converting priv->lecd to an RCU-protected pointer:
- Mark priv->lecd as __rcu in lec.h
- Use rcu_assign_pointer() in lec_atm_close() and lecd_attach() for safe pointer assignment
- Use rcu_access_pointer() for NULL checks that do not dereference the pointer in lec_start_xmit(), lec_push(), send_to_lecd() and lecd_attach()
- Use rcu_read_lock/rcu_dereference/rcu_read_unlock in send_to_lecd(), lec_handle_bridge() and lec_atm_send() to safely access lecd
- Use rcu_assign_pointer() followed by synchronize_rcu() in lec_atm_close() to ensure all readers have completed before proceeding. This is safe since lec_atm_close() is called from vcc_release() which holds lock_sock(), a sleeping lock.
- Remove the manual sk_receive_queue drain from lec_atm_close() since vcc_destroy_socket() already drains it after lec_atm_close() returns.
v2: Switch from spinlock + sock_hold/put approach to RCU to properly
fix the race. The v1 spinlock approach had two issues pointed out by Eric Dumazet:
1. priv->lecd was still accessed directly after releasing the lock instead of using a local copy.
2. The spinlock did not prevent packets being queued after lec_atm_close() drains sk_receive_queue since timer and workqueue paths bypass netif_stop_queue().
Note: Syzbot patch testing was attempted but the test VM terminated
unexpectedly with "Connection to localhost closed by remote host", likely due to a QEMU AHCI emulation issue unrelated to this fix. Compile testing with "make W=1 net/atm/lec.o" passes cleanly.
--- net/atm/lec.c | 72 +++++++++++++++++++++++++++++++++++++--------------------- net/atm/lec.h | 2 - 2 files changed, 48 insertions(+), 26 deletions(-)
net/atm/lec.c +47 -25
@@ -142,6 +142,7 @@ static void lec_handle_bridge(struct sk_struct sock *sk;struct sk_buff *skb2;struct atmlec_msg *mesg; +struct atm_vcc *vcc; skb2 =alloc_skb (sizeof (struct atmlec_msg ),GFP_ATOMIC );if (skb2 ==NULL )
@@ -154,10 +155,18 @@ static void lec_handle_bridge(struct sk_/* 0x01 is topology change */ priv =netdev_priv (dev); -atm_force_charge (priv->lecd, skb2->truesize); - sk =sk_atm (priv->lecd); -skb_queue_tail (&sk->sk_receive_queue, skb2); - sk->sk_data_ready(sk); + +rcu_read_lock (); + vcc =rcu_dereference (priv->lecd); +if (vcc) { +atm_force_charge (vcc, skb2->truesize); + sk =sk_atm (vcc); +skb_queue_tail (&sk->sk_receive_queue, skb2); + sk->sk_data_ready (sk); + }else { +dev_kfree_skb (skb2); + } + rcu_read_unlock(); } }#endif /* IS_ENABLED(CONFIG_BRIDGE) */
@@ -216,7 +225,7 @@ static netdev_tx_t lec_start_xmit(structint is_rdesc;pr_debug ("called\n" ); -if (!priv->lecd) { +if (!rcu_access_pointer (priv->lecd)) {pr_info ("%s:No lecd attached\n" , dev->name); dev->stats.tx_errors++;netif_stop_queue (dev);
@@ -443,6 +452,7 @@ static int lec_atm_send(struct atm_vcc */* hit from bridge table, send LE_ARP_RESPONSE */ struct sk_buff *skb2;struct sock *sk; +struct atm_vcc *vcc;pr_debug ("%s: entry found, responding to zeppelin\n" , dev->name);
@@ -451,10 +461,18 @@ static int lec_atm_send(struct atm_vcc *break ; skb2->len =sizeof (struct atmlec_msg );skb_copy_to_linear_data (skb2, mesg,sizeof (*mesg)); -atm_force_charge (priv->lecd, skb2->truesize); - sk =sk_atm (priv->lecd); -skb_queue_tail (&sk->sk_receive_queue, skb2); - sk->sk_data_ready(sk); + +rcu_read_lock (); + vcc =rcu_dereference (priv->lecd); +if (vcc) { +atm_force_charge (vcc, skb2->truesize); + sk =sk_atm (vcc); +skb_queue_tail (&sk->sk_receive_queue, skb2); + sk->sk_data_ready (sk); + }else { +dev_kfree_skb (skb2); + } + rcu_read_unlock(); } }#endif /* IS_ENABLED(CONFIG_BRIDGE) */
@@ -470,23 +488,16 @@ static int lec_atm_send(struct atm_vcc *static void lec_atm_close (struct atm_vcc *vcc) { -struct sk_buff *skb;struct net_device *dev = (struct net_device *)vcc->proto_data;struct lec_priv *priv =netdev_priv (dev); - priv->lecd =NULL ; +rcu_assign_pointer (priv->lecd,NULL ); +synchronize_rcu ();/* Do something needful? */ netif_stop_queue (dev);lec_arp_destroy (priv); -if (skb_peek (&sk_atm (vcc)->sk_receive_queue)) -pr_info ("%s closing with messages pending\n" , dev->name); -while ((skb =skb_dequeue (&sk_atm (vcc)->sk_receive_queue))) { -atm_return (vcc, skb->truesize); -dev_kfree_skb (skb); - } -pr_info ("%s: Shut down!\n" , dev->name);module_put (THIS_MODULE ); }
@@ -512,12 +523,14 @@ send_to_lecd(struct lec_priv *priv, atml const unsigned char *mac_addr, const unsigned char *atm_addr, struct sk_buff *data) { + struct atm_vcc *vcc;struct sock *sk;struct sk_buff *skb;struct atmlec_msg *mesg; -if (!priv || !priv->lecd) +if (!priv || !rcu_access_pointer (priv->lecd))return -1 ; + skb =alloc_skb (sizeof (struct atmlec_msg ),GFP_ATOMIC );if (!skb)return -1 ;
@@ -534,18 +547,27 @@ send_to_lecd(struct lec_priv *priv, atmlif (atm_addr)memcpy (&mesg->content.normal.atm_addr, atm_addr,ATM_ESA_LEN ); -atm_force_charge (priv->lecd, skb->truesize); - sk =sk_atm (priv->lecd); +rcu_read_lock (); + vcc =rcu_dereference (priv->lecd); +if (!vcc) { +rcu_read_unlock (); +kfree_skb (skb); +return -1 ; + } + +atm_force_charge (vcc, skb->truesize); + sk =sk_atm (vcc);skb_queue_tail (&sk->sk_receive_queue, skb); sk->sk_data_ready (sk);if (data !=NULL ) {pr_debug ("about to send %d bytes of data\n" , data->len); -atm_force_charge (priv->lecd, data->truesize); +atm_force_charge (vcc, data->truesize);skb_queue_tail (&sk->sk_receive_queue, data); sk->sk_data_ready (sk); } +rcu_read_unlock ();return 0 ; }
@@ -620,7 +642,7 @@ static void lec_push(struct atm_vcc *vccatm_return (vcc, skb->truesize);if (*(__be16 *) skb->data ==htons (priv->lecid) || - !priv->lecd || !(dev->flags &IFF_UP )) { + !rcu_access_pointer (priv->lecd) || !(dev->flags &IFF_UP )) {/* * Probably looping back, or if lecd is missing, * lecd has gone down
@@ -755,12 +777,12 @@ static int lecd_attach(struct atm_vcc *v priv =netdev_priv (dev_lec[i]); }else { priv =netdev_priv (dev_lec[i]); -if (priv->lecd) +if (rcu_access_pointer (priv->lecd))return -EADDRINUSE ; }lec_arp_init (priv); priv->itfnum = i;/* LANE2 addition */ - priv->lecd = vcc; +rcu_assign_pointer (priv->lecd, vcc); vcc->dev = &lecatm_dev;vcc_insert_socket (sk_atm (vcc));
net/atm/lec.h +1 -1
@@ -91,7 +91,7 @@ struct lec_priv {*/ spinlock_t lec_arp_lock;struct atm_vcc *mcast_vcc;/* Default Multicast Send VCC */ -struct atm_vcc *lecd; +struct atm_vcc __rcu *lecd;struct delayed_work lec_arp_work;/* C10 */ unsigned int maximum_unknown_frame_count;/*
Greg Kroah-Hartman
maintainerPATCH 400/570 btrfs: dont take device_list_mutex when querying zone info
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit 77603ab10429fe713a03345553ca8dbbfb1d91c6 ]
Shin'ichiro reported sporadic hangs when running generic/013 in our CI system. When enabling lockdep, there is a lockdep splat when calling btrfs_get_dev_zone_info_all_devices() in the mount path that can be triggered by i.e. generic/013:
======================================================
WARNING: possible circular locking dependency detected
7.0.0-rc1+ #355 Not tainted
------------------------------------------------------
mount/1043 is trying to acquire lock:
ffff8881020b5470 (&vblk->vdev_mutex){+.+.}-{4:4}, at: virtblk_report_zones+0xda/0x430
but task is already holding lock:
ffff888102a738e0 (&fs_devs->device_list_mutex){+.+.}-{4:4}, at: btrfs_get_dev_zone_info_all_devices+0x45/0x90
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #4 (&fs_devs->device_list_mutex){+.+.}-{4:4}:
__mutex_lock+0xa3/0x1360 btrfs_create_pending_block_groups+0x1f4/0x9d0 __btrfs_end_transaction+0x3e/0x2e0 btrfs_zoned_reserve_data_reloc_bg+0x2f8/0x390 open_ctree+0x1934/0x23db btrfs_get_tree.cold+0x105/0x26c vfs_get_tree+0x28/0xb0 __do_sys_fsconfig+0x324/0x680 do_syscall_64+0x92/0x4f0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
-> #3 (btrfs_trans_num_extwriters){++++}-{0:0}:
join_transaction+0xc2/0x5c0 start_transaction+0x17c/0xbc0 btrfs_zoned_reserve_data_reloc_bg+0x2b4/0x390 open_ctree+0x1934/0x23db btrfs_get_tree.cold+0x105/0x26c vfs_get_tree+0x28/0xb0 __do_sys_fsconfig+0x324/0x680 do_syscall_64+0x92/0x4f0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
-> #2 (btrfs_trans_num_writers){++++}-{0:0}:
lock_release+0x163/0x4b0 __btrfs_end_transaction+0x1c7/0x2e0 btrfs_dirty_inode+0x6f/0xd0 touch_atime+0xe5/0x2c0 btrfs_file_mmap_prepare+0x65/0x90 __mmap_region+0x4b9/0xf00 mmap_region+0xf7/0x120 do_mmap+0x43d/0x610 vm_mmap_pgoff+0xd6/0x190 ksys_mmap_pgoff+0x7e/0xc0 do_syscall_64+0x92/0x4f0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
-> #1 (&mm->mmap_lock){++++}-{4:4}:
__might_fault+0x68/0xa0 _copy_to_user+0x22/0x70 blkdev_copy_zone_to_user+0x22/0x40 virtblk_report_zones+0x282/0x430 blkdev_report_zones_ioctl+0xfd/0x130 blkdev_ioctl+0x20f/0x2c0 __x64_sys_ioctl+0x86/0xd0 do_syscall_64+0x92/0x4f0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
-> #0 (&vblk->vdev_mutex){+.+.}-{4:4}:
__lock_acquire+0x1522/0x2680 lock_acquire+0xd5/0x2f0 __mutex_lock+0xa3/0x1360 virtblk_report_zones+0xda/0x430 blkdev_report_zones_cached+0x162/0x190 btrfs_get_dev_zones+0xdc/0x2e0 btrfs_get_dev_zone_info+0x219/0xe80 btrfs_get_dev_zone_info_all_devices+0x62/0x90 open_ctree+0x1200/0x23db btrfs_get_tree.cold+0x105/0x26c vfs_get_tree+0x28/0xb0 __do_sys_fsconfig+0x324/0x680 do_syscall_64+0x92/0x4f0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
other info that might help us debug this:
Chain exists of:
&vblk->vdev_mutex --> btrfs_trans_num_extwriters --> &fs_devs->device_list_mutex
Possible unsafe locking scenario: CPU0 CPU1
---- ----
lock(&fs_devs->device_list_mutex);
lock(btrfs_trans_num_extwriters);
lock(&fs_devs->device_list_mutex);
lock(&vblk->vdev_mutex);*** DEADLOCK ***
3 locks held by mount/1043:
#0: ffff88811063e878 (&fc->uapi_mutex){+.+.}-{4:4}, at: __do_sys_fsconfig+0x2ae/0x680
#1: ffff88810cb9f0e8 (&type->s_umount_key#31/1){+.+.}-{4:4}, at: alloc_super+0xc0/0x3e0
#2: ffff888102a738e0 (&fs_devs->device_list_mutex){+.+.}-{4:4}, at: btrfs_get_dev_zone_info_all_devices+0x45/0x90
stack backtrace: CPU: 2 UID: 0 PID: 1043 Comm: mount Not tainted 7.0.0-rc1+ #355 PREEMPT(full) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-9.fc43 06/10/2025 Call Trace: <TASK> dump_stack_lvl+0x5b/0x80 print_circular_bug.cold+0x18d/0x1d8 check_noncircular+0x10d/0x130 __lock_acquire+0x1522/0x2680 ? vmap_small_pages_range_noflush+0x3ef/0x820 lock_acquire+0xd5/0x2f0 ? virtblk_report_zones+0xda/0x430 ? lock_is_held_type+0xcd/0x130 __mutex_lock+0xa3/0x1360 ? virtblk_report_zones+0xda/0x430 ? virtblk_report_zones+0xda/0x430 ? __pfx_copy_zone_info_cb+0x10/0x10 ? virtblk_report_zones+0xda/0x430 virtblk_report_zones+0xda/0x430 ? __pfx_copy_zone_info_cb+0x10/0x10 blkdev_report_zones_cached+0x162/0x190 ? __pfx_copy_zone_info_cb+0x10/0x10 btrfs_get_dev_zones+0xdc/0x2e0 btrfs_get_dev_zone_info+0x219/0xe80 btrfs_get_dev_zone_info_all_devices+0x62/0x90 open_ctree+0x1200/0x23db btrfs_get_tree.cold+0x105/0x26c ? rcu_is_watching+0x18/0x50 vfs_get_tree+0x28/0xb0 __do_sys_fsconfig+0x324/0x680 do_syscall_64+0x92/0x4f0 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7f615e27a40e RSP: 002b:00007fff11b18fb8 EFLAGS: 00000246 ORIG_RAX: 00000000000001af RAX: ffffffffffffffda RBX: 000055572e92ab10 RCX: 00007f615e27a40e RDX: 0000000000000000 RSI: 0000000000000006 RDI: 0000000000000003 RBP: 00007fff11b19100 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 000055572e92bc40 R14: 00007f615e3faa60 R15: 000055572e92bd08 </TASK>
Don't hold the device_list_mutex while calling into btrfs_get_dev_zone_info() in btrfs_get_dev_zone_info_all_devices() to mitigate the issue. This is safe, as no other thread can touch the device list at the moment of execution.
--- fs/btrfs/zoned.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/btrfs/zoned.c +4 -2
@@ -313,7 +313,10 @@ int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info)if (!btrfs_fs_incompat (fs_info,ZONED ))return 0 ; -mutex_lock (&fs_devices->device_list_mutex); +/* +* No need to take the device_list mutex here, we're still in the mount +* path and devices cannot be added to or removed from the list yet. +*/ list_for_each_entry (device, &fs_devices->devices, dev_list) {/* We can skip reading of zone info for missing devices */ if (!device->bdev)
@@ -323,7 +326,6 @@ int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info)if (ret)break ; } -mutex_unlock (&fs_devices->device_list_mutex);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 401/570 objtool: Fix Clang jump table detection
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 4e5019216402ad0b4a84cff457b662d26803f103 ]
With Clang, there can be a conditional forward jump between the load of the jump table address and the indirect branch.
Fixes the following warning:
vmlinux.o: warning: objtool: ___bpf_prog_run+0x1c5: sibling call from callable instruction with modified stack frame
--- tools/objtool/check.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/objtool/check.c +2 -3
@@ -1759,12 +1759,11 @@ static void mark_func_jump_tables(struct objtool_file *file, last = insn;/* -* Store back-pointers for unconditional forward jumps such +* Store back-pointers for forward jumps such * that find_jump_table() can back-track using those and * avoid some potentially confusing code. */ -if (insn->type ==INSN_JUMP_UNCONDITIONAL && insn->jump_dest && - insn->offset > last->offset && +if (insn->jump_dest && insn->jump_dest->offset > insn->offset && !insn->jump_dest->first_jump_src) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 402/570 HID: multitouch: Check to ensure report responses match the request
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lee Jones <[email protected]>
[ Upstream commit e716edafedad4952fe3a4a273d2e039a84e8681a ]
It is possible for a malicious (or clumsy) device to respond to a specific report's feature request using a completely different report ID. This can cause confusion in the HID core resulting in nasty side-effects such as OOB writes.
Add a check to ensure that the report ID in the response, matches the one that was requested. If it doesn't, omit reporting the raw event and return early.
--- drivers/hid/hid-multitouch.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/hid/hid-multitouch.c +7 -0
@@ -472,12 +472,19 @@ static void mt_get_feature(struct hid_device *hdev, struct hid_report *report)dev_warn (&hdev->dev,"failed to fetch feature %d\n" , report->id); }else { +/* The report ID in the request and the response should match */ +if (report->id != buf[0 ]) { +hid_err (hdev,"Returned feature report did not match the request\n" ); + goto free; + } + ret =hid_report_raw_event (hdev,HID_FEATURE_REPORT , buf, size,0 );if (ret)dev_warn (&hdev->dev,"failed to report feature\n" ); } +free:kfree (buf); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 403/570 btrfs: reject root items with drop_progress and zero drop_level
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: ZhengYuan Huang <[email protected]>
[ Upstream commit b17b79ff896305fd74980a5f72afec370ee88ca4 ]
[BUG]
When recovering relocation at mount time, merge_reloc_root() and btrfs_drop_snapshot() both use BUG_ON(level == 0) to guard against an impossible state: a non-zero drop_progress combined with a zero drop_level in a root_item, which can be triggered:
------------[ cut here ]------------ kernel BUG at fs/btrfs/relocation.c:1545! Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI CPU: 1 UID: 0 PID: 283 ... Tainted: 6.18.0+ #16 PREEMPT(voluntary) Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE Hardware name: QEMU Ubuntu 24.04 PC v2, BIOS 1.16.3-debian-1.16.3-2 RIP: 0010:merge_reloc_root+0x1266/0x1650 fs/btrfs/relocation.c:1545 Code: ffff0000 00004589 d7e9acfa ffffe8a1 79bafebe 02000000 Call Trace: merge_reloc_roots+0x295/0x890 fs/btrfs/relocation.c:1861 btrfs_recover_relocation+0xd6e/0x11d0 fs/btrfs/relocation.c:4195 btrfs_start_pre_rw_mount+0xa4d/0x1810 fs/btrfs/disk-io.c:3130 open_ctree+0x5824/0x5fe0 fs/btrfs/disk-io.c:3640 btrfs_fill_super fs/btrfs/super.c:987 [inline] btrfs_get_tree_super fs/btrfs/super.c:1951 [inline] btrfs_get_tree_subvol fs/btrfs/super.c:2094 [inline] btrfs_get_tree+0x111c/0x2190 fs/btrfs/super.c:2128 vfs_get_tree+0x9a/0x370 fs/super.c:1758 fc_mount fs/namespace.c:1199 [inline] do_new_mount_fc fs/namespace.c:3642 [inline] do_new_mount fs/namespace.c:3718 [inline] path_mount+0x5b8/0x1ea0 fs/namespace.c:4028 do_mount fs/namespace.c:4041 [inline] __do_sys_mount fs/namespace.c:4229 [inline] __se_sys_mount fs/namespace.c:4206 [inline] __x64_sys_mount+0x282/0x320 fs/namespace.c:4206 ... RIP: 0033:0x7f969c9a8fde Code: 0f1f4000 48c7c2b0 fffffff7 d8648902 b8ffffff ffc3660f ---[ end trace 0000000000000000 ]---
The bug is reproducible on 7.0.0-rc2-next-20260310 with our dynamic metadata fuzzing tool that corrupts btrfs metadata at runtime.
[CAUSE]
A non-zero drop_progress.objectid means an interrupted btrfs_drop_snapshot() left a resume point on disk, and in that case drop_level must be greater than 0 because the checkpoint is only saved at internal node levels.
Although this invariant is enforced when the kernel writes the root item, it is not validated when the root item is read back from disk. That allows on-disk corruption to provide an invalid state with drop_progress.objectid != 0 and drop_level == 0.
When relocation recovery later processes such a root item, merge_reloc_root() reads drop_level and hits BUG_ON(level == 0). The same invalid metadata can also trigger the corresponding BUG_ON() in btrfs_drop_snapshot().
[FIX]
Fix this by validating the root_item invariant in tree-checker when reading root items from disk: if drop_progress.objectid is non-zero, drop_level must also be non-zero. Reject such malformed metadata with -EUCLEAN before it reaches merge_reloc_root() or btrfs_drop_snapshot() and triggers the BUG_ON.
After the fix, the same corruption is correctly rejected by tree-checker and the BUG_ON is no longer triggered.
--- fs/btrfs/tree-checker.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
fs/btrfs/tree-checker.c +17 -0
@@ -1187,6 +1187,23 @@ static int check_root_item(struct extent_buffer *leaf, struct btrfs_key *key, btrfs_root_drop_level(&ri), BTRFS_MAX_LEVEL - 1);return -EUCLEAN ; } +/* +* If drop_progress.objectid is non-zero, a btrfs_drop_snapshot() was +* interrupted and the resume point was recorded in drop_progress and +* drop_level. In that case drop_level must be >= 1: level 0 is the +* leaf level and drop_snapshot never saves a checkpoint there (it +* only records checkpoints at internal node levels in DROP_REFERENCE +* stage). A zero drop_level combined with a non-zero drop_progress +* objectid indicates on-disk corruption and would cause a BUG_ON in +* merge_reloc_root() and btrfs_drop_snapshot() at mount time. +*/ +if (unlikely (btrfs_disk_key_objectid (&ri.drop_progress) !=0 && +btrfs_root_drop_level (&ri) ==0 )) { +generic_err (leaf, slot, +"invalid root drop_level 0 with non-zero drop_progress objectid %llu" , +btrfs_disk_key_objectid (&ri.drop_progress)); +return -EUCLEAN ; + }/* Flags check */ if (unlikely (btrfs_root_flags (&ri) & ~valid_root_flags)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 404/570 dt-bindings: auxdisplay: ht16k33: Use unevaluatedProperties to fix common property warning
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit 398c0c8bbc8f5a9d2f43863275a427a9d3720b6f ]
Change additionalProperties to unevaluatedProperties because it refs to /schemas/input/matrix-keymap.yaml.
Fix below CHECK_DTBS warnings:arch/arm/boot/dts/nxp/imx/imx6dl-victgo.dtb: keypad@70 (holtek,ht16k33): 'keypad,num-columns', 'keypad,num-rows' do not match any of the regexes: '^pinctrl-[0-9]+$'
from schema $id: http://devicetree.org/schemas/auxdisplay/holtek,ht16k33.yaml#
--- .../devicetree/bindings/auxdisplay/holtek,ht16k33.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml +1 -1
@@ -46,7 +46,7 @@ required: - reg - refresh-rate-hz -additionalProperties: false +unevaluatedProperties: false examples: - |
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 405/570 crypto: af-alg - fix NULL pointer dereference in scatterwalk
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Norbert Szetei <[email protected]>
[ Upstream commit 62397b493e14107ae82d8b80938f293d95425bcb ]
The AF_ALG interface fails to unmark the end of a Scatter/Gather List (SGL) when chaining a new af_alg_tsgl structure. If a sendmsg() fills an SGL exactly to MAX_SGL_ENTS, the last entry is marked as the end. A subsequent sendmsg() allocates a new SGL and chains it, but fails to clear the end marker on the previous SGL's last data entry.
This causes the crypto scatterwalk to hit a premature end, returning NULL on sg_next() and leading to a kernel panic during dereference.
Fix this by explicitly unmarking the end of the previous SGL when performing sg_chain() in af_alg_alloc_tsgl().
--- crypto/af_alg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
crypto/af_alg.c +3 -1
@@ -515,8 +515,10 @@ static int af_alg_alloc_tsgl(struct sock *sk)sg_init_table (sgl->sg,MAX_SGL_ENTS +1 ); sgl->cur =0 ; -if (sg) +if (sg) { +sg_unmark_end (sg +MAX_SGL_ENTS -1 );sg_chain (sg,MAX_SGL_ENTS +1 , sgl->sg); + }list_add_tail (&sgl->list, &ctx->tsgl_list); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 406/570 net: qrtr: replace qrtr_tx_flow radix_tree with xarray to fix memory leak
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 2428083101f6883f979cceffa76cd8440751ffe6 ]
__radix_tree_create() allocates and links intermediate nodes into the tree one by one. If a subsequent allocation fails, the already-linked nodes remain in the tree with no corresponding leaf entry. These orphaned internal nodes are never reclaimed because radix_tree_for_each_slot() only visits slots containing leaf values.
The radix_tree API is deprecated in favor of xarray. As suggested by Matthew Wilcox, migrate qrtr_tx_flow from radix_tree to xarray instead of fixing the radix_tree itself [1]. xarray properly handles cleanup of internal nodes — xa_destroy() frees all internal xarray nodes when the qrtr_node is released, preventing the leak.
[1] https://lore.kernel.org/all/[email protected]/T/
--- net/qrtr/af_qrtr.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-)
net/qrtr/af_qrtr.c +13 -18
@@ -116,7 +116,7 @@ static DEFINE_XARRAY_ALLOC(qrtr_ports);* @ep: endpoint * @ref: reference count for node * @nid: node id -* @qrtr_tx_flow: tree of qrtr_tx_flow, keyed by node << 32 | port +* @qrtr_tx_flow: xarray of qrtr_tx_flow, keyed by node << 32 | port * @qrtr_tx_lock: lock for qrtr_tx_flow inserts * @rx_queue: receive queue * @item: list item for broadcast list
@@ -127,7 +127,7 @@ struct qrtr_node {struct kref ref;unsigned int nid; -struct radix_tree_root qrtr_tx_flow; +struct xarray qrtr_tx_flow;struct mutex qrtr_tx_lock;/* for qrtr_tx_flow */ struct sk_buff_head rx_queue;
@@ -170,6 +170,7 @@ static void __qrtr_node_release(struct kref *kref)struct qrtr_tx_flow *flow;unsigned long flags;void __rcu **slot; +unsigned long index;spin_lock_irqsave (&qrtr_nodes_lock, flags);/* If the node is a bridge for other nodes, there are possibly
@@ -187,11 +188,9 @@ static void __qrtr_node_release(struct kref *kref)skb_queue_purge (&node->rx_queue);/* Free tx flow counters */ -radix_tree_for_each_slot (slot, &node->qrtr_tx_flow, &iter,0 ) { - flow = *slot; -radix_tree_iter_delete (&node->qrtr_tx_flow, &iter, slot); +xa_for_each (&node->qrtr_tx_flow, index, flow)kfree (flow); - } +xa_destroy (&node->qrtr_tx_flow);kfree (node); }
@@ -226,9 +225,7 @@ static void qrtr_tx_resume(struct qrtr_node *node, struct sk_buff *skb) key = remote_node <<32 | remote_port; -rcu_read_lock (); - flow =radix_tree_lookup (&node->qrtr_tx_flow, key); -rcu_read_unlock (); + flow =xa_load (&node->qrtr_tx_flow, key);if (flow) {spin_lock (&flow->resume_tx.lock); flow->pending =0 ;
@@ -267,12 +264,13 @@ static int qrtr_tx_wait(struct qrtr_node *node, int dest_node, int dest_port,return 0 ;mutex_lock (&node->qrtr_tx_lock); - flow =radix_tree_lookup (&node->qrtr_tx_flow, key); + flow =xa_load (&node->qrtr_tx_flow, key);if (!flow) { flow =kzalloc (sizeof (*flow),GFP_KERNEL );if (flow) {init_waitqueue_head (&flow->resume_tx); -if (radix_tree_insert (&node->qrtr_tx_flow, key, flow)) { +if (xa_err (xa_store (&node->qrtr_tx_flow, key, flow, +GFP_KERNEL ))) {kfree (flow); flow =NULL ; }
@@ -324,9 +322,7 @@ static void qrtr_tx_flow_failed(struct qrtr_node *node, int dest_node,unsigned long key = (u64 )dest_node <<32 | dest_port;struct qrtr_tx_flow *flow; -rcu_read_lock (); - flow =radix_tree_lookup (&node->qrtr_tx_flow, key); -rcu_read_unlock (); + flow =xa_load (&node->qrtr_tx_flow, key);if (flow) {spin_lock_irq (&flow->resume_tx.lock); flow->tx_failed =1 ;
@@ -594,7 +590,7 @@ int qrtr_endpoint_register(struct qrtr_endpoint *ep, unsigned int nid) node->nid =QRTR_EP_NID_AUTO ; node->ep = ep; -INIT_RADIX_TREE (&node->qrtr_tx_flow,GFP_KERNEL ); +xa_init (&node->qrtr_tx_flow);mutex_init (&node->qrtr_tx_lock);qrtr_node_assign (node, nid);
@@ -622,6 +618,7 @@ void qrtr_endpoint_unregister(struct qrtr_endpoint *ep)struct qrtr_tx_flow *flow;struct sk_buff *skb;unsigned long flags; +unsigned long index;void __rcu **slot;mutex_lock (&node->ep_lock);
@@ -644,10 +641,8 @@ void qrtr_endpoint_unregister(struct qrtr_endpoint *ep)/* Wake up any transmitters waiting for resume-tx from the node */ mutex_lock (&node->qrtr_tx_lock); -radix_tree_for_each_slot (slot, &node->qrtr_tx_flow, &iter,0 ) { - flow = *slot; +xa_for_each (&node->qrtr_tx_flow, index, flow)wake_up_interruptible_all (&flow->resume_tx); - }mutex_unlock (&node->qrtr_tx_lock);qrtr_node_release (node);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 407/570 net: ipv6: ndisc: fix ndisc_ra_useropt to initialize nduseropt_padX fields to zero to prevent an info-leak
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yochai Eisenrich <[email protected]>
[ Upstream commit ae05340ccaa9d347fe85415609e075545bec589f ]
When processing Router Advertisements with user options the kernel builds an RTM_NEWNDUSEROPT netlink message. The nduseroptmsg struct has three padding fields that are never zeroed and can leak kernel data
The fix is simple, just zeroes the padding fields.
--- net/ipv6/ndisc.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/ndisc.c +3 -0
@@ -1155,6 +1155,9 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt) ndmsg->nduseropt_icmp_type = icmp6h->icmp6_type; ndmsg->nduseropt_icmp_code = icmp6h->icmp6_code; ndmsg->nduseropt_opts_len = opt->nd_opt_len <<3 ; + ndmsg->nduseropt_pad1 =0 ; + ndmsg->nduseropt_pad2 =0 ; + ndmsg->nduseropt_pad3 =0 ;memcpy (ndmsg +1 , opt, opt->nd_opt_len <<3 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 408/570 tg3: Fix race for querying speed/duplex
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 bb417456c7814d1493d98b7dd9c040bf3ce3b4ed ]
When driver signals carrier up via netif_carrier_on() its internal link_up state isn't updated immediately. This leads to inconsistent speed/duplex in /proc/net/bonding/bondX where the speed and duplex is shown as unknown while ethtool shows correct values. Fix this by using netif_carrier_ok() for link checking in get_ksettings function.
--- drivers/net/ethernet/broadcom/tg3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/tg3.c +1 -1
@@ -12223,7 +12223,7 @@ static int tg3_get_link_ksettings(struct net_device *dev,ethtool_convert_legacy_u32_to_link_mode (cmd->link_modes.advertising, advertising); -if (netif_running (dev) && tp->link_up) { +if (netif_running (dev) &&netif_carrier_ok (dev)) { cmd->base.speed = tp->link_config.active_speed; cmd->base.duplex = tp->link_config.active_duplex; ethtool_convert_legacy_u32_to_link_mode(
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 409/570 ipv6: icmp: clear skb2->cb[] in ip6_err_gen_icmpv6_unreach()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 86ab3e55673a7a49a841838776f1ab18d23a67b5 ]
Sashiko AI-review observed:
In ip6_err_gen_icmpv6_unreach(), the skb is an outer IPv4 ICMP error packet where its cb contains an IPv4 inet_skb_parm. When skb is cloned into skb2 and passed to icmp6_send(), it uses IP6CB(skb2).
IP6CB interprets the IPv4 inet_skb_parm as an inet6_skb_parm. The cipso offset in inet_skb_parm.opt directly overlaps with dsthao in inet6_skb_parm at offset 18.
If an attacker sends a forged ICMPv4 error with a CIPSO IP option, dsthao would be a non-zero offset. Inside icmp6_send(), mip6_addr_swap() is called and uses ipv6_find_tlv(skb, opt->dsthao, IPV6_TLV_HAO).
This would scan the inner, attacker-controlled IPv6 packet starting at that offset, potentially returning a fake TLV without checking if the remaining packet length can hold the full 18-byte struct ipv6_destopt_hao.
Could mip6_addr_swap() then perform a 16-byte swap that extends past the end of the packet data into skb_shared_info?
Should the cb array also be cleared in ip6_err_gen_icmpv6_unreach() and ip6ip6_err() to prevent this?
This patch implements the first suggestion.
I am not sure if ip6ip6_err() needs to be changed. A separate patch would be better anyway.
--- net/ipv6/icmp.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/icmp.c +3 -0
@@ -674,6 +674,9 @@ int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type,if (!skb2)return 1 ; +/* Remove debris left by IPv4 stack. */ +memset (IP6CB (skb2),0 ,sizeof (*IP6CB (skb2))); +skb_dst_drop (skb2);skb_pull (skb2, nhs);skb_reset_network_header (skb2);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 410/570 ip6_tunnel: clear skb2->cb[] in ip4ip6_err()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 2edfa31769a4add828a7e604b21cb82aaaa05925 ]
Oskar Kjos reported the following problem.
ip4ip6_err() calls icmp_send() on a cloned skb whose cb[] was written by the IPv6 receive path as struct inet6_skb_parm. icmp_send() passes IPCB(skb2) to __ip_options_echo(), which interprets that cb[] region as struct inet_skb_parm (IPv4). The layouts differ: inet6_skb_parm.nhoff at offset 14 overlaps inet_skb_parm.opt.rr, producing a non-zero rr value. __ip_options_echo() then reads optlen from attacker-controlled packet data at sptr[rr+1] and copies that many bytes into dopt->__data, a fixed 40-byte stack buffer (IP_OPTIONS_DATA_FIXED_SIZE).
To fix this we clear skb2->cb[], as suggested by Oskar Kjos.
Also add minimal IPv4 header validation (version == 4, ihl >= 5).
--- net/ipv6/ip6_tunnel.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ipv6/ip6_tunnel.c +5 -0
@@ -603,11 +603,16 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,if (!skb2)return 0 ; +/* Remove debris left by IPv6 stack. */ +memset (IPCB (skb2),0 ,sizeof (*IPCB (skb2))); +skb_dst_drop (skb2);skb_pull (skb2, offset);skb_reset_network_header (skb2); eiph =ip_hdr (skb2); +if (eiph->version !=4 || eiph->ihl <5 ) + goto out;/* Try to guess incoming interface */ rt = ip_route_output_ports(dev_net(skb->dev), &fl4, NULL, eiph->saddr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 411/570 bridge: br_nd_send: linearize skb before parsing ND options
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Yang <[email protected]>
[ Upstream commit a01aee7cafc575bb82f5529e8734e7052f9b16ea ]
br_nd_send() parses neighbour discovery options from ns->opt[] and assumes that these options are in the linear part of request.
Its callers only guarantee that the ICMPv6 header and target address are available, so the option area can still be non-linear. Parsing ns->opt[] in that case can access data past the linear buffer.
Linearize request before option parsing and derive ns from the linear network header.
--- net/bridge/br_arp_nd_proxy.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/bridge/br_arp_nd_proxy.c +7 -5
@@ -248,12 +248,12 @@ struct nd_msg *br_is_nd_neigh_msg(struct sk_buff *skb, struct nd_msg *msg)static void br_nd_send (struct net_bridge *br,struct net_bridge_port *p,struct sk_buff *request,struct neighbour *n, -__be16 vlan_proto,u16 vlan_tci,struct nd_msg *ns) +__be16 vlan_proto,u16 vlan_tci) {struct net_device *dev = request->dev;struct net_bridge_vlan_group *vg; +struct nd_msg *na, *ns;struct sk_buff *reply; -struct nd_msg *na;struct ipv6hdr *pip6;int na_olen =8 ;/* opt hdr + ETH_ALEN for target */ int ns_olen;
@@ -261,7 +261,7 @@ static void br_nd_send(struct net_bridge *br, struct net_bridge_port *p,u8 *daddr;u16 pvid; -if (!dev) +if (!dev ||skb_linearize (request))return ; len = LL_RESERVED_SPACE(dev) + sizeof(struct ipv6hdr) +
@@ -278,6 +278,8 @@ static void br_nd_send(struct net_bridge *br, struct net_bridge_port *p,skb_set_mac_header (reply,0 ); daddr =eth_hdr (request)->h_source; + ns = (struct nd_msg *)(skb_network_header (request) + +sizeof (struct ipv6hdr ));/* Do we need option processing ? */ ns_olen = request->len - (skb_network_offset(request) +
@@ -465,9 +467,9 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,if (vid !=0 )br_nd_send (br, p, skb, n, skb->vlan_proto, -skb_vlan_tag_get (skb), msg); +skb_vlan_tag_get (skb));else -br_nd_send (br, p, skb, n,0 ,0 , msg); +br_nd_send (br, p, skb, n,0 ,0 ); replied = true; }
Signature · 1 line
2.53.0