6.6.48-rc1 review
Subsystems (9)
Greg Kroah-Hartman
maintainerPATCH 136/341 cpu/SMT: Enable SMT only if a core is online
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nysal Jan K.A <[email protected]>
[ Upstream commit 6c17ea1f3eaa330d445ac14a9428402ce4e3055e ]
If a core is offline then enabling SMT should not online CPUs of this core. By enabling SMT, what is intended is either changing the SMT value from "off" to "on" or setting the SMT level (threads per core) from a lower to higher value.
On PowerPC the ppc64_cpu utility can be used, among other things, to perform the following functions:
ppc64_cpu --cores-on # Get the number of online coresppc64_cpu --cores-on=X # Put exactly X cores onlineppc64_cpu --offline-cores=X[,Y,...] # Put specified cores offlineppc64_cpu --smt={on|off|value} # Enable, disable or change SMT level
If the user has decided to offline certain cores, enabling SMT should not online CPUs in those cores. This patch fixes the issue and changes the behaviour as described, by introducing an arch specific function topology_is_core_online(). It is currently implemented only for PowerPC.
--- Documentation/ABI/testing/sysfs-devices-system-cpu | 3 ++- kernel/cpu.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-devices-system-cpu +2 -1
@@ -565,7 +565,8 @@ Description: Control Symmetric Multi Threading (SMT) ================ ========================================= If control status is "forceoff" or "notsupported" writes - are rejected. + are rejected. Note that enabling SMT on PowerPC skips + offline cores. What: /sys/devices/system/cpu/cpuX/power/energy_perf_bias Date: March 2019
kernel/cpu.c +11 -1
@@ -2728,6 +2728,16 @@ int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)return ret; } +/** +* Check if the core a CPU belongs to is online +*/ +#if !defined(topology_is_core_online) +static inline bool topology_is_core_online (unsigned int cpu) +{ +return true; +} +#endif +int cpuhp_smt_enable (void ) {int cpu, ret =0 ;
@@ -2738,7 +2748,7 @@ int cpuhp_smt_enable(void)/* Skip online CPUs and CPUs on offline nodes */ if (cpu_online (cpu) || !node_online (cpu_to_node (cpu)))continue ; -if (!cpu_smt_thread_allowed (cpu)) +if (!cpu_smt_thread_allowed (cpu) || !topology_is_core_online (cpu))continue ; ret =_cpu_up (cpu,0 ,CPUHP_ONLINE );if (ret)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 137/341 powerpc/topology: Check if a core is online
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nysal Jan K.A <[email protected]>
[ Upstream commit 227bbaabe64b6f9cd98aa051454c1d4a194a8c6a ]
topology_is_core_online() checks if the core a CPU belongs to is online. The core is online if at least one of the sibling CPUs is online. The first CPU of an online core is also online in the common case, so this should be fairly quick.
--- arch/powerpc/include/asm/topology.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/powerpc/include/asm/topology.h +13 -0
@@ -145,6 +145,7 @@ static inline int cpu_to_coregroup_id(int cpu)#ifdef CONFIG_HOTPLUG_SMT #include <linux/cpu_smt.h> +#include <linux/cpumask.h> #include <asm/cputhreads.h> static inline bool topology_is_primary_thread (unsigned int cpu)
@@ -156,6 +157,18 @@ static inline bool topology_smt_thread_allowed(unsigned int cpu) {return cpu_thread_in_core (cpu) < cpu_smt_num_threads; } + +#define topology_is_core_online topology_is_core_online +static inline bool topology_is_core_online (unsigned int cpu) +{ +int i, first_cpu =cpu_first_thread_sibling (cpu); + +for (i = first_cpu; i < first_cpu + threads_per_core; ++i) { +if (cpu_online (i)) +return true; + } +return false; +}#endif #endif /* __KERNEL__ */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 138/341 arm64: Fix KASAN random tag seed initialization
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Holland <[email protected]>
[ Upstream commit f75c235565f90c4a17b125e47f1c68ef6b8c2bce ]
Currently, kasan_init_sw_tags() is called before setup_per_cpu_areas(), so per_cpu(prng_state, cpu) accesses the same address regardless of the value of "cpu", and the same seed value gets copied to the percpu area for every CPU. Fix this by moving the call to smp_prepare_boot_cpu(), which is the first architecture hook after setup_per_cpu_areas().
--- arch/arm64/kernel/setup.c | 3 --- arch/arm64/kernel/smp.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-)
arch/arm64/kernel/setup.c +0 -3
@@ -371,9 +371,6 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p)smp_init_cpus ();smp_build_mpidr_hash (); -/* Init percpu seeds for random tags after cpus are set up. */ -kasan_init_sw_tags (); -#ifdef CONFIG_ARM64_SW_TTBR0_PAN /* * Make sure init_thread_info.ttbr0 always generates translation
arch/arm64/kernel/smp.c +2 -0
@@ -459,6 +459,8 @@ void __init smp_prepare_boot_cpu(void)init_gic_priority_masking ();kasan_init_hw_tags (); +/* Init percpu seeds for random tags after cpus are set up. */ +kasan_init_sw_tags (); }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 139/341 block: Fix lockdep warning in blk_mq_mark_tag_wait
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Lingfeng <[email protected]>
[ Upstream commit b313a8c835516bdda85025500be866ac8a74e022 ]
Lockdep reported a warning in Linux version 6.6:
[ 414.344659] ================================
[ 414.345155] WARNING: inconsistent lock state
[ 414.345658] 6.6.0-07439-gba2303cacfda #6 Not tainted
[ 414.346221] --------------------------------
[ 414.346712] inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.
[ 414.347545] kworker/u10:3/1152 [HC0[0]:SC0[0]:HE0:SE1] takes:
[ 414.349245] ffff88810edd1098 (&sbq->ws[i].wait){+.?.}-{2:2}, at: blk_mq_dispatch_rq_list+0x131c/0x1ee0
[ 414.351204] {IN-SOFTIRQ-W} state was registered at:
[ 414.351751] lock_acquire+0x18d/0x460
[ 414.352218] _raw_spin_lock_irqsave+0x39/0x60
[ 414.352769] __wake_up_common_lock+0x22/0x60
[ 414.353289] sbitmap_queue_wake_up+0x375/0x4f0
[ 414.353829] sbitmap_queue_clear+0xdd/0x270
[ 414.354338] blk_mq_put_tag+0xdf/0x170
[ 414.354807] __blk_mq_free_request+0x381/0x4d0
[ 414.355335] blk_mq_free_request+0x28b/0x3e0
[ 414.355847] __blk_mq_end_request+0x242/0xc30
[ 414.356367] scsi_end_request+0x2c1/0x830
[ 414.345155] WARNING: inconsistent lock state
[ 414.345658] 6.6.0-07439-gba2303cacfda #6 Not tainted
[ 414.346221] --------------------------------
[ 414.346712] inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.
[ 414.347545] kworker/u10:3/1152 [HC0[0]:SC0[0]:HE0:SE1] takes:
[ 414.349245] ffff88810edd1098 (&sbq->ws[i].wait){+.?.}-{2:2}, at: blk_mq_dispatch_rq_list+0x131c/0x1ee0
[ 414.351204] {IN-SOFTIRQ-W} state was registered at:
[ 414.351751] lock_acquire+0x18d/0x460
[ 414.352218] _raw_spin_lock_irqsave+0x39/0x60
[ 414.352769] __wake_up_common_lock+0x22/0x60
[ 414.353289] sbitmap_queue_wake_up+0x375/0x4f0
[ 414.353829] sbitmap_queue_clear+0xdd/0x270
[ 414.354338] blk_mq_put_tag+0xdf/0x170
[ 414.354807] __blk_mq_free_request+0x381/0x4d0
[ 414.355335] blk_mq_free_request+0x28b/0x3e0
[ 414.355847] __blk_mq_end_request+0x242/0xc30
[ 414.356367] scsi_end_request+0x2c1/0x830
[ 414.356863] scsi_io_completion+0x177/0x1610
[ 414.357379] scsi_complete+0x12f/0x260
[ 414.357856] blk_complete_reqs+0xba/0xf0
[ 414.358338] __do_softirq+0x1b0/0x7a2
[ 414.358796] irq_exit_rcu+0x14b/0x1a0
[ 414.359262] sysvec_call_function_single+0xaf/0xc0
[ 414.359828] asm_sysvec_call_function_single+0x1a/0x20
[ 414.360426] default_idle+0x1e/0x30
[ 414.360873] default_idle_call+0x9b/0x1f0
[ 414.361390] do_idle+0x2d2/0x3e0
[ 414.361819] cpu_startup_entry+0x55/0x60
[ 414.362314] start_secondary+0x235/0x2b0
[ 414.362809] secondary_startup_64_no_verify+0x18f/0x19b
[ 414.363413] irq event stamp: 428794
[ 414.363825] hardirqs last enabled at (428793): [<ffffffff816bfd1c>] ktime_get+0x1dc/0x200
[ 414.364694] hardirqs last disabled at (428794): [<ffffffff85470177>] _raw_spin_lock_irq+0x47/0x50
[ 414.365629] softirqs last enabled at (428444): [<ffffffff85474780>] __do_softirq+0x540/0x7a2
[ 414.366522] softirqs last disabled at (428419): [<ffffffff813f65ab>] irq_exit_rcu+0x14b/0x1a0
[ 414.367425]
other info that might help us debug this:
[ 414.368194] Possible unsafe locking scenario:
[ 414.368900] CPU0
[ 414.369225] ----
[ 414.369548] lock(&sbq->ws[i].wait);
[ 414.370000] <Interrupt>
[ 414.370342] lock(&sbq->ws[i].wait);
[ 414.370802]
*** DEADLOCK ***
[ 414.371569] 5 locks held by kworker/u10:3/1152:
[ 414.372088] #0: ffff88810130e938 ((wq_completion)writeback){+.+.}-{0:0}, at: process_scheduled_works+0x357/0x13f0
[ 414.373180] #1: ffff88810201fdb8 ((work_completion)(&(&wb->dwork)->work)){+.+.}-{0:0}, at: process_scheduled_works+0x3a3/0x13f0
[ 414.374384] #2: ffffffff86ffbdc0 (rcu_read_lock){....}-{1:2}, at: blk_mq_run_hw_queue+0x637/0xa00
[ 414.375342] #3: ffff88810edd1098 (&sbq->ws[i].wait){+.?.}-{2:2}, at: blk_mq_dispatch_rq_list+0x131c/0x1ee0
[ 414.376377] #4: ffff888106205a08 (&hctx->dispatch_wait_lock){+.-.}-{2:2}, at: blk_mq_dispatch_rq_list+0x1337/0x1ee0
[ 414.378607]
stack backtrace:
[ 414.379177] CPU: 0 PID: 1152 Comm: kworker/u10:3 Not tainted 6.6.0-07439-gba2303cacfda #6
[ 414.380032] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
[ 414.381177] Workqueue: writeback wb_workfn (flush-253:0)
[ 414.381805] Call Trace:
[ 414.382136] <TASK>
[ 414.382429] dump_stack_lvl+0x91/0xf0
[ 414.382884] mark_lock_irq+0xb3b/0x1260
[ 414.383367] ? __pfx_mark_lock_irq+0x10/0x10
[ 414.383889] ? stack_trace_save+0x8e/0xc0
[ 414.384373] ? __pfx_stack_trace_save+0x10/0x10
[ 414.384903] ? graph_lock+0xcf/0x410
[ 414.385350] ? save_trace+0x3d/0xc70
[ 414.385808] mark_lock.part.20+0x56d/0xa90
[ 414.386317] mark_held_locks+0xb0/0x110
[ 414.386791] ? __pfx_do_raw_spin_lock+0x10/0x10
[ 414.387320] lockdep_hardirqs_on_prepare+0x297/0x3f0
[ 414.387901] ? _raw_spin_unlock_irq+0x28/0x50
[ 414.388422] trace_hardirqs_on+0x58/0x100
[ 414.388917] _raw_spin_unlock_irq+0x28/0x50
[ 414.389422] __blk_mq_tag_busy+0x1d6/0x2a0
[ 414.389920] __blk_mq_get_driver_tag+0x761/0x9f0
[ 414.390899] blk_mq_dispatch_rq_list+0x1780/0x1ee0
[ 414.391473] ? __pfx_blk_mq_dispatch_rq_list+0x10/0x10
[ 414.392070] ? sbitmap_get+0x2b8/0x450
[ 414.392533] ? __blk_mq_get_driver_tag+0x210/0x9f0
[ 414.393095] __blk_mq_sched_dispatch_requests+0xd99/0x1690
[ 414.393730] ? elv_attempt_insert_merge+0x1b1/0x420
[ 414.394302] ? __pfx___blk_mq_sched_dispatch_requests+0x10/0x10
[ 414.394970] ? lock_acquire+0x18d/0x460
[ 414.395456] ? blk_mq_run_hw_queue+0x637/0xa00
[ 414.395986] ? __pfx_lock_acquire+0x10/0x10
[ 414.396499] blk_mq_sched_dispatch_requests+0x109/0x190
[ 414.397100] blk_mq_run_hw_queue+0x66e/0xa00
[ 414.397616] blk_mq_flush_plug_list.part.17+0x614/0x2030
[ 414.398244] ? __pfx_blk_mq_flush_plug_list.part.17+0x10/0x10
[ 414.398897] ? writeback_sb_inodes+0x241/0xcc0
[ 414.399429] blk_mq_flush_plug_list+0x65/0x80
[ 414.399957] __blk_flush_plug+0x2f1/0x530
[ 414.400458] ? __pfx___blk_flush_plug+0x10/0x10
[ 414.400999] blk_finish_plug+0x59/0xa0
[ 414.401467] wb_writeback+0x7cc/0x920
[ 414.401935] ? __pfx_wb_writeback+0x10/0x10
[ 414.402442] ? mark_held_locks+0xb0/0x110
[ 414.402931] ? __pfx_do_raw_spin_lock+0x10/0x10
[ 414.403462] ? lockdep_hardirqs_on_prepare+0x297/0x3f0
[ 414.404062] wb_workfn+0x2b3/0xcf0
[ 414.404500] ? __pfx_wb_workfn+0x10/0x10
[ 414.404989] process_scheduled_works+0x432/0x13f0
[ 414.405546] ? __pfx_process_scheduled_works+0x10/0x10
[ 414.406139] ? do_raw_spin_lock+0x101/0x2a0
[ 414.406641] ? assign_work+0x19b/0x240
[ 414.407106] ? lock_is_held_type+0x9d/0x110
[ 414.407604] worker_thread+0x6f2/0x1160
[ 414.408075] ? __kthread_parkme+0x62/0x210
[ 414.408572] ? lockdep_hardirqs_on_prepare+0x297/0x3f0
[ 414.409168] ? __kthread_parkme+0x13c/0x210
[ 414.409678] ? __pfx_worker_thread+0x10/0x10
[ 414.410191] kthread+0x33c/0x440
[ 414.410602] ? __pfx_kthread+0x10/0x10
[ 414.411068] ret_from_fork+0x4d/0x80
[ 414.411526] ? __pfx_kthread+0x10/0x10
[ 414.411993] ret_from_fork_asm+0x1b/0x30
[ 414.412489] </TASK>When interrupt is turned on while a lock holding by spin_lock_irq it throws a warning because of potential deadlock.
blk_mq_prep_dispatch_rq
blk_mq_get_driver_tag
__blk_mq_get_driver_tag
__blk_mq_alloc_driver_tag
blk_mq_tag_busy -> tag is already busy
// failed to get driver tag blk_mq_mark_tag_wait
spin_lock_irq(&wq->lock) -> lock A (&sbq->ws[i].wait) __add_wait_queue(wq, wait) -> wait queue active blk_mq_get_driver_tag
__blk_mq_tag_busy
-> 1) tag must be idle, which means there can't be inflight IO
spin_lock_irq(&tags->lock) -> lock B (hctx->tags) spin_unlock_irq(&tags->lock) -> unlock B, turn on interrupt accidentally
-> 2) context must be preempt by IO interrupt to trigger deadlock.
As shown above, the deadlock is not possible in theory, but the warning still need to be fixed.
Fix it by using spin_lock_irqsave to get lockB instead of spin_lock_irq.
--- block/blk-mq-tag.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
block/blk-mq-tag.c +3 -2
@@ -38,6 +38,7 @@ static void blk_mq_update_wake_batch(struct blk_mq_tags *tags,void __blk_mq_tag_busy (struct blk_mq_hw_ctx *hctx) {unsigned int users; +unsigned long flags;struct blk_mq_tags *tags = hctx->tags;/*
@@ -56,11 +57,11 @@ void __blk_mq_tag_busy(struct blk_mq_hw_ctx *hctx)return ; } -spin_lock_irq (&tags->lock); +spin_lock_irqsave (&tags->lock, flags); users = tags->active_queues +1 ;WRITE_ONCE (tags->active_queues, users);blk_mq_update_wake_batch (tags, users); -spin_unlock_irq (&tags->lock); +spin_unlock_irqrestore (&tags->lock, flags); }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 140/341 drm/msm: Reduce fallout of fence signaling vs reclaim hangs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Clark <[email protected]>
[ Upstream commit 4bea53b9c7c72fd12a0ceebe88a71723c0a514b8 ]
Until various PM devfreq/QoS and interconnect patches land, we could potentially trigger reclaim from gpu scheduler thread, and under enough memory pressure that could trigger a sort of deadlock. Eventually the wait will timeout and we'll move on to consider other GEM objects. But given that there is still a potential for deadlock/stalling, we should reduce the timeout to contain the damage.
Patchwork: https://patchwork.freedesktop.org/patch/568031/
--- drivers/gpu/drm/msm/msm_gem_shrinker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gem_shrinker.c +1 -1
@@ -76,7 +76,7 @@ static bool wait_for_idle(struct drm_gem_object *obj) {enum dma_resv_usage usage =dma_resv_usage_rw (true); -return dma_resv_wait_timeout (obj->resv, usage, false,1000 ) >0 ; +return dma_resv_wait_timeout (obj->resv, usage, false,10 ) >0 ; } static bool
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 141/341 memory: tegra: Skip SID programming if SID registers arent set
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ashish Mhetre <[email protected]>
[ Upstream commit 0d6c918011ce4764ed277de4726a468b7ffe5fed ]
There are few MC clients where SID security and override register offsets are not specified like "sw_cluster0" in tegra234. Don't program SID override for such clients because it leads to access to invalid addresses.
--- drivers/memory/tegra/tegra186.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/memory/tegra/tegra186.c +3 -0
@@ -75,6 +75,9 @@ static void tegra186_mc_client_sid_override(struct tegra_mc *mc, {u32 value, old; +if (client->regs.sid.security ==0 && client->regs.sid.override ==0 ) +return ; + value =readl (mc->regs + client->regs.sid.security);if ((value &MC_SID_STREAMID_SECURITY_OVERRIDE ) ==0 ) {/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 142/341 powerpc/xics: Check return value of kasprintf in icp_native_map_one_cpu
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunwu Chan <[email protected]>
[ Upstream commit 45b1ba7e5d1f6881050d558baf9bc74a2ae13930 ]
kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Ensure the allocation was successful by checking the pointer validity.
--- arch/powerpc/sysdev/xics/icp-native.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/sysdev/xics/icp-native.c +2 -0
@@ -236,6 +236,8 @@ static int __init icp_native_map_one_cpu(int hw_id, unsigned long addr, rname =kasprintf (GFP_KERNEL ,"CPU %d [0x%x] Interrupt Presentation" , cpu, hw_id); +if (!rname) +return -ENOMEM ;if (!request_mem_region (addr, size, rname)) {pr_warn ("icp_native: Could not reserve ICP MMIO for CPU %d, interrupt server #0x%x\n" , cpu, hw_id);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 143/341 ASoC: SOF: ipc4: check return value of snd_sof_ipc_msg_data
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bard Liao <[email protected]>
[ Upstream commit 2bd512626f8ea3957c981cadd2ebf75feff737dd ]
snd_sof_ipc_msg_data could return error.
--- sound/soc/sof/ipc4.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
sound/soc/sof/ipc4.c +8 -1
@@ -629,7 +629,14 @@ static void sof_ipc4_rx_msg(struct snd_sof_dev *sdev)return ; ipc4_msg->data_size = data_size; -snd_sof_ipc_msg_data (sdev,NULL , ipc4_msg->data_ptr, ipc4_msg->data_size); + err =snd_sof_ipc_msg_data (sdev,NULL , ipc4_msg->data_ptr, ipc4_msg->data_size); +if (err <0 ) { +dev_err (sdev->dev,"failed to read IPC notification data: %d\n" , err); +kfree (ipc4_msg->data_ptr); + ipc4_msg->data_ptr =NULL ; + ipc4_msg->data_size =0 ; +return ; + } }sof_ipc4_log_header (sdev->dev,"ipc rx done " , ipc4_msg, true);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 144/341 hwmon: (pc87360) Bounds check data->innr usage
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 4265eb062a7303e537ab3792ade31f424c3c5189 ]
Without visibility into the initializers for data->innr, GCC suspects using it as an index could walk off the end of the various 14-element arrays in data. Perform an explicit clamp to the array size. Silences the following warning with GCC 12+:
../drivers/hwmon/pc87360.c: In function 'pc87360_update_device':../drivers/hwmon/pc87360.c:341:49: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
341 | data->in_max[i] = pc87360_read_value(data,
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
342 | LD_IN, i,
| ~~~~~~~~~
343 | PC87365_REG_IN_MAX);
| ~~~~~~~~~~~~~~~~~~~
../drivers/hwmon/pc87360.c:209:12: note: at offset 255 into destination object 'in_max' of size 14
209 | u8 in_max[14]; /* Register value */
| ^~~~~~--- drivers/hwmon/pc87360.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/hwmon/pc87360.c +5 -1
@@ -323,7 +323,11 @@ static struct pc87360_data *pc87360_update_device(struct device *dev) }/* Voltages */ -for (i =0 ; i < data->innr; i++) { +/* +* The min() below does not have any practical meaning and is +* only needed to silence a warning observed with gcc 12+. +*/ +for (i =0 ; i <min (data->innr,ARRAY_SIZE (data->in)); i++) { data->in_status[i] =pc87360_read_value (data,LD_IN , i,PC87365_REG_IN_STATUS );/* Clear bits */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 145/341 powerpc/pseries/papr-sysparm: Validate buffer object lengths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Lynch <[email protected]>
[ Upstream commit 35aae182bd7b422be3cefc08c12207bf2b973364 ]
The ability to get and set system parameters will be exposed to user space, so let's get a little more strict about malformed papr_sysparm_buf objects.
* Create accessors for the length field of struct papr_sysparm_buf. The length is always stored in MSB order and this is better than spreading the necessary conversions all over.
* Reject attempts to submit invalid buffers to RTAS.
* Warn if RTAS returns a buffer with an invalid length, clamping the returned length to a safe value that won't overrun the buffer.
These are meant as precautionary measures to mitigate both firmware and kernel bugs in this area, should they arise, but I am not aware of any.
--- arch/powerpc/platforms/pseries/papr-sysparm.c | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+)
arch/powerpc/platforms/pseries/papr-sysparm.c +47 -0
@@ -23,6 +23,46 @@ void papr_sysparm_buf_free(struct papr_sysparm_buf *buf)kfree (buf); } +static size_t papr_sysparm_buf_get_length (const struct papr_sysparm_buf *buf) +{ +return be16_to_cpu (buf->len); +} + +static void papr_sysparm_buf_set_length (struct papr_sysparm_buf *buf,size_t length) +{ +WARN_ONCE (length >sizeof (buf->val), +"bogus length %zu, clamping to safe value" , length); + length =min (sizeof (buf->val), length); + buf->len =cpu_to_be16 (length); +} + +/* +* For use on buffers returned from ibm,get-system-parameter before +* returning them to callers. Ensures the encoded length of valid data +* cannot overrun buf->val[]. +*/ +static void papr_sysparm_buf_clamp_length (struct papr_sysparm_buf *buf) +{ +papr_sysparm_buf_set_length (buf,papr_sysparm_buf_get_length (buf)); +} + +/* +* Perform some basic diligence on the system parameter buffer before +* submitting it to RTAS. +*/ +static bool papr_sysparm_buf_can_submit (const struct papr_sysparm_buf *buf) +{ +/* +* Firmware ought to reject buffer lengths that exceed the +* maximum specified in PAPR, but there's no reason for the +* kernel to allow them either. +*/ +if (papr_sysparm_buf_get_length (buf) >sizeof (buf->val)) +return false; + +return true; +} +/** * papr_sysparm_get() - Retrieve the value of a PAPR system parameter. * @param: PAPR system parameter token as described in
@@ -63,6 +103,9 @@ int papr_sysparm_get(papr_sysparm_t param, struct papr_sysparm_buf *buf)if (token ==RTAS_UNKNOWN_SERVICE )return -ENOENT ; +if (!papr_sysparm_buf_can_submit (buf)) +return -EINVAL ; + work_area =rtas_work_area_alloc (sizeof (*buf));memcpy (rtas_work_area_raw_buf (work_area), buf,sizeof (*buf));
@@ -77,6 +120,7 @@ int papr_sysparm_get(papr_sysparm_t param, struct papr_sysparm_buf *buf)case 0 : ret =0 ;memcpy (buf,rtas_work_area_raw_buf (work_area),sizeof (*buf)); +papr_sysparm_buf_clamp_length (buf);break ;case -3 :/* parameter not implemented */ ret = -EOPNOTSUPP ;
@@ -115,6 +159,9 @@ int papr_sysparm_set(papr_sysparm_t param, const struct papr_sysparm_buf *buf)if (token ==RTAS_UNKNOWN_SERVICE )return -ENOENT ; +if (!papr_sysparm_buf_can_submit (buf)) +return -EINVAL ; + work_area =rtas_work_area_alloc (sizeof (*buf));memcpy (rtas_work_area_raw_buf (work_area), buf,sizeof (*buf));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 146/341 ionic: prevent pci disable of already disabled device
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shannon Nelson <[email protected]>
[ Upstream commit 13943d6c82730a2a4e40e05d6deaca26a8de0a4d ]
If a reset fails, the PCI device is left in a disabled state, so don't try to disable it again on driver remove. This prevents a scary looking WARN trace in the kernel log.
ionic 0000:2b:00.0: disabling already-disabled device
--- drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +3 -1
@@ -217,7 +217,9 @@ static void ionic_clear_pci(struct ionic *ionic) {ionic_unmap_bars (ionic);pci_release_regions (ionic->pdev); -pci_disable_device (ionic->pdev); + +if (atomic_read (&ionic->pdev->enable_cnt) >0 ) +pci_disable_device (ionic->pdev); }static int ionic_setup_one (struct ionic *ionic)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 147/341 ionic: no fw read when PCI reset failed
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shannon Nelson <[email protected]>
[ Upstream commit 219e183272b4a566650a37264aff90a8c613d9b5 ]
If there was a failed attempt to reset the PCI connection, don't later try to read from PCI as the space is unmapped and will cause a paging request crash. When clearing the PCI setup we can clear the dev_info register pointer, and check it before using it in the fw_running test.
--- .../ethernet/pensando/ionic/ionic_bus_pci.c | 5 ++++ .../net/ethernet/pensando/ionic/ionic_dev.c | 23 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +5 -0
@@ -215,6 +215,11 @@ static int ionic_sriov_configure(struct pci_dev *pdev, int num_vfs)static void ionic_clear_pci (struct ionic *ionic) { + ionic->idev.dev_info_regs =NULL ; + ionic->idev.dev_cmd_regs =NULL ; + ionic->idev.intr_status =NULL ; + ionic->idev.intr_ctrl =NULL ; +ionic_unmap_bars (ionic);pci_release_regions (ionic->pdev);
drivers/net/ethernet/pensando/ionic/ionic_dev.c +18 -5
@@ -165,9 +165,19 @@ void ionic_dev_teardown(struct ionic *ionic) }/* Devcmd Interface */ -bool ionic_is_fw_running (struct ionic_dev *idev) +static bool __ionic_is_fw_running (struct ionic_dev *idev,u8 *status_ptr) { -u8 fw_status =ioread8 (&idev->dev_info_regs->fw_status); +u8 fw_status; + +if (!idev->dev_info_regs) { +if (status_ptr) + *status_ptr =0xff ; +return false; + } + + fw_status =ioread8 (&idev->dev_info_regs->fw_status); +if (status_ptr) + *status_ptr = fw_status;/* firmware is useful only if the running bit is set and * fw_status != 0xff (bad PCI read)
@@ -175,6 +185,11 @@ bool ionic_is_fw_running(struct ionic_dev *idev)return (fw_status !=0xff ) && (fw_status &IONIC_FW_STS_F_RUNNING ); } +bool ionic_is_fw_running (struct ionic_dev *idev) +{ +return __ionic_is_fw_running (idev,NULL ); +} +int ionic_heartbeat_check (struct ionic *ionic) {unsigned long check_time, last_check_time;
@@ -199,10 +214,8 @@ int ionic_heartbeat_check(struct ionic *ionic) goto do_check_time; } - fw_status =ioread8 (&idev->dev_info_regs->fw_status); -/* If fw_status is not ready don't bother with the generation */ -if (!ionic_is_fw_running (idev)) { +if (!__ionic_is_fw_running (idev, &fw_status)) { fw_status_ready = false; }else { fw_generation = fw_status &IONIC_FW_STS_F_GENERATION ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 148/341 drm/rockchip: vop2: clear afbc en and transform bit for cluster window at linear mode
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Yan <[email protected]>
[ Upstream commit 20529a68307feed00dd3d431d3fff0572616b0f2 ]
The enable bit and transform offset of cluster windows should be cleared when it work at linear mode, or we may have a iommu fault issue on rk3588 which cluster windows switch between afbc and linear mode.
As the cluster windows of rk3568 only supports afbc format so is therefore not affected.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +5 -0
@@ -1260,6 +1260,11 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,vop2_win_write (win,VOP2_WIN_AFBC_ROTATE_270 , rotate_270);vop2_win_write (win,VOP2_WIN_AFBC_ROTATE_90 , rotate_90); }else { +if (vop2_cluster_window (win)) { +vop2_win_write (win,VOP2_WIN_AFBC_ENABLE ,0 ); +vop2_win_write (win,VOP2_WIN_AFBC_TRANSFORM_OFFSET ,0 ); + } +vop2_win_write (win,VOP2_WIN_YRGB_VIR ,DIV_ROUND_UP (fb->pitches[0 ],4 )); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 149/341 evm: dont copy up security.evm xattr
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mimi Zohar <[email protected]>
[ Upstream commit 40ca4ee3136d2d09977d1cab8c0c0e1582c3359d ]
The security.evm HMAC and the original file signatures contain filesystem specific data. As a result, the HMAC and signature are not the same on the stacked and backing filesystems.
Don't copy up 'security.evm'.
--- include/linux/evm.h | 6 ++++++ security/integrity/evm/evm_main.c | 7 +++++++ security/security.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-)
include/linux/evm.h +6 -0
@@ -31,6 +31,7 @@ extern void evm_inode_post_setxattr(struct dentry *dentry,const char *xattr_name, const void *xattr_value, size_t xattr_value_len); +extern int evm_inode_copy_up_xattr (const char *name);extern int evm_inode_removexattr (struct mnt_idmap *idmap,struct dentry *dentry,const char *xattr_name); extern void evm_inode_post_removexattr(struct dentry *dentry,
@@ -117,6 +118,11 @@ static inline void evm_inode_post_setxattr(struct dentry *dentry,return ; } +static inline int evm_inode_copy_up_xattr (const char *name) +{ +return 0 ; +} +static inline int evm_inode_removexattr (struct mnt_idmap *idmap,struct dentry *dentry,const char *xattr_name)
security/integrity/evm/evm_main.c +7 -0
@@ -864,6 +864,13 @@ void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)evm_update_evmxattr (dentry,NULL ,NULL ,0 ); } +int evm_inode_copy_up_xattr (const char *name) +{ +if (strcmp (name,XATTR_NAME_EVM ) ==0 ) +return 1 ;/* Discard */ +return -EOPNOTSUPP ; +} +/* * evm_inode_init_security - initializes security.evm HMAC value */
security/security.c +1 -1
@@ -2539,7 +2539,7 @@ int security_inode_copy_up_xattr(const char *name)return rc; } -return LSM_RET_DEFAULT (inode_copy_up_xattr); +return evm_inode_copy_up_xattr (name); }EXPORT_SYMBOL (security_inode_copy_up_xattr);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 150/341 Bluetooth: hci_conn: Check non NULL function before calling for HFP offload
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit 132d0fd0b8418094c9e269e5bc33bf5b864f4a65 ]
For some controllers such as QCA2066, it does not need to send HCI_Configure_Data_Path to configure non-HCI data transport path to support HFP offload, their device drivers may set hdev->get_codec_config_data as NULL, so Explicitly add this non NULL checking before calling the function.
--- net/bluetooth/hci_conn.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
net/bluetooth/hci_conn.c +8 -3
@@ -299,6 +299,13 @@ static int configure_datapath_sync(struct hci_dev *hdev, struct bt_codec *codec)__u8 vnd_len, *vnd_data =NULL ;struct hci_op_configure_data_path *cmd =NULL ; +if (!codec->data_path || !hdev->get_codec_config_data) +return 0 ; + +/* Do not take me as error */ +if (!hdev->get_codec_config_data) +return 0 ; + err = hdev->get_codec_config_data (hdev,ESCO_LINK , codec, &vnd_len, &vnd_data);if (err <0 )
@@ -344,9 +351,7 @@ static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data)bt_dev_dbg (hdev,"hcon %p" , conn); -/* for offload use case, codec needs to configured before opening SCO */ -if (conn->codec.data_path) -configure_datapath_sync (hdev, &conn->codec); +configure_datapath_sync (hdev, &conn->codec); conn->state =BT_CONNECT ; conn->out = true;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 151/341 gfs2: Refcounting fix in gfs2_thaw_super
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
[ Upstream commit 4e58543e7da4859c4ba61d15493e3522b6ad71fd ]
It turns out that the .freeze_super and .thaw_super operations require the filesystem to manage the superblock refcount itself. We are using the freeze_super() and thaw_super() helpers to mostly take care of that for us, but this means that the superblock may no longer be around by when thaw_super() returns, and gfs2_thaw_super() will then access freed memory. Take an extra superblock reference in gfs2_thaw_super() to fix that.
--- fs/gfs2/super.c | 2 ++ 1 file changed, 2 insertions(+)
fs/gfs2/super.c +2 -0
@@ -819,6 +819,7 @@ static int gfs2_thaw_super(struct super_block *sb, enum freeze_holder who)if (!test_bit (SDF_FREEZE_INITIATOR , &sdp->sd_flags)) goto out; +atomic_inc (&sb->s_active);gfs2_freeze_unlock (&sdp->sd_freeze_gh); error =gfs2_do_thaw (sdp);
@@ -829,6 +830,7 @@ static int gfs2_thaw_super(struct super_block *sb, enum freeze_holder who) } out:mutex_unlock (&sdp->sd_freeze_mutex); +deactivate_super (sb);return error; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 152/341 EDAC/skx_common: Filter out the invalid address
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiuxu Zhuo <[email protected]>
[ Upstream commit 1e92af09fab1b5589f3a7ae68109e3c6a5ca6c6e ]
Decoding an invalid address with certain firmware decoders could cause a #PF (Page Fault) in the EFI runtime context, which could subsequently hang the system. To make {i10nm,skx}_edac more robust against such bogus firmware decoders, filter out invalid addresses before allowing the firmware decoder to process them.
--- drivers/edac/skx_common.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/edac/skx_common.c +4 -0
@@ -659,6 +659,10 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,memset (&res,0 ,sizeof (res)); res.mce = mce; res.addr = mce->addr &MCI_ADDR_PHYSADDR ; +if (!pfn_to_online_page (res.addr >>PAGE_SHIFT )) { +pr_err ("Invalid address 0x%llx in IA32_MC%d_ADDR\n" , mce->addr, mce->bank); +return NOTIFY_DONE ; + }/* Try driver decoder first */ if (!(driver_decode &&driver_decode (&res))) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 153/341 nvmet-trace: avoid dereferencing pointer too early
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit 0e716cec6fb11a14c220ee17c404b67962e902f7 ]
The first command issued from the host to the target is the fabrics connect command. At this point, neither the target queue nor the controller have been allocated. But we already try to trace this command in nvmet_req_init.
Reported by KASAN.
--- drivers/nvme/target/trace.c | 6 +++--- drivers/nvme/target/trace.h | 28 +++++++++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-)
drivers/nvme/target/trace.c +3 -3
@@ -211,7 +211,7 @@ const char *nvmet_trace_disk_name(struct trace_seq *p, char *name)return ret; } -const char *nvmet_trace_ctrl_name (struct trace_seq *p,struct nvmet_ctrl *ctrl) +const char *nvmet_trace_ctrl_id (struct trace_seq *p,u16 ctrl_id) {const char *ret =trace_seq_buffer_ptr (p);
@@ -224,8 +224,8 @@ const char *nvmet_trace_ctrl_name(struct trace_seq *p, struct nvmet_ctrl *ctrl)* If we can know the extra data of the connect command in this stage, * we can update this print statement later. */ -if (ctrl) -trace_seq_printf (p,"%d" , ctrl->cntlid); +if (ctrl_id) +trace_seq_printf (p,"%d" , ctrl_id);else trace_seq_printf (p,"_" );trace_seq_putc (p,0 );
drivers/nvme/target/trace.h +17 -11
@@ -32,18 +32,24 @@ const char *nvmet_trace_parse_fabrics_cmd(struct trace_seq *p, u8 fctype, nvmet_trace_parse_nvm_cmd(p, opcode, cdw10) : \ nvmet_trace_parse_admin_cmd(p, opcode, cdw10))) -const char *nvmet_trace_ctrl_name (struct trace_seq *p,struct nvmet_ctrl *ctrl); -#define __print_ctrl_name (ctrl) \ - nvmet_trace_ctrl_name(p, ctrl) +const char *nvmet_trace_ctrl_id (struct trace_seq *p,u16 ctrl_id); +#define __print_ctrl_id (ctrl_id) \ + nvmet_trace_ctrl_id(p, ctrl_id)const char *nvmet_trace_disk_name (struct trace_seq *p,char *name);#define __print_disk_name (name) \ nvmet_trace_disk_name(p, name)#ifndef TRACE_HEADER_MULTI_READ -static inline struct nvmet_ctrl *nvmet_req_to_ctrl (struct nvmet_req *req) +static inline u16 nvmet_req_to_ctrl_id (struct nvmet_req *req) { -return req->sq->ctrl; +/* +* The queue and controller pointers are not valid until an association +* has been established. +*/ +if (!req->sq || !req->sq->ctrl) +return 0 ; +return req->sq->ctrl->cntlid; }static inline void __assign_req_name (char *name,struct nvmet_req *req)
@@ -62,7 +68,7 @@ TRACE_EVENT(nvmet_req_init, TP_ARGS(req, cmd),TP_STRUCT__entry (__field (struct nvme_command *,cmd ) - __field(struct nvmet_ctrl *, ctrl) +__field (u16, ctrl_id)__array (char, disk,DISK_NAME_LEN )__field (int, qid) __field(u16, cid)
@@ -75,7 +81,7 @@ TRACE_EVENT(nvmet_req_init, ), TP_fast_assign( __entry->cmd = cmd; - __entry->ctrl =nvmet_req_to_ctrl (req); + __entry->ctrl_id =nvmet_req_to_ctrl_id (req);__assign_req_name (__entry->disk, req); __entry->qid = req->sq->qid; __entry->cid = cmd->common.command_id;
@@ -89,7 +95,7 @@ TRACE_EVENT(nvmet_req_init, ), TP_printk("nvmet%s: %sqid=%d, cmdid=%u, nsid=%u, flags=%#x, " "meta=%#llx, cmd=(%s, %s)", - __print_ctrl_name(__entry->ctrl), + __print_ctrl_id(__entry->ctrl_id), __print_disk_name(__entry->disk), __entry->qid, __entry->cid, __entry->nsid, __entry->flags, __entry->metadata,
@@ -103,7 +109,7 @@ TRACE_EVENT(nvmet_req_complete, TP_PROTO(struct nvmet_req *req), TP_ARGS(req), TP_STRUCT__entry( - __field(struct nvmet_ctrl *, ctrl) + __field(u16, ctrl_id) __array(char, disk, DISK_NAME_LEN) __field(int, qid) __field(int, cid)
@@ -111,7 +117,7 @@ TRACE_EVENT(nvmet_req_complete,__field (u16, status) ),TP_fast_assign ( - __entry->ctrl = nvmet_req_to_ctrl(req); + __entry->ctrl_id = nvmet_req_to_ctrl_id(req); __entry->qid = req->cq->qid; __entry->cid = req->cqe->command_id; __entry->result =le64_to_cpu (req->cqe->result.u64);
@@ -119,7 +125,7 @@ TRACE_EVENT(nvmet_req_complete,__assign_req_name (__entry->disk, req); ),TP_printk ("nvmet%s: %sqid=%d, cmdid=%u, res=%#llx, status=%#x" , -__print_ctrl_name (__entry->ctrl), +__print_ctrl_id (__entry->ctrl_id),__print_disk_name (__entry->disk), __entry->qid, __entry->cid, __entry->result, __entry->status)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 154/341 ext4: do not trim the group with corrupted block bitmap
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 172202152a125955367393956acf5f4ffd092e0d ]
Otherwise operating on an incorrupted block bitmap can lead to all sorts of unknown problems.
--- fs/ext4/mballoc.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ext4/mballoc.c +3 -0
@@ -6953,6 +6953,9 @@ __releases(ext4_group_lock_ptr(sb, e4b->bd_group))bool set_trimmed = false;void *bitmap; +if (unlikely (EXT4_MB_GRP_BBITMAP_CORRUPT (e4b->bd_info))) +return 0 ; + last =ext4_last_grp_cluster (sb, e4b->bd_group); bitmap = e4b->bd_bitmap;if (start ==0 && max >= last)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 155/341 btrfs: zlib: fix and simplify the inline extent decompression
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 2c25716dcc25a0420c4ad49d6e6bf61e60a21434 ]
[BUG]
If we have a filesystem with 4k sectorsize, and an inlined compressed extent created like this:
item 4 key (257 INODE_ITEM 0) itemoff 15863 itemsize 160
generation 8 transid 8 size 4096 nbytes 4096 block group 0 mode 100600 links 1 uid 0 gid 0 rdev 0 sequence 1 flags 0x0(none)
item 5 key (257 INODE_REF 256) itemoff 15839 itemsize 24
index 2 namelen 14 name: source_inlined
item 6 key (257 EXTENT_DATA 0) itemoff 15770 itemsize 69
generation 8 type 0 (inline)
inline extent data size 48 ram_bytes 4096 compression 1 (zlib)
Which has an inline compressed extent at file offset 0, and its decompressed size is 4K, allowing us to reflink that 4K range to another location (which will not be compressed).
If we do such reflink on a subpage system, it would fail like this:
# xfs_io -f -c "reflink $mnt/source_inlined 0 60k 4k" $mnt/dest XFS_IOC_CLONE_RANGE: Input/output error
[CAUSE]
In zlib_decompress(), we didn't treat @start_byte as just a page offset, but also use it as an indicator on whether we should switch our output buffer.
In reality, for subpage cases, although @start_byte can be non-zero, we should never switch input/output buffer, since the whole input/output buffer should never exceed one sector.
Note: The above assumption is only not true if we're going to support multi-page sectorsize.
Thus the current code using @start_byte as a condition to switch input/output buffer or finish the decompression is completely incorrect.
[FIX]
The fix involves several modifications:
- Rename @start_byte to @dest_pgoff to properly express its meaning
- Add an extra ASSERT() inside btrfs_decompress() to make sure the input/output size never exceeds one sector.
- Use Z_FINISH flag to make sure the decompression happens in one go
- Remove the loop needed to switch input/output buffers
- Use correct destination offset inside the destination page
- Consider early end as an error
After the fix, even on 64K page sized aarch64, above reflink now works as expected:
# xfs_io -f -c "reflink $mnt/source_inlined 0 60k 4k" $mnt/dest linked 4096/4096 bytes at offset 61440
And resulted a correct file layout:
item 9 key (258 INODE_ITEM 0) itemoff 15542 itemsize 160 generation 10 transid 10 size 65536 nbytes 4096 block group 0 mode 100600 links 1 uid 0 gid 0 rdev 0 sequence 1 flags 0x0(none) item 10 key (258 INODE_REF 256) itemoff 15528 itemsize 14 index 3 namelen 4 name: dest item 11 key (258 XATTR_ITEM 3817753667) itemoff 15445 itemsize 83 location key (0 UNKNOWN.0 0) type XATTR transid 10 data_len 37 name_len 16 name: security.selinux data unconfined_u:object_r:unlabeled_t:s0 item 12 key (258 EXTENT_DATA 61440) itemoff 15392 itemsize 53 generation 10 type 1 (regular) extent data disk byte 13631488 nr 4096 extent data offset 0 nr 4096 ram 4096 extent compression 0 (none)
--- fs/btrfs/compression.c | 23 +++++++++---- fs/btrfs/compression.h | 2 +- fs/btrfs/zlib.c | 73 +++++++++++------------------------------- 3 files changed, 36 insertions(+), 62 deletions(-)
fs/btrfs/compression.c +16 -7
@@ -140,16 +140,16 @@ static int compression_decompress_bio(struct list_head *ws, }static int compression_decompress (int type,struct list_head *ws, -const u8 *data_in,struct page *dest_page, -unsigned long start_byte,size_t srclen,size_t destlen) +const u8 *data_in,struct page *dest_page, +unsigned long dest_pgoff,size_t srclen,size_t destlen) {switch (type) {case BTRFS_COMPRESS_ZLIB :return zlib_decompress (ws, data_in, dest_page, - start_byte, srclen, destlen); + dest_pgoff, srclen, destlen);case BTRFS_COMPRESS_LZO :return lzo_decompress (ws, data_in, dest_page, - start_byte, srclen, destlen); + dest_pgoff, srclen, destlen);case BTRFS_COMPRESS_ZSTD :return zstd_decompress (ws, data_in, dest_page, - start_byte, srclen, destlen); + dest_pgoff, srclen, destlen);case BTRFS_COMPRESS_NONE :default :/*
@@ -941,14 +941,23 @@ static int btrfs_decompress_bio(struct compressed_bio *cb)* start_byte tells us the offset into the compressed data we're interested in */ int btrfs_decompress (int type,const u8 *data_in,struct page *dest_page, -unsigned long start_byte,size_t srclen,size_t destlen) +unsigned long dest_pgoff,size_t srclen,size_t destlen) { +struct btrfs_fs_info *fs_info =btrfs_sb (dest_page->mapping->host->i_sb);struct list_head *workspace; +const u32 sectorsize = fs_info->sectorsize;int ret; +/* +* The full destination page range should not exceed the page size. +* And the @destlen should not exceed sectorsize, as this is only called for +* inline file extents, which should not exceed sectorsize. +*/ +ASSERT (dest_pgoff + destlen <=PAGE_SIZE && destlen <= sectorsize); + workspace =get_workspace (type,0 ); ret =compression_decompress (type, workspace, data_in, dest_page, - start_byte, srclen, destlen); + dest_pgoff, srclen, destlen);put_workspace (type, workspace);return ret;
fs/btrfs/compression.h +1 -1
@@ -143,7 +143,7 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping, unsigned long *total_in, unsigned long *total_out);int zlib_decompress_bio (struct list_head *ws,struct compressed_bio *cb);int zlib_decompress (struct list_head *ws,const u8 *data_in, -struct page *dest_page,unsigned long start_byte,size_t srclen, +struct page *dest_page,unsigned long dest_pgoff,size_t srclen,size_t destlen);struct list_head *zlib_alloc_workspace (unsigned int level);void zlib_free_workspace (struct list_head *ws);
fs/btrfs/zlib.c +19 -54
97 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 156/341 afs: fix __afs_break_callback() / afs_drop_open_mmap() race
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit 275655d3207b9e65d1561bf21c06a622d9ec1d43 ]
In __afs_break_callback() we might check ->cb_nr_mmap and if it's non-zero do queue_work(&vnode->cb_work). In afs_drop_open_mmap() we decrement ->cb_nr_mmap and do flush_work(&vnode->cb_work) if it reaches zero.
The trouble is, there's nothing to prevent __afs_break_callback() from seeing ->cb_nr_mmap before the decrement and do queue_work() after both the decrement and flush_work(). If that happens, we might be in trouble - vnode might get freed before the queued work runs.
__afs_break_callback() is always done under ->cb_lock, so let's make sure that ->cb_nr_mmap can change from non-zero to zero while holding ->cb_lock (the spinlock component of it - it's a seqlock and we don't need to mess with the counter).
--- fs/afs/file.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/afs/file.c +6 -2
@@ -529,13 +529,17 @@ static void afs_add_open_mmap(struct afs_vnode *vnode)static void afs_drop_open_mmap (struct afs_vnode *vnode) { -if (!atomic_dec_and_test (&vnode->cb_nr_mmap)) +if (atomic_add_unless (&vnode->cb_nr_mmap,-1 ,1 ))return ;down_write (&vnode->volume->cell->fs_open_mmaps_lock); -if (atomic_read (&vnode->cb_nr_mmap) ==0 ) +read_seqlock_excl (&vnode->cb_lock); +// the only place where ->cb_nr_mmap may hit 0 +// see __afs_break_callback() for the other side... +if (atomic_dec_and_test (&vnode->cb_nr_mmap))list_del_init (&vnode->cb_mmap_link); +read_sequnlock_excl (&vnode->cb_lock);up_write (&vnode->volume->cell->fs_open_mmaps_lock);flush_work (&vnode->cb_work);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 157/341 fuse: fix UAF in rcu pathwalks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit 053fc4f755ad43cf35210677bcba798ccdc48d0c ]
->permission(), ->get_link() and ->inode_get_acl() might dereference ->s_fs_info (and, in case of ->permission(), ->s_fs_info->fc->user_ns as well) when called from rcu pathwalk.
Freeing ->s_fs_info->fc is rcu-delayed; we need to make freeing ->s_fs_info and dropping ->user_ns rcu-delayed too.
--- fs/fuse/cuse.c | 3 +-- fs/fuse/fuse_i.h | 1 + fs/fuse/inode.c | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-)
fs/fuse/cuse.c +1 -2
@@ -474,8 +474,7 @@ static int cuse_send_init(struct cuse_conn *cc)static void cuse_fc_release (struct fuse_conn *fc) { -struct cuse_conn *cc =fc_to_cc (fc); -kfree_rcu (cc, fc.rcu); +kfree (fc_to_cc (fc)); }/**
fs/fuse/fuse_i.h +1 -0
@@ -888,6 +888,7 @@ struct fuse_mount {/* Entry on fc->mounts */ struct list_head fc_entry; +struct rcu_head rcu; };static inline struct fuse_mount *get_fuse_mount_super (struct super_block *sb)
fs/fuse/inode.c +11 -4
@@ -952,6 +952,14 @@ void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm, }EXPORT_SYMBOL_GPL (fuse_conn_init); +static void delayed_release (struct rcu_head *p) +{ + struct fuse_conn *fc = container_of(p, struct fuse_conn, rcu); + +put_user_ns (fc->user_ns); + fc->release (fc); +} +void fuse_conn_put (struct fuse_conn *fc) {if (refcount_dec_and_test (&fc->count)) {
@@ -963,13 +971,12 @@ void fuse_conn_put(struct fuse_conn *fc)if (fiq->ops->release) fiq->ops->release (fiq);put_pid_ns (fc->pid_ns); -put_user_ns (fc->user_ns); bucket =rcu_dereference_protected (fc->curr_bucket,1 );if (bucket) {WARN_ON (atomic_read (&bucket->count) !=1 );kfree (bucket); } - fc->release (fc); +call_rcu (&fc->rcu, delayed_release); } }EXPORT_SYMBOL_GPL (fuse_conn_put);
@@ -1387,7 +1394,7 @@ EXPORT_SYMBOL_GPL(fuse_send_init);void fuse_free_conn (struct fuse_conn *fc) {WARN_ON (!list_empty (&fc->devices)); -kfree_rcu (fc, rcu); +kfree (fc); }EXPORT_SYMBOL_GPL (fuse_free_conn);
@@ -1921,7 +1928,7 @@ static void fuse_sb_destroy(struct super_block *sb)void fuse_mount_destroy (struct fuse_mount *fm) {fuse_conn_put (fm->fc); -kfree (fm); +kfree_rcu (fm, rcu); }EXPORT_SYMBOL (fuse_mount_destroy);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 158/341 wifi: ath12k: Add missing qmi_txn_cancel() calls
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <[email protected]>
[ Upstream commit 2e82b5f09a97f1b98b885470c81c1248bec103af ]
Per the QMI documentation "A client calling qmi_txn_init() must call either qmi_txn_wait() or qmi_txn_cancel() to free up the allocated resources."
Unfortunately, in most of the ath12k messaging functions, when qmi_send_request() fails, the function returns without performing the necessary cleanup. So update those functions to call qmi_txn_cancel() when qmi_send_request() fails.
No functional changes, compile tested only.
--- drivers/net/wireless/ath/ath12k/qmi.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/ath/ath12k/qmi.c +7 -0
@@ -1977,6 +1977,7 @@ static int ath12k_qmi_host_cap_send(struct ath12k_base *ab)QMI_WLANFW_HOST_CAP_REQ_MSG_V01_MAX_LEN , qmi_wlanfw_host_cap_req_msg_v01_ei, &req);if (ret <0 ) { +qmi_txn_cancel (&txn);ath12k_warn (ab,"Failed to send host capability request,err = %d\n" , ret); goto out; }
@@ -2040,6 +2041,7 @@ static int ath12k_qmi_fw_ind_register_send(struct ath12k_base *ab)QMI_WLANFW_IND_REGISTER_REQ_MSG_V01_MAX_LEN , qmi_wlanfw_ind_register_req_msg_v01_ei, req);if (ret <0 ) { +qmi_txn_cancel (&txn);ath12k_warn (ab,"Failed to send indication register request, err = %d\n" , ret); goto out;
@@ -2114,6 +2116,7 @@ static int ath12k_qmi_respond_fw_mem_request(struct ath12k_base *ab)QMI_WLANFW_RESPOND_MEM_REQ_MSG_V01_MAX_LEN , qmi_wlanfw_respond_mem_req_msg_v01_ei, req);if (ret <0 ) { +qmi_txn_cancel (&txn);ath12k_warn (ab,"qmi failed to respond memory request, err = %d\n" , ret); goto out;
@@ -2228,6 +2231,7 @@ static int ath12k_qmi_request_target_cap(struct ath12k_base *ab)QMI_WLANFW_CAP_REQ_MSG_V01_MAX_LEN , qmi_wlanfw_cap_req_msg_v01_ei, &req);if (ret <0 ) { +qmi_txn_cancel (&txn);ath12k_warn (ab,"qmi failed to send target cap request, err = %d\n" , ret); goto out;
@@ -2567,6 +2571,7 @@ static int ath12k_qmi_wlanfw_m3_info_send(struct ath12k_base *ab)QMI_WLANFW_M3_INFO_REQ_MSG_V01_MAX_MSG_LEN , qmi_wlanfw_m3_info_req_msg_v01_ei, &req);if (ret <0 ) { +qmi_txn_cancel (&txn);ath12k_warn (ab,"qmi failed to send M3 information request, err = %d\n" , ret); goto out;
@@ -2613,6 +2618,7 @@ static int ath12k_qmi_wlanfw_mode_send(struct ath12k_base *ab,QMI_WLANFW_WLAN_MODE_REQ_MSG_V01_MAX_LEN , qmi_wlanfw_wlan_mode_req_msg_v01_ei, &req);if (ret <0 ) { +qmi_txn_cancel (&txn);ath12k_warn (ab,"qmi failed to send mode request, mode: %d, err = %d\n" , mode, ret); goto out;
@@ -2704,6 +2710,7 @@ static int ath12k_qmi_wlanfw_wlan_cfg_send(struct ath12k_base *ab)QMI_WLANFW_WLAN_CFG_REQ_MSG_V01_MAX_LEN , qmi_wlanfw_wlan_cfg_req_msg_v01_ei, req);if (ret <0 ) { +qmi_txn_cancel (&txn);ath12k_warn (ab,"qmi failed to send wlan config request, err = %d\n" , ret); goto out;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 159/341 quota: Remove BUG_ON from dqget()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit 249f374eb9b6b969c64212dd860cc1439674c4a8 ]
dqget() checks whether dquot->dq_sb is set when returning it using BUG_ON. Firstly this doesn't work as an invalidation check for quite some time (we release dquot with dq_sb set these days), secondly using BUG_ON is quite harsh. Use WARN_ON_ONCE and check whether dquot is still hashed instead.
--- fs/quota/dquot.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/quota/dquot.c +2 -3
@@ -995,9 +995,8 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid)* smp_mb__before_atomic() in dquot_acquire(). */ smp_rmb (); -#ifdef CONFIG_QUOTA_DEBUG -BUG_ON (!dquot->dq_sb);/* Has somebody invalidated entry under us? */ -#endif +/* Has somebody invalidated entry under us? */ +WARN_ON_ONCE (hlist_unhashed (&dquot->dq_hash)); out:if (empty)do_destroy_dquot (empty);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 160/341 riscv: blacklist assembly symbols for kprobe
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Clément Léger <[email protected]>
[ Upstream commit 5014396af9bbac0f28d9afee7eae405206d01ee7 ]
Adding kprobes on some assembly functions (mainly exception handling) will result in crashes (either recursive trap or panic). To avoid such errors, add ASM_NOKPROBE() macro which allow adding specific symbols into the __kprobe_blacklist section and use to blacklist the following symbols that showed to be problematic:
- handle_exception()
- ret_from_exception()
- handle_kernel_stack_overflow()
--- arch/riscv/include/asm/asm.h | 10 ++++++++++ arch/riscv/kernel/entry.S | 3 +++ 2 files changed, 13 insertions(+)
arch/riscv/include/asm/asm.h +10 -0
@@ -164,6 +164,16 @@ REG_L x31, PT_T6(sp) .endm +/* Annotate a function as being unsuitable for kprobes. */ +#ifdef CONFIG_KPROBES +#define ASM_NOKPROBE (name) \ + .pushsection "_kprobe_blacklist", "aw"; \ + RISCV_PTR name; \ + .popsection +#else +#define ASM_NOKPROBE (name) +#endif +#endif /* __ASSEMBLY__ */ #endif /* _ASM_RISCV_ASM_H */
arch/riscv/kernel/entry.S +3 -0
@@ -105,6 +105,7 @@ _save_context: 1: tail do_trap_unknown SYM_CODE_END(handle_exception) +ASM_NOKPROBE(handle_exception) /* * The ret_from_exception must be called with interrupt disabled. Here is the
@@ -171,6 +172,7 @@ SYM_CODE_START_NOALIGN(ret_from_exception) sret #endif SYM_CODE_END(ret_from_exception) +ASM_NOKPROBE(ret_from_exception) #ifdef CONFIG_VMAP_STACK SYM_CODE_START_LOCAL(handle_kernel_stack_overflow)
@@ -206,6 +208,7 @@ SYM_CODE_START_LOCAL(handle_kernel_stack_overflow) move a0, sp tail handle_bad_stack SYM_CODE_END(handle_kernel_stack_overflow) +ASM_NOKPROBE(handle_kernel_stack_overflow) #endif SYM_CODE_START(ret_from_fork)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 161/341 kernfs: fix false-positive WARN(nr_mmapped) in kernfs_drain_open_files
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neel Natu <[email protected]>
[ Upstream commit 05d8f255867e3196565bb31a911a437697fab094 ]
Prior to this change 'on->nr_mmapped' tracked the total number of mmaps across all of its associated open files via kernfs_fop_mmap(). Thus if the file descriptor associated with a kernfs_open_file was mmapped 10 times then we would have: 'of->mmapped = true' and 'of_on(of)->nr_mmapped = 10'.
The problem is that closing or draining a 'of->mmapped' file would only decrement one from the 'of_on(of)->nr_mmapped' counter.
For e.g. we have this from kernfs_unlink_open_file():
if (of->mmapped)
on->nr_mmapped--;The WARN_ON_ONCE(on->nr_mmapped) in kernfs_drain_open_files() is easy to reproduce by:
1. opening a (mmap-able) kernfs file.
2. mmap-ing that file more than once (mapping just once masks the issue).
3. trigger a drain of that kernfs file.
Modulo out-of-tree patches I was able to trigger this reliably by identifying pci device nodes in sysfs that have resource regions that are mmap-able and that don't have any driver attached to them (steps 1 and 2). For step 3 we can "echo 1 > remove" to trigger a kernfs_drain.
--- fs/kernfs/file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/kernfs/file.c +5 -3
@@ -532,9 +532,11 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) goto out_put; rc =0 ; - of->mmapped = true; -of_on (of)->nr_mmapped++; - of->vm_ops = vma->vm_ops; +if (!of->mmapped) { + of->mmapped = true; +of_on (of)->nr_mmapped++; + of->vm_ops = vma->vm_ops; + } vma->vm_ops = &kernfs_vm_ops; out_put:kernfs_put_active (of->kn);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 162/341 media: pci: cx23885: check cx23885_vdev_init() return
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit 15126b916e39b0cb67026b0af3c014bfeb1f76b3 ]
cx23885_vdev_init() can return a NULL pointer, but that pointer is used in the next line without a check.
Add a NULL pointer check and go to the error unwind if it is NULL.
--- drivers/media/pci/cx23885/cx23885-video.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/media/pci/cx23885/cx23885-video.c +8 -0
@@ -1354,6 +1354,10 @@ int cx23885_video_register(struct cx23885_dev *dev)/* register Video device */ dev->video_dev =cx23885_vdev_init (dev, dev->pci, &cx23885_video_template,"video" ); +if (!dev->video_dev) { + err = -ENOMEM ; + goto fail_unreg; + } dev->video_dev->queue = &dev->vb2_vidq; dev->video_dev->device_caps =V4L2_CAP_READWRITE |V4L2_CAP_STREAMING |V4L2_CAP_AUDIO |V4L2_CAP_VIDEO_CAPTURE ;
@@ -1382,6 +1386,10 @@ int cx23885_video_register(struct cx23885_dev *dev)/* register VBI device */ dev->vbi_dev =cx23885_vdev_init (dev, dev->pci, &cx23885_vbi_template,"vbi" ); +if (!dev->vbi_dev) { + err = -ENOMEM ; + goto fail_unreg; + } dev->vbi_dev->queue = &dev->vb2_vbiq; dev->vbi_dev->device_caps =V4L2_CAP_READWRITE |V4L2_CAP_STREAMING |V4L2_CAP_AUDIO |V4L2_CAP_VBI_CAPTURE ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 163/341 fs: binfmt_elf_efpic: dont use missing interpreters properties
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Filippov <[email protected]>
[ Upstream commit 15fd1dc3dadb4268207fa6797e753541aca09a2a ]
Static FDPIC executable may get an executable stack even when it has non-executable GNU_STACK segment. This happens when STACK segment has rw permissions, but does not specify stack size. In that case FDPIC loader uses permissions of the interpreter's stack, and for static executables with no interpreter it results in choosing the arch-default permissions for the stack.
Fix that by using the interpreter's properties only when the interpreter is actually used.
--- fs/binfmt_elf_fdpic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_elf_fdpic.c +1 -1
@@ -320,7 +320,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)else executable_stack =EXSTACK_DEFAULT ; -if (stack_size ==0 ) { +if (stack_size ==0 && interp_params.flags &ELF_FDPIC_FLAG_PRESENT ) { stack_size = interp_params.stack_size;if (interp_params.flags &ELF_FDPIC_FLAG_EXEC_STACK ) executable_stack =EXSTACK_ENABLE_X ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 164/341 scsi: lpfc: Initialize status local variable in lpfc_sli4_repost_sgl_list()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Tee <[email protected]>
[ Upstream commit 3d0f9342ae200aa1ddc4d6e7a573c6f8f068d994 ]
A static code analyzer tool indicates that the local variable called status in the lpfc_sli4_repost_sgl_list() routine could be used to print garbage uninitialized values in the routine's log message.
Fix by initializing to zero.
--- drivers/scsi/lpfc/lpfc_sli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_sli.c +1 -1
@@ -7577,7 +7577,7 @@ lpfc_sli4_repost_sgl_list(struct lpfc_hba *phba,struct lpfc_sglq *sglq_entry =NULL ;struct lpfc_sglq *sglq_entry_next =NULL ;struct lpfc_sglq *sglq_entry_first =NULL ; -int status, total_cnt; +int status =0 , total_cnt;int post_cnt =0 , num_posted =0 , block_cnt =0 ;int last_xritag =NO_XRI ;LIST_HEAD (prep_sgl_list);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 165/341 media: drivers/media/dvb-core: copy user arrays safely
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Philipp Stanner <[email protected]>
[ Upstream commit 102fb77c2deb0df3683ef8ff7a6f4cf91dc456e2 ]
At several positions in dvb_frontend.c, memdup_user() is utilized to copy userspace arrays. This is done without overflow checks.
Use the new wrapper memdup_array_user() to copy the arrays more safely.
--- drivers/media/dvb-core/dvb_frontend.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/media/dvb-core/dvb_frontend.c +8 -4
@@ -2168,7 +2168,8 @@ static int dvb_frontend_handle_compat_ioctl(struct file *file, unsigned int cmd,if (!tvps->num || (tvps->num >DTV_IOCTL_MAX_MSGS ))return -EINVAL ; - tvp =memdup_user (compat_ptr (tvps->props), tvps->num *sizeof (*tvp)); + tvp =memdup_array_user (compat_ptr (tvps->props), + tvps->num,sizeof (*tvp));if (IS_ERR (tvp))return PTR_ERR (tvp);
@@ -2199,7 +2200,8 @@ static int dvb_frontend_handle_compat_ioctl(struct file *file, unsigned int cmd,if (!tvps->num || (tvps->num >DTV_IOCTL_MAX_MSGS ))return -EINVAL ; - tvp =memdup_user (compat_ptr (tvps->props), tvps->num *sizeof (*tvp)); + tvp =memdup_array_user (compat_ptr (tvps->props), + tvps->num,sizeof (*tvp));if (IS_ERR (tvp))return PTR_ERR (tvp);
@@ -2379,7 +2381,8 @@ static int dvb_get_property(struct dvb_frontend *fe, struct file *file,if (!tvps->num || tvps->num >DTV_IOCTL_MAX_MSGS )return -EINVAL ; - tvp =memdup_user ((void __user *)tvps->props, tvps->num *sizeof (*tvp)); + tvp =memdup_array_user ((void __user *)tvps->props, + tvps->num,sizeof (*tvp));if (IS_ERR (tvp))return PTR_ERR (tvp);
@@ -2457,7 +2460,8 @@ static int dvb_frontend_handle_ioctl(struct file *file,if (!tvps->num || (tvps->num >DTV_IOCTL_MAX_MSGS ))return -EINVAL ; - tvp =memdup_user ((void __user *)tvps->props, tvps->num *sizeof (*tvp)); + tvp =memdup_array_user ((void __user *)tvps->props, + tvps->num,sizeof (*tvp));if (IS_ERR (tvp))return PTR_ERR (tvp);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 166/341 wifi: iwlwifi: mvm: avoid garbage iPN
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shaul Triebitz <[email protected]>
[ Upstream commit 0c1c91604f3e3fc41f4d77dcfc3753860a9a32c9 ]
After waking from D3, we set the iPN given by the firmware. For some reason, CIPHER_SUITE_AES_CMAC was missed. That caused copying garbage to the iPN - causing false replays.
(since 'seq' is on the stack, and the iPN from the firmware was not copied into it, it contains garbage which later is copied to the iPN key).
--- drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/d3.c +3 -0
@@ -1849,9 +1849,12 @@ iwl_mvm_d3_set_igtk_bigtk_ipn(const struct iwl_multicast_key_data *key,memcpy (seq->aes_gmac.pn, key->ipn,sizeof (seq->aes_gmac.pn));break ;case WLAN_CIPHER_SUITE_BIP_CMAC_256 : +case WLAN_CIPHER_SUITE_AES_CMAC :BUILD_BUG_ON (sizeof (seq->aes_cmac.pn) !=sizeof (key->ipn));memcpy (seq->aes_cmac.pn, key->ipn,sizeof (seq->aes_cmac.pn));break ; +default : +WARN_ON (1 ); } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 167/341 net/sun3_82586: Avoid reading past buffer in debug output
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 4bea747f3fbec33c16d369b2f51e55981d7c78d0 ]
Since NUM_XMIT_BUFFS is always 1, building m68k with sun3_defconfig and -Warraybounds, this build warning is visible[1]:
drivers/net/ethernet/i825xx/sun3_82586.c: In function 'sun3_82586_timeout':drivers/net/ethernet/i825xx/sun3_82586.c:990:122: warning: array subscript 1 is above array bounds of 'volatile struct transmit_cmd_struct *[1]' [-Warray-bounds=]
990 | printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
| ~~~~~~~~~~~~^~~
...drivers/net/ethernet/i825xx/sun3_82586.c:156:46: note: while referencing 'xmit_cmds'
156 | volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
Avoid accessing index 1 since it doesn't exist.
--- drivers/net/ethernet/i825xx/sun3_82586.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/i825xx/sun3_82586.c +1 -1
@@ -987,7 +987,7 @@ static void sun3_82586_timeout(struct net_device *dev, unsigned int txqueue) {#ifdef DEBUG printk ("%s: xmitter timed out, try to restart! stat: %02x\n" ,dev->name,p->scb->cus); -printk ("%s: command-stats: %04x %04x\n" ,dev->name,swab16 (p->xmit_cmds[0 ]->cmd_status),swab16 (p->xmit_cmds[1 ]->cmd_status)); +printk ("%s: command-stats: %04x\n" , dev->name,swab16 (p->xmit_cmds[0 ]->cmd_status));printk ("%s: check, whether you set the right interrupt number!\n" ,dev->name);#endif sun3_82586_close (dev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 168/341 drm/lima: set gp bus_stop bit before hard reset
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Erico Nunes <[email protected]>
[ Upstream commit 27aa58ec85f973d98d336df7b7941149308db80f ]
This is required for reliable hard resets. Otherwise, doing a hard reset while a task is still running (such as a task which is being stopped by the drm_sched timeout handler) may result in random mmu write timeouts or lockups which cause the entire gpu to hang.
--- drivers/gpu/drm/lima/lima_gp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/lima/lima_gp.c +12 -0
@@ -166,6 +166,11 @@ static void lima_gp_task_run(struct lima_sched_pipe *pipe,gp_write (LIMA_GP_CMD , cmd); } +static int lima_gp_bus_stop_poll (struct lima_ip *ip) +{ +return !!(gp_read (LIMA_GP_STATUS ) &LIMA_GP_STATUS_BUS_STOPPED ); +} +static int lima_gp_hard_reset_poll (struct lima_ip *ip) {gp_write (LIMA_GP_PERF_CNT_0_LIMIT ,0xC01A0000 );
@@ -179,6 +184,13 @@ static int lima_gp_hard_reset(struct lima_ip *ip)gp_write (LIMA_GP_PERF_CNT_0_LIMIT ,0xC0FFE000 );gp_write (LIMA_GP_INT_MASK ,0 ); + +gp_write (LIMA_GP_CMD ,LIMA_GP_CMD_STOP_BUS ); + ret =lima_poll_timeout (ip, lima_gp_bus_stop_poll,10 ,100 ); +if (ret) { +dev_err (dev->dev,"%s bus stop timeout\n" ,lima_ip_name (ip)); +return ret; + }gp_write (LIMA_GP_CMD ,LIMA_GP_CMD_RESET ); ret =lima_poll_timeout (ip, lima_gp_hard_reset_poll,10 ,100 );if (ret) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 169/341 gpio: sysfs: extend the critical section for unregistering sysfs devices
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
[ Upstream commit 59cba4a0e6ca1058fbf88fec22530a4e2841802a ]
Checking the gdev->mockdev pointer for NULL must be part of the critical section.
--- drivers/gpio/gpiolib-sysfs.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/gpio/gpiolib-sysfs.c +8 -7
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/bitops.h> +#include <linux/cleanup.h> #include <linux/device.h> #include <linux/idr.h> #include <linux/init.h>
@@ -774,15 +775,15 @@ void gpiochip_sysfs_unregister(struct gpio_device *gdev)struct gpio_desc *desc;struct gpio_chip *chip = gdev->chip; -if (!gdev->mockdev) -return ; + scoped_guard(mutex, &sysfs_lock) { +if (!gdev->mockdev) +return ; -device_unregister (gdev->mockdev); +device_unregister (gdev->mockdev); -/* prevent further gpiod exports */ -mutex_lock (&sysfs_lock); - gdev->mockdev =NULL ; -mutex_unlock (&sysfs_lock); +/* prevent further gpiod exports */ + gdev->mockdev =NULL ; + }/* unregister gpiod class devices owned by sysfs */ for_each_gpio_desc_with_flag (chip, desc,FLAG_SYSFS ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 170/341 hrtimer: Select housekeeping CPU during migration
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Costa Shulyupin <[email protected]>
[ Upstream commit 56c2cb10120894be40c40a9bf0ce798da14c50f6 ]
During CPU-down hotplug, hrtimers may migrate to isolated CPUs, compromising CPU isolation.
Address this issue by masking valid CPUs for hrtimers using housekeeping_cpumask(HK_TYPE_TIMER).
--- kernel/time/hrtimer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/time/hrtimer.c +2 -1
@@ -38,6 +38,7 @@#include <linux/sched/deadline.h> #include <linux/sched/nohz.h> #include <linux/sched/debug.h> +#include <linux/sched/isolation.h> #include <linux/timer.h> #include <linux/freezer.h> #include <linux/compat.h>
@@ -2223,8 +2224,8 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base,int hrtimers_cpu_dying (unsigned int dying_cpu) { +int i, ncpu =cpumask_any_and (cpu_active_mask,housekeeping_cpumask (HK_TYPE_TIMER ));struct hrtimer_cpu_base *old_base, *new_base; -int i, ncpu =cpumask_first (cpu_active_mask);tick_cancel_sched_timer (dying_cpu);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 171/341 virtiofs: forbid newlines in tags
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Hajnoczi <[email protected]>
[ Upstream commit 40488cc16f7ea0d193a4e248f0d809c25cc377db ]
Newlines in virtiofs tags are awkward for users and potential vectors for string injection attacks.
--- fs/fuse/virtio_fs.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/fuse/virtio_fs.c +10 -0
@@ -323,6 +323,16 @@ static int virtio_fs_read_tag(struct virtio_device *vdev, struct virtio_fs *fs)return -ENOMEM ;memcpy (fs->tag, tag_buf, len); fs->tag[len] ='\0' ; + +/* While the VIRTIO specification allows any character, newlines are +* awkward on mount(8) command-lines and cause problems in the sysfs +* "tag" attr and uevent TAG= properties. Forbid them. +*/ +if (strchr (fs->tag,'\n' )) { +dev_dbg (&vdev->dev,"refusing virtiofs tag with newline character\n" ); +return -EINVAL ; + } +return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 172/341 accel/habanalabs: fix debugfs files permissions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avri Kehat <[email protected]>
[ Upstream commit 0b105a2a7225f2736bd07aca0538cd67f09bfa20 ]
debugfs files are created with permissions that don't align with the access requirements.
--- drivers/accel/habanalabs/common/debugfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/accel/habanalabs/common/debugfs.c +7 -7
@@ -1645,19 +1645,19 @@ static void add_files_to_device(struct hl_device *hdev, struct hl_dbg_device_ent &hl_data64b_fops);debugfs_create_file ("set_power_state" , -0200 , +0644 , root, dev_entry, &hl_power_fops);debugfs_create_file ("device" , -0200 , +0644 , root, dev_entry, &hl_device_fops);debugfs_create_file ("clk_gate" , -0200 , +0644 , root, dev_entry, &hl_clk_gate_fops);
@@ -1669,13 +1669,13 @@ static void add_files_to_device(struct hl_device *hdev, struct hl_dbg_device_ent &hl_stop_on_err_fops);debugfs_create_file ("dump_security_violations" , -0644 , +0400 , root, dev_entry, &hl_security_violations_fops);debugfs_create_file ("dump_razwi_events" , -0644 , +0400 , root, dev_entry, &hl_razwi_check_fops);
@@ -1708,7 +1708,7 @@ static void add_files_to_device(struct hl_device *hdev, struct hl_dbg_device_ent &hdev->reset_info.skip_reset_on_timeout);debugfs_create_file ("state_dump" , -0600 , +0644 , root, dev_entry, &hl_state_dump_fops);
@@ -1726,7 +1726,7 @@ static void add_files_to_device(struct hl_device *hdev, struct hl_dbg_device_entfor (i =0 , entry = dev_entry->entry_arr ; i < count ; i++, entry++) {debugfs_create_file (hl_debugfs_list[i].name, -0444 , +0644 , root, entry, &hl_debugfs_fops);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 173/341 clocksource/drivers/arm_global_timer: Guard against division by zero
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Blumenstingl <[email protected]>
[ Upstream commit e651f2fae33634175fae956d896277cf916f5d09 ]
The result of the division of new_rate by gt_target_rate can be zero (if new_rate is smaller than gt_target_rate). Using that result as divisor without checking can result in a division by zero error. Guard against this by checking for a zero value earlier.
While here, also change the psv variable to an unsigned long to make sure we don't overflow the datatype as all other types involved are also unsiged long.
--- drivers/clocksource/arm_global_timer.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/clocksource/arm_global_timer.c +5 -6
@@ -290,18 +290,17 @@ static int gt_clk_rate_change_cb(struct notifier_block *nb,switch (event) {case PRE_RATE_CHANGE : { -int psv; +unsigned long psv; - psv =DIV_ROUND_CLOSEST (ndata->new_rate, - gt_target_rate); - -if (abs (gt_target_rate - (ndata->new_rate / psv)) >MAX_F_ERR ) + psv =DIV_ROUND_CLOSEST (ndata->new_rate, gt_target_rate); +if (!psv || +abs (gt_target_rate - (ndata->new_rate / psv)) >MAX_F_ERR )return NOTIFY_BAD ; psv--;/* prescaler within legal range? */ -if (psv <0 || psv >GT_CONTROL_PRESCALER_MAX ) +if (psv >GT_CONTROL_PRESCALER_MAX )return NOTIFY_BAD ;/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 174/341 tick: Move got_idle_tick away from common flags
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
[ Upstream commit 3ce74f1a8566dbbc9774f85fb0ce781fe290fd32 ]
tick_nohz_idle_got_tick() is called by cpuidle_reflect() within the idle loop with interrupts enabled. This function modifies the struct tick_sched's bitfield "got_idle_tick". However this bitfield is stored within the same mask as other bitfields that can be modified from interrupts.
Fortunately so far it looks like the only race that can happen is while writing ->got_idle_tick to 0, an interrupt fires and writes the ->idle_active field to 0. It's then possible that the interrupted write to ->got_idle_tick writes back the old value of ->idle_active back to 1.
However if that happens, the worst possible outcome is that the time spent between that interrupt and the upcoming call to tick_nohz_idle_exit() is accounted as idle, which is negligible quantity.
Still all the bitfield writes within this struct tick_sched's shadow mask should be IRQ-safe. Therefore move this bitfield out to its own storage to avoid further suprises.
--- kernel/time/tick-sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/tick-sched.h +1 -1
@@ -61,7 +61,6 @@ struct tick_sched { unsigned int tick_stopped : 1; unsigned int idle_active : 1; unsigned int do_timer_last : 1; - unsigned int got_idle_tick : 1;/* Tick handling: jiffies stall check */ unsigned int stalled_jiffies;
@@ -73,6 +72,7 @@ struct tick_sched {ktime_t next_tick;unsigned long idle_jiffies;ktime_t idle_waketime; +unsigned int got_idle_tick;/* Idle entry */ seqcount_t idle_sleeptime_seq;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 175/341 netlink: hold nlk->cb_mutex longer in __netlink_dump_start()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit b5590270068c4324dac4a2b5a4a156e02e21339f ]
__netlink_dump_start() releases nlk->cb_mutex right before calling netlink_dump() which grabs it again.
This seems dangerous, even if KASAN did not bother yet.
Add a @lock_taken parameter to netlink_dump() to let it grab the mutex if called from netlink_recvmsg() only.
--- net/netlink/af_netlink.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
net/netlink/af_netlink.c +6 -7
@@ -130,7 +130,7 @@ static const char *const nlk_cb_mutex_key_strings[MAX_LINKS + 1] = { "nlk_cb_mutex-MAX_LINKS" }; -static int netlink_dump (struct sock *sk); +static int netlink_dump (struct sock *sk,bool lock_taken);/* nl_table locking explained: * Lookup and traversal are protected with an RCU read-side lock. Insertion
@@ -1989,7 +1989,7 @@ static int netlink_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,if (READ_ONCE (nlk->cb_running) &&atomic_read (&sk->sk_rmem_alloc) <= sk->sk_rcvbuf /2 ) { - ret =netlink_dump (sk); + ret =netlink_dump (sk, false);if (ret) {WRITE_ONCE (sk->sk_err, -ret);sk_error_report (sk);
@@ -2198,7 +2198,7 @@ static int netlink_dump_done(struct netlink_sock *nlk, struct sk_buff *skb,return 0 ; } -static int netlink_dump (struct sock *sk) +static int netlink_dump (struct sock *sk,bool lock_taken) {struct netlink_sock *nlk =nlk_sk (sk);struct netlink_ext_ack extack = {};
@@ -2210,7 +2210,8 @@ static int netlink_dump(struct sock *sk)int alloc_min_size;int alloc_size; -mutex_lock (nlk->cb_mutex); +if (!lock_taken) +mutex_lock (nlk->cb_mutex);if (!nlk->cb_running) { err = -EINVAL ; goto errout_skb;
@@ -2367,9 +2368,7 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,WRITE_ONCE (nlk->cb_running, true); nlk->dump_done_errno =INT_MAX ; -mutex_unlock (nlk->cb_mutex); - - ret =netlink_dump (sk); + ret =netlink_dump (sk, true);sock_put (sk);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 176/341 md: clean up invalid BUG_ON in md_ioctl
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Nan <[email protected]>
[ Upstream commit 9dd8702e7cd28ebf076ff838933f29cf671165ec ]
'disk->private_data' is set to mddev in md_alloc() and never set to NULL, and users need to open mddev before submitting ioctl. So mddev must not have been freed during ioctl, and there is no need to check mddev here. Clean up it.
--- drivers/md/md.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/md/md.c +0 -5
@@ -7652,11 +7652,6 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode, mddev = bdev->bd_disk->private_data; -if (!mddev) { -BUG (); - goto out; - } -/* Some actions do not requires the mutex */ switch (cmd) {case GET_ARRAY_INFO :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 177/341 x86: Increase brk randomness entropy for 64-bit systems
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 44c76825d6eefee9eb7ce06c38e1a6632ac7eb7d ]
In commit c1d171a00294 ("x86: randomize brk"), arch_randomize_brk() was defined to use a 32MB range (13 bits of entropy), but was never increased when moving to 64-bit. The default arch_randomize_brk() uses 32MB for 32-bit tasks, and 1GB (18 bits of entropy) for 64-bit tasks.
Update x86_64 to match the entropy used by arm64 and other 64-bit architectures.
--- arch/x86/kernel/process.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/kernel/process.c +4 -1
@@ -1030,7 +1030,10 @@ unsigned long arch_align_stack(unsigned long sp)unsigned long arch_randomize_brk (struct mm_struct *mm) { -return randomize_page (mm->brk,0x02000000 ); +if (mmap_is_ia32 ()) +return randomize_page (mm->brk,SZ_32M ); + +return randomize_page (mm->brk,SZ_1G ); }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 178/341 memory: stm32-fmc2-ebi: check regmap_read return value
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Kerello <[email protected]>
[ Upstream commit 722463f73bcf65a8c818752a38c14ee672c77da1 ]
Check regmap_read return value to avoid to use uninitialized local variables.
--- drivers/memory/stm32-fmc2-ebi.c | 122 +++++++++++++++++++++++--------- 1 file changed, 88 insertions(+), 34 deletions(-)
drivers/memory/stm32-fmc2-ebi.c +88 -34
@@ -181,8 +181,11 @@ static int stm32_fmc2_ebi_check_mux(struct stm32_fmc2_ebi *ebi, int cs) {u32 bcr; +int ret; -regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); + ret =regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); +if (ret) +return ret;if (bcr &FMC2_BCR_MTYP )return 0 ;
@@ -195,8 +198,11 @@ static int stm32_fmc2_ebi_check_waitcfg(struct stm32_fmc2_ebi *ebi, int cs) {u32 bcr, val =FIELD_PREP (FMC2_BCR_MTYP ,FMC2_BCR_MTYP_NOR ); +int ret; -regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); + ret =regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); +if (ret) +return ret;if ((bcr &FMC2_BCR_MTYP ) == val && bcr &FMC2_BCR_BURSTEN )return 0 ;
@@ -209,8 +215,11 @@ static int stm32_fmc2_ebi_check_sync_trans(struct stm32_fmc2_ebi *ebi, int cs) {u32 bcr; +int ret; -regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); + ret =regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); +if (ret) +return ret;if (bcr &FMC2_BCR_BURSTEN )return 0 ;
@@ -223,8 +232,11 @@ static int stm32_fmc2_ebi_check_async_trans(struct stm32_fmc2_ebi *ebi, int cs) {u32 bcr; +int ret; -regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); + ret =regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); +if (ret) +return ret;if (!(bcr &FMC2_BCR_BURSTEN ) || !(bcr &FMC2_BCR_CBURSTRW ))return 0 ;
@@ -237,8 +249,11 @@ static int stm32_fmc2_ebi_check_cpsize(struct stm32_fmc2_ebi *ebi, int cs) {u32 bcr, val =FIELD_PREP (FMC2_BCR_MTYP ,FMC2_BCR_MTYP_PSRAM ); +int ret; -regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); + ret =regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); +if (ret) +return ret;if ((bcr &FMC2_BCR_MTYP ) == val && bcr &FMC2_BCR_BURSTEN )return 0 ;
@@ -251,12 +266,18 @@ static int stm32_fmc2_ebi_check_address_hold(struct stm32_fmc2_ebi *ebi, int cs) {u32 bcr, bxtr, val =FIELD_PREP (FMC2_BXTR_ACCMOD ,FMC2_BXTR_EXTMOD_D ); +int ret; + + ret =regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); +if (ret) +return ret; -regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr);if (prop->reg_type ==FMC2_REG_BWTR ) -regmap_read (ebi->regmap,FMC2_BWTR (cs), &bxtr); + ret =regmap_read (ebi->regmap,FMC2_BWTR (cs), &bxtr);else -regmap_read (ebi->regmap,FMC2_BTR (cs), &bxtr); + ret =regmap_read (ebi->regmap,FMC2_BTR (cs), &bxtr); +if (ret) +return ret;if ((!(bcr &FMC2_BCR_BURSTEN ) || !(bcr &FMC2_BCR_CBURSTRW )) && ((bxtr &FMC2_BXTR_ACCMOD ) == val || bcr &FMC2_BCR_MUXEN ))
@@ -270,12 +291,19 @@ static int stm32_fmc2_ebi_check_clk_period(struct stm32_fmc2_ebi *ebi, int cs) {u32 bcr, bcr1; +int ret; -regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); -if (cs) -regmap_read (ebi->regmap,FMC2_BCR1 , &bcr1); -else + ret =regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); +if (ret) +return ret; + +if (cs) { + ret =regmap_read (ebi->regmap,FMC2_BCR1 , &bcr1); +if (ret) +return ret; + }else { bcr1 = bcr; + }if (bcr &FMC2_BCR_BURSTEN && (!cs || !(bcr1 &FMC2_BCR1_CCLKEN )))return 0 ;
@@ -307,12 +335,18 @@ static u32 stm32_fmc2_ebi_ns_to_clk_period(struct stm32_fmc2_ebi *ebi, {u32 nb_clk_cycles =stm32_fmc2_ebi_ns_to_clock_cycles (ebi, cs, setup);u32 bcr, btr, clk_period; +int ret; + + ret =regmap_read (ebi->regmap,FMC2_BCR1 , &bcr); +if (ret) +return ret; -regmap_read (ebi->regmap,FMC2_BCR1 , &bcr);if (bcr &FMC2_BCR1_CCLKEN || !cs) -regmap_read (ebi->regmap,FMC2_BTR1 , &btr); + ret =regmap_read (ebi->regmap,FMC2_BTR1 , &btr);else -regmap_read (ebi->regmap,FMC2_BTR (cs), &btr); + ret =regmap_read (ebi->regmap,FMC2_BTR (cs), &btr); +if (ret) +return ret; clk_period =FIELD_GET (FMC2_BTR_CLKDIV , btr) +1 ;
@@ -571,11 +605,16 @@ static int stm32_fmc2_ebi_set_address_setup(struct stm32_fmc2_ebi *ebi,if (ret)return ret; -regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); + ret =regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); +if (ret) +return ret; +if (prop->reg_type ==FMC2_REG_BWTR ) -regmap_read (ebi->regmap,FMC2_BWTR (cs), &bxtr); + ret =regmap_read (ebi->regmap,FMC2_BWTR (cs), &bxtr);else -regmap_read (ebi->regmap,FMC2_BTR (cs), &bxtr); + ret =regmap_read (ebi->regmap,FMC2_BTR (cs), &bxtr); +if (ret) +return ret;if ((bxtr &FMC2_BXTR_ACCMOD ) == val || bcr &FMC2_BCR_MUXEN ) val =clamp_val (setup,1 ,FMC2_BXTR_ADDSET_MAX );
@@ -693,11 +732,14 @@ static int stm32_fmc2_ebi_set_max_low_pulse(struct stm32_fmc2_ebi *ebi, int cs, u32 setup) {u32 old_val, new_val, pcscntr; +int ret;if (setup <1 )return 0 ; -regmap_read (ebi->regmap,FMC2_PCSCNTR , &pcscntr); + ret =regmap_read (ebi->regmap,FMC2_PCSCNTR , &pcscntr); +if (ret) +return ret;/* Enable counter for the bank */ regmap_update_bits(ebi->regmap, FMC2_PCSCNTR,
@@ -944,17 +986,20 @@ static void stm32_fmc2_ebi_disable_bank(struct stm32_fmc2_ebi *ebi, int cs)regmap_update_bits (ebi->regmap,FMC2_BCR (cs),FMC2_BCR_MBKEN ,0 ); } -static void stm32_fmc2_ebi_save_setup (struct stm32_fmc2_ebi *ebi) +static int stm32_fmc2_ebi_save_setup (struct stm32_fmc2_ebi *ebi) {unsigned int cs; +int ret;for (cs =0 ; cs <FMC2_MAX_EBI_CE ; cs++) { -regmap_read (ebi->regmap,FMC2_BCR (cs), &ebi->bcr[cs]); -regmap_read (ebi->regmap,FMC2_BTR (cs), &ebi->btr[cs]); -regmap_read (ebi->regmap,FMC2_BWTR (cs), &ebi->bwtr[cs]); + ret =regmap_read (ebi->regmap,FMC2_BCR (cs), &ebi->bcr[cs]); + ret |=regmap_read (ebi->regmap,FMC2_BTR (cs), &ebi->btr[cs]); + ret |=regmap_read (ebi->regmap,FMC2_BWTR (cs), &ebi->bwtr[cs]); +if (ret) +return ret; } -regmap_read (ebi->regmap,FMC2_PCSCNTR , &ebi->pcscntr); +return regmap_read (ebi->regmap,FMC2_PCSCNTR , &ebi->pcscntr); }static void stm32_fmc2_ebi_set_setup (struct stm32_fmc2_ebi *ebi)
@@ -983,22 +1028,29 @@ static void stm32_fmc2_ebi_disable_banks(struct stm32_fmc2_ebi *ebi) }/* NWAIT signal can not be connected to EBI controller and NAND controller */ -static bool stm32_fmc2_ebi_nwait_used_by_ctrls (struct stm32_fmc2_ebi *ebi) +static int stm32_fmc2_ebi_nwait_used_by_ctrls (struct stm32_fmc2_ebi *ebi) { +struct device *dev = ebi->dev;unsigned int cs;u32 bcr; +int ret;for (cs =0 ; cs <FMC2_MAX_EBI_CE ; cs++) {if (!(ebi->bank_assigned &BIT (cs)))continue ; -regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); + ret =regmap_read (ebi->regmap,FMC2_BCR (cs), &bcr); +if (ret) +return ret; +if ((bcr &FMC2_BCR_WAITEN || bcr &FMC2_BCR_ASYNCWAIT ) && - ebi->bank_assigned &BIT (FMC2_NAND )) -return true; + ebi->bank_assigned &BIT (FMC2_NAND )) { +dev_err (dev,"NWAIT signal connected to EBI and NAND controllers\n" ); +return -EINVAL ; + } } -return false; +return 0 ; }static void stm32_fmc2_ebi_enable (struct stm32_fmc2_ebi *ebi)
@@ -1085,10 +1137,9 @@ static int stm32_fmc2_ebi_parse_dt(struct stm32_fmc2_ebi *ebi)return -ENODEV ; } -if (stm32_fmc2_ebi_nwait_used_by_ctrls (ebi)) { -dev_err (dev,"NWAIT signal connected to EBI and NAND controllers\n" ); -return -EINVAL ; - } + ret =stm32_fmc2_ebi_nwait_used_by_ctrls (ebi); +if (ret) +return ret;stm32_fmc2_ebi_enable (ebi);
@@ -1133,7 +1184,10 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev)if (ret) goto err_release; -stm32_fmc2_ebi_save_setup (ebi); + ret =stm32_fmc2_ebi_save_setup (ebi); +if (ret) + goto err_release; +platform_set_drvdata (pdev, ebi);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 179/341 parisc: Use irq_enter_rcu() to fix warning at kernel/context_tracking.c:367
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
[ Upstream commit 73cb4a2d8d7e0259f94046116727084f21e4599f ]
Use irq*_rcu() functions to fix this kernel warning:
WARNING: CPU: 0 PID: 0 at kernel/context_tracking.c:367 ct_irq_enter+0xa0/0xd0 Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.7.0-rc3-64bit+ #1037 Hardware name: 9000/785/C3700
IASQ: 0000000000000000 0000000000000000 IAOQ: 00000000412cd758 00000000412cd75c
IIR: 03ffe01f ISR: 0000000000000000 IOR: 0000000043c20c20
CPU: 0 CR30: 0000000041caa000 CR31: 0000000000000000
ORIG_R28: 0000000000000005
IAOQ[0]: ct_irq_enter+0xa0/0xd0
IAOQ[1]: ct_irq_enter+0xa4/0xd0
RP(r2): irq_enter+0x34/0x68
Backtrace: [<000000004034a3ec>] irq_enter+0x34/0x68 [<000000004030dc48>] do_cpu_irq_mask+0xc0/0x450 [<0000000040303070>] intr_return+0x0/0xc
--- arch/parisc/kernel/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/parisc/kernel/irq.c +2 -2
@@ -498,7 +498,7 @@ asmlinkage void do_cpu_irq_mask(struct pt_regs *regs) old_regs =set_irq_regs (regs);local_irq_disable (); -irq_enter (); +irq_enter_rcu (); eirr_val =mfctl (23 ) & cpu_eiem &per_cpu (local_ack_eiem, cpu);if (!eirr_val)
@@ -533,7 +533,7 @@ asmlinkage void do_cpu_irq_mask(struct pt_regs *regs)#endif /* CONFIG_IRQSTACKS */ out: -irq_exit (); +irq_exit_rcu ();set_irq_regs (old_regs);return ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 180/341 rxrpc: Dont pick values out of the wire header when setting up security
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit a1c9af4d4467354132417c2d8db10d6e928a7f77 ]
Don't pick values out of the wire header in rxkad when setting up DATA packet security, but rather use other sources. This makes it easier to get rid of txb->wire.
--- net/rxrpc/rxkad.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/rxrpc/rxkad.c +4 -4
@@ -259,7 +259,7 @@ static int rxkad_secure_packet_auth(const struct rxrpc_call *call,_enter ("" ); - check = txb->seq ^ntohl (txb->wire.callNumber); + check = txb->seq ^ call->call_id; hdr->data_size =htonl ((u32 )check <<16 | txb->len); txb->len +=sizeof (struct rxkad_level1_hdr );
@@ -302,7 +302,7 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call,_enter ("" ); - check = txb->seq ^ntohl (txb->wire.callNumber); + check = txb->seq ^ call->call_id; rxkhdr->data_size =htonl (txb->len | (u32 )check <<16 ); rxkhdr->checksum =0 ;
@@ -362,9 +362,9 @@ static int rxkad_secure_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb)memcpy (&iv, call->conn->rxkad.csum_iv.x,sizeof (iv));/* calculate the security checksum */ - x = (ntohl (txb->wire.cid) &RXRPC_CHANNELMASK ) << (32 -RXRPC_CIDSHIFT ); + x = (call->cid &RXRPC_CHANNELMASK ) << (32 -RXRPC_CIDSHIFT ); x |= txb->seq &0x3fffffff ; - crypto.buf[0 ] = txb->wire.callNumber; + crypto.buf[0 ] =htonl (call->call_id); crypto.buf[1 ] =htonl (x);sg_init_one (&sg, crypto.buf,8 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 181/341 f2fs: stop checkpoint when get a out-of-bounds segment
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiguo Niu <[email protected]>
[ Upstream commit f9e28904e6442019043a8e94ec6747a064d06003 ]
There is low probability that an out-of-bounds segment will be got on a small-capacity device. In order to prevent subsequent write requests allocating block address from this invalid segment, which may cause unexpected issue, stop checkpoint should be performed.
Also introduce a new stop cp reason: STOP_CP_REASON_NO_SEGMENT.
Note, f2fs_stop_checkpoint(, false) is complex and it may sleep, so we should move it outside segmap_lock spinlock coverage in get_new_segment().
--- fs/f2fs/segment.c | 12 +++++++++++- include/linux/f2fs_fs.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +11 -1
@@ -2646,6 +2646,7 @@ static void get_new_segment(struct f2fs_sb_info *sbi,unsigned int old_zoneno =GET_ZONE_FROM_SEG (sbi, *newseg);bool init = true;int i; +int ret =0 ;spin_lock (&free_i->segmap_lock);
@@ -2670,7 +2671,10 @@ static void get_new_segment(struct f2fs_sb_info *sbi,if (secno >=MAIN_SECS (sbi)) { secno =find_first_zero_bit (free_i->free_secmap,MAIN_SECS (sbi)); -f2fs_bug_on (sbi, secno >=MAIN_SECS (sbi)); +if (secno >=MAIN_SECS (sbi)) { + ret = -ENOSPC ; + goto out_unlock; + } } segno =GET_SEG_FROM_SEC (sbi, secno); zoneno =GET_ZONE_FROM_SEC (sbi, secno);
@@ -2700,7 +2704,13 @@ static void get_new_segment(struct f2fs_sb_info *sbi,f2fs_bug_on (sbi,test_bit (segno, free_i->free_segmap));__set_inuse (sbi, segno); *newseg = segno; +out_unlock:spin_unlock (&free_i->segmap_lock); + +if (ret) { +f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_NO_SEGMENT ); +f2fs_bug_on (sbi,1 ); + } }static void reset_curseg (struct f2fs_sb_info *sbi,int type,int modified)
include/linux/f2fs_fs.h +1 -0
@@ -76,6 +76,7 @@ enum stop_cp_reason {STOP_CP_REASON_CORRUPTED_SUMMARY ,STOP_CP_REASON_UPDATE_INODE ,STOP_CP_REASON_FLUSH_FAIL , +STOP_CP_REASON_NO_SEGMENT , STOP_CP_REASON_MAX, };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 182/341 powerpc/boot: Handle allocation failure in simple_realloc()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li zeming <[email protected]>
[ Upstream commit 69b0194ccec033c208b071e019032c1919c2822d ]
simple_malloc() will return NULL when there is not enough memory left. Check pointer 'new' before using it to copy the old data.
--- arch/powerpc/boot/simple_alloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/boot/simple_alloc.c +3 -1
@@ -112,7 +112,9 @@ static void *simple_realloc(void *ptr, unsigned long size)return ptr; new =simple_malloc (size); -memcpy (new, ptr, p->size); +if (new) +memcpy (new, ptr, p->size); +simple_free (ptr);return new; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 183/341 powerpc/boot: Only free if realloc() succeeds
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
[ Upstream commit f2d5bccaca3e8c09c9b9c8485375f7bdbb2631d2 ]
simple_realloc() frees the original buffer (ptr) even if the reallocation failed.
Fix it to behave like standard realloc() and only free the original buffer if the reallocation succeeded.
--- arch/powerpc/boot/simple_alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/boot/simple_alloc.c +3 -2
@@ -112,10 +112,11 @@ static void *simple_realloc(void *ptr, unsigned long size)return ptr; new =simple_malloc (size); -if (new) +if (new) {memcpy (new, ptr, p->size); +simple_free (ptr); + } -simple_free (ptr);return new; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 184/341 btrfs: delayed-inode: drop pointless BUG_ON in __btrfs_remove_delayed_item()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit 778e618b8bfedcc39354373c1b072c5fe044fa7b ]
There's a BUG_ON checking for a valid pointer of fs_info::delayed_root but it is valid since init_mount_fs_info() and has the same lifetime as fs_info.
--- fs/btrfs/delayed-inode.c | 2 -- 1 file changed, 2 deletions(-)
fs/btrfs/delayed-inode.c +0 -2
@@ -425,8 +425,6 @@ static void __btrfs_remove_delayed_item(struct btrfs_delayed_item *delayed_item) delayed_root = delayed_node->root->fs_info->delayed_root; -BUG_ON (!delayed_root); -if (delayed_item->type ==BTRFS_DELAYED_INSERTION_ITEM ) root = &delayed_node->ins_root;else
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 185/341 btrfs: defrag: change BUG_ON to assertion in btrfs_defrag_leaves()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit 51d4be540054be32d7ce28b63ea9b84ac6ff1db2 ]
The BUG_ON verifies a condition that should be guaranteed by the correct use of the path search (with keep_locks and lowest_level set), an assertion is the suitable check.
--- fs/btrfs/defrag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/defrag.c +1 -1
@@ -416,7 +416,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,* keep_locks set and lowest_level is 1, regardless of the value of * path->slots[1]. */ -BUG_ON (path->locks[1 ] ==0 ); +ASSERT (path->locks[1 ] !=0 ); ret = btrfs_realloc_node(trans, root, path->nodes[1], 0, &last_ret,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 186/341 btrfs: change BUG_ON to assertion when checking for delayed_node root
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit be73f4448b607e6b7ce41cd8ef2214fdf6e7986f ]
The pointer to root is initialized in btrfs_init_delayed_node(), no need to check for it again. Change the BUG_ON to assertion.
--- fs/btrfs/delayed-inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/delayed-inode.c +1 -1
@@ -973,7 +973,7 @@ static void btrfs_release_delayed_inode(struct btrfs_delayed_node *delayed_node)if (delayed_node &&test_bit (BTRFS_DELAYED_NODE_INODE_DIRTY , &delayed_node->flags)) { -BUG_ON (!delayed_node->root); +ASSERT (delayed_node->root);clear_bit (BTRFS_DELAYED_NODE_INODE_DIRTY , &delayed_node->flags); delayed_node->count--;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 187/341 btrfs: tests: allocate dummy fs_info and root in test_find_delalloc()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit b2136cc288fce2f24a92f3d656531b2d50ebec5a ]
Allocate fs_info and root to have a valid fs_info pointer in case it's dereferenced by a helper outside of tests, like find_lock_delalloc_range().
--- fs/btrfs/tests/extent-io-tests.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)
fs/btrfs/tests/extent-io-tests.c +24 -4
@@ -11,6 +11,7 @@#include "btrfs-tests.h" #include "../ctree.h" #include "../extent_io.h" +#include "../disk-io.h" #include "../btrfs_inode.h" #define PROCESS_UNLOCK (1 << 0)
@@ -105,9 +106,11 @@ static void dump_extent_io_tree(const struct extent_io_tree *tree) } } -static int test_find_delalloc (u32 sectorsize) +static int test_find_delalloc (u32 sectorsize,u32 nodesize) { -struct inode *inode; +struct btrfs_fs_info *fs_info; +struct btrfs_root *root =NULL ; +struct inode *inode =NULL ;struct extent_io_tree *tmp;struct page *page;struct page *locked_page =NULL ;
@@ -121,12 +124,27 @@ static int test_find_delalloc(u32 sectorsize)test_msg ("running find delalloc tests" ); + fs_info =btrfs_alloc_dummy_fs_info (nodesize, sectorsize); +if (!fs_info) { +test_std_err (TEST_ALLOC_FS_INFO ); +return -ENOMEM ; + } + + root =btrfs_alloc_dummy_root (fs_info); +if (IS_ERR (root)) { +test_std_err (TEST_ALLOC_ROOT ); + ret =PTR_ERR (root); + goto out; + } + inode =btrfs_new_test_inode ();if (!inode) {test_std_err (TEST_ALLOC_INODE ); -return -ENOMEM ; + ret = -ENOMEM ; + goto out; } tmp = &BTRFS_I (inode)->io_tree; +BTRFS_I (inode)->root = root;/* * Passing NULL as we don't have fs_info but tracepoints are not used
@@ -316,6 +334,8 @@ static int test_find_delalloc(u32 sectorsize)process_page_range (inode,0 , total_dirty -1 ,PROCESS_UNLOCK |PROCESS_RELEASE );iput (inode); +btrfs_free_dummy_root (root); +btrfs_free_dummy_fs_info (fs_info);return ret; }
@@ -794,7 +814,7 @@ int btrfs_test_extent_io(u32 sectorsize, u32 nodesize)test_msg ("running extent I/O tests" ); - ret =test_find_delalloc (sectorsize); + ret =test_find_delalloc (sectorsize, nodesize);if (ret) goto out;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 188/341 btrfs: push errors up from add_async_extent()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit dbe6cda68f0e1be269e6509c8bf3d8d89089c1c4 ]
The memory allocation error in add_async_extent() is not handled properly, return an error and push the BUG_ON to the caller. Handling it there is not trivial so at least make it visible.
--- fs/btrfs/inode.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
fs/btrfs/inode.c +8 -5
@@ -730,7 +730,8 @@ static noinline int add_async_extent(struct async_chunk *cow,struct async_extent *async_extent; async_extent =kmalloc (sizeof (*async_extent),GFP_NOFS ); -BUG_ON (!async_extent);/* -ENOMEM */ +if (!async_extent) +return -ENOMEM ; async_extent->start = start; async_extent->ram_size = ram_size; async_extent->compressed_size = compressed_size;
@@ -1017,8 +1018,9 @@ static void compress_file_range(struct btrfs_work *work)* The async work queues will take care of doing actual allocation on * disk for these compressed pages, and will submit the bios. */ -add_async_extent (async_chunk, start, total_in, total_compressed, pages, - nr_pages, compress_type); + ret =add_async_extent (async_chunk, start, total_in, total_compressed, pages, + nr_pages, compress_type); +BUG_ON (ret);if (start + total_in < end) { start += total_in;cond_resched ();
@@ -1030,8 +1032,9 @@ static void compress_file_range(struct btrfs_work *work)if (!btrfs_test_opt (fs_info,FORCE_COMPRESS ) && !inode->prop_compress) inode->flags |=BTRFS_INODE_NOCOMPRESS ; cleanup_and_bail_uncompressed: -add_async_extent (async_chunk, start, end - start +1 ,0 ,NULL ,0 , -BTRFS_COMPRESS_NONE ); + ret =add_async_extent (async_chunk, start, end - start +1 ,0 ,NULL ,0 , +BTRFS_COMPRESS_NONE ); +BUG_ON (ret); free_pages:if (pages) {for (i =0 ; i < nr_pages; i++) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 189/341 btrfs: handle invalid root reference found in may_destroy_subvol()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit 6fbc6f4ac1f4907da4fc674251527e7dc79ffbf6 ]
The may_destroy_subvol() looks up a root by a key, allowing to do an inexact search when key->offset is -1. It's never expected to find such item, as it would break the allowed range of a root id.
--- fs/btrfs/inode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +8 -1
@@ -4374,7 +4374,14 @@ static noinline int may_destroy_subvol(struct btrfs_root *root) ret =btrfs_search_slot (NULL , fs_info->tree_root, &key, path,0 ,0 );if (ret <0 ) goto out; -BUG_ON (ret ==0 ); +if (ret ==0 ) { +/* +* Key with offset -1 found, there would have to exist a root +* with such id, but this is out of valid range. +*/ + ret = -EUCLEAN ; + goto out; + } ret =0 ;if (path->slots[0 ] >0 ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 190/341 btrfs: send: handle unexpected data in header buffer in begin_cmd()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit e80e3f732cf53c64b0d811e1581470d67f6c3228 ]
Change BUG_ON to a proper error handling in the unlikely case of seeing data when the command is started. This is supposed to be reset when the command is finished (send_cmd, send_encoded_extent).
--- fs/btrfs/send.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/btrfs/send.c +6 -1
@@ -777,7 +777,12 @@ static int begin_cmd(struct send_ctx *sctx, int cmd)if (WARN_ON (!sctx->send_buf))return -EINVAL ; -BUG_ON (sctx->send_size); +if (unlikely (sctx->send_size !=0 )) { +btrfs_err (sctx->send_root->fs_info, +"send: command header buffer not empty cmd %d offset %llu" , + cmd, sctx->send_off); +return -EINVAL ; + } sctx->send_size +=sizeof (*hdr); hdr = (struct btrfs_cmd_header *)sctx->send_buf;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 191/341 btrfs: send: handle unexpected inode in header process_recorded_refs()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit 5d2288711ccc483feca73151c46ee835bda17839 ]
Change BUG_ON to proper error handling when an unexpected inode number is encountered. As the comment says this should never happen.
--- fs/btrfs/send.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/btrfs/send.c +7 -1
@@ -4195,7 +4195,13 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)* This should never happen as the root dir always has the same ref * which is always '..' */ -BUG_ON (sctx->cur_ino <=BTRFS_FIRST_FREE_OBJECTID ); +if (unlikely (sctx->cur_ino <=BTRFS_FIRST_FREE_OBJECTID )) { +btrfs_err (fs_info, +"send: unexpected inode %llu in process_recorded_refs()" , + sctx->cur_ino); + ret = -EINVAL ; + goto out; + } valid_path =fs_path_alloc ();if (!valid_path) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 192/341 btrfs: change BUG_ON to assertion in tree_move_down()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit 56f335e043ae73c32dbb70ba95488845dc0f1e6e ]
There's only one caller of tree_move_down() that does not pass level 0 so the assertion is better suited here.
--- fs/btrfs/send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/send.c +1 -1
@@ -7448,8 +7448,8 @@ static int tree_move_down(struct btrfs_path *path, int *level, u64 reada_min_genu64 reada_done =0 ;lockdep_assert_held_read (&parent->fs_info->commit_root_sem); +ASSERT (*level !=0 ); -BUG_ON (*level ==0 ); eb =btrfs_read_node_slot (parent, slot);if (IS_ERR (eb))return PTR_ERR (eb);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 193/341 btrfs: delete pointless BUG_ON check on quota root in btrfs_qgroup_account_extent()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit f40a3ea94881f668084f68f6b9931486b1606db0 ]
The BUG_ON is deep in the qgroup code where we can expect that it exists. A NULL pointer would cause a crash.
It was added long ago in 550d7a2ed5db35 ("btrfs: qgroup: Add new qgroup calculation function btrfs_qgroup_account_extents()."). It maybe made sense back then as the quota enable/disable state machine was not that robust as it is nowadays, so we can just delete it.
--- fs/btrfs/qgroup.c | 2 -- 1 file changed, 2 deletions(-)
fs/btrfs/qgroup.c +0 -2
@@ -2725,8 +2725,6 @@ int btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans, u64 bytenr,if (nr_old_roots ==0 && nr_new_roots ==0 ) goto out_free; -BUG_ON (!fs_info->quota_root); -trace_btrfs_qgroup_account_extent (fs_info, trans->transid, bytenr, num_bytes, nr_old_roots, nr_new_roots);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 194/341 f2fs: fix to do sanity check in update_sit_entry
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiguo Niu <[email protected]>
[ Upstream commit 36959d18c3cf09b3c12157c6950e18652067de77 ]
If GET_SEGNO return NULL_SEGNO for some unecpected case, update_sit_entry will access invalid memory address, cause system crash. It is better to do sanity check about GET_SEGNO just like update_segment_mtime & locate_dirty_segment.
Also remove some redundant judgment code.
--- fs/f2fs/segment.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/segment.c +3 -2
@@ -2398,6 +2398,8 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)#endif segno =GET_SEGNO (sbi, blkaddr); +if (segno ==NULL_SEGNO ) +return ; se =get_seg_entry (sbi, segno); new_vblocks = se->valid_blocks + del;
@@ -3481,8 +3483,7 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,* since SSR needs latest valid block information. */ update_sit_entry (sbi, *new_blkaddr,1 ); -if (GET_SEGNO (sbi, old_blkaddr) !=NULL_SEGNO ) -update_sit_entry (sbi, old_blkaddr,-1 ); +update_sit_entry (sbi, old_blkaddr,-1 );/* * If the current segment is full, flush it out and replace it with a
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 195/341 usb: gadget: fsl: Increase size of name buffer for endpoints
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 87850f6cc20911e35eafcbc1d56b0d649ae9162d ]
This fixes a W=1 warning about sprintf writing up to 16 bytes into a buffer of size 14. There is no practical relevance because there are not more than 32 endpoints.
--- drivers/usb/gadget/udc/fsl_udc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/fsl_udc_core.c +1 -1
@@ -2486,7 +2486,7 @@ static int fsl_udc_probe(struct platform_device *pdev)/* setup the udc->eps[] for non-control endpoints and link * to gadget.ep_list */ for (i =1 ; i < (int )(udc_controller->max_ep /2 ); i++) { -char name[14 ]; +char name[16 ];sprintf (name,"ep%dout" , i);struct_ep_setup (udc_controller, i *2 , name,1 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 196/341 nvme: clear caller pointer on identify failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit 7e80eb792bd7377a20f204943ac31c77d859be89 ]
The memory allocated for the identification is freed on failure. Set it to NULL so the caller doesn't have a pointer to that freed address.
--- drivers/nvme/host/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +4 -1
@@ -1313,8 +1313,10 @@ static int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id) error =nvme_submit_sync_cmd (dev->admin_q, &c, *id,sizeof (struct nvme_id_ctrl )); -if (error) +if (error) {kfree (*id); + *id =NULL ; + }return error; }
@@ -1443,6 +1445,7 @@ static int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,if (error) {dev_warn (ctrl->device,"Identify namespace failed (%d)\n" , error);kfree (*id); + *id =NULL ; }return error; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 197/341 Bluetooth: bnep: Fix out-of-bound access
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 0f0639b4d6f649338ce29c62da3ec0787fa08cd1 ]
This fixes attempting to access past ethhdr.h_source, although it seems intentional to copy also the contents of h_proto this triggers out-of-bound access problems with the likes of static analyzer, so this instead just copy ETH_ALEN and then proceed to use put_unaligned to copy h_proto separetely.
--- net/bluetooth/bnep/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/bnep/core.c +2 -1
@@ -385,7 +385,8 @@ static int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)case BNEP_COMPRESSED_DST_ONLY :__skb_put_data (nskb,skb_mac_header (skb),ETH_ALEN ); -__skb_put_data (nskb, s->eh.h_source,ETH_ALEN +2 ); +__skb_put_data (nskb, s->eh.h_source,ETH_ALEN ); +put_unaligned (s->eh.h_proto, (__be16 *)__skb_put (nskb,2 ));break ;case BNEP_GENERAL :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 198/341 firmware: cirrus: cs_dsp: Initialize debugfs_root to invalid
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 66626b15636b5f5cf3d7f6104799f77462748974 ]
Initialize debugfs_root to -ENODEV so that if the client never sets a valid debugfs root the debugfs files will not be created.
A NULL pointer passed to any of the debugfs_create_*() functions means "create in the root of debugfs". It doesn't mean "ignore".
--- drivers/firmware/cirrus/cs_dsp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/firmware/cirrus/cs_dsp.c +6 -1
@@ -522,7 +522,7 @@ void cs_dsp_cleanup_debugfs(struct cs_dsp *dsp) {cs_dsp_debugfs_clear (dsp);debugfs_remove_recursive (dsp->debugfs_root); - dsp->debugfs_root =NULL ; + dsp->debugfs_root =ERR_PTR (-ENODEV ); }EXPORT_SYMBOL_NS_GPL (cs_dsp_cleanup_debugfs,FW_CS_DSP );#else
@@ -2343,6 +2343,11 @@ static int cs_dsp_common_init(struct cs_dsp *dsp)mutex_init (&dsp->pwr_lock); +#ifdef CONFIG_DEBUG_FS +/* Ensure this is invalid if client never provides a debugfs root */ + dsp->debugfs_root =ERR_PTR (-ENODEV ); +#endif +return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 199/341 rtc: nct3018y: fix possible NULL dereference
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Belloni <[email protected]>
[ Upstream commit babfeb9cbe7ebc657bd5b3e4f9fde79f560b6acc ]
alarm_enable and alarm_flag are allowed to be NULL but will be dereferenced later by the dev_dbg call.
--- drivers/rtc/rtc-nct3018y.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-nct3018y.c +3 -3
@@ -99,6 +99,8 @@ static int nct3018y_get_alarm_mode(struct i2c_client *client, unsigned char *alaif (flags <0 )return flags; *alarm_enable = flags &NCT3018Y_BIT_AIE ; +dev_dbg (&client->dev,"%s:alarm_enable:%x\n" , __func__, *alarm_enable); + }if (alarm_flag) {
@@ -107,11 +109,9 @@ static int nct3018y_get_alarm_mode(struct i2c_client *client, unsigned char *alaif (flags <0 )return flags; *alarm_flag = flags &NCT3018Y_BIT_AF ; +dev_dbg (&client->dev,"%s:alarm_flag:%x\n" , __func__, *alarm_flag); } -dev_dbg (&client->dev,"%s:alarm_enable:%x alarm_flag:%x\n" , - __func__, *alarm_enable, *alarm_flag); -return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 200/341 net: hns3: add checking for vf id of mailbox
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian Shen <[email protected]>
[ Upstream commit 4e2969a0d6a7549bc0bc1ebc990588b622c4443d ]
Add checking for vf id of mailbox, in order to avoid array out-of-bounds risk.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +4 -3
@@ -1124,10 +1124,11 @@ void hclge_mbx_handler(struct hclge_dev *hdev) req = (struct hclge_mbx_vf_to_pf_cmd *)desc->data; flag =le16_to_cpu (crq->desc[crq->next_to_use].flag); -if (unlikely (!hnae3_get_bit (flag,HCLGE_CMDQ_RX_OUTVLD_B ))) { +if (unlikely (!hnae3_get_bit (flag,HCLGE_CMDQ_RX_OUTVLD_B ) || + req->mbx_src_vfid > hdev->num_req_vfs)) {dev_warn (&hdev->pdev->dev, -"dropped invalid mailbox message, code = %u\n" , - req->msg.code); +"dropped invalid mailbox message, code = %u, vfid = %u\n" , + req->msg.code, req->mbx_src_vfid);/* dropping/not processing this invalid message */ crq->desc[crq->next_to_use].flag =0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 201/341 nvmet-tcp: do not continue for invalid icreq
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
[ Upstream commit 0889d13b9e1cbef49e802ae09f3b516911ad82a1 ]
When the length check for an icreq sqe fails we should not continue processing but rather return immediately as all other contents of that sqe cannot be relied on.
--- drivers/nvme/target/tcp.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/target/tcp.c +1 -0
@@ -875,6 +875,7 @@ static int nvmet_tcp_handle_icreq(struct nvmet_tcp_queue *queue)pr_err ("bad nvme-tcp pdu length (%d)\n" ,le32_to_cpu (icreq->hdr.plen));nvmet_tcp_fatal_error (queue); +return -EPROTO ; }if (icreq->pfv !=NVME_TCP_PFV_1_0 ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 202/341 NFS: avoid infinite loop in pnfs_update_layout.
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
[ Upstream commit 2fdbc20036acda9e5694db74a032d3c605323005 ]
If pnfsd_update_layout() is called on a file for which recovery has failed it will enter a tight infinite loop.
NFS_LAYOUT_INVALID_STID will be set, nfs4_select_rw_stateid() will return -EIO, and nfs4_schedule_stateid_recovery() will do nothing, so nfs4_client_recover_expired_lease() will not wait. So the code will loop indefinitely.
Break the loop by testing the validity of the open stateid at the top of the loop.
--- fs/nfs/pnfs.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/nfs/pnfs.c +8 -0
@@ -1997,6 +1997,14 @@ pnfs_update_layout(struct inode *ino, } lookup_again: +if (!nfs4_valid_open_stateid (ctx->state)) { +trace_pnfs_update_layout (ino, pos, count, + iomode, lo, lseg, +PNFS_UPDATE_LAYOUT_INVALID_OPEN ); + lseg =ERR_PTR (-EIO ); + goto out; + } + lseg =ERR_PTR (nfs4_client_recover_expired_lease (clp));if (IS_ERR (lseg)) goto out;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 203/341 openrisc: Call setup_memory() earlier in the init sequence
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oreoluwa Babatunde <[email protected]>
[ Upstream commit 7b432bf376c9c198a7ff48f1ed14a14c0ffbe1fe ]
The unflatten_and_copy_device_tree() function contains a call to memblock_alloc(). This means that memblock is allocating memory before any of the reserved memory regions are set aside in the setup_memory() function which calls early_init_fdt_scan_reserved_mem(). Therefore, there is a possibility for memblock to allocate from any of the reserved memory regions.
Hence, move the call to setup_memory() to be earlier in the init sequence so that the reserved memory regions are set aside before any allocations are done using memblock.
--- arch/openrisc/kernel/setup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/openrisc/kernel/setup.c +3 -3
@@ -255,6 +255,9 @@ void calibrate_delay(void)void __init setup_arch (char **cmdline_p) { +/* setup memblock allocator */ +setup_memory (); +unflatten_and_copy_device_tree ();setup_cpuinfo ();
@@ -278,9 +281,6 @@ void __init setup_arch(char **cmdline_p) }#endif -/* setup memblock allocator */ -setup_memory (); -/* paging_init() sets up the MMU and marks all pages as reserved */ paging_init ();
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 204/341 s390/iucv: fix receive buffer virtual vs physical address confusion
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Gordeev <[email protected]>
[ Upstream commit 4e8477aeb46dfe74e829c06ea588dd00ba20c8cc ]
Fix IUCV_IPBUFLST-type buffers virtual vs physical address confusion. This does not fix a bug since virtual and physical address spaces are currently the same.
--- net/iucv/iucv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/iucv/iucv.c +1 -2
@@ -1090,8 +1090,7 @@ static int iucv_message_receive_iprmdata(struct iucv_path *path, size = (size <8 ) ? size :8 ;for (array = buffer; size >0 ; array++) { copy =min_t (size_t, size, array->length); -memcpy ((u8 *)(addr_t ) array->address, - rmmsg, copy); +memcpy (phys_to_virt (array->address), rmmsg, copy); rmmsg += copy; size -= copy; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 205/341 irqchip/renesas-rzg2l: Do not set TIEN and TINT source at the same time
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit dce0919c83c325ac9dec5bc8838d5de6d32c01b1 ]
As per the hardware team, TIEN and TINT source should not set at the same time due to a possible hardware race leading to spurious IRQ.
Currently on some scenarios hardware settings for TINT detection is not in sync with TINT source as the enable/disable overrides source setting value leading to hardware inconsistent state. For eg: consider the case GPIOINT0 is used as TINT interrupt and configuring GPIOINT5 as edge type. During rzg2l_irq_set_type(), TINT source for GPIOINT5 is set. On disable(), clearing of the entire bytes of TINT source selection for GPIOINT5 is same as GPIOINT0 with TIEN disabled. Apart from this during enable(), the setting of GPIOINT5 with TIEN results in spurious IRQ as due to a HW race, it is possible that IP can use the TIEN with previous source value (GPIOINT0).
So, just update TIEN during enable/disable as TINT source is already set during rzg2l_irq_set_type(). This will make the consistent hardware settings for detection method tied with TINT source and allows to simplify the code.
--- drivers/irqchip/irq-renesas-rzg2l.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +2 -3
@@ -132,7 +132,7 @@ static void rzg2l_irqc_irq_disable(struct irq_data *d)raw_spin_lock (&priv->lock); reg =readl_relaxed (priv->base +TSSR (tssr_index)); - reg &= ~(TSSEL_MASK <<TSSEL_SHIFT (tssr_offset)); + reg &= ~(TIEN <<TSSEL_SHIFT (tssr_offset));writel_relaxed (reg, priv->base +TSSR (tssr_index));raw_spin_unlock (&priv->lock); }
@@ -144,7 +144,6 @@ static void rzg2l_irqc_irq_enable(struct irq_data *d)unsigned int hw_irq =irqd_to_hwirq (d);if (hw_irq >=IRQC_TINT_START && hw_irq <IRQC_NUM_IRQ ) { -unsigned long tint = (uintptr_t )irq_data_get_irq_chip_data (d);struct rzg2l_irqc_priv *priv =irq_data_to_priv (d);u32 offset = hw_irq -IRQC_TINT_START ;u32 tssr_offset =TSSR_OFFSET (offset);
@@ -153,7 +152,7 @@ static void rzg2l_irqc_irq_enable(struct irq_data *d)raw_spin_lock (&priv->lock); reg =readl_relaxed (priv->base +TSSR (tssr_index)); - reg |= (TIEN | tint) <<TSSEL_SHIFT (tssr_offset); + reg |=TIEN <<TSSEL_SHIFT (tssr_offset);writel_relaxed (reg, priv->base +TSSR (tssr_index));raw_spin_unlock (&priv->lock); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 206/341 clocksource: Make watchdog and suspend-timing multiplication overflow safe
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit d0304569fb019d1bcfbbbce1ce6df6b96f04079b ]
Kernel timekeeping is designed to keep the change in cycles (since the last timer interrupt) below max_cycles, which prevents multiplication overflow when converting cycles to nanoseconds. However, if timer interrupts stop, the clocksource_cyc2ns() calculation will eventually overflow.
Add protection against that. Simplify by folding together clocksource_delta() and clocksource_cyc2ns() into cycles_to_nsec_safe(). Check against max_cycles, falling back to a slower higher precision calculation.
--- kernel/time/clocksource.c | 42 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 22 deletions(-)
kernel/time/clocksource.c +20 -22
@@ -20,6 +20,16 @@#include "tick-internal.h" #include "timekeeping_internal.h" +static noinline u64 cycles_to_nsec_safe(struct clocksource *cs, u64 start, u64 end) +{ +u64 delta =clocksource_delta (end, start, cs->mask); + +if (likely (delta < cs->max_cycles)) +return clocksource_cyc2ns (delta, cs->mult, cs->shift); + +return mul_u64_u32_shr (delta, cs->mult, cs->shift); +} +/** * clocks_calc_mult_shift - calculate mult/shift factors for scaled math of clocks * @mult: pointer to mult variable
@@ -222,8 +232,8 @@ enum wd_read_status {static enum wd_read_status cs_watchdog_read (struct clocksource *cs,u64 *csnow,u64 *wdnow) {unsigned int nretries, max_retries; -u64 wd_end, wd_end2, wd_delta;int64_t wd_delay, wd_seq_delay; +u64 wd_end, wd_end2; max_retries =clocksource_get_max_watchdog_retry ();for (nretries =0 ; nretries <= max_retries; nretries++) {
@@ -234,9 +244,7 @@ static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow, wd_end2 = watchdog->read (watchdog);local_irq_enable (); - wd_delta =clocksource_delta (wd_end, *wdnow, watchdog->mask); - wd_delay =clocksource_cyc2ns (wd_delta, watchdog->mult, - watchdog->shift); + wd_delay =cycles_to_nsec_safe (watchdog, *wdnow, wd_end);if (wd_delay <=WATCHDOG_MAX_SKEW ) {if (nretries >1 && nretries >= max_retries) { pr_warn("timekeeping watchdog on CPU%d: %s retried %d times before success\n",
@@ -254,8 +262,7 @@ static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow,* report system busy, reinit the watchdog and skip the current * watchdog test. */ - wd_delta =clocksource_delta (wd_end2, wd_end, watchdog->mask); - wd_seq_delay =clocksource_cyc2ns (wd_delta, watchdog->mult, watchdog->shift); + wd_seq_delay =cycles_to_nsec_safe (watchdog, wd_end, wd_end2);if (wd_seq_delay >WATCHDOG_MAX_SKEW /2 ) goto skip_test; }
@@ -366,8 +373,7 @@ void clocksource_verify_percpu(struct clocksource *cs) delta = (csnow_end - csnow_mid) & cs->mask;if (delta <0 )cpumask_set_cpu (cpu, &cpus_ahead); - delta =clocksource_delta (csnow_end, csnow_begin, cs->mask); - cs_nsec =clocksource_cyc2ns (delta, cs->mult, cs->shift); + cs_nsec =cycles_to_nsec_safe (cs, csnow_begin, csnow_end);if (cs_nsec > cs_nsec_max) cs_nsec_max = cs_nsec;if (cs_nsec < cs_nsec_min)
@@ -398,8 +404,8 @@ static inline void clocksource_reset_watchdog(void)static void clocksource_watchdog (struct timer_list *unused) { -u64 csnow, wdnow, cslast, wdlast, delta;int64_t wd_nsec, cs_nsec, interval; +u64 csnow, wdnow, cslast, wdlast;int next_cpu, reset_pending;struct clocksource *cs;enum wd_read_status read_ret;
@@ -456,12 +462,8 @@ static void clocksource_watchdog(struct timer_list *unused)continue ; } - delta =clocksource_delta (wdnow, cs->wd_last, watchdog->mask); - wd_nsec =clocksource_cyc2ns (delta, watchdog->mult, - watchdog->shift); - - delta =clocksource_delta (csnow, cs->cs_last, cs->mask); - cs_nsec =clocksource_cyc2ns (delta, cs->mult, cs->shift); + wd_nsec =cycles_to_nsec_safe (watchdog, cs->wd_last, wdnow); + cs_nsec =cycles_to_nsec_safe (cs, cs->cs_last, csnow); wdlast = cs->wd_last;/* save these in case we print them */ cslast = cs->cs_last; cs->cs_last = csnow;
@@ -832,7 +834,7 @@ void clocksource_start_suspend_timing(struct clocksource *cs, u64 start_cycles)*/ u64 clocksource_stop_suspend_timing (struct clocksource *cs,u64 cycle_now) { -u64 now, delta, nsec =0 ; +u64 now, nsec =0 ;if (!suspend_clocksource)return 0 ;
@@ -847,12 +849,8 @@ u64 clocksource_stop_suspend_timing(struct clocksource *cs, u64 cycle_now)else now = suspend_clocksource->read (suspend_clocksource); -if (now > suspend_start) { - delta =clocksource_delta (now, suspend_start, - suspend_clocksource->mask); - nsec =mul_u64_u32_shr (delta, suspend_clocksource->mult, - suspend_clocksource->shift); - } +if (now > suspend_start) + nsec =cycles_to_nsec_safe (suspend_clocksource, suspend_start, now);/* * Disable the suspend timer to save power if current clocksource is
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 207/341 platform/x86: lg-laptop: fix %s null argument warning
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gergo Koteles <[email protected]>
[ Upstream commit e71c8481692582c70cdfd0996c20cdcc71e425d3 ]
W=1 warns about null argument to kprintf:
warning: ‘%s’ directive argument is null [-Wformat-overflow=] pr_info("product: %s year: %d\n", product, year);
Use "unknown" instead of NULL.
--- drivers/platform/x86/lg-laptop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/lg-laptop.c +1 -1
@@ -715,7 +715,7 @@ static int acpi_add(struct acpi_device *device)default : year =2019 ; } -pr_info ("product: %s year: %d\n" , product, year); +pr_info ("product: %s year: %d\n" , product ?:"unknown" , year);if (year >=2019 ) battery_limit_use_wmbb =1 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 208/341 usb: dwc3: core: Skip setting event buffers for host only controllers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krishna Kurapati <[email protected]>
[ Upstream commit 89d7f962994604a3e3d480832788d06179abefc5 ]
On some SoC's like SA8295P where the tertiary controller is host-only capable, GEVTADDRHI/LO, GEVTSIZ, GEVTCOUNT registers are not accessible. Trying to access them leads to a crash.
For DRD/Peripheral supported controllers, event buffer setup is done again in gadget_pullup. Skip setup or cleanup of event buffers if controller is host-only capable.
--- drivers/usb/dwc3/core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/usb/dwc3/core.c +13 -0
@@ -506,6 +506,13 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)static int dwc3_alloc_event_buffers (struct dwc3 *dwc,unsigned int length) {struct dwc3_event_buffer *evt; +unsigned int hw_mode; + + hw_mode =DWC3_GHWPARAMS0_MODE (dwc->hwparams.hwparams0); +if (hw_mode ==DWC3_GHWPARAMS0_MODE_HOST ) { + dwc->ev_buf =NULL ; +return 0 ; + } evt =dwc3_alloc_one_event_buffer (dwc, length);if (IS_ERR (evt)) {
@@ -527,6 +534,9 @@ int dwc3_event_buffers_setup(struct dwc3 *dwc) {struct dwc3_event_buffer *evt; +if (!dwc->ev_buf) +return 0 ; + evt = dwc->ev_buf; evt->lpos =0 ; dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0),
@@ -544,6 +554,9 @@ void dwc3_event_buffers_cleanup(struct dwc3 *dwc) {struct dwc3_event_buffer *evt; +if (!dwc->ev_buf) +return ; + evt = dwc->ev_buf; evt->lpos =0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 209/341 irqchip/gic-v3-its: Remove BUG_ON in its_vpe_irq_domain_alloc
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanrui Huang <[email protected]>
[ Upstream commit 382d2ffe86efb1e2fa803d2cf17e5bfc34e574f3 ]
This BUG_ON() is useless, because the same effect will be obtained by letting the code run its course and vm being dereferenced, triggering an exception.
So just remove this check.
--- drivers/irqchip/irq-gic-v3-its.c | 2 -- 1 file changed, 2 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +0 -2
@@ -4501,8 +4501,6 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virqstruct page *vprop_page;int base, nr_ids, i, err =0 ; -BUG_ON (!vm); - bitmap =its_lpi_alloc (roundup_pow_of_two (nr_irqs), &base, &nr_ids);if (!bitmap)return -ENOMEM ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 210/341 ext4: set the type of max_zeroout to unsigned int to avoid overflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
[ Upstream commit 261341a932d9244cbcd372a3659428c8723e5a49 ]
The max_zeroout is of type int and the s_extent_max_zeroout_kb is of type uint, and the s_extent_max_zeroout_kb can be freely modified via the sysfs interface. When the block size is 1024, max_zeroout may overflow, so declare it as unsigned int to avoid overflow.
--- fs/ext4/extents.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/extents.c +2 -1
@@ -3402,9 +3402,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,struct ext4_extent *ex, *abut_ex;ext4_lblk_t ee_block, eof_block;unsigned int ee_len, depth, map_len = map->m_len; -int allocated =0 , max_zeroout =0 ;int err =0 ;int split_flag =EXT4_EXT_DATA_VALID2 ; +int allocated =0 ; +unsigned int max_zeroout =0 ;ext_debug (inode,"logical block %llu, max_blocks %u\n" , (unsigned long long )map->m_lblk, map_len);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 211/341 nvmet-rdma: fix possible bad dereference when freeing rsps
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Grimberg <[email protected]>
[ Upstream commit 73964c1d07c054376f1b32a62548571795159148 ]
It is possible that the host connected and saw a cm established event and started sending nvme capsules on the qp, however the ctrl did not yet see an established event. This is why the rsp_wait_list exists (for async handling of these cmds, we move them to a pending list).
Furthermore, it is possible that the ctrl cm times out, resulting in a connect-error cm event. in this case we hit a bad deref [1] because in nvmet_rdma_free_rsps we assume that all the responses are in the free list.
We are freeing the cmds array anyways, so don't even bother to remove the rsp from the free_list. It is also guaranteed that we are not racing anything when we are releasing the queue so no other context accessing this array should be running.
[1]:
--
Workqueue: nvmet-free-wq nvmet_rdma_free_queue_work [nvmet_rdma] [...] pc : nvmet_rdma_free_rsps+0x78/0xb8 [nvmet_rdma] lr : nvmet_rdma_free_queue_work+0x88/0x120 [nvmet_rdma] Call trace: nvmet_rdma_free_rsps+0x78/0xb8 [nvmet_rdma] nvmet_rdma_free_queue_work+0x88/0x120 [nvmet_rdma] process_one_work+0x1ec/0x4a0 worker_thread+0x48/0x490 kthread+0x158/0x160 ret_from_fork+0x10/0x18
--
--- drivers/nvme/target/rdma.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/nvme/target/rdma.c +4 -12
@@ -473,12 +473,8 @@ nvmet_rdma_alloc_rsps(struct nvmet_rdma_queue *queue)return 0 ; out_free: -while (--i >=0 ) { -struct nvmet_rdma_rsp *rsp = &queue->rsps[i]; - -list_del (&rsp->free_list); -nvmet_rdma_free_rsp (ndev, rsp); - } +while (--i >=0 ) +nvmet_rdma_free_rsp (ndev, &queue->rsps[i]);kfree (queue->rsps); out:return ret;
@@ -489,12 +485,8 @@ static void nvmet_rdma_free_rsps(struct nvmet_rdma_queue *queue)struct nvmet_rdma_device *ndev = queue->dev;int i, nr_rsps = queue->recv_queue_size *2 ; -for (i =0 ; i < nr_rsps; i++) { -struct nvmet_rdma_rsp *rsp = &queue->rsps[i]; - -list_del (&rsp->free_list); -nvmet_rdma_free_rsp (ndev, rsp); - } +for (i =0 ; i < nr_rsps; i++) +nvmet_rdma_free_rsp (ndev, &queue->rsps[i]);kfree (queue->rsps); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 212/341 selftests/bpf: Fix a few tests for GCC related warnings.
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cupertino Miranda <[email protected]>
[ Upstream commit 5ddafcc377f98778acc08f660dee6400aece6a62 ]
This patch corrects a few warnings to allow selftests to compile for GCC.
-- progs/cpumask_failure.c --
progs/bpf_misc.h:136:22: error: ‘cpumask’ is used uninitialized [-Werror=uninitialized]
136 | #define __sink(expr) asm volatile("" : "+g"(expr))
| ^~~progs/cpumask_failure.c:68:9: note: in expansion of macro ‘__sink’
68 | __sink(cpumask);
The macro __sink(cpumask) with the '+' contraint modifier forces the the compiler to expect a read and write from cpumask. GCC detects that cpumask is never initialized and reports an error. This patch removes the spurious non required definitions of cpumask.
-- progs/dynptr_fail.c --
progs/dynptr_fail.c:1444:9: error: ‘ptr1’ may be used uninitialized [-Werror=maybe-uninitialized]
1444 | bpf_dynptr_clone(&ptr1, &ptr2);
Many of the tests in the file are related to the detection of uninitialized pointers by the verifier. GCC is able to detect possible uninitialized values, and reports this as an error.
The patch initializes all of the previous uninitialized structs.
-- progs/test_tunnel_kern.c --
progs/test_tunnel_kern.c:590:9: error: array subscript 1 is outside array bounds of ‘struct geneve_opt[1]’ [-Werror=array-bounds=]
590 | *(int *) &gopt.opt_data = bpf_htonl(0xdeadbeef);
| ^~~~~~~~~~~~~~~~~~~~~~~progs/test_tunnel_kern.c:575:27: note: at offset 4 into object ‘gopt’ of size 4
575 | struct geneve_opt gopt;
This tests accesses beyond the defined data for the struct geneve_opt which contains as last field "u8 opt_data[0]" which clearly does not get reserved space (in stack) in the function header. This pattern is repeated in ip6geneve_set_tunnel and geneve_set_tunnel functions. GCC is able to see this and emits a warning.
The patch introduces a local struct that allocates enough space to safely allow the write to opt_data field.
-- progs/jeq_infer_not_null_fail.c --
progs/jeq_infer_not_null_fail.c:21:40: error: array subscript ‘struct bpf_map[0]’ is partly outside array bounds of ‘struct <anonymous>[1]’ [-Werror=array-bounds=]
21 | struct bpf_map *inner_map = map->inner_map_meta;
| ^~progs/jeq_infer_not_null_fail.c:14:3: note: object ‘m_hash’ of size 32
14 | } m_hash SEC(".maps");
This example defines m_hash in the context of the compilation unit and casts it to struct bpf_map which is much smaller than the size of struct bpf_map. It errors out in GCC when it attempts to access an element that would be defined in struct bpf_map outsize of the defined limits for m_hash.
This patch disables the warning through a GCC pragma.
This changes were tested in bpf-next master selftests without any regressions.
--- .../selftests/bpf/progs/cpumask_failure.c | 3 -- .../testing/selftests/bpf/progs/dynptr_fail.c | 12 ++--- .../bpf/progs/jeq_infer_not_null_fail.c | 4 ++ .../selftests/bpf/progs/test_tunnel_kern.c | 47 +++++++++++-------- 4 files changed, 37 insertions(+), 29 deletions(-)
tools/testing/selftests/bpf/progs/cpumask_failure.c +0 -3
@@ -61,11 +61,8 @@ SEC("tp_btf/task_newtask") __failure __msg("bpf_cpumask_set_cpu args#1 expected pointer to STRUCT bpf_cpumask")int BPF_PROG (test_mutate_cpumask ,struct task_struct *task,u64 clone_flags) { -struct bpf_cpumask *cpumask; -/* Can't set the CPU of a non-struct bpf_cpumask. */ bpf_cpumask_set_cpu (0 , (struct bpf_cpumask *)task->cpus_ptr); -__sink (cpumask);return 0 ; }
tools/testing/selftests/bpf/progs/dynptr_fail.c +6 -6
@@ -80,7 +80,7 @@ SEC("?raw_tp") __failure __msg("Unreleased reference id=2")int ringbuf_missing_release1 (void *ctx) { -struct bpf_dynptr ptr; +struct bpf_dynptr ptr = {};bpf_ringbuf_reserve_dynptr (&ringbuf, val,0 , &ptr);
@@ -1385,7 +1385,7 @@ SEC("?raw_tp") __failure __msg("Expected an initialized dynptr as arg #1")int dynptr_adjust_invalid (void *ctx) { -struct bpf_dynptr ptr; +struct bpf_dynptr ptr = {};/* this should fail */ bpf_dynptr_adjust (&ptr,1 ,2 );
@@ -1398,7 +1398,7 @@ SEC("?raw_tp") __failure __msg("Expected an initialized dynptr as arg #1")int dynptr_is_null_invalid (void *ctx) { -struct bpf_dynptr ptr; +struct bpf_dynptr ptr = {};/* this should fail */ bpf_dynptr_is_null (&ptr);
@@ -1411,7 +1411,7 @@ SEC("?raw_tp") __failure __msg("Expected an initialized dynptr as arg #1")int dynptr_is_rdonly_invalid (void *ctx) { -struct bpf_dynptr ptr; +struct bpf_dynptr ptr = {};/* this should fail */ bpf_dynptr_is_rdonly (&ptr);
@@ -1424,7 +1424,7 @@ SEC("?raw_tp") __failure __msg("Expected an initialized dynptr as arg #1")int dynptr_size_invalid (void *ctx) { -struct bpf_dynptr ptr; +struct bpf_dynptr ptr = {};/* this should fail */ bpf_dynptr_size (&ptr);
@@ -1437,7 +1437,7 @@ SEC("?raw_tp") __failure __msg("Expected an initialized dynptr as arg #1")int clone_invalid1 (void *ctx) { -struct bpf_dynptr ptr1; +struct bpf_dynptr ptr1 = {};struct bpf_dynptr ptr2;/* this should fail */
tools/testing/selftests/bpf/progs/jeq_infer_not_null_fail.c +4 -0
@@ -4,6 +4,10 @@#include <bpf/bpf_helpers.h> #include "bpf_misc.h" +#ifndef __clang__ +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif + char _license[] SEC("license") = "GPL";struct {
tools/testing/selftests/bpf/progs/test_tunnel_kern.c +27 -20
83 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 213/341 Revert "bpf, sockmap: Prevent lock inversion deadlock in map delete elem"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Sitnicki <[email protected]>
[ Upstream commit 3b9ce0491a43e9af7f108b2f1bced7cd35931660 ]
This reverts commit ff91059932401894e6c86341915615c5eb0eca48.
This check is no longer needed. BPF programs attached to tracepoints are now rejected by the verifier when they attempt to delete from a sockmap/sockhash maps.
--- net/core/sock_map.c | 6 ------ 1 file changed, 6 deletions(-)
net/core/sock_map.c +0 -6
@@ -411,9 +411,6 @@ static int __sock_map_delete(struct bpf_stab *stab, struct sock *sk_test,struct sock *sk;int err =0 ; -if (irqs_disabled ()) -return -EOPNOTSUPP ;/* locks here are hardirq-unsafe */ -spin_lock_bh (&stab->lock); sk = *psk;if (!sk_test || sk_test == sk)
@@ -936,9 +933,6 @@ static long sock_hash_delete_elem(struct bpf_map *map, void *key)struct bpf_shtab_elem *elem;int ret = -ENOENT ; -if (irqs_disabled ()) -return -EOPNOTSUPP ;/* locks here are hardirq-unsafe */ - hash =sock_hash_bucket_hash (key, key_size); bucket =sock_hash_select_bucket (htab, hash);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 214/341 nvme: use srcu for iterating namespace list
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit be647e2c76b27f409cdd520f66c95be888b553a3 ]
The nvme pci driver synchronizes with all the namespace queues during a reset to ensure that there's no pending timeout work.
Meanwhile the timeout work potentially iterates those same namespaces to freeze their queues.
Each of those namespace iterations use the same read lock. If a write lock should somehow get between the synchronize and freeze steps, then forward progress is deadlocked.
We had been relying on the nvme controller state machine to ensure the reset work wouldn't conflict with timeout work. That guarantee may be a bit fragile to rely on, so iterate the namespace lists without taking potentially circular locks, as reported by lockdep.
--- drivers/nvme/host/core.c | 99 +++++++++++++++++++++-------------- drivers/nvme/host/ioctl.c | 15 +++--- drivers/nvme/host/multipath.c | 21 ++++---- drivers/nvme/host/nvme.h | 4 +- 4 files changed, 83 insertions(+), 56 deletions(-)
drivers/nvme/host/core.c +59 -40
@@ -632,7 +632,7 @@ static void nvme_free_ns(struct kref *kref)kfree (ns); } -static inline bool nvme_get_ns (struct nvme_ns *ns) +bool nvme_get_ns (struct nvme_ns *ns) {return kref_get_unless_zero (&ns->kref); }
@@ -3542,9 +3542,10 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info)struct nvme_ns *nvme_find_get_ns (struct nvme_ctrl *ctrl,unsigned nsid) {struct nvme_ns *ns, *ret =NULL ; +int srcu_idx; -down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) { + srcu_idx =srcu_read_lock (&ctrl->srcu); +list_for_each_entry_rcu (ns, &ctrl->namespaces, list) {if (ns->head->ns_id == nsid) {if (!nvme_get_ns (ns))continue ;
@@ -3554,7 +3555,7 @@ struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid)if (ns->head->ns_id > nsid)break ; } -up_read (&ctrl->namespaces_rwsem); +srcu_read_unlock (&ctrl->srcu, srcu_idx);return ret; }EXPORT_SYMBOL_NS_GPL (nvme_find_get_ns,NVME_TARGET_PASSTHRU );
@@ -3568,7 +3569,7 @@ static void nvme_ns_add_to_ctrl_list(struct nvme_ns *ns)list_for_each_entry_reverse (tmp, &ns->ctrl->namespaces, list) {if (tmp->head->ns_id < ns->head->ns_id) { -list_add (&ns->list, &tmp->list); +list_add_rcu (&ns->list, &tmp->list);return ; } }
@@ -3634,17 +3635,18 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)if (nvme_update_ns_info (ns, info)) goto out_unlink_ns; -down_write (&ctrl->namespaces_rwsem); +mutex_lock (&ctrl->namespaces_lock);/* * Ensure that no namespaces are added to the ctrl list after the queues * are frozen, thereby avoiding a deadlock between scan and reset. */ if (test_bit (NVME_CTRL_FROZEN , &ctrl->flags)) { -up_write (&ctrl->namespaces_rwsem); +mutex_unlock (&ctrl->namespaces_lock); goto out_unlink_ns; }nvme_ns_add_to_ctrl_list (ns); -up_write (&ctrl->namespaces_rwsem); +mutex_unlock (&ctrl->namespaces_lock); +synchronize_srcu (&ctrl->srcu);nvme_get_ctrl (ctrl);if (device_add_disk (ctrl->device, ns->disk, nvme_ns_id_attr_groups))
@@ -3660,9 +3662,10 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info) out_cleanup_ns_from_list:nvme_put_ctrl (ctrl); -down_write (&ctrl->namespaces_rwsem); -list_del_init (&ns->list); -up_write (&ctrl->namespaces_rwsem); +mutex_lock (&ctrl->namespaces_lock); +list_del_rcu (&ns->list); +mutex_unlock (&ctrl->namespaces_lock); +synchronize_srcu (&ctrl->srcu); out_unlink_ns:mutex_lock (&ctrl->subsys->lock);list_del_rcu (&ns->siblings);
@@ -3712,9 +3715,10 @@ static void nvme_ns_remove(struct nvme_ns *ns)nvme_cdev_del (&ns->cdev, &ns->cdev_device);del_gendisk (ns->disk); -down_write (&ns->ctrl->namespaces_rwsem); -list_del_init (&ns->list); -up_write (&ns->ctrl->namespaces_rwsem); +mutex_lock (&ns->ctrl->namespaces_lock); +list_del_rcu (&ns->list); +mutex_unlock (&ns->ctrl->namespaces_lock); +synchronize_srcu (&ns->ctrl->srcu);if (last_path)nvme_mpath_shutdown_disk (ns->head);
@@ -3804,16 +3808,17 @@ static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,struct nvme_ns *ns, *next;LIST_HEAD (rm_list); -down_write (&ctrl->namespaces_rwsem); +mutex_lock (&ctrl->namespaces_lock);list_for_each_entry_safe (ns, next, &ctrl->namespaces, list) {if (ns->head->ns_id > nsid) -list_move_tail (&ns->list, &rm_list); +list_splice_init_rcu (&ns->list, &rm_list, + synchronize_rcu); } -up_write (&ctrl->namespaces_rwsem); +mutex_unlock (&ctrl->namespaces_lock); +synchronize_srcu (&ctrl->srcu);list_for_each_entry_safe (ns, next, &rm_list, list)nvme_ns_remove (ns); - }static int nvme_scan_ns_list (struct nvme_ctrl *ctrl)
@@ -3983,9 +3988,10 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)/* this is a no-op when called from the controller reset handler */ nvme_change_ctrl_state (ctrl,NVME_CTRL_DELETING_NOIO ); -down_write (&ctrl->namespaces_rwsem); -list_splice_init (&ctrl->namespaces, &ns_list); -up_write (&ctrl->namespaces_rwsem); +mutex_lock (&ctrl->namespaces_lock); +list_splice_init_rcu (&ctrl->namespaces, &ns_list, synchronize_rcu); +mutex_unlock (&ctrl->namespaces_lock); +synchronize_srcu (&ctrl->srcu);list_for_each_entry_safe (ns, next, &ns_list, list)nvme_ns_remove (ns);
@@ -4418,6 +4424,7 @@ static void nvme_free_ctrl(struct device *dev)nvme_free_cels (ctrl);nvme_mpath_uninit (ctrl); +cleanup_srcu_struct (&ctrl->srcu);nvme_auth_stop (ctrl);nvme_auth_free (ctrl);__free_page (ctrl->discard_page);
@@ -4449,10 +4456,15 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,WRITE_ONCE (ctrl->state,NVME_CTRL_NEW );clear_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags);spin_lock_init (&ctrl->lock); +mutex_init (&ctrl->namespaces_lock); + + ret =init_srcu_struct (&ctrl->srcu); +if (ret) +return ret; +mutex_init (&ctrl->scan_lock);INIT_LIST_HEAD (&ctrl->namespaces);xa_init (&ctrl->cels); -init_rwsem (&ctrl->namespaces_rwsem); ctrl->dev = dev; ctrl->ops = ops; ctrl->quirks = quirks;
@@ -4531,6 +4543,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, out:if (ctrl->discard_page)__free_page (ctrl->discard_page); +cleanup_srcu_struct (&ctrl->srcu);return ret; }EXPORT_SYMBOL_GPL (nvme_init_ctrl);
@@ -4539,22 +4552,24 @@ EXPORT_SYMBOL_GPL(nvme_init_ctrl);void nvme_mark_namespaces_dead (struct nvme_ctrl *ctrl) {struct nvme_ns *ns; +int srcu_idx; -down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) + srcu_idx =srcu_read_lock (&ctrl->srcu); +list_for_each_entry_rcu (ns, &ctrl->namespaces, list)blk_mark_disk_dead (ns->disk); -up_read (&ctrl->namespaces_rwsem); +srcu_read_unlock (&ctrl->srcu, srcu_idx); }EXPORT_SYMBOL_GPL (nvme_mark_namespaces_dead);void nvme_unfreeze (struct nvme_ctrl *ctrl) {struct nvme_ns *ns; +int srcu_idx; -down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) + srcu_idx =srcu_read_lock (&ctrl->srcu); +list_for_each_entry_rcu (ns, &ctrl->namespaces, list)blk_mq_unfreeze_queue (ns->queue); -up_read (&ctrl->namespaces_rwsem); +srcu_read_unlock (&ctrl->srcu, srcu_idx);clear_bit (NVME_CTRL_FROZEN , &ctrl->flags); }EXPORT_SYMBOL_GPL (nvme_unfreeze);
@@ -4562,14 +4577,15 @@ EXPORT_SYMBOL_GPL(nvme_unfreeze);int nvme_wait_freeze_timeout (struct nvme_ctrl *ctrl,long timeout) {struct nvme_ns *ns; +int srcu_idx; -down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) { + srcu_idx =srcu_read_lock (&ctrl->srcu); +list_for_each_entry_rcu (ns, &ctrl->namespaces, list) { timeout =blk_mq_freeze_queue_wait_timeout (ns->queue, timeout);if (timeout <=0 )break ; } -up_read (&ctrl->namespaces_rwsem); +srcu_read_unlock (&ctrl->srcu, srcu_idx);return timeout; }EXPORT_SYMBOL_GPL (nvme_wait_freeze_timeout);
@@ -4577,23 +4593,25 @@ EXPORT_SYMBOL_GPL(nvme_wait_freeze_timeout);void nvme_wait_freeze (struct nvme_ctrl *ctrl) {struct nvme_ns *ns; +int srcu_idx; -down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) + srcu_idx =srcu_read_lock (&ctrl->srcu); +list_for_each_entry_rcu (ns, &ctrl->namespaces, list)blk_mq_freeze_queue_wait (ns->queue); -up_read (&ctrl->namespaces_rwsem); +srcu_read_unlock (&ctrl->srcu, srcu_idx); }EXPORT_SYMBOL_GPL (nvme_wait_freeze);void nvme_start_freeze (struct nvme_ctrl *ctrl) {struct nvme_ns *ns; +int srcu_idx;set_bit (NVME_CTRL_FROZEN , &ctrl->flags); -down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) + srcu_idx =srcu_read_lock (&ctrl->srcu); +list_for_each_entry_rcu (ns, &ctrl->namespaces, list)blk_freeze_queue_start (ns->queue); -up_read (&ctrl->namespaces_rwsem); +srcu_read_unlock (&ctrl->srcu, srcu_idx); }EXPORT_SYMBOL_GPL (nvme_start_freeze);
@@ -4636,11 +4654,12 @@ EXPORT_SYMBOL_GPL(nvme_unquiesce_admin_queue);void nvme_sync_io_queues (struct nvme_ctrl *ctrl) {struct nvme_ns *ns; +int srcu_idx; -down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) + srcu_idx =srcu_read_lock (&ctrl->srcu); +list_for_each_entry_rcu (ns, &ctrl->namespaces, list)blk_sync_queue (ns->queue); -up_read (&ctrl->namespaces_rwsem); +srcu_read_unlock (&ctrl->srcu, srcu_idx); }EXPORT_SYMBOL_GPL (nvme_sync_io_queues);
drivers/nvme/host/ioctl.c +9 -6
@@ -921,15 +921,15 @@ static int nvme_dev_user_cmd(struct nvme_ctrl *ctrl, void __user *argp, bool open_for_write) {struct nvme_ns *ns; -int ret; +int ret, srcu_idx; -down_read (&ctrl->namespaces_rwsem); + srcu_idx =srcu_read_lock (&ctrl->srcu);if (list_empty (&ctrl->namespaces)) { ret = -ENOTTY ; goto out_unlock; } - ns = list_first_entry(&ctrl->namespaces, struct nvme_ns, list); + ns = list_first_or_null_rcu(&ctrl->namespaces, struct nvme_ns, list); if (ns != list_last_entry(&ctrl->namespaces, struct nvme_ns, list)) {dev_warn (ctrl->device,"NVME_IOCTL_IO_CMD not supported when multiple namespaces present!\n" );
@@ -939,15 +939,18 @@ static int nvme_dev_user_cmd(struct nvme_ctrl *ctrl, void __user *argp,dev_warn (ctrl->device,"using deprecated NVME_IOCTL_IO_CMD ioctl on the char device!\n" ); -kref_get (&ns->kref); -up_read (&ctrl->namespaces_rwsem); +if (!nvme_get_ns (ns)) { + ret = -ENXIO ; + goto out_unlock; + } +srcu_read_unlock (&ctrl->srcu, srcu_idx); ret =nvme_user_cmd (ctrl, ns, argp,0 , open_for_write);nvme_put_ns (ns);return ret; out_unlock: -up_read (&ctrl->namespaces_rwsem); +srcu_read_unlock (&ctrl->srcu, srcu_idx);return ret; }
drivers/nvme/host/multipath.c +12 -9
@@ -151,16 +151,17 @@ void nvme_mpath_end_request(struct request *rq)void nvme_kick_requeue_lists (struct nvme_ctrl *ctrl) {struct nvme_ns *ns; +int srcu_idx; -down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) { + srcu_idx =srcu_read_lock (&ctrl->srcu); +list_for_each_entry_rcu (ns, &ctrl->namespaces, list) {if (!ns->head->disk)continue ;kblockd_schedule_work (&ns->head->requeue_work);if (ctrl->state ==NVME_CTRL_LIVE )disk_uevent (ns->head->disk,KOBJ_CHANGE ); } -up_read (&ctrl->namespaces_rwsem); +srcu_read_unlock (&ctrl->srcu, srcu_idx); }static const char *nvme_ana_state_names[] = {
@@ -194,13 +195,14 @@ bool nvme_mpath_clear_current_path(struct nvme_ns *ns)void nvme_mpath_clear_ctrl_paths (struct nvme_ctrl *ctrl) {struct nvme_ns *ns; +int srcu_idx; -down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) { + srcu_idx =srcu_read_lock (&ctrl->srcu); +list_for_each_entry_rcu (ns, &ctrl->namespaces, list) {nvme_mpath_clear_current_path (ns);kblockd_schedule_work (&ns->head->requeue_work); } -up_read (&ctrl->namespaces_rwsem); +srcu_read_unlock (&ctrl->srcu, srcu_idx); }void nvme_mpath_revalidate_paths (struct nvme_ns *ns)
@@ -679,6 +681,7 @@ static int nvme_update_ana_state(struct nvme_ctrl *ctrl,u32 nr_nsids =le32_to_cpu (desc->nnsids), n =0 ;unsigned *nr_change_groups = data;struct nvme_ns *ns; +int srcu_idx; dev_dbg(ctrl->device, "ANA group %d: %s.\n", le32_to_cpu(desc->grpid),
@@ -690,8 +693,8 @@ static int nvme_update_ana_state(struct nvme_ctrl *ctrl,if (!nr_nsids)return 0 ; -down_read (&ctrl->namespaces_rwsem); -list_for_each_entry (ns, &ctrl->namespaces, list) { + srcu_idx =srcu_read_lock (&ctrl->srcu); +list_for_each_entry_rcu (ns, &ctrl->namespaces, list) {unsigned nsid; again: nsid =le32_to_cpu (desc->nsids[n]);
@@ -704,7 +707,7 @@ static int nvme_update_ana_state(struct nvme_ctrl *ctrl,if (ns->head->ns_id > nsid) goto again; } -up_read (&ctrl->namespaces_rwsem); +srcu_read_unlock (&ctrl->srcu, srcu_idx);return 0 ; }
drivers/nvme/host/nvme.h +3 -1
@@ -280,7 +280,8 @@ struct nvme_ctrl {struct blk_mq_tag_set *tagset;struct blk_mq_tag_set *admin_tagset;struct list_head namespaces; -struct rw_semaphore namespaces_rwsem; +struct mutex namespaces_lock; +struct srcu_struct srcu;struct device ctrl_device;struct device *device;/* char device */ #ifdef CONFIG_NVME_HWMON
@@ -1126,6 +1127,7 @@ void nvme_passthru_end(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u32 effects, struct nvme_command *cmd, int status);struct nvme_ctrl *nvme_ctrl_from_file (struct file *file);struct nvme_ns *nvme_find_get_ns (struct nvme_ctrl *ctrl,unsigned nsid); +bool nvme_get_ns (struct nvme_ns *ns);void nvme_put_ns (struct nvme_ns *ns);static inline bool nvme_multi_css (struct nvme_ctrl *ctrl)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 215/341 drm/amdgpu: fix dereference null return value for the function amdgpu_vm_pt_parent
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jesse Zhang <[email protected]>
[ Upstream commit 511a623fb46a6cf578c61d4f2755783c48807c77 ]
The pointer parent may be NULLed by the function amdgpu_vm_pt_parent. To make the code more robust, check the pointer parent.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +5 -1
@@ -766,11 +766,15 @@ int amdgpu_vm_pde_update(struct amdgpu_vm_update_params *params, struct amdgpu_vm_bo_base *entry) {struct amdgpu_vm_bo_base *parent =amdgpu_vm_pt_parent (entry); -struct amdgpu_bo *bo = parent->bo, *pbo; +struct amdgpu_bo *bo, *pbo;struct amdgpu_vm *vm = params->vm;uint64_t pde, pt, flags;unsigned int level; +if (WARN_ON (!parent)) +return -EINVAL ; + + bo = parent->bo;for (level =0 , pbo = bo->parent; pbo; ++level) pbo = pbo->parent;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 216/341 hrtimer: Prevent queuing of hrtimer without a function callback
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Phil Chang <[email protected]>
[ Upstream commit 5a830bbce3af16833fe0092dec47b6dd30279825 ]
The hrtimer function callback must not be NULL. It has to be specified by the call side but it is not validated by the hrtimer code. When a hrtimer is queued without a function callback, the kernel crashes with a null pointer dereference when trying to execute the callback in __run_hrtimer().
Introduce a validation before queuing the hrtimer in hrtimer_start_range_ns().
[anna-maria: Rephrase commit message]
--- kernel/time/hrtimer.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/time/hrtimer.c +2 -0
@@ -1288,6 +1288,8 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,struct hrtimer_clock_base *base;unsigned long flags; +if (WARN_ON_ONCE (!timer->function)) +return ;/* * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft * match on CONFIG_PREEMPT_RT = n. With PREEMPT_RT check the hard
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 217/341 ionic: use pci_is_enabled not open code
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shannon Nelson <[email protected]>
[ Upstream commit 121e4dcba3700b30e63f25203d09ddfccbab4a09 ]
Since there is a utility available for this, use
the API rather than open code.
--- drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +1 -1
@@ -223,7 +223,7 @@ static void ionic_clear_pci(struct ionic *ionic)ionic_unmap_bars (ionic);pci_release_regions (ionic->pdev); -if (atomic_read (&ionic->pdev->enable_cnt) >0 ) +if (pci_is_enabled (ionic->pdev))pci_disable_device (ionic->pdev); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 218/341 ionic: check cmd_regs before copying in or out
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shannon Nelson <[email protected]>
[ Upstream commit 7662fad348ac54120e9e6443cb0bbe4f3b582219 ]
Since we now have potential cases of NULL cmd_regs and info_regs during a reset recovery, and left NULL if a reset recovery has failed, we need to check that they exist before we use them. Most of the cases were covered in the original patch where we verify before doing the ioreadb() for health or cmd status. However, we need to protect a few uses of io mem that could be hit in error recovery or asynchronous threads calls as well (e.g. ethtool or devlink handlers).
--- drivers/net/ethernet/pensando/ionic/ionic_dev.c | 10 ++++++++++ drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 7 ++++++- drivers/net/ethernet/pensando/ionic/ionic_fw.c | 5 +++++ drivers/net/ethernet/pensando/ionic/ionic_main.c | 3 +++ 4 files changed, 24 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.c +10 -0
@@ -319,22 +319,32 @@ int ionic_heartbeat_check(struct ionic *ionic)u8 ionic_dev_cmd_status (struct ionic_dev *idev) { +if (!idev->dev_cmd_regs) +return (u8 )PCI_ERROR_RESPONSE ;return ioread8 (&idev->dev_cmd_regs->comp.comp.status); }bool ionic_dev_cmd_done (struct ionic_dev *idev) { +if (!idev->dev_cmd_regs) +return false;return ioread32 (&idev->dev_cmd_regs->done) &IONIC_DEV_CMD_DONE ; }void ionic_dev_cmd_comp (struct ionic_dev *idev,union ionic_dev_cmd_comp *comp) { +if (!idev->dev_cmd_regs) +return ;memcpy_fromio (comp, &idev->dev_cmd_regs->comp,sizeof (*comp)); }void ionic_dev_cmd_go (struct ionic_dev *idev,union ionic_dev_cmd *cmd) { idev->opcode = cmd->cmd.opcode; + +if (!idev->dev_cmd_regs) +return ; +memcpy_toio (&idev->dev_cmd_regs->cmd, cmd,sizeof (*cmd));iowrite32 (0 , &idev->dev_cmd_regs->done);iowrite32 (1 , &idev->dev_cmd_regs->doorbell);
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +6 -1
@@ -90,18 +90,23 @@ static void ionic_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p) {struct ionic_lif *lif =netdev_priv (netdev); +struct ionic_dev *idev;unsigned int offset;unsigned int size; regs->version =IONIC_DEV_CMD_REG_VERSION ; + idev = &lif->ionic->idev; +if (!idev->dev_info_regs) +return ; + offset =0 ; size =IONIC_DEV_INFO_REG_COUNT *sizeof (u32);memcpy_fromio (p + offset, lif->ionic->idev.dev_info_regs->words, size); offset += size; size =IONIC_DEV_CMD_REG_COUNT *sizeof (u32); -memcpy_fromio (p + offset, lif->ionic->idev.dev_cmd_regs->words, size); +memcpy_fromio (p + offset, idev->dev_cmd_regs->words, size); } static void ionic_get_link_ext_stats(struct net_device *netdev,
drivers/net/ethernet/pensando/ionic/ionic_fw.c +5 -0
@@ -109,6 +109,11 @@ int ionic_firmware_update(struct ionic_lif *lif, const struct firmware *fw, dl =priv_to_devlink (ionic);devlink_flash_update_status_notify (dl,"Preparing to flash" ,NULL ,0 ,0 ); +if (!idev->dev_cmd_regs) { + err = -ENXIO ; + goto err_out; + } + buf_sz =sizeof (idev->dev_cmd_regs->data); netdev_dbg(netdev,
drivers/net/ethernet/pensando/ionic/ionic_main.c +3 -0
@@ -438,6 +438,9 @@ static void ionic_dev_cmd_clean(struct ionic *ionic) {struct ionic_dev *idev = &ionic->idev; +if (!idev->dev_cmd_regs) +return ; +iowrite32 (0 , &idev->dev_cmd_regs->doorbell);memset_io (&idev->dev_cmd_regs->cmd,0 ,sizeof (idev->dev_cmd_regs->cmd)); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 219/341 EDAC/skx_common: Allow decoding of SGX addresses
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiuxu Zhuo <[email protected]>
[ Upstream commit e0d335077831196bffe6a634ffe385fc684192ca ]
There are no "struct page" associations with SGX pages, causing the check pfn_to_online_page() to fail. This results in the inability to decode the SGX addresses and warning messages like:
Invalid address 0x34cc9a98840 in IA32_MC17_ADDR
Add an additional check to allow the decoding of the error address and to skip the warning message, if the error address is an SGX address.
--- drivers/edac/skx_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/skx_common.c +1 -1
@@ -659,7 +659,7 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,memset (&res,0 ,sizeof (res)); res.mce = mce; res.addr = mce->addr &MCI_ADDR_PHYSADDR ; -if (!pfn_to_online_page (res.addr >>PAGE_SHIFT )) { +if (!pfn_to_online_page (res.addr >>PAGE_SHIFT ) && !arch_is_platform_page (res.addr)) {pr_err ("Invalid address 0x%llx in IA32_MC%d_ADDR\n" , mce->addr, mce->bank);return NOTIFY_DONE ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 220/341 nvme: fix namespace removal list
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit ff0ffe5b7c3c12c6e0cca16652905963ae817b44 ]
This function wants to move a subset of a list from one element to the tail into another list. It also needs to use the srcu synchronize instead of the regular rcu version. Do this one element at a time because that's the only to do it.
--- drivers/nvme/host/core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/nvme/host/core.c +5 -4
@@ -3810,12 +3810,13 @@ static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,mutex_lock (&ctrl->namespaces_lock);list_for_each_entry_safe (ns, next, &ctrl->namespaces, list) { -if (ns->head->ns_id > nsid) -list_splice_init_rcu (&ns->list, &rm_list, - synchronize_rcu); +if (ns->head->ns_id > nsid) { +list_del_rcu (&ns->list); +synchronize_srcu (&ctrl->srcu); +list_add_tail_rcu (&ns->list, &rm_list); + } }mutex_unlock (&ctrl->namespaces_lock); -synchronize_srcu (&ctrl->srcu);list_for_each_entry_safe (ns, next, &rm_list, list)nvme_ns_remove (ns);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 221/341 gtp: pull network headers in gtp_dev_xmit()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 3a3be7ff9224f424e485287b54be00d2c6bd9c40 upstream.
syzbot/KMSAN reported use of uninit-value in get_dev_xmit() [1]
We must make sure the IPv4 or Ipv6 header is pulled in skb->head before accessing fields in them.
Use pskb_inet_may_pull() to fix this issue.
[1]
BUG: KMSAN: uninit-value in ipv6_pdp_find drivers/net/gtp.c:220 [inline] BUG: KMSAN: uninit-value in gtp_build_skb_ip6 drivers/net/gtp.c:1229 [inline] BUG: KMSAN: uninit-value in gtp_dev_xmit+0x1424/0x2540 drivers/net/gtp.c:1281 ipv6_pdp_find drivers/net/gtp.c:220 [inline] gtp_build_skb_ip6 drivers/net/gtp.c:1229 [inline] gtp_dev_xmit+0x1424/0x2540 drivers/net/gtp.c:1281 __netdev_start_xmit include/linux/netdevice.h:4913 [inline] netdev_start_xmit include/linux/netdevice.h:4922 [inline] xmit_one net/core/dev.c:3580 [inline] dev_hard_start_xmit+0x247/0xa20 net/core/dev.c:3596 __dev_queue_xmit+0x358c/0x5610 net/core/dev.c:4423 dev_queue_xmit include/linux/netdevice.h:3105 [inline] packet_xmit+0x9c/0x6c0 net/packet/af_packet.c:276 packet_snd net/packet/af_packet.c:3145 [inline] packet_sendmsg+0x90e3/0xa3a0 net/packet/af_packet.c:3177 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x30f/0x380 net/socket.c:745 __sys_sendto+0x685/0x830 net/socket.c:2204 __do_sys_sendto net/socket.c:2216 [inline] __se_sys_sendto net/socket.c:2212 [inline] __x64_sys_sendto+0x125/0x1d0 net/socket.c:2212 x64_sys_call+0x3799/0x3c10 arch/x86/include/generated/asm/syscalls_64.h:45 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was created at:
slab_post_alloc_hook mm/slub.c:3994 [inline] slab_alloc_node mm/slub.c:4037 [inline] kmem_cache_alloc_node_noprof+0x6bf/0xb80 mm/slub.c:4080 kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:583 __alloc_skb+0x363/0x7b0 net/core/skbuff.c:674 alloc_skb include/linux/skbuff.h:1320 [inline] alloc_skb_with_frags+0xc8/0xbf0 net/core/skbuff.c:6526 sock_alloc_send_pskb+0xa81/0xbf0 net/core/sock.c:2815 packet_alloc_skb net/packet/af_packet.c:2994 [inline] packet_snd net/packet/af_packet.c:3088 [inline] packet_sendmsg+0x749c/0xa3a0 net/packet/af_packet.c:3177 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x30f/0x380 net/socket.c:745 __sys_sendto+0x685/0x830 net/socket.c:2204 __do_sys_sendto net/socket.c:2216 [inline] __se_sys_sendto net/socket.c:2212 [inline] __x64_sys_sendto+0x125/0x1d0 net/socket.c:2212 x64_sys_call+0x3799/0x3c10 arch/x86/include/generated/asm/syscalls_64.h:45 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f CPU: 0 UID: 0 PID: 7115 Comm: syz.1.515 Not tainted 6.11.0-rc1-syzkaller-00043-g94ede2a3e913 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
--- drivers/net/gtp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/gtp.c +3 -0
@@ -901,6 +901,9 @@ static netdev_tx_t gtp_dev_xmit(struct sif (skb_cow_head (skb, dev->needed_headroom)) goto tx_err; +if (!pskb_inet_may_pull (skb)) + goto tx_err; +skb_reset_inner_headers (skb);/* PDP context lookups in gtp_build_skb_*() need rcu read-side lock. */
Greg Kroah-Hartman
maintainerPATCH 222/341 jfs: define xtree root and page independently
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Kleikamp <[email protected]>
commit a779ed754e52d582b8c0e17959df063108bd0656 upstream.
In order to make array bounds checking sane, provide a separate definition of the in-inode xtree root and the external xtree page.
--- fs/jfs/jfs_dinode.h | 2 +- fs/jfs/jfs_imap.c | 6 +++--- fs/jfs/jfs_incore.h | 2 +- fs/jfs/jfs_txnmgr.c | 4 ++-- fs/jfs/jfs_xtree.c | 4 ++-- fs/jfs/jfs_xtree.h | 37 +++++++++++++++++++++++-------------- 6 files changed, 32 insertions(+), 23 deletions(-)
fs/jfs/jfs_dinode.h +1 -1
@@ -96,7 +96,7 @@ struct dinode {#define di_gengen u._file._u1._imap._gengenunion { -xtpage_t _xtroot; +xtroot_t _xtroot;struct {u8 unused[16 ];/* 16: */ dxd_t _dxd;/* 16: */
fs/jfs/jfs_imap.c +3 -3
@@ -673,7 +673,7 @@ int diWrite(tid_t tid, struct inode *ip)* This is the special xtree inside the directory for storing * the directory table */ -xtpage_t *p, *xp; +xtroot_t *p, *xp;xad_t *xad; jfs_ip->xtlid =0 ;
@@ -687,7 +687,7 @@ int diWrite(tid_t tid, struct inode *ip)* copy xtree root from inode to dinode: */ p = &jfs_ip->i_xtroot; - xp = (xtpage_t *) &dp->di_dirtable; + xp = (xtroot_t *) &dp->di_dirtable; lv = ilinelock->lv;for (n =0 ; n < ilinelock->index; n++, lv++) { memcpy(&xp->xad[lv->offset], &p->xad[lv->offset],
@@ -716,7 +716,7 @@ int diWrite(tid_t tid, struct inode *ip)* regular file: 16 byte (XAD slot) granularity */ if (type & tlckXTREE) { -xtpage_t *p, *xp; +xtroot_t *p, *xp;xad_t *xad;/*
fs/jfs/jfs_incore.h +1 -1
@@ -66,7 +66,7 @@ struct jfs_inode_info {lid_t xtlid;/* lid of xtree lock on directory */ union {struct { -xtpage_t _xtroot;/* 288: xtree root */ +xtroot_t _xtroot;/* 288: xtree root */ struct inomap *_imap;/* 4: inode map header */ } file;struct {
fs/jfs/jfs_txnmgr.c +2 -2
@@ -783,7 +783,7 @@ struct tlock *txLock(tid_t tid, struct iif (mp->xflag &COMMIT_PAGE ) p = (xtpage_t *) mp->data;else - p = &jfs_ip->i_xtroot; + p = (xtpage_t *) &jfs_ip->i_xtroot; xtlck->lwm.offset =le16_to_cpu (p->header.nextindex); }
@@ -1676,7 +1676,7 @@ static void xtLog(struct jfs_log * log,if (tlck->type & tlckBTROOT) { lrd->log.redopage.type |=cpu_to_le16 (LOG_BTROOT ); - p = &JFS_IP (ip)->i_xtroot; + p = (xtpage_t *) &JFS_IP (ip)->i_xtroot;if (S_ISDIR (ip->i_mode)) lrd->log.redopage.type |=cpu_to_le16 (LOG_DIR_XTREE );
fs/jfs/jfs_xtree.c +2 -2
@@ -1213,7 +1213,7 @@ xtSplitRoot(tid_t tid,struct xtlock *xtlck;int rc; - sp = &JFS_IP (ip)->i_xtroot; + sp = (xtpage_t *) &JFS_IP (ip)->i_xtroot;INCREMENT (xtStat.split);
@@ -2098,7 +2098,7 @@ int xtAppend(tid_t tid, /* transaction*/ void xtInitRoot (tid_t tid,struct inode *ip) { -xtpage_t *p; +xtroot_t *p;/* * acquire a transaction lock on the root
fs/jfs/jfs_xtree.h +23 -14
@@ -65,24 +65,33 @@ struct xadlist {#define XTPAGEMAXSLOT 256#define XTENTRYSTART 2 +struct xtheader { +__le64 next;/* 8: */ +__le64 prev;/* 8: */ + +u8 flag;/* 1: */ +u8 rsrvd1;/* 1: */ +__le16 nextindex;/* 2: next index = number of entries */ +__le16 maxentry;/* 2: max number of entries */ +__le16 rsrvd2;/* 2: */ + +pxd_t self;/* 8: self */ +}; +/* -* xtree page: +* xtree root (in inode): */ typedef union { -struct xtheader { -__le64 next;/* 8: */ -__le64 prev;/* 8: */ - -u8 flag;/* 1: */ -u8 rsrvd1;/* 1: */ -__le16 nextindex;/* 2: next index = number of entries */ -__le16 maxentry;/* 2: max number of entries */ -__le16 rsrvd2;/* 2: */ - -pxd_t self;/* 8: self */ - } header;/* (32) */ - +struct xtheader header;xad_t xad[XTROOTMAXSLOT ];/* 16 * maxentry: xad array */ +}xtroot_t ; + +/* +* xtree page: +*/ +typedef union { +struct xtheader header; +xad_t xad[XTPAGEMAXSLOT ];/* 16 * maxentry: xad array */ }xtpage_t ;/*
Greg Kroah-Hartman
maintainerPATCH 223/341 i2c: stm32f7: Add atomic_xfer method to driver
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Nyekjaer <[email protected]>
commit 470a662688563d8f5e0fb164930d6f5507a883e4 upstream.
Add an atomic_xfer method to the driver so that it behaves correctly when controlling a PMIC that is responsible for device shutdown.
The atomic_xfer method added is similar to the one from the i2c-mv64xxx driver. When running an atomic_xfer a bool flag in the driver data is set, the interrupt is not unmasked on transfer start, and the IRQ handler is manually invoked while waiting for pending transfers to complete.
--- drivers/i2c/busses/i2c-stm32f7.c | 51 +++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-stm32f7.c +47 -4
@@ -357,6 +357,7 @@ struct stm32f7_i2c_dev {u32 dnf_dt;u32 dnf;struct stm32f7_i2c_alert *alert; +bool atomic; };/*
@@ -915,7 +916,8 @@ static void stm32f7_i2c_xfer_msg(struct/* Configure DMA or enable RX/TX interrupt */ i2c_dev->use_dma = false; -if (i2c_dev->dma && f7_msg->count >=STM32F7_I2C_DMA_LEN_MIN ) { +if (i2c_dev->dma && f7_msg->count >=STM32F7_I2C_DMA_LEN_MIN + && !i2c_dev->atomic) { ret = stm32_i2c_prep_dma_xfer(i2c_dev->dev, i2c_dev->dma, msg->flags & I2C_M_RD, f7_msg->count, f7_msg->buf,
@@ -939,6 +941,9 @@ static void stm32f7_i2c_xfer_msg(struct cr1 |=STM32F7_I2C_CR1_TXDMAEN ; } +if (i2c_dev->atomic) + cr1 &= ~STM32F7_I2C_ALL_IRQ_MASK ;/* Disable all interrupts */ +/* Configure Start/Repeated Start */ cr2 |=STM32F7_I2C_CR2_START ;
@@ -1673,7 +1678,22 @@ static irqreturn_t stm32f7_i2c_isr_errorreturn IRQ_HANDLED ; } -static int stm32f7_i2c_xfer (struct i2c_adapter *i2c_adap, +static int stm32f7_i2c_wait_polling (struct stm32f7_i2c_dev *i2c_dev) +{ +ktime_t timeout =ktime_add_ms (ktime_get (), i2c_dev->adap.timeout); + +while (ktime_compare (ktime_get (), timeout) <0 ) { +udelay (5 ); +stm32f7_i2c_isr_event (0 , i2c_dev); + +if (completion_done (&i2c_dev->complete)) +return 1 ; + } + +return 0 ; +} + +static int stm32f7_i2c_xfer_core (struct i2c_adapter *i2c_adap,struct i2c_msg msgs[],int num) {struct stm32f7_i2c_dev *i2c_dev =i2c_get_adapdata (i2c_adap);
@@ -1697,8 +1717,12 @@ static int stm32f7_i2c_xfer(struct i2c_astm32f7_i2c_xfer_msg (i2c_dev, msgs); - time_left =wait_for_completion_timeout (&i2c_dev->complete, - i2c_dev->adap.timeout); +if (!i2c_dev->atomic) + time_left =wait_for_completion_timeout (&i2c_dev->complete, + i2c_dev->adap.timeout); +else + time_left =stm32f7_i2c_wait_polling (i2c_dev); + ret = f7_msg->result;if (ret) {if (i2c_dev->use_dma)
@@ -1730,6 +1754,24 @@ pm_free:return (ret <0 ) ? ret : num; } +static int stm32f7_i2c_xfer (struct i2c_adapter *i2c_adap, +struct i2c_msg msgs[],int num) +{ +struct stm32f7_i2c_dev *i2c_dev =i2c_get_adapdata (i2c_adap); + + i2c_dev->atomic = false; +return stm32f7_i2c_xfer_core (i2c_adap, msgs, num); +} + +static int stm32f7_i2c_xfer_atomic (struct i2c_adapter *i2c_adap, +struct i2c_msg msgs[],int num) +{ +struct stm32f7_i2c_dev *i2c_dev =i2c_get_adapdata (i2c_adap); + + i2c_dev->atomic = true; +return stm32f7_i2c_xfer_core (i2c_adap, msgs, num); +} + static int stm32f7_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, char read_write, u8 command, int size,
@@ -2098,6 +2140,7 @@ static u32 stm32f7_i2c_func(struct i2c_astatic const struct i2c_algorithm stm32f7_i2c_algo = { .master_xfer = stm32f7_i2c_xfer, + .master_xfer_atomic = stm32f7_i2c_xfer_atomic, .smbus_xfer = stm32f7_i2c_smbus_xfer, .functionality = stm32f7_i2c_func, .reg_slave = stm32f7_i2c_reg_slave,
Greg Kroah-Hartman
maintainerPATCH 224/341 riscv: entry: always initialize regs->a0 to -ENOSYS
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Celeste Liu <[email protected]>
[ Upstream commit 61119394631f219e23ce98bcc3eb993a64a8ea64 ]
Otherwise when the tracer changes syscall number to -1, the kernel fails to initialize a0 with -ENOSYS and subsequently fails to return the error code of the failed syscall to userspace. For example, it will break strace syscall tampering.
--- arch/riscv/kernel/traps.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/riscv/kernel/traps.c +1 -2
@@ -311,6 +311,7 @@ asmlinkage __visible __trap_section void do_trap_ecall_u(struct pt_regs *regs) regs->epc +=4 ; regs->orig_a0 = regs->a0; + regs->a0 = -ENOSYS ;riscv_v_vstate_discard (regs);
@@ -318,8 +319,6 @@ asmlinkage __visible __trap_section void do_trap_ecall_u(struct pt_regs *regs)if (syscall >=0 && syscall < NR_syscalls)syscall_handler (regs, syscall); -else if (syscall !=-1 ) - regs->a0 = -ENOSYS ;syscall_exit_to_user_mode (regs); }else {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 225/341 dm suspend: return -ERESTARTSYS instead of -EINTR
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 1e1fd567d32fcf7544c6e09e0e5bc6c650da6e23 ]
This commit changes device mapper, so that it returns -ERESTARTSYS instead of -EINTR when it is interrupted by a signal (so that the ioctl can be restarted).
The manpage signal(7) says that the ioctl function should be restarted if the signal was handled with SA_RESTART.
--- drivers/md/dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm.c +2 -2
@@ -2531,7 +2531,7 @@ static int dm_wait_for_bios_completion(struct mapped_device *md, unsigned int tabreak ;if (signal_pending_state (task_state, current)) { - r = -EINTR ; + r = -ERESTARTSYS ;break ; }
@@ -2556,7 +2556,7 @@ static int dm_wait_for_completion(struct mapped_device *md, unsigned int task_stbreak ;if (signal_pending_state (task_state, current)) { - r = -EINTR ; + r = -ERESTARTSYS ;break ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 226/341 mm: fix endless reclaim on machines with unaccepted memory
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kirill A. Shutemov <[email protected]>
[ Upstream commit 807174a93d24c456503692dc3f5af322ee0b640a ]
Unaccepted memory is considered unusable free memory, which is not counted as free on the zone watermark check. This causes get_page_from_freelist() to accept more memory to hit the high watermark, but it creates problems in the reclaim path.
The reclaim path encounters a failed zone watermark check and attempts to reclaim memory. This is usually successful, but if there is little or no reclaimable memory, it can result in endless reclaim with little to no progress. This can occur early in the boot process, just after start of the init process when the only reclaimable memory is the page cache of the init executable and its libraries.
Make unaccepted memory free from watermark check point of view. This way unaccepted memory will never be the trigger of memory reclaim. Accept more memory in the get_page_from_freelist() if needed.
--- mm/page_alloc.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-)
mm/page_alloc.c +20 -22
@@ -302,7 +302,7 @@ EXPORT_SYMBOL(nr_online_nodes);static bool page_contains_unaccepted (struct page *page,unsigned int order);static void accept_page (struct page *page,unsigned int order); -static bool try_to_accept_memory (struct zone *zone,unsigned int order); +static bool cond_accept_memory (struct zone *zone,unsigned int order);static inline bool has_unaccepted_memory (void );static bool __free_unaccepted (struct page *page);
@@ -2830,9 +2830,6 @@ static inline long __zone_watermark_unusable_free(struct zone *z,if (!(alloc_flags &ALLOC_CMA )) unusable_free +=zone_page_state (z,NR_FREE_CMA_PAGES );#endif -#ifdef CONFIG_UNACCEPTED_MEMORY - unusable_free +=zone_page_state (z,NR_UNACCEPTED ); -#endif return unusable_free; }
@@ -3126,16 +3123,16 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, } } +cond_accept_memory (zone, order); + mark =wmark_pages (zone, alloc_flags &ALLOC_WMARK_MASK );if (!zone_watermark_fast (zone, order, mark, ac->highest_zoneidx, alloc_flags, gfp_mask)) {int ret; -if (has_unaccepted_memory ()) { -if (try_to_accept_memory (zone, order)) - goto try_this_zone; - } +if (cond_accept_memory (zone, order)) + goto try_this_zone;#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT /*
@@ -3189,10 +3186,8 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,return page; }else { -if (has_unaccepted_memory ()) { -if (try_to_accept_memory (zone, order)) - goto try_this_zone; - } +if (cond_accept_memory (zone, order)) + goto try_this_zone;#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT /* Try again if zone has deferred pages */
@@ -6619,9 +6614,6 @@ static bool try_to_accept_memory_one(struct zone *zone)struct page *page;bool last; -if (list_empty (&zone->unaccepted_pages)) -return false; -spin_lock_irqsave (&zone->lock, flags); page =list_first_entry_or_null (&zone->unaccepted_pages, struct page, lru);
@@ -6647,23 +6639,29 @@ static bool try_to_accept_memory_one(struct zone *zone)return true; } -static bool try_to_accept_memory (struct zone *zone,unsigned int order) +static bool cond_accept_memory (struct zone *zone,unsigned int order) {long to_accept; -int ret = false; +bool ret = false; + +if (!has_unaccepted_memory ()) +return false; + +if (list_empty (&zone->unaccepted_pages)) +return false;/* How much to accept to get to high watermark? */ to_accept =high_wmark_pages (zone) - (zone_page_state (zone,NR_FREE_PAGES ) - -__zone_watermark_unusable_free (zone, order,0 )); +__zone_watermark_unusable_free (zone, order,0 ) - +zone_page_state (zone,NR_UNACCEPTED )); -/* Accept at least one page */ -do { +while (to_accept >0 ) {if (!try_to_accept_memory_one (zone))break ; ret = true; to_accept -=MAX_ORDER_NR_PAGES ; - }while (to_accept >0 ); + }return ret; }
@@ -6706,7 +6704,7 @@ static void accept_page(struct page *page, unsigned int order) { } -static bool try_to_accept_memory (struct zone *zone,unsigned int order) +static bool cond_accept_memory (struct zone *zone,unsigned int order) {return false; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 227/341 tools/testing/selftests/mm/run_vmtests.sh: lower the ptrace permissions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Itaru Kitayama <[email protected]>
[ Upstream commit 2ffc27b15b11c9584ac46335c2ed2248d2aa4137 ]
On Ubuntu and probably other distros, ptrace permissions are tightend a bit by default; i.e., /proc/sys/kernel/yama/ptrace_score is set to 1. This cases memfd_secret's ptrace attach test fails with a permission error. Set it to 0 piror to running the program.
Stable-dep-of: 7c5e8d212d7d ("selftests: memfd_secret: don't build memfd_secret test on unsupported arches")
--- tools/testing/selftests/mm/run_vmtests.sh | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/mm/run_vmtests.sh +1 -0
@@ -303,6 +303,7 @@ CATEGORY="hmm" run_test bash ./test_hmm.sh smoke # MADV_POPULATE_READ and MADV_POPULATE_WRITE tests CATEGORY="madv_populate" run_test ./madv_populate +echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope CATEGORY="memfd_secret" run_test ./memfd_secret # KSM KSM_MERGE_TIME_HUGE_PAGES test with size of 100
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 228/341 selftests/mm: log run_vmtests.sh results in TAP format
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryan Roberts <[email protected]>
[ Upstream commit a3c5cc5129ef55ac6c69f468e5ee6e4b0cd8179c ]
When running tests on a CI system (e.g. LAVA) it is useful to output test results in TAP (Test Anything Protocol) format so that the CI can parse the fine-grained results to show regressions. Many of the mm selftest binaries already output using the TAP format. And the kselftests runner (run_kselftest.sh) also uses the format. CI systems such as LAVA can already handle nested TAP reports. However, with the mm selftests we have 3 levels of nesting (run_kselftest.sh -> run_vmtests.sh -> individual test binaries) and the middle level did not previously support TAP, which breaks the parser.
Let's fix that by teaching run_vmtests.sh to output using the TAP format. Ideally this would be opt-in via a command line argument to avoid the possibility of breaking anyone's existing scripts that might scrape the output. However, it is not possible to pass arguments to tests invoked via run_kselftest.sh. So I've implemented an opt-out option (-n), which will revert to the existing output format.
Future changes to this file should be aware of 2 new conventions:
- output that is part of the TAP reporting is piped through tap_output
- general output is piped through tap_prefix
Stable-dep-of: 7c5e8d212d7d ("selftests: memfd_secret: don't build memfd_secret test on unsupported arches")
--- tools/testing/selftests/mm/run_vmtests.sh | 51 +++++++++++++++++------ 1 file changed, 39 insertions(+), 12 deletions(-)
tools/testing/selftests/mm/run_vmtests.sh +39 -12
@@ -5,6 +5,7 @@ # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 +count_total=0 count_pass=0 count_fail=0 count_skip=0
@@ -17,6 +18,7 @@ usage: ${BASH_SOURCE[0]:-$0} [ options ] -a: run all tests, including extra ones -t: specify specific categories to tests to run -h: display this message + -n: disable TAP output The default behavior is to run required tests only. If -a is specified, will run all tests.
@@ -75,12 +77,14 @@ EOF } RUN_ALL=false +TAP_PREFIX="# " -while getopts "aht:" OPT; do +while getopts "aht:n" OPT; do case ${OPT} in "a") RUN_ALL=true ;; "h") usage ;; "t") VM_SELFTEST_ITEMS=${OPTARG} ;; + "n") TAP_PREFIX= ;; esac done shift $((OPTIND -1))
@@ -182,30 +186,52 @@ fi VADDR64=0 echo "$ARCH64STR" | grep "$ARCH" &>/dev/null && VADDR64=1 +tap_prefix() { + sed -e "s/^/${TAP_PREFIX}/" +} + +tap_output() { + if [[ ! -z "$TAP_PREFIX" ]]; then + read str + echo $str + fi +} + +pretty_name() { + echo "$*" | sed -e 's/^\(bash \)\?\.\///' +} + # Usage: run_test [test binary] [arbitrary test arguments...] run_test() { if test_selected ${CATEGORY}; then + local test=$(pretty_name "$*") local title="running $*" local sep=$(echo -n "$title" | tr "[:graph:][:space:]" -) - printf "%s\n%s\n%s\n" "$sep" "$title" "$sep" + printf "%s\n%s\n%s\n" "$sep" "$title" "$sep" | tap_prefix - "$@" - local ret=$? + ("$@" 2>&1) | tap_prefix + local ret=${PIPESTATUS[0]} + count_total=$(( count_total + 1 )) if [ $ret -eq 0 ]; then count_pass=$(( count_pass + 1 )) - echo "[PASS]" + echo "[PASS]" | tap_prefix + echo "ok ${count_total} ${test}" | tap_output elif [ $ret -eq $ksft_skip ]; then count_skip=$(( count_skip + 1 )) - echo "[SKIP]" + echo "[SKIP]" | tap_prefix + echo "ok ${count_total} ${test} # SKIP" | tap_output exitcode=$ksft_skip else count_fail=$(( count_fail + 1 )) - echo "[FAIL]" + echo "[FAIL]" | tap_prefix + echo "not ok ${count_total} ${test} # exit=$ret" | tap_output exitcode=1 fi fi # test_selected } +echo "TAP version 13" | tap_output + CATEGORY="hugetlb" run_test ./hugepage-mmap shmmax=$(cat /proc/sys/kernel/shmmax)
@@ -222,9 +248,9 @@ CATEGORY="hugetlb" run_test ./hugepage-vmemmap CATEGORY="hugetlb" run_test ./hugetlb-madvise if test_selected "hugetlb"; then - echo "NOTE: These hugetlb tests provide minimal coverage. Use" - echo " https://github.com/libhugetlbfs/libhugetlbfs.git for" - echo " hugetlb regression testing." + echo "NOTE: These hugetlb tests provide minimal coverage. Use" | tap_prefix + echo " https://github.com/libhugetlbfs/libhugetlbfs.git for" | tap_prefix + echo " hugetlb regression testing." | tap_prefix fi CATEGORY="mmap" run_test ./map_fixed_noreplace
@@ -303,7 +329,7 @@ CATEGORY="hmm" run_test bash ./test_hmm.sh smoke # MADV_POPULATE_READ and MADV_POPULATE_WRITE tests CATEGORY="madv_populate" run_test ./madv_populate -echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope +(echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope 2>&1) | tap_prefix CATEGORY="memfd_secret" run_test ./memfd_secret # KSM KSM_MERGE_TIME_HUGE_PAGES test with size of 100
@@ -358,6 +384,7 @@ CATEGORY="mkdirty" run_test ./mkdirty CATEGORY="mdwe" run_test ./mdwe_test -echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}" +echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}" | tap_prefix +echo "1..${count_total}" | tap_output exit $exitcode
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 229/341 selftests: memfd_secret: dont build memfd_secret test on unsupported arches
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
[ Upstream commit 7c5e8d212d7d81991a580e7de3904ea213d9a852 ]
[1] mentions that memfd_secret is only supported on arm64, riscv, x86 and x86_64 for now. It doesn't support other architectures. I found the build error on arm and decided to send the fix as it was creating noise on KernelCI:
memfd_secret.c: In function 'memfd_secret':
memfd_secret.c:42:24: error: '__NR_memfd_secret' undeclared (first use in this function); did you mean 'memfd_secret'?
42 | return syscall(__NR_memfd_secret, flags);
| ^~~~~~~~~~~~~~~~~
| memfd_secretHence I'm adding condition that memfd_secret should only be compiled on supported architectures.
Also check in run_vmtests script if memfd_secret binary is present before executing it.
--- tools/testing/selftests/mm/Makefile | 2 ++ tools/testing/selftests/mm/run_vmtests.sh | 3 +++ 2 files changed, 5 insertions(+)
tools/testing/selftests/mm/Makefile +2 -0
@@ -51,7 +51,9 @@ TEST_GEN_FILES += madv_populate TEST_GEN_FILES += map_fixed_noreplace TEST_GEN_FILES += map_hugetlb TEST_GEN_FILES += map_populate +ifneq (,$(filter $(ARCH),arm64 riscv riscv64 x86 x86_64)) TEST_GEN_FILES += memfd_secret +endif TEST_GEN_FILES += migration TEST_GEN_FILES += mkdirty TEST_GEN_FILES += mlock-random-test
tools/testing/selftests/mm/run_vmtests.sh +3 -0
@@ -329,8 +329,11 @@ CATEGORY="hmm" run_test bash ./test_hmm.sh smoke # MADV_POPULATE_READ and MADV_POPULATE_WRITE tests CATEGORY="madv_populate" run_test ./madv_populate +if [ -x ./memfd_secret ] +then (echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope 2>&1) | tap_prefix CATEGORY="memfd_secret" run_test ./memfd_secret +fi # KSM KSM_MERGE_TIME_HUGE_PAGES test with size of 100 CATEGORY="ksm" run_test ./ksm_tests -H -s 100
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 230/341 change alloc_pages name in dma_map_ops to avoid name conflicts
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
[ Upstream commit 8a2f11878771da65b8ac135c73b47dae13afbd62 ]
After redefining alloc_pages, all uses of that name are being replaced. Change the conflicting names to prevent preprocessor from replacing them when it's not intended.
Stable-dep-of: 61ebe5a747da ("mm/vmalloc: fix page mapping if vm_area_alloc_pages() with high order fallback to order 0")
--- arch/alpha/kernel/pci_iommu.c | 2 +- arch/mips/jazz/jazzdma.c | 2 +- arch/powerpc/kernel/dma-iommu.c | 2 +- arch/powerpc/platforms/ps3/system-bus.c | 4 ++-- arch/powerpc/platforms/pseries/vio.c | 2 +- arch/x86/kernel/amd_gart_64.c | 2 +- drivers/iommu/dma-iommu.c | 2 +- drivers/parisc/ccio-dma.c | 2 +- drivers/parisc/sba_iommu.c | 2 +- drivers/xen/grant-dma-ops.c | 2 +- drivers/xen/swiotlb-xen.c | 2 +- include/linux/dma-map-ops.h | 2 +- kernel/dma/mapping.c | 4 ++-- 13 files changed, 15 insertions(+), 15 deletions(-)
arch/alpha/kernel/pci_iommu.c +1 -1
@@ -929,7 +929,7 @@ const struct dma_map_ops alpha_pci_ops = { .dma_supported = alpha_pci_supported, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages, };EXPORT_SYMBOL (alpha_pci_ops);
arch/mips/jazz/jazzdma.c +1 -1
@@ -617,7 +617,7 @@ const struct dma_map_ops jazz_dma_ops = { .sync_sg_for_device = jazz_dma_sync_sg_for_device, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages, };EXPORT_SYMBOL (jazz_dma_ops);
arch/powerpc/kernel/dma-iommu.c +1 -1
@@ -216,6 +216,6 @@ const struct dma_map_ops dma_iommu_ops = { .get_required_mask = dma_iommu_get_required_mask, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages, };
arch/powerpc/platforms/ps3/system-bus.c +2 -2
@@ -695,7 +695,7 @@ static const struct dma_map_ops ps3_sb_dma_ops = { .unmap_page = ps3_unmap_page, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages, };
@@ -709,7 +709,7 @@ static const struct dma_map_ops ps3_ioc0_dma_ops = { .unmap_page = ps3_unmap_page, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages, };
arch/powerpc/platforms/pseries/vio.c +1 -1
@@ -611,7 +611,7 @@ static const struct dma_map_ops vio_dma_mapping_ops = { .get_required_mask = dma_iommu_get_required_mask, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages, };
arch/x86/kernel/amd_gart_64.c +1 -1
@@ -676,7 +676,7 @@ static const struct dma_map_ops gart_dma_ops = { .get_sgtable = dma_common_get_sgtable, .dma_supported = dma_direct_supported, .get_required_mask = dma_direct_get_required_mask, - .alloc_pages = dma_direct_alloc_pages, + .alloc_pages_op = dma_direct_alloc_pages, .free_pages = dma_direct_free_pages, };
drivers/iommu/dma-iommu.c +1 -1
@@ -1614,7 +1614,7 @@ static const struct dma_map_ops iommu_dma_ops = { .flags = DMA_F_PCI_P2PDMA_SUPPORTED, .alloc = iommu_dma_alloc, .free = iommu_dma_free, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages, .alloc_noncontiguous = iommu_dma_alloc_noncontiguous, .free_noncontiguous = iommu_dma_free_noncontiguous,
drivers/parisc/ccio-dma.c +1 -1
@@ -1022,7 +1022,7 @@ static const struct dma_map_ops ccio_ops = { .map_sg = ccio_map_sg, .unmap_sg = ccio_unmap_sg, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages, };
drivers/parisc/sba_iommu.c +1 -1
@@ -1090,7 +1090,7 @@ static const struct dma_map_ops sba_ops = { .map_sg = sba_map_sg, .unmap_sg = sba_unmap_sg, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages, };
drivers/xen/grant-dma-ops.c +1 -1
@@ -282,7 +282,7 @@ static int xen_grant_dma_supported(struct device *dev, u64 mask)static const struct dma_map_ops xen_grant_dma_ops = { .alloc = xen_grant_dma_alloc, .free = xen_grant_dma_free, - .alloc_pages = xen_grant_dma_alloc_pages, + .alloc_pages_op = xen_grant_dma_alloc_pages, .free_pages = xen_grant_dma_free_pages, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable,
drivers/xen/swiotlb-xen.c +1 -1
@@ -403,7 +403,7 @@ const struct dma_map_ops xen_swiotlb_dma_ops = { .dma_supported = xen_swiotlb_dma_supported, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages, .max_mapping_size = swiotlb_max_mapping_size, };
include/linux/dma-map-ops.h +1 -1
@@ -28,7 +28,7 @@ struct dma_map_ops { unsigned long attrs);void (*free)(struct device *dev,size_t size,void *vaddr,dma_addr_t dma_handle,unsigned long attrs); -struct page *(*alloc_pages)(struct device *dev,size_t size, +struct page *(*alloc_pages_op)(struct device *dev,size_t size,dma_addr_t *dma_handle,enum dma_data_direction dir,gfp_t gfp); void (*free_pages)(struct device *dev, size_t size, struct page *vaddr,
kernel/dma/mapping.c +2 -2
@@ -570,9 +570,9 @@ static struct page *__dma_alloc_pages(struct device *dev, size_t size, size =PAGE_ALIGN (size);if (dma_alloc_direct (dev, ops))return dma_direct_alloc_pages (dev, size, dma_handle, dir, gfp); -if (!ops->alloc_pages) +if (!ops->alloc_pages_op)return NULL ; -return ops->alloc_pages (dev, size, dma_handle, dir, gfp); +return ops->alloc_pages_op (dev, size, dma_handle, dir, gfp); } struct page *dma_alloc_pages(struct device *dev, size_t size,
Signature · 1 line
2.43.0
Re: [PATCH 6.6 230/341] change alloc_pages name in dma_map_ops to avoid name conflicts
Hi Greg and Sasha,
Quoted 35 lines · Greg Kroah-Hartman
6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
[ Upstream commit
8a2f11878771da65b8ac135c73b47dae13afbd62]After redefining
alloc_pages, all uses of that name are being replaced. Change the conflicting names to prevent preprocessor from replacing them when it's not intended.Signed-off-by Suren Baghdasaryan <[email protected]>Tested-by Kees Cook <[email protected]>Cc Alexander Viro <[email protected]>Cc Alex Gaynor <[email protected]>Cc Alice Ryhl <[email protected]>Cc Andreas Hindborg <[email protected]>Cc Benno Lossin <[email protected]>Cc "Björn Roy Baron" <[email protected]>Cc Boqun Feng <[email protected]>Cc Christoph Lameter <[email protected]>Cc Dennis Zhou <[email protected]>Cc Gary Guo <[email protected]>Cc Kent Overstreet <[email protected]>Cc Miguel Ojeda <[email protected]>Cc Pasha Tatashin <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Tejun Heo <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wedson Almeida Filho <[email protected]>Signed-off-by Andrew Morton <[email protected]>Stable-dep-of:
61ebe5a747da("mm/vmalloc: fix page mapping ifvm_area_alloc_pages()with high order fallback to order 0")Signed-off-by Sasha Levin <[email protected]>
Quoted 15 lines
--- arch/alpha/kernel/pci_iommu.c | 2 +- arch/mips/jazz/jazzdma.c | 2 +- arch/powerpc/kernel/dma-iommu.c | 2 +- arch/powerpc/platforms/ps3/system-bus.c | 4 ++-- arch/powerpc/platforms/pseries/vio.c | 2 +- arch/x86/kernel/amd_gart_64.c | 2 +- drivers/iommu/dma-iommu.c | 2 +- drivers/parisc/ccio-dma.c | 2 +- drivers/parisc/sba_iommu.c | 2 +- drivers/xen/grant-dma-ops.c | 2 +- drivers/xen/swiotlb-xen.c | 2 +- include/linux/dma-map-ops.h | 2 +- kernel/dma/mapping.c | 4 ++-- 13 files changed, 15 insertions(+), 15 deletions(-)
This patch breaks the build for s390:
arch/s390/pci/pci_dma.c:724:10: error: 'const struct dma_map_ops' has no member named 'alloc_pages'; did you mean 'alloc_pages_op'?
724 | .alloc_pages = dma_common_alloc_pages,
| ^~~~~~~~~~~
| alloc_pages_opThis change happened after commit c76c067e488c ("s390/pci: Use dma-iommu layer") in mainline, which explains how it was missed for stable.
The fix seems simple:
arch/s390/pci/pci_dma.c +1 -1
@@ -721,7 +721,7 @@ const struct dma_map_ops s390_pci_dma_ops = { .unmap_page = s390_dma_unmap_pages, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages,/* dma_supported is unconditionally true without a callback */ };
but I think the better question is why this patch is even needed in the first place? It claims that it is a stable dependency of 61ebe5a747da but this patch does not even touch mm/vmalloc.c and 61ebe5a747da does not mention or touch anything with alloc_pages_op, so it seems like this change should just be reverted from 6.6?
Cheers,
Nathan
Re: [PATCH 6.6 230/341] change alloc_pages name in dma_map_ops to avoid name conflicts
Quoted 83 lines · Nathan Chancellor
Hi Greg and Sasha,
Quoted 35 lines · Greg Kroah-Hartman
6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
[ Upstream commit
8a2f11878771da65b8ac135c73b47dae13afbd62]After redefining
alloc_pages, all uses of that name are being replaced. Change the conflicting names to prevent preprocessor from replacing them when it's not intended.Signed-off-by Suren Baghdasaryan <[email protected]>Tested-by Kees Cook <[email protected]>Cc Alexander Viro <[email protected]>Cc Alex Gaynor <[email protected]>Cc Alice Ryhl <[email protected]>Cc Andreas Hindborg <[email protected]>Cc Benno Lossin <[email protected]>Cc "Björn Roy Baron" <[email protected]>Cc Boqun Feng <[email protected]>Cc Christoph Lameter <[email protected]>Cc Dennis Zhou <[email protected]>Cc Gary Guo <[email protected]>Cc Kent Overstreet <[email protected]>Cc Miguel Ojeda <[email protected]>Cc Pasha Tatashin <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Tejun Heo <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wedson Almeida Filho <[email protected]>Signed-off-by Andrew Morton <[email protected]>Stable-dep-of:
61ebe5a747da("mm/vmalloc: fix page mapping ifvm_area_alloc_pages()with high order fallback to order 0")Signed-off-by Sasha Levin <[email protected]>Quoted 15 lines
--- arch/alpha/kernel/pci_iommu.c | 2 +- arch/mips/jazz/jazzdma.c | 2 +- arch/powerpc/kernel/dma-iommu.c | 2 +- arch/powerpc/platforms/ps3/system-bus.c | 4 ++-- arch/powerpc/platforms/pseries/vio.c | 2 +- arch/x86/kernel/amd_gart_64.c | 2 +- drivers/iommu/dma-iommu.c | 2 +- drivers/parisc/ccio-dma.c | 2 +- drivers/parisc/sba_iommu.c | 2 +- drivers/xen/grant-dma-ops.c | 2 +- drivers/xen/swiotlb-xen.c | 2 +- include/linux/dma-map-ops.h | 2 +- kernel/dma/mapping.c | 4 ++-- 13 files changed, 15 insertions(+), 15 deletions(-)This patch breaks the build for s390:
arch/s390/pci/pci_dma.c:724:10: error: 'const structdma_map_ops' has no member named 'alloc_pages'; did you mean 'alloc_pages_op'?724 | .alloc_pages = dma_common_alloc_pages, | ^~~~~~~~~~~ | alloc_pages_opThis change happened after commit
c76c067e488c("s390/pci: Use dma-iommu layer") in mainline, which explains how it was missed for stable.The fix seems simple:
arch/s390/pci/pci_dma.c +1
-1@@ -721,7 +721,7 @@ const struct dma_map_ops s390_pci_dma_ops = { .unmap_page = s390_dma_unmap_pages, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages,/* dma_supported is unconditionally true without a callback */ };
Quoted 5 lines
but I think the better question is why this patch is even needed in the first place? It claims that it is a stable dependency of
61ebe5a747dabut this patch does not even touchmm/vmalloc.cand61ebe5a747dadoes not mention or touch anything withalloc_pages_op, so it seems like this change should just be reverted from 6.6?
Hmm, Nathan is right. I don't see any dependency between this patch and 61ebe5a747da. Maybe some other patch that uses .alloc_pages_op got backported and that caused a dependency but then that other patch should be changed to use .alloc_pages. I'm syncing stable 6.6 to check. Thanks for pointing this out Nathan!
Quoted 3 lines
Cheers,
Nathan
Re: [PATCH 6.6 230/341] change alloc_pages name in dma_map_ops to avoid name conflicts
Quoted 85 lines · Suren Baghdasaryan
Quoted 83 lines · Nathan Chancellor
Hi Greg and Sasha,
Quoted 35 lines · Greg Kroah-Hartman
6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
[ Upstream commit
8a2f11878771da65b8ac135c73b47dae13afbd62]After redefining
alloc_pages, all uses of that name are being replaced. Change the conflicting names to prevent preprocessor from replacing them when it's not intended.Signed-off-by Suren Baghdasaryan <[email protected]>Tested-by Kees Cook <[email protected]>Cc Alexander Viro <[email protected]>Cc Alex Gaynor <[email protected]>Cc Alice Ryhl <[email protected]>Cc Andreas Hindborg <[email protected]>Cc Benno Lossin <[email protected]>Cc "Björn Roy Baron" <[email protected]>Cc Boqun Feng <[email protected]>Cc Christoph Lameter <[email protected]>Cc Dennis Zhou <[email protected]>Cc Gary Guo <[email protected]>Cc Kent Overstreet <[email protected]>Cc Miguel Ojeda <[email protected]>Cc Pasha Tatashin <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Tejun Heo <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wedson Almeida Filho <[email protected]>Signed-off-by Andrew Morton <[email protected]>Stable-dep-of:
61ebe5a747da("mm/vmalloc: fix page mapping ifvm_area_alloc_pages()with high order fallback to order 0")Signed-off-by Sasha Levin <[email protected]>Quoted 15 lines
--- arch/alpha/kernel/pci_iommu.c | 2 +- arch/mips/jazz/jazzdma.c | 2 +- arch/powerpc/kernel/dma-iommu.c | 2 +- arch/powerpc/platforms/ps3/system-bus.c | 4 ++-- arch/powerpc/platforms/pseries/vio.c | 2 +- arch/x86/kernel/amd_gart_64.c | 2 +- drivers/iommu/dma-iommu.c | 2 +- drivers/parisc/ccio-dma.c | 2 +- drivers/parisc/sba_iommu.c | 2 +- drivers/xen/grant-dma-ops.c | 2 +- drivers/xen/swiotlb-xen.c | 2 +- include/linux/dma-map-ops.h | 2 +- kernel/dma/mapping.c | 4 ++-- 13 files changed, 15 insertions(+), 15 deletions(-)This patch breaks the build for s390:
arch/s390/pci/pci_dma.c:724:10: error: 'const structdma_map_ops' has no member named 'alloc_pages'; did you mean 'alloc_pages_op'?724 | .alloc_pages = dma_common_alloc_pages, | ^~~~~~~~~~~ | alloc_pages_opThis change happened after commit
c76c067e488c("s390/pci: Use dma-iommu layer") in mainline, which explains how it was missed for stable.The fix seems simple:
arch/s390/pci/pci_dma.c +1
-1@@ -721,7 +721,7 @@ const struct dma_map_ops s390_pci_dma_ops = { .unmap_page = s390_dma_unmap_pages, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages,/* dma_supported is unconditionally true without a callback */ };
Quoted 11 lines
Quoted 5 lines
but I think the better question is why this patch is even needed in the first place? It claims that it is a stable dependency of
61ebe5a747dabut this patch does not even touchmm/vmalloc.cand61ebe5a747dadoes not mention or touch anything withalloc_pages_op, so it seems like this change should just be reverted from 6.6?Hmm, Nathan is right. I don't see any dependency between this patch and
61ebe5a747da. Maybe some other patch that uses .alloc_pages_op got backported and that caused a dependency but then that other patch should be changed to use .alloc_pages. I'm syncing stable 6.6 to check. Thanks for pointing this out Nathan!
I reverted this patch in stable 6.6 and there is no code using alloc_pages_op. We should just drop this patch (983e6b2636f0099dbac1874c9e885bbe1cf2df05) from stable 6.6. Sorry for not noticing this in the first place.
Thanks,
Suren.
Quoted 5 lines
Quoted 5 lines
Cheers,
Nathan
Greg Kroah-Hartman
maintainerRe: [PATCH 6.6 230/341] change alloc_pages name in dma_map_ops to avoid name conflicts
Quoted 98 lines · Suren Baghdasaryan
Quoted 85 lines · Suren Baghdasaryan
Quoted 83 lines · Nathan Chancellor
Hi Greg and Sasha,
Quoted 35 lines · Greg Kroah-Hartman
6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
[ Upstream commit
8a2f11878771da65b8ac135c73b47dae13afbd62]After redefining
alloc_pages, all uses of that name are being replaced. Change the conflicting names to prevent preprocessor from replacing them when it's not intended.Signed-off-by Suren Baghdasaryan <[email protected]>Tested-by Kees Cook <[email protected]>Cc Alexander Viro <[email protected]>Cc Alex Gaynor <[email protected]>Cc Alice Ryhl <[email protected]>Cc Andreas Hindborg <[email protected]>Cc Benno Lossin <[email protected]>Cc "Björn Roy Baron" <[email protected]>Cc Boqun Feng <[email protected]>Cc Christoph Lameter <[email protected]>Cc Dennis Zhou <[email protected]>Cc Gary Guo <[email protected]>Cc Kent Overstreet <[email protected]>Cc Miguel Ojeda <[email protected]>Cc Pasha Tatashin <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Tejun Heo <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wedson Almeida Filho <[email protected]>Signed-off-by Andrew Morton <[email protected]>Stable-dep-of:
61ebe5a747da("mm/vmalloc: fix page mapping ifvm_area_alloc_pages()with high order fallback to order 0")Signed-off-by Sasha Levin <[email protected]>Quoted 15 lines
--- arch/alpha/kernel/pci_iommu.c | 2 +- arch/mips/jazz/jazzdma.c | 2 +- arch/powerpc/kernel/dma-iommu.c | 2 +- arch/powerpc/platforms/ps3/system-bus.c | 4 ++-- arch/powerpc/platforms/pseries/vio.c | 2 +- arch/x86/kernel/amd_gart_64.c | 2 +- drivers/iommu/dma-iommu.c | 2 +- drivers/parisc/ccio-dma.c | 2 +- drivers/parisc/sba_iommu.c | 2 +- drivers/xen/grant-dma-ops.c | 2 +- drivers/xen/swiotlb-xen.c | 2 +- include/linux/dma-map-ops.h | 2 +- kernel/dma/mapping.c | 4 ++-- 13 files changed, 15 insertions(+), 15 deletions(-)This patch breaks the build for s390:
arch/s390/pci/pci_dma.c:724:10: error: 'const structdma_map_ops' has no member named 'alloc_pages'; did you mean 'alloc_pages_op'?724 | .alloc_pages = dma_common_alloc_pages, | ^~~~~~~~~~~ | alloc_pages_opThis change happened after commit
c76c067e488c("s390/pci: Use dma-iommu layer") in mainline, which explains how it was missed for stable.The fix seems simple:
arch/s390/pci/pci_dma.c +1
-1@@ -721,7 +721,7 @@ const struct dma_map_ops s390_pci_dma_ops = { .unmap_page = s390_dma_unmap_pages, .mmap = dma_common_mmap, .get_sgtable = dma_common_get_sgtable, - .alloc_pages = dma_common_alloc_pages, + .alloc_pages_op = dma_common_alloc_pages, .free_pages = dma_common_free_pages,/* dma_supported is unconditionally true without a callback */ };Quoted 11 lines
Quoted 5 lines
but I think the better question is why this patch is even needed in the first place? It claims that it is a stable dependency of
61ebe5a747dabut this patch does not even touchmm/vmalloc.cand61ebe5a747dadoes not mention or touch anything withalloc_pages_op, so it seems like this change should just be reverted from 6.6?Hmm, Nathan is right. I don't see any dependency between this patch and
61ebe5a747da. Maybe some other patch that uses .alloc_pages_op got backported and that caused a dependency but then that other patch should be changed to use .alloc_pages. I'm syncing stable 6.6 to check. Thanks for pointing this out Nathan!
Quoted 4 lines
I reverted this patch in stable 6.6 and there is no code using
alloc_pages_op. We should just drop this patch (983e6b2636f0099dbac1874c9e885bbe1cf2df05) from stable 6.6. Sorry for not noticing this in the first place.
Now reverted, thanks!
greg k-h
Greg Kroah-Hartman
maintainerPATCH 231/341 mm/vmalloc: fix page mapping if vm_area_alloc_pages() with high order fallback to order 0
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hailong Liu <[email protected]>
[ Upstream commit 61ebe5a747da649057c37be1c37eb934b4af79ca ]
The __vmap_pages_range_noflush() assumes its argument pages** contains pages with the same page shift. However, since commit e9c3cda4d86e ("mm,
vmalloc: fix high order __GFP_NOFAIL allocations"), if gfp_flags includes __GFP_NOFAIL with high order in vm_area_alloc_pages() and page allocation failed for high order, the pages** may contain two different page shifts (high order and order-0). This could lead __vmap_pages_range_noflush() to perform incorrect mappings, potentially resulting in memory corruption.
Users might encounter this as follows (vmap_allow_huge = true, 2M is for PMD_SIZE):
kvmalloc(2M, __GFP_NOFAIL|GFP_X)
__vmalloc_node_range_noprof(vm_flags=VM_ALLOW_HUGE_VMAP)
vm_area_alloc_pages(order=9) ---> order-9 allocation failed and fallback to order-0
vmap_pages_range()
vmap_pages_range_noflush()
__vmap_pages_range_noflush(page_shift = 21) ----> wrong mapping happensWe can remove the fallback code because if a high-order allocation fails, __vmalloc_node_range_noprof() will retry with order-0. Therefore, it is unnecessary to fallback to order-0 here. Therefore, fix this by removing the fallback code.
--- mm/vmalloc.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
mm/vmalloc.c +2 -9
@@ -3079,15 +3079,8 @@ vm_area_alloc_pages(gfp_t gfp, int nid, page =alloc_pages (alloc_gfp, order); else page =alloc_pages_node (nid, alloc_gfp, order); -if (unlikely (!page)) { -if (!nofail) -break ; - -/* fall back to the zero order allocations */ - alloc_gfp |= __GFP_NOFAIL; - order =0 ; -continue ; - } +if (unlikely (!page)) +break ;/* * Higher order allocations must be able to be treated as
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 232/341 btrfs: replace sb::s_blocksize by fs_info::sectorsize
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit 4e00422ee62663e31e611d7de4d2c4aa3f8555f2 ]
The block size stored in the super block is used by subsystems outside of btrfs and it's a copy of fs_info::sectorsize. Unify that to always use our sectorsize, with the exception of mount where we first need to use fixed values (4K) until we read the super block and can set the sectorsize.
Replace all uses, in most cases it's fewer pointer indirections.
Stable-dep-of: 46a6e10a1ab1 ("btrfs: send: allow cloning non-aligned extent if it ends at i_size")
--- fs/btrfs/disk-io.c | 2 ++ fs/btrfs/extent_io.c | 4 ++-- fs/btrfs/inode.c | 2 +- fs/btrfs/ioctl.c | 2 +- fs/btrfs/reflink.c | 6 +++--- fs/btrfs/send.c | 2 +- fs/btrfs/super.c | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-)
fs/btrfs/disk-io.c +2 -0
@@ -2800,6 +2800,7 @@ static int init_mount_fs_info(struct btrfs_fs_info *fs_info, struct super_blockint ret; fs_info->sb = sb; +/* Temporary fixed values for block size until we read the superblock. */ sb->s_blocksize =BTRFS_BDEV_BLOCKSIZE ; sb->s_blocksize_bits =blksize_bits (BTRFS_BDEV_BLOCKSIZE );
@@ -3339,6 +3340,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device sb->s_bdi->ra_pages *=btrfs_super_num_devices (disk_super); sb->s_bdi->ra_pages =max (sb->s_bdi->ra_pages,SZ_4M /PAGE_SIZE ); +/* Update the values for the current filesystem. */ sb->s_blocksize = sectorsize; sb->s_blocksize_bits =blksize_bits (sectorsize);memcpy (&sb->s_uuid, fs_info->fs_devices->fsid,BTRFS_FSID_SIZE );
fs/btrfs/extent_io.c +2 -2
@@ -974,7 +974,7 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,int ret =0 ;size_t pg_offset =0 ;size_t iosize; -size_t blocksize = inode->i_sb->s_blocksize; +size_t blocksize = fs_info->sectorsize;struct extent_io_tree *tree = &BTRFS_I (inode)->io_tree; ret =set_page_extent_mapped (page);
@@ -2254,7 +2254,7 @@ int extent_invalidate_folio(struct extent_io_tree *tree,struct extent_state *cached_state =NULL ;u64 start =folio_pos (folio);u64 end = start +folio_size (folio) -1 ; -size_t blocksize = folio->mapping->host->i_sb->s_blocksize; +size_t blocksize =btrfs_sb (folio->mapping->host->i_sb)->sectorsize;/* This function is only called for the btree inode */ ASSERT (tree->owner ==IO_TREE_BTREE_INODE_IO );
fs/btrfs/inode.c +1 -1
@@ -8695,7 +8695,7 @@ static int btrfs_getattr(struct mnt_idmap *idmap,u64 delalloc_bytes;u64 inode_bytes;struct inode *inode =d_inode (path->dentry); -u32 blocksize = inode->i_sb->s_blocksize; +u32 blocksize =btrfs_sb (inode->i_sb)->sectorsize;u32 bi_flags =BTRFS_I (inode)->flags;u32 bi_ro_flags =BTRFS_I (inode)->ro_flags;
fs/btrfs/ioctl.c +1 -1
@@ -528,7 +528,7 @@ static noinline int btrfs_ioctl_fitrim(struct btrfs_fs_info *fs_info,* block group is in the logical address space, which can be any * sectorsize aligned bytenr in the range [0, U64_MAX]. */ -if (range.len < fs_info->sb->s_blocksize) +if (range.len < fs_info->sectorsize)return -EINVAL ; range.minlen =max (range.minlen, minlen);
fs/btrfs/reflink.c +3 -3
@@ -664,7 +664,7 @@ static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len, struct inode *dst, u64 dst_loff) {struct btrfs_fs_info *fs_info =BTRFS_I (src)->root->fs_info; -const u64 bs = fs_info->sb->s_blocksize; +const u64 bs = fs_info->sectorsize;int ret;/*
@@ -731,7 +731,7 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,int ret;int wb_ret;u64 len = olen; -u64 bs = fs_info->sb->s_blocksize; +u64 bs = fs_info->sectorsize;/* * VFS's generic_remap_file_range_prep() protects us from cloning the
@@ -797,7 +797,7 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in, {struct inode *inode_in =file_inode (file_in);struct inode *inode_out =file_inode (file_out); -u64 bs =BTRFS_I (inode_out)->root->fs_info->sb->s_blocksize; +u64 bs =BTRFS_I (inode_out)->root->fs_info->sectorsize;u64 wb_len;int ret;
fs/btrfs/send.c +1 -1
@@ -6159,7 +6159,7 @@ static int send_write_or_clone(struct send_ctx *sctx,int ret =0 ;u64 offset = key->offset;u64 end; -u64 bs = sctx->send_root->fs_info->sb->s_blocksize; +u64 bs = sctx->send_root->fs_info->sectorsize; end =min_t (u64,btrfs_file_extent_end (path), sctx->cur_inode_size);if (offset >= end)
fs/btrfs/super.c +1 -1
@@ -2124,7 +2124,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_bavail =0 ; buf->f_type =BTRFS_SUPER_MAGIC ; - buf->f_bsize = dentry->d_sb->s_blocksize; + buf->f_bsize = fs_info->sectorsize; buf->f_namelen =BTRFS_NAME_LEN ;/* We treat it as constant endianness (it doesn't matter _which_)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 233/341 btrfs: send: allow cloning non-aligned extent if it ends at i_size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 46a6e10a1ab16cc71d4a3cab73e79aabadd6b8ea ]
If we a find that an extent is shared but its end offset is not sector size aligned, then we don't clone it and issue write operations instead. This is because the reflink (remap_file_range) operation does not allow to clone unaligned ranges, except if the end offset of the range matches the i_size of the source and destination files (and the start offset is sector size aligned).
While this is not incorrect because send can only guarantee that a file has the same data in the source and destination snapshots, it's not optimal and generates confusion and surprising behaviour for users.
For example, running this test:
$ cat test.sh #!/bin/bash
DEV=/dev/sdi
MNT=/mnt/sdi
mkfs.btrfs -f $DEV
mount $DEV $MNT
# Use a file size not aligned to any possible sector size. file_size=$((1 * 1024 * 1024 + 5)) # 1MB + 5 bytes dd if=/dev/random of=$MNT/foo bs=$file_size count=1 cp --reflink=always $MNT/foo $MNT/bar
btrfs subvolume snapshot -r $MNT/ $MNT/snap
rm -f /tmp/send-test
btrfs send -f /tmp/send-test $MNT/snap
umount $MNT
mkfs.btrfs -f $DEV
mount $DEV $MNT
btrfs receive -vv -f /tmp/send-test $MNT
xfs_io -r -c "fiemap -v" $MNT/snap/bar
umount $MNT
Gives the following result:
(...)
mkfile o258-7-0
rename o258-7-0 -> bar
write bar - offset=0 length=49152
write bar - offset=49152 length=49152
write bar - offset=98304 length=49152
write bar - offset=147456 length=49152
write bar - offset=196608 length=49152
write bar - offset=245760 length=49152
write bar - offset=294912 length=49152
write bar - offset=344064 length=49152
write bar - offset=393216 length=49152
write bar - offset=442368 length=49152
write bar - offset=491520 length=49152
write bar - offset=540672 length=49152
write bar - offset=589824 length=49152
write bar - offset=638976 length=49152
write bar - offset=688128 length=49152
write bar - offset=737280 length=49152
write bar - offset=786432 length=49152
write bar - offset=835584 length=49152
write bar - offset=884736 length=49152
write bar - offset=933888 length=49152
write bar - offset=983040 length=49152
write bar - offset=1032192 length=16389
chown bar - uid=0, gid=0
chmod bar - mode=0644
utimes bar
utimes
BTRFS_IOC_SET_RECEIVED_SUBVOL uuid=06d640da-9ca1-604c-b87c-3375175a8eb3, stransid=7 /mnt/sdi/snap/bar:
EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS
0: [0..2055]: 26624..28679 2056 0x1
There's no clone operation to clone extents from the file foo into file bar and fiemap confirms there's no shared flag (0x2000).
So update send_write_or_clone() so that it proceeds with cloning if the source and destination ranges end at the i_size of the respective files.
After this changes the result of the test is:
(...)
mkfile o258-7-0
rename o258-7-0 -> bar
clone bar - source=foo source offset=0 offset=0 length=1048581
chown bar - uid=0, gid=0
chmod bar - mode=0644
utimes bar
utimes
BTRFS_IOC_SET_RECEIVED_SUBVOL uuid=582420f3-ea7d-564e-bbe5-ce440d622190, stransid=7 /mnt/sdi/snap/bar:
EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS
0: [0..2055]: 26624..28679 2056 0x2001
A test case for fstests will also follow up soon.
--- fs/btrfs/send.c | 52 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-)
fs/btrfs/send.c +39 -13
@@ -6160,25 +6160,51 @@ static int send_write_or_clone(struct send_ctx *sctx,u64 offset = key->offset;u64 end;u64 bs = sctx->send_root->fs_info->sectorsize; +struct btrfs_file_extent_item *ei; +u64 disk_byte; +u64 data_offset; +u64 num_bytes; +struct btrfs_inode_info info = {0 }; end =min_t (u64,btrfs_file_extent_end (path), sctx->cur_inode_size);if (offset >= end)return 0 ; -if (clone_root &&IS_ALIGNED (end, bs)) { -struct btrfs_file_extent_item *ei; -u64 disk_byte; -u64 data_offset; + num_bytes = end - offset; - ei =btrfs_item_ptr (path->nodes[0 ], path->slots[0 ], - struct btrfs_file_extent_item); - disk_byte =btrfs_file_extent_disk_bytenr (path->nodes[0 ], ei); - data_offset =btrfs_file_extent_offset (path->nodes[0 ], ei); - ret =clone_range (sctx, path, clone_root, disk_byte, - data_offset, offset, end - offset); - }else { - ret =send_extent_data (sctx, path, offset, end - offset); - } +if (!clone_root) + goto write_data; + +if (IS_ALIGNED (end, bs)) + goto clone_data; + +/* +* If the extent end is not aligned, we can clone if the extent ends at +* the i_size of the inode and the clone range ends at the i_size of the +* source inode, otherwise the clone operation fails with -EINVAL. +*/ +if (end != sctx->cur_inode_size) + goto write_data; + + ret =get_inode_info (clone_root->root, clone_root->ino, &info); +if (ret <0 ) +return ret; + +if (clone_root->offset + num_bytes == info.size) + goto clone_data; + +write_data: + ret =send_extent_data (sctx, path, offset, num_bytes); + sctx->cur_inode_next_write_offset = end; +return ret; + +clone_data: + ei =btrfs_item_ptr (path->nodes[0 ], path->slots[0 ], + struct btrfs_file_extent_item); + disk_byte =btrfs_file_extent_disk_bytenr (path->nodes[0 ], ei); + data_offset =btrfs_file_extent_offset (path->nodes[0 ], ei); + ret =clone_range (sctx, path, clone_root, disk_byte, data_offset, offset, + num_bytes); sctx->cur_inode_next_write_offset = end;return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 234/341 drm/amd/display: Adjust cursor position
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rodrigo Siqueira <[email protected]>
[ Upstream commit 56fb276d0244d430496f249335a44ae114dd5f54 ]
[why & how]
When the commit 9d84c7ef8a87 ("drm/amd/display: Correct cursor position on horizontal mirror") was introduced, it used the wrong calculation for the position copy for X. This commit uses the correct calculation for that based on the original patch.
--- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +1 -1
@@ -3614,7 +3614,7 @@ void dcn10_set_cursor_position(struct pipe_ctx *pipe_ctx) (int)hubp->curs_attr.width || pos_cpy.x <= (int)hubp->curs_attr.width + pipe_ctx->plane_state->src_rect.x) { - pos_cpy.x =2 * viewport_width - temp_x; + pos_cpy.x = temp_x + viewport_width; } } }else {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 235/341 drm/amd/display: Enable otg synchronization logic for DCN321
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Loan Chen <[email protected]>
[ Upstream commit 0dbb81d44108a2a1004e5b485ef3fca5bc078424 ]
[Why]
Tiled display cannot synchronize properly after S3. The fix for commit 5f0c74915815 ("drm/amd/display: Fix for otg synchronization logic") is not enable in DCN321, which causes the otg is excluded from synchronization.
[How]
Enable otg synchronization logic in dcn321.
--- drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c +3 -0
@@ -1756,6 +1756,9 @@ static bool dcn321_resource_construct( dc->caps.color.mpc.ogam_rom_caps.hlg =0 ; dc->caps.color.mpc.ocsc =1 ; +/* Use pipe context based otg sync logic */ + dc->config.use_pipe_ctx_sync_logic = true; + dc->config.dc_mode_clk_limit_support = true;/* read VBIOS LTTPR caps */ {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 236/341 drm/amd/display: fix cursor offset on rotation 180
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Melissa Wen <[email protected]>
[ Upstream commit 737222cebecbdbcdde2b69475c52bcb9ecfeb830 ]
[why & how]
Cursor gets clipped off in the middle of the screen with hw rotation 180. Fix a miscalculation of cursor offset when it's placed near the edges in the pipe split case.
Cursor bugs with hw rotation were reported on AMD issue tracker:
https://gitlab.freedesktop.org/drm/amd/-/issues/2247
The issues on rotation 270 was fixed by:
https://lore.kernel.org/amd-gfx/[email protected]/
that partially addressed the rotation 180 too. So, this patch is the final bits for rotation 180.
--- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +1 -1
@@ -3521,7 +3521,7 @@ void dcn10_set_cursor_position(struct pipe_ctx *pipe_ctx) (int)hubp->curs_attr.width || pos_cpy.x <= (int)hubp->curs_attr.width + pipe_ctx->plane_state->src_rect.x) { - pos_cpy.x = temp_x + viewport_width; + pos_cpy.x =2 * viewport_width - temp_x; } } }else {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 237/341 drm/amd/amdgpu: command submission parser for JPEG
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David (Ming Qiang) Wu <[email protected]>
[ Upstream commit 470516c2925493594a690bc4d05b1f4471d9f996 ]
Add JPEG IB command parser to ensure registers in the command are within the JPEG IP block.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 ++ drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c | 61 +++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.h | 6 +++ drivers/gpu/drm/amd/amdgpu/soc15d.h | 6 +++ 4 files changed, 75 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +3 -0
@@ -1057,6 +1057,9 @@ static int amdgpu_cs_patch_ibs(struct amdgpu_cs_parser *p, r =amdgpu_ring_parse_cs (ring, p, job, ib);if (r)return r; + +if (ib->sa_bo) + ib->gpu_addr =amdgpu_sa_bo_gpu_addr (ib->sa_bo); }else { ib->ptr = (uint32_t *)kptr; r =amdgpu_ring_patch_cs_in_place (ring, p, job, ib);
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c +60 -1
82 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.h +6 -0
@@ -46,6 +46,12 @@#define JRBC_DEC_EXTERNAL_REG_WRITE_ADDR 0x18000 +#define JPEG_REG_RANGE_START 0x4000 +#define JPEG_REG_RANGE_END 0x41c2 +extern const struct amdgpu_ip_block_version jpeg_v4_0_3_ip_block; +int jpeg_v4_0_3_dec_ring_parse_cs (struct amdgpu_cs_parser *parser, +struct amdgpu_job *job, +struct amdgpu_ib *ib);#endif /* __JPEG_V4_0_3_H__ */
drivers/gpu/drm/amd/amdgpu/soc15d.h +6 -0
@@ -76,6 +76,12 @@ ((cond & 0xF) << 24) | \ ((type & 0xF) << 28)) +#define CP_PACKETJ_NOP 0x60000000 +#define CP_PACKETJ_GET_REG (x) ((x) & 0x3FFFF) +#define CP_PACKETJ_GET_RES (x) (((x) >> 18) & 0x3F) +#define CP_PACKETJ_GET_COND (x) (((x) >> 24) & 0xF) +#define CP_PACKETJ_GET_TYPE (x) (((x) >> 28) & 0xF) +/* Packet 3 types */ #define PACKET3_NOP 0x10#define PACKET3_SET_BASE 0x11
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 238/341 platform/surface: aggregator: Fix warning when controller is destroyed in probe
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maximilian Luz <[email protected]>
[ Upstream commit bc923d594db21bee0ead128eb4bb78f7e77467a4 ]
There is a small window in ssam_serial_hub_probe() where the controller is initialized but has not been started yet. Specifically, between ssam_controller_init() and ssam_controller_start(). Any failure in this window, for example caused by a failure of serdev_device_open(), currently results in an incorrect warning being emitted.
In particular, any failure in this window results in the controller being destroyed via ssam_controller_destroy(). This function checks the state of the controller and, in an attempt to validate that the controller has been cleanly shut down before we try and deallocate any resources, emits a warning if that state is not SSAM_CONTROLLER_STOPPED.
However, since we have only just initialized the controller and have not yet started it, its state is SSAM_CONTROLLER_INITIALIZED. Note that this is the only point at which the controller has this state, as it will change after we start the controller with ssam_controller_start() and never revert back. Further, at this point no communication has taken place and the sender and receiver threads have not been started yet (and we may not even have an open serdev device either).
Therefore, it is perfectly safe to call ssam_controller_destroy() with a state of SSAM_CONTROLLER_INITIALIZED. This, however, means that the warning currently being emitted is incorrect. Fix it by extending the check.
--- drivers/platform/surface/aggregator/controller.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/surface/aggregator/controller.c +2 -1
@@ -1354,7 +1354,8 @@ void ssam_controller_destroy(struct ssam_controller *ctrl)if (ctrl->state ==SSAM_CONTROLLER_UNINITIALIZED )return ; -WARN_ON (ctrl->state !=SSAM_CONTROLLER_STOPPED ); +WARN_ON (ctrl->state !=SSAM_CONTROLLER_STOPPED && + ctrl->state !=SSAM_CONTROLLER_INITIALIZED );/* * Note: New events could still have been received after the previous
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 239/341 ALSA: hda/tas2781: Use correct endian conversion
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 829e2a23121fb36ee30ea5145c2a85199f68e2c8 ]
The data conversion is done rather by a wrong function. We convert to BE32, not from BE32. Although the end result must be same, this was complained by the compiler.
Fix the code again and align with another similar function tas2563_apply_calib() that does already right.
--- sound/pci/hda/tas2781_hda_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +2 -2
@@ -433,8 +433,8 @@ static void tas2781_apply_calib(struct tasdevice_priv *tas_priv)for (i =0 ; i < tas_priv->ndev; i++) {for (j =0 ; j <CALIB_MAX ; j++) { - data =get_unaligned_be32 ( - &tas_priv->cali_data.data[offset]); + data =cpu_to_be32 ( + *(uint32_t *)&tas_priv->cali_data.data[offset]); rc =tasdevice_dev_bulk_write (tas_priv, i,TASDEVICE_REG (0 , page_array[j], rgno_array[j]), (unsigned char *)&data,4 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 240/341 drm/amdkfd: reserve the BO before validating it
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lang Yu <[email protected]>
[ Upstream commit 0c93bd49576677ae1a18817d5ec000ef031d5187 ]
Fix a warning.
v2: Avoid unmapping attachment repeatedly when ERESTARTSYS.
v3: Lock the BO before accessing ttm->sg to avoid race conditions.(Felix)
[ 41.708711] WARNING: CPU: 0 PID: 1463 at drivers/gpu/drm/ttm/ttm_bo.c:846 ttm_bo_validate+0x146/0x1b0 [ttm] [ 41.708989] Call Trace: [ 41.708992] <TASK> [ 41.708996] ? show_regs+0x6c/0x80 [ 41.709000] ? ttm_bo_validate+0x146/0x1b0 [ttm] [ 41.709008] ? __warn+0x93/0x190 [ 41.709014] ? ttm_bo_validate+0x146/0x1b0 [ttm] [ 41.709024] ? report_bug+0x1f9/0x210 [ 41.709035] ? handle_bug+0x46/0x80 [ 41.709041] ? exc_invalid_op+0x1d/0x80 [ 41.709048] ? asm_exc_invalid_op+0x1f/0x30 [ 41.709057] ? amdgpu_amdkfd_gpuvm_dmaunmap_mem+0x2c/0x80 [amdgpu] [ 41.709185] ? ttm_bo_validate+0x146/0x1b0 [ttm] [ 41.709197] ? amdgpu_amdkfd_gpuvm_dmaunmap_mem+0x2c/0x80 [amdgpu] [ 41.709337] ? srso_alias_return_thunk+0x5/0x7f [ 41.709346] kfd_mem_dmaunmap_attachment+0x9e/0x1e0 [amdgpu] [ 41.709467] amdgpu_amdkfd_gpuvm_dmaunmap_mem+0x56/0x80 [amdgpu] [ 41.709586] kfd_ioctl_unmap_memory_from_gpu+0x1b7/0x300 [amdgpu] [ 41.709710] kfd_ioctl+0x1ec/0x650 [amdgpu] [ 41.709822] ? __pfx_kfd_ioctl_unmap_memory_from_gpu+0x10/0x10 [amdgpu] [ 41.709945] ? srso_alias_return_thunk+0x5/0x7f [ 41.709949] ? tomoyo_file_ioctl+0x20/0x30 [ 41.709959] __x64_sys_ioctl+0x9c/0xd0 [ 41.709967] do_syscall_64+0x3f/0x90 [ 41.709973] entry_SYSCALL_64_after_hwframe+0x6e/0xd8
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 20 ++++++++++++++++--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 +++- 3 files changed, 21 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +1 -1
@@ -303,7 +303,7 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(struct amdgpu_device *adev, struct kgd_mem *mem, void *drm_priv);int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu (struct amdgpu_device *adev,struct kgd_mem *mem,void *drm_priv); -void amdgpu_amdkfd_gpuvm_dmaunmap_mem (struct kgd_mem *mem,void *drm_priv); +int amdgpu_amdkfd_gpuvm_dmaunmap_mem (struct kgd_mem *mem,void *drm_priv);int amdgpu_amdkfd_gpuvm_sync_memory (struct amdgpu_device *adev,struct kgd_mem *mem,bool intr); int amdgpu_amdkfd_gpuvm_map_gtt_bo_to_kernel(struct kgd_mem *mem,
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +17 -3
@@ -2038,21 +2038,35 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(return ret; } -void amdgpu_amdkfd_gpuvm_dmaunmap_mem (struct kgd_mem *mem,void *drm_priv) +int amdgpu_amdkfd_gpuvm_dmaunmap_mem (struct kgd_mem *mem,void *drm_priv) {struct kfd_mem_attachment *entry;struct amdgpu_vm *vm; +int ret; vm =drm_priv_to_vm (drm_priv);mutex_lock (&mem->lock); + ret =amdgpu_bo_reserve (mem->bo, true); +if (ret) + goto out; +list_for_each_entry (entry, &mem->attachments, list) { -if (entry->bo_va->base.vm == vm) -kfd_mem_dmaunmap_attachment (mem, entry); +if (entry->bo_va->base.vm != vm) +continue ; +if (entry->bo_va->base.bo->tbo.ttm && + !entry->bo_va->base.bo->tbo.ttm->sg) +continue ; + +kfd_mem_dmaunmap_attachment (mem, entry); } +amdgpu_bo_unreserve (mem->bo); +out:mutex_unlock (&mem->lock); + +return ret; } int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +3 -1
@@ -1442,7 +1442,9 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,kfd_flush_tlb (peer_pdd,TLB_FLUSH_HEAVYWEIGHT );/* Remove dma mapping after tlb flush to avoid IO_PAGE_FAULT */ -amdgpu_amdkfd_gpuvm_dmaunmap_mem (mem, peer_pdd->drm_priv); + err =amdgpu_amdkfd_gpuvm_dmaunmap_mem (mem, peer_pdd->drm_priv); +if (err) + goto sync_memory_failed; }mutex_unlock (&p->mutex);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 241/341 Bluetooth: hci_core: Fix LE quote calculation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 932021a11805b9da4bd6abf66fe233cccd59fe0e ]
Function hci_sched_le needs to update the respective counter variable inplace other the likes of hci_quote_sent would attempt to use the possible outdated value of conn->{le_cnt,acl_cnt}.
--- net/bluetooth/hci_core.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
net/bluetooth/hci_core.c +7 -12
@@ -3637,19 +3637,19 @@ static void hci_sched_le(struct hci_dev *hdev) {struct hci_chan *chan;struct sk_buff *skb; -int quote, cnt, tmp; +int quote, *cnt, tmp;BT_DBG ("%s" , hdev->name);if (!hci_conn_num (hdev,LE_LINK ))return ; - cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt; + cnt = hdev->le_pkts ? &hdev->le_cnt : &hdev->acl_cnt; -__check_timeout (hdev, cnt,LE_LINK ); +__check_timeout (hdev, *cnt,LE_LINK ); - tmp = cnt; -while (cnt && (chan =hci_chan_sent (hdev,LE_LINK , "e))) { + tmp = *cnt; +while (*cnt && (chan =hci_chan_sent (hdev,LE_LINK , "e))) {u32 priority = (skb_peek (&chan->data_q))->priority;while (quote-- && (skb =skb_peek (&chan->data_q))) { BT_DBG("chan %p skb %p len %d priority %u", chan, skb,
@@ -3664,7 +3664,7 @@ static void hci_sched_le(struct hci_dev *hdev)hci_send_frame (hdev, skb); hdev->le_last_tx = jiffies; - cnt--; + (*cnt)--; chan->sent++; chan->conn->sent++;
@@ -3674,12 +3674,7 @@ static void hci_sched_le(struct hci_dev *hdev) } } -if (hdev->le_pkts) - hdev->le_cnt = cnt; -else - hdev->acl_cnt = cnt; - -if (cnt != tmp) +if (*cnt != tmp)hci_prio_recalculate (hdev,LE_LINK ); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 242/341 Bluetooth: SMP: Fix assumption of Central always being Initiator
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 28cd47f75185c4818b0fb1b46f2f02faaba96376 ]
SMP initiator role shall be considered the one that initiates the pairing procedure with SMP_CMD_PAIRING_REQ:
BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 3, Part H page 1557:
Figure 2.1: LE pairing phases
Note that by sending SMP_CMD_SECURITY_REQ it doesn't change the role to be Initiator.
--- net/bluetooth/smp.c | 144 ++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 72 deletions(-)
net/bluetooth/smp.c +72 -72
@@ -915,7 +915,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,* Confirms and the responder Enters the passkey. */ if (smp->method ==OVERLAP ) { -if (hcon->role ==HCI_ROLE_MASTER ) +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) smp->method =CFM_PASSKEY ;else smp->method =REQ_PASSKEY ;
@@ -965,7 +965,7 @@ static u8 smp_confirm(struct smp_chan *smp)smp_send_cmd (smp->conn,SMP_CMD_PAIRING_CONFIRM ,sizeof (cp), &cp); -if (conn->hcon->out) +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags))SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_CONFIRM );else SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_RANDOM );
@@ -981,7 +981,8 @@ static u8 smp_random(struct smp_chan *smp)int ret;bt_dev_dbg (conn->hcon->hdev,"conn %p %s" , conn, - conn->hcon->out ?"initiator" :"responder" ); +test_bit (SMP_FLAG_INITIATOR , &smp->flags) ?"initiator" : +"responder" ); ret = smp_c1(smp->tk, smp->rrnd, smp->preq, smp->prsp, hcon->init_addr_type, &hcon->init_addr,
@@ -995,7 +996,7 @@ static u8 smp_random(struct smp_chan *smp)return SMP_CONFIRM_FAILED ; } -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) {u8 stk[16 ];__le64 rand =0 ;__le16 ediv =0 ;
@@ -1257,14 +1258,15 @@ static void smp_distribute_keys(struct smp_chan *smp) rsp = (void *) &smp->prsp[1 ];/* The responder sends its keys first */ -if (hcon->out && (smp->remote_key_dist &KEY_DIST_MASK )) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags) && + (smp->remote_key_dist &KEY_DIST_MASK )) {smp_allow_key_dist (smp);return ; } req = (void *) &smp->preq[1 ]; -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) { keydist = &rsp->init_key_dist; *keydist &= req->init_key_dist; }else {
@@ -1433,7 +1435,7 @@ static int sc_mackey_and_ltk(struct smp_chan *smp, u8 mackey[16], u8 ltk[16])struct hci_conn *hcon = smp->conn->hcon;u8 *na, *nb, a[7 ], b[7 ]; -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) { na = smp->prnd; nb = smp->rrnd; }else {
@@ -1461,7 +1463,7 @@ static void sc_dhkey_check(struct smp_chan *smp) a[6 ] = hcon->init_addr_type; b[6 ] = hcon->resp_addr_type; -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) { local_addr = a; remote_addr = b;memcpy (io_cap, &smp->preq[1 ],3 );
@@ -1540,7 +1542,7 @@ static u8 sc_passkey_round(struct smp_chan *smp, u8 smp_op)/* The round is only complete when the initiator * receives pairing random. */ -if (!hcon->out) { +if (!test_bit (SMP_FLAG_INITIATOR , &smp->flags)) {smp_send_cmd (conn,SMP_CMD_PAIRING_RANDOM ,sizeof (smp->prnd), smp->prnd);if (smp->passkey_round ==20 )
@@ -1568,7 +1570,7 @@ static u8 sc_passkey_round(struct smp_chan *smp, u8 smp_op)SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_RANDOM ); -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) {smp_send_cmd (conn,SMP_CMD_PAIRING_RANDOM ,sizeof (smp->prnd), smp->prnd);return 0 ;
@@ -1579,7 +1581,7 @@ static u8 sc_passkey_round(struct smp_chan *smp, u8 smp_op)case SMP_CMD_PUBLIC_KEY :default :/* Initiating device starts the round */ -if (!hcon->out) +if (!test_bit (SMP_FLAG_INITIATOR , &smp->flags))return 0 ; bt_dev_dbg(hdev, "Starting passkey round %u",
@@ -1624,7 +1626,7 @@ static int sc_user_reply(struct smp_chan *smp, u16 mgmt_op, __le32 passkey) }/* Initiator sends DHKey check first */ -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) {sc_dhkey_check (smp);SMP_ALLOW_CMD (smp,SMP_CMD_DHKEY_CHECK ); }else if (test_and_clear_bit (SMP_FLAG_DHKEY_PENDING , &smp->flags)) {
@@ -1747,7 +1749,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)struct smp_cmd_pairing rsp, *req = (void *) skb->data;struct l2cap_chan *chan = conn->smp;struct hci_dev *hdev = conn->hcon->hdev; -struct smp_chan *smp; +struct smp_chan *smp = chan->data;u8 key_size, auth, sec_level;int ret;
@@ -1756,16 +1758,14 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)if (skb->len <sizeof (*req))return SMP_INVALID_PARAMS ; -if (conn->hcon->role !=HCI_ROLE_SLAVE ) +if (smp &&test_bit (SMP_FLAG_INITIATOR , &smp->flags))return SMP_CMD_NOTSUPP ; -if (!chan->data) +if (!smp) { smp =smp_chan_create (conn); -else - smp = chan->data; - -if (!smp) -return SMP_UNSPECIFIED ; +if (!smp) +return SMP_UNSPECIFIED ; + }/* We didn't start the pairing, so match remote */ auth = req->auth_req &AUTH_REQ_MASK (hdev);
@@ -1947,7 +1947,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)if (skb->len <sizeof (*rsp))return SMP_INVALID_PARAMS ; -if (conn->hcon->role !=HCI_ROLE_MASTER ) +if (!test_bit (SMP_FLAG_INITIATOR , &smp->flags))return SMP_CMD_NOTSUPP ;skb_pull (skb,sizeof (*rsp));
@@ -2042,7 +2042,7 @@ static u8 sc_check_confirm(struct smp_chan *smp)if (smp->method ==REQ_PASSKEY || smp->method ==DSP_PASSKEY )return sc_passkey_round (smp,SMP_CMD_PAIRING_CONFIRM ); -if (conn->hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) {smp_send_cmd (conn,SMP_CMD_PAIRING_RANDOM ,sizeof (smp->prnd), smp->prnd);SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_RANDOM );
@@ -2064,7 +2064,7 @@ static int fixup_sc_false_positive(struct smp_chan *smp)u8 auth;/* The issue is only observed when we're in responder role */ -if (hcon->out) +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags))return SMP_UNSPECIFIED ;if (hci_dev_test_flag (hdev,HCI_SC_ONLY )) {
@@ -2100,7 +2100,8 @@ static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb)struct hci_dev *hdev = hcon->hdev;bt_dev_dbg (hdev,"conn %p %s" , conn, - hcon->out ?"initiator" :"responder" ); +test_bit (SMP_FLAG_INITIATOR , &smp->flags) ?"initiator" : +"responder" );if (skb->len <sizeof (smp->pcnf))return SMP_INVALID_PARAMS ;
@@ -2122,7 +2123,7 @@ static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb)return ret; } -if (conn->hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) {smp_send_cmd (conn,SMP_CMD_PAIRING_RANDOM ,sizeof (smp->prnd), smp->prnd);SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_RANDOM );
@@ -2157,7 +2158,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)if (!test_bit (SMP_FLAG_SC , &smp->flags))return smp_random (smp); -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) { pkax = smp->local_pk; pkbx = smp->remote_pk; na = smp->prnd;
@@ -2170,7 +2171,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) }if (smp->method ==REQ_OOB ) { -if (!hcon->out) +if (!test_bit (SMP_FLAG_INITIATOR , &smp->flags))smp_send_cmd (conn,SMP_CMD_PAIRING_RANDOM ,sizeof (smp->prnd), smp->prnd);SMP_ALLOW_CMD (smp,SMP_CMD_DHKEY_CHECK );
@@ -2181,7 +2182,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)if (smp->method ==REQ_PASSKEY || smp->method ==DSP_PASSKEY )return sc_passkey_round (smp,SMP_CMD_PAIRING_RANDOM ); -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) {u8 cfm[16 ]; err = smp_f4(smp->tfm_cmac, smp->remote_pk, smp->local_pk,
@@ -2222,7 +2223,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)return SMP_UNSPECIFIED ;if (smp->method ==REQ_OOB ) { -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) {sc_dhkey_check (smp);SMP_ALLOW_CMD (smp,SMP_CMD_DHKEY_CHECK ); }
@@ -2296,10 +2297,27 @@ bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level,return false; } +static void smp_send_pairing_req (struct smp_chan *smp,__u8 auth) +{ +struct smp_cmd_pairing cp; + +if (smp->conn->hcon->type ==ACL_LINK ) +build_bredr_pairing_cmd (smp, &cp,NULL ); +else +build_pairing_cmd (smp->conn, &cp,NULL , auth); + + smp->preq[0 ] =SMP_CMD_PAIRING_REQ ; +memcpy (&smp->preq[1 ], &cp,sizeof (cp)); + +smp_send_cmd (smp->conn,SMP_CMD_PAIRING_REQ ,sizeof (cp), &cp); +SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_RSP ); + +set_bit (SMP_FLAG_INITIATOR , &smp->flags); +} +static u8 smp_cmd_security_req (struct l2cap_conn *conn,struct sk_buff *skb) {struct smp_cmd_security_req *rp = (void *) skb->data; -struct smp_cmd_pairing cp;struct hci_conn *hcon = conn->hcon;struct hci_dev *hdev = hcon->hdev;struct smp_chan *smp;
@@ -2348,16 +2366,20 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)skb_pull (skb,sizeof (*rp)); -memset (&cp,0 ,sizeof (cp)); -build_pairing_cmd (conn, &cp,NULL , auth); +smp_send_pairing_req (smp, auth); - smp->preq[0 ] =SMP_CMD_PAIRING_REQ ; -memcpy (&smp->preq[1 ], &cp,sizeof (cp)); +return 0 ; +} -smp_send_cmd (conn,SMP_CMD_PAIRING_REQ ,sizeof (cp), &cp); -SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_RSP ); +static void smp_send_security_req (struct smp_chan *smp,__u8 auth) +{ +struct smp_cmd_security_req cp; -return 0 ; + cp.auth_req = auth; +smp_send_cmd (smp->conn,SMP_CMD_SECURITY_REQ ,sizeof (cp), &cp); +SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_REQ ); + +clear_bit (SMP_FLAG_INITIATOR , &smp->flags); }int smp_conn_security (struct hci_conn *hcon,__u8 sec_level)
@@ -2428,23 +2450,11 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) authreq |=SMP_AUTH_MITM ; } -if (hcon->role ==HCI_ROLE_MASTER ) { -struct smp_cmd_pairing cp; - -build_pairing_cmd (conn, &cp,NULL , authreq); - smp->preq[0 ] =SMP_CMD_PAIRING_REQ ; -memcpy (&smp->preq[1 ], &cp,sizeof (cp)); - -smp_send_cmd (conn,SMP_CMD_PAIRING_REQ ,sizeof (cp), &cp); -SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_RSP ); - }else { -struct smp_cmd_security_req cp; - cp.auth_req = authreq; -smp_send_cmd (conn,SMP_CMD_SECURITY_REQ ,sizeof (cp), &cp); -SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_REQ ); - } +if (hcon->role ==HCI_ROLE_MASTER ) +smp_send_pairing_req (smp, authreq); +else +smp_send_security_req (smp, authreq); -set_bit (SMP_FLAG_INITIATOR , &smp->flags); ret =0 ; unlock:
@@ -2695,8 +2705,6 @@ static int smp_cmd_sign_info(struct l2cap_conn *conn, struct sk_buff *skb)static u8 sc_select_method (struct smp_chan *smp) { -struct l2cap_conn *conn = smp->conn; -struct hci_conn *hcon = conn->hcon;struct smp_cmd_pairing *local, *remote;u8 local_mitm, remote_mitm, local_io, remote_io, method;
@@ -2709,7 +2717,7 @@ static u8 sc_select_method(struct smp_chan *smp)* the "struct smp_cmd_pairing" from them we need to skip the * first byte which contains the opcode. */ -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) { local = (void *) &smp->preq[1 ]; remote = (void *) &smp->prsp[1 ]; }else {
@@ -2778,7 +2786,7 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)/* Non-initiating device sends its public key after receiving * the key from the initiating device. */ -if (!hcon->out) { +if (!test_bit (SMP_FLAG_INITIATOR , &smp->flags)) { err =sc_send_public_key (smp);if (err)return err;
@@ -2840,7 +2848,7 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb) }if (smp->method ==REQ_OOB ) { -if (hcon->out) +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags))smp_send_cmd (conn,SMP_CMD_PAIRING_RANDOM ,sizeof (smp->prnd), smp->prnd);
@@ -2849,7 +2857,7 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)return 0 ; } -if (hcon->out) +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags))SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_CONFIRM );if (smp->method ==REQ_PASSKEY ) {
@@ -2864,7 +2872,7 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)/* The Initiating device waits for the non-initiating device to * send the confirm value. */ -if (conn->hcon->out) +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags))return 0 ; err = smp_f4(smp->tfm_cmac, smp->local_pk, smp->remote_pk, smp->prnd,
@@ -2898,7 +2906,7 @@ static int smp_cmd_dhkey_check(struct l2cap_conn *conn, struct sk_buff *skb) a[6 ] = hcon->init_addr_type; b[6 ] = hcon->resp_addr_type; -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) { local_addr = a; remote_addr = b;memcpy (io_cap, &smp->prsp[1 ],3 );
@@ -2923,7 +2931,7 @@ static int smp_cmd_dhkey_check(struct l2cap_conn *conn, struct sk_buff *skb)if (crypto_memneq (check->e, e,16 ))return SMP_DHKEY_CHECK_FAILED ; -if (!hcon->out) { +if (!test_bit (SMP_FLAG_INITIATOR , &smp->flags)) {if (test_bit (SMP_FLAG_WAIT_USER , &smp->flags)) {set_bit (SMP_FLAG_DHKEY_PENDING , &smp->flags);return 0 ;
@@ -2935,7 +2943,7 @@ static int smp_cmd_dhkey_check(struct l2cap_conn *conn, struct sk_buff *skb)sc_add_ltk (smp); -if (hcon->out) { +if (test_bit (SMP_FLAG_INITIATOR , &smp->flags)) {hci_le_start_enc (hcon,0 ,0 , smp->tk, smp->enc_key_size); hcon->enc_key_size = smp->enc_key_size; }
@@ -3084,7 +3092,6 @@ static void bredr_pairing(struct l2cap_chan *chan)struct l2cap_conn *conn = chan->conn;struct hci_conn *hcon = conn->hcon;struct hci_dev *hdev = hcon->hdev; -struct smp_cmd_pairing req;struct smp_chan *smp;bt_dev_dbg (hdev,"chan %p" , chan);
@@ -3136,14 +3143,7 @@ static void bredr_pairing(struct l2cap_chan *chan)bt_dev_dbg (hdev,"starting SMP over BR/EDR" ); -/* Prepare and send the BR/EDR SMP Pairing Request */ -build_bredr_pairing_cmd (smp, &req,NULL ); - - smp->preq[0 ] =SMP_CMD_PAIRING_REQ ; -memcpy (&smp->preq[1 ], &req,sizeof (req)); - -smp_send_cmd (conn,SMP_CMD_PAIRING_REQ ,sizeof (req), &req); -SMP_ALLOW_CMD (smp,SMP_CMD_PAIRING_RSP ); +smp_send_pairing_req (smp,0x00 ); }static void smp_resume_cb (struct l2cap_chan *chan)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 243/341 net: mscc: ocelot: use ocelot_xmit_get_vlan_info() also for FDMA and register injection
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit 67c3ca2c5cfe6a50772514e3349b5e7b3b0fac03 ]
Problem description
-------------------
On an NXP LS1028A (felix DSA driver) with the following configuration:
- ocelot-8021q tagging protocol
- VLAN-aware bridge (with STP) spanning at least swp0 and swp1
- 8021q VLAN upper interfaces on swp0 and swp1: swp0.700, swp1.700
- ptp4l on swp0.700 and swp1.700
we see that the ptp4l instances do not see each other's traffic, and they all go to the grand master state due to the ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES condition.
Jumping to the conclusion for the impatient
-------------------------------------------
There is a zero-day bug in the ocelot switchdev driver in the way it handles VLAN-tagged packet injection. The correct logic already exists in the source code, in function ocelot_xmit_get_vlan_info() added by commit 5ca721c54d86 ("net: dsa: tag_ocelot: set the classified VLAN during xmit"). But it is used only for normal NPI-based injection with the DSA "ocelot" tagging protocol. The other injection code paths (register-based and FDMA-based) roll their own wrong logic. This affects and was noticed on the DSA "ocelot-8021q" protocol because it uses register-based injection.
By moving ocelot_xmit_get_vlan_info() to a place that's common for both the DSA tagger and the ocelot switch library, it can also be called from ocelot_port_inject_frame() in ocelot.c.
We need to touch the lines with ocelot_ifh_port_set()'s prototype anyway, so let's rename it to something clearer regarding what it does, and add a kernel-doc. ocelot_ifh_set_basic() should do.
Investigation notes
-------------------
Debugging reveals that PTP event (aka those carrying timestamps, like Sync) frames injected into swp0.700 (but also swp1.700) hit the wire with two VLAN tags:
00000000: 01 1b 19 00 00 00 00 01 02 03 04 05 81 00 02 bc
~~~~~~~~~~~
00000010: 81 00 02 bc 88 f7 00 12 00 2c 00 00 02 00 00 00
~~~~~~~~~~~00000020: 00 00 00 00 00 00 00 00 00 00 00 01 02 ff fe 03 00000030: 04 05 00 01 00 04 00 00 00 00 00 00 00 00 00 00 00000040: 00 00
The second (unexpected) VLAN tag makes felix_check_xtr_pkt() -> ptp_classify_raw() fail to see these as PTP packets at the link partner's receiving end, and return PTP_CLASS_NONE (because the BPF classifier is not written to expect 2 VLAN tags).
The reason why packets have 2 VLAN tags is because the transmission code treats VLAN incorrectly.
Neither ocelot switchdev, nor felix DSA, declare the NETIF_F_HW_VLAN_CTAG_TX feature. Therefore, at xmit time, all VLANs should be in the skb head, and none should be in the hwaccel area. This is done by:
static struct sk_buff *validate_xmit_vlan(struct sk_buff *skb,
netdev_features_t features)
{
if (skb_vlan_tag_present(skb) &&
!vlan_hw_offload_capable(features, skb->vlan_proto))
skb = __vlan_hwaccel_push_inside(skb);
return skb;
}But ocelot_port_inject_frame() handles things incorrectly:
ocelot_ifh_port_set(ifh, port, rew_op, skb_vlan_tag_get(skb));
void ocelot_ifh_port_set(struct sk_buff *skb, void *ifh, int port, u32 rew_op)
{
(...)
if (vlan_tag)
ocelot_ifh_set_vlan_tci(ifh, vlan_tag);
(...)
}The way __vlan_hwaccel_push_inside() pushes the tag inside the skb head is by calling:
static inline void __vlan_hwaccel_clear_tag(struct sk_buff *skb)
{
skb->vlan_present = 0;
}which does _not_ zero out skb->vlan_tci as seen by skb_vlan_tag_get(). This means that ocelot, when it calls skb_vlan_tag_get(), sees (and uses) a residual skb->vlan_tci, while the same VLAN tag is _already_ in the skb head.
The trivial fix for double VLAN headers is to replace the content of ocelot_ifh_port_set() with:
if (skb_vlan_tag_present(skb)) ocelot_ifh_set_vlan_tci(ifh, skb_vlan_tag_get(skb));
but this would not be correct either, because, as mentioned, vlan_hw_offload_capable() is false for us, so we'd be inserting dead code and we'd always transmit packets with VID=0 in the injection frame header.
I can't actually test the ocelot switchdev driver and rely exclusively on code inspection, but I don't think traffic from 8021q uppers has ever been injected properly, and not double-tagged. Thus I'm blaming the introduction of VLAN fields in the injection header - early driver code.
As hinted at in the early conclusion, what we _want_ to happen for VLAN transmission was already described once in commit 5ca721c54d86 ("net: dsa: tag_ocelot: set the classified VLAN during xmit").
ocelot_xmit_get_vlan_info() intends to ensure that if the port through which we're transmitting is under a VLAN-aware bridge, the outer VLAN tag from the skb head is stripped from there and inserted into the injection frame header (so that the packet is processed in hardware through that actual VLAN). And in all other cases, the packet is sent with VID=0 in the injection frame header, since the port is VLAN-unaware and has logic to strip this VID on egress (making it invisible to the wire).
--- drivers/net/ethernet/mscc/ocelot.c | 29 +++++++++++---- drivers/net/ethernet/mscc/ocelot_fdma.c | 2 +- include/linux/dsa/ocelot.h | 47 +++++++++++++++++++++++++ include/soc/mscc/ocelot.h | 3 +- net/dsa/tag_ocelot.c | 37 ++----------------- 5 files changed, 75 insertions(+), 43 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +23 -6
@@ -1193,17 +1193,34 @@ bool ocelot_can_inject(struct ocelot *ocelot, int grp) }EXPORT_SYMBOL (ocelot_can_inject); -void ocelot_ifh_port_set (void *ifh,int port,u32 rew_op,u32 vlan_tag) +/** +* ocelot_ifh_set_basic - Set basic information in Injection Frame Header +* @ifh: Pointer to Injection Frame Header memory +* @ocelot: Switch private data structure +* @port: Egress port number +* @rew_op: Egress rewriter operation for PTP +* @skb: Pointer to socket buffer (packet) +* +* Populate the Injection Frame Header with basic information for this skb: the +* analyzer bypass bit, destination port, VLAN info, egress rewriter info. +*/ +void ocelot_ifh_set_basic (void *ifh,struct ocelot *ocelot,int port, +u32 rew_op,struct sk_buff *skb) { +struct ocelot_port *ocelot_port = ocelot->ports[port]; +u64 vlan_tci, tag_type; + +ocelot_xmit_get_vlan_info (skb, ocelot_port->bridge, &vlan_tci, + &tag_type); +ocelot_ifh_set_bypass (ifh,1 );ocelot_ifh_set_dest (ifh,BIT_ULL (port)); -ocelot_ifh_set_tag_type (ifh,IFH_TAG_TYPE_C ); -if (vlan_tag) -ocelot_ifh_set_vlan_tci (ifh, vlan_tag); +ocelot_ifh_set_tag_type (ifh, tag_type); +ocelot_ifh_set_vlan_tci (ifh, vlan_tci);if (rew_op)ocelot_ifh_set_rew_op (ifh, rew_op); } -EXPORT_SYMBOL (ocelot_ifh_port_set); +EXPORT_SYMBOL (ocelot_ifh_set_basic);void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp,u32 rew_op,struct sk_buff *skb)
@@ -1214,7 +1231,7 @@ void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp,ocelot_write_rix (ocelot,QS_INJ_CTRL_GAP_SIZE (1 ) |QS_INJ_CTRL_SOF ,QS_INJ_CTRL , grp); -ocelot_ifh_port_set (ifh, port, rew_op,skb_vlan_tag_get (skb)); +ocelot_ifh_set_basic (ifh, ocelot, port, rew_op, skb);for (i =0 ; i <OCELOT_TAG_LEN /4 ; i++)ocelot_write_rix (ocelot, ifh[i],QS_INJ_WR , grp);
drivers/net/ethernet/mscc/ocelot_fdma.c +1 -1
@@ -666,7 +666,7 @@ static int ocelot_fdma_prepare_skb(struct ocelot *ocelot, int port, u32 rew_op, ifh =skb_push (skb,OCELOT_TAG_LEN );skb_put (skb,ETH_FCS_LEN );memset (ifh,0 ,OCELOT_TAG_LEN ); -ocelot_ifh_port_set (ifh, port, rew_op,skb_vlan_tag_get (skb)); +ocelot_ifh_set_basic (ifh, ocelot, port, rew_op, skb);return 0 ; }
include/linux/dsa/ocelot.h +47 -0
57 lines not on this page · raw message
include/soc/mscc/ocelot.h +2 -1
@@ -969,7 +969,8 @@ void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target,bool ocelot_can_inject (struct ocelot *ocelot,int grp);void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp,u32 rew_op,struct sk_buff *skb); -void ocelot_ifh_port_set (void *ifh,int port,u32 rew_op,u32 vlan_tag); +void ocelot_ifh_set_basic (void *ifh,struct ocelot *ocelot,int port, +u32 rew_op,struct sk_buff *skb);int ocelot_xtr_poll_frame (struct ocelot *ocelot,int grp,struct sk_buff **skb);void ocelot_drain_cpu_queue (struct ocelot *ocelot,int grp); void ocelot_ptp_rx_timestamp(struct ocelot *ocelot, struct sk_buff *skb,
net/dsa/tag_ocelot.c +2 -35
@@ -8,40 +8,6 @@#define OCELOT_NAME "ocelot"#define SEVILLE_NAME "seville" -/* If the port is under a VLAN-aware bridge, remove the VLAN header from the -* payload and move it into the DSA tag, which will make the switch classify -* the packet to the bridge VLAN. Otherwise, leave the classified VLAN at zero, -* which is the pvid of standalone and VLAN-unaware bridge ports. -*/ -static void ocelot_xmit_get_vlan_info (struct sk_buff *skb,struct dsa_port *dp, -u64 *vlan_tci,u64 *tag_type) -{ -struct net_device *br =dsa_port_bridge_dev_get (dp); -struct vlan_ethhdr *hdr; -u16 proto, tci; - -if (!br || !br_vlan_enabled (br)) { - *vlan_tci =0 ; - *tag_type =IFH_TAG_TYPE_C ; -return ; - } - - hdr =skb_vlan_eth_hdr (skb); -br_vlan_get_proto (br, &proto); - -if (ntohs (hdr->h_vlan_proto) == proto) { -vlan_remove_tag (skb, &tci); - *vlan_tci = tci; - }else { -rcu_read_lock (); -br_vlan_get_pvid_rcu (br, &tci); -rcu_read_unlock (); - *vlan_tci = tci; - } - - *tag_type = (proto !=ETH_P_8021Q ) ?IFH_TAG_TYPE_S :IFH_TAG_TYPE_C ; -} -static void ocelot_xmit_common (struct sk_buff *skb,struct net_device *netdev,__be32 ifh_prefix,void **ifh) {
@@ -53,7 +19,8 @@ static void ocelot_xmit_common(struct sk_buff *skb, struct net_device *netdev,u32 rew_op =0 ;u64 qos_class; -ocelot_xmit_get_vlan_info (skb, dp, &vlan_tci, &tag_type); +ocelot_xmit_get_vlan_info (skb,dsa_port_bridge_dev_get (dp), &vlan_tci, + &tag_type); qos_class =netdev_get_num_tc (netdev) ?netdev_get_prio_tc_map (netdev, skb->priority) : skb->priority;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 244/341 net: mscc: ocelot: fix QoS class for injected packets with "ocelot-8021q"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit e1b9e80236c540fa85d76e2d510d1b38e1968c5d ]
There are 2 distinct code paths (listed below) in the source code which set up an injection header for Ocelot(-like) switches. Code path (2) lacks the QoS class and source port being set correctly. Especially the improper QoS classification is a problem for the "ocelot-8021q" alternative DSA tagging protocol, because we support tc-taprio and each packet needs to be scheduled precisely through its time slot. This includes PTP, which is normally assigned to a traffic class other than 0, but would be sent through TC 0 nonetheless.
The code paths are:
(1) ocelot_xmit_common() from net/dsa/tag_ocelot.c - called only by the standard "ocelot" DSA tagging protocol which uses NPI-based injection - sets up bit fields in the tag manually to account for a small difference (destination port offset) between Ocelot and Seville. Namely, ocelot_ifh_set_dest() is omitted out of ocelot_xmit_common(), because there's also seville_ifh_set_dest().
(2) ocelot_ifh_set_basic(), called by:
- ocelot_fdma_prepare_skb() for FDMA transmission of the ocelot switchdev driver
- ocelot_port_xmit() -> ocelot_port_inject_frame() for register-based transmission of the ocelot switchdev driver
- felix_port_deferred_xmit() -> ocelot_port_inject_frame() for the DSA tagger ocelot-8021q when it must transmit PTP frames (also through register-based injection).
sets the bit fields according to its own logic.
The problem is that (2) doesn't call ocelot_ifh_set_qos_class(). Copying that logic from ocelot_xmit_common() fixes that.
Unfortunately, although desirable, it is not easily possible to de-duplicate code paths (1) and (2), and make net/dsa/tag_ocelot.c directly call ocelot_ifh_set_basic()), because of the ocelot/seville difference. This is the "minimal" fix with some logic duplicated (but at least more consolidated).
--- drivers/net/ethernet/mscc/ocelot.c | 10 +++++++++- drivers/net/ethernet/mscc/ocelot_fdma.c | 1 - 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +9 -1
@@ -1208,13 +1208,21 @@ void ocelot_ifh_set_basic(void *ifh, struct ocelot *ocelot, int port, u32 rew_op, struct sk_buff *skb) { struct ocelot_port *ocelot_port = ocelot->ports[port]; +struct net_device *dev = skb->dev;u64 vlan_tci, tag_type; +int qos_class;ocelot_xmit_get_vlan_info (skb, ocelot_port->bridge, &vlan_tci, &tag_type); + qos_class =netdev_get_num_tc (dev) ? +netdev_get_prio_tc_map (dev, skb->priority) : skb->priority; + +memset (ifh,0 ,OCELOT_TAG_LEN );ocelot_ifh_set_bypass (ifh,1 ); +ocelot_ifh_set_src (ifh,BIT_ULL (ocelot->num_phys_ports));ocelot_ifh_set_dest (ifh,BIT_ULL (port)); +ocelot_ifh_set_qos_class (ifh, qos_class);ocelot_ifh_set_tag_type (ifh, tag_type);ocelot_ifh_set_vlan_tci (ifh, vlan_tci);if (rew_op)
@@ -1225,7 +1233,7 @@ EXPORT_SYMBOL(ocelot_ifh_set_basic);void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp,u32 rew_op,struct sk_buff *skb) { -u32 ifh[OCELOT_TAG_LEN /4 ] = {0 }; +u32 ifh[OCELOT_TAG_LEN /4 ];unsigned int i, count, last; ocelot_write_rix(ocelot, QS_INJ_CTRL_GAP_SIZE(1) |
drivers/net/ethernet/mscc/ocelot_fdma.c +0 -1
@@ -665,7 +665,6 @@ static int ocelot_fdma_prepare_skb(struct ocelot *ocelot, int port, u32 rew_op, ifh =skb_push (skb,OCELOT_TAG_LEN );skb_put (skb,ETH_FCS_LEN ); -memset (ifh,0 ,OCELOT_TAG_LEN );ocelot_ifh_set_basic (ifh, ocelot, port, rew_op, skb);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 245/341 net: mscc: ocelot: serialize access to the injection/extraction groups
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit c5e12ac3beb0dd3a718296b2d8af5528e9ab728e ]
As explained by Horatiu Vultur in commit 603ead96582d ("net: sparx5: Add spinlock for frame transmission from CPU") which is for a similar hardware design, multiple CPUs can simultaneously perform injection or extraction. There are only 2 register groups for injection and 2 for extraction, and the driver only uses one of each. So we'd better serialize access using spin locks, otherwise frame corruption is possible.
Note that unlike in sparx5, FDMA in ocelot does not have this issue because struct ocelot_fdma_tx_ring already contains an xmit_lock.
I guess this is mostly a problem for NXP LS1028A, as that is dual core. I don't think VSC7514 is. So I'm blaming the commit where LS1028A (aka the felix DSA driver) started using register-based packet injection and extraction.
--- drivers/net/dsa/ocelot/felix.c | 11 +++++ drivers/net/ethernet/mscc/ocelot.c | 52 ++++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot_vsc7514.c | 4 ++ include/soc/mscc/ocelot.h | 9 ++++ 4 files changed, 76 insertions(+)
drivers/net/dsa/ocelot/felix.c +11 -0
@@ -528,7 +528,9 @@ static int felix_tag_8021q_setup(struct dsa_switch *ds)* so we need to be careful that there are no extra frames to be * dequeued over MMIO, since we would never know to discard them. */ +ocelot_lock_xtr_grp_bh (ocelot,0 );ocelot_drain_cpu_queue (ocelot,0 ); +ocelot_unlock_xtr_grp_bh (ocelot,0 );return 0 ; }
@@ -1504,6 +1506,8 @@ static void felix_port_deferred_xmit(struct kthread_work *work)int port = xmit_work->dp->index;int retries =10 ; +ocelot_lock_inj_grp (ocelot,0 ); + do { if (ocelot_can_inject(ocelot, 0)) break;
@@ -1512,6 +1516,7 @@ static void felix_port_deferred_xmit(struct kthread_work *work) }while (--retries);if (!retries) { +ocelot_unlock_inj_grp (ocelot,0 );dev_err (ocelot->dev,"port %d failed to inject skb\n" , port);ocelot_port_purge_txtstamp_skb (ocelot, port, skb);
@@ -1521,6 +1526,8 @@ static void felix_port_deferred_xmit(struct kthread_work *work)ocelot_port_inject_frame (ocelot, port,0 , rew_op, skb); +ocelot_unlock_inj_grp (ocelot,0 ); +consume_skb (skb);kfree (xmit_work); }
@@ -1671,6 +1678,8 @@ static bool felix_check_xtr_pkt(struct ocelot *ocelot)if (!felix->info->quirk_no_xtr_irq)return false; +ocelot_lock_xtr_grp (ocelot, grp); +while (ocelot_read (ocelot,QS_XTR_DATA_PRESENT ) &BIT (grp)) {struct sk_buff *skb;unsigned int type;
@@ -1707,6 +1716,8 @@ static bool felix_check_xtr_pkt(struct ocelot *ocelot)ocelot_drain_cpu_queue (ocelot,0 ); } +ocelot_unlock_xtr_grp (ocelot, grp); +return true; }
drivers/net/ethernet/mscc/ocelot.c +52 -0
88 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_vsc7514.c +4 -0
@@ -51,6 +51,8 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)struct ocelot *ocelot = arg;int grp =0 , err; +ocelot_lock_xtr_grp (ocelot, grp); +while (ocelot_read (ocelot,QS_XTR_DATA_PRESENT ) &BIT (grp)) {struct sk_buff *skb;
@@ -69,6 +71,8 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)if (err <0 )ocelot_drain_cpu_queue (ocelot,0 ); +ocelot_unlock_xtr_grp (ocelot, grp); +return IRQ_HANDLED ; }
include/soc/mscc/ocelot.h +9 -0
@@ -813,6 +813,9 @@ struct ocelot {const u32 *const *map;struct list_head stats_regions; +spinlock_t inj_lock; +spinlock_t xtr_lock; +u32 pool_size[OCELOT_SB_NUM ][OCELOT_SB_POOL_NUM ];int packet_buffer_size;int num_frame_refs;
@@ -966,6 +969,12 @@ void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target, u32 val, u32 reg, u32 offset);/* Packet I/O */ +void ocelot_lock_inj_grp (struct ocelot *ocelot,int grp); +void ocelot_unlock_inj_grp (struct ocelot *ocelot,int grp); +void ocelot_lock_xtr_grp (struct ocelot *ocelot,int grp); +void ocelot_unlock_xtr_grp (struct ocelot *ocelot,int grp); +void ocelot_lock_xtr_grp_bh (struct ocelot *ocelot,int grp); +void ocelot_unlock_xtr_grp_bh (struct ocelot *ocelot,int grp);bool ocelot_can_inject (struct ocelot *ocelot,int grp);void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp,u32 rew_op,struct sk_buff *skb);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 246/341 tc-testing: dont access non-existent variable on exception
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Horman <[email protected]>
[ Upstream commit a0c9fe5eecc97680323ee83780ea3eaf440ba1b7 ]
Since commit 255c1c7279ab ("tc-testing: Allow test cases to be skipped") the variable test_ordinal doesn't exist in call_pre_case(). So it should not be accessed when an exception occurs.
This resolves the following splat:
...
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../tdc.py", line 1028, in <module>
main()
File ".../tdc.py", line 1022, in main
set_operation_mode(pm, parser, args, remaining)
File ".../tdc.py", line 966, in set_operation_mode
catresults = test_runner_serial(pm, args, alltests)
File ".../tdc.py", line 642, in test_runner_serial
(index, tsr) = test_runner(pm, args, alltests)
File ".../tdc.py", line 536, in test_runner
res = run_one_test(pm, args, index, tidx)
File ".../tdc.py", line 419, in run_one_test
pm.call_pre_case(tidx)
File ".../tdc.py", line 146, in call_pre_case
print('test_ordinal is {}'.format(test_ordinal)) NameError: name 'test_ordinal' is not defined
--- tools/testing/selftests/tc-testing/tdc.py | 1 - 1 file changed, 1 deletion(-)
tools/testing/selftests/tc-testing/tdc.py +0 -1
@@ -129,7 +129,6 @@ class PluginMgr: except Exception as ee: print('exception {} in call to pre_case for {} plugin'. format(ee, pgn_inst.__class__)) - print('test_ordinal is {}'.format(test_ordinal)) print('testid is {}'.format(caseinfo['id'])) raise
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 247/341 selftests: udpgro: report error when receive failed
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
[ Upstream commit 7167395a4be7930ecac6a33b4e54d7e3dd9ee209 ]
Currently, we only check the latest senders's exit code. If the receiver report failed, it is not recoreded. Fix it by checking the exit code of all the involved processes.
Before:
bad GRO lookup ok
multiple GRO socks ./udpgso_bench_rx: recv: bad packet len, got 1452, expected 14520
./udpgso_bench_rx: recv: bad packet len, got 1452, expected 14520
failed
$ echo $? 0
After:
bad GRO lookup ok
multiple GRO socks ./udpgso_bench_rx: recv: bad packet len, got 1452, expected 14520
./udpgso_bench_rx: recv: bad packet len, got 1452, expected 14520
failed
$ echo $? 1
--- tools/testing/selftests/net/udpgro.sh | 44 ++++++++++++++++----------- 1 file changed, 27 insertions(+), 17 deletions(-)
tools/testing/selftests/net/udpgro.sh +27 -17
@@ -46,17 +46,19 @@ run_one() { local -r all="$@" local -r tx_args=${all%rx*} local -r rx_args=${all#*rx} + local ret=0 cfg_veth - ip netns exec "${PEER_NS}" ./udpgso_bench_rx -C 1000 -R 10 ${rx_args} && \ - echo "ok" || \ - echo "failed" & + ip netns exec "${PEER_NS}" ./udpgso_bench_rx -C 1000 -R 10 ${rx_args} & + local PID1=$! wait_local_port_listen ${PEER_NS} 8000 udp ./udpgso_bench_tx ${tx_args} - ret=$? - wait $(jobs -p) + check_err $? + wait ${PID1} + check_err $? + [ "$ret" -eq 0 ] && echo "ok" || echo "failed" return $ret }
@@ -73,6 +75,7 @@ run_one_nat() { local -r all="$@" local -r tx_args=${all%rx*} local -r rx_args=${all#*rx} + local ret=0 if [[ ${tx_args} = *-4* ]]; then ipt_cmd=iptables
@@ -93,16 +96,17 @@ run_one_nat() { # ... so that GRO will match the UDP_GRO enabled socket, but packets # will land on the 'plain' one ip netns exec "${PEER_NS}" ./udpgso_bench_rx -G ${family} -b ${addr1} -n 0 & - pid=$! - ip netns exec "${PEER_NS}" ./udpgso_bench_rx -C 1000 -R 10 ${family} -b ${addr2%/*} ${rx_args} && \ - echo "ok" || \ - echo "failed"& + local PID1=$! + ip netns exec "${PEER_NS}" ./udpgso_bench_rx -C 1000 -R 10 ${family} -b ${addr2%/*} ${rx_args} & + local PID2=$! wait_local_port_listen "${PEER_NS}" 8000 udp ./udpgso_bench_tx ${tx_args} - ret=$? - kill -INT $pid - wait $(jobs -p) + check_err $? + kill -INT ${PID1} + wait ${PID2} + check_err $? + [ "$ret" -eq 0 ] && echo "ok" || echo "failed" return $ret }
@@ -111,20 +115,26 @@ run_one_2sock() { local -r all="$@" local -r tx_args=${all%rx*} local -r rx_args=${all#*rx} + local ret=0 cfg_veth ip netns exec "${PEER_NS}" ./udpgso_bench_rx -C 1000 -R 10 ${rx_args} -p 12345 & - ip netns exec "${PEER_NS}" ./udpgso_bench_rx -C 2000 -R 10 ${rx_args} && \ - echo "ok" || \ - echo "failed" & + local PID1=$! + ip netns exec "${PEER_NS}" ./udpgso_bench_rx -C 2000 -R 10 ${rx_args} & + local PID2=$! wait_local_port_listen "${PEER_NS}" 12345 udp ./udpgso_bench_tx ${tx_args} -p 12345 + check_err $? wait_local_port_listen "${PEER_NS}" 8000 udp ./udpgso_bench_tx ${tx_args} - ret=$? - wait $(jobs -p) + check_err $? + wait ${PID1} + check_err $? + wait ${PID2} + check_err $? + [ "$ret" -eq 0 ] && echo "ok" || echo "failed" return $ret }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 248/341 tcp/dccp: bypass empty buckets in inet_twsk_purge()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 50e2907ef8bb52cf80ecde9eec5c4dac07177146 ]
TCP ehash table is often sparsely populated.
inet_twsk_purge() spends too much time calling cond_resched().
This patch can reduce time spent in inet_twsk_purge() by 20x.
Stable-dep-of: 565d121b6998 ("tcp: prevent concurrent execution of tcp_sk_exit_batch")
--- net/ipv4/inet_timewait_sock.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/ipv4/inet_timewait_sock.c +7 -2
@@ -281,12 +281,17 @@ EXPORT_SYMBOL_GPL(__inet_twsk_schedule);/* Remove all non full sockets (TIME_WAIT and NEW_SYN_RECV) for dead netns */ void inet_twsk_purge (struct inet_hashinfo *hashinfo,int family) { +struct inet_ehash_bucket *head = &hashinfo->ehash[0 ]; +unsigned int ehash_mask = hashinfo->ehash_mask;struct hlist_nulls_node *node;unsigned int slot;struct sock *sk; -for (slot =0 ; slot <= hashinfo->ehash_mask; slot++) { -struct inet_ehash_bucket *head = &hashinfo->ehash[slot]; +for (slot =0 ; slot <= ehash_mask; slot++, head++) { + +if (hlist_nulls_empty (&head->chain)) +continue ; + restart_rcu:cond_resched ();rcu_read_lock ();
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 249/341 tcp/dccp: do not care about families in inet_twsk_purge()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 1eeb5043573981f3a1278876515851b7f6b1df1b ]
We lost ability to unload ipv6 module a long time ago.
Instead of calling expensive inet_twsk_purge() twice, we can handle all families in one round.
Also remove an extra line added in my prior patch, per Kuniyuki Iwashima feedback.
Stable-dep-of: 565d121b6998 ("tcp: prevent concurrent execution of tcp_sk_exit_batch")
--- include/net/inet_timewait_sock.h | 2 +- include/net/tcp.h | 2 +- net/dccp/ipv4.c | 2 +- net/dccp/ipv6.c | 6 ------ net/ipv4/inet_timewait_sock.c | 9 +++------ net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/tcp_minisocks.c | 6 +++--- net/ipv6/tcp_ipv6.c | 6 ------ 8 files changed, 10 insertions(+), 25 deletions(-)
include/net/inet_timewait_sock.h +1 -1
@@ -114,7 +114,7 @@ static inline void inet_twsk_reschedule(struct inet_timewait_sock *tw, int timeovoid inet_twsk_deschedule_put (struct inet_timewait_sock *tw); -void inet_twsk_purge (struct inet_hashinfo *hashinfo,int family); +void inet_twsk_purge (struct inet_hashinfo *hashinfo);static inline struct net *twsk_net (const struct inet_timewait_sock *twsk)
include/net/tcp.h +1 -1
@@ -344,7 +344,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb);void tcp_rcv_space_adjust (struct sock *sk);int tcp_twsk_unique (struct sock *sk,struct sock *sktw,void *twp);void tcp_twsk_destructor (struct sock *sk); -void tcp_twsk_purge (struct list_head *net_exit_list,int family); +void tcp_twsk_purge (struct list_head *net_exit_list);ssize_t tcp_splice_read (struct socket *sk,loff_t *ppos,struct pipe_inode_info *pipe,size_t len,unsigned int flags);
net/dccp/ipv4.c +1 -1
@@ -1042,7 +1042,7 @@ static void __net_exit dccp_v4_exit_net(struct net *net) static void __net_exit dccp_v4_exit_batch(struct list_head *net_exit_list) { -inet_twsk_purge (&dccp_hashinfo,AF_INET ); +inet_twsk_purge (&dccp_hashinfo); }static struct pernet_operations dccp_v4_ops = {
net/dccp/ipv6.c +0 -6
@@ -1122,15 +1122,9 @@ static void __net_exit dccp_v6_exit_net(struct net *net)inet_ctl_sock_destroy (pn->v6_ctl_sk); } -static void __net_exit dccp_v6_exit_batch(struct list_head *net_exit_list) -{ -inet_twsk_purge (&dccp_hashinfo,AF_INET6 ); -} -static struct pernet_operations dccp_v6_ops = { .init = dccp_v6_init_net, .exit = dccp_v6_exit_net, - .exit_batch = dccp_v6_exit_batch, .id = &dccp_v6_pernet_id, .size =sizeof (struct dccp_v6_pernet ), };
net/ipv4/inet_timewait_sock.c +3 -6
@@ -279,7 +279,7 @@ void __inet_twsk_schedule(struct inet_timewait_sock *tw, int timeo, bool rearm)EXPORT_SYMBOL_GPL (__inet_twsk_schedule);/* Remove all non full sockets (TIME_WAIT and NEW_SYN_RECV) for dead netns */ -void inet_twsk_purge (struct inet_hashinfo *hashinfo,int family) +void inet_twsk_purge (struct inet_hashinfo *hashinfo) {struct inet_ehash_bucket *head = &hashinfo->ehash[0 ];unsigned int ehash_mask = hashinfo->ehash_mask;
@@ -288,7 +288,6 @@ void inet_twsk_purge(struct inet_hashinfo *hashinfo, int family)struct sock *sk;for (slot =0 ; slot <= ehash_mask; slot++, head++) { -if (hlist_nulls_empty (&head->chain))continue ;
@@ -303,15 +302,13 @@ void inet_twsk_purge(struct inet_hashinfo *hashinfo, int family) TCPF_NEW_SYN_RECV))continue ; -if (sk->sk_family != family || -refcount_read (&sock_net (sk)->ns.count)) +if (refcount_read (&sock_net (sk)->ns.count))continue ;if (unlikely (!refcount_inc_not_zero (&sk->sk_refcnt)))continue ; -if (unlikely (sk->sk_family != family || -refcount_read (&sock_net (sk)->ns.count))) { +if (refcount_read (&sock_net (sk)->ns.count)) {sock_gen_put (sk); goto restart; }
net/ipv4/tcp_ipv4.c +1 -1
@@ -3304,7 +3304,7 @@ static void __net_exit tcp_sk_exit_batch(struct list_head *net_exit_list) {struct net *net; -tcp_twsk_purge (net_exit_list,AF_INET ); +tcp_twsk_purge (net_exit_list);list_for_each_entry (net, net_exit_list, exit_list) {inet_pernet_hashinfo_free (net->ipv4.tcp_death_row.hashinfo);
net/ipv4/tcp_minisocks.c +3 -3
@@ -363,7 +363,7 @@ void tcp_twsk_destructor(struct sock *sk) }EXPORT_SYMBOL_GPL (tcp_twsk_destructor); -void tcp_twsk_purge (struct list_head *net_exit_list,int family) +void tcp_twsk_purge (struct list_head *net_exit_list) {bool purged_once = false;struct net *net;
@@ -371,9 +371,9 @@ void tcp_twsk_purge(struct list_head *net_exit_list, int family)list_for_each_entry (net, net_exit_list, exit_list) {if (net->ipv4.tcp_death_row.hashinfo->pernet) {/* Even if tw_refcount == 1, we must clean up kernel reqsk */ -inet_twsk_purge (net->ipv4.tcp_death_row.hashinfo, family); +inet_twsk_purge (net->ipv4.tcp_death_row.hashinfo); }else if (!purged_once) { -inet_twsk_purge (&tcp_hashinfo, family); +inet_twsk_purge (&tcp_hashinfo); purged_once = true; } }
net/ipv6/tcp_ipv6.c +0 -6
@@ -2213,15 +2213,9 @@ static void __net_exit tcpv6_net_exit(struct net *net)inet_ctl_sock_destroy (net->ipv6.tcp_sk); } -static void __net_exit tcpv6_net_exit_batch(struct list_head *net_exit_list) -{ -tcp_twsk_purge (net_exit_list,AF_INET6 ); -} -static struct pernet_operations tcpv6_net_ops = { .init = tcpv6_net_init, .exit = tcpv6_net_exit, - .exit_batch = tcpv6_net_exit_batch, };int __init tcpv6_init (void )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 250/341 tcp: prevent concurrent execution of tcp_sk_exit_batch
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 565d121b69980637f040eb4d84289869cdaabedf ]
Its possible that two threads call tcp_sk_exit_batch() concurrently, once from the cleanup_net workqueue, once from a task that failed to clone a new netns. In the latter case, error unwinding calls the exit handlers in reverse order for the 'failed' netns.
tcp_sk_exit_batch() calls tcp_twsk_purge().
Problem is that since commit b099ce2602d8 ("net: Batch inet_twsk_purge"), this function picks up twsk in any dying netns, not just the one passed in via exit_batch list.
This means that the error unwind of setup_net() can "steal" and destroy timewait sockets belonging to the exiting netns.
This allows the netns exit worker to proceed to call
WARN_ON_ONCE(!refcount_dec_and_test(&net->ipv4.tcp_death_row.tw_refcount));
without the expected 1 -> 0 transition, which then splats.
At same time, error unwind path that is also running inet_twsk_purge() will splat as well:
WARNING: .. at lib/refcount.c:31 refcount_warn_saturate+0x1ed/0x210
...
refcount_dec include/linux/refcount.h:351 [inline] inet_twsk_kill+0x758/0x9c0 net/ipv4/inet_timewait_sock.c:70 inet_twsk_deschedule_put net/ipv4/inet_timewait_sock.c:221 inet_twsk_purge+0x725/0x890 net/ipv4/inet_timewait_sock.c:304 tcp_sk_exit_batch+0x1c/0x170 net/ipv4/tcp_ipv4.c:3522 ops_exit_list+0x128/0x180 net/core/net_namespace.c:178 setup_net+0x714/0xb40 net/core/net_namespace.c:375 copy_net_ns+0x2f0/0x670 net/core/net_namespace.c:508 create_new_namespaces+0x3ea/0xb10 kernel/nsproxy.c:110
... because refcount_dec() of tw_refcount unexpectedly dropped to 0.
This doesn't seem like an actual bug (no tw sockets got lost and I don't see a use-after-free) but as erroneous trigger of debug check.
Add a mutex to force strict ordering: the task that calls tcp_twsk_purge() blocks other task from doing final _dec_and_test before mutex-owner has removed all tw sockets of dying netns.
--- net/ipv4/tcp_ipv4.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
net/ipv4/tcp_ipv4.c +14 -0
@@ -94,6 +94,8 @@ EXPORT_SYMBOL(tcp_hashinfo); static DEFINE_PER_CPU(struct sock *, ipv4_tcp_sk); +static DEFINE_MUTEX (tcp_exit_batch_mutex); +static u32 tcp_v4_init_seq (const struct sk_buff *skb) { return secure_tcp_seq(ip_hdr(skb)->daddr,
@@ -3304,6 +3306,16 @@ static void __net_exit tcp_sk_exit_batch(struct list_head *net_exit_list) {struct net *net; +/* make sure concurrent calls to tcp_sk_exit_batch from net_cleanup_work +* and failed setup_net error unwinding path are serialized. +* +* tcp_twsk_purge() handles twsk in any dead netns, not just those in +* net_exit_list, the thread that dismantles a particular twsk must +* do so without other thread progressing to refcount_dec_and_test() of +* tcp_death_row.tw_refcount. +*/ +mutex_lock (&tcp_exit_batch_mutex); +tcp_twsk_purge (net_exit_list);list_for_each_entry (net, net_exit_list, exit_list) {
@@ -3311,6 +3323,8 @@ static void __net_exit tcp_sk_exit_batch(struct list_head *net_exit_list)WARN_ON_ONCE (!refcount_dec_and_test (&net->ipv4.tcp_death_row.tw_refcount));tcp_fastopen_ctx_destroy (net); } + +mutex_unlock (&tcp_exit_batch_mutex); }static struct pernet_operations __net_initdata tcp_sk_ops = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 251/341 net: mctp: test: Use correct skb for route input check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Kerr <[email protected]>
[ Upstream commit ce335db0621648472f9bb4b7191eb2e13a5793cf ]
In the MCTP route input test, we're routing one skb, then (when delivery is expected) checking the resulting routed skb.
However, we're currently checking the original skb length, rather than the routed skb. Check the routed skb instead; the original will have been freed at this point.
--- net/mctp/test/route-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mctp/test/route-test.c +1 -1
@@ -354,7 +354,7 @@ static void mctp_test_route_input_sk(struct kunit *test) skb2 =skb_recv_datagram (sock->sk,MSG_DONTWAIT , &rc);KUNIT_EXPECT_NOT_ERR_OR_NULL (test, skb2); -KUNIT_EXPECT_EQ (test, skb->len,1 ); +KUNIT_EXPECT_EQ (test, skb2->len,1 );skb_free_datagram (sock->sk, skb2);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 252/341 kcm: Serialise kcm_sendmsg() for the same socket.
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 807067bf014d4a3ae2cc55bd3de16f22a01eb580 ]
syzkaller reported UAF in kcm_release(). [0]
The scenario is
1. Thread A builds a skb with MSG_MORE and sets kcm->seq_skb.
2. Thread A resumes building skb from kcm->seq_skb but is blocked by sk_stream_wait_memory()
3. Thread B calls sendmsg() concurrently, finishes building kcm->seq_skb and puts the skb to the write queue
4. Thread A faces an error and finally frees skb that is already in the write queue
5. kcm_release() does double-free the skb in the write queue
When a thread is building a MSG_MORE skb, another thread must not touch it.
Let's add a per-sk mutex and serialise kcm_sendmsg().
[0]:
BUG: KASAN: slab-use-after-free in __skb_unlink include/linux/skbuff.h:2366 [inline] BUG: KASAN: slab-use-after-free in __skb_dequeue include/linux/skbuff.h:2385 [inline] BUG: KASAN: slab-use-after-free in __skb_queue_purge_reason include/linux/skbuff.h:3175 [inline] BUG: KASAN: slab-use-after-free in __skb_queue_purge include/linux/skbuff.h:3181 [inline] BUG: KASAN: slab-use-after-free in kcm_release+0x170/0x4c8 net/kcm/kcmsock.c:1691 Read of size 8 at addr ffff0000ced0fc80 by task syz-executor329/6167 CPU: 1 PID: 6167 Comm: syz-executor329 Tainted: G B 6.8.0-rc5-syzkaller-g9abbc24128bc #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024 Call trace: dump_backtrace+0x1b8/0x1e4 arch/arm64/kernel/stacktrace.c:291 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:298 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd0/0x124 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:377 [inline] print_report+0x178/0x518 mm/kasan/report.c:488 kasan_report+0xd8/0x138 mm/kasan/report.c:601 __asan_report_load8_noabort+0x20/0x2c mm/kasan/report_generic.c:381 __skb_unlink include/linux/skbuff.h:2366 [inline] __skb_dequeue include/linux/skbuff.h:2385 [inline] __skb_queue_purge_reason include/linux/skbuff.h:3175 [inline] __skb_queue_purge include/linux/skbuff.h:3181 [inline] kcm_release+0x170/0x4c8 net/kcm/kcmsock.c:1691 __sock_release net/socket.c:659 [inline] sock_close+0xa4/0x1e8 net/socket.c:1421 __fput+0x30c/0x738 fs/file_table.c:376 ____fput+0x20/0x30 fs/file_table.c:404 task_work_run+0x230/0x2e0 kernel/task_work.c:180 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0x618/0x1f64 kernel/exit.c:871 do_group_exit+0x194/0x22c kernel/exit.c:1020 get_signal+0x1500/0x15ec kernel/signal.c:2893 do_signal+0x23c/0x3b44 arch/arm64/kernel/signal.c:1249 do_notify_resume+0x74/0x1f4 arch/arm64/kernel/entry-common.c:148 exit_to_user_mode_prepare arch/arm64/kernel/entry-common.c:169 [inline] exit_to_user_mode arch/arm64/kernel/entry-common.c:178 [inline] el0_svc+0xac/0x168 arch/arm64/kernel/entry-common.c:713 el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598 Allocated by task 6166: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x40/0x78 mm/kasan/common.c:68 kasan_save_alloc_info+0x70/0x84 mm/kasan/generic.c:626 unpoison_slab_object mm/kasan/common.c:314 [inline] __kasan_slab_alloc+0x74/0x8c mm/kasan/common.c:340 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slub.c:3813 [inline] slab_alloc_node mm/slub.c:3860 [inline] kmem_cache_alloc_node+0x204/0x4c0 mm/slub.c:3903 __alloc_skb+0x19c/0x3d8 net/core/skbuff.c:641 alloc_skb include/linux/skbuff.h:1296 [inline] kcm_sendmsg+0x1d3c/0x2124 net/kcm/kcmsock.c:783 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg net/socket.c:745 [inline] sock_sendmsg+0x220/0x2c0 net/socket.c:768 splice_to_socket+0x7cc/0xd58 fs/splice.c:889 do_splice_from fs/splice.c:941 [inline] direct_splice_actor+0xec/0x1d8 fs/splice.c:1164 splice_direct_to_actor+0x438/0xa0c fs/splice.c:1108 do_splice_direct_actor fs/splice.c:1207 [inline] do_splice_direct+0x1e4/0x304 fs/splice.c:1233 do_sendfile+0x460/0xb3c fs/read_write.c:1295 __do_sys_sendfile64 fs/read_write.c:1362 [inline] __se_sys_sendfile64 fs/read_write.c:1348 [inline] __arm64_sys_sendfile64+0x160/0x3b4 fs/read_write.c:1348 __invoke_syscall arch/arm64/kernel/syscall.c:37 [inline] invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:51 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:136 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:155 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712 el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598 Freed by task 6167: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x40/0x78 mm/kasan/common.c:68 kasan_save_free_info+0x5c/0x74 mm/kasan/generic.c:640 poison_slab_object+0x124/0x18c mm/kasan/common.c:241 __kasan_slab_free+0x3c/0x78 mm/kasan/common.c:257 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2121 [inline] slab_free mm/slub.c:4299 [inline] kmem_cache_free+0x15c/0x3d4 mm/slub.c:4363 kfree_skbmem+0x10c/0x19c __kfree_skb net/core/skbuff.c:1109 [inline] kfree_skb_reason+0x240/0x6f4 net/core/skbuff.c:1144 kfree_skb include/linux/skbuff.h:1244 [inline] kcm_release+0x104/0x4c8 net/kcm/kcmsock.c:1685 __sock_release net/socket.c:659 [inline] sock_close+0xa4/0x1e8 net/socket.c:1421 __fput+0x30c/0x738 fs/file_table.c:376 ____fput+0x20/0x30 fs/file_table.c:404 task_work_run+0x230/0x2e0 kernel/task_work.c:180 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0x618/0x1f64 kernel/exit.c:871 do_group_exit+0x194/0x22c kernel/exit.c:1020 get_signal+0x1500/0x15ec kernel/signal.c:2893 do_signal+0x23c/0x3b44 arch/arm64/kernel/signal.c:1249 do_notify_resume+0x74/0x1f4 arch/arm64/kernel/entry-common.c:148 exit_to_user_mode_prepare arch/arm64/kernel/entry-common.c:169 [inline] exit_to_user_mode arch/arm64/kernel/entry-common.c:178 [inline] el0_svc+0xac/0x168 arch/arm64/kernel/entry-common.c:713 el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598 The buggy address belongs to the object at ffff0000ced0fc80 which belongs to the cache skbuff_head_cache of size 240
The buggy address is located 0 bytes inside of
freed 240-byte region [ffff0000ced0fc80, ffff0000ced0fd70)
The buggy address belongs to the physical page:
page:00000000d35f4ae4 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10ed0f
flags: 0x5ffc00000000800(slab|node=0|zone=2|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 05ffc00000000800 ffff0000c1cbf640 fffffdffc3423100 dead000000000004
raw: 0000000000000000 00000000000c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff0000ced0fb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff0000ced0fc00: fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc
>ffff0000ced0fc80: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff0000ced0fd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
ffff0000ced0fd80: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb--- include/net/kcm.h | 1 + net/kcm/kcmsock.c | 4 ++++ 2 files changed, 5 insertions(+)
include/net/kcm.h +1 -0
@@ -70,6 +70,7 @@ struct kcm_sock {struct work_struct tx_work;struct list_head wait_psock_list;struct sk_buff *seq_skb; +struct mutex tx_mutex; u32 tx_stopped : 1;/* Don't use bit fields here, these are set under different locks */
net/kcm/kcmsock.c +4 -0
@@ -754,6 +754,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) !(msg->msg_flags & MSG_MORE) : !!(msg->msg_flags & MSG_EOR);int err = -EPIPE ; +mutex_lock (&kcm->tx_mutex);lock_sock (sk);/* Per tcp_sendmsg this should be in poll */
@@ -925,6 +926,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)KCM_STATS_ADD (kcm->stats.tx_bytes, copied);release_sock (sk); +mutex_unlock (&kcm->tx_mutex);return copied; out_error:
@@ -950,6 +952,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) sk->sk_write_space (sk);release_sock (sk); +mutex_unlock (&kcm->tx_mutex);return err; }
@@ -1203,6 +1206,7 @@ static void init_kcm_sock(struct kcm_sock *kcm, struct kcm_mux *mux)spin_unlock_bh (&mux->lock);INIT_WORK (&kcm->tx_work, kcm_tx_work); +mutex_init (&kcm->tx_mutex);spin_lock_bh (&mux->rx_lock);kcm_rcv_ready (kcm);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 253/341 netfilter: nft_counter: Disable BH in nft_counter_offload_stats().
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 1eacdd71b3436b54d5fc8218c4bb0187d92a6892 ]
The sequence counter nft_counter_seq is a per-CPU counter. There is no lock associated with it. nft_counter_do_eval() is using the same counter and disables BH which suggest that it can be invoked from a softirq. This in turn means that nft_counter_offload_stats(), which disables only preemption, can be interrupted by nft_counter_do_eval() leading to two writer for one seqcount_t.
This can lead to loosing stats or reading statistics while they are updated.
Disable BH during stats update in nft_counter_offload_stats() to ensure one writer at a time.
--- net/netfilter/nft_counter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nft_counter.c +2 -2
@@ -265,7 +265,7 @@ static void nft_counter_offload_stats(struct nft_expr *expr,struct nft_counter *this_cpu;seqcount_t *myseq; -preempt_disable (); +local_bh_disable (); this_cpu =this_cpu_ptr (priv->counter); myseq =this_cpu_ptr (&nft_counter_seq);
@@ -273,7 +273,7 @@ static void nft_counter_offload_stats(struct nft_expr *expr, this_cpu->packets += stats->pkts; this_cpu->bytes += stats->bytes;write_seqcount_end (myseq); -preempt_enable (); +local_bh_enable (); }void nft_counter_init_seqcount (void )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 254/341 netfilter: nft_counter: Synchronize nft_counter_reset() against reader.
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit a0b39e2dc7017ac667b70bdeee5293e410fab2fb ]
nft_counter_reset() resets the counter by subtracting the previously retrieved value from the counter. This is a write operation on the counter and as such it requires to be performed with a write sequence of nft_counter_seq to serialize against its possible reader.
Update the packets/ bytes within write-sequence of nft_counter_seq.
--- net/netfilter/nft_counter.c | 5 +++++ 1 file changed, 5 insertions(+)
net/netfilter/nft_counter.c +5 -0
@@ -107,11 +107,16 @@ static void nft_counter_reset(struct nft_counter_percpu_priv *priv, struct nft_counter *total) {struct nft_counter *this_cpu; +seqcount_t *myseq;local_bh_disable (); this_cpu =this_cpu_ptr (priv->counter); + myseq =this_cpu_ptr (&nft_counter_seq); + +write_seqcount_begin (myseq); this_cpu->packets -= total->packets; this_cpu->bytes -= total->bytes; +write_seqcount_end (myseq);local_bh_enable (); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 255/341 ip6_tunnel: Fix broken GRO
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Bogendoerfer <[email protected]>
[ Upstream commit 4b3e33fcc38f7750604b065c55a43e94c5bc3145 ]
GRO code checks for matching layer 2 headers to see, if packet belongs to the same flow and because ip6 tunnel set dev->hard_header_len this check fails in cases, where it shouldn't. To fix this don't set hard_header_len, but use needed_headroom like ipv4/ip_tunnel.c does.
--- net/ipv6/ip6_tunnel.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/ipv6/ip6_tunnel.c +7 -5
@@ -1508,7 +1508,8 @@ static void ip6_tnl_link_config(struct ip6_tnl *t) tdev =__dev_get_by_index (t->net, p->link);if (tdev) { - dev->hard_header_len = tdev->hard_header_len + t_hlen; + dev->needed_headroom = tdev->hard_header_len + + tdev->needed_headroom + t_hlen; mtu = min_t(unsigned int, tdev->mtu, IP6_MAX_MTU); mtu = mtu - t_hlen;
@@ -1732,7 +1733,9 @@ ip6_tnl_siocdevprivate(struct net_device *dev, struct ifreq *ifr,int ip6_tnl_change_mtu (struct net_device *dev,int new_mtu) {struct ip6_tnl *tnl =netdev_priv (dev); +int t_hlen; + t_hlen = tnl->hlen +sizeof (struct ipv6hdr );if (tnl->parms.proto ==IPPROTO_IPV6 ) {if (new_mtu <IPV6_MIN_MTU )return -EINVAL ;
@@ -1741,10 +1744,10 @@ int ip6_tnl_change_mtu(struct net_device *dev, int new_mtu)return -EINVAL ; }if (tnl->parms.proto ==IPPROTO_IPV6 || tnl->parms.proto ==0 ) { -if (new_mtu >IP6_MAX_MTU - dev->hard_header_len) +if (new_mtu >IP6_MAX_MTU - dev->hard_header_len - t_hlen)return -EINVAL ; }else { -if (new_mtu >IP_MAX_MTU - dev->hard_header_len) +if (new_mtu >IP_MAX_MTU - dev->hard_header_len - t_hlen)return -EINVAL ; } dev->mtu = new_mtu;
@@ -1890,12 +1893,11 @@ ip6_tnl_dev_init_gen(struct net_device *dev) t_hlen = t->hlen +sizeof (struct ipv6hdr ); dev->type =ARPHRD_TUNNEL6 ; - dev->hard_header_len =LL_MAX_HEADER + t_hlen; dev->mtu =ETH_DATA_LEN - t_hlen;if (!(t->parms.flags &IP6_TNL_F_IGN_ENCAP_LIMIT )) dev->mtu -=8 ; dev->min_mtu =ETH_MIN_MTU ; - dev->max_mtu =IP6_MAX_MTU - dev->hard_header_len; + dev->max_mtu =IP6_MAX_MTU - dev->hard_header_len - t_hlen;netdev_hold (dev, &t->dev_tracker,GFP_KERNEL );netdev_lockdep_set_classes (dev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 256/341 bonding: fix bond_ipsec_offload_ok return type
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Aleksandrov <[email protected]>
[ Upstream commit fc59b9a5f7201b9f7272944596113a82cc7773d5 ]
Fix the return type which should be bool.
--- drivers/net/bonding/bond_main.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/net/bonding/bond_main.c +6 -12
@@ -599,34 +599,28 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs)struct net_device *real_dev;struct slave *curr_active;struct bonding *bond; -int err; +bool ok = false; bond =netdev_priv (bond_dev);rcu_read_lock (); curr_active =rcu_dereference (bond->curr_active_slave); real_dev = curr_active->dev; -if (BOND_MODE (bond) !=BOND_MODE_ACTIVEBACKUP ) { - err = false; +if (BOND_MODE (bond) !=BOND_MODE_ACTIVEBACKUP ) goto out; - } -if (!xs->xso.real_dev) { - err = false; +if (!xs->xso.real_dev) goto out; - }if (!real_dev->xfrmdev_ops || !real_dev->xfrmdev_ops->xdo_dev_offload_ok || -netif_is_bond_master (real_dev)) { - err = false; +netif_is_bond_master (real_dev)) goto out; - } - err = real_dev->xfrmdev_ops->xdo_dev_offload_ok (skb, xs); + ok = real_dev->xfrmdev_ops->xdo_dev_offload_ok (skb, xs); out:rcu_read_unlock (); -return err; +return ok; }static const struct xfrmdev_ops bond_xfrmdev_ops = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 257/341 bonding: fix null pointer deref in bond_ipsec_offload_ok
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 95c90e4ad89d493a7a14fa200082e466e2548f9d ]
We must check if there is an active slave before dereferencing the pointer.
--- drivers/net/bonding/bond_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/bonding/bond_main.c +2 -0
@@ -604,6 +604,8 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs) bond =netdev_priv (bond_dev);rcu_read_lock (); curr_active =rcu_dereference (bond->curr_active_slave); +if (!curr_active) + goto out; real_dev = curr_active->dev;if (BOND_MODE (bond) !=BOND_MODE_ACTIVEBACKUP )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 258/341 bonding: fix xfrm real_dev null pointer dereference
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Aleksandrov <[email protected]>
[ Upstream commit f8cde9805981c50d0c029063dc7d82821806fc44 ]
We shouldn't set real_dev to NULL because packets can be in transit and xfrm might call xdo_dev_offload_ok() in parallel. All callbacks assume real_dev is set.
Example trace:
kernel: BUG: unable to handle page fault for address: 0000000000001030
kernel: bond0: (slave eni0np1): making interface the new active one
kernel: #PF: supervisor write access in kernel mode
kernel: #PF: error_code(0x0002) - not-present page
kernel: PGD 0 P4D 0
kernel: Oops: 0002 [#1] PREEMPT SMP
kernel: CPU: 4 PID: 2237 Comm: ping Not tainted 6.7.7+ #12
kernel: Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-2.fc40 04/01/2014
kernel: RIP: 0010:nsim_ipsec_offload_ok+0xc/0x20 [netdevsim]
kernel: bond0: (slave eni0np1): bond_ipsec_add_sa_all: failed to add SA
kernel: Code: e0 0f 0b 48 83 7f 38 00 74 de 0f 0b 48 8b 47 08 48 8b 37 48 8b 78 40 e9 b2 e5 9a d7 66 90 0f 1f 44 00 00 48 8b 86 80 02 00 00 <83> 80 30 10 00 00 01 b8 01 00 00 00 c3 0f 1f 80 00 00 00 00 0f 1f
kernel: bond0: (slave eni0np1): making interface the new active one
kernel: RSP: 0018:ffffabde81553b98 EFLAGS: 00010246
kernel: bond0: (slave eni0np1): bond_ipsec_add_sa_all: failed to add SA
kernel:
kernel: RAX: 0000000000000000 RBX: ffff9eb404e74900 RCX: ffff9eb403d97c60
kernel: RDX: ffffffffc090de10 RSI: ffff9eb404e74900 RDI: ffff9eb3c5de9e00
kernel: RBP: ffff9eb3c0a42000 R08: 0000000000000010 R09: 0000000000000014
kernel: R10: 7974203030303030 R11: 3030303030303030 R12: 0000000000000000
kernel: R13: ffff9eb3c5de9e00 R14: ffffabde81553cc8 R15: ffff9eb404c53000
kernel: FS: 00007f2a77a3ad00(0000) GS:ffff9eb43bd00000(0000) knlGS:0000000000000000
kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
kernel: CR2: 0000000000001030 CR3: 00000001122ab000 CR4: 0000000000350ef0
kernel: bond0: (slave eni0np1): making interface the new active one
kernel: Call Trace:
kernel: <TASK>
kernel: ? __die+0x1f/0x60
kernel: bond0: (slave eni0np1): bond_ipsec_add_sa_all: failed to add SA
kernel: ? page_fault_oops+0x142/0x4c0 kernel: ? do_user_addr_fault+0x65/0x670 kernel: ? kvm_read_and_reset_apf_flags+0x3b/0x50 kernel: bond0: (slave eni0np1): making interface the new active one kernel: ? exc_page_fault+0x7b/0x180 kernel: ? asm_exc_page_fault+0x22/0x30 kernel: ? nsim_bpf_uninit+0x50/0x50 [netdevsim]
kernel: bond0: (slave eni0np1): bond_ipsec_add_sa_all: failed to add SA
kernel: ? nsim_ipsec_offload_ok+0xc/0x20 [netdevsim]
kernel: bond0: (slave eni0np1): making interface the new active one
kernel: bond_ipsec_offload_ok+0x7b/0x90 [bonding]
kernel: xfrm_output+0x61/0x3b0
kernel: bond0: (slave eni0np1): bond_ipsec_add_sa_all: failed to add SA
kernel: ip_push_pending_frames+0x56/0x80
--- drivers/net/bonding/bond_main.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/bonding/bond_main.c +0 -1
@@ -582,7 +582,6 @@ static void bond_ipsec_del_sa_all(struct bonding *bond) }else { slave->dev->xfrmdev_ops->xdo_dev_state_delete (ipsec->xs); } - ipsec->xs->xso.real_dev =NULL ; }spin_unlock_bh (&bond->ipsec_lock);rcu_read_unlock ();
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 259/341 bonding: fix xfrm state handling when clearing active slave
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Aleksandrov <[email protected]>
[ Upstream commit c4c5c5d2ef40a9f67a9241dc5422eac9ffe19547 ]
If the active slave is cleared manually the xfrm state is not flushed. This leads to xfrm add/del imbalance and adding the same state multiple times. For example when the device cannot handle anymore states we get:
[ 1169.884811] bond0: (slave eni0np1): bond_ipsec_add_sa_all: failed to add SA
because it's filled with the same state after multiple active slave clearings. This change also has a few nice side effects: user-space gets a notification for the change, the old device gets its mac address and promisc/mcast adjusted properly.
--- drivers/net/bonding/bond_options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_options.c +1 -1
@@ -920,7 +920,7 @@ static int bond_option_active_slave_set(struct bonding *bond,/* check to see if we are clearing active */ if (!slave_dev) {netdev_dbg (bond->dev,"Clearing current active slave\n" ); -RCU_INIT_POINTER (bond->curr_active_slave,NULL ); +bond_change_active_slave (bond,NULL );bond_select_active_slave (bond); }else {struct slave *old_active =rtnl_dereference (bond->curr_active_slave);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 260/341 ice: fix page reuse when PAGE_SIZE is over 8k
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej Fijalkowski <[email protected]>
[ Upstream commit 50b2143356e888777fc5bca023c39f34f404613a ]
Architectures that have PAGE_SIZE >= 8192 such as arm64 should act the same as x86 currently, meaning reuse of a page should only take place when no one else is busy with it.
Do two things independently of underlying PAGE_SIZE:
- store the page count under ice_rx_buf::pgcnt
- then act upon its value vs ice_rx_buf::pagecnt_bias when making the decision regarding page reuse
--- drivers/net/ethernet/intel/ice/ice_txrx.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +3 -9
@@ -834,16 +834,15 @@ ice_can_reuse_rx_page(struct ice_rx_buf *rx_buf)if (!dev_page_is_reusable (page))return false; -#if (PAGE_SIZE <8192 )/* if we are only owner of page we can reuse it */ if (unlikely (rx_buf->pgcnt - pagecnt_bias >1 ))return false; -#else +#if (PAGE_SIZE >=8192 )#define ICE_LAST_OFFSET \ (SKB_WITH_OVERHEAD(PAGE_SIZE) - ICE_RXBUF_2048)if (rx_buf->page_offset >ICE_LAST_OFFSET )return false; -#endif /* PAGE_SIZE < 8192) */ +#endif /* PAGE_SIZE >= 8192) */ /* If we have drained the page fragment pool we need to update * the pagecnt_bias and page count so that we fully restock the
@@ -946,12 +945,7 @@ ice_get_rx_buf(struct ice_rx_ring *rx_ring, const unsigned int size,struct ice_rx_buf *rx_buf; rx_buf = &rx_ring->rx_buf[ntc]; - rx_buf->pgcnt = -#if (PAGE_SIZE <8192 ) -page_count (rx_buf->page); -#else -0 ; -#endif + rx_buf->pgcnt =page_count (rx_buf->page);prefetchw (rx_buf->page);if (!size)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 261/341 ice: fix ICE_LAST_OFFSET formula
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej Fijalkowski <[email protected]>
[ Upstream commit b966ad832942b5a11e002f9b5ef102b08425b84a ]
For bigger PAGE_SIZE archs, ice driver works on 3k Rx buffers. Therefore, ICE_LAST_OFFSET should take into account ICE_RXBUF_3072, not ICE_RXBUF_2048.
--- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +1 -1
@@ -839,7 +839,7 @@ ice_can_reuse_rx_page(struct ice_rx_buf *rx_buf)return false;#if (PAGE_SIZE >=8192 )#define ICE_LAST_OFFSET \ - (SKB_WITH_OVERHEAD(PAGE_SIZE) - ICE_RXBUF_2048) + (SKB_WITH_OVERHEAD(PAGE_SIZE) - ICE_RXBUF_3072)if (rx_buf->page_offset >ICE_LAST_OFFSET )return false;#endif /* PAGE_SIZE >= 8192) */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 262/341 ice: fix truesize operations for PAGE_SIZE >= 8192
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej Fijalkowski <[email protected]>
[ Upstream commit d53d4dcce69be5773e2d0878c9899ebfbf58c393 ]
When working on multi-buffer packet on arch that has PAGE_SIZE >= 8192, truesize is calculated and stored in xdp_buff::frame_sz per each processed Rx buffer. This means that frame_sz will contain the truesize based on last received buffer, but commit 1dc1a7e7f410 ("ice:
Centrallize Rx buffer recycling") assumed this value will be constant for each buffer, which breaks the page recycling scheme and mess up the way we update the page::page_offset.
To fix this, let us work on constant truesize when PAGE_SIZE >= 8192 instead of basing this on size of a packet read from Rx descriptor. This way we can simplify the code and avoid calculating truesize per each received frame and on top of that when using xdp_update_skb_shared_info(), current formula for truesize update will be valid.
This means ice_rx_frame_truesize() can be removed altogether. Furthermore, first call to it within ice_clean_rx_irq() for 4k PAGE_SIZE was redundant as xdp_buff::frame_sz is initialized via xdp_init_buff() in ice_vsi_cfg_rxq(). This should have been removed at the point where xdp_buff struct started to be a member of ice_rx_ring and it was no longer a stack based variable.
There are two fixes tags as my understanding is that the first one exposed us to broken truesize and page_offset handling and then second introduced broken skb_shared_info update in ice_{construct,build}_skb().
--- drivers/net/ethernet/intel/ice/ice_base.c | 21 ++++++++++++++- drivers/net/ethernet/intel/ice/ice_txrx.c | 33 ----------------------- 2 files changed, 20 insertions(+), 34 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +20 -1
@@ -519,6 +519,25 @@ static int ice_setup_rx_ctx(struct ice_rx_ring *ring)return 0 ; } +/** +* ice_get_frame_sz - calculate xdp_buff::frame_sz +* @rx_ring: the ring being configured +* +* Return frame size based on underlying PAGE_SIZE +*/ +static unsigned int ice_get_frame_sz (struct ice_rx_ring *rx_ring) +{ +unsigned int frame_sz; + +#if (PAGE_SIZE >=8192 ) + frame_sz = rx_ring->rx_buf_len; +#else + frame_sz =ice_rx_pg_size (rx_ring) /2 ; +#endif + +return frame_sz; +} +/** * ice_vsi_cfg_rxq - Configure an Rx queue * @ring: the ring being configured
@@ -582,7 +601,7 @@ int ice_vsi_cfg_rxq(struct ice_rx_ring *ring) } } -xdp_init_buff (&ring->xdp,ice_rx_pg_size (ring) /2 , &ring->xdp_rxq); +xdp_init_buff (&ring->xdp,ice_get_frame_sz (ring), &ring->xdp_rxq); ring->xdp.data =NULL ; err =ice_setup_rx_ctx (ring);if (err) {
drivers/net/ethernet/intel/ice/ice_txrx.c +0 -33
@@ -521,30 +521,6 @@ int ice_setup_rx_ring(struct ice_rx_ring *rx_ring)return -ENOMEM ; } -/** -* ice_rx_frame_truesize -* @rx_ring: ptr to Rx ring -* @size: size -* -* calculate the truesize with taking into the account PAGE_SIZE of -* underlying arch -*/ -static unsigned int -ice_rx_frame_truesize (struct ice_rx_ring *rx_ring,const unsigned int size) -{ -unsigned int truesize; - -#if (PAGE_SIZE <8192 ) - truesize =ice_rx_pg_size (rx_ring) /2 ;/* Must be power-of-2 */ -#else - truesize = rx_ring->rx_offset ? -SKB_DATA_ALIGN (rx_ring->rx_offset + size) + -SKB_DATA_ALIGN (sizeof (struct skb_shared_info )) : -SKB_DATA_ALIGN (size); -#endif -return truesize; -} -/** * ice_run_xdp - Executes an XDP program on initialized xdp_buff * @rx_ring: Rx ring
@@ -1152,11 +1128,6 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)bool failure;u32 first; -/* Frame size depend on rx_ring setup when PAGE_SIZE=4K */ -#if (PAGE_SIZE <8192 ) - xdp->frame_sz =ice_rx_frame_truesize (rx_ring,0 ); -#endif - xdp_prog =READ_ONCE (rx_ring->xdp_prog);if (xdp_prog) { xdp_ring = rx_ring->xdp_ring;
@@ -1216,10 +1187,6 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget) hard_start =page_address (rx_buf->page) + rx_buf->page_offset - offset;xdp_prepare_buff (xdp, hard_start, offset, size, !!offset); -#if (PAGE_SIZE >4096 ) -/* At larger PAGE_SIZE, frame_sz depend on len size */ - xdp->frame_sz =ice_rx_frame_truesize (rx_ring, size); -#endif xdp_buff_clear_frags_flag (xdp); }else if (ice_add_xdp_frag (rx_ring, xdp, rx_buf, size)) {break ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 263/341 dpaa2-switch: Fix error checking in dpaa2_switch_seed_bp()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit c50e7475961c36ec4d21d60af055b32f9436b431 ]
The dpaa2_switch_add_bufs() function returns the number of bufs that it was able to add. It returns BUFS_PER_CMD (7) for complete success or a smaller number if there are not enough pages available. However, the error checking is looking at the total number of bufs instead of the number which were added on this iteration. Thus the error checking only works correctly for the first iteration through the loop and subsequent iterations are always counted as a success.
Fix this by checking only the bufs added in the current iteration.
--- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +4 -3
@@ -2603,13 +2603,14 @@ static int dpaa2_switch_refill_bp(struct ethsw_core *ethsw)static int dpaa2_switch_seed_bp (struct ethsw_core *ethsw) { -int *count, i; +int *count, ret, i;for (i =0 ; i <DPAA2_ETHSW_NUM_BUFS ; i +=BUFS_PER_CMD ) { + ret =dpaa2_switch_add_bufs (ethsw, ethsw->bpid); count = ðsw->buf_count; - *count +=dpaa2_switch_add_bufs (ethsw, ethsw->bpid); + *count += ret; -if (unlikely (*count <BUFS_PER_CMD )) +if (unlikely (ret <BUFS_PER_CMD ))return -ENOMEM ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 264/341 igb: cope with large MAX_SKB_FRAGS
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 8aba27c4a5020abdf60149239198297f88338a8d ]
Sabrina reports that the igb driver does not cope well with large MAX_SKB_FRAG values: setting MAX_SKB_FRAG to 45 causes payload corruption on TX.
An easy reproducer is to run ssh to connect to the machine. With MAX_SKB_FRAGS=17 it works, with MAX_SKB_FRAGS=45 it fails. This has been reported originally in
https://bugzilla.redhat.com/show_bug.cgi?id=2265320
The root cause of the issue is that the driver does not take into account properly the (possibly large) shared info size when selecting the ring layout, and will try to fit two packets inside the same 4K page even when the 1st fraglist will trump over the 2nd head.
Address the issue by checking if 2K buffers are insufficient.
--- drivers/net/ethernet/intel/igb/igb_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/igb/igb_main.c +1 -0
@@ -4833,6 +4833,7 @@ static void igb_set_rx_buffer_len(struct igb_adapter *adapter,#if (PAGE_SIZE <8192 )if (adapter->max_frame_size >IGB_MAX_FRAME_BUILD_SKB || +IGB_2K_TOO_SMALL_WITH_PADDING ||rd32 (E1000_RCTL ) &E1000_RCTL_SBP )set_ring_uses_large_buffer (rx_ring);#endif
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 265/341 net: dsa: mv88e6xxx: Fix out-of-bound access
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Huang <[email protected]>
[ Upstream commit 528876d867a23b5198022baf2e388052ca67c952 ]
If an ATU violation was caused by a CPU Load operation, the SPID could be larger than DSA_MAX_PORTS (the size of mv88e6xxx_chip.ports[] array).
--- drivers/net/dsa/mv88e6xxx/global1_atu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/global1_atu.c +2 -1
@@ -457,7 +457,8 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)trace_mv88e6xxx_atu_full_violation (chip->dev, spid, entry.portvec, entry.mac, fid); - chip->ports[spid].atu_full_violation++; +if (spid <ARRAY_SIZE (chip->ports)) + chip->ports[spid].atu_full_violation++; }return IRQ_HANDLED ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 266/341 netem: fix return value if duplicate enqueue fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Hemminger <[email protected]>
[ Upstream commit c07ff8592d57ed258afee5a5e04991a48dbaf382 ]
There is a bug in netem_enqueue() introduced by
commit 5845f706388a ("net: netem: fix skb length BUG_ON in __skb_to_sgvec") that can lead to a use-after-free.
This commit made netem_enqueue() always return NET_XMIT_SUCCESS when a packet is duplicated, which can cause the parent qdisc's q.qlen to be mistakenly incremented. When this happens qlen_notify() may be skipped on the parent during destruction, leaving a dangling pointer for some classful qdiscs like DRR.
There are two ways for the bug happen:
- If the duplicated packet is dropped by rootq->enqueue() and then the original packet is also dropped.
- If rootq->enqueue() sends the duplicated packet to a different qdisc and the original packet is dropped.
In both cases NET_XMIT_SUCCESS is returned even though no packets are enqueued at the netem qdisc.
The fix is to defer the enqueue of the duplicate packet until after the original packet has been guaranteed to return NET_XMIT_SUCCESS.
--- net/sched/sch_netem.c | 47 ++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 18 deletions(-)
net/sched/sch_netem.c +29 -18
@@ -446,12 +446,10 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,struct netem_sched_data *q =qdisc_priv (sch);/* We don't fill cb now as skb_unshare() may invalidate it */ struct netem_skb_cb *cb; -struct sk_buff *skb2; +struct sk_buff *skb2 =NULL ;struct sk_buff *segs =NULL ;unsigned int prev_len =qdisc_pkt_len (skb);int count =1 ; -int rc =NET_XMIT_SUCCESS ; -int rc_drop =NET_XMIT_DROP ;/* Do not fool qdisc_drop_all() */ skb->prev =NULL ;
@@ -480,19 +478,11 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,skb_orphan_partial (skb);/* -* If we need to duplicate packet, then re-insert at top of the -* qdisc tree, since parent queuer expects that only one -* skb will be queued. +* If we need to duplicate packet, then clone it before +* original is modified. */ -if (count >1 && (skb2 =skb_clone (skb,GFP_ATOMIC )) !=NULL ) { -struct Qdisc *rootq =qdisc_root_bh (sch); -u32 dupsave = q->duplicate;/* prevent duplicating a dup... */ - - q->duplicate =0 ; - rootq->enqueue (skb2, rootq, to_free); - q->duplicate = dupsave; - rc_drop =NET_XMIT_SUCCESS ; - } +if (count >1 ) + skb2 =skb_clone (skb,GFP_ATOMIC );/* * Randomized packet corruption.
@@ -504,7 +494,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,if (skb_is_gso (skb)) { skb =netem_segment (skb, sch, to_free);if (!skb) -return rc_drop; + goto finish_segs; + segs = skb->next;skb_mark_not_on_list (skb);qdisc_skb_cb (skb)->pkt_len = skb->len;
@@ -530,7 +521,24 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,/* re-link segs, so that qdisc_drop_all() frees them all */ skb->next = segs;qdisc_drop_all (skb, sch, to_free); -return rc_drop; +if (skb2) +__qdisc_drop (skb2, to_free); +return NET_XMIT_DROP ; + } + +/* +* If doing duplication then re-insert at top of the +* qdisc tree, since parent queuer expects that only one +* skb will be queued. +*/ +if (skb2) { +struct Qdisc *rootq =qdisc_root_bh (sch); +u32 dupsave = q->duplicate;/* prevent duplicating a dup... */ + + q->duplicate =0 ; + rootq->enqueue (skb2, rootq, to_free); + q->duplicate = dupsave; + skb2 =NULL ; }qdisc_qstats_backlog_inc (sch, skb);
@@ -601,9 +609,12 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, } finish_segs: +if (skb2) +__qdisc_drop (skb2, to_free); +if (segs) {unsigned int len, last_len; -int nb; +int rc, nb; len = skb ? skb->len :0 ; nb = skb ?1 :0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 267/341 udp: fix receiving fraglist GSO packets
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit b128ed5ab27330deeeaf51ea8bb69f1442a96f7f ]
When assembling fraglist GSO packets, udp4_gro_complete does not set skb->csum_start, which makes the extra validation in __udp_gso_segment fail.
--- net/ipv4/udp_offload.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/udp_offload.c +2 -1
@@ -279,7 +279,8 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,return ERR_PTR (-EINVAL );if (unlikely (skb_checksum_start (gso_skb) != -skb_transport_header (gso_skb))) +skb_transport_header (gso_skb) && + !(skb_shinfo (gso_skb)->gso_type &SKB_GSO_FRAGLIST )))return ERR_PTR (-EINVAL );if (skb_gso_ok (gso_skb, features |NETIF_F_GSO_ROBUST )) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 268/341 ipv6: prevent UAF in ip6_send_skb()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit faa389b2fbaaec7fd27a390b4896139f9da662e3 ]
syzbot reported an UAF in ip6_send_skb() [1]
After ip6_local_out() has returned, we no longer can safely dereference rt, unless we hold rcu_read_lock().
A similar issue has been fixed in commit a688caa34beb ("ipv6: take rcu lock in rawv6_send_hdrinc()")
Another potential issue in ip6_finish_output2() is handled in a separate patch.
[1]
BUG: KASAN: slab-use-after-free in ip6_send_skb+0x18d/0x230 net/ipv6/ip6_output.c:1964 Read of size 8 at addr ffff88806dde4858 by task syz.1.380/6530 CPU: 1 UID: 0 PID: 6530 Comm: syz.1.380 Not tainted 6.11.0-rc3-syzkaller-00306-gdf6cbc62cc9b #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024 Call Trace: <TASK> __dump_stack lib/dump_stack.c:93 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 ip6_send_skb+0x18d/0x230 net/ipv6/ip6_output.c:1964 rawv6_push_pending_frames+0x75c/0x9e0 net/ipv6/raw.c:588 rawv6_sendmsg+0x19c7/0x23c0 net/ipv6/raw.c:926 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x1a6/0x270 net/socket.c:745 sock_write_iter+0x2dd/0x400 net/socket.c:1160 do_iter_readv_writev+0x60a/0x890 vfs_writev+0x37c/0xbb0 fs/read_write.c:971 do_writev+0x1b1/0x350 fs/read_write.c:1018 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f936bf79e79 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f936cd7f038 EFLAGS: 00000246 ORIG_RAX: 0000000000000014 RAX: ffffffffffffffda RBX: 00007f936c115f80 RCX: 00007f936bf79e79 RDX: 0000000000000001 RSI: 0000000020000040 RDI: 0000000000000004 RBP: 00007f936bfe7916 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f936c115f80 R15: 00007fff2860a7a8 </TASK> Allocated by task 6530: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 unpoison_slab_object mm/kasan/common.c:312 [inline] __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:338 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slub.c:3988 [inline] slab_alloc_node mm/slub.c:4037 [inline] kmem_cache_alloc_noprof+0x135/0x2a0 mm/slub.c:4044 dst_alloc+0x12b/0x190 net/core/dst.c:89 ip6_blackhole_route+0x59/0x340 net/ipv6/route.c:2670 make_blackhole net/xfrm/xfrm_policy.c:3120 [inline] xfrm_lookup_route+0xd1/0x1c0 net/xfrm/xfrm_policy.c:3313 ip6_dst_lookup_flow+0x13e/0x180 net/ipv6/ip6_output.c:1257 rawv6_sendmsg+0x1283/0x23c0 net/ipv6/raw.c:898 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x1a6/0x270 net/socket.c:745 ____sys_sendmsg+0x525/0x7d0 net/socket.c:2597 ___sys_sendmsg net/socket.c:2651 [inline] __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2680 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 45: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2252 [inline] slab_free mm/slub.c:4473 [inline] kmem_cache_free+0x145/0x350 mm/slub.c:4548 dst_destroy+0x2ac/0x460 net/core/dst.c:124 rcu_do_batch kernel/rcu/tree.c:2569 [inline] rcu_core+0xafd/0x1830 kernel/rcu/tree.c:2843 handle_softirqs+0x2c4/0x970 kernel/softirq.c:554 __do_softirq kernel/softirq.c:588 [inline] invoke_softirq kernel/softirq.c:428 [inline] __irq_exit_rcu+0xf4/0x1c0 kernel/softirq.c:637 irq_exit_rcu+0x9/0x30 kernel/softirq.c:649 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1043 [inline] sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1043 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702 Last potentially related work creation: kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47 __kasan_record_aux_stack+0xac/0xc0 mm/kasan/generic.c:541 __call_rcu_common kernel/rcu/tree.c:3106 [inline] call_rcu+0x167/0xa70 kernel/rcu/tree.c:3210 refdst_drop include/net/dst.h:263 [inline] skb_dst_drop include/net/dst.h:275 [inline] nf_ct_frag6_queue net/ipv6/netfilter/nf_conntrack_reasm.c:306 [inline] nf_ct_frag6_gather+0xb9a/0x2080 net/ipv6/netfilter/nf_conntrack_reasm.c:485 ipv6_defrag+0x2c8/0x3c0 net/ipv6/netfilter/nf_defrag_ipv6_hooks.c:67 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xc3/0x220 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] __ip6_local_out+0x6fa/0x800 net/ipv6/output_core.c:143 ip6_local_out+0x26/0x70 net/ipv6/output_core.c:153 ip6_send_skb+0x112/0x230 net/ipv6/ip6_output.c:1959 rawv6_push_pending_frames+0x75c/0x9e0 net/ipv6/raw.c:588 rawv6_sendmsg+0x19c7/0x23c0 net/ipv6/raw.c:926 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x1a6/0x270 net/socket.c:745 sock_write_iter+0x2dd/0x400 net/socket.c:1160 do_iter_readv_writev+0x60a/0x890
--- net/ipv6/ip6_output.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/ip6_output.c +2 -0
@@ -2023,6 +2023,7 @@ int ip6_send_skb(struct sk_buff *skb)struct rt6_info *rt = (struct rt6_info *)skb_dst (skb);int err; +rcu_read_lock (); err =ip6_local_out (net, skb->sk, skb);if (err) {if (err >0 )
@@ -2032,6 +2033,7 @@ int ip6_send_skb(struct sk_buff *skb) IPSTATS_MIB_OUTDISCARDS); } +rcu_read_unlock ();return err; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 269/341 ipv6: fix possible UAF in ip6_finish_output2()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit da273b377ae0d9bd255281ed3c2adb228321687b ]
If skb_expand_head() returns NULL, skb has been freed and associated dst/idev could also have been freed.
We need to hold rcu_read_lock() to make sure the dst and associated idev are alive.
--- net/ipv6/ip6_output.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv6/ip6_output.c +4 -0
@@ -70,11 +70,15 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff */* Be paranoid, rather than too clever. */ if (unlikely (hh_len >skb_headroom (skb)) && dev->header_ops) { +/* Make sure idev stays alive */ +rcu_read_lock (); skb =skb_expand_head (skb, hh_len);if (!skb) {IP6_INC_STATS (net, idev,IPSTATS_MIB_OUTDISCARDS ); +rcu_read_unlock ();return -ENOMEM ; } +rcu_read_unlock (); } hdr =ipv6_hdr (skb);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 270/341 ipv6: prevent possible UAF in ip6_xmit()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 2d5ff7e339d04622d8282661df36151906d0e1c7 ]
If skb_expand_head() returns NULL, skb has been freed and the associated dst/idev could also have been freed.
We must use rcu_read_lock() to prevent a possible UAF.
--- net/ipv6/ip6_output.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv6/ip6_output.c +4 -0
@@ -281,11 +281,15 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, head_room += opt->opt_nflen + opt->opt_flen;if (unlikely (head_room >skb_headroom (skb))) { +/* Make sure idev stays alive */ +rcu_read_lock (); skb =skb_expand_head (skb, head_room);if (!skb) {IP6_INC_STATS (net, idev,IPSTATS_MIB_OUTDISCARDS ); +rcu_read_unlock ();return -ENOBUFS ; } +rcu_read_unlock (); }if (opt) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 271/341 bnxt_en: Fix double DMA unmapping for XDP_REDIRECT
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Somnath Kotur <[email protected]>
[ Upstream commit 8baeef7616d5194045c5a6b97fd1246b87c55b13 ]
Remove the dma_unmap_page_attrs() call in the driver's XDP_REDIRECT code path. This should have been removed when we let the page pool handle the DMA mapping. This bug causes the warning:
WARNING: CPU: 7 PID: 59 at drivers/iommu/dma-iommu.c:1198 iommu_dma_unmap_page+0xd5/0x100 CPU: 7 PID: 59 Comm: ksoftirqd/7 Tainted: G W 6.8.0-1010-gcp #11-Ubuntu Hardware name: Dell Inc. PowerEdge R7525/0PYVT1, BIOS 2.15.2 04/02/2024 RIP: 0010:iommu_dma_unmap_page+0xd5/0x100 Code: 89 ee 48 89 df e8 cb f2 69 ff 48 83 c4 08 5b 41 5c 41 5d 41 5e 41 5f 5d 31 c0 31 d2 31 c9 31 f6 31 ff 45 31 c0 e9 ab 17 71 00 <0f> 0b 48 83 c4 08 5b 41 5c 41 5d 41 5e 41 5f 5d 31 c0 31 d2 31 c9 RSP: 0018:ffffab1fc0597a48 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff99ff838280c8 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffab1fc0597a78 R08: 0000000000000002 R09: ffffab1fc0597c1c R10: ffffab1fc0597cd3 R11: ffff99ffe375acd8 R12: 00000000e65b9000 R13: 0000000000000050 R14: 0000000000001000 R15: 0000000000000002 FS: 0000000000000000(0000) GS:ffff9a06efb80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000565c34c37210 CR3: 00000005c7e3e000 CR4: 0000000000350ef0 ? show_regs+0x6d/0x80 ? __warn+0x89/0x150 ? iommu_dma_unmap_page+0xd5/0x100 ? report_bug+0x16a/0x190 ? handle_bug+0x51/0xa0 ? exc_invalid_op+0x18/0x80 ? iommu_dma_unmap_page+0xd5/0x100 ? iommu_dma_unmap_page+0x35/0x100 dma_unmap_page_attrs+0x55/0x220 ? bpf_prog_4d7e87c0d30db711_xdp_dispatcher+0x64/0x9f bnxt_rx_xdp+0x237/0x520 [bnxt_en] bnxt_rx_pkt+0x640/0xdd0 [bnxt_en] __bnxt_poll_work+0x1a1/0x3d0 [bnxt_en] bnxt_poll+0xaa/0x1e0 [bnxt_en] __napi_poll+0x33/0x1e0 net_rx_action+0x18a/0x2f0
--- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +0 -5
@@ -297,11 +297,6 @@ bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons,* redirect is coming from a frame received by the * bnxt_en driver. */ - rx_buf = &rxr->rx_buf_ring[cons]; - mapping = rx_buf->mapping - bp->rx_dma_offset; -dma_unmap_page_attrs (&pdev->dev, mapping, -BNXT_RX_PAGE_SIZE , bp->rx_dir, -DMA_ATTR_WEAK_ORDERING );/* if we are unable to allocate a new buffer, abort and reuse */ if (bnxt_alloc_rx_data (bp, rxr, rxr->rx_prod,GFP_ATOMIC )) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 272/341 netfilter: flowtable: validate vlan header
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 6ea14ccb60c8ab829349979b22b58a941ec4a3ee ]
Ensure there is sufficient room to access the protocol field of the VLAN header, validate it once before the flowtable lookup.
=====================================================
BUG: KMSAN: uninit-value in nf_flow_offload_inet_hook+0x45a/0x5f0 net/netfilter/nf_flow_table_inet.c:32 nf_flow_offload_inet_hook+0x45a/0x5f0 net/netfilter/nf_flow_table_inet.c:32 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook_ingress include/linux/netfilter_netdev.h:34 [inline] nf_ingress net/core/dev.c:5440 [inline]
--- net/netfilter/nf_flow_table_inet.c | 3 +++ net/netfilter/nf_flow_table_ip.c | 3 +++ 2 files changed, 6 insertions(+)
net/netfilter/nf_flow_table_inet.c +3 -0
@@ -17,6 +17,9 @@ nf_flow_offload_inet_hook(void *priv, struct sk_buff *skb,switch (skb->protocol) {case htons (ETH_P_8021Q ): +if (!pskb_may_pull (skb,skb_mac_offset (skb) +sizeof (*veth))) +return NF_ACCEPT ; + veth = (struct vlan_ethhdr *)skb_mac_header (skb); proto = veth->h_vlan_encapsulated_proto;break ;
net/netfilter/nf_flow_table_ip.c +3 -0
@@ -281,6 +281,9 @@ static bool nf_flow_skb_encap_protocol(struct sk_buff *skb, __be16 proto,switch (skb->protocol) {case htons (ETH_P_8021Q ): +if (!pskb_may_pull (skb,skb_mac_offset (skb) +sizeof (*veth))) +return false; + veth = (struct vlan_ethhdr *)skb_mac_header (skb);if (veth->h_vlan_encapsulated_proto == proto) { *offset +=VLAN_HLEN ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 273/341 octeontx2-af: Fix CPT AF register offset calculation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bharat Bhushan <[email protected]>
[ Upstream commit af688a99eb1fc7ef69774665d61e6be51cea627a ]
Some CPT AF registers are per LF and others are global. Translation of PF/VF local LF slot number to actual LF slot number is required only for accessing perf LF registers. CPT AF global registers access do not require any LF slot number. Also, there is no reason CPT PF/VF to know actual lf's register offset.
Without this fix microcode loading will fail, VFs cannot be created and hardware is not usable.
--- .../ethernet/marvell/octeontx2/af/rvu_cpt.c | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c +11 -12
@@ -632,7 +632,9 @@ int rvu_mbox_handler_cpt_inline_ipsec_cfg(struct rvu *rvu,return ret; } -static bool is_valid_offset (struct rvu *rvu,struct cpt_rd_wr_reg_msg *req) +static bool validate_and_update_reg_offset (struct rvu *rvu, +struct cpt_rd_wr_reg_msg *req, +u64 *reg_offset) {u64 offset = req->reg_offset;int blkaddr, num_lfs, lf;
@@ -663,6 +665,11 @@ static bool is_valid_offset(struct rvu *rvu, struct cpt_rd_wr_reg_msg *req)if (lf <0 )return false; +/* Translate local LF's offset to global CPT LF's offset to +* access LFX register. +*/ + *reg_offset = (req->reg_offset &0xFF000 ) + (lf <<3 ); +return true; }else if (!(req->hdr.pcifunc &RVU_PFVF_FUNC_MASK )) {/* Registers that can be accessed from PF */
@@ -697,7 +704,7 @@ int rvu_mbox_handler_cpt_rd_wr_register(struct rvu *rvu, struct cpt_rd_wr_reg_msg *rsp) {u64 offset = req->reg_offset; -int blkaddr, lf; +int blkaddr; blkaddr =validate_and_get_cpt_blkaddr (req->blkaddr);if (blkaddr <0 )
@@ -708,18 +715,10 @@ int rvu_mbox_handler_cpt_rd_wr_register(struct rvu *rvu, !is_cpt_vf(rvu, req->hdr.pcifunc))return CPT_AF_ERR_ACCESS_DENIED ; -if (!is_valid_offset (rvu, req)) +if (!validate_and_update_reg_offset (rvu, req, &offset))return CPT_AF_ERR_ACCESS_DENIED ; -/* Translate local LF used by VFs to global CPT LF */ - lf =rvu_get_lf (rvu, &rvu->hw->block[blkaddr], req->hdr.pcifunc, - (offset &0xFFF ) >>3 ); - -/* Translate local LF's offset to global CPT LF's offset */ - offset &=0xFF000 ; - offset += lf <<3 ; - - rsp->reg_offset = offset; + rsp->reg_offset = req->reg_offset; rsp->ret_val = req->ret_val; rsp->is_write = req->is_write;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 274/341 net: xilinx: axienet: Always disable promiscuous mode
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Anderson <[email protected]>
[ Upstream commit 4ae738dfef2c0323752ab81786e2d298c9939321 ]
If promiscuous mode is disabled when there are fewer than four multicast addresses, then it will not be reflected in the hardware. Fix this by always clearing the promiscuous mode flag even when we program multicast addresses.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4 -0
@@ -430,6 +430,10 @@ static void axienet_set_multicast_list(struct net_device *ndev) }else if (!netdev_mc_empty (ndev)) {struct netdev_hw_addr *ha; + reg =axienet_ior (lp,XAE_FMI_OFFSET ); + reg &= ~XAE_FMI_PM_MASK ; +axienet_iow (lp,XAE_FMI_OFFSET , reg); + i =0 ;netdev_for_each_mc_addr (ha, ndev) {if (i >=XAE_MULTICAST_CAM_TABLE_NUM )
Signature · 1 line
2.43.0