5.15.111-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 144/371 arm64: kgdb: Set PSTATE.SS to 1 to re-enable single-step
In reply to Greg Kroah-HartmanFrom: Sumit Garg <[email protected]>
[ Upstream commit af6c0bd59f4f3ad5daad2f7b777954b1954551d5 ]
Currently only the first attempt to single-step has any effect. After that all further stepping remains "stuck" at the same program counter value.
Refer to the ARM Architecture Reference Manual (ARM DDI 0487E.a) D2.12, PSTATE.SS=1 should be set at each step before transferring the PE to the 'Active-not-pending' state. The problem here is PSTATE.SS=1 is not set since the second single-step.
After the first single-step, the PE transferes to the 'Inactive' state, with PSTATE.SS=0 and MDSCR.SS=1, thus PSTATE.SS won't be set to 1 due to kernel_active_single_step()=true. Then the PE transferes to the 'Active-pending' state when ERET and returns to the debugger by step exception.
Before this patch:
==================
Entering kdb (current=0xffff3376039f0000, pid 1) on processor 0 due to Keyboard Entry [0]kdb>
[0]kdb>
[0]kdb> bp write_sysrq_trigger
Instruction(i) BP #0 at 0xffffa45c13d09290 (write_sysrq_trigger)
is enabled addr at ffffa45c13d09290, hardtype=0 installed=0
[0]kdb> go
$ echo h > /proc/sysrq-trigger
Entering kdb (current=0xffff4f7e453f8000, pid 175) on processor 1 due to Breakpoint @ 0xffffad651a309290 [1]kdb> ss
Entering kdb (current=0xffff4f7e453f8000, pid 175) on processor 1 due to SS trap @ 0xffffad651a309294 [1]kdb> ss
Entering kdb (current=0xffff4f7e453f8000, pid 175) on processor 1 due to SS trap @ 0xffffad651a309294 [1]kdb>
After this patch:
=================
Entering kdb (current=0xffff6851c39f0000, pid 1) on processor 0 due to Keyboard Entry [0]kdb> bp write_sysrq_trigger
Instruction(i) BP #0 at 0xffffc02d2dd09290 (write_sysrq_trigger)
is enabled addr at ffffc02d2dd09290, hardtype=0 installed=0
[0]kdb> go
$ echo h > /proc/sysrq-trigger
Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to Breakpoint @ 0xffffc02d2dd09290 [1]kdb> ss
Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to SS trap @ 0xffffc02d2dd09294 [1]kdb> ss
Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to SS trap @ 0xffffc02d2dd09298 [1]kdb> ss
Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to SS trap @ 0xffffc02d2dd0929c [1]kdb>
--- arch/arm64/include/asm/debug-monitors.h | 1 + arch/arm64/kernel/debug-monitors.c | 5 +++++ arch/arm64/kernel/kgdb.c | 2 ++ 3 files changed, 8 insertions(+)
arch/arm64/include/asm/debug-monitors.h +1 -0
@@ -116,6 +116,7 @@ void user_regs_reset_single_step(struct user_pt_regs *regs,void kernel_enable_single_step (struct pt_regs *regs);void kernel_disable_single_step (void );int kernel_active_single_step (void ); +void kernel_rewind_single_step (struct pt_regs *regs);#ifdef CONFIG_HAVE_HW_BREAKPOINT int reinstall_suspended_bps (struct pt_regs *regs);
arch/arm64/kernel/debug-monitors.c +5 -0
@@ -438,6 +438,11 @@ int kernel_active_single_step(void) }NOKPROBE_SYMBOL (kernel_active_single_step); +void kernel_rewind_single_step (struct pt_regs *regs) +{ +set_regs_spsr_ss (regs); +} +/* ptrace API */ void user_enable_single_step (struct task_struct *task) {
arch/arm64/kernel/kgdb.c +2 -0
@@ -224,6 +224,8 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,*/ if (!kernel_active_single_step ())kernel_enable_single_step (linux_regs); +else +kernel_rewind_single_step (linux_regs); err =0 ;break ;default :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 145/371 debugobject: Prevent init race with static objects
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
[ Upstream commit 63a759694eed61025713b3e14dd827c8548daadc ]
Statically initialized objects are usually not initialized via the init() function of the subsystem. They are special cased and the subsystem provides a function to validate whether an object which is not yet tracked by debugobjects is statically initialized. This means the object is started to be tracked on first use, e.g. activation.
This works perfectly fine, unless there are two concurrent operations on that object. Schspa decoded the problem:
T0 T1
debug_object_assert_init(addr)
lock_hash_bucket()
obj = lookup_object(addr);
if (!obj) {
unlock_hash_bucket();
- > preemption
lock_subsytem_object(addr);
activate_object(addr)
lock_hash_bucket();
obj = lookup_object(addr);
if (!obj) {
unlock_hash_bucket();
if (is_static_object(addr))
init_and_track(addr);
lock_hash_bucket();
obj = lookup_object(addr);
obj->state = ACTIVATED;
unlock_hash_bucket();
subsys function modifies content of addr,
so static object detection does
not longer work.
unlock_subsytem_object(addr);
if (is_static_object(addr)) <- Fails
debugobject emits a warning and invokes the fixup function which
reinitializes the already active object in the worst case.This race exists forever, but was never observed until mod_timer() got a debug_object_assert_init() added which is outside of the timer base lock held section right at the beginning of the function to cover the lockless early exit points too.
Rework the code so that the lookup, the static object check and the tracking object association happens atomically under the hash bucket lock. This prevents the issue completely as all callers are serialized on the hash bucket lock and therefore cannot observe inconsistent state.
--- lib/debugobjects.c | 125 ++++++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 59 deletions(-)
lib/debugobjects.c +66 -59
@@ -219,10 +219,6 @@ static struct debug_obj *__alloc_object(struct hlist_head *list)return obj; } -/* -* Allocate a new object. If the pool is empty, switch off the debugger. -* Must be called with interrupts disabled. -*/ static struct debug_obj *alloc_object (void *addr,struct debug_bucket *b,const struct debug_obj_descr *descr) {
@@ -555,11 +551,49 @@ static void debug_object_is_on_stack(void *addr, int onstack)WARN_ON (1 ); } +static struct debug_obj *lookup_object_or_alloc (void *addr,struct debug_bucket *b, +const struct debug_obj_descr *descr, +bool onstack,bool alloc_ifstatic) +{ +struct debug_obj *obj =lookup_object (addr, b); +enum debug_obj_state state =ODEBUG_STATE_NONE ; + +if (likely (obj)) +return obj; + +/* +* debug_object_init() unconditionally allocates untracked +* objects. It does not matter whether it is a static object or +* not. +* +* debug_object_assert_init() and debug_object_activate() allow +* allocation only if the descriptor callback confirms that the +* object is static and considered initialized. For non-static +* objects the allocation needs to be done from the fixup callback. +*/ +if (unlikely (alloc_ifstatic)) { +if (!descr->is_static_object || !descr->is_static_object (addr)) +return ERR_PTR (-ENOENT ); +/* Statically allocated objects are considered initialized */ + state =ODEBUG_STATE_INIT ; + } + + obj =alloc_object (addr, b, descr); +if (likely (obj)) { + obj->state = state; +debug_object_is_on_stack (addr, onstack); +return obj; + } + +/* Out of memory. Do the cleanup outside of the locked region */ + debug_objects_enabled =0 ; +return NULL ; +} +static void __debug_object_init (void *addr,const struct debug_obj_descr *descr,int onstack) {enum debug_obj_state state; -bool check_stack = false;struct debug_bucket *db;struct debug_obj *obj;unsigned long flags;
@@ -575,16 +609,11 @@ __debug_object_init(void *addr, const struct debug_obj_descr *descr, int onstackraw_spin_lock_irqsave (&db->lock, flags); - obj =lookup_object (addr, db); -if (!obj) { - obj =alloc_object (addr, db, descr); -if (!obj) { - debug_objects_enabled =0 ; -raw_spin_unlock_irqrestore (&db->lock, flags); -debug_objects_oom (); -return ; - } - check_stack = true; + obj =lookup_object_or_alloc (addr, db, descr, onstack, false); +if (unlikely (!obj)) { +raw_spin_unlock_irqrestore (&db->lock, flags); +debug_objects_oom (); +return ; }switch (obj->state) {
@@ -610,8 +639,6 @@ __debug_object_init(void *addr, const struct debug_obj_descr *descr, int onstack }raw_spin_unlock_irqrestore (&db->lock, flags); -if (check_stack) -debug_object_is_on_stack (addr, onstack); }/**
@@ -651,14 +678,12 @@ EXPORT_SYMBOL_GPL(debug_object_init_on_stack);*/ int debug_object_activate (void *addr,const struct debug_obj_descr *descr) { +struct debug_obj o = { .object = addr, .state =ODEBUG_STATE_NOTAVAILABLE , .descr = descr };enum debug_obj_state state;struct debug_bucket *db;struct debug_obj *obj;unsigned long flags;int ret; -struct debug_obj o = { .object = addr, - .state =ODEBUG_STATE_NOTAVAILABLE , - .descr = descr };if (!debug_objects_enabled)return 0 ;
@@ -667,8 +692,8 @@ int debug_object_activate(void *addr, const struct debug_obj_descr *descr)raw_spin_lock_irqsave (&db->lock, flags); - obj =lookup_object (addr, db); -if (obj) { + obj =lookup_object_or_alloc (addr, db, descr, false, true); +if (likely (!IS_ERR_OR_NULL (obj))) {bool print_object = false;switch (obj->state) {
@@ -701,24 +726,16 @@ int debug_object_activate(void *addr, const struct debug_obj_descr *descr)raw_spin_unlock_irqrestore (&db->lock, flags); -/* -* We are here when a static object is activated. We -* let the type specific code confirm whether this is -* true or not. if true, we just make sure that the -* static object is tracked in the object tracker. If -* not, this must be a bug, so we try to fix it up. -*/ -if (descr->is_static_object && descr->is_static_object (addr)) { -/* track this static object */ -debug_object_init (addr, descr); -debug_object_activate (addr, descr); - }else { -debug_print_object (&o,"activate" ); - ret =debug_object_fixup (descr->fixup_activate, addr, -ODEBUG_STATE_NOTAVAILABLE ); -return ret ?0 : -EINVAL ; +/* If NULL the allocation has hit OOM */ +if (!obj) { +debug_objects_oom (); +return 0 ; } -return 0 ; + +/* Object is neither static nor tracked. It's not initialized */ +debug_print_object (&o,"activate" ); + ret =debug_object_fixup (descr->fixup_activate, addr,ODEBUG_STATE_NOTAVAILABLE ); +return ret ?0 : -EINVAL ; }EXPORT_SYMBOL_GPL (debug_object_activate);
@@ -872,6 +889,7 @@ EXPORT_SYMBOL_GPL(debug_object_free);*/ void debug_object_assert_init (void *addr,const struct debug_obj_descr *descr) { +struct debug_obj o = { .object = addr, .state =ODEBUG_STATE_NOTAVAILABLE , .descr = descr };struct debug_bucket *db;struct debug_obj *obj;unsigned long flags;
@@ -882,31 +900,20 @@ void debug_object_assert_init(void *addr, const struct debug_obj_descr *descr) db =get_bucket ((unsigned long ) addr);raw_spin_lock_irqsave (&db->lock, flags); + obj =lookup_object_or_alloc (addr, db, descr, false, true); +raw_spin_unlock_irqrestore (&db->lock, flags); +if (likely (!IS_ERR_OR_NULL (obj))) +return ; - obj =lookup_object (addr, db); +/* If NULL the allocation has hit OOM */ if (!obj) { -struct debug_obj o = { .object = addr, - .state =ODEBUG_STATE_NOTAVAILABLE , - .descr = descr }; - -raw_spin_unlock_irqrestore (&db->lock, flags); -/* -* Maybe the object is static, and we let the type specific -* code confirm. Track this static object if true, else invoke -* fixup. -*/ -if (descr->is_static_object && descr->is_static_object (addr)) { -/* Track this static object */ -debug_object_init (addr, descr); - }else { -debug_print_object (&o,"assert_init" ); -debug_object_fixup (descr->fixup_assert_init, addr, -ODEBUG_STATE_NOTAVAILABLE ); - } +debug_objects_oom ();return ; } -raw_spin_unlock_irqrestore (&db->lock, flags); +/* Object is neither tracked nor static. It's not initialized. */ +debug_print_object (&o,"assert_init" ); +debug_object_fixup (descr->fixup_assert_init, addr,ODEBUG_STATE_NOTAVAILABLE ); }EXPORT_SYMBOL_GPL (debug_object_assert_init);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 146/371 drm/i915: Make intel_get_crtc_new_encoder() less oopsy
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
[ Upstream commit 631420b06597a33c72b6dcef78d1c2dea17f452d ]
The point of the WARN was to print something, not oops straight up. Currently that is precisely what happens if we can't find the connector for the crtc in the atomic state. Get the dev pointer from the atomic state instead of the potentially NULL encoder to avoid that.
--- drivers/gpu/drm/i915/display/intel_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_display.c +1 -1
@@ -2303,7 +2303,7 @@ intel_get_crtc_new_encoder(const struct intel_atomic_state *state, num_encoders++; } -drm_WARN (encoder->base.dev, num_encoders !=1 , +drm_WARN (state->base.dev, num_encoders !=1 ,"%d encoders for pipe %c\n" , num_encoders,pipe_name (crtc->pipe));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 147/371 tick/common: Align tick period with the HZ tick.
In reply to Greg Kroah-HartmanFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit e9523a0d81899361214d118ad60ef76f0e92f71d ]
With HIGHRES enabled tick_sched_timer() is programmed every jiffy to expire the timer_list timers. This timer is programmed accurate in respect to CLOCK_MONOTONIC so that 0 seconds and nanoseconds is the first tick and the next one is 1000/CONFIG_HZ ms later. For HZ=250 it is every 4 ms and so based on the current time the next tick can be computed.
This accuracy broke since the commit mentioned below because the jiffy based clocksource is initialized with higher accuracy in read_persistent_wall_and_boot_offset(). This higher accuracy is inherited during the setup in tick_setup_device(). The timer still fires every 4ms with HZ=250 but timer is no longer aligned with CLOCK_MONOTONIC with 0 as it origin but has an offset in the us/ns part of the timestamp. The offset differs with every boot and makes it impossible for user land to align with the tick.
Align the tick period with CLOCK_MONOTONIC ensuring that it is always a multiple of 1000/CONFIG_HZ ms.
--- kernel/time/tick-common.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
kernel/time/tick-common.c +11 -1
@@ -218,9 +218,19 @@ static void tick_setup_device(struct tick_device *td,* this cpu: */ if (tick_do_timer_cpu ==TICK_DO_TIMER_BOOT ) { +ktime_t next_p; +u32 rem; + tick_do_timer_cpu = cpu; - tick_next_period =ktime_get (); + next_p =ktime_get (); +div_u64_rem (next_p,TICK_NSEC , &rem); +if (rem) { + next_p -= rem; + next_p +=TICK_NSEC ; + } + + tick_next_period = next_p;#ifdef CONFIG_NO_HZ_FULL /* * The boot CPU may be nohz_full, in which case set
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 148/371 cpufreq: use correct unit when verify cur freq
In reply to Greg Kroah-HartmanFrom: Sanjay Chandrashekara <[email protected]>
[ Upstream commit 44295af5019f1997d038ad2611086a2d1e2af167 ]
cpufreq_verify_current_freq checks() if the frequency returned by the hardware has a slight delta with the valid frequency value last set and returns "policy->cur" if the delta is within "1 MHz". In the comparison, "policy->cur" is in "kHz" but it's compared against HZ_PER_MHZ. So, the comparison range becomes "1 GHz".
Fix this by comparing against KHZ_PER_MHZ instead of HZ_PER_MHZ.
--- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -1
@@ -1709,7 +1709,7 @@ static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, b* MHz. In such cases it is better to avoid getting into * unnecessary frequency updates. */ -if (abs (policy->cur - new_freq) <HZ_PER_MHZ ) +if (abs (policy->cur - new_freq) <KHZ_PER_MHZ )return policy->cur;cpufreq_out_of_sync (policy, new_freq);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 149/371 hwmon: (pmbus/fsp-3y) Fix functionality bitmask in FSP-3Y YM-2151E
In reply to Greg Kroah-HartmanFrom: Tomáš Pecka <[email protected]>
[ Upstream commit 93822f5161a2dc57a60b95b35b3cb8589f53413e ]
The bit flags in pmbus_driver_info functionality for YM-2151E chip were joined with a comma operator instead of a bitwise OR. This means that the last constant PMBUS_HAVE_IIN was not OR-ed with the other PM_BUS_HAVE_* constants for this page but it initialized the next element of the func array (which was not accessed from anywhere because of the number of pages).
However, there is no need for setting PMBUS_HAVE_IIN in the 5Vsb page because this command does not seem to be paged. Obviously, the device only has one IIN sensor, so it doesn't make sense to query it again from the second page.
--- drivers/hwmon/pmbus/fsp-3y.c | 1 - 1 file changed, 1 deletion(-)
drivers/hwmon/pmbus/fsp-3y.c +0 -1
@@ -180,7 +180,6 @@ static struct pmbus_driver_info fsp3y_info[] = { PMBUS_HAVE_FAN12, .func[YM2151_PAGE_5VSB_LOG ] = PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT, -PMBUS_HAVE_IIN , .read_word_data = fsp3y_read_word_data, .read_byte_data = fsp3y_read_byte_data, },
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 150/371 wifi: ath6kl: minor fix for allocation size
In reply to Greg Kroah-HartmanFrom: Alexey V. Vissarionov <[email protected]>
[ Upstream commit 778f83f889e7fca37780d9640fcbd0229ae38eaa ]
Although the "param" pointer occupies more or equal space compared to "*param", the allocation size should use the size of variable itself.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/wireless/ath/ath6kl/bmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath6kl/bmi.c +1 -1
@@ -246,7 +246,7 @@ int ath6kl_bmi_execute(struct ath6kl *ar, u32 addr, u32 *param)return -EACCES ; } - size =sizeof (cid) +sizeof (addr) +sizeof (param); + size =sizeof (cid) +sizeof (addr) +sizeof (*param);if (size > ar->bmi.max_cmd_size) {WARN_ON (1 );return -EINVAL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 151/371 wifi: ath9k: hif_usb: fix memory leak of remain_skbs
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
[ Upstream commit 7654cc03eb699297130b693ec34e25f77b17c947 ]
hif_dev->remain_skb is allocated and used exclusively in ath9k_hif_usb_rx_stream(). It is implied that an allocated remain_skb is processed and subsequently freed (in error paths) only during the next call of ath9k_hif_usb_rx_stream().
So, if the urbs are deallocated between those two calls due to the device deinitialization or suspend, it is possible that ath9k_hif_usb_rx_stream() is not called next time and the allocated remain_skb is leaked. Our local Syzkaller instance was able to trigger that.
remain_skb makes sense when receiving two consecutive urbs which are logically linked together, i.e. a specific data field from the first skb indicates a cached skb to be allocated, memcpy'd with some data and subsequently processed in the next call to ath9k_hif_usb_rx_stream(). Urbs deallocation supposedly makes that link irrelevant so we need to free the cached skb in those cases.
Fix the leak by introducing a function to explicitly free remain_skb (if it is not NULL) when the rx urbs have been deallocated. remain_skb is NULL when it has not been allocated at all (hif_dev struct is kzalloced) or when it has been processed in next call to ath9k_hif_usb_rx_stream().
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/net/wireless/ath/ath9k/hif_usb.c +19 -0
@@ -534,6 +534,24 @@ static struct ath9k_htc_hif hif_usb = { .send = hif_usb_send, }; +/* Need to free remain_skb allocated in ath9k_hif_usb_rx_stream +* in case ath9k_hif_usb_rx_stream wasn't called next time to +* process the buffer and subsequently free it. +*/ +static void ath9k_hif_usb_free_rx_remain_skb (struct hif_device_usb *hif_dev) +{ +unsigned long flags; + +spin_lock_irqsave (&hif_dev->rx_lock, flags); +if (hif_dev->remain_skb) { +dev_kfree_skb_any (hif_dev->remain_skb); + hif_dev->remain_skb =NULL ; + hif_dev->rx_remain_len =0 ; +RX_STAT_INC (hif_dev, skb_dropped); + } +spin_unlock_irqrestore (&hif_dev->rx_lock, flags); +} +static void ath9k_hif_usb_rx_stream (struct hif_device_usb *hif_dev,struct sk_buff *skb) {
@@ -868,6 +886,7 @@ static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev)static void ath9k_hif_usb_dealloc_rx_urbs (struct hif_device_usb *hif_dev) {usb_kill_anchored_urbs (&hif_dev->rx_submitted); +ath9k_hif_usb_free_rx_remain_skb (hif_dev); }static int ath9k_hif_usb_alloc_rx_urbs (struct hif_device_usb *hif_dev)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 152/371 wifi: ath5k: fix an off by one check in ath5k_eeprom_read_freq_list()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 4c856ee12df85aabd437c3836ed9f68d94268358 ]
This loop checks that i < max at the start of loop but then it does i++ which could put it past the end of the array. It's harmless to check again and prevent a potential out of bounds.
--- drivers/net/wireless/ath/ath5k/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath5k/eeprom.c +1 -1
@@ -529,7 +529,7 @@ ath5k_eeprom_read_freq_list(struct ath5k_hw *ah, int *offset, int max, ee->ee_n_piers[mode]++; freq2 = (val >>8 ) &0xff ; -if (!freq2) +if (!freq2 || i >= max)break ; pc[i++].freq = ath5k_eeprom_bin2freq(ee,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 153/371 wifi: brcmfmac: support CQM RSSI notification with older firmware
In reply to Greg Kroah-HartmanFrom: John Keeping <[email protected]>
[ Upstream commit ec52d77d077529f198fd874c550a26b9cc86a331 ]
Using the BCM4339 firmware from linux-firmware (version "BCM4339/2 wl0:
Sep 5 2019 11:05:52 version 6.37.39.113 (r722271 CY)" from cypress/cyfmac4339-sdio.bin) the RSSI respose is only 4 bytes, which results in an error being logged.
It seems that older devices send only the RSSI field and neither SNR nor noise is included. Handle this by accepting a 4 byte message and reading only the RSSI from it.
--- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +8 -6
@@ -6212,18 +6212,20 @@ static s32 brcmf_notify_rssi(struct brcmf_if *ifp, {struct brcmf_cfg80211_vif *vif = ifp->vif;struct brcmf_rssi_be *info = data; -s32 rssi, snr, noise; +s32 rssi, snr =0 , noise =0 ;s32 low, high, last; -if (e->datalen <sizeof (*info)) { +if (e->datalen >=sizeof (*info)) { + rssi =be32_to_cpu (info->rssi); + snr =be32_to_cpu (info->snr); + noise =be32_to_cpu (info->noise); + }else if (e->datalen >=sizeof (rssi)) { + rssi =be32_to_cpu (*(__be32 *)data); + }else {brcmf_err ("insufficient RSSI event data\n" );return 0 ; } - rssi =be32_to_cpu (info->rssi); - snr =be32_to_cpu (info->snr); - noise =be32_to_cpu (info->noise); - low = vif->cqm_rssi_low; high = vif->cqm_rssi_high; last = vif->cqm_rssi_last;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 154/371 wifi: ath6kl: reduce WARN to dev_dbg() in callback
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
[ Upstream commit 75c4a8154cb6c7239fb55d5550f481f6765fb83c ]
The warn is triggered on a known race condition, documented in the code above the test, that is correctly handled. Using WARN() hinders automated testing. Reducing severity.
--- drivers/net/wireless/ath/ath6kl/htc_pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/htc_pipe.c +2 -2
@@ -960,8 +960,8 @@ static int ath6kl_htc_pipe_rx_complete(struct ath6kl *ar, struct sk_buff *skb,* Thus the possibility of ar->htc_target being NULL * via ath6kl_recv_complete -> ath6kl_usb_io_comp_work. */ -if (WARN_ON_ONCE (!target)) { -ath6kl_err ("Target not yet initialized\n" ); +if (!target) { +ath6kl_dbg (ATH6KL_DBG_HTC ,"Target not yet initialized\n" ); status = -EINVAL ; goto free_skb; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 155/371 tools: bpftool: Remove invalid \ json escape
In reply to Greg Kroah-HartmanFrom: Luis Gerhorst <[email protected]>
[ Upstream commit c679bbd611c08b0559ffae079330bc4e5574696a ]
RFC8259 ("The JavaScript Object Notation (JSON) Data Interchange Format") only specifies \", \\, \/, \b, \f, \n, \r, and \r as valid two-character escape sequences. This does not include \', which is not required in JSON because it exclusively uses double quotes as string separators.
Solidus (/) may be escaped, but does not have to. Only reverse solidus (\), double quotes ("), and the control characters have to be escaped. Therefore, with this fix, bpftool correctly supports all valid two-character escape sequences (but still does not support characters that require multi-character escape sequences).
Witout this fix, attempting to load a JSON file generated by bpftool using Python 3.10.6's default json.load() may fail with the error "Invalid \escape" if the file contains the invalid escaped single quote (\').
--- tools/bpf/bpftool/json_writer.c | 3 --- 1 file changed, 3 deletions(-)
tools/bpf/bpftool/json_writer.c +0 -3
@@ -80,9 +80,6 @@ static void jsonw_puts(json_writer_t *self, const char *str)case '"' :fputs ("\\\"" , self->out);break ; -case '\'' : -fputs ("\\\'" , self->out); -break ;default :putc (*str, self->out); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 156/371 wifi: rtw88: mac: Return the original error from rtw_pwr_seq_parser()
In reply to Greg Kroah-HartmanFrom: Martin Blumenstingl <[email protected]>
[ Upstream commit b7ed9fa2cb76ca7a3c3cd4a6d35748fe1fbda9f6 ]
rtw_pwr_seq_parser() calls rtw_sub_pwr_seq_parser() which can either return -EBUSY, -EINVAL or 0. Propagate the original error code instead of unconditionally returning -EBUSY in case of an error.
--- drivers/net/wireless/realtek/rtw88/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/mac.c +1 -1
@@ -233,7 +233,7 @@ static int rtw_pwr_seq_parser(struct rtw_dev *rtwdev, ret =rtw_sub_pwr_seq_parser (rtwdev, intf_mask, cut_mask, cmd);if (ret) -return -EBUSY ; +return ret; idx++; }while (1 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 157/371 wifi: rtw88: mac: Return the original error from rtw_mac_power_switch()
In reply to Greg Kroah-HartmanFrom: Martin Blumenstingl <[email protected]>
[ Upstream commit 15c8e267dfa62f207ee1db666c822324e3362b84 ]
rtw_mac_power_switch() calls rtw_pwr_seq_parser() which can return -EINVAL, -EBUSY or 0. Propagate the original error code instead of unconditionally returning -EINVAL in case of an error.
--- drivers/net/wireless/realtek/rtw88/mac.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/mac.c +4 -2
@@ -247,6 +247,7 @@ static int rtw_mac_power_switch(struct rtw_dev *rtwdev, bool pwr_on)const struct rtw_pwr_seq_cmd **pwr_seq;u8 rpwm;bool cur_pwr; +int ret;if (rtw_chip_wcpu_11ac (rtwdev)) { rpwm =rtw_read8 (rtwdev, rtwdev->hci.rpwm_addr);
@@ -270,8 +271,9 @@ static int rtw_mac_power_switch(struct rtw_dev *rtwdev, bool pwr_on)return -EALREADY ; pwr_seq = pwr_on ? chip->pwr_on_seq : chip->pwr_off_seq; -if (rtw_pwr_seq_parser (rtwdev, pwr_seq)) -return -EINVAL ; + ret =rtw_pwr_seq_parser (rtwdev, pwr_seq); +if (ret) +return ret;return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 158/371 bpf: take into account liveness when propagating precision
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 52c2b005a3c18c565fc70cfd0ca49375f301e952 ]
When doing state comparison, if old state has register that is not marked as REG_LIVE_READ, then we just skip comparison, regardless what's the state of corresponing register in current state. This is because not REG_LIVE_READ register is irrelevant for further program execution and correctness. All good here.
But when we get to precision propagation, after two states were declared equivalent, we don't take into account old register's liveness, and thus attempt to propagate precision for register in current state even if that register in old state was not REG_LIVE_READ anymore. This is bad, because register in current state could be anything at all and this could cause -EFAULT due to internal logic bugs.
Fix by taking into account REG_LIVE_READ liveness mark to keep the logic in state comparison in sync with precision propagation.
--- kernel/bpf/verifier.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/bpf/verifier.c +4 -2
@@ -10616,7 +10616,8 @@ static int propagate_precision(struct bpf_verifier_env *env, state_reg = state->regs;for (i =0 ; i <BPF_REG_FP ; i++, state_reg++) {if (state_reg->type !=SCALAR_VALUE || - !state_reg->precise) + !state_reg->precise || + !(state_reg->live ®_LIVE_READ ))continue ;if (env->log.level &BPF_LOG_LEVEL2 )verbose (env,"frame %d: propagating r%d\n" , i, fr);
@@ -10630,7 +10631,8 @@ static int propagate_precision(struct bpf_verifier_env *env,continue ; state_reg = &state->stack[i].spilled_ptr;if (state_reg->type !=SCALAR_VALUE || - !state_reg->precise) + !state_reg->precise || + !(state_reg->live ®_LIVE_READ ))continue ;if (env->log.level &BPF_LOG_LEVEL2 ) verbose(env, "frame %d: propagating fp%d\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 159/371 bpf: fix precision propagation verbose logging
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 34f0677e7afd3a292bc1aadda7ce8e35faedb204 ]
Fix wrong order of frame index vs register/slot index in precision propagation verbose (level 2) output. It's wrong and very confusing as is.
--- kernel/bpf/verifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/verifier.c +2 -2
@@ -10620,7 +10620,7 @@ static int propagate_precision(struct bpf_verifier_env *env, !(state_reg->live & REG_LIVE_READ))continue ;if (env->log.level &BPF_LOG_LEVEL2 ) -verbose (env,"frame %d: propagating r%d\n" , i, fr); +verbose (env,"frame %d: propagating r%d\n" , fr, i); err =mark_chain_precision_frame (env, fr, i);if (err <0 )return err;
@@ -10636,7 +10636,7 @@ static int propagate_precision(struct bpf_verifier_env *env,continue ;if (env->log.level &BPF_LOG_LEVEL2 )verbose (env,"frame %d: propagating fp%d\n" , - (-i -1 ) *BPF_REG_SIZE , fr); + fr, (-i -1 ) *BPF_REG_SIZE ); err =mark_chain_precision_stack_frame (env, fr, i);if (err <0 )return err;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 160/371 scm: fix MSG_CTRUNC setting condition for SO_PASSSEC
In reply to Greg Kroah-HartmanFrom: Alexander Mikhalitsyn <[email protected]>
[ Upstream commit a02d83f9947d8f71904eda4de046630c3eb6802c ]
Currently, kernel would set MSG_CTRUNC flag if msg_control buffer wasn't provided and SO_PASSCRED was set or if there was pending SCM_RIGHTS.
For some reason we have no corresponding check for SO_PASSSEC.
In the recvmsg(2) doc we have:
MSG_CTRUNC
indicates that some control data was discarded due to lack of space in the buffer for ancillary data.
So, we need to set MSG_CTRUNC flag for all types of SCM.
This change can break applications those don't check MSG_CTRUNC flag.
v2:
- commit message was rewritten according to Eric's suggestion
--- include/net/scm.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
include/net/scm.h +12 -1
@@ -105,16 +105,27 @@ static inline void scm_passec(struct socket *sock, struct msghdr *msg, struct sc } } } + +static inline bool scm_has_secdata (struct socket *sock) +{ +return test_bit (SOCK_PASSSEC , &sock->flags); +}#else static inline void scm_passec (struct socket *sock,struct msghdr *msg,struct scm_cookie *scm) { } + +static inline bool scm_has_secdata (struct socket *sock) +{ +return false; +}#endif /* CONFIG_SECURITY_NETWORK */ static __inline__void scm_recv (struct socket *sock,struct msghdr *msg,struct scm_cookie *scm,int flags) {if (!msg->msg_control) { -if (test_bit (SOCK_PASSCRED , &sock->flags) || scm->fp) +if (test_bit (SOCK_PASSCRED , &sock->flags) || scm->fp || +scm_has_secdata (sock)) msg->msg_flags |=MSG_CTRUNC ;scm_destroy (scm);return ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 161/371 selftests/bpf: Fix a fd leak in an error path in network_helpers.c
In reply to Greg Kroah-HartmanFrom: Martin KaFai Lau <[email protected]>
[ Upstream commit 226efec2b0efad60d4a6c4b2c3a8710dafc4dc21 ]
In __start_server, it leaks a fd when setsockopt(SO_REUSEPORT) fails. This patch fixes it.
--- tools/testing/selftests/bpf/network_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/network_helpers.c +1 -1
@@ -84,7 +84,7 @@ static int __start_server(int type, const struct sockaddr *addr,if (reuseport &&setsockopt (fd,SOL_SOCKET ,SO_REUSEPORT , &on,sizeof (on))) {log_err ("Failed to set SO_REUSEPORT" ); -return -1 ; + goto error_close; }if (bind (fd, addr, addrlen) <0 ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 162/371 bpf: Remove misleading spec_v1 check on var-offset stack read
In reply to Greg Kroah-HartmanFrom: Luis Gerhorst <[email protected]>
[ Upstream commit 082cdc69a4651dd2a77539d69416a359ed1214f5 ]
For every BPF_ADD/SUB involving a pointer, adjust_ptr_min_max_vals() ensures that the resulting pointer has a constant offset if bypass_spec_v1 is false. This is ensured by calling sanitize_check_bounds() which in turn calls check_stack_access_for_ptr_arithmetic(). There, -EACCESS is returned if the register's offset is not constant, thereby rejecting the program.
In summary, an unprivileged user must never be able to create stack pointers with a variable offset. That is also the case, because a respective check in check_stack_write() is missing. If they were able to create a variable-offset pointer, users could still use it in a stack-write operation to trigger unsafe speculative behavior [1].
Because unprivileged users must already be prevented from creating variable-offset stack pointers, viable options are to either remove this check (replacing it with a clarifying comment), or to turn it into a "verifier BUG"-message, also adding a similar check in check_stack_write() (for consistency, as a second-level defense). This patch implements the first option to reduce verifier bloat.
This check was introduced by commit 01f810ace9ed ("bpf: Allow variable-offset stack access") which correctly notes that "variable-offset reads and writes are disallowed (they were already disallowed for the indirect access case) because the speculative execution checking code doesn't support them". However, it does not further discuss why the check in check_stack_read() is necessary. The code which made this check obsolete was also introduced in this commit.
I have compiled ~650 programs from the Linux selftests, Linux samples, Cilium, and libbpf/examples projects and confirmed that none of these trigger the check in check_stack_read() [2]. Instead, all of these programs are, as expected, already rejected when constructing the variable-offset pointers. Note that the check in check_stack_access_for_ptr_arithmetic() also prints "off=%d" while the code removed by this patch does not (the error removed does not appear in the "verification_error" values). For reproducibility, the repository linked includes the raw data and scripts used to create the plot.
[1] https://arxiv.org/pdf/1807.03757.pdf
[2] https://gitlab.cs.fau.de/un65esoq/bpf-spectre/-/raw/53dc19fcf459c186613b1156a81504b39c8d49db/data/plots/23-02-26_23-56_bpftool/bpftool/0004-errors.pdf?inline=false
--- kernel/bpf/verifier.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
kernel/bpf/verifier.c +6 -10
@@ -3114,17 +3114,13 @@ static int check_stack_read(struct bpf_verifier_env *env, }/* Variable offset is prohibited for unprivileged mode for simplicity * since it requires corresponding support in Spectre masking for stack -* ALU. See also retrieve_ptr_limit(). +* ALU. See also retrieve_ptr_limit(). The check in +* check_stack_access_for_ptr_arithmetic() called by +* adjust_ptr_min_max_vals() prevents users from creating stack pointers +* with variable offsets, therefore no check is required here. Further, +* just checking it here would be insufficient as speculative stack +* writes could still lead to unsafe speculative behaviour. */ -if (!env->bypass_spec_v1 && var_off) { -char tn_buf[48 ]; - -tnum_strn (tn_buf,sizeof (tn_buf), reg->var_off); -verbose (env,"R%d variable offset stack access prohibited for !root, var_off=%s\n" , - ptr_regno, tn_buf); -return -EACCES ; - } -if (!var_off) { off += reg->var_off.value; err = check_stack_read_fixed_off(env, state, off, size,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 163/371 net: pcs: xpcs: remove double-read of link state when using AN
In reply to Greg Kroah-HartmanFrom: Russell King (Oracle) <[email protected]>
[ Upstream commit ef63461caf427a77a04620d74ba90035a712af9c ]
Phylink does not want the current state of the link when reading the PCS link state - it wants the latched state. Don't double-read the MII status register. Phylink will re-read as necessary to capture transient link-down events as of dbae3388ea9c ("net: phylink: Force retrigger in case of latched link-fail indicator").
The above referenced commit is a dependency for this change, and thus this change should not be backported to any kernel that does not contain the above referenced commit.
--- drivers/net/pcs/pcs-xpcs.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/net/pcs/pcs-xpcs.c +2 -11
@@ -309,7 +309,7 @@ static int xpcs_read_fault_c73(struct dw_xpcs *xpcs,return 0 ; } -static int xpcs_read_link_c73 (struct dw_xpcs *xpcs,bool an) +static int xpcs_read_link_c73 (struct dw_xpcs *xpcs) {bool link = true;int ret;
@@ -321,15 +321,6 @@ static int xpcs_read_link_c73(struct dw_xpcs *xpcs, bool an)if (!(ret &MDIO_STAT1_LSTATUS )) link = false; -if (an) { - ret =xpcs_read (xpcs,MDIO_MMD_AN ,MDIO_STAT1 ); -if (ret <0 ) -return ret; - -if (!(ret &MDIO_STAT1_LSTATUS )) - link = false; - } -return link; }
@@ -847,7 +838,7 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs,int ret;/* Link needs to be read first ... */ - state->link =xpcs_read_link_c73 (xpcs, state->an_enabled) >0 ?1 :0 ; + state->link =xpcs_read_link_c73 (xpcs) >0 ?1 :0 ;/* ... and then we check the faults. */ ret =xpcs_read_fault_c73 (xpcs, state);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 164/371 vlan: partially enable SIOCSHWTSTAMP in container
In reply to Greg Kroah-HartmanFrom: Vadim Fedorenko <[email protected]>
[ Upstream commit 731b73dba359e3ff00517c13aa0daa82b34ff466 ]
Setting timestamp filter was explicitly disabled on vlan devices in containers because it might affect other processes on the host. But it's absolutely legit in case when real device is in the same namespace.
--- net/8021q/vlan_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/8021q/vlan_dev.c +1 -1
@@ -365,7 +365,7 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)switch (cmd) {case SIOCSHWTSTAMP : -if (!net_eq (dev_net (dev), &init_net)) +if (!net_eq (dev_net (dev),dev_net (real_dev)))break ; fallthrough;case SIOCGMIIPHY :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 165/371 net/packet: annotate accesses to po->xmit
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit b9d83ab8a708f23a4001d60e9d8d0b3be3d9f607 ]
po->xmit can be set from setsockopt(PACKET_QDISC_BYPASS), while read locklessly.
Use READ_ONCE()/WRITE_ONCE() to avoid potential load/store tearing issues.
--- net/packet/af_packet.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/packet/af_packet.c +8 -4
@@ -271,7 +271,8 @@ static void packet_cached_dev_reset(struct packet_sock *po)static bool packet_use_direct_xmit (const struct packet_sock *po) { -return po->xmit == packet_direct_xmit; +/* Paired with WRITE_ONCE() in packet_setsockopt() */ +return READ_ONCE (po->xmit) == packet_direct_xmit; }static u16 packet_pick_tx_queue (struct sk_buff *skb)
@@ -2828,7 +2829,8 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)packet_inc_pending (&po->tx_ring); status =TP_STATUS_SEND_REQUEST ; - err = po->xmit (skb); +/* Paired with WRITE_ONCE() in packet_setsockopt() */ + err =READ_ONCE (po->xmit)(skb);if (unlikely (err !=0 )) {if (err >0 ) err =net_xmit_errno (err);
@@ -3031,7 +3033,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)virtio_net_hdr_set_proto (skb, &vnet_hdr); } - err = po->xmit (skb); +/* Paired with WRITE_ONCE() in packet_setsockopt() */ + err =READ_ONCE (po->xmit)(skb);if (unlikely (err !=0 )) {if (err >0 ) err =net_xmit_errno (err);
@@ -3976,7 +3979,8 @@ packet_setsockopt(struct socket *sock, int level, int optname, sockptr_t optval,if (copy_from_sockptr (&val, optval,sizeof (val)))return -EFAULT ; - po->xmit = val ? packet_direct_xmit : dev_queue_xmit; +/* Paired with all lockless reads of po->xmit */ +WRITE_ONCE (po->xmit, val ? packet_direct_xmit : dev_queue_xmit);return 0 ; }default :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 166/371 net/packet: convert po->origdev to an atomic flag
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit ee5675ecdf7a4e713ed21d98a70c2871d6ebed01 ]
syzbot/KCAN reported that po->origdev can be read
while another thread is changing its value.
We can avoid this splat by converting this field
to an actual bit.
Following patches will convert remaining 1bit fields.
--- net/packet/af_packet.c | 10 ++++------ net/packet/diag.c | 2 +- net/packet/internal.h | 22 +++++++++++++++++++++- 3 files changed, 26 insertions(+), 8 deletions(-)
net/packet/af_packet.c +4 -6
@@ -2149,7 +2149,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, sll = &PACKET_SKB_CB (skb)->sa.ll; sll->sll_hatype = dev->type; sll->sll_pkttype = skb->pkt_type; -if (unlikely (po->origdev)) +if (unlikely (packet_sock_flag (po,PACKET_SOCK_ORIGDEV ))) sll->sll_ifindex = orig_dev->ifindex;else sll->sll_ifindex = dev->ifindex;
@@ -2422,7 +2422,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, sll->sll_hatype = dev->type; sll->sll_protocol = skb->protocol; sll->sll_pkttype = skb->pkt_type; -if (unlikely (po->origdev)) +if (unlikely (packet_sock_flag (po,PACKET_SOCK_ORIGDEV ))) sll->sll_ifindex = orig_dev->ifindex;else sll->sll_ifindex = dev->ifindex;
@@ -3883,9 +3883,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, sockptr_t optval,if (copy_from_sockptr (&val, optval,sizeof (val)))return -EFAULT ; -lock_sock (sk); - po->origdev = !!val; -release_sock (sk); +packet_sock_flag_set (po,PACKET_SOCK_ORIGDEV , val);return 0 ; }case PACKET_VNET_HDR :
@@ -4034,7 +4032,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, val = po->auxdata;break ;case PACKET_ORIGDEV : - val = po->origdev; + val =packet_sock_flag (po,PACKET_SOCK_ORIGDEV );break ;case PACKET_VNET_HDR : val = po->has_vnet_hdr;
net/packet/diag.c +1 -1
@@ -25,7 +25,7 @@ static int pdiag_put_info(const struct packet_sock *po, struct sk_buff *nlskb) pinfo.pdi_flags |=PDI_RUNNING ;if (po->auxdata) pinfo.pdi_flags |=PDI_AUXDATA ; -if (po->origdev) +if (packet_sock_flag (po,PACKET_SOCK_ORIGDEV )) pinfo.pdi_flags |=PDI_ORIGDEV ;if (po->has_vnet_hdr) pinfo.pdi_flags |=PDI_VNETHDR ;
net/packet/internal.h +21 -1
@@ -116,9 +116,9 @@ struct packet_sock {int copy_thresh;spinlock_t bind_lock;struct mutex pg_vec_lock; +unsigned long flags;unsigned int running;/* bind_lock must be held */ unsigned int auxdata:1, /* writer must hold sock lock */ - origdev:1, has_vnet_hdr:1, tp_loss:1, tp_tx_has_off:1;
@@ -144,4 +144,24 @@ static inline struct packet_sock *pkt_sk(struct sock *sk) return (struct packet_sock *)sk; } +enum packet_sock_flags { +PACKET_SOCK_ORIGDEV , +}; + +static inline void packet_sock_flag_set (struct packet_sock *po, +enum packet_sock_flags flag, +bool val) +{ +if (val) +set_bit (flag, &po->flags); +else +clear_bit (flag, &po->flags); +} + +static inline bool packet_sock_flag (const struct packet_sock *po, +enum packet_sock_flags flag) +{ +return test_bit (flag, &po->flags); +} +#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 167/371 net/packet: convert po->auxdata to an atomic flag
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit fd53c297aa7b077ae98a3d3d2d3aa278a1686ba6 ]
po->auxdata can be read while another thread is changing its value, potentially raising KCSAN splat.
Convert it to PACKET_SOCK_AUXDATA flag.
--- net/packet/af_packet.c | 8 +++----- net/packet/diag.c | 2 +- net/packet/internal.h | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-)
net/packet/af_packet.c +3 -5
@@ -3485,7 +3485,7 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,memcpy (msg->msg_name, &PACKET_SKB_CB (skb)->sa, copy_len); } -if (pkt_sk (sk)->auxdata) { +if (packet_sock_flag (pkt_sk (sk),PACKET_SOCK_AUXDATA )) {struct tpacket_auxdata aux; aux.tp_status =TP_STATUS_USER ;
@@ -3869,9 +3869,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, sockptr_t optval,if (copy_from_sockptr (&val, optval,sizeof (val)))return -EFAULT ; -lock_sock (sk); - po->auxdata = !!val; -release_sock (sk); +packet_sock_flag_set (po,PACKET_SOCK_AUXDATA , val);return 0 ; }case PACKET_ORIGDEV :
@@ -4029,7 +4027,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,break ;case PACKET_AUXDATA : - val = po->auxdata; + val =packet_sock_flag (po,PACKET_SOCK_AUXDATA );break ;case PACKET_ORIGDEV : val =packet_sock_flag (po,PACKET_SOCK_ORIGDEV );
net/packet/diag.c +1 -1
@@ -23,7 +23,7 @@ static int pdiag_put_info(const struct packet_sock *po, struct sk_buff *nlskb) pinfo.pdi_flags =0 ;if (po->running) pinfo.pdi_flags |=PDI_RUNNING ; -if (po->auxdata) +if (packet_sock_flag (po,PACKET_SOCK_AUXDATA )) pinfo.pdi_flags |=PDI_AUXDATA ;if (packet_sock_flag (po,PACKET_SOCK_ORIGDEV )) pinfo.pdi_flags |=PDI_ORIGDEV ;
net/packet/internal.h +2 -2
@@ -118,8 +118,7 @@ struct packet_sock {struct mutex pg_vec_lock;unsigned long flags;unsigned int running;/* bind_lock must be held */ - unsigned int auxdata:1, /* writer must hold sock lock */ - has_vnet_hdr:1, + unsigned int has_vnet_hdr:1, /* writer must hold sock lock */ tp_loss:1, tp_tx_has_off:1;int pressure;
@@ -146,6 +145,7 @@ static inline struct packet_sock *pkt_sk(struct sock *sk)enum packet_sock_flags {PACKET_SOCK_ORIGDEV , +PACKET_SOCK_AUXDATA , }; static inline void packet_sock_flag_set(struct packet_sock *po,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 168/371 scsi: target: Fix multiple LUN_RESET handling
In reply to Greg Kroah-HartmanFrom: Mike Christie <[email protected]>
[ Upstream commit 673db054d7a2b5a470d7a25baf65956d005ad729 ]
This fixes a bug where an initiator thinks a LUN_RESET has cleaned up running commands when it hasn't. The bug was added in commit 51ec502a3266 ("target: Delete tmr from list before processing").
The problem occurs when:
1. We have N I/O cmds running in the target layer spread over 2 sessions.
2. The initiator sends a LUN_RESET for each session.
3. session1's LUN_RESET loops over all the running commands from both sessions and moves them to its local drain_task_list.
4. session2's LUN_RESET does not see the LUN_RESET from session1 because the commit above has it remove itself. session2 also does not see any commands since the other reset moved them off the state lists.
5. sessions2's LUN_RESET will then complete with a successful response.
6. sessions2's inititor believes the running commands on its session are now cleaned up due to the successful response and cleans up the running commands from its side. It then restarts them.
7. The commands do eventually complete on the backend and the target starts to return aborted task statuses for them. The initiator will either throw a invalid ITT error or might accidentally lookup a new task if the ITT has been reallocated already.
Fix the bug by reverting the patch, and serialize the execution of LUN_RESETs and Preempt and Aborts.
Also prevent us from waiting on LUN_RESETs in core_tmr_drain_tmr_list, because it turns out the original patch fixed a bug that was not mentioned. For LUN_RESET1 core_tmr_drain_tmr_list can see a second LUN_RESET and wait on it. Then the second reset will run core_tmr_drain_tmr_list and see the first reset and wait on it resulting in a deadlock.
--- drivers/target/target_core_device.c | 1 + drivers/target/target_core_tmr.c | 26 +++++++++++++++++++++++--- include/target/target_core_base.h | 1 + 3 files changed, 25 insertions(+), 3 deletions(-)
drivers/target/target_core_device.c +1 -0
@@ -773,6 +773,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)spin_lock_init (&dev->t10_alua.lba_map_lock);INIT_WORK (&dev->delayed_cmd_work, target_do_delayed_work); +mutex_init (&dev->lun_reset_mutex); dev->t10_wwn.t10_dev = dev;/*
drivers/target/target_core_tmr.c +23 -3
@@ -188,14 +188,23 @@ static void core_tmr_drain_tmr_list(* LUN_RESET tmr.. */ spin_lock_irqsave (&dev->se_tmr_lock, flags); -if (tmr) -list_del_init (&tmr->tmr_list);list_for_each_entry_safe (tmr_p, tmr_pp, &dev->dev_tmr_list, tmr_list) { +if (tmr_p == tmr) +continue ; + cmd = tmr_p->task_cmd;if (!cmd) {pr_err ("Unable to locate struct se_cmd for TMR\n" );continue ; } + +/* +* We only execute one LUN_RESET at a time so we can't wait +* on them below. +*/ +if (tmr_p->function ==TMR_LUN_RESET ) +continue ; +/* * If this function was called with a valid pr_res_key * parameter (eg: for PROUT PREEMPT_AND_ABORT service action
@@ -379,14 +388,25 @@ int core_tmr_lun_reset( tmr_nacl->initiatorname); } } + + +/* +* We only allow one reset or preempt and abort to execute at a time +* to prevent one call from claiming all the cmds causing a second +* call from returning while cmds it should have waited on are still +* running. +*/ +mutex_lock (&dev->lun_reset_mutex); +pr_debug ("LUN_RESET: %s starting for [%s], tas: %d\n" , (preempt_and_abort_list) ?"Preempt" :"TMR" , dev->transport->name, tas); -core_tmr_drain_tmr_list (dev, tmr, preempt_and_abort_list);core_tmr_drain_state_list (dev, prout_cmd, tmr_sess, tas, preempt_and_abort_list); +mutex_unlock (&dev->lun_reset_mutex); +/* * Clear any legacy SPC-2 reservation when called during * LOGICAL UNIT RESET
include/target/target_core_base.h +1 -0
@@ -865,6 +865,7 @@ struct se_device {struct rcu_head rcu_head;int queue_cnt;struct se_device_queue *queues; +struct mutex lun_reset_mutex; };struct se_hba {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 169/371 scsi: target: iscsit: Fix TAS handling during conn cleanup
In reply to Greg Kroah-HartmanFrom: Mike Christie <[email protected]>
[ Upstream commit cc79da306ebb2edb700c3816b90219223182ac3c ]
Fix a bug added in commit f36199355c64 ("scsi: target: iscsi: Fix cmd abort fabric stop race").
If CMD_T_TAS is set on the se_cmd we must call iscsit_free_cmd() to do the last put on the cmd and free it, because the connection is down and we will not up sending the response and doing the put from the normal I/O path.
Add a check for CMD_T_TAS in iscsit_release_commands_from_conn() so we now detect this case and run iscsit_free_cmd().
--- drivers/target/iscsi/iscsi_target.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/target/iscsi/iscsi_target.c +9 -7
@@ -4086,9 +4086,12 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)list_for_each_entry_safe (cmd, cmd_tmp, &tmp_list, i_conn_node) {struct se_cmd *se_cmd = &cmd->se_cmd; -if (se_cmd->se_tfo !=NULL ) { -spin_lock_irq (&se_cmd->t_state_lock); -if (se_cmd->transport_state &CMD_T_ABORTED ) { +if (!se_cmd->se_tfo) +continue ; + +spin_lock_irq (&se_cmd->t_state_lock); +if (se_cmd->transport_state &CMD_T_ABORTED ) { +if (!(se_cmd->transport_state &CMD_T_TAS ))/* * LIO's abort path owns the cleanup for this, * so put it back on the list and let
@@ -4096,11 +4099,10 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)*/ list_move_tail (&cmd->i_conn_node, &conn->conn_cmd_list); - }else { - se_cmd->transport_state |=CMD_T_FABRIC_STOP ; - } -spin_unlock_irq (&se_cmd->t_state_lock); + }else { + se_cmd->transport_state |=CMD_T_FABRIC_STOP ; } +spin_unlock_irq (&se_cmd->t_state_lock); }spin_unlock_bh (&conn->cmd_lock);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 170/371 scsi: megaraid: Fix mega_cmd_done() CMDID_INT_CMDS
In reply to Greg Kroah-HartmanFrom: Danila Chernetsov <[email protected]>
[ Upstream commit 75cb113cd43f06aaf4f1bda0069cfd5b98e909eb ]
When cmdid == CMDID_INT_CMDS, the 'cmds' pointer is NULL but is dereferenced below.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/scsi/megaraid.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/megaraid.c +1 -0
@@ -1443,6 +1443,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)*/ if (cmdid ==CMDID_INT_CMDS ) { scb = &adapter->int_scb; + cmd = scb->cmd;list_del_init (&scb->list); scb->state =SCB_FREE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 171/371 f2fs: handle dqget error in f2fs_transfer_project_quota()
In reply to Greg Kroah-HartmanFrom: Yangtao Li <[email protected]>
[ Upstream commit 8051692f5f23260215bfe9a72e712d93606acc5f ]
We should set the error code when dqget() failed.
--- fs/f2fs/file.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
fs/f2fs/file.c +8 -7
@@ -2977,15 +2977,16 @@ int f2fs_transfer_project_quota(struct inode *inode, kprojid_t kprojid)struct dquot *transfer_to[MAXQUOTAS ] = {};struct f2fs_sb_info *sbi =F2FS_I_SB (inode);struct super_block *sb = sbi->sb; -int err =0 ; +int err; transfer_to[PRJQUOTA ] =dqget (sb,make_kqid_projid (kprojid)); -if (!IS_ERR (transfer_to[PRJQUOTA ])) { - err =__dquot_transfer (inode, transfer_to); -if (err) -set_sbi_flag (sbi,SBI_QUOTA_NEED_REPAIR ); -dqput (transfer_to[PRJQUOTA ]); - } +if (IS_ERR (transfer_to[PRJQUOTA ])) +return PTR_ERR (transfer_to[PRJQUOTA ]); + + err =__dquot_transfer (inode, transfer_to); +if (err) +set_sbi_flag (sbi,SBI_QUOTA_NEED_REPAIR ); +dqput (transfer_to[PRJQUOTA ]);return err; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 172/371 f2fs: enforce single zone capacity
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit b771aadc6e4c221a468fe4a2dfcfffec01a06722 ]
In order to simplify the complicated per-zone capacity, let's support only one capacity for entire zoned device.
Stable-dep-of: 0b37ed21e336 ("f2fs: apply zone capacity to all zone type")
--- fs/f2fs/f2fs.h | 2 +- fs/f2fs/segment.c | 19 ++++++------------- fs/f2fs/segment.h | 3 +++ fs/f2fs/super.c | 33 ++++++++++++--------------------- 4 files changed, 22 insertions(+), 35 deletions(-)
fs/f2fs/f2fs.h +1 -1
@@ -1211,7 +1211,6 @@ struct f2fs_dev_info {#ifdef CONFIG_BLK_DEV_ZONED unsigned int nr_blkz;/* Total number of zones */ unsigned long *blkz_seq;/* Bitmap indicating sequential zones */ -block_t *zone_capacity_blocks;/* Array of zone capacity in blks */ #endif };
@@ -1632,6 +1631,7 @@ struct f2fs_sb_info {unsigned int meta_ino_num;/* meta inode number*/ unsigned int log_blocks_per_seg;/* log2 blocks per segment */ unsigned int blocks_per_seg;/* blocks per segment */ +unsigned int unusable_blocks_per_sec;/* unusable blocks per section */ unsigned int segs_per_sec;/* segments per section */ unsigned int secs_per_zone;/* sections per zone */ unsigned int total_sections;/* total section count */
fs/f2fs/segment.c +6 -13
@@ -5078,7 +5078,7 @@ static unsigned int get_zone_idx(struct f2fs_sb_info *sbi, unsigned int secno,static inline unsigned int f2fs_usable_zone_segs_in_sec (struct f2fs_sb_info *sbi,unsigned int segno) { -unsigned int dev_idx, zone_idx, unusable_segs_in_sec; +unsigned int dev_idx, zone_idx; dev_idx =f2fs_target_device_index (sbi,START_BLOCK (sbi, segno)); zone_idx =get_zone_idx (sbi,GET_SEC_FROM_SEG (sbi, segno), dev_idx);
@@ -5087,18 +5087,12 @@ static inline unsigned int f2fs_usable_zone_segs_in_sec(if (is_conv_zone (sbi, zone_idx, dev_idx))return sbi->segs_per_sec; -/* -* If the zone_capacity_blocks array is NULL, then zone capacity -* is equal to the zone size for all zones -*/ -if (!FDEV (dev_idx).zone_capacity_blocks) +if (!sbi->unusable_blocks_per_sec)return sbi->segs_per_sec;/* Get the segment count beyond zone capacity block */ - unusable_segs_in_sec = (sbi->blocks_per_blkz - -FDEV (dev_idx).zone_capacity_blocks[zone_idx]) >> - sbi->log_blocks_per_seg; -return sbi->segs_per_sec - unusable_segs_in_sec; +return sbi->segs_per_sec - (sbi->unusable_blocks_per_sec >> + sbi->log_blocks_per_seg); }/*
@@ -5127,12 +5121,11 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg(if (is_conv_zone (sbi, zone_idx, dev_idx))return sbi->blocks_per_seg; -if (!FDEV (dev_idx).zone_capacity_blocks) +if (!sbi->unusable_blocks_per_sec)return sbi->blocks_per_seg; sec_start_blkaddr =START_BLOCK (sbi,GET_SEG_FROM_SEC (sbi, secno)); - sec_cap_blkaddr = sec_start_blkaddr + -FDEV (dev_idx).zone_capacity_blocks[zone_idx]; + sec_cap_blkaddr = sec_start_blkaddr +CAP_BLKS_PER_SEC (sbi);/* * If segment starts before zone capacity and spans beyond
fs/f2fs/segment.h +3 -0
@@ -101,6 +101,9 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi, GET_SEGNO_FROM_SEG0(sbi, blk_addr)))#define BLKS_PER_SEC (sbi) \ ((sbi)->segs_per_sec * (sbi)->blocks_per_seg) +#define CAP_BLKS_PER_SEC (sbi) \ + ((sbi)->segs_per_sec * (sbi)->blocks_per_seg - \ + (sbi)->unusable_blocks_per_sec)#define GET_SEC_FROM_SEG (sbi, segno) \ (((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec)#define GET_SEG_FROM_SEC (sbi, secno) \
fs/f2fs/super.c +12 -21
@@ -1515,7 +1515,6 @@ static void destroy_device_list(struct f2fs_sb_info *sbi)blkdev_put (FDEV (i).bdev,FMODE_EXCL );#ifdef CONFIG_BLK_DEV_ZONED kvfree (FDEV (i).blkz_seq); -kfree (FDEV (i).zone_capacity_blocks);#endif }kvfree (sbi->devs);
@@ -3631,24 +3630,29 @@ static int init_percpu_info(struct f2fs_sb_info *sbi)#ifdef CONFIG_BLK_DEV_ZONED struct f2fs_report_zones_args { +struct f2fs_sb_info *sbi;struct f2fs_dev_info *dev; -bool zone_cap_mismatch; };static int f2fs_report_zone_cb (struct blk_zone *zone,unsigned int idx,void *data) {struct f2fs_report_zones_args *rz_args = data; +block_t unusable_blocks = (zone->len - zone->capacity) >> +F2FS_LOG_SECTORS_PER_BLOCK ;if (zone->type ==BLK_ZONE_TYPE_CONVENTIONAL )return 0 ;set_bit (idx, rz_args->dev->blkz_seq); - rz_args->dev->zone_capacity_blocks[idx] = zone->capacity >> -F2FS_LOG_SECTORS_PER_BLOCK ; -if (zone->len != zone->capacity && !rz_args->zone_cap_mismatch) - rz_args->zone_cap_mismatch = true; - +if (!rz_args->sbi->unusable_blocks_per_sec) { + rz_args->sbi->unusable_blocks_per_sec = unusable_blocks; +return 0 ; + } +if (rz_args->sbi->unusable_blocks_per_sec != unusable_blocks) { +f2fs_err (rz_args->sbi,"F2FS supports single zone capacity\n" ); +return -EINVAL ; + }return 0 ; }
@@ -3682,26 +3686,13 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)if (!FDEV (devi).blkz_seq)return -ENOMEM ; -/* Get block zones type and zone-capacity */ -FDEV (devi).zone_capacity_blocks =f2fs_kzalloc (sbi, -FDEV (devi).nr_blkz *sizeof (block_t), -GFP_KERNEL ); -if (!FDEV (devi).zone_capacity_blocks) -return -ENOMEM ; - + rep_zone_arg.sbi = sbi; rep_zone_arg.dev = &FDEV (devi); - rep_zone_arg.zone_cap_mismatch = false; ret =blkdev_report_zones (bdev,0 ,BLK_ALL_ZONES , f2fs_report_zone_cb, &rep_zone_arg);if (ret <0 )return ret; - -if (!rep_zone_arg.zone_cap_mismatch) { -kfree (FDEV (devi).zone_capacity_blocks); -FDEV (devi).zone_capacity_blocks =NULL ; - } - return 0; }#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 173/371 f2fs: apply zone capacity to all zone type
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 0b37ed21e3367539b79284e0b0af2246ffcf0dca ]
If we manage the zone capacity per zone type, it'll break the GC assumption. And, the current logic complains valid block count mismatch. Let's apply zone capacity to all zone type, if specified.
--- fs/f2fs/segment.c | 65 +++-------------------------------------------- fs/f2fs/segment.h | 3 +++ 2 files changed, 7 insertions(+), 61 deletions(-)
fs/f2fs/segment.c +4 -61
@@ -5053,48 +5053,6 @@ int f2fs_check_write_pointer(struct f2fs_sb_info *sbi)return 0 ; } -static bool is_conv_zone (struct f2fs_sb_info *sbi,unsigned int zone_idx, -unsigned int dev_idx) -{ -if (!bdev_is_zoned (FDEV (dev_idx).bdev)) -return true; -return !test_bit (zone_idx,FDEV (dev_idx).blkz_seq); -} - -/* Return the zone index in the given device */ -static unsigned int get_zone_idx (struct f2fs_sb_info *sbi,unsigned int secno, -int dev_idx) -{ -block_t sec_start_blkaddr =START_BLOCK (sbi,GET_SEG_FROM_SEC (sbi, secno)); - -return (sec_start_blkaddr -FDEV (dev_idx).start_blk) >> - sbi->log_blocks_per_blkz; -} - -/* -* Return the usable segments in a section based on the zone's -* corresponding zone capacity. Zone is equal to a section. -*/ -static inline unsigned int f2fs_usable_zone_segs_in_sec ( -struct f2fs_sb_info *sbi,unsigned int segno) -{ -unsigned int dev_idx, zone_idx; - - dev_idx =f2fs_target_device_index (sbi,START_BLOCK (sbi, segno)); - zone_idx =get_zone_idx (sbi,GET_SEC_FROM_SEG (sbi, segno), dev_idx); - -/* Conventional zone's capacity is always equal to zone size */ -if (is_conv_zone (sbi, zone_idx, dev_idx)) -return sbi->segs_per_sec; - -if (!sbi->unusable_blocks_per_sec) -return sbi->segs_per_sec; - -/* Get the segment count beyond zone capacity block */ -return sbi->segs_per_sec - (sbi->unusable_blocks_per_sec >> - sbi->log_blocks_per_seg); -} -/* * Return the number of usable blocks in a segment. The number of blocks * returned is always equal to the number of blocks in a segment for
@@ -5107,23 +5065,13 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg( struct f2fs_sb_info *sbi, unsigned int segno) {block_t seg_start, sec_start_blkaddr, sec_cap_blkaddr; -unsigned int zone_idx, dev_idx, secno; - - secno =GET_SEC_FROM_SEG (sbi, segno); - seg_start =START_BLOCK (sbi, segno); - dev_idx =f2fs_target_device_index (sbi, seg_start); - zone_idx =get_zone_idx (sbi, secno, dev_idx); - -/* -* Conventional zone's capacity is always equal to zone size, -* so, blocks per segment is unchanged. -*/ -if (is_conv_zone (sbi, zone_idx, dev_idx)) -return sbi->blocks_per_seg; +unsigned int secno;if (!sbi->unusable_blocks_per_sec)return sbi->blocks_per_seg; + secno =GET_SEC_FROM_SEG (sbi, segno); + seg_start =START_BLOCK (sbi, segno); sec_start_blkaddr =START_BLOCK (sbi,GET_SEG_FROM_SEC (sbi, secno)); sec_cap_blkaddr = sec_start_blkaddr +CAP_BLKS_PER_SEC (sbi);
@@ -5157,11 +5105,6 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg(struct f2fs_sb_info *sbi return 0; } -static inline unsigned int f2fs_usable_zone_segs_in_sec (struct f2fs_sb_info *sbi, -unsigned int segno) -{ -return 0 ; -}#endif unsigned int f2fs_usable_blks_in_seg (struct f2fs_sb_info *sbi,unsigned int segno)
@@ -5176,7 +5119,7 @@ unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi, unsigned int segno) {if (f2fs_sb_has_blkzoned (sbi)) -return f2fs_usable_zone_segs_in_sec (sbi, segno); +return CAP_SEGS_PER_SEC (sbi);return sbi->segs_per_sec; }
fs/f2fs/segment.h +3 -0
@@ -104,6 +104,9 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi,#define CAP_BLKS_PER_SEC (sbi) \ ((sbi)->segs_per_sec * (sbi)->blocks_per_seg - \ (sbi)->unusable_blocks_per_sec) +#define CAP_SEGS_PER_SEC (sbi) \ + ((sbi)->segs_per_sec - ((sbi)->unusable_blocks_per_sec >>\ + (sbi)->log_blocks_per_seg))#define GET_SEC_FROM_SEG (sbi, segno) \ (((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec)#define GET_SEG_FROM_SEC (sbi, secno) \
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 174/371 f2fs: compress: fix to call f2fs_wait_on_page_writeback() in f2fs_write_raw_pages()
In reply to Greg Kroah-HartmanFrom: Yangtao Li <[email protected]>
[ Upstream commit babedcbac164cec970872b8097401ca913a80e61 ]
BUG_ON() will be triggered when writing files concurrently, because the same page is writtenback multiple times.
1597 void folio_end_writeback(struct folio *folio)
1598 {
......
1618 if (!__folio_end_writeback(folio))
1619 BUG();
......1625 }
kernel BUG at mm/filemap.c:1619!
Call Trace: <TASK> f2fs_write_end_io+0x1a0/0x370 blk_update_request+0x6c/0x410 blk_mq_end_request+0x15/0x130 blk_complete_reqs+0x3c/0x50 __do_softirq+0xb8/0x29b ? sort_range+0x20/0x20 run_ksoftirqd+0x19/0x20 smpboot_thread_fn+0x10b/0x1d0 kthread+0xde/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x22/0x30 </TASK>
Below is the concurrency scenario:
[Process A] [Process B] [Process C]f2fs_write_raw_pages()
- redirty_page_for_writepage()
- unlock page()
f2fs_do_write_data_page()
- lock_page()
- clear_page_dirty_for_io()
- set_page_writeback() [1st writeback]
.....
- unlock page()
generic_perform_write()
- f2fs_write_begin()
- wait_for_stable_page()
- f2fs_write_end()
- set_page_dirty()
- lock_page()
- f2fs_do_write_data_page()
- set_page_writeback() [2st writeback]
This problem was introduced by the previous commit 7377e853967b ("f2fs:
compress: fix potential deadlock of compress file"). All pagelocks were released in f2fs_write_raw_pages(), but whether the page was in the writeback state was ignored in the subsequent writing process. Let's fix it by waiting for the page to writeback before writing.
--- fs/f2fs/compress.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/f2fs/compress.c +6 -0
@@ -1477,6 +1477,12 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,if (!PageDirty (cc->rpages[i])) goto continue_unlock; +if (PageWriteback (cc->rpages[i])) { +if (wbc->sync_mode ==WB_SYNC_NONE ) + goto continue_unlock; +f2fs_wait_on_page_writeback (cc->rpages[i],DATA , true, true); + } +if (!clear_page_dirty_for_io (cc->rpages[i])) goto continue_unlock;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 175/371 crypto: caam - Clear some memory in instantiate_rng
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 9c19fb86a8cb2ee82a832c95e139f29ea05c4d08 ]
According to the comment at the end of the 'for' loop just a few lines below, it looks needed to clear 'desc'.
So it should also be cleared for the first iteration.
Move the memset() to the beginning of the loop to be safe.
--- drivers/crypto/caam/ctrl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/crypto/caam/ctrl.c +4 -2
@@ -284,6 +284,10 @@ static int instantiate_rng(struct device *ctrldev, int state_handle_mask,const u32 rdsta_if =RDSTA_IF0 << sh_idx;const u32 rdsta_pr =RDSTA_PR0 << sh_idx;const u32 rdsta_mask = rdsta_if | rdsta_pr; + +/* Clear the contents before using the descriptor */ +memset (desc,0x00 ,CAAM_CMD_SZ *7 ); +/* * If the corresponding bit is set, this state handle * was initialized by somebody else, so it's left alone.
@@ -327,8 +331,6 @@ static int instantiate_rng(struct device *ctrldev, int state_handle_mask, }dev_info (ctrldev,"Instantiated RNG4 SH%d\n" , sh_idx); -/* Clear the contents before recreating the descriptor */ -memset (desc,0x00 ,CAAM_CMD_SZ *7 ); }kfree (desc);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 176/371 crypto: sa2ul - Select CRYPTO_DES
In reply to Greg Kroah-HartmanFrom: Suman Anna <[email protected]>
[ Upstream commit 8832023efd20966e29944dac92118dfbf1fa1bc0 ]
The SA2UL Crypto driver provides support for couple of
DES3 algos "cbc(des3_ede)" and "ecb(des3_ede)", and enabling the crypto selftest throws the following errors (as seen on
K3 J721E SoCs):
saul-crypto 4e00000.crypto: Error allocating fallback algo cbc(des3_ede)
alg: skcipher: failed to allocate transform for cbc-des3-sa2ul: -2 saul-crypto 4e00000.crypto: Error allocating fallback algo ecb(des3_ede)
alg: skcipher: failed to allocate transform for ecb-des3-sa2ul: -2
Fix this by selecting CRYPTO_DES which was missed while adding base driver support.
--- drivers/crypto/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/Kconfig +1 -0
@@ -905,6 +905,7 @@ config CRYPTO_DEV_SA2UL select CRYPTO_AES_ARM64 select CRYPTO_ALGAPI select CRYPTO_AUTHENC + select CRYPTO_DES select CRYPTO_SHA1 select CRYPTO_SHA256 select CRYPTO_SHA512
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 177/371 wifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_rfreg()
In reply to Greg Kroah-HartmanFrom: Wei Chen <[email protected]>
[ Upstream commit 905a9241e4e8c15d2c084fee916280514848fe35 ]
If there is a failure during copy_from_user or user-provided data buffer is invalid, rtl_debugfs_set_write_rfreg should return negative error code instead of a positive value count.
Fix this bug by returning correct error code. Moreover, the check of buffer against null is removed since it will be handled by copy_from_user.
--- drivers/net/wireless/realtek/rtlwifi/debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/realtek/rtlwifi/debug.c +3 -3
@@ -375,8 +375,8 @@ static ssize_t rtl_debugfs_set_write_rfreg(struct file *filp, tmp_len = (count >sizeof (tmp) -1 ?sizeof (tmp) -1 : count); -if (!buffer ||copy_from_user (tmp, buffer, tmp_len)) -return count; +if (copy_from_user (tmp, buffer, tmp_len)) +return -EFAULT ; tmp[tmp_len] ='\0' ;
@@ -386,7 +386,7 @@ static ssize_t rtl_debugfs_set_write_rfreg(struct file *filp,if (num !=4 ) {rtl_dbg (rtlpriv,COMP_ERR ,DBG_DMESG ,"Format is <path> <addr> <mask> <data>\n" ); -return count; +return -EINVAL ; }rtl_set_rfreg (hw, path, addr, bitmask, data);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 178/371 wifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_reg()
In reply to Greg Kroah-HartmanFrom: Wei Chen <[email protected]>
[ Upstream commit 5dbe1f8eb8c5ac69394400a5b86fd81775e96c43 ]
If there is a failure during copy_from_user or user-provided data buffer is invalid, rtl_debugfs_set_write_reg should return negative error code instead of a positive value count.
Fix this bug by returning correct error code. Moreover, the check of buffer against null is removed since it will be handled by copy_from_user.
--- drivers/net/wireless/realtek/rtlwifi/debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/realtek/rtlwifi/debug.c +3 -3
@@ -278,8 +278,8 @@ static ssize_t rtl_debugfs_set_write_reg(struct file *filp, tmp_len = (count >sizeof (tmp) -1 ?sizeof (tmp) -1 : count); -if (!buffer ||copy_from_user (tmp, buffer, tmp_len)) -return count; +if (copy_from_user (tmp, buffer, tmp_len)) +return -EFAULT ; tmp[tmp_len] ='\0' ;
@@ -287,7 +287,7 @@ static ssize_t rtl_debugfs_set_write_reg(struct file *filp, num =sscanf (tmp,"%x %x %x" , &addr, &val, &len);if (num !=3 ) -return count; +return -EINVAL ;switch (len) {case 1 :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 179/371 wifi: rt2x00: Fix memory leak when handling surveys
In reply to Greg Kroah-HartmanFrom: Armin Wolf <[email protected]>
[ Upstream commit cbef9a83c51dfcb07f77cfa6ac26f53a1ea86f49 ]
When removing a rt2x00 device, its associated channel surveys are not freed, causing a memory leak observable with kmemleak:
unreferenced object 0xffff9620f0881a00 (size 512):
comm "systemd-udevd", pid 2290, jiffies 4294906974 (age 33.768s) hex dump (first 32 bytes):
70 44 12 00 00 00 00 00 92 8a 00 00 00 00 00 00 pD..............
00 00 00 00 00 00 00 00 ab 87 01 00 00 00 00 00 ................
backtrace:
[<ffffffffb0ed858b>] __kmalloc+0x4b/0x130
[<ffffffffc1b0f29b>] rt2800_probe_hw+0xc2b/0x1380 [rt2800lib]
[<ffffffffc1a9496e>] rt2800usb_probe_hw+0xe/0x60 [rt2800usb]
[<ffffffffc1ae491a>] rt2x00lib_probe_dev+0x21a/0x7d0 [rt2x00lib]
[<ffffffffc1b3b83e>] rt2x00usb_probe+0x1be/0x980 [rt2x00usb]
[<ffffffffc05981e2>] usb_probe_interface+0xe2/0x310 [usbcore]
[<ffffffffb13be2d5>] really_probe+0x1a5/0x410
[<ffffffffb13be5c8>] __driver_probe_device+0x78/0x180
[<ffffffffb13be6fe>] driver_probe_device+0x1e/0x90
[<ffffffffb13be972>] __driver_attach+0xd2/0x1c0
[<ffffffffb13bbc57>] bus_for_each_dev+0x77/0xd0
[<ffffffffb13bd2a2>] bus_add_driver+0x112/0x210
[<ffffffffb13bfc6c>] driver_register+0x5c/0x120
[<ffffffffc0596ae8>] usb_register_driver+0x88/0x150 [usbcore]
[<ffffffffb0c011c4>] do_one_initcall+0x44/0x220
[<ffffffffb0d6134c>] do_init_module+0x4c/0x220Fix this by freeing the channel surveys on device removal.
Tested with a RT3070 based USB wireless adapter.
--- drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +1 -0
@@ -1091,6 +1091,7 @@ static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev) }kfree (rt2x00dev->spec.channels_info); +kfree (rt2x00dev->chan_survey); }static int rt2x00lib_probe_hw (struct rt2x00_dev *rt2x00dev)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 180/371 net: qrtr: correct types of trace event parameters
In reply to Greg Kroah-HartmanFrom: Simon Horman <[email protected]>
[ Upstream commit 054fbf7ff8143d35ca7d3bb5414bb44ee1574194 ]
The arguments passed to the trace events are of type unsigned int, however the signature of the events used __le32 parameters.
I may be missing the point here, but sparse flagged this and it does seem incorrect to me.
net/qrtr/ns.c: note: in included file (through include/trace/trace_events.h, include/trace/define_trace.h, include/trace/events/qrtr.h):
./include/trace/events/qrtr.h:11:1: warning: cast to restricted __le32
./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
... (a lot more similar warnings)
net/qrtr/ns.c:115:47: expected restricted __le32 [usertype] service
net/qrtr/ns.c:115:47: got unsigned int service
net/qrtr/ns.c:115:61: warning: incorrect type in argument 2 (different base types)
... (a lot more similar warnings)
--- include/trace/events/qrtr.h | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
include/trace/events/qrtr.h +18 -15
@@ -10,15 +10,16 @@ TRACE_EVENT(qrtr_ns_service_announce_new, - TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port), + TP_PROTO(unsigned int service, unsigned int instance, + unsigned int node, unsigned int port), TP_ARGS(service, instance, node, port), TP_STRUCT__entry( - __field(__le32, service) - __field(__le32, instance) - __field(__le32, node) - __field(__le32, port) + __field(unsigned int, service) + __field(unsigned int, instance) + __field(unsigned int, node) + __field(unsigned int, port) ), TP_fast_assign(
@@ -36,15 +37,16 @@ TRACE_EVENT(qrtr_ns_service_announce_new, TRACE_EVENT(qrtr_ns_service_announce_del, - TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port), + TP_PROTO(unsigned int service, unsigned int instance, + unsigned int node, unsigned int port), TP_ARGS(service, instance, node, port), TP_STRUCT__entry( - __field(__le32, service) - __field(__le32, instance) - __field(__le32, node) - __field(__le32, port) + __field(unsigned int, service) + __field(unsigned int, instance) + __field(unsigned int, node) + __field(unsigned int, port) ), TP_fast_assign(
@@ -62,15 +64,16 @@ TRACE_EVENT(qrtr_ns_service_announce_del, TRACE_EVENT(qrtr_ns_server_add, - TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port), + TP_PROTO(unsigned int service, unsigned int instance, + unsigned int node, unsigned int port), TP_ARGS(service, instance, node, port), TP_STRUCT__entry( - __field(__le32, service) - __field(__le32, instance) - __field(__le32, node) - __field(__le32, port) + __field(unsigned int, service) + __field(unsigned int, instance) + __field(unsigned int, node) + __field(unsigned int, port) ), TP_fast_assign(
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 181/371 selftests: xsk: Disable IPv6 on VETH1
In reply to Greg Kroah-HartmanFrom: Kal Conley <[email protected]>
[ Upstream commit f2b50f17268390567bc0e95642170d88f336c8f4 ]
This change fixes flakiness in the BIDIRECTIONAL test:
# [is_pkt_valid] expected length [60], got length [90] not ok 1 FAIL: SKB BUSY-POLL BIDIRECTIONAL
When IPv6 is enabled, the interface will periodically send MLDv1 and MLDv2 packets. These packets can cause the BIDIRECTIONAL test to fail since it uses VETH0 for RX.
For other tests, this was not a problem since they only receive on VETH1 and IPv6 was already disabled on VETH0.
--- tools/testing/selftests/bpf/test_xsk.sh | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/test_xsk.sh +1 -0
@@ -106,6 +106,7 @@ setup_vethPairs() { ip link add ${VETH0} numtxqueues 4 numrxqueues 4 type veth peer name ${VETH1} numtxqueues 4 numrxqueues 4 if [ -f /proc/net/if_inet6 ]; then echo 1 > /proc/sys/net/ipv6/conf/${VETH0}/disable_ipv6 + echo 1 > /proc/sys/net/ipv6/conf/${VETH1}/disable_ipv6 fi if [[ $verbose -eq 1 ]]; then echo "setting up ${VETH1}: namespace: ${NS1}"
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 182/371 selftests/bpf: Wait for receive in cg_storage_multi test
In reply to Greg Kroah-HartmanFrom: YiFei Zhu <[email protected]>
[ Upstream commit 5af607a861d43ffff830fc1890033e579ec44799 ]
In some cases the loopback latency might be large enough, causing the assertion on invocations to be run before ingress prog getting executed. The assertion would fail and the test would flake.
This can be reliably reproduced by arbitrarily increasing the loopback latency (thanks to [1]):
tc qdisc add dev lo root handle 1: htb default 12
tc class add dev lo parent 1:1 classid 1:12 htb rate 20kbps ceil 20kbps tc qdisc add dev lo parent 1:12 netem delay 100ms
Fix this by waiting on the receive end, instead of instantly returning to the assert. The call to read() will wait for the default SO_RCVTIMEO timeout of 3 seconds provided by start_server().
[1] https://gist.github.com/kstevens715/4598301
--- tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c +6 -2
@@ -56,8 +56,9 @@ static bool assert_storage_noexist(struct bpf_map *map, const void *key)static bool connect_send (const char *cgroup_path) { -bool res = true;int server_fd =-1 , client_fd =-1 ; +char message[] ="message" ; +bool res = true;if (join_cgroup (cgroup_path)) goto out_clean;
@@ -70,7 +71,10 @@ static bool connect_send(const char *cgroup_path)if (client_fd <0 ) goto out_clean; -if (send (client_fd,"message" ,strlen ("message" ),0 ) <0 ) +if (send (client_fd, &message,sizeof (message),0 ) <0 ) + goto out_clean; + +if (read (server_fd, &message,sizeof (message)) <0 ) goto out_clean; res = false;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 183/371 bpftool: Fix bug for long instructions in program CFG dumps
In reply to Greg Kroah-HartmanFrom: Quentin Monnet <[email protected]>
[ Upstream commit 67cf52cdb6c8fa6365d29106555dacf95c9fd374 ]
When dumping the control flow graphs for programs using the 16-byte long load instruction, we need to skip the second part of this instruction when looking for the next instruction to process. Otherwise, we end up printing "BUG_ld_00" from the kernel disassembler in the CFG.
--- tools/bpf/bpftool/xlated_dumper.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/bpf/bpftool/xlated_dumper.c +7 -0
@@ -369,8 +369,15 @@ void dump_xlated_for_graph(struct dump_data *dd, void *buf_start, void *buf_end,struct bpf_insn *insn_start = buf_start;struct bpf_insn *insn_end = buf_end;struct bpf_insn *cur = insn_start; +bool double_insn = false;for (; cur <= insn_end; cur++) { +if (double_insn) { + double_insn = false; +continue ; + } + double_insn = cur->code == (BPF_LD |BPF_IMM |BPF_DW ); +printf ("% 4d: " , (int )(cur - insn_start + start_idx));print_bpf_insn (&cbs, cur, true);if (cur != insn_end)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 184/371 crypto: drbg - make drbg_prepare_hrng() handle jent instantiation errors
In reply to Greg Kroah-HartmanFrom: Nicolai Stange <[email protected]>
[ Upstream commit 559edd47cce4cc407d606b4d7f376822816fd4b8 ]
Now that drbg_prepare_hrng() doesn't do anything but to instantiate a jitterentropy crypto_rng instance, it looks a little odd to have the related error handling at its only caller, drbg_instantiate().
Move the handling of jitterentropy allocation failures from drbg_instantiate() close to the allocation itself in drbg_prepare_hrng().
There is no change in behaviour.
Stable-dep-of: 686cd976b6dd ("crypto: drbg - Only fail when jent is unavailable in FIPS mode")
--- crypto/drbg.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
crypto/drbg.c +8 -8
@@ -1516,6 +1516,14 @@ static int drbg_prepare_hrng(struct drbg_state *drbg)return 0 ; drbg->jent =crypto_alloc_rng ("jitterentropy_rng" ,0 ,0 ); +if (IS_ERR (drbg->jent)) { +const int err =PTR_ERR (drbg->jent); + + drbg->jent =NULL ; +if (fips_enabled || err != -ENOENT ) +return err; +pr_info ("DRBG: Continuing without Jitter RNG\n" ); + }return 0 ; }
@@ -1571,14 +1579,6 @@ static int drbg_instantiate(struct drbg_state *drbg, struct drbg_string *pers,if (ret) goto free_everything; -if (IS_ERR (drbg->jent)) { - ret =PTR_ERR (drbg->jent); - drbg->jent =NULL ; -if (fips_enabled || ret != -ENOENT ) - goto free_everything; -pr_info ("DRBG: Continuing without Jitter RNG\n" ); - } - reseed = false; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 185/371 crypto: drbg - Only fail when jent is unavailable in FIPS mode
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
[ Upstream commit 686cd976b6ddedeeb1a1fb09ba53a891d3cc9a03 ]
When jent initialisation fails for any reason other than ENOENT, the entire drbg fails to initialise, even when we're not in FIPS mode. This is wrong because we can still use the kernel RNG when we're not in FIPS mode.
Change it so that it only fails when we are in FIPS mode.
--- crypto/drbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/drbg.c +1 -1
@@ -1520,7 +1520,7 @@ static int drbg_prepare_hrng(struct drbg_state *drbg)const int err =PTR_ERR (drbg->jent); drbg->jent =NULL ; -if (fips_enabled || err != -ENOENT ) +if (fips_enabled)return err;pr_info ("DRBG: Continuing without Jitter RNG\n" ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 186/371 xsk: Fix unaligned descriptor validation
In reply to Greg Kroah-HartmanFrom: Kal Conley <[email protected]>
[ Upstream commit d769ccaf957fe7391f357c0a923de71f594b8a2b ]
Make sure unaligned descriptors that straddle the end of the UMEM are considered invalid. Currently, descriptor validation is broken for zero-copy mode which only checks descriptors at page granularity. For example, descriptors in zero-copy mode that overrun the end of the UMEM but not a page boundary are (incorrectly) considered valid. The UMEM boundary check needs to happen before the page boundary and contiguity checks in xp_desc_crosses_non_contig_pg(). Do this check in xp_unaligned_validate_desc() instead like xp_check_unaligned() already does.
--- include/net/xsk_buff_pool.h | 9 ++------- net/xdp/xsk_queue.h | 1 + 2 files changed, 3 insertions(+), 7 deletions(-)
include/net/xsk_buff_pool.h +2 -7
@@ -152,13 +152,8 @@ static inline bool xp_desc_crosses_non_contig_pg(struct xsk_buff_pool *pool,if (likely (!cross_pg))return false; -if (pool->dma_pages_cnt) { -return !(pool->dma_pages[addr >>PAGE_SHIFT ] & -XSK_NEXT_PG_CONTIG_MASK ); - } - -/* skb path */ -return addr + len > pool->addrs_cnt; +return pool->dma_pages_cnt && + !(pool->dma_pages[addr >>PAGE_SHIFT ] &XSK_NEXT_PG_CONTIG_MASK ); }static inline u64 xp_aligned_extract_addr (struct xsk_buff_pool *pool,u64 addr)
net/xdp/xsk_queue.h +1 -0
@@ -157,6 +157,7 @@ static inline bool xp_unaligned_validate_desc(struct xsk_buff_pool *pool,return false;if (base_addr >= pool->addrs_cnt || addr >= pool->addrs_cnt || + addr + desc->len > pool->addrs_cnt ||xp_desc_crosses_non_contig_pg (pool, addr, desc->len))return false;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 187/371 f2fs: fix to avoid use-after-free for cached IPU bio
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 5cdb422c839134273866208dad5360835ddb9794 ]
xfstest generic/019 reports a bug:
kernel BUG at mm/filemap.c:1619!
RIP: 0010:folio_end_writeback+0x8a/0x90 Call Trace: end_page_writeback+0x1c/0x60 f2fs_write_end_io+0x199/0x420 bio_endio+0x104/0x180 submit_bio_noacct+0xa5/0x510 submit_bio+0x48/0x80 f2fs_submit_write_bio+0x35/0x300 f2fs_submit_merged_ipu_write+0x2a0/0x2b0 f2fs_write_single_data_page+0x838/0x8b0 f2fs_write_cache_pages+0x379/0xa30 f2fs_write_data_pages+0x30c/0x340 do_writepages+0xd8/0x1b0 __writeback_single_inode+0x44/0x370 writeback_sb_inodes+0x233/0x4d0 __writeback_inodes_wb+0x56/0xf0 wb_writeback+0x1dd/0x2d0 wb_workfn+0x367/0x4a0 process_one_work+0x21d/0x430 worker_thread+0x4e/0x3c0 kthread+0x103/0x130 ret_from_fork+0x2c/0x50
The root cause is: after cp_error is set, f2fs_submit_merged_ipu_write() in f2fs_write_single_data_page() tries to flush IPU bio in cache, however f2fs_submit_merged_ipu_write() missed to check validity of @bio parameter, result in submitting random cached bio which belong to other IO context, then it will cause use-after-free issue, fix it by adding additional validity check.
--- fs/f2fs/data.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/f2fs/data.c +4 -1
@@ -808,6 +808,8 @@ void f2fs_submit_merged_ipu_write(struct f2fs_sb_info *sbi,bool found = false;struct bio *target = bio ? *bio :NULL ; +f2fs_bug_on (sbi, !target && !page); +for (temp =HOT ; temp <NR_TEMP_TYPE && !found; temp++) {struct f2fs_bio_info *io = sbi->write_io[DATA ] + temp;struct list_head *head = &io->bio_list;
@@ -2867,7 +2869,8 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,if (unlikely (f2fs_cp_error (sbi))) {f2fs_submit_merged_write (sbi,DATA ); -f2fs_submit_merged_ipu_write (sbi, bio,NULL ); +if (bio && *bio) +f2fs_submit_merged_ipu_write (sbi, bio,NULL ); submitted =NULL ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 188/371 scsi: lpfc: Fix ioremap issues in lpfc_sli4_pci_mem_setup()
In reply to Greg Kroah-HartmanFrom: Shuchang Li <[email protected]>
[ Upstream commit 91a0c0c1413239d0548b5aac4c82f38f6d53a91e ]
When if_type equals zero and pci_resource_start(pdev, PCI_64BIT_BAR4) returns false, drbl_regs_memmap_p is not remapped. This passes a NULL pointer to iounmap(), which can trigger a WARN() on certain arches.
When if_type equals six and pci_resource_start(pdev, PCI_64BIT_BAR4) returns true, drbl_regs_memmap_p may has been remapped and ctrl_regs_memmap_p is not remapped. This is a resource leak and passes a NULL pointer to iounmap().
To fix these issues, we need to add null checks before iounmap(), and change some goto labels.
--- drivers/scsi/lpfc/lpfc_init.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +6 -4
@@ -11738,7 +11738,7 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba) goto out_iounmap_all; }else { error = -ENOMEM ; - goto out_iounmap_all; + goto out_iounmap_ctrl; } }
@@ -11756,7 +11756,7 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)dev_err (&pdev->dev,"ioremap failed for SLI4 HBA dpp registers.\n" ); error = -ENOMEM ; - goto out_iounmap_ctrl; + goto out_iounmap_all; } phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; }
@@ -11781,9 +11781,11 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)return 0 ; out_iounmap_all: -iounmap (phba->sli4_hba.drbl_regs_memmap_p); +if (phba->sli4_hba.drbl_regs_memmap_p) +iounmap (phba->sli4_hba.drbl_regs_memmap_p); out_iounmap_ctrl: -iounmap (phba->sli4_hba.ctrl_regs_memmap_p); +if (phba->sli4_hba.ctrl_regs_memmap_p) +iounmap (phba->sli4_hba.ctrl_regs_memmap_p); out_iounmap_conf:iounmap (phba->sli4_hba.conf_regs_memmap_p);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 189/371 net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling
In reply to Greg Kroah-HartmanFrom: Sebastian Reichel <[email protected]>
[ Upstream commit db21973263f8c56750cb610f1d5e8bee00a513b9 ]
The usual devm_regulator_get() call already handles "optional" regulators by returning a valid dummy and printing a warning that the dummy regulator should be described properly. This code open coded the same behaviour, but masked any errors that are not -EPROBE_DEFER and is quite noisy.
This change effectively unmasks and propagates regulators errors not involving -ENODEV, downgrades the error print to warning level if no regulator is specified and captures the probe defer message for /sys/kernel/debug/devices_deferred.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +4 -10
@@ -1347,9 +1347,6 @@ static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)int ret;struct device *dev = &bsp_priv->pdev->dev; -if (!ldo) -return 0 ; -if (enable) { ret =regulator_enable (ldo);if (ret)
@@ -1397,14 +1394,11 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev, } } - bsp_priv->regulator =devm_regulator_get_optional (dev,"phy" ); + bsp_priv->regulator =devm_regulator_get (dev,"phy" );if (IS_ERR (bsp_priv->regulator)) { -if (PTR_ERR (bsp_priv->regulator) == -EPROBE_DEFER ) { -dev_err (dev,"phy regulator is not available yet, deferred probing\n" ); -return ERR_PTR (-EPROBE_DEFER ); - } -dev_err (dev,"no regulator found\n" ); - bsp_priv->regulator =NULL ; + ret =PTR_ERR (bsp_priv->regulator); +dev_err_probe (dev, ret,"failed to get phy regulator\n" ); +return ERR_PTR (ret); } ret =of_property_read_string (dev->of_node,"clock_in_out" , &strings);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 190/371 bpf, sockmap: fix deadlocks in the sockhash and sockmap
In reply to Greg Kroah-HartmanFrom: Xin Liu <[email protected]>
[ Upstream commit ed17aa92dc56b6d8883e4b7a8f1c6fbf5ed6cd29 ]
When huang uses sched_switch tracepoint, the tracepoint does only one thing in the mounted ebpf program, which deletes the fixed elements in sockhash ([0])
It seems that elements in sockhash are rarely actively deleted by users or ebpf program. Therefore, we do not pay much attention to their deletion. Compared with hash maps, sockhash only provides spin_lock_bh protection. This causes it to appear to have self-locking behavior in the interrupt context.
[0]:https://lore.kernel.org/all/CABcoxUayum5oOqFMMqAeWuS8+EzojquSOSyDA3J_2omY=2EeAg@mail.gmail.com/
--- net/core/sock_map.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/core/sock_map.c +6 -4
@@ -414,8 +414,9 @@ static int __sock_map_delete(struct bpf_stab *stab, struct sock *sk_test, {struct sock *sk;int err =0 ; +unsigned long flags; -raw_spin_lock_bh (&stab->lock); +raw_spin_lock_irqsave (&stab->lock, flags); sk = *psk;if (!sk_test || sk_test == sk) sk =xchg (psk,NULL );
@@ -425,7 +426,7 @@ static int __sock_map_delete(struct bpf_stab *stab, struct sock *sk_test,else err = -EINVAL ; -raw_spin_unlock_bh (&stab->lock); +raw_spin_unlock_irqrestore (&stab->lock, flags);return err; }
@@ -930,11 +931,12 @@ static int sock_hash_delete_elem(struct bpf_map *map, void *key)struct bpf_shtab_bucket *bucket;struct bpf_shtab_elem *elem;int ret = -ENOENT ; +unsigned long flags; hash =sock_hash_bucket_hash (key, key_size); bucket =sock_hash_select_bucket (htab, hash); -raw_spin_lock_bh (&bucket->lock); +raw_spin_lock_irqsave (&bucket->lock, flags); elem =sock_hash_lookup_elem_raw (&bucket->head, hash, key, key_size);if (elem) {hlist_del_rcu (&elem->node);
@@ -942,7 +944,7 @@ static int sock_hash_delete_elem(struct bpf_map *map, void *key)sock_hash_free_elem (htab, elem); ret =0 ; } -raw_spin_unlock_bh (&bucket->lock); +raw_spin_unlock_irqrestore (&bucket->lock, flags);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 191/371 nvmet: use i_size_read() to set size for file-ns
In reply to Greg Kroah-HartmanFrom: Chaitanya Kulkarni <[email protected]>
[ Upstream commit 2caecd62ea5160803b25d96cb1a14ce755c2c259 ]
Instead of calling vfs_getattr() use i_size_read() to read the size of file so we can read the size of not only file type but also block type with one call. This is needed to implement buffered_io support for the NVMeOF block device backend.
We also change return type of function nvmet_file_ns_revalidate() from int to void, since this function does not return any meaning value.
Stable-dep-of: ab76e7206b67 ("nvmet: fix error handling in nvmet_execute_identify_cns_cs_ns()")
--- drivers/nvme/target/io-cmd-file.c | 17 ++++------------- drivers/nvme/target/nvmet.h | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-)
drivers/nvme/target/io-cmd-file.c +4 -13
@@ -13,16 +13,9 @@#define NVMET_MIN_MPOOL_OBJ 16 -int nvmet_file_ns_revalidate (struct nvmet_ns *ns) +void nvmet_file_ns_revalidate (struct nvmet_ns *ns) { -struct kstat stat; -int ret; - - ret =vfs_getattr (&ns->file->f_path, &stat,STATX_SIZE , -AT_STATX_FORCE_SYNC ); -if (!ret) - ns->size = stat.size; -return ret; + ns->size =i_size_read (ns->file->f_mapping->host); }void nvmet_file_ns_disable (struct nvmet_ns *ns)
@@ -40,7 +33,7 @@ void nvmet_file_ns_disable(struct nvmet_ns *ns)int nvmet_file_ns_enable (struct nvmet_ns *ns) {int flags =O_RDWR |O_LARGEFILE ; -int ret; +int ret =0 ;if (!ns->buffered_io) flags |=O_DIRECT ;
@@ -54,9 +47,7 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns)return ret; } - ret =nvmet_file_ns_revalidate (ns); -if (ret) - goto err; +nvmet_file_ns_revalidate (ns);/* * i_blkbits can be greater than the universally accepted upper bound,
drivers/nvme/target/nvmet.h +1 -1
@@ -542,7 +542,7 @@ u16 nvmet_bdev_flush(struct nvmet_req *req);u16 nvmet_file_flush (struct nvmet_req *req);void nvmet_ns_changed (struct nvmet_subsys *subsys,u32 nsid);void nvmet_bdev_ns_revalidate (struct nvmet_ns *ns); -int nvmet_file_ns_revalidate (struct nvmet_ns *ns); +void nvmet_file_ns_revalidate (struct nvmet_ns *ns);void nvmet_ns_revalidate (struct nvmet_ns *ns);u16 blk_to_nvme_status (struct nvmet_req *req,blk_status_t blk_sts);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 192/371 nvmet: move the call to nvmet_ns_changed out of nvmet_ns_revalidate
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit da7837339641601f202f27515771dc0646083938 ]
nvmet_ns_changed states via lockdep that the ns->subsys->lock must be held. The only caller of nvmet_ns_changed which does not acquire that lock is nvmet_ns_revalidate. nvmet_ns_revalidate has 3 callers, of which 2 do not acquire that lock: nvmet_execute_identify_cns_cs_ns and nvmet_execute_identify_ns. The other caller nvmet_ns_revalidate_size_store does acquire the lock.
Move the call to nvmet_ns_changed from nvmet_ns_revalidate to the callers so that they can perform the correct locking as needed.
This issue was found using a static type-based analyser and manually verified.
Stable-dep-of: ab76e7206b67 ("nvmet: fix error handling in nvmet_execute_identify_cns_cs_ns()")
--- drivers/nvme/target/admin-cmd.c | 6 +++++- drivers/nvme/target/configfs.c | 3 ++- drivers/nvme/target/core.c | 5 ++--- drivers/nvme/target/nvmet.h | 2 +- drivers/nvme/target/zns.c | 6 +++++- 5 files changed, 15 insertions(+), 7 deletions(-)
drivers/nvme/target/admin-cmd.c +5 -1
@@ -508,7 +508,11 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req) goto done; } -nvmet_ns_revalidate (req->ns); +if (nvmet_ns_revalidate (req->ns)) { +mutex_lock (&req->ns->subsys->lock); +nvmet_ns_changed (req->ns->subsys, req->ns->nsid); +mutex_unlock (&req->ns->subsys->lock); + }/* * nuse = ncap = nsze isn't always true, but we have no way to find
drivers/nvme/target/configfs.c +2 -1
@@ -586,7 +586,8 @@ static ssize_t nvmet_ns_revalidate_size_store(struct config_item *item,mutex_unlock (&ns->subsys->lock);return -EINVAL ; } -nvmet_ns_revalidate (ns); +if (nvmet_ns_revalidate (ns)) +nvmet_ns_changed (ns->subsys, ns->nsid);mutex_unlock (&ns->subsys->lock);return count; }
drivers/nvme/target/core.c +2 -3
@@ -535,7 +535,7 @@ static void nvmet_p2pmem_ns_add_p2p(struct nvmet_ctrl *ctrl, ns->nsid); } -void nvmet_ns_revalidate (struct nvmet_ns *ns) +bool nvmet_ns_revalidate (struct nvmet_ns *ns) {loff_t oldsize = ns->size;
@@ -544,8 +544,7 @@ void nvmet_ns_revalidate(struct nvmet_ns *ns)else nvmet_file_ns_revalidate (ns); -if (oldsize != ns->size) -nvmet_ns_changed (ns->subsys, ns->nsid); +return oldsize != ns->size; }int nvmet_ns_enable (struct nvmet_ns *ns)
drivers/nvme/target/nvmet.h +1 -1
@@ -543,7 +543,7 @@ u16 nvmet_file_flush(struct nvmet_req *req);void nvmet_ns_changed (struct nvmet_subsys *subsys,u32 nsid);void nvmet_bdev_ns_revalidate (struct nvmet_ns *ns);void nvmet_file_ns_revalidate (struct nvmet_ns *ns); -void nvmet_ns_revalidate (struct nvmet_ns *ns); +bool nvmet_ns_revalidate (struct nvmet_ns *ns);u16 blk_to_nvme_status (struct nvmet_req *req,blk_status_t blk_sts);bool nvmet_bdev_zns_enable (struct nvmet_ns *ns);
drivers/nvme/target/zns.c +5 -1
@@ -123,7 +123,11 @@ void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req) goto done; } -nvmet_ns_revalidate (req->ns); +if (nvmet_ns_revalidate (req->ns)) { +mutex_lock (&req->ns->subsys->lock); +nvmet_ns_changed (req->ns->subsys, req->ns->nsid); +mutex_unlock (&req->ns->subsys->lock); + } zsze = (bdev_zone_sectors (req->ns->bdev) <<9 ) >> req->ns->blksize_shift; id_zns->lbafe[0 ].zsze =cpu_to_le64 (zsze);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 193/371 nvmet: fix error handling in nvmet_execute_identify_cns_cs_ns()
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
[ Upstream commit ab76e7206b672b2e8818cb121a04506956d6b223 ]
Nvme specifications state that:
If the I/O Command Set associated with the namespace identified by the NSID field does not support the Identify Namespace data structure specified by the CSI field, the controller shall abort the command with a status code of Invalid Field in Command.
In other words, if nvmet_execute_identify_cns_cs_ns() is called for a target with a block device that is not zoned, we should not return any data and set the status to NVME_SC_INVALID_FIELD.
While at it, it is also better to revalidate the ns block devie *before* checking if the block device is zoned, to ensure that nvmet_execute_identify_cns_cs_ns() operates against updated device characteristics.
--- drivers/nvme/target/zns.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/nvme/target/zns.c +9 -7
@@ -97,7 +97,7 @@ void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)void nvmet_execute_identify_cns_cs_ns (struct nvmet_req *req) { -struct nvme_id_ns_zns *id_zns; +struct nvme_id_ns_zns *id_zns =NULL ;u64 zsze;u16 status;u32 mar, mor;
@@ -118,16 +118,18 @@ void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)if (status) goto done; -if (!bdev_is_zoned (req->ns->bdev)) { - req->error_loc = offsetof(struct nvme_identify , nsid); - goto done; - } -if (nvmet_ns_revalidate (req->ns)) {mutex_lock (&req->ns->subsys->lock);nvmet_ns_changed (req->ns->subsys, req->ns->nsid);mutex_unlock (&req->ns->subsys->lock); } + +if (!bdev_is_zoned (req->ns->bdev)) { + status =NVME_SC_INVALID_FIELD |NVME_SC_DNR ; + req->error_loc = offsetof(struct nvme_identify , nsid); + goto out; + } + zsze = (bdev_zone_sectors (req->ns->bdev) <<9 ) >> req->ns->blksize_shift; id_zns->lbafe[0 ].zsze =cpu_to_le64 (zsze);
@@ -148,8 +150,8 @@ void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req) done: status =nvmet_copy_to_sgl (req,0 , id_zns,sizeof (*id_zns)); -kfree (id_zns); out: +kfree (id_zns);nvmet_req_complete (req, status); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 194/371 nvmet: fix Identify Namespace handling
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
[ Upstream commit 8c098aa00118c35108f0c19bd3cdc45e11574948 ]
The identify command with cns set to NVME_ID_CNS_NS does not directly depend on the command set. The NVMe specifications is rather confusing here as it appears that this command only applies to the NVM command set. However, footnote 8 of Figure 273 in the NVMe 2.0 base specifications clearly state that this command applies to NVM command sets that support logical blocks, that is, NVM and ZNS. Both the NVM and ZNS command set specifications also list this identify as mandatory.
The command handling should thus not look at the csi field since it is defined as unused for this command. Given that we do not support the KV command set, simply remove the csi switch-case for that command handling and call directly nvmet_execute_identify_ns() in nvmet_execute_identify().
--- drivers/nvme/target/admin-cmd.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/nvme/target/admin-cmd.c +2 -7
@@ -687,13 +687,8 @@ static void nvmet_execute_identify(struct nvmet_req *req)switch (req->cmd->identify.cns) {case NVME_ID_CNS_NS : -switch (req->cmd->identify.csi) { -case NVME_CSI_NVM : -return nvmet_execute_identify_ns (req); -default : -break ; - } -break ; +nvmet_execute_identify_ns (req); +return ;case NVME_ID_CNS_CS_NS :if (IS_ENABLED (CONFIG_BLK_DEV_ZONED )) {switch (req->cmd->identify.csi) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 195/371 nvmet: fix Identify Controller handling
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
[ Upstream commit 62904b3b333e7f3c0f879dc3513295eee5765c9f ]
The identify command with cns set to NVME_ID_CNS_CTRL does not depend on the command set. The execution of this command should thus not look at the csi specified in the command. Simplify nvmet_execute_identify() to directly call nvmet_execute_identify_ctrl() without the csi switch-case.
--- drivers/nvme/target/admin-cmd.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/nvme/target/admin-cmd.c +2 -5
@@ -700,11 +700,8 @@ static void nvmet_execute_identify(struct nvmet_req *req) }break ;case NVME_ID_CNS_CTRL : -switch (req->cmd->identify.csi) { -case NVME_CSI_NVM : -return nvmet_execute_identify_ctrl (req); - } -break ; +nvmet_execute_identify_ctrl (req); +return ;case NVME_ID_CNS_CS_CTRL :if (IS_ENABLED (CONFIG_BLK_DEV_ZONED )) {switch (req->cmd->identify.csi) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 196/371 nvmet: fix Identify Active Namespace ID list handling
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
[ Upstream commit 97416f67d55fb8b866ff1815ca7ef26b6dfa6a5e ]
The identify command with cns set to NVME_ID_CNS_NS_ACTIVE_LIST does not depend on the command set. The execution of this command should thus not look at the csi field specified in the command. Simplify nvmet_execute_identify() to directly call nvmet_execute_identify_nslist() without the csi switch-case.
--- drivers/nvme/target/admin-cmd.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/nvme/target/admin-cmd.c +2 -7
@@ -713,13 +713,8 @@ static void nvmet_execute_identify(struct nvmet_req *req) }break ;case NVME_ID_CNS_NS_ACTIVE_LIST : -switch (req->cmd->identify.csi) { -case NVME_CSI_NVM : -return nvmet_execute_identify_nslist (req); -default : -break ; - } -break ; +nvmet_execute_identify_nslist (req); +return ;case NVME_ID_CNS_NS_DESC_LIST :if (nvmet_handle_identify_desclist (req) == true)return ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 197/371 nvmet: fix I/O Command Set specific Identify Controller
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
[ Upstream commit a5a6ab0950b46ab1ef4a5c83c80234018b81b38a ]
For an identify command with cns set to NVME_ID_CNS_CS_CTRL, the NVMe 2.0 specification states that:
If the I/O Command Set specified by the CSI field does not have an Identify Controller data structure, then the controller shall return a zero filled data structure. If the host requests a data structure for an I/O Command Set that the controller does not support, the controller shall abort the command with a status code of Invalid Field in Command.
However, the current implementation of this identify command in nvmet_execute_identify() only handles the ZNS command set, returning an error for the NVM command set, which is not compliant with the specifications as we do support this command set.
Fix this by:
1) Renaming nvmet_execute_identify_cns_cs_ctrl() to nvmet_execute_identify_ctrl_zns() to continue handling the ZNS command set as is.
2) Introduce a nvmet_execute_identify_ctrl_ns() helper to handle the NVM command set, returning a zero filled nvme_id_ctrl_nvm data structure.
3) Modify nvmet_execute_identify() to call these helpers based on the csi specified, returning an error for unsupported command sets.
--- drivers/nvme/target/admin-cmd.c | 22 ++++++++++++++++------ drivers/nvme/target/nvmet.h | 2 +- drivers/nvme/target/zns.c | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-)
drivers/nvme/target/admin-cmd.c +16 -6
@@ -680,6 +680,13 @@ static bool nvmet_handle_identify_desclist(struct nvmet_req *req) } } +static void nvmet_execute_identify_ctrl_nvm (struct nvmet_req *req) +{ +/* Not supported: return zeroes */ +nvmet_req_complete (req, +nvmet_zero_sgl (req,0 ,sizeof (struct nvme_id_ctrl_nvm ))); +} +static void nvmet_execute_identify (struct nvmet_req *req) {if (!nvmet_check_transfer_len (req,NVME_IDENTIFY_DATA_SIZE ))
@@ -703,13 +710,16 @@ static void nvmet_execute_identify(struct nvmet_req *req)nvmet_execute_identify_ctrl (req);return ;case NVME_ID_CNS_CS_CTRL : -if (IS_ENABLED (CONFIG_BLK_DEV_ZONED )) { -switch (req->cmd->identify.csi) { -case NVME_CSI_ZNS : -return nvmet_execute_identify_cns_cs_ctrl (req); -default : -break ; +switch (req->cmd->identify.csi) { +case NVME_CSI_NVM : +nvmet_execute_identify_ctrl_nvm (req); +return ; +case NVME_CSI_ZNS : +if (IS_ENABLED (CONFIG_BLK_DEV_ZONED )) { +nvmet_execute_identify_ctrl_zns (req); +return ; } +break ; }break ;case NVME_ID_CNS_NS_ACTIVE_LIST :
drivers/nvme/target/nvmet.h +1 -1
@@ -547,7 +547,7 @@ bool nvmet_ns_revalidate(struct nvmet_ns *ns);u16 blk_to_nvme_status (struct nvmet_req *req,blk_status_t blk_sts);bool nvmet_bdev_zns_enable (struct nvmet_ns *ns); -void nvmet_execute_identify_cns_cs_ctrl (struct nvmet_req *req); +void nvmet_execute_identify_ctrl_zns (struct nvmet_req *req);void nvmet_execute_identify_cns_cs_ns (struct nvmet_req *req);void nvmet_bdev_execute_zone_mgmt_recv (struct nvmet_req *req);void nvmet_bdev_execute_zone_mgmt_send (struct nvmet_req *req);
drivers/nvme/target/zns.c +1 -1
@@ -70,7 +70,7 @@ bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)return true; } -void nvmet_execute_identify_cns_cs_ctrl (struct nvmet_req *req) +void nvmet_execute_identify_ctrl_zns (struct nvmet_req *req) {u8 zasl = req->sq->ctrl->subsys->zasl;struct nvmet_ctrl *ctrl = req->sq->ctrl;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 198/371 nvme: handle the persistent internal error AER
In reply to Greg Kroah-HartmanFrom: Michael Kelley <[email protected]>
[ Upstream commit 2c61c97fb12b806e1c8eb15f04c277ad097ec95e ]
In the NVM Express Revision 1.4 spec, Figure 145 describes possible values for an AER with event type "Error" (value 000b). For a Persistent Internal Error (value 03h), the host should perform a controller reset.
Add support for this error using code that already exists for doing a controller reset. As part of this support, introduce two utility functions for parsing the AER type and subtype.
This new support was tested in a lab environment where we can generate the persistent internal error on demand, and observe both the Linux side and NVMe controller side to see that the controller reset has been done.
Stable-dep-of: 6622b76fe922 ("nvme: fix async event trace event")
--- drivers/nvme/host/core.c | 31 +++++++++++++++++++++++++++++-- include/linux/nvme.h | 4 ++++ 2 files changed, 33 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +29 -2
@@ -4360,9 +4360,19 @@ static void nvme_fw_act_work(struct work_struct *work)nvme_get_fw_slot_info (ctrl); } +static u32 nvme_aer_type (u32 result) +{ +return result &0x7 ; +} + +static u32 nvme_aer_subtype (u32 result) +{ +return (result &0xff00 ) >>8 ; +} +static void nvme_handle_aen_notice (struct nvme_ctrl *ctrl,u32 result) { -u32 aer_notice_type = (result &0xff00 ) >>8 ; +u32 aer_notice_type =nvme_aer_subtype (result);trace_nvme_async_event (ctrl, aer_notice_type);
@@ -4395,11 +4405,19 @@ static void nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result) } } +static void nvme_handle_aer_persistent_error (struct nvme_ctrl *ctrl) +{ +trace_nvme_async_event (ctrl,NVME_AER_ERROR ); +dev_warn (ctrl->device,"resetting controller due to AER\n" ); +nvme_reset_ctrl (ctrl); +} +void nvme_complete_async_event (struct nvme_ctrl *ctrl,__le16 status,volatile union nvme_result *res) {u32 result =le32_to_cpu (res->u32); -u32 aer_type = result &0x07 ; +u32 aer_type =nvme_aer_type (result); +u32 aer_subtype =nvme_aer_subtype (result);if (le16_to_cpu (status) >>1 !=NVME_SC_SUCCESS )return ;
@@ -4409,6 +4427,15 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,nvme_handle_aen_notice (ctrl, result);break ;case NVME_AER_ERROR : +/* +* For a persistent internal error, don't run async_event_work +* to submit a new AER. The controller reset will do it. +*/ +if (aer_subtype ==NVME_AER_ERROR_PERSIST_INT_ERR ) { +nvme_handle_aer_persistent_error (ctrl); +return ; + } + fallthrough;case NVME_AER_SMART :case NVME_AER_CSS :case NVME_AER_VS :
include/linux/nvme.h +4 -0
@@ -613,6 +613,10 @@ enum { NVME_AER_VS = 7, }; +enum { +NVME_AER_ERROR_PERSIST_INT_ERR =0x03 , +}; +enum {NVME_AER_NOTICE_NS_CHANGED =0x00 ,NVME_AER_NOTICE_FW_ACT_STARTING =0x01 ,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 199/371 nvme: fix async event trace event
In reply to Greg Kroah-HartmanFrom: Keith Busch <[email protected]>
[ Upstream commit 6622b76fe922b94189499a90ccdb714a4a8d0773 ]
Mixing AER Event Type and Event Info has masking clashes. Just print the event type, but also include the event info of the AER result in the trace.
--- drivers/nvme/host/core.c | 5 +---- drivers/nvme/host/trace.h | 15 ++++++--------- 2 files changed, 7 insertions(+), 13 deletions(-)
drivers/nvme/host/core.c +1 -4
@@ -4374,8 +4374,6 @@ static void nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result) {u32 aer_notice_type =nvme_aer_subtype (result); -trace_nvme_async_event (ctrl, aer_notice_type); -switch (aer_notice_type) {case NVME_AER_NOTICE_NS_CHANGED :set_bit (NVME_AER_NOTICE_NS_CHANGED , &ctrl->events);
@@ -4407,7 +4405,6 @@ static void nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)static void nvme_handle_aer_persistent_error (struct nvme_ctrl *ctrl) { -trace_nvme_async_event (ctrl,NVME_AER_ERROR );dev_warn (ctrl->device,"resetting controller due to AER\n" );nvme_reset_ctrl (ctrl); }
@@ -4422,6 +4419,7 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,if (le16_to_cpu (status) >>1 !=NVME_SC_SUCCESS )return ; +trace_nvme_async_event (ctrl, result);switch (aer_type) {case NVME_AER_NOTICE :nvme_handle_aen_notice (ctrl, result);
@@ -4439,7 +4437,6 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,case NVME_AER_SMART :case NVME_AER_CSS :case NVME_AER_VS : -trace_nvme_async_event (ctrl, aer_type); ctrl->aen_result = result;break ;default :
drivers/nvme/host/trace.h +6 -9
@@ -127,15 +127,12 @@ TRACE_EVENT(nvme_async_event, ),TP_printk ("nvme%d: NVME_AEN=%#08x [%s]" , __entry->ctrl_id, __entry->result, -__print_symbolic (__entry->result, -aer_name (NVME_AER_NOTICE_NS_CHANGED ), -aer_name (NVME_AER_NOTICE_ANA ), -aer_name (NVME_AER_NOTICE_FW_ACT_STARTING ), -aer_name (NVME_AER_NOTICE_DISC_CHANGED ), -aer_name (NVME_AER_ERROR ), -aer_name (NVME_AER_SMART ), -aer_name (NVME_AER_CSS ), -aer_name (NVME_AER_VS )) +__print_symbolic (__entry->result &0x7 , +aer_name (NVME_AER_ERROR ), +aer_name (NVME_AER_SMART ), +aer_name (NVME_AER_NOTICE ), +aer_name (NVME_AER_CSS ), +aer_name (NVME_AER_VS )) ) );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 200/371 nvme-fcloop: fix "inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage"
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 4f86a6ff6fbd891232dda3ca97fd1b9630b59809 ]
fcloop_fcp_op() could be called from flush request's ->end_io(flush_end_io) in which the spinlock of fq->mq_flush_lock is grabbed with irq saved/disabled.
So fcloop_fcp_op() can't call spin_unlock_irq(&tfcp_req->reqlock) simply which enables irq unconditionally.
Fixes the warning by switching to spin_lock_irqsave()/spin_unlock_irqrestore()
--- drivers/nvme/target/fcloop.c | 48 ++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 21 deletions(-)
drivers/nvme/target/fcloop.c +27 -21
@@ -614,10 +614,11 @@ fcloop_fcp_recv_work(struct work_struct *work)struct fcloop_fcpreq *tfcp_req = container_of(work, struct fcloop_fcpreq, fcp_rcv_work);struct nvmefc_fcp_req *fcpreq = tfcp_req->fcpreq; +unsigned long flags;int ret =0 ;bool aborted = false; -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags);switch (tfcp_req->inistate) {case INI_IO_START : tfcp_req->inistate =INI_IO_ACTIVE ;
@@ -626,11 +627,11 @@ fcloop_fcp_recv_work(struct work_struct *work) aborted = true;break ;default : -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);WARN_ON (1 );return ; } -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);if (unlikely (aborted)) ret = -ECANCELED ;
@@ -655,8 +656,9 @@ fcloop_fcp_abort_recv_work(struct work_struct *work) container_of(work, struct fcloop_fcpreq, abort_rcv_work);struct nvmefc_fcp_req *fcpreq;bool completed = false; +unsigned long flags; -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); fcpreq = tfcp_req->fcpreq;switch (tfcp_req->inistate) {case INI_IO_ABORTED :
@@ -665,11 +667,11 @@ fcloop_fcp_abort_recv_work(struct work_struct *work) completed = true;break ;default : -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);WARN_ON (1 );return ; } -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);if (unlikely (completed)) {/* remove reference taken in original abort downcall */
@@ -681,9 +683,9 @@ fcloop_fcp_abort_recv_work(struct work_struct *work)nvmet_fc_rcv_fcp_abort (tfcp_req->tport->targetport, &tfcp_req->tgt_fcp_req); -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); tfcp_req->fcpreq =NULL ; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);fcloop_call_host_done (fcpreq, tfcp_req, -ECANCELED );/* call_host_done releases reference for abort downcall */
@@ -699,11 +701,12 @@ fcloop_tgt_fcprqst_done_work(struct work_struct *work)struct fcloop_fcpreq *tfcp_req = container_of(work, struct fcloop_fcpreq, tio_done_work);struct nvmefc_fcp_req *fcpreq; +unsigned long flags; -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); fcpreq = tfcp_req->fcpreq; tfcp_req->inistate =INI_IO_COMPLETED ; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);fcloop_call_host_done (fcpreq, tfcp_req, tfcp_req->status); }
@@ -807,13 +810,14 @@ fcloop_fcp_op(struct nvmet_fc_target_port *tgtport,u32 rsplen =0 , xfrlen =0 ;int fcp_err =0 , active, aborted;u8 op = tgt_fcpreq->op; +unsigned long flags; -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); fcpreq = tfcp_req->fcpreq; active = tfcp_req->active; aborted = tfcp_req->aborted; tfcp_req->active = true; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);if (unlikely (active))/* illegal - call while i/o active */
@@ -821,9 +825,9 @@ fcloop_fcp_op(struct nvmet_fc_target_port *tgtport,if (unlikely (aborted)) {/* target transport has aborted i/o prior */ -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); tfcp_req->active = false; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags); tgt_fcpreq->transferred_length =0 ; tgt_fcpreq->fcp_error = -ECANCELED ; tgt_fcpreq->done (tgt_fcpreq);
@@ -880,9 +884,9 @@ fcloop_fcp_op(struct nvmet_fc_target_port *tgtport,break ; } -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); tfcp_req->active = false; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags); tgt_fcpreq->transferred_length = xfrlen; tgt_fcpreq->fcp_error = fcp_err;
@@ -896,15 +900,16 @@ fcloop_tgt_fcp_abort(struct nvmet_fc_target_port *tgtport, struct nvmefc_tgt_fcp_req *tgt_fcpreq) {struct fcloop_fcpreq *tfcp_req =tgt_fcp_req_to_fcpreq (tgt_fcpreq); +unsigned long flags;/* * mark aborted only in case there were 2 threads in transport * (one doing io, other doing abort) and only kills ops posted * after the abort request */ -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); tfcp_req->aborted = true; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags); tfcp_req->status =NVME_SC_INTERNAL ;
@@ -946,6 +951,7 @@ fcloop_fcp_abort(struct nvme_fc_local_port *localport,struct fcloop_ini_fcpreq *inireq = fcpreq->private;struct fcloop_fcpreq *tfcp_req;bool abortio = true; +unsigned long flags;spin_lock (&inireq->inilock); tfcp_req = inireq->tfcp_req;
@@ -958,7 +964,7 @@ fcloop_fcp_abort(struct nvme_fc_local_port *localport,return ;/* break initiator/target relationship for io */ -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags);switch (tfcp_req->inistate) {case INI_IO_START :case INI_IO_ACTIVE :
@@ -968,11 +974,11 @@ fcloop_fcp_abort(struct nvme_fc_local_port *localport, abortio = false;break ;default : -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);WARN_ON (1 );return ; } -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);if (abortio)/* leave the reference while the work item is scheduled */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 201/371 selftests/bpf: Fix leaked bpf_link in get_stackid_cannot_attach
In reply to Greg Kroah-HartmanFrom: Song Liu <[email protected]>
[ Upstream commit c1e07a80cf23d3a6e96172bc9a73bfa912a9fcbc ]
skel->links.oncpu is leaked in one case. This causes test perf_branches fails when it runs after get_stackid_cannot_attach:
./test_progs -t get_stackid_cannot_attach,perf_branches
84 get_stackid_cannot_attach:OK
test_perf_branches_common:PASS:test_perf_branches_load 0 nsec test_perf_branches_common:PASS:attach_perf_event 0 nsec test_perf_branches_common:PASS:set_affinity 0 nsec check_good_sample:FAIL:output not valid no valid sample from prog
146/1 perf_branches/perf_branches_hw:FAIL 146/2 perf_branches/perf_branches_no_hw:OK 146 perf_branches:FAIL
All error logs:
test_perf_branches_common:PASS:test_perf_branches_load 0 nsec test_perf_branches_common:PASS:attach_perf_event 0 nsec test_perf_branches_common:PASS:set_affinity 0 nsec check_good_sample:FAIL:output not valid no valid sample from prog
146/1 perf_branches/perf_branches_hw:FAIL
146 perf_branches:FAIL
Summary: 1/1 PASSED, 0 SKIPPED, 1 FAILED
Fix this by adding the missing bpf_link__destroy().
--- .../testing/selftests/bpf/prog_tests/get_stackid_cannot_attach.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/get_stackid_cannot_attach.c +1 -0
@@ -65,6 +65,7 @@ void test_get_stackid_cannot_attach(void) skel->links.oncpu =bpf_program__attach_perf_event (skel->progs.oncpu, pmu_fd);ASSERT_OK_PTR (skel->links.oncpu,"attach_perf_event_callchain" ); +bpf_link__destroy (skel->links.oncpu);close (pmu_fd);/* add exclude_callchain_kernel, attach should fail */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 202/371 bpf, sockmap: Revert buggy deadlock fix in the sockhash and sockmap
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
[ Upstream commit 8c5c2a4898e3d6bad86e29d471e023c8a19ba799 ]
syzbot reported a splat and bisected it to recent commit ed17aa92dc56 ("bpf,
sockmap: fix deadlocks in the sockhash and sockmap"):
[...]
WARNING: CPU: 1 PID: 9280 at kernel/softirq.c:376 __local_bh_enable_ip+0xbe/0x130 kernel/softirq.c:376 Modules linked in: CPU: 1 PID: 9280 Comm: syz-executor.1 Not tainted 6.2.0-syzkaller-13249-gd319f344561d #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023 RIP: 0010:__local_bh_enable_ip+0xbe/0x130 kernel/softirq.c:376 [...] Call Trace: <TASK> spin_unlock_bh include/linux/spinlock.h:395 [inline] sock_map_del_link+0x2ea/0x510 net/core/sock_map.c:165 sock_map_unref+0xb0/0x1d0 net/core/sock_map.c:184 sock_hash_delete_elem+0x1ec/0x2a0 net/core/sock_map.c:945 map_delete_elem kernel/bpf/syscall.c:1536 [inline] __sys_bpf+0x2edc/0x53e0 kernel/bpf/syscall.c:5053 __do_sys_bpf kernel/bpf/syscall.c:5166 [inline] __se_sys_bpf kernel/bpf/syscall.c:5164 [inline] __x64_sys_bpf+0x79/0xc0 kernel/bpf/syscall.c:5164 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fe8f7c8c169 </TASK> [...]
Revert for now until we have a proper solution.
--- net/core/sock_map.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
net/core/sock_map.c +4 -6
@@ -414,9 +414,8 @@ static int __sock_map_delete(struct bpf_stab *stab, struct sock *sk_test, {struct sock *sk;int err =0 ; -unsigned long flags; -raw_spin_lock_irqsave (&stab->lock, flags); +raw_spin_lock_bh (&stab->lock); sk = *psk;if (!sk_test || sk_test == sk) sk =xchg (psk,NULL );
@@ -426,7 +425,7 @@ static int __sock_map_delete(struct bpf_stab *stab, struct sock *sk_test,else err = -EINVAL ; -raw_spin_unlock_irqrestore (&stab->lock, flags); +raw_spin_unlock_bh (&stab->lock);return err; }
@@ -931,12 +930,11 @@ static int sock_hash_delete_elem(struct bpf_map *map, void *key)struct bpf_shtab_bucket *bucket;struct bpf_shtab_elem *elem;int ret = -ENOENT ; -unsigned long flags; hash =sock_hash_bucket_hash (key, key_size); bucket =sock_hash_select_bucket (htab, hash); -raw_spin_lock_irqsave (&bucket->lock, flags); +raw_spin_lock_bh (&bucket->lock); elem =sock_hash_lookup_elem_raw (&bucket->head, hash, key, key_size);if (elem) {hlist_del_rcu (&elem->node);
@@ -944,7 +942,7 @@ static int sock_hash_delete_elem(struct bpf_map *map, void *key)sock_hash_free_elem (htab, elem); ret =0 ; } -raw_spin_unlock_irqrestore (&bucket->lock, flags); +raw_spin_unlock_bh (&bucket->lock);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 203/371 md: drop queue limitation for RAID1 and RAID10
In reply to Greg Kroah-HartmanFrom: Mariusz Tkaczyk <[email protected]>
[ Upstream commit a92ce0feffeed8b91f02dac85246d1205e4a64b6 ]
As suggested by Neil Brown[1], this limitation seems to be deprecated.
With plugging in use, writes are processed behind the raid thread and conf->pending_count is not increased. This limitation occurs only if caller doesn't use plugs.
It can be avoided and often it is (with plugging). There are no reports that queue is growing to enormous size so remove queue limitation for non-plugged IOs too.
[1] https://lore.kernel.org/linux-raid/[email protected]
Stable-dep-of: 72c215ed8731 ("md/raid10: fix task hung in raid10d")
--- drivers/md/raid1-10.c | 6 ------ drivers/md/raid1.c | 7 ------- drivers/md/raid10.c | 7 ------- 3 files changed, 20 deletions(-)
drivers/md/raid1-10.c +0 -6
@@ -22,12 +22,6 @@#define BIO_SPECIAL (bio) ((unsigned long)bio <= 2) -/* When there are this many requests queue to be written by -* the raid thread, we become 'congested' to provide back-pressure -* for writeback. -*/ -static int max_queued_requests =1024 ; -/* for managing resync I/O pages */ struct resync_pages {void *raid_bio;
drivers/md/raid1.c +0 -7
@@ -1358,12 +1358,6 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, r1_bio =alloc_r1bio (mddev, bio); r1_bio->sectors = max_write_sectors; -if (conf->pending_count >= max_queued_requests) { -md_wakeup_thread (mddev->thread); -raid1_log (mddev,"wait queued" ); -wait_event (conf->wait_barrier, - conf->pending_count < max_queued_requests); - }/* first select target devices under rcu_lock and * inc refcount on their rdev. Record them by setting * bios[x] to bio
@@ -3413,4 +3407,3 @@ MODULE_ALIAS("md-personality-3"); /* RAID1 */MODULE_ALIAS ("md-raid1" );MODULE_ALIAS ("md-level-1" ); -module_param (max_queued_requests, int,S_IRUGO |S_IWUSR );
drivers/md/raid10.c +0 -7
@@ -1387,12 +1387,6 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, conf->reshape_safe = mddev->reshape_position; } -if (conf->pending_count >= max_queued_requests) { -md_wakeup_thread (mddev->thread); -raid10_log (mddev,"wait queued" ); -wait_event (conf->wait_barrier, - conf->pending_count < max_queued_requests); - }/* first select target devices under rcu_lock and * inc refcount on their rdev. Record them by setting * bios[x] to bio
@@ -5246,4 +5240,3 @@ MODULE_ALIAS("md-personality-9"); /* RAID10 */MODULE_ALIAS ("md-raid10" );MODULE_ALIAS ("md-level-10" ); -module_param (max_queued_requests, int,S_IRUGO |S_IWUSR );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 204/371 md: raid10 add nowait support
In reply to Greg Kroah-HartmanFrom: Vishal Verma <[email protected]>
[ Upstream commit c9aa889b035fca4598ae985a0f0c76ebbb547ad2 ]
This adds nowait support to the RAID10 driver. Very similar to raid1 driver changes. It makes RAID10 driver return with EAGAIN for situations where it could wait for eg:
- Waiting for the barrier,
- Reshape operation,
- Discard operation.
wait_barrier() and regular_request_wait() fn are modified to return bool to support error for wait barriers. They returns true in case of wait or if wait is not required and returns false if wait was required but not performed to support nowait.
Stable-dep-of: 72c215ed8731 ("md/raid10: fix task hung in raid10d")
--- drivers/md/raid10.c | 100 +++++++++++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 33 deletions(-)
drivers/md/raid10.c +67 -33
@@ -952,8 +952,10 @@ static void lower_barrier(struct r10conf *conf)wake_up (&conf->wait_barrier); } -static void wait_barrier (struct r10conf *conf) +static bool wait_barrier (struct r10conf *conf,bool nowait) { +bool ret = true; +spin_lock_irq (&conf->resync_lock);if (conf->barrier) {struct bio_list *bio_list = current->bio_list;
@@ -967,27 +969,35 @@ static void wait_barrier(struct r10conf *conf)* that queue to get the nr_pending * count down. */ -raid10_log (conf->mddev,"wait barrier" ); -wait_event_lock_irq (conf->wait_barrier, - !conf->barrier || - (atomic_read (&conf->nr_pending) && - bio_list && - (!bio_list_empty (&bio_list[0 ]) || - !bio_list_empty (&bio_list[1 ]))) || -/* move on if recovery thread is -* blocked by us -*/ - (conf->mddev->thread->tsk == current && -test_bit (MD_RECOVERY_RUNNING , - &conf->mddev->recovery) && - conf->nr_queued >0 ), - conf->resync_lock); +/* Return false when nowait flag is set */ +if (nowait) { + ret = false; + }else { +raid10_log (conf->mddev,"wait barrier" ); +wait_event_lock_irq (conf->wait_barrier, + !conf->barrier || + (atomic_read (&conf->nr_pending) && + bio_list && + (!bio_list_empty (&bio_list[0 ]) || + !bio_list_empty (&bio_list[1 ]))) || +/* move on if recovery thread is +* blocked by us +*/ + (conf->mddev->thread->tsk == current && +test_bit (MD_RECOVERY_RUNNING , + &conf->mddev->recovery) && + conf->nr_queued >0 ), + conf->resync_lock); + } conf->nr_waiting--;if (!conf->nr_waiting)wake_up (&conf->wait_barrier); } -atomic_inc (&conf->nr_pending); +/* Only increment nr_pending when we wait */ +if (ret) +atomic_inc (&conf->nr_pending);spin_unlock_irq (&conf->resync_lock); +return ret; }static void allow_barrier (struct r10conf *conf)
@@ -1098,21 +1108,30 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)* currently. * 2. If IO spans the reshape position. Need to wait for reshape to pass. */ -static void regular_request_wait (struct mddev *mddev,struct r10conf *conf, +static bool regular_request_wait (struct mddev *mddev,struct r10conf *conf,struct bio *bio,sector_t sectors) { -wait_barrier (conf); +/* Bail out if REQ_NOWAIT is set for the bio */ +if (!wait_barrier (conf, bio->bi_opf &REQ_NOWAIT )) { +bio_wouldblock_error (bio); +return false; + }while (test_bit (MD_RECOVERY_RESHAPE , &mddev->recovery) && bio->bi_iter.bi_sector < conf->reshape_progress && bio->bi_iter.bi_sector + sectors > conf->reshape_progress) { -raid10_log (conf->mddev,"wait reshape" );allow_barrier (conf); +if (bio->bi_opf &REQ_NOWAIT ) { +bio_wouldblock_error (bio); +return false; + } +raid10_log (conf->mddev,"wait reshape" );wait_event (conf->wait_barrier, conf->reshape_progress <= bio->bi_iter.bi_sector || conf->reshape_progress >= bio->bi_iter.bi_sector + sectors); -wait_barrier (conf); +wait_barrier (conf, false); } +return true; } static void raid10_read_request(struct mddev *mddev, struct bio *bio,
@@ -1157,7 +1176,8 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,rcu_read_unlock (); } -regular_request_wait (mddev, conf, bio, r10_bio->sectors); +if (!regular_request_wait (mddev, conf, bio, r10_bio->sectors)) +return ; rdev =read_balance (conf, r10_bio, &max_sectors);if (!rdev) {if (err_rdev) {
@@ -1179,7 +1199,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,bio_chain (split, bio);allow_barrier (conf);submit_bio_noacct (bio); -wait_barrier (conf); +wait_barrier (conf, false); bio = split; r10_bio->master_bio = bio; r10_bio->sectors = max_sectors;
@@ -1338,7 +1358,7 @@ static void wait_blocked_dev(struct mddev *mddev, struct r10bio *r10_bio)raid10_log (conf->mddev,"%s wait rdev %d blocked" , __func__, blocked_rdev->raid_disk);md_wait_for_blocked_rdev (blocked_rdev, mddev); -wait_barrier (conf); +wait_barrier (conf, false); goto retry_wait; } }
@@ -1356,6 +1376,11 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, bio->bi_iter.bi_sector, bio_end_sector(bio)))) {DEFINE_WAIT (w); +/* Bail out if REQ_NOWAIT is set for the bio */ +if (bio->bi_opf &REQ_NOWAIT ) { +bio_wouldblock_error (bio); +return ; + }for (;;) {prepare_to_wait (&conf->wait_barrier, &w,TASK_IDLE );
@@ -1368,7 +1393,8 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, } sectors = r10_bio->sectors; -regular_request_wait (mddev, conf, bio, sectors); +if (!regular_request_wait (mddev, conf, bio, sectors)) +return ; if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && (mddev->reshape_backwards ? (bio->bi_iter.bi_sector < conf->reshape_safe &&
@@ -1380,6 +1406,11 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,set_mask_bits (&mddev->sb_flags,0 ,BIT (MD_SB_CHANGE_DEVS ) |BIT (MD_SB_CHANGE_PENDING ));md_wakeup_thread (mddev->thread); +if (bio->bi_opf &REQ_NOWAIT ) { +allow_barrier (conf); +bio_wouldblock_error (bio); +return ; + }raid10_log (conf->mddev,"wait reshape metadata" );wait_event (mddev->sb_wait, !test_bit (MD_SB_CHANGE_PENDING , &mddev->sb_flags));
@@ -1476,7 +1507,7 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,bio_chain (split, bio);allow_barrier (conf);submit_bio_noacct (bio); -wait_barrier (conf); +wait_barrier (conf, false); bio = split; r10_bio->master_bio = bio; }
@@ -1601,7 +1632,11 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)if (test_bit (MD_RECOVERY_RESHAPE , &mddev->recovery))return -EAGAIN ; -wait_barrier (conf); +if (WARN_ON_ONCE (bio->bi_opf &REQ_NOWAIT )) { +bio_wouldblock_error (bio); +return 0 ; + } +wait_barrier (conf, false);/* * Check reshape again to avoid reshape happens after checking
@@ -1643,7 +1678,7 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)allow_barrier (conf);/* Resend the fist split part */ submit_bio_noacct (split); -wait_barrier (conf); +wait_barrier (conf, false); }div_u64_rem (bio_end, stripe_size, &remainder);if (remainder) {
@@ -1654,7 +1689,7 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)/* Resend the second split part */ submit_bio_noacct (bio); bio = split; -wait_barrier (conf); +wait_barrier (conf, false); } bio_start = bio->bi_iter.bi_sector;
@@ -1810,7 +1845,7 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio) end_disk_offset += geo->stride;atomic_inc (&first_r10bio->remaining);raid_end_discard_bio (r10_bio); -wait_barrier (conf); +wait_barrier (conf, false); goto retry_discard; }
@@ -2005,7 +2040,7 @@ static void print_conf(struct r10conf *conf)static void close_sync (struct r10conf *conf) { -wait_barrier (conf); +wait_barrier (conf, false);allow_barrier (conf);mempool_exit (&conf->r10buf_pool);
@@ -4816,7 +4851,7 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr,if (need_flush ||time_after (jiffies, conf->reshape_checkpoint +10 *HZ )) {/* Need to update reshape_position in metadata */ -wait_barrier (conf); +wait_barrier (conf, false); mddev->reshape_position = conf->reshape_progress;if (mddev->reshape_backwards) mddev->curr_resync_completed =raid10_size (mddev,0 ,0 )
@@ -5239,4 +5274,3 @@ MODULE_DESCRIPTION("RAID10 (striped mirror) personality for MD");MODULE_ALIAS ("md-personality-9" );/* RAID10 */ MODULE_ALIAS ("md-raid10" );MODULE_ALIAS ("md-level-10" ); -
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 205/371 md/raid10: factor out code from wait_barrier() to stop_waiting_barrier()
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit ed2e063f92c44c891ccd883e289dde6ca870edcc ]
Currently the nasty condition in wait_barrier() is hard to read. This patch factors out the condition into a function.
There are no functional changes.
Stable-dep-of: 72c215ed8731 ("md/raid10: fix task hung in raid10d")
--- drivers/md/raid10.c | 50 +++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 22 deletions(-)
drivers/md/raid10.c +28 -22
@@ -952,41 +952,47 @@ static void lower_barrier(struct r10conf *conf)wake_up (&conf->wait_barrier); } +static bool stop_waiting_barrier (struct r10conf *conf) +{ +struct bio_list *bio_list = current->bio_list; + +/* barrier is dropped */ +if (!conf->barrier) +return true; + +/* +* If there are already pending requests (preventing the barrier from +* rising completely), and the pre-process bio queue isn't empty, then +* don't wait, as we need to empty that queue to get the nr_pending +* count down. +*/ +if (atomic_read (&conf->nr_pending) && bio_list && + (!bio_list_empty (&bio_list[0 ]) || !bio_list_empty (&bio_list[1 ]))) +return true; + +/* move on if recovery thread is blocked by us */ +if (conf->mddev->thread->tsk == current && +test_bit (MD_RECOVERY_RUNNING , &conf->mddev->recovery) && + conf->nr_queued >0 ) +return true; + +return false; +} +static bool wait_barrier (struct r10conf *conf,bool nowait) {bool ret = true;spin_lock_irq (&conf->resync_lock);if (conf->barrier) { -struct bio_list *bio_list = current->bio_list; conf->nr_waiting++; -/* Wait for the barrier to drop. -* However if there are already pending -* requests (preventing the barrier from -* rising completely), and the -* pre-process bio queue isn't empty, -* then don't wait, as we need to empty -* that queue to get the nr_pending -* count down. -*/ /* Return false when nowait flag is set */ if (nowait) { ret = false; }else {raid10_log (conf->mddev,"wait barrier" );wait_event_lock_irq (conf->wait_barrier, - !conf->barrier || - (atomic_read (&conf->nr_pending) && - bio_list && - (!bio_list_empty (&bio_list[0 ]) || - !bio_list_empty (&bio_list[1 ]))) || -/* move on if recovery thread is -* blocked by us -*/ - (conf->mddev->thread->tsk == current && -test_bit (MD_RECOVERY_RUNNING , - &conf->mddev->recovery) && - conf->nr_queued >0 ), +stop_waiting_barrier (conf), conf->resync_lock); } conf->nr_waiting--;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 206/371 md/raid10: fix task hung in raid10d
In reply to Greg Kroah-HartmanFrom: Li Nan <[email protected]>
[ Upstream commit 72c215ed8731c88b2d7e09afc51fffc207ae47b8 ]
commit fe630de009d0 ("md/raid10: avoid deadlock on recovery.") allowed normal io and sync io to exist at the same time. Task hung will occur as below:
T1 T2 T3 T4
raid10d
handle_read_error
allow_barrier
conf->nr_pending--
-> 0
//submit sync io
raid10_sync_request
raise_barrier
->will not be blocked
...
//submit to drivers
raid10_read_request
wait_barrier
conf->nr_pending++
-> 1
//retry read fail
raid10_end_read_request
reschedule_retry
add to retry_list
conf->nr_queued++
-> 1
//sync io fail
end_sync_read
__end_sync_read
reschedule_retry
add to retry_list
conf->nr_queued++
-> 2
...
handle_read_error
get form retry_list
conf->nr_queued--
freeze_array
wait nr_pending == nr_queued+1
->1 ->2//task hung
retry read and sync io will be added to retry_list(nr_queued->2) if they fails. raid10d() called handle_read_error() and hung in freeze_array(). nr_queued will not decrease because raid10d is blocked, nr_pending will not increase because conf->barrier is not released.
Fix it by moving allow_barrier() after raid10_read_request(). raise_barrier() will wait for nr_waiting to become 0. Therefore, sync io and regular io will not be issued at the same time.
Also remove the check of nr_queued in stop_waiting_barrier. It can be 0 but don't need to be blocking. Remove the check for MD_RECOVERY_RUNNING as the check is redundent.
--- drivers/md/raid10.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/md/raid10.c +13 -5
@@ -970,11 +970,15 @@ static bool stop_waiting_barrier(struct r10conf *conf) (!bio_list_empty(&bio_list[0]) || !bio_list_empty(&bio_list[1])))return true; -/* move on if recovery thread is blocked by us */ -if (conf->mddev->thread->tsk == current && -test_bit (MD_RECOVERY_RUNNING , &conf->mddev->recovery) && - conf->nr_queued >0 ) +/* +* move on if io is issued from raid10d(), nr_pending is not released +* from original io(see handle_read_error()). All raise barrier is +* blocked until this io is done. +*/ +if (conf->mddev->thread->tsk == current) { +WARN_ON_ONCE (atomic_read (&conf->nr_pending) ==0 );return true; + }return false; }
@@ -2954,9 +2958,13 @@ static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio)md_error (mddev, rdev);rdev_dec_pending (rdev, mddev); -allow_barrier (conf); r10_bio->state =0 ;raid10_read_request (mddev, r10_bio->master_bio, r10_bio); +/* +* allow_barrier after re-submit to ensure no sync io +* can be issued while regular io pending. +*/ +allow_barrier (conf); }static void handle_write_completed (struct r10conf *conf,struct r10bio *r10_bio)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 207/371 md/raid10: fix leak of r10bio->remaining for recovery
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit 26208a7cffd0c7cbf14237ccd20c7270b3ffeb7e ]
raid10_sync_request() will add 'r10bio->remaining' for both rdev and replacement rdev. However, if the read io fails, recovery_request_write() returns without issuing the write io, in this case, end_sync_request() is only called once and 'remaining' is leaked, cause an io hang.
Fix the problem by decreasing 'remaining' according to if 'bio' and 'repl_bio' is valid.
--- drivers/md/raid10.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/md/raid10.c +13 -10
@@ -2581,11 +2581,22 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio) {struct r10conf *conf = mddev->private;int d; -struct bio *wbio, *wbio2; +struct bio *wbio = r10_bio->devs[1 ].bio; +struct bio *wbio2 = r10_bio->devs[1 ].repl_bio; + +/* Need to test wbio2->bi_end_io before we call +* submit_bio_noacct as if the former is NULL, +* the latter is free to free wbio2. +*/ +if (wbio2 && !wbio2->bi_end_io) + wbio2 =NULL ;if (!test_bit (R10BIO_Uptodate, &r10_bio->state)) {fix_recovery_read_error (r10_bio); -end_sync_request (r10_bio); +if (wbio->bi_end_io) +end_sync_request (r10_bio); +if (wbio2) +end_sync_request (r10_bio);return ; }
@@ -2594,14 +2605,6 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio)* and submit the write request */ d = r10_bio->devs[1 ].devnum; - wbio = r10_bio->devs[1 ].bio; - wbio2 = r10_bio->devs[1 ].repl_bio; -/* Need to test wbio2->bi_end_io before we call -* submit_bio_noacct as if the former is NULL, -* the latter is free to free wbio2. -*/ -if (wbio2 && !wbio2->bi_end_io) - wbio2 =NULL ;if (wbio->bi_end_io) {atomic_inc (&conf->mirrors[d].rdev->nr_pending);md_sync_acct (conf->mirrors[d].rdev->bdev,bio_sectors (wbio));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 208/371 md/raid10: fix memleak for conf->bio_split
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit c9ac2acde53f5385de185bccf6aaa91cf9ac1541 ]
In the error path of raid10_run(), 'conf' need be freed, however, 'conf->bio_split' is missed and memory will be leaked.
Since there are 3 places to free 'conf', factor out a helper to fix the problem.
--- drivers/md/raid10.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-)
drivers/md/raid10.c +17 -20
@@ -3991,6 +3991,20 @@ static int setup_geo(struct geom *geo, struct mddev *mddev, enum geo_type new)return nc*fc; } +static void raid10_free_conf (struct r10conf *conf) +{ +if (!conf) +return ; + +mempool_exit (&conf->r10bio_pool); +kfree (conf->mirrors); +kfree (conf->mirrors_old); +kfree (conf->mirrors_new); +safe_put_page (conf->tmppage); +bioset_exit (&conf->bio_split); +kfree (conf); +} +static struct r10conf *setup_conf (struct mddev *mddev) {struct r10conf *conf =NULL ;
@@ -4073,13 +4087,7 @@ static struct r10conf *setup_conf(struct mddev *mddev)return conf; out: -if (conf) { -mempool_exit (&conf->r10bio_pool); -kfree (conf->mirrors); -safe_put_page (conf->tmppage); -bioset_exit (&conf->bio_split); -kfree (conf); - } +raid10_free_conf (conf);return ERR_PTR (err); }
@@ -4285,10 +4293,7 @@ static int raid10_run(struct mddev *mddev) out_free_conf:md_unregister_thread (&mddev->thread); -mempool_exit (&conf->r10bio_pool); -safe_put_page (conf->tmppage); -kfree (conf->mirrors); -kfree (conf); +raid10_free_conf (conf); mddev->private =NULL ; out:return -EIO ;
@@ -4296,15 +4301,7 @@ static int raid10_run(struct mddev *mddev)static void raid10_free (struct mddev *mddev,void *priv) { -struct r10conf *conf = priv; - -mempool_exit (&conf->r10bio_pool); -safe_put_page (conf->tmppage); -kfree (conf->mirrors); -kfree (conf->mirrors_old); -kfree (conf->mirrors_new); -bioset_exit (&conf->bio_split); -kfree (conf); +raid10_free_conf (priv); }static void raid10_quiesce (struct mddev *mddev,int quiesce)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 209/371 md/raid10: fix memleak of md thread
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit f0ddb83da3cbbf8a1f9087a642c448ff52ee9abd ]
In raid10_run(), if setup_conf() succeed and raid10_run() failed before setting 'mddev->thread', then in the error path 'conf->thread' is not freed.
Fix the problem by setting 'mddev->thread' right after setup_conf().
--- drivers/md/raid10.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/md/raid10.c +3 -3
@@ -4125,6 +4125,9 @@ static int raid10_run(struct mddev *mddev)if (!conf) goto out; + mddev->thread = conf->thread; + conf->thread =NULL ; +if (mddev_is_clustered (conf->mddev)) {int fc, fo;
@@ -4137,9 +4140,6 @@ static int raid10_run(struct mddev *mddev) } } - mddev->thread = conf->thread; - conf->thread =NULL ; -if (mddev->queue) {blk_queue_max_discard_sectors (mddev->queue,UINT_MAX );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 210/371 md/raid10: dont call bio_start_io_acct twice for bio which experienced read error
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit 7cddb055bfda5f7b0be931e8ea750fc28bc18a27 ]
handle_read_error() will resumit r10_bio by raid10_read_request(), which will call bio_start_io_acct() again, while bio_end_io_acct() will only be called once.
Fix the problem by don't account io again from handle_read_error().
--- drivers/md/raid10.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/raid10.c +3 -1
@@ -1216,7 +1216,8 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio, } slot = r10_bio->read_slot; -if (blk_queue_io_stat (bio->bi_bdev->bd_disk->queue)) +if (!r10_bio->start_time && +blk_queue_io_stat (bio->bi_bdev->bd_disk->queue)) r10_bio->start_time =bio_start_io_acct (bio); read_bio =bio_clone_fast (bio, gfp, &mddev->bio_set);
@@ -1550,6 +1551,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio, int sectors) r10_bio->sector = bio->bi_iter.bi_sector; r10_bio->state =0 ; r10_bio->read_slot =-1 ; + r10_bio->start_time =0 ;memset (r10_bio->devs,0 ,sizeof (r10_bio->devs[0 ]) * conf->geo.raid_disks);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 211/371 wifi: iwlwifi: yoyo: skip dump correctly on hw error
In reply to Greg Kroah-HartmanFrom: Daniel Gabay <[email protected]>
[ Upstream commit 11195ab0d6f3202cf7af1a4c69570f59c377d8ad ]
When NIC is in a bad state, reading data will return 28 bits as 0xa5a5a5a and the lowest 4 bits are not fixed value.
Mask these bits in a few places to skip the dump correctly.
--- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +2 -2
@@ -1022,7 +1022,7 @@ iwl_dump_ini_prph_mac_iter(struct iwl_fw_runtime *fwrt, range->range_data_size = reg->dev_addr.size;for (i =0 ; i <le32_to_cpu (reg->dev_addr.size); i +=4 ) { prph_val =iwl_read_prph (fwrt->trans, addr + i); -if (prph_val ==0x5a5a5a5a ) +if ((prph_val & ~0xf ) ==0xa5a5a5a0 )return -EBUSY ; *val++ =cpu_to_le32 (prph_val); }
@@ -1536,7 +1536,7 @@ iwl_dump_ini_dbgi_sram_iter(struct iwl_fw_runtime *fwrt, prph_data =iwl_read_prph (fwrt->trans, (i %2 ) ?DBGI_SRAM_TARGET_ACCESS_RDATA_MSB :DBGI_SRAM_TARGET_ACCESS_RDATA_LSB ); -if (prph_data ==0x5a5a5a5a ) { +if ((prph_data & ~0xf ) ==0xa5a5a5a0 ) {iwl_trans_release_nic_access (fwrt->trans);return -EBUSY ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 212/371 wifi: iwlwifi: yoyo: Fix possible division by zero
In reply to Greg Kroah-HartmanFrom: Daniel Gabay <[email protected]>
[ Upstream commit ba30415118eee374a08b39a0460a1d1e52c24a25 ]
Don't allow buffer allocation TLV with zero req_size since it leads later to division by zero in iwl_dbg_tlv_alloc_fragments(). Also, NPK/SRAM locations are allowed to have zero buffer req_size, don't discard them.
--- drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c +6 -0
@@ -134,6 +134,12 @@ static int iwl_dbg_tlv_alloc_buf_alloc(struct iwl_trans *trans, alloc_id != IWL_FW_INI_ALLOCATION_ID_DBGC1) goto err; +if (buf_location ==IWL_FW_INI_LOCATION_DRAM_PATH && + alloc->req_size ==0 ) { +IWL_ERR (trans,"WRT: Invalid DRAM buffer allocation requested size (0)\n" ); +return -EINVAL ; + } + trans->dbg.fw_mon_cfg[alloc_id] = *alloc;return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 213/371 wifi: iwlwifi: mvm: initialize seq variable
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
[ Upstream commit 11e94d2bcd88dea5d9ce99555b6b172f5232d3e2 ]
Clang static analysis reports this issue
d3.c:567:22: warning: The left operand of '>' is
a garbage value
if (seq.tkip.iv32 > cur_rx_iv32)
~~~~~~~~~~~~~ ^
seq is never initialized. Call ieee80211_get_key_rx_seq() to initialize seq.
--- drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/intel/iwlwifi/mvm/d3.c +1 -0
@@ -564,6 +564,7 @@ static void iwl_mvm_wowlan_get_tkip_data(struct ieee80211_hw *hw, }for (i =0 ; i <IWL_NUM_RSC ; i++) { +ieee80211_get_key_rx_seq (key, i, &seq);/* wrapping isn't allowed, AP must rekey */ if (seq.tkip.iv32 > cur_rx_iv32) cur_rx_iv32 = seq.tkip.iv32;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 214/371 wifi: iwlwifi: fw: move memset before early return
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
[ Upstream commit 8ce437dd5b2e4adef13aa4ecce07392f9966b1ab ]
Clang static analysis reports this representative issue dbg.c:1455:6: warning: Branch condition evaluates to a garbage value
if (!rxf_data.size)
^~~~~~~~~~~~~~
This check depends on iwl_ini_get_rxf_data() to clear rxf_data but the function can return early without doing the clear. So move the memset before the early return.
--- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +2 -2
@@ -1362,13 +1362,13 @@ static void iwl_ini_get_rxf_data(struct iwl_fw_runtime *fwrt,if (!data)return ; +memset (data,0 ,sizeof (*data)); +/* make sure only one bit is set in only one fid */ if (WARN_ONCE (hweight_long (fid1) +hweight_long (fid2) !=1 ,"fid1=%x, fid2=%x\n" , fid1, fid2))return ; -memset (data,0 ,sizeof (*data)); -if (fid1) { fifo_idx =ffs (fid1) -1 ; if (WARN_ONCE(fifo_idx >= MAX_NUM_LMAC, "fifo_idx=%d\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 215/371 jdb2: Dont refuse invalidation of already invalidated buffers
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
[ Upstream commit bd159398a2d2234de07d310132865706964aaaa7 ]
When invalidating buffers under the partial tail page, jbd2_journal_invalidate_folio() returns -EBUSY if the buffer is part of the committing transaction as we cannot safely modify buffer state. However if the buffer is already invalidated (due to previous invalidation attempts from ext4_wait_for_tail_page_commit()), there's nothing to do and there's no point in returning -EBUSY. This fixes occasional warnings from ext4_journalled_invalidate_folio() triggered by generic/051 fstest when blocksize < pagesize.
--- fs/jbd2/transaction.c | 3 +++ 1 file changed, 3 insertions(+)
fs/jbd2/transaction.c +3 -0
@@ -2378,6 +2378,9 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,spin_unlock (&jh->b_state_lock);write_unlock (&journal->j_state_lock);jbd2_journal_put_journal_head (jh); +/* Already zapped buffer? Nothing to do... */ +if (!bh->b_bdev) +return 0 ;return -EBUSY ; }/*
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 216/371 wifi: iwlwifi: make the loop for card preparation effective
In reply to Greg Kroah-HartmanFrom: Emmanuel Grumbach <[email protected]>
[ Upstream commit 28965ec0b5d9112585f725660e2ff13218505ace ]
Since we didn't reset t to 0, only the first iteration of the loop did checked the ready bit several times.
Quoted 1 line
From the second iteration and on, we just tested the bit once and
continued to the next iteration.
--- drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/pcie/trans.c +2 -1
@@ -581,7 +581,6 @@ static int iwl_pcie_set_hw_ready(struct iwl_trans *trans)int iwl_pcie_prepare_card_hw (struct iwl_trans *trans) {int ret; -int t =0 ;int iter;IWL_DEBUG_INFO (trans,"iwl_trans_prepare_card_hw enter\n" );
@@ -596,6 +595,8 @@ int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)usleep_range (1000 ,2000 );for (iter =0 ; iter <10 ; iter++) { +int t =0 ; +/* If HW is not ready, prepare the conditions to check again */ iwl_set_bit (trans,CSR_HW_IF_CONFIG_REG ,CSR_HW_IF_CONFIG_REG_PREPARE );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 217/371 wifi: mt76: handle failure of vzalloc in mt7615_coredump_work
In reply to Greg Kroah-HartmanFrom: Kang Chen <[email protected]>
[ Upstream commit 9e47dd9f64a47ae00ca0123017584c37209ee900 ]
vzalloc may fails, dump might be null and will cause illegal address access later.
--- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +5 -3
@@ -2273,7 +2273,7 @@ void mt7615_coredump_work(struct work_struct *work)break ;skb_pull (skb,sizeof (struct mt7615_mcu_rxd )); -if (data + skb->len - dump >MT76_CONNAC_COREDUMP_SZ ) { +if (!dump || data + skb->len - dump >MT76_CONNAC_COREDUMP_SZ ) {dev_kfree_skb (skb);continue ; }
@@ -2283,6 +2283,8 @@ void mt7615_coredump_work(struct work_struct *work)dev_kfree_skb (skb); } -dev_coredumpv (dev->mt76.dev, dump,MT76_CONNAC_COREDUMP_SZ , -GFP_KERNEL ); + +if (dump) +dev_coredumpv (dev->mt76.dev, dump,MT76_CONNAC_COREDUMP_SZ , +GFP_KERNEL ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 218/371 wifi: mt76: add flexible polling wait-interval support
In reply to Greg Kroah-HartmanFrom: Deren Wu <[email protected]>
[ Upstream commit 35effe6c0c24adcf0f732bb1c3d75573d4c88e63 ]
The default waiting unit is 10ms and the value is too much for data path related control. Provide a new API mt76_poll_msec_tick() to support different cases, such as 1ms polling waiting kick.
Stable-dep-of: c397fc1e6365 ("wifi: mt76: mt7921e: fix probe timeout after reboot")
--- drivers/net/wireless/mediatek/mt76/mt76.h | 9 +++++---- drivers/net/wireless/mediatek/mt76/util.c | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +5 -4
@@ -820,10 +820,11 @@ bool __mt76_poll(struct mt76_dev *dev, u32 offset, u32 mask, u32 val,#define mt76_poll (dev, ...) __mt76_poll(&((dev)->mt76), __VA_ARGS__) -bool __mt76_poll_msec (struct mt76_dev *dev,u32 offset,u32 mask,u32 val, -int timeout); - -#define mt76_poll_msec (dev, ...) __mt76_poll_msec(&((dev)->mt76), __VA_ARGS__) +bool ____mt76_poll_msec (struct mt76_dev *dev,u32 offset,u32 mask,u32 val, +int timeout,int kick); +#define __mt76_poll_msec (...) ____mt76_poll_msec(__VA_ARGS__, 10) +#define mt76_poll_msec (dev, ...) ____mt76_poll_msec(&((dev)->mt76), __VA_ARGS__, 10) +#define mt76_poll_msec_tick (dev, ...) ____mt76_poll_msec(&((dev)->mt76), __VA_ARGS__)void mt76_mmio_init (struct mt76_dev *dev,void __iomem *regs);void mt76_pci_disable_aspm (struct pci_dev *pdev);
drivers/net/wireless/mediatek/mt76/util.c +5 -5
@@ -24,23 +24,23 @@ bool __mt76_poll(struct mt76_dev *dev, u32 offset, u32 mask, u32 val, }EXPORT_SYMBOL_GPL (__mt76_poll); -bool __mt76_poll_msec (struct mt76_dev *dev,u32 offset,u32 mask,u32 val, -int timeout) +bool ____mt76_poll_msec (struct mt76_dev *dev,u32 offset,u32 mask,u32 val, +int timeout,int tick) {u32 cur; - timeout /=10 ; + timeout /= tick;do { cur =__mt76_rr (dev, offset) & mask;if (cur == val)return true; -usleep_range (10000 ,20000 ); +usleep_range (1000 * tick,2000 * tick); }while (timeout-- >0 );return false; } -EXPORT_SYMBOL_GPL (__mt76_poll_msec); +EXPORT_SYMBOL_GPL (____mt76_poll_msec);int mt76_wcid_alloc (u32 *mask,int size) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 219/371 wifi: mt76: mt7921e: fix probe timeout after reboot
In reply to Greg Kroah-HartmanFrom: Quan Zhou <[email protected]>
[ Upstream commit c397fc1e6365a2a9e5540a85b2c1d4ea412aa0e2 ]
In system warm reboot scene, due to the polling timeout(now 1000us) is too short to wait dma idle in time, it may make driver probe fail with error code -ETIMEDOUT. Meanwhile, we also found the dma may take around 70ms to enter idle state. Change the polling idle timeout to 100ms to avoid the probabilistic probe fail.
Tested pass with 5000 times warm reboot on x86 platform.
[4.477496] pci 0000:01:00.0: attach allowed to drvr mt7921e [internal device] [4.478306] mt7921e 0000:01:00.0: ASIC revision: 79610010 [4.480063] mt7921e: probe of 0000:01:00.0 failed with error -110
--- drivers/net/wireless/mediatek/mt76/mt7921/dma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/dma.c +3 -3
@@ -144,9 +144,9 @@ static int mt7921_dma_disable(struct mt7921_dev *dev, bool force)MT_WFDMA0_GLO_CFG_OMIT_RX_INFO | MT_WFDMA0_GLO_CFG_OMIT_RX_INFO_PFET2); -if (!mt76_poll (dev,MT_WFDMA0_GLO_CFG , -MT_WFDMA0_GLO_CFG_TX_DMA_BUSY | -MT_WFDMA0_GLO_CFG_RX_DMA_BUSY ,0 ,1000 )) +if (!mt76_poll_msec_tick (dev,MT_WFDMA0_GLO_CFG , +MT_WFDMA0_GLO_CFG_TX_DMA_BUSY | +MT_WFDMA0_GLO_CFG_RX_DMA_BUSY ,0 ,100 ,1 ))return -ETIMEDOUT ;return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 220/371 wifi: mt76: fix 6GHz high channel not be scanned
In reply to Greg Kroah-HartmanFrom: Ming Yen Hsieh <[email protected]>
[ Upstream commit 23792cedaff02351b57bddd8957fc917fa88f2e0 ]
mt76 scan command only support 64 channels currently. If the channel count is larger than 64(for 2+5+6GHz), some channels will not be scanned. Hence change the scan type to full channel scan in case of the command cannot include proper list for chip.
--- .../net/wireless/mediatek/mt76/mt76_connac_mcu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +10 -3
@@ -1446,8 +1446,16 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, req->channel_min_dwell_time =cpu_to_le16 (duration); req->channel_dwell_time =cpu_to_le16 (duration); - req->channels_num =min_t (u8, sreq->n_channels,32 ); - req->ext_channels_num =min_t (u8, ext_channels_num,32 ); +if (sreq->n_channels ==0 || sreq->n_channels >64 ) { + req->channel_type =0 ; + req->channels_num =0 ; + req->ext_channels_num =0 ; + }else { + req->channel_type =4 ; + req->channels_num =min_t (u8, sreq->n_channels,32 ); + req->ext_channels_num =min_t (u8, ext_channels_num,32 ); + } +for (i =0 ; i < req->channels_num + req->ext_channels_num; i++) {if (i >=32 ) chan = &req->ext_channels[i -32 ];
@@ -1457,7 +1465,6 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, chan->band = scan_list[i]->band ==NL80211_BAND_2GHZ ?1 :2 ; chan->channel_num = scan_list[i]->hw_value; } - req->channel_type = sreq->n_channels ?4 :0 ;if (sreq->ie_len >0 ) {memcpy (req->ies, sreq->ie, sreq->ie_len);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 221/371 wifi: mt76: mt7921e: improve reliability of dma reset
In reply to Greg Kroah-HartmanFrom: Quan Zhou <[email protected]>
[ Upstream commit 87714bf6ed1589813e473db5471e6e9857755764 ]
The hardware team has advised the driver that it is necessary to first put WFDMA into an idle state before resetting the WFDMA. Otherwise, the WFDMA may enter an unknown state where it cannot be polled with the right state successfully. To ensure that the DMA can work properly while a stressful cold reboot test was being made, we have reordered the programming sequence in the driver based on the hardware team's guidance.
The patch would modify the WFDMA disabling flow from
"DMA reset -> disabling DMASHDL -> disabling WFDMA -> polling and waiting until DMA idle" to "disabling WFDMA -> polling and waiting for DMA idle -> disabling DMASHDL -> DMA reset.
Where he polling and waiting until WFDMA is idle is coordinated with the operation of disabling WFDMA. Even while WFDMA is being disabled, it can still handle Tx/Rx requests. The additional polling allows sufficient time for WFDMA to process the last T/Rx request. When the idle state of WFDMA is reached, it is a reliable indication that DMASHDL is also idle to ensure it is safe to disable it and perform the DMA reset.
--- .../net/wireless/mediatek/mt76/mt7921/dma.c | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/dma.c +20 -16
@@ -120,22 +120,6 @@ static void mt7921_dma_prefetch(struct mt7921_dev *dev)static int mt7921_dma_disable (struct mt7921_dev *dev,bool force) { -if (force) { -/* reset */ -mt76_clear (dev,MT_WFDMA0_RST , -MT_WFDMA0_RST_DMASHDL_ALL_RST | -MT_WFDMA0_RST_LOGIC_RST ); - -mt76_set (dev,MT_WFDMA0_RST , -MT_WFDMA0_RST_DMASHDL_ALL_RST | -MT_WFDMA0_RST_LOGIC_RST ); - } - -/* disable dmashdl */ -mt76_clear (dev,MT_WFDMA0_GLO_CFG_EXT0 , -MT_WFDMA0_CSR_TX_DMASHDL_ENABLE ); -mt76_set (dev,MT_DMASHDL_SW_CONTROL ,MT_DMASHDL_DMASHDL_BYPASS ); -/* disable WFDMA0 */ mt76_clear(dev, MT_WFDMA0_GLO_CFG, MT_WFDMA0_GLO_CFG_TX_DMA_EN | MT_WFDMA0_GLO_CFG_RX_DMA_EN |
@@ -149,6 +133,22 @@ static int mt7921_dma_disable(struct mt7921_dev *dev, bool force) MT_WFDMA0_GLO_CFG_RX_DMA_BUSY, 0, 100, 1))return -ETIMEDOUT ; +/* disable dmashdl */ +mt76_clear (dev,MT_WFDMA0_GLO_CFG_EXT0 , +MT_WFDMA0_CSR_TX_DMASHDL_ENABLE ); +mt76_set (dev,MT_DMASHDL_SW_CONTROL ,MT_DMASHDL_DMASHDL_BYPASS ); + +if (force) { +/* reset */ +mt76_clear (dev,MT_WFDMA0_RST , +MT_WFDMA0_RST_DMASHDL_ALL_RST | +MT_WFDMA0_RST_LOGIC_RST ); + +mt76_set (dev,MT_WFDMA0_RST , +MT_WFDMA0_RST_DMASHDL_ALL_RST | +MT_WFDMA0_RST_LOGIC_RST ); + } +return 0 ; }
@@ -354,6 +354,10 @@ void mt7921_dma_cleanup(struct mt7921_dev *dev)MT_WFDMA0_GLO_CFG_OMIT_RX_INFO | MT_WFDMA0_GLO_CFG_OMIT_RX_INFO_PFET2); +mt76_poll_msec_tick (dev,MT_WFDMA0_GLO_CFG , +MT_WFDMA0_GLO_CFG_TX_DMA_BUSY | +MT_WFDMA0_GLO_CFG_RX_DMA_BUSY ,0 ,100 ,1 ); +/* reset */ mt76_clear(dev, MT_WFDMA0_RST, MT_WFDMA0_RST_DMASHDL_ALL_RST |
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 222/371 wifi: iwlwifi: mvm: check firmware response size
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 13513cec93ac9902d0b896976d8bab3758a9881c ]
Check the firmware response size for responses to the memory read/write command in debugfs before using it.
--- drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +10 -0
@@ -1931,6 +1931,11 @@ static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,if (ret <0 )return ret; +if (iwl_rx_packet_payload_len (hcmd.resp_pkt) <sizeof (*rsp)) { + ret = -EIO ; + goto out; + } + rsp = (void *)hcmd.resp_pkt->data;if (le32_to_cpu (rsp->status) !=DEBUG_MEM_STATUS_SUCCESS ) { ret = -ENXIO ;
@@ -2008,6 +2013,11 @@ static ssize_t iwl_dbgfs_mem_write(struct file *file,if (ret <0 )return ret; +if (iwl_rx_packet_payload_len (hcmd.resp_pkt) <sizeof (*rsp)) { + ret = -EIO ; + goto out; + } + rsp = (void *)hcmd.resp_pkt->data;if (rsp->status !=DEBUG_MEM_STATUS_SUCCESS ) { ret = -ENXIO ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 223/371 wifi: iwlwifi: fw: fix memory leak in debugfs
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 3d90d2f4a018fe8cfd65068bc6350b6222be4852 ]
Fix a memory leak that occurs when reading the fw_info file all the way, since we return NULL indicating no more data, but don't free the status tracking object.
--- drivers/net/wireless/intel/iwlwifi/fw/debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/fw/debugfs.c +3 -1
@@ -317,8 +317,10 @@ static void *iwl_dbgfs_fw_info_seq_next(struct seq_file *seq,const struct iwl_fw *fw = priv->fwrt->fw; *pos = ++state->pos; -if (*pos >= fw->ucode_capa.n_cmd_versions) +if (*pos >= fw->ucode_capa.n_cmd_versions) { +kfree (state);return NULL ; + }return state; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 224/371 ixgbe: Allow flow hash to be set via ethtool
In reply to Greg Kroah-HartmanFrom: Joe Damato <[email protected]>
[ Upstream commit 4f3ed1293feb9502dc254b05802faf1ad3317ac6 ]
ixgbe currently returns EINVAL whenever the flowhash it set by ethtool because the ethtool code in the kernel passes a non-zero value for hfunc that ixgbe should allow.
When ethtool is called with ETHTOOL_SRXFHINDIR, ethtool_set_rxfh_indir will call ixgbe's set_rxfh function with ETH_RSS_HASH_NO_CHANGE. This value should be accepted.
When ethtool is called with ETHTOOL_SRSSH, ethtool_set_rxfh will call ixgbe's set_rxfh function with rxfh.hfunc, which appears to be hardcoded in ixgbe to always be ETH_RSS_HASH_TOP. This value should also be accepted.
Before this patch:
$ sudo ethtool -L eth1 combined 10 $ sudo ethtool -X eth1 default Cannot set RX flow hash configuration: Invalid argument
After this patch:
$ sudo ethtool -L eth1 combined 10
$ sudo ethtool -X eth1 default
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 10 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 0 1 2 3 4 5
16: 6 7 8 9 0 1 2 3
24: 4 5 6 7 8 9 0 1
...--- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +2 -2
@@ -3099,8 +3099,8 @@ static int ixgbe_set_rxfh(struct net_device *netdev, const u32 *indir,int i;u32 reta_entries =ixgbe_rss_indir_tbl_entries (adapter); -if (hfunc) -return -EINVAL ; +if (hfunc !=ETH_RSS_HASH_NO_CHANGE && hfunc !=ETH_RSS_HASH_TOP ) +return -EOPNOTSUPP ;/* Fill out the redirection table */ if (indir) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 225/371 ixgbe: Enable setting RSS table to default values
In reply to Greg Kroah-HartmanFrom: Joe Damato <[email protected]>
[ Upstream commit e85d3d55875f7a1079edfbc4e4e98d6f8aea9ac7 ]
ethtool uses ETHTOOL_GRXRINGS to compute how many queues are supported by RSS. The driver should return the smaller of either:
- The maximum number of RSS queues the device supports, OR
- The number of RX queues configured
Prior to this change, running ethtool -X $iface default fails if the number of queues configured is larger than the number supported by RSS, even though changing the queue count correctly resets the flowhash to use all supported queues.
Other drivers (for example, i40e) will succeed but the flow hash will reset to support the maximum number of queues supported by RSS, even if that amount is smaller than the configured amount.
Prior to this change:
$ sudo ethtool -L eth1 combined 20
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 20 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 10 11 12 13 14 15
16: 0 1 2 3 4 5 6 7
24: 8 9 10 11 12 13 14 15
32: 0 1 2 3 4 5 6 7
...You can see that the flowhash was correctly set to use the maximum number of queues supported by the driver (16).
However, asking the NIC to reset to "default" fails:
$ sudo ethtool -X eth1 default Cannot set RX flow hash configuration: Invalid argument
After this change, the flowhash can be reset to default which will use all of the available RSS queues (16) or the configured queue count, whichever is smaller.
Starting with eth1 which has 10 queues and a flowhash distributing to all 10 queues:
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 10 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 0 1 2 3 4 5
16: 6 7 8 9 0 1 2 3
...Increasing the queue count to 48 resets the flowhash to distribute to 16 queues, as it did before this patch:
$ sudo ethtool -L eth1 combined 48
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 16 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 10 11 12 13 14 15
16: 0 1 2 3 4 5 6 7
...Due to the other bugfix in this series, the flowhash can be set to use queues 0-5:
$ sudo ethtool -X eth1 equal 5
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 16 RX ring(s):
0: 0 1 2 3 4 0 1 2
8: 3 4 0 1 2 3 4 0
16: 1 2 3 4 0 1 2 3
...Due to this bugfix, the flowhash can be reset to default and use 16 queues:
$ sudo ethtool -X eth1 default
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 16 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 10 11 12 13 14 15
16: 0 1 2 3 4 5 6 7
...--- .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +10 -9
@@ -2633,6 +2633,14 @@ static int ixgbe_get_rss_hash_opts(struct ixgbe_adapter *adapter,return 0 ; } +static int ixgbe_rss_indir_tbl_max (struct ixgbe_adapter *adapter) +{ +if (adapter->hw.mac.type < ixgbe_mac_X550) +return 16 ; +else +return 64 ; +} +static int ixgbe_get_rxnfc (struct net_device *dev,struct ethtool_rxnfc *cmd,u32 *rule_locs) {
@@ -2641,7 +2649,8 @@ static int ixgbe_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,switch (cmd->cmd) {case ETHTOOL_GRXRINGS : - cmd->data = adapter->num_rx_queues; + cmd->data =min_t (int, adapter->num_rx_queues, +ixgbe_rss_indir_tbl_max (adapter)); ret =0 ;break ;case ETHTOOL_GRXCLSRLCNT :
@@ -3043,14 +3052,6 @@ static int ixgbe_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)return ret; } -static int ixgbe_rss_indir_tbl_max (struct ixgbe_adapter *adapter) -{ -if (adapter->hw.mac.type < ixgbe_mac_X550) -return 16 ; -else -return 64 ; -} -static u32 ixgbe_get_rxfh_key_size (struct net_device *netdev) {return IXGBE_RSS_KEY_SIZE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 226/371 net/mlx5: E-switch, Dont destroy indirect table in split rule
In reply to Greg Kroah-HartmanFrom: Chris Mi <[email protected]>
[ Upstream commit 4c8189302567f75099a336b0efcff8291ec86ff4 ]
Source port rewrite (forward to ovs internal port or statck device) isn't supported in the rule of split action. So there is no indirect table in split rule. The cited commit destroyes indirect table in split rule. The indirect table for other rules will be destroyed wrongly. It will cause traffic loss.
Fix it by removing the destroy function in split rule. And also remove the destroy function in error flow.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -2
@@ -656,7 +656,6 @@ mlx5_eswitch_add_fwd_rule(struct mlx5_eswitch *esw,return rule; err_chain_src_rewrite: -esw_put_dest_tables_loop (esw, attr,0 , i);mlx5_esw_vporttbl_put (esw, &fwd_attr); err_get_fwd:mlx5_chains_put_table (chains, attr->chain, attr->prio,0 );
@@ -698,7 +697,6 @@ __mlx5_eswitch_del_rule(struct mlx5_eswitch *esw,if (fwd_rule) {mlx5_esw_vporttbl_put (esw, &fwd_attr);mlx5_chains_put_table (chains, attr->chain, attr->prio,0 ); -esw_put_dest_tables_loop (esw, attr,0 , esw_attr->split_count); }else {if (split)mlx5_esw_vporttbl_put (esw, &fwd_attr);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 227/371 net: stmmac:fix system hang when setting up tag_8021q VLAN for DSA ports
In reply to Greg Kroah-HartmanFrom: Yan Wang <[email protected]>
[ Upstream commit 35226750f7ab9d49140d95bc7d38a2a9b0f4fdfc ]
The system hang because of dsa_tag_8021q_port_setup()->
stmmac_vlan_rx_add_vid().
I found in stmmac_drv_probe() that cailing pm_runtime_put() disabled the clock.
First, when the kernel is compiled with CONFIG_PM=y,The stmmac's resume/suspend is active.
Secondly,stmmac as DSA master,the dsa_tag_8021q_port_setup() function will callback stmmac_vlan_rx_add_vid when DSA dirver starts. However, The system is hanged for the stmmac_vlan_rx_add_vid() accesses its registers after stmmac's clock is closed.
I would suggest adding the pm_runtime_resume_and_get() to the stmmac_vlan_rx_add_vid().This guarantees that resuming clock output while in use.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +9 -3
@@ -6283,6 +6283,10 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vidbool is_double = false;int ret; + ret =pm_runtime_resume_and_get (priv->device); +if (ret <0 ) +return ret; +if (be16_to_cpu (proto) ==ETH_P_8021AD ) is_double = true;
@@ -6290,16 +6294,18 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid ret =stmmac_vlan_update (priv, is_double);if (ret) {clear_bit (vid, priv->active_vlans); -return ret; + goto err_pm_put; }if (priv->hw->num_vlan) { ret =stmmac_add_hw_vlan_rx_fltr (priv, ndev, priv->hw, proto, vid);if (ret) -return ret; + goto err_pm_put; } +err_pm_put: +pm_runtime_put (priv->device); -return 0 ; +return ret; }static int stmmac_vlan_rx_kill_vid (struct net_device *ndev,__be16 proto,u16 vid)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 228/371 bpf: Dont EFAULT for getsockopt with optval=NULL
In reply to Greg Kroah-HartmanFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit 00e74ae0863827d944e36e56a4ce1e77e50edb91 ]
Some socket options do getsockopt with optval=NULL to estimate the size of the final buffer (which is returned via optlen). This breaks BPF getsockopt assumptions about permitted optval buffer size. Let's enforce these assumptions only when non-NULL optval is provided.
--- kernel/bpf/cgroup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/bpf/cgroup.c +6 -3
@@ -1586,7 +1586,7 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, goto out; } -if (ctx.optlen > max_optlen || ctx.optlen <0 ) { +if (optval && (ctx.optlen > max_optlen || ctx.optlen <0 )) { ret = -EFAULT ; goto out; }
@@ -1600,8 +1600,11 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, }if (ctx.optlen !=0 ) { -if (copy_to_user (optval, ctx.optval, ctx.optlen) || -put_user (ctx.optlen, optlen)) { +if (optval &©_to_user (optval, ctx.optval, ctx.optlen)) { + ret = -EFAULT ; + goto out; + } +if (put_user (ctx.optlen, optlen)) { ret = -EFAULT ; goto out; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 229/371 netfilter: nf_tables: dont write table validation state without mutex
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit 9a32e9850686599ed194ccdceb6cd3dd56b2d9b9 ]
The ->cleanup callback needs to be removed, this doesn't work anymore as the transaction mutex is already released in the ->abort function.
Just do it after a successful validation pass, this either happens from commit or abort phases where transaction mutex is held.
--- include/linux/netfilter/nfnetlink.h | 1 - net/netfilter/nf_tables_api.c | 8 ++------ net/netfilter/nfnetlink.c | 2 -- 3 files changed, 2 insertions(+), 9 deletions(-)
include/linux/netfilter/nfnetlink.h +0 -1
@@ -45,7 +45,6 @@ struct nfnetlink_subsystem {int (*commit)(struct net *net,struct sk_buff *skb);int (*abort)(struct net *net,struct sk_buff *skb,enum nfnl_abort_action action); -void (*cleanup)(struct net *net);bool (*valid_genid)(struct net *net,u32 genid); };
net/netfilter/nf_tables_api.c +2 -6
@@ -8360,6 +8360,8 @@ static int nf_tables_validate(struct net *net)if (nft_table_validate (net, table) <0 )return -EAGAIN ; } + +nft_validate_state_update (net,NFT_VALIDATE_SKIP );break ; }
@@ -9231,11 +9233,6 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)return 0 ; } -static void nf_tables_cleanup (struct net *net) -{ -nft_validate_state_update (net,NFT_VALIDATE_SKIP ); -} -static int nf_tables_abort (struct net *net,struct sk_buff *skb,enum nfnl_abort_action action) {
@@ -9269,7 +9266,6 @@ static const struct nfnetlink_subsystem nf_tables_subsys = { .cb = nf_tables_cb, .commit = nf_tables_commit, .abort = nf_tables_abort, - .cleanup = nf_tables_cleanup, .valid_genid = nf_tables_valid_genid, .owner = THIS_MODULE, };
net/netfilter/nfnetlink.c +0 -2
@@ -585,8 +585,6 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh, goto replay_abort; } } -if (ss->cleanup) - ss->cleanup (net);nfnl_err_deliver (&err_list, oskb);kfree_skb (skb);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 230/371 net/sched: sch_fq: fix integer overflow of "credit"
In reply to Greg Kroah-HartmanFrom: Davide Caratti <[email protected]>
[ Upstream commit 7041101ff6c3073fd8f2e99920f535b111c929cb ]
if sch_fq is configured with "initial quantum" having values greater than INT_MAX, the first assignment of "credit" does signed integer overflow to a very negative value.
In this situation, the syzkaller script provided by Cristoph triggers the CPU soft-lockup warning even with few sockets. It's not an infinite loop, but "credit" wasn't probably meant to be minus 2Gb for each new flow. Capping "initial quantum" to INT_MAX proved to fix the issue.
v2: validation of "initial quantum" is done in fq_policy, instead of open
coding in fq_change() _ suggested by Jakub Kicinski
--- net/sched/sch_fq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/sched/sch_fq.c +5 -1
@@ -779,13 +779,17 @@ static int fq_resize(struct Qdisc *sch, u32 log)return 0 ; } +static struct netlink_range_validation iq_range = { + .max =INT_MAX , +}; +static const struct nla_policy fq_policy[TCA_FQ_MAX +1 ] = { [TCA_FQ_UNSPEC ] = { .strict_start_type =TCA_FQ_TIMER_SLACK }, [TCA_FQ_PLIMIT ] = { .type =NLA_U32 }, [TCA_FQ_FLOW_PLIMIT ] = { .type =NLA_U32 }, [TCA_FQ_QUANTUM ] = { .type =NLA_U32 }, - [TCA_FQ_INITIAL_QUANTUM ] = { .type =NLA_U32 }, + [TCA_FQ_INITIAL_QUANTUM ] =NLA_POLICY_FULL_RANGE (NLA_U32 , &iq_range), [TCA_FQ_RATE_ENABLE ] = { .type =NLA_U32 }, [TCA_FQ_FLOW_DEFAULT_RATE ] = { .type =NLA_U32 }, [TCA_FQ_FLOW_MAX_RATE ] = { .type =NLA_U32 },
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 231/371 ipv4: Fix potential uninit variable access bug in __ip_make_skb()
In reply to Greg Kroah-HartmanFrom: Ziyang Xuan <[email protected]>
[ Upstream commit 99e5acae193e369b71217efe6f1dad42f3f18815 ]
Like commit ea30388baebc ("ipv6: Fix an uninit variable access bug in __ip6_make_skb()"). icmphdr does not in skb linear region under the scenario of SOCK_RAW socket. Access icmp_hdr(skb)->type directly will trigger the uninit variable access bug.
Use a local variable icmp_type to carry the correct value in different scenarios.
--- net/ipv4/ip_output.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
net/ipv4/ip_output.c +13 -3
@@ -1555,9 +1555,19 @@ struct sk_buff *__ip_make_skb(struct sock *sk, cork->dst =NULL ;skb_dst_set (skb, &rt->dst); -if (iph->protocol ==IPPROTO_ICMP ) -icmp_out_count (net, ((struct icmphdr *) -skb_transport_header (skb))->type); +if (iph->protocol ==IPPROTO_ICMP ) { +u8 icmp_type; + +/* For such sockets, transhdrlen is zero when do ip_append_data(), +* so icmphdr does not in skb linear region and can not get icmp_type +* by icmp_hdr(skb)->type. +*/ +if (sk->sk_type ==SOCK_RAW && !inet_sk (sk)->hdrincl) + icmp_type = fl4->fl4_icmp_type; +else + icmp_type =icmp_hdr (skb)->type; +icmp_out_count (net, icmp_type); + }ip_cork_release (cork); out:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 232/371 Revert "Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work"
In reply to Greg Kroah-HartmanFrom: Liu Jian <[email protected]>
[ Upstream commit db2bf510bd5d57f064d9e1db395ed86a08320c54 ]
This reverts commit 1e9ac114c4428fdb7ff4635b45d4f46017e8916f.
This patch introduces a possible null-ptr-def problem. Revert it. And the fixed bug by this patch have resolved by commit 73f7b171b7c0 ("Bluetooth:
btsdio: fix use after free bug in btsdio_remove due to race condition").
--- drivers/bluetooth/btsdio.c | 1 - 1 file changed, 1 deletion(-)
drivers/bluetooth/btsdio.c +0 -1
@@ -352,7 +352,6 @@ static void btsdio_remove(struct sdio_func *func)BT_DBG ("func %p" , func); -cancel_work_sync (&data->work);if (!data)return ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 233/371 netlink: Use copy_to_user() for optval in netlink_getsockopt().
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit d913d32cc2707e9cd24fe6fa6d7d470e9c728980 ]
Brad Spencer provided a detailed report [0] that when calling getsockopt() for AF_NETLINK, some SOL_NETLINK options set only 1 byte even though such options require at least sizeof(int) as length.
The options return a flag value that fits into 1 byte, but such behaviour confuses users who do not initialise the variable before calling getsockopt() and do not strictly check the returned value as char.
Currently, netlink_getsockopt() uses put_user() to copy data to optlen and optval, but put_user() casts the data based on the pointer, char *optval. As a result, only 1 byte is set to optval.
To avoid this behaviour, we need to use copy_to_user() or cast optval for put_user().
Note that this changes the behaviour on big-endian systems, but we document that the size of optval is int in the man page.
$ man 7 netlink
...
Socket options
To set or get a netlink socket option, call getsockopt(2) to read
or setsockopt(2) to write the option with the option level argument
set to SOL_NETLINK. Unless otherwise noted, optval is a pointer to
an int.--- net/netlink/af_netlink.c | 75 ++++++++++++---------------------------- 1 file changed, 23 insertions(+), 52 deletions(-)
net/netlink/af_netlink.c +23 -52
@@ -1752,7 +1752,8 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname, {struct sock *sk = sock->sk;struct netlink_sock *nlk =nlk_sk (sk); -int len, val, err; +unsigned int flag; +int len, val;if (level !=SOL_NETLINK )return -ENOPROTOOPT ;
@@ -1764,39 +1765,17 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,switch (optname) {case NETLINK_PKTINFO : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_RECV_PKTINFO ?1 :0 ; -if (put_user (len, optlen) || -put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_RECV_PKTINFO ;break ;case NETLINK_BROADCAST_ERROR : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_BROADCAST_SEND_ERROR ?1 :0 ; -if (put_user (len, optlen) || -put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_BROADCAST_SEND_ERROR ;break ;case NETLINK_NO_ENOBUFS : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_RECV_NO_ENOBUFS ?1 :0 ; -if (put_user (len, optlen) || -put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_RECV_NO_ENOBUFS ;break ;case NETLINK_LIST_MEMBERSHIPS : { -int pos, idx, shift; +int pos, idx, shift, err =0 ; - err =0 ;netlink_lock_table ();for (pos =0 ; pos *8 < nlk->ngroups; pos +=sizeof (u32)) {if (len - pos <sizeof (u32))
@@ -1813,40 +1792,32 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,if (put_user (ALIGN (nlk->ngroups /8 ,sizeof (u32)), optlen)) err = -EFAULT ;netlink_unlock_table (); -break ; +return err; }case NETLINK_CAP_ACK : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_CAP_ACK ?1 :0 ; -if (put_user (len, optlen) || -put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_CAP_ACK ;break ;case NETLINK_EXT_ACK : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_EXT_ACK ?1 :0 ; -if (put_user (len, optlen) ||put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_EXT_ACK ;break ;case NETLINK_GET_STRICT_CHK : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_STRICT_CHK ?1 :0 ; -if (put_user (len, optlen) ||put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_STRICT_CHK ;break ;default : - err = -ENOPROTOOPT ; +return -ENOPROTOOPT ; } -return err; + +if (len <sizeof (int )) +return -EINVAL ; + + len =sizeof (int ); + val = nlk->flags & flag ?1 :0 ; + +if (put_user (len, optlen) || +copy_to_user (optval, &val, len)) +return -EFAULT ; + +return 0 ; }static void netlink_cmsg_recv_pktinfo (struct msghdr *msg,struct sk_buff *skb)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 234/371 net: amd: Fix link leak when verifying config failed
In reply to Greg Kroah-HartmanFrom: Gencen Gan <[email protected]>
[ Upstream commit d325c34d9e7e38d371c0a299d415e9b07f66a1fb ]
After failing to verify configuration, it returns directly without releasing link, which may cause memory leak.
Paolo Abeni thinks that the whole code of this driver is quite "suboptimal" and looks unmainatained since at least ~15y, so he suggests that we could simply remove the whole driver, please take it into consideration.
Simon Horman suggests that the fix label should be set to "Linux-2.6.12-rc2" considering that the problem has existed since the driver was introduced and the commit above doesn't seem to exist in net/net-next.
--- drivers/net/ethernet/amd/nmclan_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/amd/nmclan_cs.c +1 -1
@@ -650,7 +650,7 @@ static int nmclan_config(struct pcmcia_device *link) }else {pr_notice ("mace id not found: %x %x should be 0x40 0x?9\n" , sig[0 ], sig[1 ]); -return -ENODEV ; + goto failed; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 235/371 tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 50749f2dd6854a41830996ad302aef2ffaf011d8 ]
syzkaller reported [0] memory leaks of an UDP socket and ZEROCOPY skbs. We can reproduce the problem with these sequences:
sk = socket(AF_INET, SOCK_DGRAM, 0) sk.setsockopt(SOL_SOCKET, SO_TIMESTAMPING, SOF_TIMESTAMPING_TX_SOFTWARE) sk.setsockopt(SOL_SOCKET, SO_ZEROCOPY, 1)
sk.sendto(b'', MSG_ZEROCOPY, ('127.0.0.1', 53))
sk.close()
sendmsg() calls msg_zerocopy_alloc(), which allocates a skb, sets skb->cb->ubuf.refcnt to 1, and calls sock_hold(). Here, struct ubuf_info_msgzc indirectly holds a refcnt of the socket. When the skb is sent, __skb_tstamp_tx() clones it and puts the clone into the socket's error queue with the TX timestamp.
When the original skb is received locally, skb_copy_ubufs() calls skb_unclone(), and pskb_expand_head() increments skb->cb->ubuf.refcnt. This additional count is decremented while freeing the skb, but struct ubuf_info_msgzc still has a refcnt, so __msg_zerocopy_callback() is not called.
The last refcnt is not released unless we retrieve the TX timestamped skb by recvmsg(). Since we clear the error queue in inet_sock_destruct() after the socket's refcnt reaches 0, there is a circular dependency. If we close() the socket holding such skbs, we never call sock_put() and leak the count, sk, and skb.
TCP has the same problem, and commit e0c8bccd40fc ("net: stream:
purge sk_error_queue in sk_stream_kill_queues()") tried to fix it by calling skb_queue_purge() during close(). However, there is a small chance that skb queued in a qdisc or device could be put into the error queue after the skb_queue_purge() call.
In __skb_tstamp_tx(), the cloned skb should not have a reference to the ubuf to remove the circular dependency, but skb_clone() does not call skb_copy_ubufs() for zerocopy skb. So, we need to call skb_orphan_frags_rx() for the cloned skb to call skb_copy_ubufs().
[0]:
BUG: memory leak
unreferenced object 0xffff88800c6d2d00 (size 1152):
comm "syz-executor392", pid 264, jiffies 4294785440 (age 13.044s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 cd af e8 81 00 00 00 00 ................
02 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00 ...@............
backtrace:
[<0000000055636812>] sk_prot_alloc+0x64/0x2a0 net/core/sock.c:2024
[<0000000054d77b7a>] sk_alloc+0x3b/0x800 net/core/sock.c:2083
[<0000000066f3c7e0>] inet_create net/ipv4/af_inet.c:319 [inline]
[<0000000066f3c7e0>] inet_create+0x31e/0xe40 net/ipv4/af_inet.c:245
[<000000009b83af97>] __sock_create+0x2ab/0x550 net/socket.c:1515
[<00000000b9b11231>] sock_create net/socket.c:1566 [inline]
[<00000000b9b11231>] __sys_socket_create net/socket.c:1603 [inline]
[<00000000b9b11231>] __sys_socket_create net/socket.c:1588 [inline]
[<00000000b9b11231>] __sys_socket+0x138/0x250 net/socket.c:1636
[<000000004fb45142>] __do_sys_socket net/socket.c:1649 [inline]
[<000000004fb45142>] __se_sys_socket net/socket.c:1647 [inline]
[<000000004fb45142>] __x64_sys_socket+0x73/0xb0 net/socket.c:1647
[<0000000066999e0e>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<0000000066999e0e>] do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
[<0000000017f238c1>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
BUG: memory leak
unreferenced object 0xffff888017633a00 (size 240):
comm "syz-executor392", pid 264, jiffies 4294785440 (age 13.044s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 2d 6d 0c 80 88 ff ff .........-m.....
backtrace:
[<000000002b1c4368>] __alloc_skb+0x229/0x320 net/core/skbuff.c:497
[<00000000143579a6>] alloc_skb include/linux/skbuff.h:1265 [inline]
[<00000000143579a6>] sock_omalloc+0xaa/0x190 net/core/sock.c:2596
[<00000000be626478>] msg_zerocopy_alloc net/core/skbuff.c:1294 [inline]
[<00000000be626478>] msg_zerocopy_realloc+0x1ce/0x7f0 net/core/skbuff.c:1370
[<00000000cbfc9870>] __ip_append_data+0x2adf/0x3b30 net/ipv4/ip_output.c:1037
[<0000000089869146>] ip_make_skb+0x26c/0x2e0 net/ipv4/ip_output.c:1652
[<00000000098015c2>] udp_sendmsg+0x1bac/0x2390 net/ipv4/udp.c:1253
[<0000000045e0e95e>] inet_sendmsg+0x10a/0x150 net/ipv4/af_inet.c:819
[<000000008d31bfde>] sock_sendmsg_nosec net/socket.c:714 [inline]
[<000000008d31bfde>] sock_sendmsg+0x141/0x190 net/socket.c:734
[<0000000021e21aa4>] __sys_sendto+0x243/0x360 net/socket.c:2117
[<00000000ac0af00c>] __do_sys_sendto net/socket.c:2129 [inline]
[<00000000ac0af00c>] __se_sys_sendto net/socket.c:2125 [inline]
[<00000000ac0af00c>] __x64_sys_sendto+0xe1/0x1c0 net/socket.c:2125
[<0000000066999e0e>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<0000000066999e0e>] do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
[<0000000017f238c1>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- net/core/skbuff.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/skbuff.c +3 -0
@@ -4960,6 +4960,9 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb, skb =alloc_skb (0 ,GFP_ATOMIC ); }else { skb =skb_clone (orig_skb,GFP_ATOMIC ); + +if (skb_orphan_frags_rx (skb,GFP_ATOMIC )) +return ; }if (!skb)return ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 236/371 ipmi: ASPEED_BT_IPMI_BMC: select REGMAP_MMIO instead of depending on it
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 2a587b9ad052e7e92e508aea90c1e2ae433c1908 ]
REGMAP is a hidden (not user visible) symbol. Users cannot set it directly thru "make *config", so drivers should select it instead of depending on it if they need it.
Consistently using "select" or "depends on" can also help reduce Kconfig circular dependency issues.
Therefore, change the use of "depends on REGMAP_MMIO" to "select REGMAP_MMIO", which will also set REGMAP.
Message-Id: <[email protected]>
--- drivers/char/ipmi/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/ipmi/Kconfig +2 -1
@@ -153,7 +153,8 @@ config IPMI_KCS_BMC_SERIO config ASPEED_BT_IPMI_BMC depends on ARCH_ASPEED || COMPILE_TEST - depends on REGMAP && REGMAP_MMIO && MFD_SYSCON + depends on MFD_SYSCON + select REGMAP_MMIO tristate "BT IPMI bmc driver" help Provides a driver for the BT (Block Transfer) IPMI interface
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 237/371 drivers: staging: rtl8723bs: Fix locking in _rtw_join_timeout_handler()
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 215792eda008f6a1e7ed9d77fa20d582d22bb114 ]
Commit 041879b12ddb ("drivers: staging: rtl8192bs: Fix deadlock in rtw_joinbss_event_prehandle()") besides fixing the deadlock also modified _rtw_join_timeout_handler() to use spin_[un]lock_irq() instead of spin_[un]lock_bh().
_rtw_join_timeout_handler() calls rtw_do_join() which takes pmlmepriv->scanned_queue.lock using spin_[un]lock_bh(). This spin_unlock_bh() call re-enables softirqs which triggers an oops in kernel/softirq.c: __local_bh_enable_ip() when it calls lockdep_assert_irqs_enabled():
[ 244.506087] WARNING: CPU: 2 PID: 0 at kernel/softirq.c:376 __local_bh_enable_ip+0xa6/0x100 ... [ 244.509022] Call Trace: [ 244.509048] <IRQ> [ 244.509100] _rtw_join_timeout_handler+0x134/0x170 [r8723bs] [ 244.509468] ? __pfx__rtw_join_timeout_handler+0x10/0x10 [r8723bs] [ 244.509772] ? __pfx__rtw_join_timeout_handler+0x10/0x10 [r8723bs] [ 244.510076] call_timer_fn+0x95/0x2a0 [ 244.510200] __run_timers.part.0+0x1da/0x2d0
This oops is causd by the switch to spin_[un]lock_irq() which disables the IRQs for the entire duration of _rtw_join_timeout_handler().
Disabling the IRQs is not necessary since all code taking this lock runs from either user contexts or from softirqs, switch back to spin_[un]lock_bh() to fix this.
--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +2 -2
@@ -1547,7 +1547,7 @@ void _rtw_join_timeout_handler(struct timer_list *t)if (adapter->bDriverStopped || adapter->bSurpriseRemoved)return ; -spin_lock_irq (&pmlmepriv->lock); +spin_lock_bh (&pmlmepriv->lock);if (rtw_to_roam (adapter) >0 ) {/* join timeout caused by roaming */ while (1 ) {
@@ -1575,7 +1575,7 @@ void _rtw_join_timeout_handler(struct timer_list *t) } -spin_unlock_irq (&pmlmepriv->lock); +spin_unlock_bh (&pmlmepriv->lock); }/*
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 238/371 drivers: staging: rtl8723bs: Fix locking in rtw_scan_timeout_handler()
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 3f467036093fedd7e231924327455fc609b5ef02 ]
Commit cc7ad0d77b51 ("drivers: staging: rtl8723bs: Fix deadlock in rtw_surveydone_event_callback()") besides fixing the deadlock also modified rtw_scan_timeout_handler() to use spin_[un]lock_irq() instead of spin_[un]lock_bh().
Disabling the IRQs is not necessary since all code taking this lock runs from either user contexts or from softirqs
rtw_scan_timeout_handler() is the only function taking pmlmepriv->lock which uses spin_[un]lock_irq() for this. Switch back to spin_[un]lock_bh() to make it consistent with the rest of the code.
--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +2 -2
@@ -1588,11 +1588,11 @@ void rtw_scan_timeout_handler(struct timer_list *t) mlmepriv.scan_to_timer);struct mlme_priv *pmlmepriv = &adapter->mlmepriv; -spin_lock_irq (&pmlmepriv->lock); +spin_lock_bh (&pmlmepriv->lock);_clr_fwstate_ (pmlmepriv, _FW_UNDER_SURVEY); -spin_unlock_irq (&pmlmepriv->lock); +spin_unlock_bh (&pmlmepriv->lock);rtw_indicate_scan_done (adapter, true); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 239/371 pstore: Revert pmsg_lock back to a normal mutex
In reply to Greg Kroah-HartmanFrom: John Stultz <[email protected]>
[ Upstream commit 5239a89b06d6b199f133bf0ffea421683187f257 ]
This reverts commit 76d62f24db07f22ccf9bc18ca793c27d4ebef721.
So while priority inversion on the pmsg_lock is an occasional problem that an rt_mutex would help with, in uses where logging is writing to pmsg heavily from multiple threads, the pmsg_lock can be heavily contended.
After this change landed, it was reported that cases where the mutex locking overhead was commonly adding on the order of 10s of usecs delay had suddenly jumped to ~msec delay with rtmutex.
It seems the slight differences in the locks under this level of contention causes the normal mutexes to utilize the spinning optimizations, while the rtmutexes end up in the sleeping slowpath (which allows additional threads to pile on trying to take the lock).
In this case, it devolves to a worse case senerio where the lock acquisition and scheduling overhead dominates, and each thread is waiting on the order of ~ms to do ~us of work.
Obviously, having tons of threads all contending on a single lock for logging is non-optimal, so the proper fix is probably reworking pstore pmsg to have per-cpu buffers so we don't have contention.
Additionally, Steven Rostedt has provided some furhter optimizations for rtmutexes that improves the rtmutex spinning path, but at least in my testing, I still see the test tripping into the sleeping path on rtmutexes while utilizing the spinning path with mutexes.
But in the short term, lets revert the change to the rt_mutex and go back to normal mutexes to avoid a potentially major performance regression. And we can work on optimizations to both rtmutexes and finer-grained locking for pstore pmsg in the future.
--- fs/pstore/pmsg.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/pstore/pmsg.c +3 -4
@@ -7,10 +7,9 @@#include <linux/device.h> #include <linux/fs.h> #include <linux/uaccess.h> -#include <linux/rtmutex.h> #include "internal.h" -static DEFINE_RT_MUTEX (pmsg_lock); +static DEFINE_MUTEX (pmsg_lock);static ssize_t write_pmsg (struct file *file,const char __user *buf,size_t count,loff_t *ppos)
@@ -29,9 +28,9 @@ static ssize_t write_pmsg(struct file *file, const char __user *buf,if (!access_ok (buf, count))return -EFAULT ; -rt_mutex_lock (&pmsg_lock); +mutex_lock (&pmsg_lock); ret = psinfo->write_user (&record, buf); -rt_mutex_unlock (&pmsg_lock); +mutex_unlock (&pmsg_lock);return ret ? ret : count; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 240/371 usb: host: xhci-rcar: remove leftover quirk handling
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
[ Upstream commit 5d67f4861884762ebc2bddb5d667444e45f25782 ]
Loading V3 firmware does not need a quirk anymore, remove the leftover code.
--- drivers/usb/host/xhci-rcar.c | 3 --- 1 file changed, 3 deletions(-)
drivers/usb/host/xhci-rcar.c +0 -3
@@ -75,7 +75,6 @@ MODULE_FIRMWARE(XHCI_RCAR_FIRMWARE_NAME_V3);/* For soc_device_attribute */ #define RCAR_XHCI_FIRMWARE_V2 BIT(0)/* FIRMWARE V2 */ -#define RCAR_XHCI_FIRMWARE_V3 BIT(1)/* FIRMWARE V3 */ static const struct soc_device_attribute rcar_quirks_match[] = { {
@@ -147,8 +146,6 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd)if (quirks &RCAR_XHCI_FIRMWARE_V2 ) firmware_name =XHCI_RCAR_FIRMWARE_NAME_V2 ; -else if (quirks &RCAR_XHCI_FIRMWARE_V3 ) - firmware_name =XHCI_RCAR_FIRMWARE_NAME_V3 ;else firmware_name = priv->firmware_name;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 241/371 usb: dwc3: gadget: Change condition for processing suspend event
In reply to Greg Kroah-HartmanFrom: Prashanth K <[email protected]>
[ Upstream commit 4decf4060ecfee1f7a710999fcd421645ac0c419 ]
Currently we process the suspend interrupt event only if the device is in configured state. Consider a case where device is not configured and got suspend interrupt, in that case our gadget will still use 100mA as composite_suspend didn't happen. But battery charging specification (BC1.2) expects a downstream device to draw less than 2.5mA when unconnected OR suspended.
Fix this by removing the condition for processing suspend event, and thus composite_resume would set vbus draw to 2.
--- drivers/usb/dwc3/gadget.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/usb/dwc3/gadget.c +2 -9
@@ -4092,15 +4092,8 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc,break ;case DWC3_DEVICE_EVENT_SUSPEND :/* It changed to be suspend event for version 2.30a and above */ - if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) { -/* -* Ignore suspend event until the gadget enters into -* USB_STATE_CONFIGURED state. -*/ -if (dwc->gadget->state >=USB_STATE_CONFIGURED ) -dwc3_gadget_suspend_interrupt (dwc, - event->event_info); - } + if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) +dwc3_gadget_suspend_interrupt (dwc, event->event_info);break ;case DWC3_DEVICE_EVENT_SOF :case DWC3_DEVICE_EVENT_ERRATIC_ERROR :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 242/371 serial: stm32: re-introduce an irq flag condition in usart_receive_chars
In reply to Greg Kroah-HartmanFrom: Erwan Le Ray <[email protected]>
[ Upstream commit cc58d0a3f0a4755b9c808e065d9227c6e984e7db ]
Re-introduce an irq flag condition in usart_receive_chars.
This condition has been deleted by commit 75f4e830fa9c ("serial: do not restore interrupt state in sysrq helper").
This code was present to handle threaded case, and has been removed because it is no more needed in this case. Nevertheless an irq safe lock is still needed in some cases, when DMA should be stopped to receive errors or breaks in PIO mode.
This patch is a precursor to the complete rework or stm32 serial driver DMA implementation.
Stable-dep-of: c47527cbcc3c ("serial: stm32: Re-assert RTS/DE GPIO in RS485 mode only if more data are transmitted")
--- drivers/tty/serial/stm32-usart.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/tty/serial/stm32-usart.c +13 -8
@@ -264,19 +264,22 @@ static unsigned long stm32_usart_get_char(struct uart_port *port, u32 *sr,return c; } -static void stm32_usart_receive_chars (struct uart_port *port,bool threaded) +static void stm32_usart_receive_chars (struct uart_port *port,bool irqflag) {struct tty_port *tport = &port->state->port;struct stm32_port *stm32_port =to_stm32_port (port);const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; -unsigned long c; +unsigned long c, flags;u32 sr;char flag; -spin_lock (&port->lock); +if (irqflag) +spin_lock_irqsave (&port->lock, flags); +else +spin_lock (&port->lock);while (stm32_usart_pending_rx (port, &sr, &stm32_port->last_res, - threaded)) { + irqflag)) { sr |=USART_SR_DUMMY_RX ; flag =TTY_NORMAL ;
@@ -330,7 +333,10 @@ static void stm32_usart_receive_chars(struct uart_port *port, bool threaded)uart_insert_char (port, sr,USART_SR_ORE , c, flag); } -uart_unlock_and_check_sysrq (port); +if (irqflag) +uart_unlock_and_check_sysrq_irqrestore (port, irqflag); +else +uart_unlock_and_check_sysrq (port);tty_flip_buffer_push (tport); }
@@ -599,10 +605,9 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)static irqreturn_t stm32_usart_threaded_interrupt (int irq,void *ptr) {struct uart_port *port = ptr; -struct stm32_port *stm32_port =to_stm32_port (port); -if (stm32_port->rx_ch) -stm32_usart_receive_chars (port, true); +/* Receiver timeout irq for DMA RX */ +stm32_usart_receive_chars (port, false);return IRQ_HANDLED ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 243/371 serial: stm32: Re-assert RTS/DE GPIO in RS485 mode only if more data are transmitted
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit c47527cbcc3c50800f34b8c684f29721f75de246 ]
The stm32_usart_transmit_chars() may be called with empty or stopped transmit queue, and no XON/OFF character pending. This can happen at the end of transmission, where this last call is used to either handle the XON/XOFF x_char, or disable TX interrupt if queue is empty or stopped.
If that occurs, do not assert the RS485 RTS/DE GPIO anymore, as the GPIO would remain asserted past the end of transmission and that would block the RS485 bus after the transmission.
Only assert the RS485 RTS/DE GPIO if there is either pending XON/XOFF x_char, or at least one character in running transmit queue.
--- drivers/tty/serial/stm32-usart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/stm32-usart.c +3 -2
@@ -502,8 +502,9 @@ static void stm32_usart_transmit_chars(struct uart_port *port)int ret;if (!stm32_port->hw_flow_control && - port->rs485.flags &SER_RS485_ENABLED ) { - stm32_port->txdone = false; + port->rs485.flags &SER_RS485_ENABLED && + (port->x_char || + !(uart_circ_empty (xmit) ||uart_tx_stopped (port)))) {stm32_usart_tc_interrupt_disable (port);stm32_usart_rs485_rts_enable (port); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 244/371 fpga: bridge: fix kernel-doc parameter description
In reply to Greg Kroah-HartmanFrom: Marco Pagani <[email protected]>
[ Upstream commit 7ef1a2c1c9dffa177ecc3ea50b7f5ee63a621137 ]
Fix the kernel-doc description for the "struct fpga_image_info *info" parameter of the fpga_bridge_get() function.
--- drivers/fpga/fpga-bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/fpga-bridge.c +1 -1
@@ -115,7 +115,7 @@ static int fpga_bridge_dev_match(struct device *dev, const void *data)/** * fpga_bridge_get - get an exclusive reference to an fpga bridge * @dev: parent device that fpga bridge was registered with -* @info: fpga manager info +* @info: fpga image specific information * * Given a device, get an exclusive reference to an fpga bridge. *
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 245/371 iio: light: max44009: add missing OF device matching
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit b29c49026c3c05a11f845dba17cad0b3ba06836d ]
The driver currently matches only via i2c_device_id, but also has of_device_id table:
drivers/iio/light/max44009.c:545:34: error: ‘max44009_of_match’ defined but not used [-Werror=unused-const-variable=]
--- drivers/iio/light/max44009.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/iio/light/max44009.c +7 -6
@@ -528,6 +528,12 @@ static int max44009_probe(struct i2c_client *client,return devm_iio_device_register (&client->dev, indio_dev); } +static const struct of_device_id max44009_of_match[] = { + { .compatible ="maxim,max44009" }, + { } +}; +MODULE_DEVICE_TABLE (of, max44009_of_match); +static const struct i2c_device_id max44009_id[] = { {"max44009" ,0 }, { }
@@ -537,18 +543,13 @@ MODULE_DEVICE_TABLE(i2c, max44009_id);static struct i2c_driver max44009_driver = { .driver = { .name =MAX44009_DRV_NAME , + .of_match_table = max44009_of_match, }, .probe = max44009_probe, .id_table = max44009_id, };module_i2c_driver (max44009_driver); -static const struct of_device_id max44009_of_match[] = { - { .compatible ="maxim,max44009" }, - { } -}; -MODULE_DEVICE_TABLE (of, max44009_of_match); -MODULE_AUTHOR ("Robert Eshleman <[email protected]>" );MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("MAX44009 ambient light sensor driver" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 246/371 serial: 8250_bcm7271: Fix arbitration handling
In reply to Greg Kroah-HartmanFrom: Doug Berger <[email protected]>
[ Upstream commit 15ac1122fd6d4bf408a03e6f23c7ad4f60b22f9e ]
The arbitration of the UART DMA is mishandled for a few exceptional cases when probing and releasing the driver.
It is possible that the DMA register spaces are not defined in device tree for an instance of the driver, so attempts to access the registers in brcmuart_arbitration() would use NULL pointers.
It is also possible for the probe function to return an error while still holding the UART DMA. This would prevent the UART DMA from being claimed by an instance that could use it.
These errors are addressed by only releasing the UART DMA if it is held by this instance (i.e. priv->dma_enabled == 1) and directing early error paths in probe to this common release_dma handling.
--- drivers/tty/serial/8250/8250_bcm7271.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/tty/serial/8250/8250_bcm7271.c +12 -6
@@ -1018,14 +1018,16 @@ static int brcmuart_probe(struct platform_device *pdev)/* See if a Baud clock has been specified */ baud_mux_clk =of_clk_get_by_name (np,"sw_baud" );if (IS_ERR (baud_mux_clk)) { -if (PTR_ERR (baud_mux_clk) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; +if (PTR_ERR (baud_mux_clk) == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto release_dma; + }dev_dbg (dev,"BAUD MUX clock not specified\n" ); }else {dev_dbg (dev,"BAUD MUX clock found\n" ); ret =clk_prepare_enable (baud_mux_clk);if (ret) -return ret; + goto release_dma; priv->baud_mux_clk = baud_mux_clk;init_real_clk_rates (dev, priv); clk_rate = priv->default_mux_rate;
@@ -1033,7 +1035,8 @@ static int brcmuart_probe(struct platform_device *pdev)if (clk_rate ==0 ) {dev_err (dev,"clock-frequency or clk not defined\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto release_dma; }dev_dbg (dev,"DMA is %senabled\n" , priv->dma_enabled ?"" :"not " );
@@ -1120,7 +1123,9 @@ static int brcmuart_probe(struct platform_device *pdev)serial8250_unregister_port (priv->line); err:brcmuart_free_bufs (dev, priv); -brcmuart_arbitration (priv,0 ); +release_dma: +if (priv->dma_enabled) +brcmuart_arbitration (priv,0 );return ret; }
@@ -1132,7 +1137,8 @@ static int brcmuart_remove(struct platform_device *pdev)hrtimer_cancel (&priv->hrt);serial8250_unregister_port (priv->line);brcmuart_free_bufs (&pdev->dev, priv); -brcmuart_arbitration (priv,0 ); +if (priv->dma_enabled) +brcmuart_arbitration (priv,0 );return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 247/371 spi: spi-imx: using pm_runtime_resume_and_get instead of pm_runtime_get_sync
In reply to Greg Kroah-HartmanFrom: Minghao Chi <[email protected]>
[ Upstream commit 7d34ff58f35c82207698f43af79817a05e1342e5 ]
Using pm_runtime_resume_and_get() to replace pm_runtime_get_sync and pm_runtime_put_noidle. This change is just to simplify the code, no actual functional changes.
Stable-dep-of: 11951c9e3f36 ("spi: imx: Don't skip cleanup in remove's error path")
--- drivers/spi/spi-imx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/spi/spi-imx.c +2 -4
@@ -1552,9 +1552,8 @@ spi_imx_prepare_message(struct spi_master *master, struct spi_message *msg)struct spi_imx_data *spi_imx =spi_master_get_devdata (master);int ret; - ret =pm_runtime_get_sync (spi_imx->dev); + ret =pm_runtime_resume_and_get (spi_imx->dev);if (ret <0 ) { -pm_runtime_put_noidle (spi_imx->dev);dev_err (spi_imx->dev,"failed to enable clock\n" );return ret; }
@@ -1770,9 +1769,8 @@ static int spi_imx_remove(struct platform_device *pdev)spi_bitbang_stop (&spi_imx->bitbang); - ret =pm_runtime_get_sync (spi_imx->dev); + ret =pm_runtime_resume_and_get (spi_imx->dev);if (ret <0 ) { -pm_runtime_put_noidle (spi_imx->dev);dev_err (spi_imx->dev,"failed to enable clock\n" );return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 248/371 spi: imx: Dont skip cleanup in removes error path
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 11951c9e3f364d7ae3b568a0e52c8335d43066b5 ]
Returning early in a platform driver's remove callback is wrong. In this case the dma resources are not released in the error path. this is never retried later and so this is a permanent leak. To fix this, only skip hardware disabling if waking the device fails.
--- drivers/spi/spi-imx.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/spi/spi-imx.c +5 -7
@@ -1769,13 +1769,11 @@ static int spi_imx_remove(struct platform_device *pdev)spi_bitbang_stop (&spi_imx->bitbang); - ret =pm_runtime_resume_and_get (spi_imx->dev); -if (ret <0 ) { -dev_err (spi_imx->dev,"failed to enable clock\n" ); -return ret; - } - -writel (0 , spi_imx->base +MXC_CSPICTRL ); + ret =pm_runtime_get_sync (spi_imx->dev); +if (ret >=0 ) +writel (0 , spi_imx->base +MXC_CSPICTRL ); +else +dev_warn (spi_imx->dev,"failed to enable clock, skip hw disable\n" );pm_runtime_dont_use_autosuspend (spi_imx->dev);pm_runtime_put_sync (spi_imx->dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 249/371 usb: gadget: udc: renesas_usb3: Fix use after free bug in renesas_usb3_remove due to race condition
In reply to Greg Kroah-HartmanFrom: Zheng Wang <[email protected]>
[ Upstream commit 2b947f8769be8b8181dc795fd292d3e7120f5204 ]
In renesas_usb3_probe, role_work is bound with renesas_usb3_role_work. renesas_usb3_start will be called to start the work.
If we remove the driver which will call usbhs_remove, there may be an unfinished work. The possible sequence is as follows:
CPU0 CPU1
renesas_usb3_role_workrenesas_usb3_removeusb_role_switch_unregisterdevice_unregister
kfree(sw)
//free usb3->role_sw
usb_role_switch_set_role
//use usb3->role_swThe usb3->role_sw could be freed under such circumstance and then used in usb_role_switch_set_role.
This bug was found by static analysis. And note that removing a driver is a root-only operation, and should never happen in normal case. But the root user may directly remove the device which will also trigger the remove function.
Fix it by canceling the work before cleanup in the renesas_usb3_remove.
--- drivers/usb/gadget/udc/renesas_usb3.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/udc/renesas_usb3.c +1 -0
@@ -2568,6 +2568,7 @@ static int renesas_usb3_remove(struct platform_device *pdev)debugfs_remove_recursive (usb3->dentry);device_remove_file (&pdev->dev, &dev_attr_role); +cancel_work_sync (&usb3->role_work);usb_role_switch_unregister (usb3->role_sw);usb_del_gadget_udc (&usb3->gadget);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 250/371 PCI: imx6: Install the fault handler only on compatible match
In reply to Greg Kroah-HartmanFrom: H. Nikolaus Schaller <[email protected]>
[ Upstream commit 5f5ac460dfe7f4e11f99de9870f240e39189cf72 ]
commit bb38919ec56e ("PCI: imx6: Add support for i.MX6 PCIe controller") added a fault hook to this driver in the probe function. So it was only installed if needed.
commit bde4a5a00e76 ("PCI: imx6: Allow probe deferral by reset GPIO") moved it from probe to driver init which installs the hook unconditionally as soon as the driver is compiled into a kernel.
When this driver is compiled as a module, the hook is not registered until after the driver has been matched with a .compatible and loaded.
commit 415b6185c541 ("PCI: imx6: Fix config read timeout handling") extended the fault handling code.
commit 2d8ed461dbc9 ("PCI: imx6: Add support for i.MX8MQ") added some protection for non-ARM architectures, but this does not protect non-i.MX ARM architectures.
Since fault handlers can be triggered on any architecture for different reasons, there is no guarantee that they will be triggered only for the assumed situation, leading to improper error handling (i.MX6-specific imx6q_pcie_abort_handler) on foreign systems.
I had seen strange L3 imprecise external abort messages several times on OMAP4 and OMAP5 devices and couldn't make sense of them until I realized they were related to this unused imx6q driver because I had CONFIG_PCI_IMX6=y.
Note that CONFIG_PCI_IMX6=y is useful for kernel binaries that are designed to run on different ARM SoC and be differentiated only by device tree binaries. So turning off CONFIG_PCI_IMX6 is not a solution.
Therefore we check the compatible in the init function before registering the fault handler.
--- drivers/pci/controller/dwc/pci-imx6.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pci/controller/dwc/pci-imx6.c +7 -0
@@ -1258,6 +1258,13 @@ DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_SYNOPSYS, 0xabcd,static int __init imx6_pcie_init (void ) {#ifdef CONFIG_ARM +struct device_node *np; + + np =of_find_matching_node (NULL , imx6_pcie_of_match); +if (!np) +return -ENODEV ; +of_node_put (np); +/* * Since probe() can be deferred we need to make sure that * hook_fault_code is not called after __init memory is freed
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 251/371 ASoC: es8316: Handle optional IRQ assignment
In reply to Greg Kroah-HartmanFrom: Cristian Ciocaltea <[email protected]>
[ Upstream commit 39db65a0a17b54915b269d3685f253a4731f344c ]
The driver is able to work fine without relying on a mandatory interrupt being assigned to the I2C device. This is only needed when making use of the jack-detect support.
However, the following warning message is always emitted when there is no such interrupt available:
es8316 0-0011: Failed to get IRQ 0: -22
Do not attempt to request an IRQ if it is not available/valid. This also ensures the rather misleading message is not displayed anymore.
Also note the IRQ validation relies on commit dab472eb931bc291 ("i2c /
ACPI: Use 0 to indicate that device does not have interrupt assigned").
--- sound/soc/codecs/es8316.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
sound/soc/codecs/es8316.c +8 -6
@@ -810,12 +810,14 @@ static int es8316_i2c_probe(struct i2c_client *i2c_client, es8316->irq = i2c_client->irq;mutex_init (&es8316->lock); - ret =devm_request_threaded_irq (dev, es8316->irq,NULL , es8316_irq, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT |IRQF_NO_AUTOEN , -"es8316" , es8316); -if (ret) { -dev_warn (dev,"Failed to get IRQ %d: %d\n" , es8316->irq, ret); - es8316->irq = -ENXIO ; +if (es8316->irq >0 ) { + ret =devm_request_threaded_irq (dev, es8316->irq,NULL , es8316_irq, +IRQF_TRIGGER_HIGH |IRQF_ONESHOT |IRQF_NO_AUTOEN , +"es8316" , es8316); +if (ret) { +dev_warn (dev,"Failed to get IRQ %d: %d\n" , es8316->irq, ret); + es8316->irq = -ENXIO ; + } } return devm_snd_soc_register_component(&i2c_client->dev,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 252/371 linux/vt_buffer.h: allow either builtin or modular for macros
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 2b76ffe81e32afd6d318dc4547e2ba8c46207b77 ]
Fix build errors on ARCH=alpha when CONFIG_MDA_CONSOLE=m. This allows the ARCH macros to be the only ones defined.
In file included from ../drivers/video/console/mdacon.c:37:../arch/alpha/include/asm/vga.h:17:40: error: expected identifier or '(' before 'volatile'
17 | static inline void scr_writew(u16 val, volatile u16 *addr)
| ^~~~~~~~../include/linux/vt_buffer.h:24:34: note: in definition of macro 'scr_writew'
24 | #define scr_writew(val, addr) (*(addr) = (val))
| ^~~~../include/linux/vt_buffer.h:24:40: error: expected ')' before '=' token
24 | #define scr_writew(val, addr) (*(addr) = (val))
| ^../arch/alpha/include/asm/vga.h:17:20: note: in expansion of macro 'scr_writew'
17 | static inline void scr_writew(u16 val, volatile u16 *addr)
| ^~~~~~~~~~
../arch/alpha/include/asm/vga.h:25:29: error: expected identifier or '(' before 'volatile'
25 | static inline u16 scr_readw(volatile const u16 *addr)
| ^~~~~~~~
--- include/linux/vt_buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/vt_buffer.h +1 -1
@@ -16,7 +16,7 @@#include <linux/string.h> -#if defined(CONFIG_VGA_CONSOLE ) || defined(CONFIG_MDA_CONSOLE ) +#if IS_ENABLED (CONFIG_VGA_CONSOLE ) ||IS_ENABLED (CONFIG_MDA_CONSOLE )#include <asm/vga.h> #endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 253/371 spi: qup: Dont skip cleanup in removes error path
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 61f49171a43ab1f80c73c5c88c508770c461e0f2 ]
Returning early in a platform driver's remove callback is wrong. In this case the dma resources are not released in the error path. this is never retried later and so this is a permanent leak. To fix this, only skip hardware disabling if waking the device fails.
--- drivers/spi/spi-qup.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
drivers/spi/spi-qup.c +13 -9
@@ -1276,18 +1276,22 @@ static int spi_qup_remove(struct platform_device *pdev)struct spi_qup *controller =spi_master_get_devdata (master);int ret; - ret =pm_runtime_resume_and_get (&pdev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_sync (&pdev->dev); - ret =spi_qup_set_state (controller,QUP_STATE_RESET ); -if (ret) -return ret; +if (ret >=0 ) { + ret =spi_qup_set_state (controller,QUP_STATE_RESET ); +if (ret) +dev_warn (&pdev->dev,"failed to reset controller (%pe)\n" , +ERR_PTR (ret)); -spi_qup_release_dma (master); +clk_disable_unprepare (controller->cclk); +clk_disable_unprepare (controller->iclk); + }else { +dev_warn (&pdev->dev,"failed to resume, skip hw disable (%pe)\n" , +ERR_PTR (ret)); + } -clk_disable_unprepare (controller->cclk); -clk_disable_unprepare (controller->iclk); +spi_qup_release_dma (master);pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 254/371 spi: fsl-spi: Fix CPM/QE mode Litte Endian
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit c20c57d9868d7f9fd1b2904c7801b07e128f6322 ]
CPM has the same problem as QE so for CPM also use the fix added by commit 0398fb70940e ("spi/spi_mpc8xxx: Fix QE mode Litte Endian"):
CPM mode uses Little Endian so words > 8 bits are byte swapped. Workaround this by always enforcing wordsize 8 for 16 and 32 bits words. Unfortunately this will not work for LSB transfers where wordsize is > 8 bits so disable these for now.
Also limit the workaround to 16 and 32 bits words because it can only work for multiples of 8-bits.
--- drivers/spi/spi-fsl-spi.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/spi/spi-fsl-spi.c +7 -5
@@ -207,8 +207,8 @@ static int mspi_apply_qe_mode_quirks(struct spi_mpc8xxx_cs *cs,struct spi_device *spi, int bits_per_word) { -/* QE uses Little Endian for words > 8 -* so transform all words > 8 into 8 bits +/* CPM/QE uses Little Endian for words > 8 +* so transform 16 and 32 bits words into 8 bits * Unfortnatly that doesn't work for LSB so * reject these for now */ /* Note: 32 bits word, LSB works iff
@@ -216,9 +216,11 @@ static int mspi_apply_qe_mode_quirks(struct spi_mpc8xxx_cs *cs,if (spi->mode &SPI_LSB_FIRST && bits_per_word >8 )return -EINVAL ; -if (bits_per_word >8 ) +if (bits_per_word <=8 ) +return bits_per_word; +if (bits_per_word ==16 || bits_per_word ==32 )return 8 ;/* pretend its 8 bits */ -return bits_per_word; +return -EINVAL ; } static int fsl_spi_setup_transfer(struct spi_device *spi,
@@ -248,7 +250,7 @@ static int fsl_spi_setup_transfer(struct spi_device *spi, bits_per_word =mspi_apply_cpu_mode_quirks (cs, spi, mpc8xxx_spi, bits_per_word); - else if (mpc8xxx_spi->flags & SPI_QE) + else bits_per_word =mspi_apply_qe_mode_quirks (cs, spi, bits_per_word);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 255/371 vmci_host: fix a race condition in vmci_host_poll() causing GPF
In reply to Greg Kroah-HartmanFrom: Dae R. Jeong <[email protected]>
[ Upstream commit ae13381da5ff0e8e084c0323c3cc0a945e43e9c7 ]
During fuzzing, a general protection fault is observed in vmci_host_poll().
general protection fault, probably for non-canonical address 0xdffffc0000000019: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x00000000000000c8-0x00000000000000cf] RIP: 0010:__lock_acquire+0xf3/0x5e00 kernel/locking/lockdep.c:4926 <- omitting registers -> Call Trace: <TASK> lock_acquire+0x1a4/0x4a0 kernel/locking/lockdep.c:5672 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0xb3/0x100 kernel/locking/spinlock.c:162 add_wait_queue+0x3d/0x260 kernel/sched/wait.c:22 poll_wait include/linux/poll.h:49 [inline] vmci_host_poll+0xf8/0x2b0 drivers/misc/vmw_vmci/vmci_host.c:174 vfs_poll include/linux/poll.h:88 [inline] do_pollfd fs/select.c:873 [inline] do_poll fs/select.c:921 [inline] do_sys_poll+0xc7c/0x1aa0 fs/select.c:1015 __do_sys_ppoll fs/select.c:1121 [inline] __se_sys_ppoll+0x2cc/0x330 fs/select.c:1101 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x4e/0xa0 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x46/0xb0
Example thread interleaving that causes the general protection fault is as follows:
CPU1 (vmci_host_poll) CPU2 (vmci_host_do_init_context)
----- -----
// Read uninitialized context
context = vmci_host_dev->context;
// Initialize context
vmci_host_dev->context = vmci_ctx_create();
vmci_host_dev->ct_type = VMCIOBJ_CONTEXT;if (vmci_host_dev->ct_type == VMCIOBJ_CONTEXT) {
// Dereferencing the wrong pointer
poll_wait(..., &context->host_context);
}In this scenario, vmci_host_poll() reads vmci_host_dev->context first, and then reads vmci_host_dev->ct_type to check that vmci_host_dev->context is initialized. However, since these two reads are not atomically executed, there is a chance of a race condition as described above.
To fix this race condition, read vmci_host_dev->context after checking the value of vmci_host_dev->ct_type so that vmci_host_poll() always reads an initialized context.
--- drivers/misc/vmw_vmci/vmci_host.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/misc/vmw_vmci/vmci_host.c +7 -1
@@ -165,10 +165,16 @@ static int vmci_host_close(struct inode *inode, struct file *filp)static __poll_t vmci_host_poll (struct file *filp,poll_table *wait) {struct vmci_host_dev *vmci_host_dev = filp->private_data; -struct vmci_ctx *context = vmci_host_dev->context; +struct vmci_ctx *context;__poll_t mask =0 ;if (vmci_host_dev->ct_type ==VMCIOBJ_CONTEXT ) { +/* +* Read context only if ct_type == VMCIOBJ_CONTEXT to make +* sure that context is initialized +*/ + context = vmci_host_dev->context; +/* Check for VMCI calls to this VM context. */ if (wait) poll_wait(filp, &context->host_context.wait_queue,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 256/371 of: Fix modalias string generation
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
[ Upstream commit b19a4266c52de78496fe40f0b37580a3b762e67d ]
The helper generating an OF based modalias (of_device_get_modalias()) works fine, but due to the use of snprintf() internally it needs a buffer one byte longer than what should be needed just for the entire string (excluding the '\0'). Most users of this helper are sysfs hooks providing the modalias string to users. They all provide a PAGE_SIZE buffer which is way above the number of bytes required to fit the modalias string and hence do not suffer from this issue.
There is another user though, of_device_request_module(), which is only called by drivers/usb/common/ulpi.c. This request module function is faulty, but maybe because in most cases there is an alternative, ULPI driver users have not noticed it.
In this function, of_device_get_modalias() is called twice. The first time without buffer just to get the number of bytes required by the modalias string (excluding the null byte), and a second time, after buffer allocation, to fill the buffer. The allocation asks for an additional byte, in order to store the trailing '\0'. However, the buffer *length* provided to of_device_get_modalias() excludes this extra byte. The internal use of snprintf() with a length that is exactly the number of bytes to be written has the effect of using the last available byte to store a '\0', which then smashes the last character of the modalias string.
Provide the actual size of the buffer to of_device_get_modalias() to fix this issue.
Note: the "str[size - 1] = '\0';" line is not really needed as snprintf will anyway end the string with a null byte, but there is a possibility that this function might be called on a struct device_node without compatible, in this case snprintf() would not be executed. So we keep it just to avoid possible unbounded strings.
--- drivers/of/device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/of/device.c +5 -2
@@ -290,12 +290,15 @@ int of_device_request_module(struct device *dev)if (size <0 )return size; - str =kmalloc (size +1 ,GFP_KERNEL ); +/* Reserve an additional byte for the trailing '\0' */ + size++; + + str =kmalloc (size,GFP_KERNEL );if (!str)return -ENOMEM ;of_device_get_modalias (dev, str, size); - str[size] ='\0' ; + str[size -1 ] ='\0' ; ret =request_module (str);kfree (str);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 257/371 PCI/EDR: Clear Device Status after EDR error recovery
In reply to Greg Kroah-HartmanFrom: Kuppuswamy Sathyanarayanan <[email protected]>
[ Upstream commit c441b1e03da6c680a3e12da59c554f454f2ccf5e ]
During EDR recovery, the OS must clear error status of the port that triggered DPC even if firmware retains control of DPC and AER (see the implementation note in the PCI Firmware spec r3.3, sec 4.6.12).
Prior to 068c29a248b6 ("PCI/ERR: Clear PCIe Device Status errors only if OS owns AER"), the port Device Status was cleared in this path:
edr_handle_event
dpc_process_error(dev) # "dev" triggered DPC
pcie_do_recovery(dev, dpc_reset_link)
dpc_reset_link # exit DPC
pcie_clear_device_status(dev) # clear Device Status
After 068c29a248b6, pcie_do_recovery() no longer clears Device Status when firmware controls AER, so the error bit remains set even after recovery.
Per the "Downstream Port Containment configuration control" bit in the returned _OSC Control Field (sec 4.5.1), the OS is allowed to clear error status until it evaluates _OST, so clear Device Status in edr_handle_event() if the error recovery was successful.
--- drivers/pci/pcie/edr.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/pcie/edr.c +1 -0
@@ -193,6 +193,7 @@ static void edr_handle_event(acpi_handle handle, u32 event, void *data)*/ if (estate ==PCI_ERS_RESULT_RECOVERED ) {pci_dbg (edev,"DPC port successfully recovered\n" ); +pcie_clear_device_status (edev);acpi_send_edr_status (pdev, edev,EDR_OST_SUCCESS ); }else {pci_dbg (edev,"DPC port recovery failed\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 258/371 ia64: mm/contig: fix section mismatch warning/error
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 58deeb4ef3b054498747d0929d94ac53ab90981f ]
alloc_per_cpu_data() is called by find_memory(), which is marked as __init. Therefore alloc_per_cpu_data() can also be marked as __init to remedy this modpost problem.
WARNING: modpost: vmlinux.o: section mismatch in reference: alloc_per_cpu_data (section: .text) -> memblock_alloc_try_nid (section: .init.text)
--- arch/ia64/mm/contig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/mm/contig.c +1 -1
@@ -77,7 +77,7 @@ void *per_cpu_init(void)return __per_cpu_start + __per_cpu_offset[smp_processor_id ()]; } -static inline void +static inline __init void alloc_per_cpu_data (void ) {size_t size =PERCPU_PAGE_SIZE *num_possible_cpus ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 259/371 ia64: salinfo: placate defined-but-not-used warning
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 0de155752b152d6bcd96b5b5bf20af336abd183a ]
When CONFIG_PROC_FS is not set, proc_salinfo_show() is not used. Mark the function as __maybe_unused to quieten the warning message.
../arch/ia64/kernel/salinfo.c:584:12: warning: 'proc_salinfo_show' defined but not used [-Wunused-function]
584 | static int proc_salinfo_show(struct seq_file *m, void *v)
| ^~~~~~~~~~~~~~~~~
--- arch/ia64/kernel/salinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/kernel/salinfo.c +1 -1
@@ -581,7 +581,7 @@ static int salinfo_cpu_pre_down(unsigned int cpu)* 'data' contains an integer that corresponds to the feature we're * testing */ -static int proc_salinfo_show (struct seq_file *m,void *v) +static int __maybe_unused proc_salinfo_show (struct seq_file *m,void *v) {unsigned long data = (unsigned long )v;seq_puts (m, (sal_platform_features & data) ?"1\n" :"0\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 260/371 scripts/gdb: bail early if there are no clocks
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 1d7adbc74c009057ed9dc3112f388e91a9c79acc ]
Avoid generating an exception if there are no clocks registered:
(gdb) lx-clk-summary
enable prepare protect
clock count count count rate
------------------------------------------------------------------------
Python Exception <class 'gdb.error'>: No symbol "clk_root_list" in current context.
Error occurred in Python: No symbol "clk_root_list" in current context.
--- scripts/gdb/linux/clk.py | 2 ++ 1 file changed, 2 insertions(+)
scripts/gdb/linux/clk.py +2 -0
@@ -41,6 +41,8 @@ are cached and potentially out of date""" self.show_subtree(child, level + 1) def invoke(self, arg, from_tty): + if utils.gdb_eval_or_none("clk_root_list") is None: + raise gdb.GdbError("No clocks registered") gdb.write(" enable prepare protect \n") gdb.write(" clock count count count rate \n") gdb.write("------------------------------------------------------------------------\n")
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 261/371 scripts/gdb: bail early if there are no generic PD
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit f19c3c2959e465209ade1a7a699e6cbf4359ce78 ]
Avoid generating an exception if there are no generic power domain(s) registered:
(gdb) lx-genpd-summary
domain status children
/device runtime status
----------------------------------------------------------------------
Python Exception <class 'gdb.error'>: No symbol "gpd_list" in current context. Error occurred in Python: No symbol "gpd_list" in current context. (gdb) quit
--- scripts/gdb/linux/genpd.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/gdb/linux/genpd.py +3 -1
@@ -5,7 +5,7 @@ import gdb import sys -from linux.utils import CachedType +from linux.utils import CachedType, gdb_eval_or_none from linux.lists import list_for_each_entry generic_pm_domain_type = CachedType('struct generic_pm_domain')
@@ -70,6 +70,8 @@ Output is similar to /sys/kernel/debug/pm_genpd/pm_genpd_summary''' gdb.write(' %-50s %s\n' % (kobj_path, rtpm_status_str(dev))) def invoke(self, arg, from_tty): + if gdb_eval_or_none("&gpd_list") is None: + raise gdb.GdbError("No power domain(s) registered") gdb.write('domain status children\n'); gdb.write(' /device runtime status\n'); gdb.write('----------------------------------------------------------------------\n');
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 262/371 HID: amd_sfh: Add support for shutdown operation
In reply to Greg Kroah-HartmanFrom: Basavaraj Natikar <[email protected]>
[ Upstream commit 1353ecaf1830d6d1b74f3225378a9498b4e14fdd ]
As soon as the system is booted after shutdown, the sensors may remain in a weird state and fail to initialize. Therefore, all sensors should be turned off during shutdown.
--- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +9 -0
@@ -351,6 +351,14 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ireturn devm_add_action_or_reset (&pdev->dev, amd_mp2_pci_remove, privdata); } +static void amd_sfh_shutdown (struct pci_dev *pdev) +{ +struct amd_mp2_dev *mp2 =pci_get_drvdata (pdev); + +if (mp2 && mp2->mp2_ops) + mp2->mp2_ops->stop_all (mp2); +} +static int __maybe_unused amd_mp2_pci_resume (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);
@@ -420,6 +428,7 @@ static struct pci_driver amd_mp2_pci_driver = { .id_table = amd_mp2_pci_tbl, .probe = amd_mp2_pci_probe, .driver.pm = &amd_mp2_pm_ops, + .shutdown = amd_sfh_shutdown, };module_pci_driver (amd_mp2_pci_driver);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 263/371 coresight: etm_pmu: Set the module field
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
[ Upstream commit 18996a113f2567aef3057e300e3193ce2df1684c ]
struct pmu::module must be set to the module owning the PMU driver. Set this for the coresight etm_pmu.
--- drivers/hwtracing/coresight/coresight-etm-perf.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwtracing/coresight/coresight-etm-perf.c +1 -0
@@ -830,6 +830,7 @@ int __init etm_perf_init(void) etm_pmu.addr_filters_sync = etm_addr_filters_sync; etm_pmu.addr_filters_validate = etm_addr_filters_validate; etm_pmu.nr_addr_filters =ETM_ADDR_CMP_MAX ; + etm_pmu.module =THIS_MODULE ; ret =perf_pmu_register (&etm_pmu,CORESIGHT_ETM_PMU_NAME ,-1 );if (ret ==0 )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 264/371 ASoC: fsl_mqs: move of_node_put() to the correct location
In reply to Greg Kroah-HartmanFrom: Liliang Ye <[email protected]>
[ Upstream commit 1c34890273a020d61d6127ade3f68ed1cb21c16a ]
of_node_put() should have been done directly after mqs_priv->regmap = syscon_node_to_regmap(gpr_np); otherwise it creates a reference leak on the success path.
To fix this, of_node_put() is moved to the correct location, and change all the gotos to direct returns.
--- sound/soc/fsl/fsl_mqs.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
sound/soc/fsl/fsl_mqs.c +5 -10
@@ -204,10 +204,10 @@ static int fsl_mqs_probe(struct platform_device *pdev) } mqs_priv->regmap =syscon_node_to_regmap (gpr_np); +of_node_put (gpr_np);if (IS_ERR (mqs_priv->regmap)) {dev_err (&pdev->dev,"failed to get gpr regmap\n" ); - ret =PTR_ERR (mqs_priv->regmap); - goto err_free_gpr_np; +return PTR_ERR (mqs_priv->regmap); } }else { regs =devm_platform_ioremap_resource (pdev,0 );
@@ -236,8 +236,7 @@ static int fsl_mqs_probe(struct platform_device *pdev)if (IS_ERR (mqs_priv->mclk)) {dev_err (&pdev->dev,"failed to get the clock: %ld\n" ,PTR_ERR (mqs_priv->mclk)); - ret =PTR_ERR (mqs_priv->mclk); - goto err_free_gpr_np; +return PTR_ERR (mqs_priv->mclk); }dev_set_drvdata (&pdev->dev, mqs_priv);
@@ -246,13 +245,9 @@ static int fsl_mqs_probe(struct platform_device *pdev) ret =devm_snd_soc_register_component (&pdev->dev, &soc_codec_fsl_mqs, &fsl_mqs_dai,1 );if (ret) - goto err_free_gpr_np; -return 0 ; - -err_free_gpr_np: -of_node_put (gpr_np); +return ret; -return ret; +return 0 ; }static int fsl_mqs_remove (struct platform_device *pdev)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 265/371 spi: cadence-quadspi: fix suspend-resume implementations
In reply to Greg Kroah-HartmanFrom: Dhruva Gole <[email protected]>
[ Upstream commit 2087e85bb66ee3652dafe732bb9b9b896229eafc ]
The cadence QSPI driver misbehaves after performing a full system suspend resume:
...
spi-nor spi0.0: resume() failed
...
This results in a flash connected via OSPI interface after system suspend- resume to be unusable.
fix these suspend and resume functions.
--- drivers/spi/spi-cadence-quadspi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/spi/spi-cadence-quadspi.c +16 -3
@@ -1619,17 +1619,30 @@ static int cqspi_remove(struct platform_device *pdev)static int cqspi_suspend (struct device *dev) {struct cqspi_st *cqspi =dev_get_drvdata (dev); +struct spi_master *master =dev_get_drvdata (dev); +int ret; + ret =spi_master_suspend (master);cqspi_controller_enable (cqspi,0 ); -return 0 ; + +clk_disable_unprepare (cqspi->clk); + +return ret; }static int cqspi_resume (struct device *dev) {struct cqspi_st *cqspi =dev_get_drvdata (dev); +struct spi_master *master =dev_get_drvdata (dev); -cqspi_controller_enable (cqspi,1 ); -return 0 ; +clk_prepare_enable (cqspi->clk); +cqspi_wait_idle (cqspi); +cqspi_controller_init (cqspi); + + cqspi->current_cs =-1 ; + cqspi->sclk =0 ; + +return spi_master_resume (master); }static const struct dev_pm_ops cqspi__dev_pm_ops = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 266/371 i2c: cadence: cdns_i2c_master_xfer(): Fix runtime PM leak on error path
In reply to Greg Kroah-HartmanFrom: Lars-Peter Clausen <[email protected]>
[ Upstream commit ae1664f04f504a998737f5bb563f16b44357bcca ]
The cdns_i2c_master_xfer() function gets a runtime PM reference when the function is entered. This reference is released when the function is exited. There is currently one error path where the function exits directly, which leads to a leak of the runtime PM reference.
Make sure that this error path also releases the runtime PM reference.
--- drivers/i2c/busses/i2c-cadence.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-cadence.c +4 -2
@@ -828,8 +828,10 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,#if IS_ENABLED (CONFIG_I2C_SLAVE )/* Check i2c operating mode and switch if possible */ if (id->dev_mode ==CDNS_I2C_MODE_SLAVE ) { -if (id->slave_state !=CDNS_I2C_SLAVE_STATE_IDLE ) -return -EAGAIN ; +if (id->slave_state !=CDNS_I2C_SLAVE_STATE_IDLE ) { + ret = -EAGAIN ; + goto out; + }/* Set mode to master */ cdns_i2c_set_mode (CDNS_I2C_MODE_MASTER , id);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 267/371 scripts/gdb: raise error with reduced debugging information
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 8af055ae25bff48f57227f5e3d48a4306f3dd1c4 ]
If CONFIG_DEBUG_INFO_REDUCED is enabled in the kernel configuration, we will typically not be able to load vmlinux-gdb.py and will fail with:
Traceback (most recent call last):
File "/home/fainelli/work/buildroot/output/arm64/build/linux-custom/vmlinux-gdb.py", line 25, in <module>
import linux.utils
File "/home/fainelli/work/buildroot/output/arm64/build/linux-custom/scripts/gdb/linux/utils.py", line 131, in <module>
atomic_long_counter_offset = atomic_long_type.get_type()['counter'].bitpos
KeyError: 'counter'
Rather be left wondering what is happening only to find out that reduced debug information is the cause, raise an eror. This was not typically a problem until e3c8d33e0d62 ("scripts/gdb: fix 'lx-dmesg' on 32 bits arch") but it has since then.
--- scripts/gdb/linux/constants.py.in | 2 ++ scripts/gdb/vmlinux-gdb.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-)
scripts/gdb/linux/constants.py.in +2 -0
@@ -39,6 +39,8 @@ import gdb +LX_CONFIG(CONFIG_DEBUG_INFO_REDUCED) + /* linux/clk-provider.h */ if IS_BUILTIN(CONFIG_COMMON_CLK): LX_GDBPARSED(CLK_GET_RATE_NOCACHE)
scripts/gdb/vmlinux-gdb.py +4 -1
@@ -22,6 +22,10 @@ except: gdb.write("NOTE: gdb 7.2 or later required for Linux helper scripts to " "work.\n") else: + import linux.constants + if linux.constants.LX_CONFIG_DEBUG_INFO_REDUCED: + raise gdb.GdbError("Reduced debug information will prevent GDB " + "from having complete types.\n") import linux.utils import linux.symbols import linux.modules
@@ -32,7 +36,6 @@ else: import linux.lists import linux.rbtree import linux.proc - import linux.constants import linux.timerlist import linux.clk import linux.genpd
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 268/371 uapi/linux/const.h: prefer ISO-friendly __typeof__
In reply to Greg Kroah-HartmanFrom: Kevin Brodsky <[email protected]>
[ Upstream commit 31088f6f7906253ef4577f6a9b84e2d42447dba0 ]
typeof is (still) a GNU extension, which means that it cannot be used when building ISO C (e.g. -std=c99). It should therefore be avoided in uapi headers in favour of the ISO-friendly __typeof__.
Unfortunately this issue could not be detected by CONFIG_UAPI_HEADER_TEST=y as the __ALIGN_KERNEL() macro is not expanded in any uapi header.
This matters from a userspace perspective, not a kernel one. uapi headers and their contents are expected to be usable in a variety of situations, and in particular when building ISO C applications (with -std=c99 or similar).
This particular problem can be reproduced by trying to use the __ALIGN_KERNEL macro directly in application code, say:
#include <linux/const.h>
int align(int x, int a)
{
return __KERNEL_ALIGN(x, a);
}and trying to build that with -std=c99.
--- include/uapi/linux/const.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/const.h +1 -1
@@ -28,7 +28,7 @@#define _BITUL (x) (_UL(1) << (x))#define _BITULL (x) (_ULL(1) << (x)) -#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)#define __ALIGN_KERNEL_MASK (x, mask) (((x) + (mask)) & ~(mask))#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 269/371 sh: sq: Fix incorrect element size for allocating bitmap buffer
In reply to Greg Kroah-HartmanFrom: John Paul Adrian Glaubitz <[email protected]>
[ Upstream commit 80f746e2bd0e1da3fdb49a53570e54a1a225faac ]
The Store Queue code allocates a bitmap buffer with the size of multiple of sizeof(long) in sq_api_init(). While the buffer size is calculated correctly, the code uses the wrong element size to allocate the buffer which results in the allocated bitmap buffer being too small.
Fix this by allocating the buffer with kcalloc() with element size sizeof(long) instead of kzalloc() whose elements size defaults to sizeof(char).
--- arch/sh/kernel/cpu/sh4/sq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/kernel/cpu/sh4/sq.c +1 -1
@@ -381,7 +381,7 @@ static int __init sq_api_init(void)if (unlikely (!sq_cache))return ret; - sq_bitmap =kzalloc (size,GFP_KERNEL ); + sq_bitmap =kcalloc (size,sizeof (long ),GFP_KERNEL );if (unlikely (!sq_bitmap)) goto out;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 270/371 usb: gadget: tegra-xudc: Fix crash in vbus_draw
In reply to Greg Kroah-HartmanFrom: Jon Hunter <[email protected]>
[ Upstream commit 5629d31955297ca47b9283c64fff70f2f34aa528 ]
Commit ac82b56bda5f ("usb: gadget: tegra-xudc: Add vbus_draw support") populated the vbus_draw callback for the Tegra XUDC driver. The function tegra_xudc_gadget_vbus_draw(), that was added by this commit, assumes that the pointer 'curr_usbphy' has been initialised, which is not always the case because this is only initialised when the USB role is updated. Fix this crash, by checking that the 'curr_usbphy' is valid before dereferencing.
--- drivers/usb/gadget/udc/tegra-xudc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/tegra-xudc.c +1 -1
@@ -2154,7 +2154,7 @@ static int tegra_xudc_gadget_vbus_draw(struct usb_gadget *gadget,dev_dbg (xudc->dev,"%s: %u mA\n" , __func__, m_a); -if (xudc->curr_usbphy->chg_type ==SDP_TYPE ) +if (xudc->curr_usbphy && xudc->curr_usbphy->chg_type ==SDP_TYPE ) ret =usb_phy_set_power (xudc->curr_usbphy, m_a);return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 271/371 usb: chipidea: fix missing goto in `ci_hdrc_probe`
In reply to Greg Kroah-HartmanFrom: Yinhao Hu <[email protected]>
[ Upstream commit d6f712f53b79f5017cdcefafb7a5aea9ec52da5d ]
Quoted 1 line
From the comment of
ci_usb_phy_init, it returns an error code if
usb_phy_init has failed, and it should do some clean up, not just return directly.
Fix this by goto the error handling.
--- drivers/usb/chipidea/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/chipidea/core.c +1 -1
@@ -1098,7 +1098,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) ret =ci_usb_phy_init (ci);if (ret) {dev_err (dev,"unable to init phy: %d\n" , ret); -return ret; + goto ulpi_exit; } ci->hw_bank.phys = res->start;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 272/371 usb: mtu3: fix kernel panic at qmu transfer done irq handler
In reply to Greg Kroah-HartmanFrom: Chunfeng Yun <[email protected]>
[ Upstream commit d28f4091ea7ec3510fd6a3c6d433234e7a2bef14 ]
When handle qmu transfer irq, it will unlock @mtu->lock before give back request, if another thread handle disconnect event at the same time, and try to disable ep, it may lock @mtu->lock and free qmu ring, then qmu irq hanlder may get a NULL gpd, avoid the KE by checking gpd's value before handling it.
e.g.
qmu done irq on cpu0 thread running on cpu1
qmu_done_tx()
handle gpd [0]
mtu3_requ_complete() mtu3_gadget_ep_disable()
unlock @mtu->lock
give back request lock @mtu->lock
mtu3_ep_disable()
mtu3_gpd_ring_free()
unlock @mtu->lock
lock @mtu->lock
get next gpd [1][1]: goto [0] to handle next gpd, and next gpd may be NULL.
--- drivers/usb/mtu3/mtu3_qmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/mtu3/mtu3_qmu.c +3 -2
@@ -210,6 +210,7 @@ static struct qmu_gpd *advance_enq_gpd(struct mtu3_gpd_ring *ring)return ring->enqueue; } +/* @dequeue may be NULL if ring is unallocated or freed */ static struct qmu_gpd *advance_deq_gpd (struct mtu3_gpd_ring *ring) {if (ring->dequeue < ring->end)
@@ -484,7 +485,7 @@ static void qmu_done_tx(struct mtu3 *mtu, u8 epnum)dev_dbg (mtu->dev,"%s EP%d, last=%p, current=%p, enq=%p\n" , __func__, epnum, gpd, gpd_current, ring->enqueue); -while (gpd != gpd_current && !GET_GPD_HWO (gpd)) { +while (gpd && gpd != gpd_current && !GET_GPD_HWO (gpd)) { mreq =next_request (mep);
@@ -523,7 +524,7 @@ static void qmu_done_rx(struct mtu3 *mtu, u8 epnum)dev_dbg (mtu->dev,"%s EP%d, last=%p, current=%p, enq=%p\n" , __func__, epnum, gpd, gpd_current, ring->enqueue); -while (gpd != gpd_current && !GET_GPD_HWO (gpd)) { +while (gpd && gpd != gpd_current && !GET_GPD_HWO (gpd)) { mreq =next_request (mep);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 273/371 firmware: stratix10-svc: Fix an NULL vs IS_ERR() bug in probe
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e1d6ca042e62c2a69513235f8629eb6e62ca79c5 ]
The svc_create_memory_pool() function returns error pointers. It never returns NULL. Fix the check.
--- drivers/firmware/stratix10-svc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/stratix10-svc.c +2 -2
@@ -989,8 +989,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)return ret; genpool =svc_create_memory_pool (pdev, sh_memory); -if (!genpool) -return -ENOMEM ; +if (IS_ERR (genpool)) +return PTR_ERR (genpool);/* allocate service controller and supporting channel */ controller =devm_kzalloc (dev,sizeof (*controller),GFP_KERNEL );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 274/371 tty: serial: fsl_lpuart: adjust buffer length to the intended size
In reply to Greg Kroah-HartmanFrom: Shenwei Wang <[email protected]>
[ Upstream commit f73fd750552524b06b5d77ebfdd106ccc8fcac61 ]
Based on the fls function definition provided below, we should not subtract 1 to obtain the correct buffer length:
fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
--- drivers/tty/serial/fsl_lpuart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/fsl_lpuart.c +1 -1
@@ -1250,7 +1250,7 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport)* 10ms at any baud rate. */ sport->rx_dma_rng_buf_len = (DMA_RX_TIMEOUT * baud / bits /1000 ) *2 ; - sport->rx_dma_rng_buf_len = (1 << (fls (sport->rx_dma_rng_buf_len) -1 )); + sport->rx_dma_rng_buf_len = (1 <<fls (sport->rx_dma_rng_buf_len));if (sport->rx_dma_rng_buf_len <16 ) sport->rx_dma_rng_buf_len =16 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 275/371 serial: 8250: Add missing wakeup event reporting
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 0ba9e3a13c6adfa99e32b2576d20820ab10ad48a ]
An 8250 UART configured as a wake-up source would not have reported itself through sysfs as being the source of wake-up, correct that.
--- drivers/tty/serial/8250/8250_port.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/8250/8250_port.c +4 -0
@@ -15,6 +15,7 @@#include <linux/moduleparam.h> #include <linux/ioport.h> #include <linux/init.h> +#include <linux/irq.h> #include <linux/console.h> #include <linux/gpio/consumer.h> #include <linux/sysrq.h>
@@ -1904,6 +1905,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) {unsigned char status;struct uart_8250_port *up =up_to_u8250p (port); +struct tty_port *tport = &port->state->port;bool skip_rx = false;unsigned long flags;
@@ -1928,6 +1930,8 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) skip_rx = true;if (status & (UART_LSR_DR |UART_LSR_BI ) && !skip_rx) { +if (irqd_is_wakeup_set (irq_get_irq_data (port->irq))) +pm_wakeup_event (tport->tty->dev,0 );if (!up->dma ||handle_rx_dma (up, iir)) status =serial8250_rx_chars (up, status); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 276/371 staging: rtl8192e: Fix W_DISABLE# does not work after stop/start
In reply to Greg Kroah-HartmanFrom: Philipp Hortmann <[email protected]>
[ Upstream commit 3fac2397f562eb669ddc2f45867a253f3fc26184 ]
When loading the driver for rtl8192e, the W_DISABLE# switch is working as intended. But when the WLAN is turned off in software and then turned on again the W_DISABLE# does not work anymore. Reason for this is that in the function _rtl92e_dm_check_rf_ctrl_gpio() the bfirst_after_down is checked and returned when true. bfirst_after_down is set true when switching the WLAN off in software. But it is not set to false again when WLAN is turned on again.
Add bfirst_after_down = false in _rtl92e_sta_up to reset bit and fix above described bug.
--- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +1 -0
@@ -768,6 +768,7 @@ static int _rtl92e_sta_up(struct net_device *dev, bool is_silent_reset)else netif_wake_queue (dev); + priv->bfirst_after_down = false;return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 277/371 spmi: Add a check for remove callback when removing a SPMI driver
In reply to Greg Kroah-HartmanFrom: Jishnu Prakash <[email protected]>
[ Upstream commit b56eef3e16d888883fefab47425036de80dd38fc ]
When removing a SPMI driver, there can be a crash due to NULL pointer dereference if it does not have a remove callback defined. This is one such call trace observed when removing the QCOM SPMI PMIC driver:
dump_backtrace.cfi_jt+0x0/0x8 dump_stack_lvl+0xd8/0x16c panic+0x188/0x498 __cfi_slowpath+0x0/0x214 __cfi_slowpath+0x1dc/0x214 spmi_drv_remove+0x16c/0x1e0 device_release_driver_internal+0x468/0x79c driver_detach+0x11c/0x1a0 bus_remove_driver+0xc4/0x124 driver_unregister+0x58/0x84 cleanup_module+0x1c/0xc24 [qcom_spmi_pmic] __do_sys_delete_module+0x3ec/0x53c __arm64_sys_delete_module+0x18/0x28 el0_svc_common+0xdc/0x294 el0_svc+0x38/0x9c el0_sync_handler+0x8c/0xf0 el0_sync+0x1b4/0x1c0
If a driver has all its resources allocated through devm_() APIs and does not need any other explicit cleanup, it would not require a remove callback to be defined. Hence, add a check for remove callback presence before calling it when removing a SPMI driver.
--- drivers/spmi/spmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spmi/spmi.c +2 -1
@@ -350,7 +350,8 @@ static void spmi_drv_remove(struct device *dev)const struct spmi_driver *sdrv =to_spmi_driver (dev->driver);pm_runtime_get_sync (dev); - sdrv->remove (to_spmi_device (dev)); +if (sdrv->remove) + sdrv->remove (to_spmi_device (dev));pm_runtime_put_noidle (dev);pm_runtime_disable (dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 278/371 virtio_ring: dont update event idx on get_buf
In reply to Greg Kroah-HartmanFrom: Albert Huang <[email protected]>
[ Upstream commit 6c0b057cec5eade4c3afec3908821176931a9997 ]
In virtio_net, if we disable napi_tx, when we trigger a tx interrupt, the vq->event_triggered will be set to true. It is then never reset until we explicitly call virtqueue_enable_cb_delayed or virtqueue_enable_cb_prepare.
If we disable the napi_tx, virtqueue_enable_cb* will only be called when the tx ring is getting relatively empty.
Since event_triggered is true, VRING_AVAIL_F_NO_INTERRUPT or VRING_PACKED_EVENT_FLAG_DISABLE will not be set. As a result we update vring_used_event(&vq->split.vring) or vq->packed.vring.driver->off_wrap every time we call virtqueue_get_buf_ctx. This causes more interrupts.
To summarize:
1) event_triggered was set to true in vring_interrupt()
2) after this nothing will happen in virtqueue_disable_cb() so VRING_AVAIL_F_NO_INTERRUPT is not set in avail_flags_shadow
3) virtqueue_get_buf_ctx_split() will still think the cb is enabled and then it will publish a new event index
To fix:
update VRING_AVAIL_F_NO_INTERRUPT or VRING_PACKED_EVENT_FLAG_DISABLE in the vq when we call virtqueue_disable_cb even when event_triggered is true.
Tested with iperf:
iperf3 tcp stream:
vm1 -----------------> vm2
vm2 just receives tcp data stream from vm1, and sends acks to vm1, there are many tx interrupts in vm2.
with the patch applied there are just a few tx interrupts.
v2->v3:
-update the interrupt disable flag even with the event_triggered is set, -instead of checking whether event_triggered is set in -virtqueue_get_buf_ctx_{packed/split}, will cause the drivers which have -not called virtqueue_{enable/disable}_cb to miss notifications.
v3->v4:
-remove change for
-"if (vq->packed.event_flags_shadow != VRING_PACKED_EVENT_FLAG_DISABLE)" -in virtqueue_disable_cb_packed
Message-Id: <[email protected]>
--- drivers/virtio/virtio_ring.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/virtio/virtio_ring.c +16 -6
@@ -809,6 +809,14 @@ static void virtqueue_disable_cb_split(struct virtqueue *_vq)if (!(vq->split.avail_flags_shadow &VRING_AVAIL_F_NO_INTERRUPT )) { vq->split.avail_flags_shadow |=VRING_AVAIL_F_NO_INTERRUPT ; + +/* +* If device triggered an event already it won't trigger one again: +* no need to disable. +*/ +if (vq->event_triggered) +return ; +if (vq->event)/* TODO: this is a hack. Figure out a cleaner value to write. */ vring_used_event (&vq->split.vring) =0x0 ;
@@ -1500,6 +1508,14 @@ static void virtqueue_disable_cb_packed(struct virtqueue *_vq)if (vq->packed.event_flags_shadow !=VRING_PACKED_EVENT_FLAG_DISABLE ) { vq->packed.event_flags_shadow =VRING_PACKED_EVENT_FLAG_DISABLE ; + +/* +* If device triggered an event already it won't trigger one again: +* no need to disable. +*/ +if (vq->event_triggered) +return ; + vq->packed.vring.driver->flags =cpu_to_le16 (vq->packed.event_flags_shadow); }
@@ -2019,12 +2035,6 @@ void virtqueue_disable_cb(struct virtqueue *_vq) {struct vring_virtqueue *vq =to_vvq (_vq); -/* If device triggered an event already it won't trigger one again: -* no need to disable. -*/ -if (vq->event_triggered) -return ; -if (vq->packed_ring)virtqueue_disable_cb_packed (_vq);else
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 279/371 spi: bcm63xx: remove PM_SLEEP based conditional compilation
In reply to Greg Kroah-HartmanFrom: Dhruva Gole <[email protected]>
[ Upstream commit 25f0617109496e1aff49594fbae5644286447a0f ]
Get rid of conditional compilation based on CONFIG_PM_SLEEP because it may introduce build issues with certain configs where it maybe disabled This is because if above config is not enabled the suspend-resume functions are never part of the code but the bcm63xx_spi_pm_ops struct still inits them to non-existent suspend-resume functions.
--- drivers/spi/spi-bcm63xx.c | 2 -- 1 file changed, 2 deletions(-)
drivers/spi/spi-bcm63xx.c +0 -2
@@ -630,7 +630,6 @@ static int bcm63xx_spi_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_SLEEP static int bcm63xx_spi_suspend (struct device *dev) {struct spi_master *master =dev_get_drvdata (dev);
@@ -657,7 +656,6 @@ static int bcm63xx_spi_resume(struct device *dev)return 0 ; } -#endif static const struct dev_pm_ops bcm63xx_spi_pm_ops = {SET_SYSTEM_SLEEP_PM_OPS (bcm63xx_spi_suspend, bcm63xx_spi_resume)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 280/371 macintosh/windfarm_smu_sat: Add missing of_node_put()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 631cf002826007ab7415258ee647dcaf8845ad5a ]
We call of_node_get() in wf_sat_probe() after sat is created, so we need the of_node_put() before *kfree(sat)*.
--- drivers/macintosh/windfarm_smu_sat.c | 1 + 1 file changed, 1 insertion(+)
drivers/macintosh/windfarm_smu_sat.c +1 -0
@@ -171,6 +171,7 @@ static void wf_sat_release(struct kref *ref)if (sat->nr >=0 ) sats[sat->nr] =NULL ; +of_node_put (sat->node);kfree (sat); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 281/371 powerpc/mpc512x: fix resource printk format warning
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 7538c97e2b80ff6b7a8ea2ecf16a04355461b439 ]
Use "%pa" format specifier for resource_size_t to avoid a compiler printk format warning.
../arch/powerpc/platforms/512x/clock-commonclk.c: In function 'mpc5121_clk_provide_backwards_compat':../arch/powerpc/platforms/512x/clock-commonclk.c:989:44: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
989 | snprintf(devname, sizeof(devname), "%08x.%s", res.start, np->name); \
| ^~~~~~~~~ ~~~~~~~~~
| |
| resource_size_t {aka long long unsigned int}Prevents 24 such warnings.
--- arch/powerpc/platforms/512x/clock-commonclk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/512x/clock-commonclk.c +1 -1
@@ -984,7 +984,7 @@ static void mpc5121_clk_provide_migration_support(void)#define NODE_PREP do { \ of_address_to_resource(np, 0, &res); \ - snprintf(devname, sizeof(devname), "%08x.%s", res.start, np->name); \ + snprintf(devname, sizeof(devname), "%pa.%s", &res.start, np->name); \ } while (0)#define NODE_CHK (clkname, clkitem, regnode, regflag) do { \
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 282/371 powerpc/wii: fix resource printk format warnings
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 7b69600d4da0049244e9be2f5ef5a2f8e04fcd9a ]
Use "%pa" format specifier for resource_size_t to avoid compiler printk format warnings.
../arch/powerpc/platforms/embedded6xx/flipper-pic.c: In function 'flipper_pic_init':../include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=] ../arch/powerpc/platforms/embedded6xx/flipper-pic.c:148:9: note: in expansion of macro 'pr_info'
148 | pr_info("controller at 0x%08x mapped to 0x%p\n", res.start, io_base);
| ^~~~~~~../arch/powerpc/platforms/embedded6xx/hlwd-pic.c: In function 'hlwd_pic_init':../include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=] ../arch/powerpc/platforms/embedded6xx/hlwd-pic.c:174:9: note: in expansion of macro 'pr_info'
174 | pr_info("controller at 0x%08x mapped to 0x%p\n", res.start, io_base);
| ^~~~~~~../arch/powerpc/platforms/embedded6xx/wii.c: In function 'wii_ioremap_hw_regs':../include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=] ../arch/powerpc/platforms/embedded6xx/wii.c:77:17: note: in expansion of macro 'pr_info'
77 | pr_info("%s at 0x%08x mapped to 0x%p\n", name,
| ^~~~~~~--- arch/powerpc/platforms/embedded6xx/flipper-pic.c | 2 +- arch/powerpc/platforms/embedded6xx/hlwd-pic.c | 2 +- arch/powerpc/platforms/embedded6xx/wii.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/embedded6xx/flipper-pic.c +1 -1
@@ -145,7 +145,7 @@ static struct irq_domain * __init flipper_pic_init(struct device_node *np) } io_base =ioremap (res.start,resource_size (&res)); -pr_info ("controller at 0x%08x mapped to 0x%p\n" , res.start, io_base); +pr_info ("controller at 0x%pa mapped to 0x%p\n" , &res.start, io_base);__flipper_quiesce (io_base);
arch/powerpc/platforms/embedded6xx/hlwd-pic.c +1 -1
@@ -171,7 +171,7 @@ static struct irq_domain *hlwd_pic_init(struct device_node *np)return NULL ; } -pr_info ("controller at 0x%08x mapped to 0x%p\n" , res.start, io_base); +pr_info ("controller at 0x%pa mapped to 0x%p\n" , &res.start, io_base);__hlwd_quiesce (io_base);
arch/powerpc/platforms/embedded6xx/wii.c +2 -2
@@ -89,8 +89,8 @@ static void __iomem *wii_ioremap_hw_regs(char *name, char *compatible) hw_regs =ioremap (res.start,resource_size (&res));if (hw_regs) { -pr_info ("%s at 0x%08x mapped to 0x%p\n" , name, - res.start, hw_regs); +pr_info ("%s at 0x%pa mapped to 0x%p\n" , name, + &res.start, hw_regs); } out_put:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 283/371 powerpc/sysdev/tsi108: fix resource printk format warnings
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 55d8bd02cc1b9f1063993b5c42c9cabf4af67dea ]
Use "%pa" format specifier for resource_size_t to avoid a compiler printk format warning.
arch/powerpc/sysdev/tsi108_pci.c: In function 'tsi108_setup_pci':
include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'resource_size_t'
--- arch/powerpc/sysdev/tsi108_pci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/sysdev/tsi108_pci.c +2 -3
@@ -216,9 +216,8 @@ int __init tsi108_setup_pci(struct device_node *dev, u32 cfg_phys, int primary) (hose)->ops = &tsi108_direct_pci_ops; -printk (KERN_INFO "Found tsi108 PCI host bridge at 0x%08x. " -"Firmware bus number: %d->%d\n" , - rsrc.start, hose->first_busno, hose->last_busno); +pr_info ("Found tsi108 PCI host bridge at 0x%pa. Firmware bus number: %d->%d\n" , + &rsrc.start, hose->first_busno, hose->last_busno);/* Interpret the "ranges" property */ /* This also maps the I/O region and sets isa_io/mem_base */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 284/371 macintosh: via-pmu-led: requires ATA to be set
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 05dce4ba125336875cd3eed3c1503fa81cd2f691 ]
LEDS_TRIGGER_DISK depends on ATA, so selecting LEDS_TRIGGER_DISK when ATA is not set/enabled causes a Kconfig warning:
WARNING: unmet direct dependencies detected for LEDS_TRIGGER_DISK
Depends on [n]: NEW_LEDS [=y] && LEDS_TRIGGERS [=y] && ATA [=n]
Selected by [y]:
- ADB_PMU_LED_DISK [=y] && MACINTOSH_DRIVERS [=y] && ADB_PMU_LED [=y] && LEDS_CLASS [=y]
Fix this by making ADB_PMU_LED_DISK depend on ATA.
Seen on both PPC32 and PPC64.
--- drivers/macintosh/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/macintosh/Kconfig +1 -0
@@ -86,6 +86,7 @@ config ADB_PMU_LED config ADB_PMU_LED_DISK bool "Use front LED as DISK LED by default" + depends on ATA depends on ADB_PMU_LED depends on LEDS_CLASS select LEDS_TRIGGERS
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 285/371 powerpc/rtas: use memmove for potentially overlapping buffer copy
In reply to Greg Kroah-HartmanFrom: Nathan Lynch <[email protected]>
[ Upstream commit 271208ee5e335cb1ad280d22784940daf7ddf820 ]
Using memcpy() isn't safe when buf is identical to rtas_err_buf, which can happen during boot before slab is up. Full context which may not be obvious from the diff:
if (altbuf) {
buf = altbuf;
} else {
buf = rtas_err_buf;
if (slab_is_available())
buf = kmalloc(RTAS_ERROR_LOG_MAX, GFP_ATOMIC);
}
if (buf)
memcpy(buf, rtas_err_buf, RTAS_ERROR_LOG_MAX);This was found by inspection and I'm not aware of it causing problems in practice. It appears to have been introduced by commit 033ef338b6e0 ("powerpc: Merge rtas.c into arch/powerpc/kernel"); the old ppc64 version of this code did not have this problem.
Use memmove() instead.
--- arch/powerpc/kernel/rtas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/rtas.c +1 -1
@@ -415,7 +415,7 @@ static char *__fetch_rtas_last_error(char *altbuf) buf =kmalloc (RTAS_ERROR_LOG_MAX ,GFP_ATOMIC ); }if (buf) -memcpy (buf, rtas_err_buf,RTAS_ERROR_LOG_MAX ); +memmove (buf, rtas_err_buf,RTAS_ERROR_LOG_MAX ); }return buf;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 286/371 sched/fair: Use __schedstat_set() in set_next_entity()
In reply to Greg Kroah-HartmanFrom: Yafang Shao <[email protected]>
[ Upstream commit a2dcb276ff9287fcea103ca1a2436383e8583751 ]
schedstat_enabled() has been already checked, so we can use __schedstat_set() directly.
Stable-dep-of: 39afe5d6fc59 ("sched/fair: Fix inaccurate tally of ttwu_move_affine")
--- kernel/sched/fair.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/fair.c +3 -3
@@ -4691,9 +4691,9 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)*/ if (schedstat_enabled () &&rq_of (cfs_rq)->cfs.load.weight >=2 *se->load.weight) { -schedstat_set (se->statistics.slice_max, -max ((u64 )schedstat_val (se->statistics.slice_max), - se->sum_exec_runtime - se->prev_sum_exec_runtime)); +__schedstat_set (se->statistics.slice_max, +max ((u64 )se->statistics.slice_max, + se->sum_exec_runtime - se->prev_sum_exec_runtime)); } se->prev_sum_exec_runtime = se->sum_exec_runtime;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 287/371 sched: Make struct sched_statistics independent of fair sched class
In reply to Greg Kroah-HartmanFrom: Yafang Shao <[email protected]>
[ Upstream commit ceeadb83aea28372e54857bf88ab7e17af48ab7b ]
If we want to use the schedstats facility to trace other sched classes, we should make it independent of fair sched class. The struct sched_statistics is the schedular statistics of a task_struct or a task_group. So we can move it into struct task_struct and struct task_group to achieve the goal.
After the patch, schestats are orgnized as follows,
struct task_struct {
...
struct sched_entity se;
struct sched_rt_entity rt;
struct sched_dl_entity dl;
...
struct sched_statistics stats;
...};
Regarding the task group, schedstats is only supported for fair group sched, and a new struct sched_entity_stats is introduced, suggested by Peter -
struct sched_entity_stats {
struct sched_entity se;
struct sched_statistics stats;
} __no_randomize_layout;Then with the se in a task_group, we can easily get the stats.
The sched_statistics members may be frequently modified when schedstats is enabled, in order to avoid impacting on random data which may in the same cacheline with them, the struct sched_statistics is defined as cacheline aligned.
As this patch changes the core struct of scheduler, so I verified the performance it may impact on the scheduler with 'perf bench sched pipe', suggested by Mel. Below is the result, in which all the values are in usecs/op.
Before After
kernel.sched_schedstats=0 5.2~5.4 5.2~5.4
kernel.sched_schedstats=1 5.3~5.5 5.3~5.5[These data is a little difference with the earlier version, that is
because my old test machine is destroyed so I have to use a new different test machine.]
Almost no impact on the sched performance.
No functional change.
[[email protected]: reported build failure in earlier version]
Stable-dep-of: 39afe5d6fc59 ("sched/fair: Fix inaccurate tally of ttwu_move_affine")
--- include/linux/sched.h | 6 +-- kernel/sched/core.c | 25 ++++++----- kernel/sched/deadline.c | 4 +- kernel/sched/debug.c | 92 +++++++++++++++++++++------------------- kernel/sched/fair.c | 89 ++++++++++++++++++++++---------------- kernel/sched/rt.c | 4 +- kernel/sched/stats.h | 19 +++++++++ kernel/sched/stop_task.c | 4 +- 8 files changed, 143 insertions(+), 100 deletions(-)
include/linux/sched.h +3 -3
@@ -522,7 +522,7 @@ struct sched_statistics {u64 nr_wakeups_passive;u64 nr_wakeups_idle;#endif -}; +}____cacheline_aligned ;struct sched_entity {/* For load-balancing: */
@@ -538,8 +538,6 @@ struct sched_entity {u64 nr_migrations; -struct sched_statistics statistics; -#ifdef CONFIG_FAIR_GROUP_SCHED int depth;struct sched_entity *parent;
@@ -803,6 +801,8 @@ struct task_struct {struct uclamp_se uclamp[UCLAMP_CNT ];#endif +struct sched_statistics stats; +#ifdef CONFIG_PREEMPT_NOTIFIERS /* List of struct preempt_notifier: */ struct hlist_head preempt_notifiers;
kernel/sched/core.c +14 -11
@@ -3522,11 +3522,11 @@ ttwu_stat(struct task_struct *p, int cpu, int wake_flags)#ifdef CONFIG_SMP if (cpu == rq->cpu) {__schedstat_inc (rq->ttwu_local); -__schedstat_inc (p->se.statistics.nr_wakeups_local); +__schedstat_inc (p->stats.nr_wakeups_local); }else {struct sched_domain *sd; -__schedstat_inc (p->se.statistics.nr_wakeups_remote); +__schedstat_inc (p->stats.nr_wakeups_remote);rcu_read_lock ();for_each_domain (rq->cpu, sd) {if (cpumask_test_cpu (cpu,sched_domain_span (sd))) {
@@ -3538,14 +3538,14 @@ ttwu_stat(struct task_struct *p, int cpu, int wake_flags) }if (wake_flags &WF_MIGRATED ) -__schedstat_inc (p->se.statistics.nr_wakeups_migrate); +__schedstat_inc (p->stats.nr_wakeups_migrate);#endif /* CONFIG_SMP */ __schedstat_inc (rq->ttwu_count); -__schedstat_inc (p->se.statistics.nr_wakeups); +__schedstat_inc (p->stats.nr_wakeups);if (wake_flags &WF_SYNC ) -__schedstat_inc (p->se.statistics.nr_wakeups_sync); +__schedstat_inc (p->stats.nr_wakeups_sync); }/*
@@ -4241,7 +4241,7 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p)#ifdef CONFIG_SCHEDSTATS /* Even if schedstat is disabled, there should not be garbage */ -memset (&p->se.statistics,0 ,sizeof (p->se.statistics)); +memset (&p->stats,0 ,sizeof (p->stats));#endif RB_CLEAR_NODE (&p->dl.rb_node);
@@ -9706,9 +9706,9 @@ void normalize_rt_tasks(void)continue ; p->se.exec_start =0 ; -schedstat_set (p->se.statistics.wait_start,0 ); -schedstat_set (p->se.statistics.sleep_start,0 ); -schedstat_set (p->se.statistics.block_start,0 ); +schedstat_set (p->stats.wait_start,0 ); +schedstat_set (p->stats.sleep_start,0 ); +schedstat_set (p->stats.block_start,0 );if (!dl_task (p) && !rt_task (p)) {/*
@@ -10576,11 +10576,14 @@ static int cpu_cfs_stat_show(struct seq_file *sf, void *v)seq_printf (sf,"throttled_time %llu\n" , cfs_b->throttled_time);if (schedstat_enabled () && tg != &root_task_group) { +struct sched_statistics *stats;u64 ws =0 ;int i; -for_each_possible_cpu (i) - ws +=schedstat_val (tg->se[i]->statistics.wait_sum); +for_each_possible_cpu (i) { + stats =__schedstats_from_se (tg->se[i]); + ws +=schedstat_val (stats->wait_sum); + }seq_printf (sf,"wait_sum %llu\n" , ws); }
kernel/sched/deadline.c +2 -2
@@ -1265,8 +1265,8 @@ static void update_curr_dl(struct rq *rq)return ; } -schedstat_set (curr->se.statistics.exec_max, -max (curr->se.statistics.exec_max, delta_exec)); +schedstat_set (curr->stats.exec_max, +max (curr->stats.exec_max, delta_exec)); curr->se.sum_exec_runtime += delta_exec;account_group_exec_runtime (curr, delta_exec);
kernel/sched/debug.c +48 -44
130 lines not on this page · raw message
kernel/sched/fair.c +53 -36
220 lines not on this page · raw message
kernel/sched/rt.c +2 -2
@@ -1021,8 +1021,8 @@ static void update_curr_rt(struct rq *rq)if (unlikely ((s64 )delta_exec <=0 ))return ; -schedstat_set (curr->se.statistics.exec_max, -max (curr->se.statistics.exec_max, delta_exec)); +schedstat_set (curr->stats.exec_max, +max (curr->stats.exec_max, delta_exec)); curr->se.sum_exec_runtime += delta_exec;account_group_exec_runtime (curr, delta_exec);
kernel/sched/stats.h +19 -0
@@ -41,6 +41,7 @@ rq_sched_info_dequeue(struct rq *rq, unsigned long long delta)#define schedstat_val_or_zero (var) ((schedstat_enabled()) ? (var) : 0)#else /* !CONFIG_SCHEDSTATS: */ +static inline void rq_sched_info_arrive (struct rq *rq,unsigned long long delta) { }static inline void rq_sched_info_dequeue (struct rq *rq,unsigned long long delta) { }static inline void rq_sched_info_depart (struct rq *rq,unsigned long long delta) { }
@@ -53,8 +54,26 @@ static inline void rq_sched_info_depart (struct rq *rq, unsigned long long delt# define schedstat_set (var, val) do { } while (0)# define schedstat_val (var) 0# define schedstat_val_or_zero (var) 0 +#endif /* CONFIG_SCHEDSTATS */ +#ifdef CONFIG_FAIR_GROUP_SCHED +struct sched_entity_stats { +struct sched_entity se; +struct sched_statistics stats; +} __no_randomize_layout; +#endif + +static inline struct sched_statistics * +__schedstats_from_se (struct sched_entity *se) +{ +#ifdef CONFIG_FAIR_GROUP_SCHED +if (!entity_is_task (se)) + return &container_of(se, struct sched_entity_stats, se)->stats; +#endif +return &task_of (se)->stats; +} +#ifdef CONFIG_PSI /* * PSI tracks state that persists across sleeps, such as iowaits and
kernel/sched/stop_task.c +2 -2
@@ -78,8 +78,8 @@ static void put_prev_task_stop(struct rq *rq, struct task_struct *prev)if (unlikely ((s64 )delta_exec <0 )) delta_exec =0 ; -schedstat_set (curr->se.statistics.exec_max, -max (curr->se.statistics.exec_max, delta_exec)); +schedstat_set (curr->stats.exec_max, +max (curr->stats.exec_max, delta_exec)); curr->se.sum_exec_runtime += delta_exec;account_group_exec_runtime (curr, delta_exec);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 288/371 sched/fair: Fix inaccurate tally of ttwu_move_affine
In reply to Greg Kroah-HartmanFrom: Libo Chen <[email protected]>
[ Upstream commit 39afe5d6fc59237ff7738bf3ede5a8856822d59d ]
There are scenarios where non-affine wakeups are incorrectly counted as affine wakeups by schedstats.
When wake_affine_idle() returns prev_cpu which doesn't equal to nr_cpumask_bits, it will slip through the check: target == nr_cpumask_bits in wake_affine() and be counted as if target == this_cpu in schedstats.
Replace target == nr_cpumask_bits with target != this_cpu to make sure affine wakeups are accurately tallied.
--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
@@ -6207,7 +6207,7 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, target =wake_affine_weight (sd, p, this_cpu, prev_cpu, sync);schedstat_inc (p->stats.nr_wakeups_affine_attempts); -if (target == nr_cpumask_bits) +if (target != this_cpu)return prev_cpu;schedstat_inc (sd->ttwu_move_affine);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 289/371 perf/core: Fix hardlockup failure caused by perf throttle
In reply to Greg Kroah-HartmanFrom: Yang Jihong <[email protected]>
[ Upstream commit 15def34e2635ab7e0e96f1bc32e1b69609f14942 ]
commit e050e3f0a71bf ("perf: Fix broken interrupt rate throttling") introduces a change in throttling threshold judgment. Before this, compare hwc->interrupts and max_samples_per_tick, then increase hwc->interrupts by 1, but this commit reverses order of these two behaviors, causing the semantics of max_samples_per_tick to change. In literal sense of "max_samples_per_tick", if hwc->interrupts == max_samples_per_tick, it should not be throttled, therefore, the judgment condition should be changed to "hwc->interrupts > max_samples_per_tick".
In fact, this may cause the hardlockup to fail, The minimum value of max_samples_per_tick may be 1, in this case, the return value of __perf_event_account_interrupt function is 1.
As a result, nmi_watchdog gets throttled, which would stop PMU (Use x86 architecture as an example, see x86_pmu_handle_irq).
--- kernel/events/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/events/core.c +2 -2
@@ -9271,8 +9271,8 @@ __perf_event_account_interrupt(struct perf_event *event, int throttle) hwc->interrupts =1 ; }else { hwc->interrupts++; -if (unlikely (throttle - && hwc->interrupts >= max_samples_per_tick)) { +if (unlikely (throttle && + hwc->interrupts > max_samples_per_tick)) {__this_cpu_inc (perf_throttled_count);tick_dep_set_cpu (smp_processor_id (),TICK_DEP_BIT_PERF_EVENTS ); hwc->interrupts =MAX_INTERRUPTS ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 290/371 Revert "objtool: Support addition to set CFA base"
In reply to Greg Kroah-HartmanFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit e18398e80c73e3cc7d9c3d2e0bc06a4af8f4f1cb ]
Commit 468af56a7bba ("objtool: Support addition to set CFA base") was added as a preparatory patch for arm64 support, but that support never came. It triggers a false positive warning on x86, so just revert it for now.
Fixes the following warning:
vmlinux.o: warning: objtool: cdce925_regmap_i2c_write+0xdb: stack state mismatch: cfa1=4+120 cfa2=5+40
--- tools/objtool/check.c | 11 ----------- 1 file changed, 11 deletions(-)
tools/objtool/check.c +0 -11
@@ -2481,17 +2481,6 @@ static int update_cfi_state(struct instruction *insn,break ; } -if (!cfi->drap && op->src.reg ==CFI_SP && - op->dest.reg ==CFI_BP && cfa->base ==CFI_SP && -check_reg_frame_pos (®s[CFI_BP ], -cfa->offset + op->src.offset)) { - -/* lea disp(%rsp), %rbp */ - cfa->base =CFI_BP ; - cfa->offset -= op->src.offset; - cfi->bp_scratch = false; -break ; - } -if (op->src.reg ==CFI_SP && cfa->base ==CFI_SP ) {/* drap: lea disp(%rsp), %drap */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 291/371 sched/rt: Fix bad task migration for rt tasks
In reply to Greg Kroah-HartmanFrom: Schspa Shi <[email protected]>
[ Upstream commit feffe5bb274dd3442080ef0e4053746091878799 ]
Commit 95158a89dd50 ("sched,rt: Use the full cpumask for balancing") allows find_lock_lowest_rq() to pick a task with migration disabled. The purpose of the commit is to push the current running task on the CPU that has the migrate_disable() task away.
However, there is a race which allows a migrate_disable() task to be migrated. Consider:
CPU0 CPU1
push_rt_task
check is_migration_disabled(next_task)
task not running and
migration_disabled == 0
find_lock_lowest_rq(next_task, rq);
_double_lock_balance(this_rq, busiest);
raw_spin_rq_unlock(this_rq);
double_rq_lock(this_rq, busiest);
<<wait for busiest rq>>
<wakeup>
task become running
migrate_disable();
<context out>
deactivate_task(rq, next_task, 0);
set_task_cpu(next_task, lowest_rq->cpu);
WARN_ON_ONCE(is_migration_disabled(p));--- kernel/sched/deadline.c | 1 + kernel/sched/rt.c | 4 ++++ 2 files changed, 5 insertions(+)
kernel/sched/deadline.c +1 -0
@@ -2084,6 +2084,7 @@ static struct rq *find_lock_later_rq(struct task_struct *task, struct rq *rq) !cpumask_test_cpu(later_rq->cpu, &task->cpus_mask) || task_running(rq, task) || !dl_task(task) || + is_migration_disabled(task) || !task_on_rq_queued(task))) {double_unlock_balance (rq, later_rq); later_rq =NULL ;
kernel/sched/rt.c +4 -0
@@ -1842,11 +1842,15 @@ static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq)* the mean time, task could have * migrated already or had its affinity changed. * Also make sure that it wasn't scheduled on its rq. +* It is possible the task was scheduled, set +* "migrate_disabled" and then got preempted, so we must +* check the task migration disable flag here too. */ if (unlikely (task_rq (task) != rq || !cpumask_test_cpu (lowest_rq->cpu, &task->cpus_mask) ||task_running (rq, task) || !rt_task (task) || +is_migration_disabled (task) || !task_on_rq_queued (task))) {double_unlock_balance (rq, lowest_rq);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 292/371 clk: at91: clk-sam9x60-pll: fix return value check
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 1bd8e27fd0db0fe7f489213836dcbab92934f8fa ]
sam9x60_frac_pll_compute_mul_frac() can't return zero. Remove the check against zero to reflect this.
--- drivers/clk/at91/clk-sam9x60-pll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/at91/clk-sam9x60-pll.c +1 -1
@@ -561,7 +561,7 @@ sam9x60_clk_register_frac_pll(struct regmap *regmap, spinlock_t *lock, ret =sam9x60_frac_pll_compute_mul_frac (&frac->core,FCORE_MIN , parent_rate, true); -if (ret <=0 ) { +if (ret <0 ) { hw =ERR_PTR (ret); goto free; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 293/371 RDMA/siw: Fix potential page_array out of range access
In reply to Greg Kroah-HartmanFrom: Daniil Dulov <[email protected]>
[ Upstream commit 271bfcfb83a9f77cbae3d6e1a16e3c14132922f0 ]
When seg is equal to MAX_ARRAY, the loop should break, otherwise it will result in out of range access.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/sw/siw/siw_qp_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +1 -1
@@ -558,7 +558,7 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s) data_len -= plen; fp_off =0 ; -if (++seg > (int )MAX_ARRAY ) { +if (++seg >= (int )MAX_ARRAY ) {siw_dbg_qp (tx_qp (c_tx),"to many fragments\n" );siw_unmap_pages (iov, kmap_mask, seg-1 ); wqe->processed -= c_tx->bytes_unsent;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 294/371 RDMA/rdmavt: Delete unnecessary NULL check
In reply to Greg Kroah-HartmanFrom: Natalia Petrova <[email protected]>
[ Upstream commit b73a0b80c69de77d8d4942abb37066531c0169b2 ]
There is no need to check 'rdi->qp_dev' for NULL. The field 'qp_dev' is created in rvt_register_device() which will fail if the 'qp_dev' allocation fails in rvt_driver_qp_init(). Overwise this pointer doesn't changed and passed to rvt_qp_exit() by the next step.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/sw/rdmavt/qp.c | 2 -- 1 file changed, 2 deletions(-)
drivers/infiniband/sw/rdmavt/qp.c +0 -2
@@ -464,8 +464,6 @@ void rvt_qp_exit(struct rvt_dev_info *rdi)if (qps_inuse)rvt_pr_err (rdi,"QP memory leak! %u still in use\n" , qps_inuse); -if (!rdi->qp_dev) -return ;kfree (rdi->qp_dev->qp_table);free_qpn_table (&rdi->qp_dev->qpn_table);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 295/371 workqueue: Introduce show_one_worker_pool and show_one_workqueue.
In reply to Greg Kroah-HartmanFrom: Imran Khan <[email protected]>
[ Upstream commit 55df0933be74bd2e52aba0b67eb743ae0feabe7e ]
Currently show_workqueue_state shows the state of all workqueues and of all worker pools. In certain cases we may need to dump state of only a specific workqueue or worker pool. For example in destroy_workqueue we only need to show state of the workqueue which is getting destroyed.
So rename show_workqueue_state to show_all_workqueues(to signify it dumps state of all busy workqueues) and divide it into more granular functions (show_one_workqueue and show_one_worker_pool), that would show states of individual workqueues and worker pools and can be used in cases such as the one mentioned above.
Also, as mentioned earlier, make destroy_workqueue dump data pertaining to only the workqueue that is being destroyed and make user(s) of earlier interface(show_workqueue_state), use new interface (show_all_workqueues).
Stable-dep-of: 335a42ebb0ca ("workqueue: Fix hung time report of worker pools")
--- drivers/tty/sysrq.c | 2 +- include/linux/workqueue.h | 3 +- kernel/power/process.c | 2 +- kernel/workqueue.c | 172 +++++++++++++++++++++----------------- 4 files changed, 100 insertions(+), 79 deletions(-)
drivers/tty/sysrq.c +1 -1
@@ -301,7 +301,7 @@ static const struct sysrq_key_op sysrq_showregs_op = {static void sysrq_handle_showstate (int key) {show_state (); -show_workqueue_state (); +show_all_workqueues (); }static const struct sysrq_key_op sysrq_showstate_op = { .handler = sysrq_handle_showstate,
include/linux/workqueue.h +2 -1
@@ -469,7 +469,8 @@ extern bool workqueue_congested(int cpu, struct workqueue_struct *wq);extern unsigned int work_busy (struct work_struct *work); extern __printf(1, 2) void set_worker_desc(const char *fmt, ...); extern void print_worker_info(const char *log_lvl, struct task_struct *task); -extern void show_workqueue_state(void); +extern void show_all_workqueues(void); +extern void show_one_workqueue(struct workqueue_struct *wq); extern void wq_worker_comm(char *buf, size_t size, struct task_struct *task); /**
kernel/power/process.c +1 -1
@@ -94,7 +94,7 @@ static int try_to_freeze_tasks(bool user_only) todo - wq_busy, wq_busy);if (wq_busy) -show_workqueue_state (); +show_all_workqueues ();if (!wakeup || pm_debug_messages_on) {read_lock (&tasklist_lock);
kernel/workqueue.c +96 -76
213 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 296/371 workqueue: Fix hung time report of worker pools
In reply to Greg Kroah-HartmanFrom: Petr Mladek <[email protected]>
[ Upstream commit 335a42ebb0ca8ee9997a1731aaaae6dcd704c113 ]
The workqueue watchdog prints a warning when there is no progress in a worker pool. Where the progress means that the pool started processing a pending work item.
Note that it is perfectly fine to process work items much longer. The progress should be guaranteed by waking up or creating idle workers.
show_one_worker_pool() prints state of non-idle worker pool. It shows a delay since the last pool->watchdog_ts.
The timestamp is updated when a first pending work is queued in __queue_work(). Also it is updated when a work is dequeued for processing in worker_thread() and rescuer_thread().
The delay is misleading when there is no pending work item. In this case it shows how long the last work item is being proceed. Show zero instead. There is no stall if there is no pending work.
--- kernel/workqueue.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
kernel/workqueue.c +7 -3
@@ -4857,10 +4857,16 @@ static void show_one_worker_pool(struct worker_pool *pool)struct worker *worker;bool first = true;unsigned long flags; +unsigned long hung =0 ;raw_spin_lock_irqsave (&pool->lock, flags);if (pool->nr_workers == pool->nr_idle) goto next_pool; + +/* How long the first pending work is waiting for a worker. */ +if (!list_empty (&pool->worklist)) + hung =jiffies_to_msecs (jiffies - pool->watchdog_ts) /1000 ; +/* * Defer printing to avoid deadlocks in console drivers that * queue work while holding locks also taken in their write
@@ -4869,9 +4875,7 @@ static void show_one_worker_pool(struct worker_pool *pool)printk_deferred_enter ();pr_info ("pool %d:" , pool->id);pr_cont_pool_info (pool); -pr_cont (" hung=%us workers=%d" , -jiffies_to_msecs (jiffies - pool->watchdog_ts) /1000 , - pool->nr_workers); +pr_cont (" hung=%lus workers=%d" , hung, pool->nr_workers);if (pool->manager)pr_cont (" manager: %d" ,task_pid_nr (pool->manager->task));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 297/371 rtc: omap: include header for omap_rtc_power_off_program prototype
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit f69c2b5420497b7a54181ce170d682cbeb1f119f ]
Non-static functions should have a prototype:
drivers/rtc/rtc-omap.c:410:5: error: no previous prototype for ‘omap_rtc_power_off_program’ [-Werror=missing-prototypes]
--- drivers/rtc/rtc-omap.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-omap.c +1 -0
@@ -25,6 +25,7 @@#include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/rtc.h> +#include <linux/rtc/rtc-omap.h> /* * The OMAP RTC is a year/month/day/hours/minutes/seconds BCD clock
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 298/371 RDMA/mlx4: Prevent shift wrapping in set_user_sq_size()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit d50b3c73f1ac20dabc53dc6e9d64ce9c79a331eb ]
The ucmd->log_sq_bb_count variable is controlled by the user so this shift can wrap. Fix it by using check_shl_overflow() in the same way that it was done in commit 515f60004ed9 ("RDMA/hns: Prevent undefined behavior in hns_roce_set_user_sq_size()").
--- drivers/infiniband/hw/mlx4/qp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx4/qp.c +6 -2
@@ -412,9 +412,13 @@ static int set_user_sq_size(struct mlx4_ib_dev *dev,struct mlx4_ib_qp *qp, struct mlx4_ib_create_qp *ucmd) { + u32 cnt; +/* Sanity check SQ size before proceeding */ -if ((1 << ucmd->log_sq_bb_count) > dev->dev->caps.max_wqes || - ucmd->log_sq_stride > +if (check_shl_overflow (1 , ucmd->log_sq_bb_count, &cnt) || + cnt > dev->dev->caps.max_wqes) +return -EINVAL ; +if (ucmd->log_sq_stride >ilog2 (roundup_pow_of_two (dev->dev->caps.max_sq_desc_sz)) || ucmd->log_sq_stride <MLX4_IB_MIN_SQ_STRIDE )return -EINVAL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 299/371 rtc: meson-vrtc: Use ktime_get_real_ts64() to get the current time
In reply to Greg Kroah-HartmanFrom: Martin Blumenstingl <[email protected]>
[ Upstream commit 0e6255fa3f649170da6bd1a544680589cfae1131 ]
The VRTC alarm register can be programmed with an amount of seconds after which the SoC will be woken up by the VRTC timer again. We are already converting the alarm time from meson_vrtc_set_alarm() to "seconds since 1970". This means we also need to use "seconds since 1970" for the current time.
This fixes a problem where setting the alarm to one minute in the future results in the firmware (which handles wakeup) to output (on the serial console) that the system will be woken up in billions of seconds. ktime_get_raw_ts64() returns the time since boot, not since 1970. Switch to ktime_get_real_ts64() to fix the calculation of the alarm time and to make the SoC wake up at the specified date/time. Also the firmware (which manages suspend) now prints either 59 or 60 seconds until wakeup (depending on how long it takes for the system to enter suspend).
--- drivers/rtc/rtc-meson-vrtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-meson-vrtc.c +2 -2
@@ -23,7 +23,7 @@ static int meson_vrtc_read_time(struct device *dev, struct rtc_time *tm)struct timespec64 time;dev_dbg (dev,"%s\n" , __func__); -ktime_get_raw_ts64 (&time); +ktime_get_real_ts64 (&time);rtc_time64_to_tm (time.tv_sec, tm);return 0 ;
@@ -96,7 +96,7 @@ static int __maybe_unused meson_vrtc_suspend(struct device *dev)long alarm_secs;struct timespec64 time; -ktime_get_raw_ts64 (&time); +ktime_get_real_ts64 (&time); local_time = time.tv_sec; dev_dbg(dev, "alarm_time = %lus, local_time=%lus\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 300/371 fs/ntfs3: Fix memory leak if ntfs_read_mft failed
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit bfa434c60157c9793e9b12c9b68ade02aff9f803 ]
Label ATTR_ROOT in ntfs_read_mft() sets is_root = true and ni->ni_flags |= NI_FLAG_DIR, then next attr will goto label ATTR_ALLOC and alloc ni->dir.alloc_run. However two states are not always consistent and can make memory leak.
1) attr_name in ATTR_ROOT does not fit the condition it will set is_root = true but NI_FLAG_DIR is not set.
2) next attr_name in ATTR_ALLOC fits the condition and alloc ni->dir.alloc_run
3) in cleanup function ni_clear(), when NI_FLAG_DIR is set, it frees ni->dir.alloc_run, otherwise it frees ni->file.run
4) because NI_FLAG_DIR is not set in this case, ni->dir.alloc_run is leaked as kmemleak reported:
unreferenced object 0xffff888003bc5480 (size 64):
backtrace:
[<000000003d42e6b0>] __kmalloc_node+0x4e/0x1c0
[<00000000d8e19b8a>] kvmalloc_node+0x39/0x1f0
[<00000000fc3eb5b8>] run_add_entry+0x18a/0xa40 [ntfs3]
[<0000000011c9f978>] run_unpack+0x75d/0x8e0 [ntfs3]
[<00000000e7cf1819>] run_unpack_ex+0xbc/0x500 [ntfs3]
[<00000000bbf0a43d>] ntfs_iget5+0xb25/0x2dd0 [ntfs3]
[<00000000a6e50693>] ntfs_fill_super+0x218d/0x3580 [ntfs3]
[<00000000b9170608>] get_tree_bdev+0x3fb/0x710
[<000000004833798a>] vfs_get_tree+0x8e/0x280
[<000000006e20b8e6>] path_mount+0xf3c/0x1930
[<000000007bf15a5f>] do_mount+0xf3/0x110
...Fix this by always setting is_root and NI_FLAG_DIR together.
--- fs/ntfs3/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/inode.c +1 -1
@@ -257,7 +257,6 @@ static struct inode *ntfs_read_mft(struct inode *inode, goto out; root =Add2Ptr (attr, roff); - is_root = true;if (attr->name_len !=ARRAY_SIZE (I30_NAME ) ||memcmp (attr_name (attr),I30_NAME ,sizeof (I30_NAME )))
@@ -270,6 +269,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,if (!is_dir) goto next_attr; + is_root = true; ni->ni_flags |=NI_FLAG_DIR ; err =indx_init (&ni->dir, sbi, attr,INDEX_MUTEX_I30 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 301/371 fs/ntfs3: Add check for kmemdup
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit e6c3cef24cb0d045f99d5cb039b344874e3cfd74 ]
Since the kmemdup may return NULL pointer,
it should be better to add check for the return value in order to avoid NULL pointer dereference.
--- fs/ntfs3/fslog.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ntfs3/fslog.c +4 -0
@@ -4256,6 +4256,10 @@ int log_replay(struct ntfs_inode *ni, bool *initialized) rec_len -= t32; attr_names =kmemdup (Add2Ptr (lrh, t32), rec_len,GFP_NOFS ); +if (!attr_names) { + err = -ENOMEM ; + goto out; + }lcb_put (lcb); lcb =NULL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 302/371 fs/ntfs3: Fix null-ptr-deref on inode->i_op in ntfs_lookup()
In reply to Greg Kroah-HartmanFrom: ZhangPeng <[email protected]>
[ Upstream commit 254e69f284d7270e0abdc023ee53b71401c3ba0c ]
Syzbot reported a null-ptr-deref bug:
ntfs3: loop0: Different NTFS' sector size (1024) and media sector size
(512)
ntfs3: loop0: Mark volume as dirty due to NTFS errors
general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] RIP: 0010:d_flags_for_inode fs/dcache.c:1980 [inline] RIP: 0010:__d_add+0x5ce/0x800 fs/dcache.c:2796 Call Trace: <TASK> d_splice_alias+0x122/0x3b0 fs/dcache.c:3191 lookup_open fs/namei.c:3391 [inline] open_last_lookups fs/namei.c:3481 [inline] path_openat+0x10e6/0x2df0 fs/namei.c:3688 do_filp_open+0x264/0x4f0 fs/namei.c:3718 do_sys_openat2+0x124/0x4e0 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_open fs/open.c:1334 [inline] __se_sys_open fs/open.c:1330 [inline] __x64_sys_open+0x221/0x270 fs/open.c:1330 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd
If the MFT record of ntfs inode is not a base record, inode->i_op can be NULL. And a null-ptr-deref may happen:
ntfs_lookup()
dir_search_u() # inode->i_op is set to NULL
d_splice_alias()
__d_add()
d_flags_for_inode() # inode->i_op->get_link null-ptr-derefFix this by adding a Check on inode->i_op before calling the d_splice_alias() function.
--- fs/ntfs3/namei.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/ntfs3/namei.c +10 -0
@@ -86,6 +86,16 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,__putname (uni); } +/* +* Check for a null pointer +* If the MFT record of ntfs inode is not a base record, inode->i_op can be NULL. +* This causes null pointer dereference in d_splice_alias(). +*/ +if (!IS_ERR (inode) && inode->i_op ==NULL ) { +iput (inode); + inode =ERR_PTR (-EINVAL ); + } +return d_splice_alias (inode, dentry); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 303/371 fs/ntfs3: Fix OOB read in indx_insert_into_buffer
In reply to Greg Kroah-HartmanFrom: ZhangPeng <[email protected]>
[ Upstream commit b8c44949044e5f7f864525fdffe8e95135ce9ce5 ]
Syzbot reported a OOB read bug:
BUG: KASAN: slab-out-of-bounds in indx_insert_into_buffer+0xaa3/0x13b0 fs/ntfs3/index.c:1755 Read of size 17168 at addr ffff8880255e06c0 by task syz-executor308/3630 Call Trace: <TASK> memmove+0x25/0x60 mm/kasan/shadow.c:54 indx_insert_into_buffer+0xaa3/0x13b0 fs/ntfs3/index.c:1755 indx_insert_entry+0x446/0x6b0 fs/ntfs3/index.c:1863 ntfs_create_inode+0x1d3f/0x35c0 fs/ntfs3/inode.c:1548 ntfs_create+0x3e/0x60 fs/ntfs3/namei.c:100 lookup_open fs/namei.c:3413 [inline]
If the member struct INDEX_BUFFER *index of struct indx_node is incorrect, that is, the value of __le32 used is greater than the value of __le32 total in struct INDEX_HDR. Therefore, OOB read occurs when memmove is called in indx_insert_into_buffer().
Fix this by adding a check in hdr_find_e().
--- fs/ntfs3/index.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ntfs3/index.c +4 -0
@@ -679,9 +679,13 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,u32 e_size, e_key_len;u32 end =le32_to_cpu (hdr->used);u32 off =le32_to_cpu (hdr->de_off); +u32 total =le32_to_cpu (hdr->total);u16 offs[128 ]; fill_table: +if (end > total) +return NULL ; +if (off +sizeof (struct NTFS_DE ) > end)return NULL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 304/371 fs/ntfs3: Fix slab-out-of-bounds read in hdr_delete_de()
In reply to Greg Kroah-HartmanFrom: Zeng Heng <[email protected]>
[ Upstream commit ab84eee4c7ab929996602eda7832854c35a6dda2 ]
Here is a BUG report from syzbot:
BUG: KASAN: slab-out-of-bounds in hdr_delete_de+0xe0/0x150 fs/ntfs3/index.c:806 Read of size 16842960 at addr ffff888079cc0600 by task syz-executor934/3631 Call Trace: memmove+0x25/0x60 mm/kasan/shadow.c:54 hdr_delete_de+0xe0/0x150 fs/ntfs3/index.c:806 indx_delete_entry+0x74f/0x3670 fs/ntfs3/index.c:2193 ni_remove_name+0x27a/0x980 fs/ntfs3/frecord.c:2910 ntfs_unlink_inode+0x3d4/0x720 fs/ntfs3/inode.c:1712 ntfs_rename+0x41a/0xcb0 fs/ntfs3/namei.c:276
Before using the meta-data in struct INDEX_HDR, we need to check index header valid or not. Otherwise, the corruptedi (or malicious) fs image can cause out-of-bounds access which could make kernel panic.
--- fs/ntfs3/fslog.c | 2 +- fs/ntfs3/index.c | 4 ++++ fs/ntfs3/ntfs_fs.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-)
fs/ntfs3/fslog.c +1 -1
@@ -2575,7 +2575,7 @@ static int read_next_log_rec(struct ntfs_log *log, struct lcb *lcb, u64 *lsn)return find_log_rec (log, *lsn, lcb); } -static inline bool check_index_header (const struct INDEX_HDR *hdr,size_t bytes) +bool check_index_header (const struct INDEX_HDR *hdr,size_t bytes) {__le16 mask;u32 min_de, de_off, used, total;
fs/ntfs3/index.c +4 -0
@@ -802,6 +802,10 @@ static inline struct NTFS_DE *hdr_delete_de(struct INDEX_HDR *hdr,u32 off =PtrOffset (hdr, re);int bytes = used - (off + esize); +/* check INDEX_HDR valid before using INDEX_HDR */ +if (!check_index_header (hdr,le32_to_cpu (hdr->total))) +return NULL ; +if (off >= used || esize <sizeof (struct NTFS_DE ) || bytes <sizeof (struct NTFS_DE ))return NULL ;
fs/ntfs3/ntfs_fs.h +1 -0
@@ -575,6 +575,7 @@ int ni_rename(struct ntfs_inode *dir_ni, struct ntfs_inode *new_dir_ni,bool ni_is_dirty (struct inode *inode);/* Globals from fslog.c */ +bool check_index_header (const struct INDEX_HDR *hdr,size_t bytes);int log_replay (struct ntfs_inode *ni,bool *initialized);/* Globals from fsntfs.c */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 305/371 power: supply: generic-adc-battery: fix unit scaling
In reply to Greg Kroah-HartmanFrom: Sebastian Reichel <[email protected]>
[ Upstream commit 44263f50065969f2344808388bd589740f026167 ]
power-supply properties are reported in µV, µA and µW. The IIO API provides mV, mA, mW, so the values need to be multiplied by 1000.
--- drivers/power/supply/generic-adc-battery.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/power/supply/generic-adc-battery.c +3 -0
@@ -135,6 +135,9 @@ static int read_channel(struct gab *adc_bat, enum power_supply_property psp, result);if (ret <0 )pr_err ("read channel error\n" ); +else + *result *=1000 ; +return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 306/371 clk: add missing of_node_put() in "assigned-clocks" property parsing
In reply to Greg Kroah-HartmanFrom: Clément Léger <[email protected]>
[ Upstream commit 27a6e1b09a782517fddac91259970ac466a3f7b6 ]
When returning from of_parse_phandle_with_args(), the np member of the of_phandle_args structure should be put after usage. Add missing of_node_put() calls in both __set_clk_parents() and __set_clk_rates().
--- drivers/clk/clk-conf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/clk/clk-conf.c +10 -2
@@ -33,9 +33,12 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)else return rc; } -if (clkspec.np == node && !clk_supplier) +if (clkspec.np == node && !clk_supplier) { +of_node_put (clkspec.np);return 0 ; + } pclk =of_clk_get_from_provider (&clkspec); +of_node_put (clkspec.np);if (IS_ERR (pclk)) {if (PTR_ERR (pclk) != -EPROBE_DEFER ) pr_warn("clk: couldn't get parent clock %d for %pOF\n",
@@ -48,10 +51,12 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)if (rc <0 ) goto err;if (clkspec.np == node && !clk_supplier) { +of_node_put (clkspec.np); rc =0 ; goto err; } clk =of_clk_get_from_provider (&clkspec); +of_node_put (clkspec.np);if (IS_ERR (clk)) {if (PTR_ERR (clk) != -EPROBE_DEFER ) pr_warn("clk: couldn't get assigned clock %d for %pOF\n",
@@ -93,10 +98,13 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)else return rc; } -if (clkspec.np == node && !clk_supplier) +if (clkspec.np == node && !clk_supplier) { +of_node_put (clkspec.np);return 0 ; + } clk =of_clk_get_from_provider (&clkspec); +of_node_put (clkspec.np);if (IS_ERR (clk)) {if (PTR_ERR (clk) != -EPROBE_DEFER ) pr_warn("clk: couldn't get clock %d for %pOF\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 307/371 RDMA/siw: Remove namespace check from siw_netdev_event()
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
[ Upstream commit 266e9b3475ba82212062771fdbc40be0e3c06ec8 ]
syzbot is reporting that siw_netdev_event(NETDEV_UNREGISTER) cannot destroy siw_device created after unshare(CLONE_NEWNET) due to net namespace check. It seems that this check was by error there and should be removed.
--- drivers/infiniband/sw/siw/siw_main.c | 3 --- 1 file changed, 3 deletions(-)
drivers/infiniband/sw/siw/siw_main.c +0 -3
@@ -437,9 +437,6 @@ static int siw_netdev_event(struct notifier_block *nb, unsigned long event,dev_dbg (&netdev->dev,"siw: event %lu\n" , event); -if (dev_net (netdev) != &init_net) -return NOTIFY_OK ; - base_dev =ib_device_get_by_netdev (netdev,RDMA_DRIVER_SIW );if (!base_dev)return NOTIFY_OK ;
Signature · 1 line
2.39.2