6.1.28-rc1 review
Subsystems (10)
Greg Kroah-Hartman
maintainerPATCH 267/611 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 268/611 wifi: ath11k: Use platform_get_irq() to get the interrupt
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit f117276638b7600b981b3fe28550823cfbe1ef23 ]
As of commit a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core"), we need to use platform_get_irq() instead of platform_get_resource() to get our IRQs because platform_get_resource() simply won't get them anymore.
This was already fixed in several other Atheros WiFi drivers, apparently in response to Zeal Robot reports. An example of another fix is commit 9503a1fc123d ("ath9k: Use platform_get_irq() to get the interrupt"). ath11k seems to have been missed in this effort, though.
Without this change, WiFi wasn't coming up on my Qualcomm sc7280-based hardware. Specifically, "platform_get_resource(pdev, IORESOURCE_IRQ, i)" was failing even for i=0.
Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.1.0.1-00887-QCAMSLSWPLZ-1
--- drivers/net/wireless/ath/ath11k/ahb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath11k/ahb.c +4 -4
@@ -859,11 +859,11 @@ static int ath11k_ahb_setup_msi_resources(struct ath11k_base *ab) ab->pci.msi.ep_base_data = int_prop +32 ;for (i =0 ; i < ab->pci.msi.config->total_vectors; i++) { - res =platform_get_resource (pdev,IORESOURCE_IRQ , i); -if (!res) -return -ENODEV ; + ret =platform_get_irq (pdev, i); +if (ret <0 ) +return ret; - ab->pci.msi.irqs[i] = res->start; + ab->pci.msi.irqs[i] = ret; }set_bit (ATH11K_FLAG_MULTI_MSI_VECTORS , &ab->dev_flags);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 269/611 wifi: ath5k: Use platform_get_irq() to get the interrupt
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit 95c95251d0547b46d6571e4fbd51b42865c15a4a ]
As of commit a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core"), we need to use platform_get_irq() instead of platform_get_resource() to get our IRQs because platform_get_resource() simply won't get them anymore.
This was already fixed in several other Atheros WiFi drivers, apparently in response to Zeal Robot reports. An example of another fix is commit 9503a1fc123d ("ath9k: Use platform_get_irq() to get the interrupt"). ath5k seems to have been missed in this effort, though.
--- drivers/net/wireless/ath/ath5k/ahb.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath5k/ahb.c +4 -6
@@ -113,15 +113,13 @@ static int ath_ahb_probe(struct platform_device *pdev) goto err_out; } - res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); -if (res ==NULL ) { -dev_err (&pdev->dev,"no IRQ resource found\n" ); - ret = -ENXIO ; + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { +dev_err (&pdev->dev,"no IRQ resource found: %d\n" , irq); + ret = irq; goto err_iounmap; } - irq = res->start; - hw =ieee80211_alloc_hw (sizeof (struct ath5k_hw ), &ath5k_hw_ops);if (hw ==NULL ) {dev_err (&pdev->dev,"no memory for ieee80211_hw\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 270/611 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 271/611 wifi: ath11k: fix SAC bug on peer addition with sta band migration
In reply to Greg Kroah-HartmanFrom: Christian Marangi <[email protected]>
[ Upstream commit 60b7d62ba8cdbd073997bff0f1cdae8d844002c0 ]
Fix sleep in atomic context warning detected by Smatch static checker analyzer.
Following the locking pattern for peer_rhash_add lock tbl_mtx_lock mutex always even if sta is not transitioning to another band. This is peer_add function and a more secure locking should not cause performance regression.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-01208-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/peer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/peer.c +3 -2
@@ -382,22 +382,23 @@ int ath11k_peer_create(struct ath11k *ar, struct ath11k_vif *arvif,return -ENOBUFS ; } +mutex_lock (&ar->ab->tbl_mtx_lock);spin_lock_bh (&ar->ab->base_lock); peer =ath11k_peer_find_by_addr (ar->ab, param->peer_addr);if (peer) {if (peer->vdev_id == param->vdev_id) {spin_unlock_bh (&ar->ab->base_lock); +mutex_unlock (&ar->ab->tbl_mtx_lock);return -EINVAL ; }/* Assume sta is transitioning to another band. * Remove here the peer from rhash. */ -mutex_lock (&ar->ab->tbl_mtx_lock);ath11k_peer_rhash_delete (ar->ab, peer); -mutex_unlock (&ar->ab->tbl_mtx_lock); }spin_unlock_bh (&ar->ab->base_lock); +mutex_unlock (&ar->ab->tbl_mtx_lock); ret =ath11k_wmi_send_peer_create_cmd (ar, param);if (ret) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 272/611 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
@@ -6210,18 +6210,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 273/611 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 274/611 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 275/611 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 276/611 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;if (pwr_on)set_bit (RTW_FLAG_POWERON , rtwdev->flags);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 277/611 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
@@ -11908,7 +11908,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);
@@ -11922,7 +11923,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 278/611 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
@@ -11912,7 +11912,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;
@@ -11928,7 +11928,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 279/611 crypto: qat - fix concurrency issue when device state changes
In reply to Greg Kroah-HartmanFrom: Shashank Gupta <[email protected]>
[ Upstream commit 1bdc85550a2b59bb7f62ead7173134e66dd2d60e ]
The sysfs state attribute is not protected against race conditions. If multiple processes perform a device state transition on the same device in parallel, unexpected behaviors might occur.
For transitioning the device state, adf_sysfs.c calls the functions adf_dev_init(), adf_dev_start(), adf_dev_stop() and adf_dev_shutdown() which are unprotected and interdependent on each other. To perform a state transition, these functions needs to be called in a specific order:
* device up: adf_dev_init() -> adf_dev_start()
* device down: adf_dev_stop() -> adf_dev_shutdown()
This change introduces the functions adf_dev_up() and adf_dev_down() which wrap the state machine functions and protect them with a per-device lock. These are then used in adf_sysfs.c instead of the individual state transition functions.
--- .../crypto/qat/qat_common/adf_accel_devices.h | 1 + .../crypto/qat/qat_common/adf_common_drv.h | 3 + drivers/crypto/qat/qat_common/adf_dev_mgr.c | 2 + drivers/crypto/qat/qat_common/adf_init.c | 64 +++++++++++++++++++ drivers/crypto/qat/qat_common/adf_sysfs.c | 23 +------ 5 files changed, 73 insertions(+), 20 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -0
@@ -296,6 +296,7 @@ struct adf_accel_dev {u8 pf_compat_ver; } vf; }; +struct mutex state_lock;/* protect state of the device */ bool is_vf;u32 accel_id; };
drivers/crypto/qat/qat_common/adf_common_drv.h +3 -0
@@ -58,6 +58,9 @@ void adf_dev_stop(struct adf_accel_dev *accel_dev);void adf_dev_shutdown (struct adf_accel_dev *accel_dev);int adf_dev_shutdown_cache_cfg (struct adf_accel_dev *accel_dev); +int adf_dev_up (struct adf_accel_dev *accel_dev,bool init_config); +int adf_dev_down (struct adf_accel_dev *accel_dev,bool cache_config); +void adf_devmgr_update_class_index (struct adf_hw_device_data *hw_data);void adf_clean_vf_map (bool );
drivers/crypto/qat/qat_common/adf_dev_mgr.c +2 -0
@@ -223,6 +223,7 @@ int adf_devmgr_add_dev(struct adf_accel_dev *accel_dev, map->attached = true;list_add_tail (&map->list, &vfs_table); } +mutex_init (&accel_dev->state_lock); unlock:mutex_unlock (&table_lock);return ret;
@@ -269,6 +270,7 @@ void adf_devmgr_rm_dev(struct adf_accel_dev *accel_dev, } } unlock: +mutex_destroy (&accel_dev->state_lock);list_del (&accel_dev->list);mutex_unlock (&table_lock); }
drivers/crypto/qat/qat_common/adf_init.c +64 -0
67 lines not on this page · raw message
drivers/crypto/qat/qat_common/adf_sysfs.c +3 -20
@@ -50,38 +50,21 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr,switch (ret) {case DEV_DOWN : -if (!adf_dev_started (accel_dev)) { -dev_info (dev,"Device qat_dev%d already down\n" , - accel_id); -return -EINVAL ; - } -dev_info (dev,"Stopping device qat_dev%d\n" , accel_id); - ret =adf_dev_shutdown_cache_cfg (accel_dev); + ret =adf_dev_down (accel_dev, true);if (ret <0 )return -EINVAL ;break ;case DEV_UP : -if (adf_dev_started (accel_dev)) { -dev_info (dev,"Device qat_dev%d already up\n" , - accel_id); -return -EINVAL ; - } -dev_info (dev,"Starting device qat_dev%d\n" , accel_id); - ret =GET_HW_DATA (accel_dev)->dev_config (accel_dev); -if (!ret) - ret =adf_dev_init (accel_dev); -if (!ret) - ret =adf_dev_start (accel_dev); - + ret =adf_dev_up (accel_dev, true);if (ret <0 ) {dev_err (dev,"Failed to start device qat_dev%d\n" , accel_id); -adf_dev_shutdown_cache_cfg (accel_dev); +adf_dev_down (accel_dev, true);return ret; }break ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 280/611 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 281/611 wifi: ath11k: fix deinitialization of firmware resources
In reply to Greg Kroah-HartmanFrom: Aditya Kumar Singh <[email protected]>
[ Upstream commit 5a78ac33e3cb8822da64dd1af196e83664b332b0 ]
Currently, in ath11k_ahb_fw_resources_init(), iommu domain mapping is done only for the chipsets having fixed firmware memory. Also, for such chipsets, mapping is done only if it does not have TrustZone support.
During deinitialization, only if TrustZone support is not there, iommu is unmapped back. However, for non fixed firmware memory chipsets, TrustZone support is not there and this makes the condition check to true and it tries to unmap the memory which was not mapped during initialization.
This leads to the following trace -
[ 83.198790] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 [ 83.259537] Modules linked in: ath11k_ahb ath11k qmi_helpers .. snip .. [ 83.280286] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 83.287228] pc : __iommu_unmap+0x30/0x140 [ 83.293907] lr : iommu_unmap+0x5c/0xa4 [ 83.298072] sp : ffff80000b3abad0 .. snip .. [ 83.369175] Call trace: [ 83.376282] __iommu_unmap+0x30/0x140 [ 83.378541] iommu_unmap+0x5c/0xa4 [ 83.382360] ath11k_ahb_fw_resource_deinit.part.12+0x2c/0xac [ath11k_ahb] [ 83.385666] ath11k_ahb_free_resources+0x140/0x17c [ath11k_ahb] [ 83.392521] ath11k_ahb_shutdown+0x34/0x40 [ath11k_ahb] [ 83.398248] platform_shutdown+0x20/0x2c [ 83.403455] device_shutdown+0x16c/0x1c4 [ 83.407621] kernel_restart_prepare+0x34/0x3c [ 83.411529] kernel_restart+0x14/0x74 [ 83.415781] __do_sys_reboot+0x1c4/0x22c [ 83.419427] __arm64_sys_reboot+0x1c/0x24 [ 83.423420] invoke_syscall+0x44/0xfc [ 83.427326] el0_svc_common.constprop.3+0xac/0xe8 [ 83.430974] do_el0_svc+0xa0/0xa8 [ 83.435659] el0_svc+0x1c/0x44 [ 83.438957] el0t_64_sync_handler+0x60/0x144 [ 83.441910] el0t_64_sync+0x15c/0x160 [ 83.446343] Code: aa0103f4 f9400001 f90027a1 d2800001 (f94006a0) [ 83.449903] ---[ end trace 0000000000000000 ]---
This can be reproduced by probing an AHB chipset which is not having a fixed memory region. During reboot (or rmmod) trace can be seen.
Fix this issue by adding a condition check on firmware fixed memory hw_param as done in the counter initialization function.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/ahb.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/ath/ath11k/ahb.c +6 -0
@@ -1063,6 +1063,12 @@ static int ath11k_ahb_fw_resource_deinit(struct ath11k_base *ab)struct iommu_domain *iommu;size_t unmapped_size; +/* Chipsets not requiring MSA would have not initialized +* MSA resources, return success in such cases. +*/ +if (!ab->hw_params.fixed_fw_mem) +return 0 ; +if (ab_ahb->fw.use_tz)return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 282/611 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
@@ -95,7 +95,7 @@ static int __start_server(int type, int protocol, 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 283/611 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
@@ -3518,17 +3518,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 284/611 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
@@ -329,7 +329,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;
@@ -341,15 +341,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; }
@@ -943,7 +934,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 285/611 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 286/611 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
@@ -307,7 +307,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)
@@ -2866,7 +2867,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);
@@ -3069,7 +3071,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);
@@ -4006,7 +4009,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 287/611 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
@@ -2185,7 +2185,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;
@@ -2460,7 +2460,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;
@@ -3913,9 +3913,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 :
@@ -4064,7 +4062,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 288/611 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
@@ -3515,7 +3515,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 ;
@@ -3899,9 +3899,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 :
@@ -4059,7 +4057,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 289/611 libbpf: Fix ld_imm64 copy logic for ksym in light skeleton.
In reply to Greg Kroah-HartmanFrom: Alexei Starovoitov <[email protected]>
[ Upstream commit a506d6ce1dd184051037dc9d26c3eb187c9fe625 ]
Unlike normal libbpf the light skeleton 'loader' program is doing btf_find_by_name_kind() call at run-time to find ksym in the kernel and populate its {btf_id, btf_obj_fd} pair in ld_imm64 insn. To avoid doing the search multiple times for the same ksym it remembers the first patched ld_imm64 insn and copies {btf_id, btf_obj_fd} from it into subsequent ld_imm64 insn. Fix a bug in copying logic, since it may incorrectly clear BPF_PSEUDO_BTF_ID flag.
Also replace always true if (btf_obj_fd >= 0) check with unconditional JMP_JA to clarify the code.
--- tools/lib/bpf/gen_loader.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
tools/lib/bpf/gen_loader.c +6 -4
@@ -804,11 +804,13 @@ static void emit_relo_ksym_btf(struct bpf_gen *gen, struct ksym_relo_desc *relo,return ;/* try to copy from existing ldimm64 insn */ if (kdesc->ref >1 ) { -move_blob2blob (gen, insn + offsetof(struct bpf_insn , imm),4 , - kdesc->insn + offsetof(struct bpf_insn , imm));move_blob2blob (gen, insn +sizeof (struct bpf_insn ) + offsetof(struct bpf_insn , imm),4 , kdesc->insn +sizeof (struct bpf_insn ) + offsetof(struct bpf_insn , imm)); -/* jump over src_reg adjustment if imm is not 0, reuse BPF_REG_0 from move_blob2blob */ +move_blob2blob (gen, insn + offsetof(struct bpf_insn , imm),4 , + kdesc->insn + offsetof(struct bpf_insn , imm)); +/* jump over src_reg adjustment if imm (btf_id) is not 0, reuse BPF_REG_0 from move_blob2blob +* If btf_id is zero, clear BPF_PSEUDO_BTF_ID flag in src_reg of ld_imm64 insn +*/ emit (gen,BPF_JMP_IMM (BPF_JNE ,BPF_REG_0 ,0 ,3 )); goto clear_src_reg; }
@@ -831,7 +833,7 @@ static void emit_relo_ksym_btf(struct bpf_gen *gen, struct ksym_relo_desc *relo,emit (gen,BPF_STX_MEM (BPF_W ,BPF_REG_8 ,BPF_REG_7 ,sizeof (struct bpf_insn ) + offsetof(struct bpf_insn , imm)));/* skip src_reg adjustment */ -emit (gen,BPF_JMP_IMM (BPF_JSGE ,BPF_REG_7 ,0 ,3 )); +emit (gen,BPF_JMP_IMM (BPF_JA ,0 ,0 ,3 )); clear_src_reg:/* clear bpf_object__relocate_data's src_reg assignment, otherwise we get a verifier failure */ reg_mask =src_reg_mask ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 290/611 net: dsa: qca8k: remove assignment of an_enabled in pcs_get_state()
In reply to Greg Kroah-HartmanFrom: Russell King (Oracle) <[email protected]>
[ Upstream commit 9ef70d0130f282638b28cfce24222f71ada00c9c ]
pcs_get_state() implementations are not supposed to alter an_enabled. Remove this assignment.
--- drivers/net/dsa/qca/qca8k-8xxx.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/dsa/qca/qca8k-8xxx.c +0 -1
@@ -1365,7 +1365,6 @@ static void qca8k_pcs_get_state(struct phylink_pcs *pcs, state->link = !!(reg &QCA8K_PORT_STATUS_LINK_UP ); state->an_complete = state->link; - state->an_enabled = !!(reg &QCA8K_PORT_STATUS_LINK_AUTO ); state->duplex = (reg &QCA8K_PORT_STATUS_DUPLEX ) ?DUPLEX_FULL :DUPLEX_HALF ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 291/611 netfilter: keep conntrack reference until IPsecv6 policy checks are done
In reply to Greg Kroah-HartmanFrom: Madhu Koriginja <[email protected]>
[ Upstream commit b0e214d212030fe497d4d150bb3474e50ad5d093 ]
Keep the conntrack reference until policy checks have been performed for IPsec V6 NAT support, just like ipv4.
The reference needs to be dropped before a packet is queued to avoid having the conntrack module unloadable.
--- net/dccp/ipv6.c | 1 + net/ipv6/ip6_input.c | 14 ++++++-------- net/ipv6/raw.c | 5 ++--- net/ipv6/tcp_ipv6.c | 2 ++ net/ipv6/udp.c | 2 ++ 5 files changed, 13 insertions(+), 11 deletions(-)
net/dccp/ipv6.c +1 -0
@@ -783,6 +783,7 @@ static int dccp_v6_rcv(struct sk_buff *skb)if (!xfrm6_policy_check (sk,XFRM_POLICY_IN , skb)) goto discard_and_relse; +nf_reset_ct (skb);return __sk_receive_skb (sk, skb,1 , dh->dccph_doff *4 , refcounted) ?-1 :0 ;
net/ipv6/ip6_input.c +6 -8
@@ -404,10 +404,6 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,/* Only do this once for first final protocol */ have_final = true; -/* Free reference early: we don't need it any more, -and it may hold ip_conntrack module loaded -indefinitely. */ -nf_reset_ct (skb);skb_postpull_rcsum (skb,skb_network_header (skb),skb_network_header_len (skb));
@@ -430,10 +426,12 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr, goto discard; } } -if (!(ipprot->flags &INET6_PROTO_NOPOLICY ) && - !xfrm6_policy_check (NULL ,XFRM_POLICY_IN , skb)) { -SKB_DR_SET (reason,XFRM_POLICY ); - goto discard; +if (!(ipprot->flags &INET6_PROTO_NOPOLICY )) { +if (!xfrm6_policy_check (NULL ,XFRM_POLICY_IN , skb)) { +SKB_DR_SET (reason,XFRM_POLICY ); + goto discard; + } +nf_reset_ct (skb); } ret = INDIRECT_CALL_2(ipprot->handler, tcp_v6_rcv, udpv6_rcv,
net/ipv6/raw.c +2 -3
@@ -193,10 +193,8 @@ static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)struct sk_buff *clone =skb_clone (skb,GFP_ATOMIC );/* Not releasing hash table! */ -if (clone) { -nf_reset_ct (clone); +if (clone)rawv6_rcv (sk, clone); - } } }rcu_read_unlock ();
@@ -387,6 +385,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)kfree_skb (skb);return NET_RX_DROP ; } +nf_reset_ct (skb);if (!rp->checksum) skb->ip_summed =CHECKSUM_UNNECESSARY ;
net/ipv6/tcp_ipv6.c +2 -0
@@ -1722,6 +1722,8 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)if (drop_reason) goto discard_and_relse; +nf_reset_ct (skb); +if (tcp_filter (sk, skb)) { drop_reason =SKB_DROP_REASON_SOCKET_FILTER ; goto discard_and_relse;
net/ipv6/udp.c +2 -0
@@ -701,6 +701,7 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) drop_reason =SKB_DROP_REASON_XFRM_POLICY ; goto drop; } +nf_reset_ct (skb);if (static_branch_unlikely (&udpv6_encap_needed_key) && up->encap_type) {int (*encap_rcv)(struct sock *sk,struct sk_buff *skb);
@@ -1024,6 +1025,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,if (!xfrm6_policy_check (NULL ,XFRM_POLICY_IN , skb)) goto discard; +nf_reset_ct (skb);if (udp_lib_checksum_complete (skb)) goto csum_error;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 292/611 bpf: Fix __reg_bound_offset 64->32 var_off subreg propagation
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
[ Upstream commit 7be14c1c9030f73cc18b4ff23b78a0a081f16188 ]
Xu reports that after commit 3f50f132d840 ("bpf: Verifier, do explicit ALU32 bounds tracking"), the following BPF program is rejected by the verifier:
0: (61) r2 = *(u32 *)(r1 +0) ; R2_w=pkt(off=0,r=0,imm=0)
1: (61) r3 = *(u32 *)(r1 +4) ; R3_w=pkt_end(off=0,imm=0)
2: (bf) r1 = r2
3: (07) r1 += 1
4: (2d) if r1 > r3 goto pc+8
5: (71) r1 = *(u8 *)(r2 +0) ; R1_w=scalar(umax=255,var_off=(0x0; 0xff))
6: (18) r0 = 0x7fffffffffffff10
8: (0f) r1 += r0 ; R1_w=scalar(umin=0x7fffffffffffff10,umax=0x800000000000000f)
9: (18) r0 = 0x8000000000000000
11: (07) r0 += 1
12: (ad) if r0 < r1 goto pc-2
13: (b7) r0 = 0
14: (95) exit
And the verifier log says:
func#0 @0
0: R1=ctx(off=0,imm=0) R10=fp0
0: (61) r2 = *(u32 *)(r1 +0) ; R1=ctx(off=0,imm=0) R2_w=pkt(off=0,r=0,imm=0) 1: (61) r3 = *(u32 *)(r1 +4) ; R1=ctx(off=0,imm=0) R3_w=pkt_end(off=0,imm=0) 2: (bf) r1 = r2 ; R1_w=pkt(off=0,r=0,imm=0) R2_w=pkt(off=0,r=0,imm=0) 3: (07) r1 += 1 ; R1_w=pkt(off=1,r=0,imm=0) 4: (2d) if r1 > r3 goto pc+8 ; R1_w=pkt(off=1,r=1,imm=0) R3_w=pkt_end(off=0,imm=0) 5: (71) r1 = *(u8 *)(r2 +0) ; R1_w=scalar(umax=255,var_off=(0x0; 0xff)) R2_w=pkt(off=0,r=1,imm=0) 6: (18) r0 = 0x7fffffffffffff10 ; R0_w=9223372036854775568 8: (0f) r1 += r0 ; R0_w=9223372036854775568 R1_w=scalar(umin=9223372036854775568,umax=9223372036854775823,s32_min=-240,s32_max=15) 9: (18) r0 = 0x8000000000000000 ; R0_w=-9223372036854775808 11: (07) r0 += 1 ; R0_w=-9223372036854775807 12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775807 R1_w=scalar(umin=9223372036854775568,umax=9223372036854775809) 13: (b7) r0 = 0 ; R0_w=0
14: (95) exit
from 12 to 11: R0_w=-9223372036854775807 R1_w=scalar(umin=9223372036854775810,umax=9223372036854775823,var_off=(0x8000000000000000; 0xffffffff)) R2_w=pkt(off=0,r=1,imm=0) R3_w=pkt_end(off=0,imm=0) R10=fp0
11: (07) r0 += 1 ; R0_w=-9223372036854775806
12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775806 R1_w=scalar(umin=9223372036854775810,umax=9223372036854775810,var_off=(0x8000000000000000; 0xffffffff))
13: safe
[...]
from 12 to 11: R0_w=-9223372036854775795 R1=scalar(umin=9223372036854775822,umax=9223372036854775823,var_off=(0x8000000000000000; 0xffffffff)) R2=pkt(off=0,r=1,imm=0) R3=pkt_end(off=0,imm=0) R10=fp0
11: (07) r0 += 1 ; R0_w=-9223372036854775794
12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775794 R1=scalar(umin=9223372036854775822,umax=9223372036854775822,var_off=(0x8000000000000000; 0xffffffff))
13: safe
from 12 to 11: R0_w=-9223372036854775794 R1=scalar(umin=9223372036854775823,umax=9223372036854775823,var_off=(0x8000000000000000; 0xffffffff)) R2=pkt(off=0,r=1,imm=0) R3=pkt_end(off=0,imm=0) R10=fp0
11: (07) r0 += 1 ; R0_w=-9223372036854775793
12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775793 R1=scalar(umin=9223372036854775823,umax=9223372036854775823,var_off=(0x8000000000000000; 0xffffffff))
13: safe
from 12 to 11: R0_w=-9223372036854775793 R1=scalar(umin=9223372036854775824,umax=9223372036854775823,var_off=(0x8000000000000000; 0xffffffff)) R2=pkt(off=0,r=1,imm=0) R3=pkt_end(off=0,imm=0) R10=fp0
11: (07) r0 += 1 ; R0_w=-9223372036854775792
12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775792 R1=scalar(umin=9223372036854775824,umax=9223372036854775823,var_off=(0x8000000000000000; 0xffffffff))
13: safe
[...]
The 64bit umin=9223372036854775810 bound continuously bumps by +1 while umax=9223372036854775823 stays as-is until the verifier complexity limit is reached and the program gets finally rejected. During this simulation, the umin also eventually surpasses umax. Looking at the first 'from 12 to 11' output line from the loop, R1 has the following state:
R1_w=scalar(umin=0x8000000000000002 (9223372036854775810),
umax=0x800000000000000f (9223372036854775823),
var_off=(0x8000000000000000;
0xffffffff))The var_off has technically not an inconsistent state but it's very imprecise and far off surpassing 64bit umax bounds whereas the expected output with refined known bits in var_off should have been like:
R1_w=scalar(umin=0x8000000000000002 (9223372036854775810),
umax=0x800000000000000f (9223372036854775823),
var_off=(0x8000000000000000;
0xf))In the above log, var_off stays as var_off=(0x8000000000000000; 0xffffffff) and does not converge into a narrower mask where more bits become known, eventually transforming R1 into a constant upon umin=9223372036854775823, umax=9223372036854775823 case where the verifier would have terminated and let the program pass.
The __reg_combine_64_into_32() marks the subregister unknown and propagates 64bit {s,u}min/{s,u}max bounds to their 32bit equivalents iff they are within the 32bit universe. The question came up whether __reg_combine_64_into_32() should special case the situation that when 64bit {s,u}min bounds have the same value as 64bit {s,u}max bounds to then assign the latter as well to the 32bit reg->{s,u}32_{min,max}_value. As can be seen from the above example however, that is just /one/ special case and not a /generic/ solution given above example would still not be addressed this way and remain at an imprecise var_off=(0x8000000000000000; 0xffffffff).
The improvement is needed in __reg_bound_offset() to refine var32_off with the updated var64_off instead of the prior reg->var_off. The reg_bounds_sync() code first refines information about the register's min/max bounds via __update_reg_bounds() from the current var_off, then in __reg_deduce_bounds() from sign bit and with the potentially learned bits from bounds it'll update the var_off tnum in __reg_bound_offset(). For example, intersecting with the old var_off might have improved bounds slightly, e.g. if umax was 0x7f...f and var_off was (0; 0xf...fc), then new var_off will then result in (0; 0x7f...fc). The intersected var64_off holds then the universe which is a superset of var32_off. The point for the latter is not to broaden, but to further refine known bits based on the intersection of var_off with 32 bit bounds, so that we later construct the final var_off from upper and lower 32 bits. The final __update_reg_bounds() can then potentially still slightly refine bounds if more bits became known from the new var_off.
After the improvement, we can see R1 converging successively:
func#0 @0
0: R1=ctx(off=0,imm=0) R10=fp0
0: (61) r2 = *(u32 *)(r1 +0) ; R1=ctx(off=0,imm=0) R2_w=pkt(off=0,r=0,imm=0) 1: (61) r3 = *(u32 *)(r1 +4) ; R1=ctx(off=0,imm=0) R3_w=pkt_end(off=0,imm=0) 2: (bf) r1 = r2 ; R1_w=pkt(off=0,r=0,imm=0) R2_w=pkt(off=0,r=0,imm=0) 3: (07) r1 += 1 ; R1_w=pkt(off=1,r=0,imm=0) 4: (2d) if r1 > r3 goto pc+8 ; R1_w=pkt(off=1,r=1,imm=0) R3_w=pkt_end(off=0,imm=0) 5: (71) r1 = *(u8 *)(r2 +0) ; R1_w=scalar(umax=255,var_off=(0x0; 0xff)) R2_w=pkt(off=0,r=1,imm=0) 6: (18) r0 = 0x7fffffffffffff10 ; R0_w=9223372036854775568 8: (0f) r1 += r0 ; R0_w=9223372036854775568 R1_w=scalar(umin=9223372036854775568,umax=9223372036854775823,s32_min=-240,s32_max=15) 9: (18) r0 = 0x8000000000000000 ; R0_w=-9223372036854775808 11: (07) r0 += 1 ; R0_w=-9223372036854775807 12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775807 R1_w=scalar(umin=9223372036854775568,umax=9223372036854775809) 13: (b7) r0 = 0 ; R0_w=0
14: (95) exit
from 12 to 11: R0_w=-9223372036854775807 R1_w=scalar(umin=9223372036854775810,umax=9223372036854775823,var_off=(0x8000000000000000; 0xf),s32_min=0,s32_max=15,u32_max=15) R2_w=pkt(off=0,r=1,imm=0) R3_w=pkt_end(off=0,imm=0) R10=fp0
11: (07) r0 += 1 ; R0_w=-9223372036854775806
12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775806 R1_w=-9223372036854775806
13: safe
from 12 to 11: R0_w=-9223372036854775806 R1_w=scalar(umin=9223372036854775811,umax=9223372036854775823,var_off=(0x8000000000000000; 0xf),s32_min=0,s32_max=15,u32_max=15) R2_w=pkt(off=0,r=1,imm=0) R3_w=pkt_end(off=0,imm=0) R10=fp0
11: (07) r0 += 1 ; R0_w=-9223372036854775805
12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775805 R1_w=-9223372036854775805
13: safe
[...]
from 12 to 11: R0_w=-9223372036854775798 R1=scalar(umin=9223372036854775819,umax=9223372036854775823,var_off=(0x8000000000000008; 0x7),s32_min=8,s32_max=15,u32_min=8,u32_max=15) R2=pkt(off=0,r=1,imm=0) R3=pkt_end(off=0,imm=0) R10=fp0
11: (07) r0 += 1 ; R0_w=-9223372036854775797
12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775797 R1=-9223372036854775797
13: safe
from 12 to 11: R0_w=-9223372036854775797 R1=scalar(umin=9223372036854775820,umax=9223372036854775823,var_off=(0x800000000000000c; 0x3),s32_min=12,s32_max=15,u32_min=12,u32_max=15) R2=pkt(off=0,r=1,imm=0) R3=pkt_end(off=0,imm=0) R10=fp0
11: (07) r0 += 1 ; R0_w=-9223372036854775796
12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775796 R1=-9223372036854775796
13: safe
from 12 to 11: R0_w=-9223372036854775796 R1=scalar(umin=9223372036854775821,umax=9223372036854775823,var_off=(0x800000000000000c; 0x3),s32_min=12,s32_max=15,u32_min=12,u32_max=15) R2=pkt(off=0,r=1,imm=0) R3=pkt_end(off=0,imm=0) R10=fp0
11: (07) r0 += 1 ; R0_w=-9223372036854775795
12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775795 R1=-9223372036854775795
13: safe
from 12 to 11: R0_w=-9223372036854775795 R1=scalar(umin=9223372036854775822,umax=9223372036854775823,var_off=(0x800000000000000e; 0x1),s32_min=14,s32_max=15,u32_min=14,u32_max=15) R2=pkt(off=0,r=1,imm=0) R3=pkt_end(off=0,imm=0) R10=fp0
11: (07) r0 += 1 ; R0_w=-9223372036854775794
12: (ad) if r0 < r1 goto pc-2 ; R0_w=-9223372036854775794 R1=-9223372036854775794
13: safe
from 12 to 11: R0_w=-9223372036854775794 R1=-9223372036854775793 R2=pkt(off=0,r=1,imm=0) R3=pkt_end(off=0,imm=0) R10=fp0
11: (07) r0 += 1 ; R0_w=-9223372036854775793
12: (ad) if r0 < r1 goto pc-2
last_idx 12 first_idx 12
parent didn't have regs=1 stack=0 marks: R0_rw=P-9223372036854775801 R1_r=scalar(umin=9223372036854775815,umax=9223372036854775823,var_off=(0x8000000000000000; 0xf),s32_min=0,s32_max=15,u32_max=15) R2=pkt(off=0,r=1,imm=0) R3=pkt_end(off=0,imm=0) R10=fp0 last_idx 11 first_idx 11
regs=1 stack=0 before 11: (07) r0 += 1
parent didn't have regs=1 stack=0 marks: R0_rw=P-9223372036854775805 R1_rw=scalar(umin=9223372036854775812,umax=9223372036854775823,var_off=(0x8000000000000000; 0xf),s32_min=0,s32_max=15,u32_max=15) R2_w=pkt(off=0,r=1,imm=0) R3_w=pkt_end(off=0,imm=0) R10=fp0 last_idx 12 first_idx 0
regs=1 stack=0 before 12: (ad) if r0 < r1 goto pc-2
regs=1 stack=0 before 11: (07) r0 += 1
regs=1 stack=0 before 12: (ad) if r0 < r1 goto pc-2
regs=1 stack=0 before 11: (07) r0 += 1
regs=1 stack=0 before 12: (ad) if r0 < r1 goto pc-2
regs=1 stack=0 before 11: (07) r0 += 1
regs=1 stack=0 before 9: (18) r0 = 0x8000000000000000
last_idx 12 first_idx 12
parent didn't have regs=2 stack=0 marks: R0_rw=P-9223372036854775801 R1_r=Pscalar(umin=9223372036854775815,umax=9223372036854775823,var_off=(0x8000000000000000; 0xf),s32_min=0,s32_max=15,u32_max=15) R2=pkt(off=0,r=1,imm=0) R3=pkt_end(off=0,imm=0) R10=fp0 last_idx 11 first_idx 11
regs=2 stack=0 before 11: (07) r0 += 1
parent didn't have regs=2 stack=0 marks: R0_rw=P-9223372036854775805 R1_rw=Pscalar(umin=9223372036854775812,umax=9223372036854775823,var_off=(0x8000000000000000; 0xf),s32_min=0,s32_max=15,u32_max=15) R2_w=pkt(off=0,r=1,imm=0) R3_w=pkt_end(off=0,imm=0) R10=fp0 last_idx 12 first_idx 0
regs=2 stack=0 before 12: (ad) if r0 < r1 goto pc-2
regs=2 stack=0 before 11: (07) r0 += 1
regs=2 stack=0 before 12: (ad) if r0 < r1 goto pc-2
regs=2 stack=0 before 11: (07) r0 += 1
regs=2 stack=0 before 12: (ad) if r0 < r1 goto pc-2
regs=2 stack=0 before 11: (07) r0 += 1
regs=2 stack=0 before 9: (18) r0 = 0x8000000000000000
regs=2 stack=0 before 8: (0f) r1 += r0
regs=3 stack=0 before 6: (18) r0 = 0x7fffffffffffff10
regs=2 stack=0 before 5: (71) r1 = *(u8 *)(r2 +0)
13: safe
from 4 to 13: safe
verification time 322 usec
stack depth 0
processed 56 insns (limit 1000000) max_states_per_insn 1 total_states 3 peak_states 3 mark_read 1
This also fixes up a test case along with this improvement where we match on the verifier log. The updated log now has a refined var_off, too.
--- kernel/bpf/verifier.c | 6 +++--- tools/testing/selftests/bpf/prog_tests/align.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
kernel/bpf/verifier.c +3 -3
@@ -1590,9 +1590,9 @@ static void __reg_bound_offset(struct bpf_reg_state *reg)struct tnum var64_off =tnum_intersect (reg->var_off,tnum_range (reg->umin_value, reg->umax_value)); -struct tnum var32_off =tnum_intersect (tnum_subreg (reg->var_off), -tnum_range (reg->u32_min_value, - reg->u32_max_value)); +struct tnum var32_off =tnum_intersect (tnum_subreg (var64_off), +tnum_range (reg->u32_min_value, + reg->u32_max_value)); reg->var_off =tnum_or (tnum_clear_subreg (var64_off), var32_off); }
tools/testing/selftests/bpf/prog_tests/align.c +2 -2
@@ -565,14 +565,14 @@ static struct bpf_align_test tests[] = {/* New unknown value in R7 is (4n), >= 76 */ {14, "R7_w=scalar(umin=76,umax=1096,var_off=(0x0; 0x7fc))"},/* Adding it to packet pointer gives nice bounds again */ - {16, "R5_w=pkt(id=3,off=0,r=0,umin=2,umax=1082,var_off=(0x2; 0xfffffffc)"}, + {16, "R5_w=pkt(id=3,off=0,r=0,umin=2,umax=1082,var_off=(0x2; 0x7fc)"},/* At the time the word size load is performed from R5, * its total fixed offset is NET_IP_ALIGN + reg->off (0) * which is 2. Then the variable offset is (4n+2), so * the total offset is 4-byte aligned and meets the * load's requirements. */ - {20, "R5=pkt(id=3,off=0,r=4,umin=2,umax=1082,var_off=(0x2; 0xfffffffc)"}, + {20, "R5=pkt(id=3,off=0,r=4,umin=2,umax=1082,var_off=(0x2; 0x7fc)"}, }, }, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 293/611 scsi: target: core: Change the way target_xcopy_do_work() sets restiction on max I/O
In reply to Greg Kroah-HartmanFrom: Anastasia Kovaleva <[email protected]>
[ Upstream commit 689d94ec208cfdf95101d99319cb4bdc5f55774d ]
To determine how many blocks sends in one command, the minimum value is selected from the hw_max_sectors of both devices. In target_xcopy_do_work, hw_max_sectors are used as blocks, not sectors; it also ignores the fact that sectors can be of different sizes, for example 512 and 4096 bytes. Because of this, a number of blocks can be transmitted that the device will not be able to accept.
Change the selection of max transmission size into bytes.
Stable-dep-of: 395cee83d02d ("scsi: target: iscsit: Stop/wait on cmds during conn close")
--- drivers/target/target_core_xcopy.c | 97 ++++++++++++++++-------------- drivers/target/target_core_xcopy.h | 2 +- 2 files changed, 54 insertions(+), 45 deletions(-)
drivers/target/target_core_xcopy.c +53 -44
@@ -582,11 +582,11 @@ static int target_xcopy_read_source(struct xcopy_op *xop, struct se_device *src_dev, sector_t src_lba, - u32 src_sectors) + u32 src_bytes) { struct xcopy_pt_cmd xpt_cmd;struct se_cmd *se_cmd = &xpt_cmd.se_cmd; -u32 length = (src_sectors * src_dev->dev_attrib.block_size); +u32 transfer_length_block = src_bytes / src_dev->dev_attrib.block_size;int rc;unsigned char cdb[16 ];bool remote_port = (xop->op_origin ==XCOL_DEST_RECV_OP );
@@ -597,11 +597,11 @@ static int target_xcopy_read_source(memset (&cdb[0 ],0 ,16 ); cdb[0 ] =READ_16 ;put_unaligned_be64 (src_lba, &cdb[2 ]); -put_unaligned_be32 (src_sectors, &cdb[10 ]); -pr_debug ("XCOPY: Built READ_16: LBA: %llu Sectors: %u Length: %u\n" , - (unsigned long long )src_lba, src_sectors, length); +put_unaligned_be32 (transfer_length_block, &cdb[10 ]); +pr_debug ("XCOPY: Built READ_16: LBA: %llu Blocks: %u Length: %u\n" , + (unsigned long long )src_lba, transfer_length_block, src_bytes); -__target_init_cmd (se_cmd, &xcopy_pt_tfo, &xcopy_pt_sess, length, +__target_init_cmd (se_cmd, &xcopy_pt_tfo, &xcopy_pt_sess, src_bytes,DMA_FROM_DEVICE ,0 , &xpt_cmd.sense_buffer[0 ],0 ); rc = target_xcopy_setup_pt_cmd(&xpt_cmd, xop, src_dev, &cdb[0],
@@ -627,11 +627,11 @@ static int target_xcopy_write_destination(struct xcopy_op *xop, struct se_device *dst_dev, sector_t dst_lba, - u32 dst_sectors) + u32 dst_bytes) { struct xcopy_pt_cmd xpt_cmd;struct se_cmd *se_cmd = &xpt_cmd.se_cmd; -u32 length = (dst_sectors * dst_dev->dev_attrib.block_size); +u32 transfer_length_block = dst_bytes / dst_dev->dev_attrib.block_size;int rc;unsigned char cdb[16 ];bool remote_port = (xop->op_origin ==XCOL_SOURCE_RECV_OP );
@@ -642,11 +642,11 @@ static int target_xcopy_write_destination(memset (&cdb[0 ],0 ,16 ); cdb[0 ] =WRITE_16 ;put_unaligned_be64 (dst_lba, &cdb[2 ]); -put_unaligned_be32 (dst_sectors, &cdb[10 ]); -pr_debug ("XCOPY: Built WRITE_16: LBA: %llu Sectors: %u Length: %u\n" , - (unsigned long long )dst_lba, dst_sectors, length); +put_unaligned_be32 (transfer_length_block, &cdb[10 ]); +pr_debug ("XCOPY: Built WRITE_16: LBA: %llu Blocks: %u Length: %u\n" , + (unsigned long long )dst_lba, transfer_length_block, dst_bytes); -__target_init_cmd (se_cmd, &xcopy_pt_tfo, &xcopy_pt_sess, length, +__target_init_cmd (se_cmd, &xcopy_pt_tfo, &xcopy_pt_sess, dst_bytes,DMA_TO_DEVICE ,0 , &xpt_cmd.sense_buffer[0 ],0 ); rc = target_xcopy_setup_pt_cmd(&xpt_cmd, xop, dst_dev, &cdb[0],
@@ -670,9 +670,10 @@ static void target_xcopy_do_work(struct work_struct *work)struct se_cmd *ec_cmd = xop->xop_se_cmd;struct se_device *src_dev, *dst_dev;sector_t src_lba, dst_lba, end_lba; -unsigned int max_sectors; +unsigned long long max_bytes, max_bytes_src, max_bytes_dst, max_blocks;int rc =0 ; -unsigned short nolb, max_nolb, copied_nolb =0 ; +unsigned short nolb; +unsigned int copied_bytes =0 ;sense_reason_t sense_rc; sense_rc =target_parse_xcopy_cmd (xop);
@@ -691,23 +692,31 @@ static void target_xcopy_do_work(struct work_struct *work) nolb = xop->nolb; end_lba = src_lba + nolb;/* -* Break up XCOPY I/O into hw_max_sectors sized I/O based on the -* smallest max_sectors between src_dev + dev_dev, or +* Break up XCOPY I/O into hw_max_sectors * hw_block_size sized +* I/O based on the smallest max_bytes between src_dev + dst_dev */ - max_sectors =min (src_dev->dev_attrib.hw_max_sectors, - dst_dev->dev_attrib.hw_max_sectors); - max_sectors =min_t (u32, max_sectors,XCOPY_MAX_SECTORS ); + max_bytes_src = (unsigned long long ) src_dev->dev_attrib.hw_max_sectors * + src_dev->dev_attrib.hw_block_size; + max_bytes_dst = (unsigned long long ) dst_dev->dev_attrib.hw_max_sectors * + dst_dev->dev_attrib.hw_block_size; - max_nolb =min_t (u16, max_sectors, ((u16)(~0U ))); + max_bytes =min_t (u64, max_bytes_src, max_bytes_dst); + max_bytes =min_t (u64, max_bytes,XCOPY_MAX_BYTES ); -pr_debug ("target_xcopy_do_work: nolb: %hu, max_nolb: %hu end_lba: %llu\n" , - nolb, max_nolb, (unsigned long long )end_lba); -pr_debug ("target_xcopy_do_work: Starting src_lba: %llu, dst_lba: %llu\n" , +/* +* Using shift instead of the division because otherwise GCC +* generates __udivdi3 that is missing on i386 +*/ + max_blocks = max_bytes >>ilog2 (src_dev->dev_attrib.block_size); + +pr_debug ("%s: nolb: %u, max_blocks: %llu end_lba: %llu\n" , __func__, + nolb, max_blocks, (unsigned long long )end_lba); +pr_debug ("%s: Starting src_lba: %llu, dst_lba: %llu\n" , __func__, (unsigned long long )src_lba, (unsigned long long )dst_lba); -while (src_lba < end_lba) { -unsigned short cur_nolb =min (nolb, max_nolb); -u32 cur_bytes = cur_nolb * src_dev->dev_attrib.block_size; +while (nolb) { +u32 cur_bytes =min_t (u64, max_bytes, nolb * src_dev->dev_attrib.block_size); +unsigned short cur_nolb = cur_bytes / src_dev->dev_attrib.block_size;if (cur_bytes != xop->xop_data_bytes) {/*
@@ -724,43 +733,43 @@ static void target_xcopy_do_work(struct work_struct *work) xop->xop_data_bytes = cur_bytes; } -pr_debug ("target_xcopy_do_work: Calling read src_dev: %p src_lba: %llu," -" cur_nolb: %hu\n" , src_dev, (unsigned long long )src_lba, cur_nolb); +pr_debug ("%s: Calling read src_dev: %p src_lba: %llu, cur_nolb: %hu\n" , + __func__, src_dev, (unsigned long long )src_lba, cur_nolb); - rc =target_xcopy_read_source (ec_cmd, xop, src_dev, src_lba, cur_nolb); + rc =target_xcopy_read_source (ec_cmd, xop, src_dev, src_lba, cur_bytes);if (rc <0 ) goto out; - src_lba += cur_nolb; -pr_debug ("target_xcopy_do_work: Incremented READ src_lba to %llu\n" , + src_lba += cur_bytes / src_dev->dev_attrib.block_size; +pr_debug ("%s: Incremented READ src_lba to %llu\n" , __func__, (unsigned long long )src_lba); -pr_debug ("target_xcopy_do_work: Calling write dst_dev: %p dst_lba: %llu," -" cur_nolb: %hu\n" , dst_dev, (unsigned long long )dst_lba, cur_nolb); +pr_debug ("%s: Calling write dst_dev: %p dst_lba: %llu, cur_nolb: %u\n" , + __func__, dst_dev, (unsigned long long )dst_lba, cur_nolb); rc =target_xcopy_write_destination (ec_cmd, xop, dst_dev, - dst_lba, cur_nolb); + dst_lba, cur_bytes);if (rc <0 ) goto out; - dst_lba += cur_nolb; -pr_debug ("target_xcopy_do_work: Incremented WRITE dst_lba to %llu\n" , + dst_lba += cur_bytes / dst_dev->dev_attrib.block_size; +pr_debug ("%s: Incremented WRITE dst_lba to %llu\n" , __func__, (unsigned long long )dst_lba); - copied_nolb += cur_nolb; - nolb -= cur_nolb; + copied_bytes += cur_bytes; + nolb -= cur_bytes / src_dev->dev_attrib.block_size; }xcopy_pt_undepend_remotedev (xop);target_free_sgl (xop->xop_data_sg, xop->xop_data_nents);kfree (xop); -pr_debug ("target_xcopy_do_work: Final src_lba: %llu, dst_lba: %llu\n" , +pr_debug ("%s: Final src_lba: %llu, dst_lba: %llu\n" , __func__, (unsigned long long )src_lba, (unsigned long long )dst_lba); -pr_debug ("target_xcopy_do_work: Blocks copied: %hu, Bytes Copied: %u\n" , - copied_nolb, copied_nolb * dst_dev->dev_attrib.block_size); +pr_debug ("%s: Blocks copied: %u, Bytes Copied: %u\n" , __func__, + copied_bytes / dst_dev->dev_attrib.block_size, copied_bytes); -pr_debug ("target_xcopy_do_work: Setting X-COPY GOOD status -> sending response\n" ); +pr_debug ("%s: Setting X-COPY GOOD status -> sending response\n" , __func__);target_complete_cmd (ec_cmd,SAM_STAT_GOOD );return ;
@@ -776,8 +785,8 @@ static void target_xcopy_do_work(struct work_struct *work) err_free:kfree (xop); -pr_warn_ratelimited ("target_xcopy_do_work: rc: %d, sense: %u, XCOPY operation failed\n" , - rc, sense_rc); +pr_warn_ratelimited ("%s: rc: %d, sense: %u, XCOPY operation failed\n" , + __func__, rc, sense_rc);target_complete_cmd_with_sense (ec_cmd,SAM_STAT_CHECK_CONDITION , sense_rc); }
drivers/target/target_core_xcopy.h +1 -1
@@ -5,7 +5,7 @@#define XCOPY_TARGET_DESC_LEN 32#define XCOPY_SEGMENT_DESC_LEN 28#define XCOPY_NAA_IEEE_REGEX_LEN 16 -#define XCOPY_MAX_SECTORS 4096 +#define XCOPY_MAX_BYTES 16777216/* 16 MB */ /* * SPC4r37 6.4.6.1
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 294/611 scsi: target: Move sess cmd counter to new struct
In reply to Greg Kroah-HartmanFrom: Mike Christie <[email protected]>
[ Upstream commit becd9be6069e7b183c084f460f0eb363e43cc487 ]
iSCSI needs to wait on outstanding commands like how SRP and the FC/FCoE drivers do. It can't use target_stop_session() because for MCS support we can't stop the entire session during recovery because if other connections are OK then we want to be able to continue to execute I/O on them.
Move the per session cmd counters to a new struct so iSCSI can allocate them per connection. The xcopy code can also just not allocate in the future since it doesn't need to track commands.
Stable-dep-of: 395cee83d02d ("scsi: target: iscsit: Stop/wait on cmds during conn close")
--- drivers/target/target_core_tpg.c | 2 +- drivers/target/target_core_transport.c | 135 ++++++++++++++++------- include/target/iscsi/iscsi_target_core.h | 1 + include/target/target_core_base.h | 13 ++- 4 files changed, 107 insertions(+), 44 deletions(-)
drivers/target/target_core_tpg.c +1 -1
@@ -328,7 +328,7 @@ static void target_shutdown_sessions(struct se_node_acl *acl) restart:spin_lock_irqsave (&acl->nacl_sess_lock, flags);list_for_each_entry (sess, &acl->acl_sess_list, sess_acl_list) { -if (atomic_read (&sess->stopped)) +if (sess->cmd_cnt &&atomic_read (&sess->cmd_cnt->stopped))continue ;list_del_init (&sess->sess_acl_list);
drivers/target/target_core_transport.c +96 -39
201 lines not on this page · raw message
include/target/iscsi/iscsi_target_core.h +1 -0
@@ -600,6 +600,7 @@ struct iscsit_conn {struct iscsi_tpg_np *tpg_np;/* Pointer to parent session */ struct iscsit_session *sess; +struct target_cmd_counter *cmd_cnt;int bitmap_id;int rx_thread_active;struct task_struct *rx_thread;
include/target/target_core_base.h +9 -4
@@ -492,6 +492,7 @@ struct se_cmd {struct se_lun *se_lun;/* Only used for internal passthrough and legacy TCM fabric modules */ struct se_session *se_sess; +struct target_cmd_counter *cmd_cnt;struct se_tmr_req *se_tmr_req;struct llist_node se_cmd_list;struct completion *free_compl;
@@ -617,22 +618,26 @@ static inline struct se_node_acl *fabric_stat_to_nacl(struct config_item *item) acl_fabric_stat_group); } -struct se_session { +struct target_cmd_counter { +struct percpu_ref refcnt; +wait_queue_head_t refcnt_wq; +struct completion stop_done;atomic_t stopped; +}; + +struct se_session {u64 sess_bin_isid;enum target_prot_op sup_prot_ops;enum target_prot_type sess_prot_type;struct se_node_acl *se_node_acl;struct se_portal_group *se_tpg;void *fabric_sess_ptr; -struct percpu_ref cmd_count;struct list_head sess_list;struct list_head sess_acl_list;spinlock_t sess_cmd_lock; -wait_queue_head_t cmd_count_wq; -struct completion stop_done;void *sess_cmd_map;struct sbitmap_queue sess_tag_pool; +struct target_cmd_counter *cmd_cnt; };struct se_device ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 295/611 scsi: target: Move cmd counter allocation
In reply to Greg Kroah-HartmanFrom: Mike Christie <[email protected]>
[ Upstream commit 4edba7e4a8f39112398d3cda94128a8e13a7d527 ]
iSCSI needs to allocate its cmd counter per connection for MCS support where we need to stop and wait on commands running on a connection instead of per session. This moves the cmd counter allocation to target_setup_session() which is used by drivers that need the stop+wait behavior per session.
xcopy doesn't need stop+wait at all, so we will be OK moving the cmd counter allocation outside of transport_init_session().
Stable-dep-of: 395cee83d02d ("scsi: target: iscsit: Stop/wait on cmds during conn close")
--- drivers/target/iscsi/iscsi_target_login.c | 10 +++++ drivers/target/target_core_internal.h | 1 - drivers/target/target_core_transport.c | 55 +++++++++++------------ drivers/target/target_core_xcopy.c | 15 +------ include/target/target_core_fabric.h | 4 +- 5 files changed, 42 insertions(+), 43 deletions(-)
drivers/target/iscsi/iscsi_target_login.c +10 -0
@@ -324,8 +324,18 @@ static int iscsi_login_zero_tsih_s1( goto free_ops; } +/* +* This is temp for iser. It will be moved to per conn in later +* patches for iscsi. +*/ + sess->se_sess->cmd_cnt =target_alloc_cmd_counter (); +if (!sess->se_sess->cmd_cnt) + goto free_se_sess; +return 0 ; +free_se_sess: +transport_free_session (sess->se_sess); free_ops:kfree (sess->sess_ops); free_id:
drivers/target/target_core_internal.h +0 -1
@@ -138,7 +138,6 @@ int init_se_kmem_caches(void);void release_se_kmem_caches (void );u32 scsi_get_new_index (scsi_index_t );void transport_subsystem_check_init (void ); -void transport_uninit_session (struct se_session *);unsigned char *transport_dump_cmd_direction (struct se_cmd *);void transport_dump_dev_state (struct se_device *,char *,int *); void transport_dump_dev_info(struct se_device *, struct se_lun *,
drivers/target/target_core_transport.c +27 -28
126 lines not on this page · raw message
drivers/target/target_core_xcopy.c +2 -13
@@ -461,8 +461,6 @@ static const struct target_core_fabric_ops xcopy_pt_tfo = {int target_xcopy_setup_pt (void ) { -int ret; - xcopy_wq =alloc_workqueue ("xcopy_wq" ,WQ_MEM_RECLAIM ,0 );if (!xcopy_wq) {pr_err ("Unable to allocate xcopy_wq\n" );
@@ -479,9 +477,7 @@ int target_xcopy_setup_pt(void)INIT_LIST_HEAD (&xcopy_pt_nacl.acl_list);INIT_LIST_HEAD (&xcopy_pt_nacl.acl_sess_list);memset (&xcopy_pt_sess,0 ,sizeof (struct se_session )); - ret =transport_init_session (&xcopy_pt_sess); -if (ret <0 ) - goto destroy_wq; +transport_init_session (&xcopy_pt_sess); xcopy_pt_nacl.se_tpg = &xcopy_pt_tpg; xcopy_pt_nacl.nacl_sess = &xcopy_pt_sess;
@@ -490,19 +486,12 @@ int target_xcopy_setup_pt(void) xcopy_pt_sess.se_node_acl = &xcopy_pt_nacl;return 0 ; - -destroy_wq: -destroy_workqueue (xcopy_wq); - xcopy_wq =NULL ; -return ret; }void target_xcopy_release_pt (void ) { -if (xcopy_wq) { +if (xcopy_wq)destroy_workqueue (xcopy_wq); -transport_uninit_session (&xcopy_pt_sess); - } }/*
include/target/target_core_fabric.h +3 -1
@@ -133,7 +133,9 @@ struct se_session *target_setup_session(struct se_portal_group *, struct se_session *, void *));void target_remove_session (struct se_session *); -int transport_init_session (struct se_session *se_sess); +struct target_cmd_counter *target_alloc_cmd_counter (void ); + +void transport_init_session (struct se_session *se_sess);struct se_session *transport_alloc_session (enum target_prot_op );int transport_alloc_session_tags (struct se_session *,unsigned int ,unsigned int );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 296/611 scsi: target: Pass in cmd counter to use during cmd setup
In reply to Greg Kroah-HartmanFrom: Mike Christie <[email protected]>
[ Upstream commit 8e288be8606ad87c1726618eacfb8fbd3ab4b806 ]
Allow target_get_sess_cmd() users to pass in the cmd counter they want to use. Right now we pass in the session's cmd counter but in a subsequent commit iSCSI will switch from per session to per conn.
Stable-dep-of: 395cee83d02d ("scsi: target: iscsit: Stop/wait on cmds during conn close")
--- drivers/target/iscsi/iscsi_target.c | 10 +++++---- drivers/target/target_core_transport.c | 28 ++++++++++++-------------- drivers/target/target_core_xcopy.c | 8 ++++---- drivers/usb/gadget/function/f_tcm.c | 4 ++-- include/target/target_core_fabric.h | 8 +++++--- 5 files changed, 30 insertions(+), 28 deletions(-)
drivers/target/iscsi/iscsi_target.c +6 -4
@@ -1190,9 +1190,10 @@ int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,* Initialize struct se_cmd descriptor from target_core_mod infrastructure */ __target_init_cmd (&cmd->se_cmd, &iscsi_ops, - conn->sess->se_sess,be32_to_cpu (hdr->data_length), - cmd->data_direction, sam_task_attr, - cmd->sense_buffer +2 ,scsilun_to_int (&hdr->lun)); + conn->sess->se_sess,be32_to_cpu (hdr->data_length), + cmd->data_direction, sam_task_attr, + cmd->sense_buffer +2 ,scsilun_to_int (&hdr->lun), + conn->sess->se_sess->cmd_cnt); pr_debug("Got SCSI Command, ITT: 0x%08x, CmdSN: 0x%08x," " ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt,
@@ -2055,7 +2056,8 @@ iscsit_handle_task_mgt_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,__target_init_cmd (&cmd->se_cmd, &iscsi_ops, conn->sess->se_sess,0 ,DMA_NONE ,TCM_SIMPLE_TAG , cmd->sense_buffer +2 , -scsilun_to_int (&hdr->lun)); +scsilun_to_int (&hdr->lun), + conn->sess->se_sess->cmd_cnt);target_get_sess_cmd (&cmd->se_cmd, true);
drivers/target/target_core_transport.c +13 -15
@@ -1441,14 +1441,12 @@ target_cmd_size_check(struct se_cmd *cmd, unsigned int size)* * Preserves the value of @cmd->tag. */ -void __target_init_cmd ( -struct se_cmd *cmd, -const struct target_core_fabric_ops *tfo, -struct se_session *se_sess, -u32 data_length, -int data_direction, -int task_attr, -unsigned char *sense_buffer,u64 unpacked_lun) +void __target_init_cmd (struct se_cmd *cmd, +const struct target_core_fabric_ops *tfo, +struct se_session *se_sess,u32 data_length, +int data_direction,int task_attr, +unsigned char *sense_buffer,u64 unpacked_lun, +struct target_cmd_counter *cmd_cnt) {INIT_LIST_HEAD (&cmd->se_delayed_node);INIT_LIST_HEAD (&cmd->se_qf_node);
@@ -1468,6 +1466,7 @@ void __target_init_cmd( cmd->sam_task_attr = task_attr; cmd->sense_buffer = sense_buffer; cmd->orig_fe_lun = unpacked_lun; + cmd->cmd_cnt = cmd_cnt;if (!(cmd->se_cmd_flags &SCF_USE_CPUID )) cmd->cpuid =raw_smp_processor_id ();
@@ -1687,7 +1686,8 @@ int target_init_cmd(struct se_cmd *se_cmd, struct se_session *se_sess,* target_core_fabric_ops->queue_status() callback */ __target_init_cmd (se_cmd, se_tpg->se_tpg_tfo, se_sess, data_length, - data_dir, task_attr, sense, unpacked_lun); + data_dir, task_attr, sense, unpacked_lun, + se_sess->cmd_cnt);/* * Obtain struct se_cmd->cmd_kref reference. A second kref_get here is
@@ -1982,7 +1982,8 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,BUG_ON (!se_tpg);__target_init_cmd (se_cmd, se_tpg->se_tpg_tfo, se_sess, -0 ,DMA_NONE ,TCM_SIMPLE_TAG , sense, unpacked_lun); +0 ,DMA_NONE ,TCM_SIMPLE_TAG , sense, unpacked_lun, + se_sess->cmd_cnt);/* * FIXME: Currently expect caller to handle se_cmd->se_tmr_req * allocation failure.
@@ -2986,7 +2987,6 @@ EXPORT_SYMBOL(transport_generic_free_cmd);*/ int target_get_sess_cmd (struct se_cmd *se_cmd,bool ack_kref) { -struct se_session *se_sess = se_cmd->se_sess;int ret =0 ;/*
@@ -3003,11 +3003,9 @@ int target_get_sess_cmd(struct se_cmd *se_cmd, bool ack_kref)* Users like xcopy do not use counters since they never do a stop * and wait. */ -if (se_sess->cmd_cnt) { -if (!percpu_ref_tryget_live (&se_sess->cmd_cnt->refcnt)) +if (se_cmd->cmd_cnt) { +if (!percpu_ref_tryget_live (&se_cmd->cmd_cnt->refcnt)) ret = -ESHUTDOWN ; -else - se_cmd->cmd_cnt = se_sess->cmd_cnt; }if (ret && ack_kref)target_put_sess_cmd (se_cmd);
drivers/target/target_core_xcopy.c +4 -4
@@ -591,8 +591,8 @@ static int target_xcopy_read_source( (unsigned long long)src_lba, transfer_length_block, src_bytes);__target_init_cmd (se_cmd, &xcopy_pt_tfo, &xcopy_pt_sess, src_bytes, -DMA_FROM_DEVICE ,0 , &xpt_cmd.sense_buffer[0 ],0 ); - +DMA_FROM_DEVICE ,0 , &xpt_cmd.sense_buffer[0 ],0 , +NULL ); rc =target_xcopy_setup_pt_cmd (&xpt_cmd, xop, src_dev, &cdb[0 ], remote_port);if (rc <0 ) {
@@ -636,8 +636,8 @@ static int target_xcopy_write_destination( (unsigned long long)dst_lba, transfer_length_block, dst_bytes);__target_init_cmd (se_cmd, &xcopy_pt_tfo, &xcopy_pt_sess, dst_bytes, -DMA_TO_DEVICE ,0 , &xpt_cmd.sense_buffer[0 ],0 ); - +DMA_TO_DEVICE ,0 , &xpt_cmd.sense_buffer[0 ],0 , +NULL ); rc =target_xcopy_setup_pt_cmd (&xpt_cmd, xop, dst_dev, &cdb[0 ], remote_port);if (rc <0 ) {
drivers/usb/gadget/function/f_tcm.c +2 -2
@@ -1054,7 +1054,7 @@ static void usbg_cmd_work(struct work_struct *work) tv_nexus->tvn_se_sess->se_tpg->se_tpg_tfo, tv_nexus->tvn_se_sess, cmd->data_len,DMA_NONE , cmd->prio_attr, cmd->sense_iu.sense, - cmd->unpacked_lun); + cmd->unpacked_lun, NULL); goto out; }
@@ -1183,7 +1183,7 @@ static void bot_cmd_work(struct work_struct *work) tv_nexus->tvn_se_sess->se_tpg->se_tpg_tfo, tv_nexus->tvn_se_sess, cmd->data_len,DMA_NONE , cmd->prio_attr, cmd->sense_iu.sense, - cmd->unpacked_lun); + cmd->unpacked_lun, NULL); goto out; }
include/target/target_core_fabric.h +5 -3
@@ -151,9 +151,11 @@ void transport_deregister_session_configfs(struct se_session *);void transport_deregister_session (struct se_session *); -void __target_init_cmd (struct se_cmd *, -const struct target_core_fabric_ops *, -struct se_session *,u32 ,int ,int ,unsigned char *,u64 ); +void __target_init_cmd (struct se_cmd *cmd, +const struct target_core_fabric_ops *tfo, +struct se_session *sess,u32 data_length,int data_direction, +int task_attr,unsigned char *sense_buffer,u64 unpacked_lun, +struct target_cmd_counter *cmd_cnt);int target_init_cmd (struct se_cmd *se_cmd,struct se_session *se_sess,unsigned char *sense,u64 unpacked_lun,u32 data_length,int task_attr,int data_dir,int flags);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 297/611 scsi: target: iscsit: isert: Alloc per conn cmd counter
In reply to Greg Kroah-HartmanFrom: Mike Christie <[email protected]>
[ Upstream commit 6d256bee602b131bd4fbc92863b6a1210bcf6325 ]
This has iscsit allocate a per conn cmd counter and converts iscsit/isert to use it instead of the per session one.
Stable-dep-of: 395cee83d02d ("scsi: target: iscsit: Stop/wait on cmds during conn close")
--- drivers/infiniband/ulp/isert/ib_isert.c | 4 ++-- drivers/target/iscsi/iscsi_target.c | 4 ++-- drivers/target/iscsi/iscsi_target_login.c | 17 +++++++---------- drivers/target/target_core_transport.c | 9 ++++++--- include/target/target_core_fabric.h | 3 +++ 5 files changed, 20 insertions(+), 17 deletions(-)
drivers/infiniband/ulp/isert/ib_isert.c +2 -2
@@ -2507,8 +2507,8 @@ isert_wait4cmds(struct iscsit_conn *conn)isert_info ("iscsit_conn %p\n" , conn);if (conn->sess) { -target_stop_session (conn->sess->se_sess); -target_wait_for_sess_cmds (conn->sess->se_sess); +target_stop_cmd_counter (conn->cmd_cnt); +target_wait_for_cmds (conn->cmd_cnt); } }
drivers/target/iscsi/iscsi_target.c +2 -2
@@ -1193,7 +1193,7 @@ int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, conn->sess->se_sess,be32_to_cpu (hdr->data_length), cmd->data_direction, sam_task_attr, cmd->sense_buffer +2 ,scsilun_to_int (&hdr->lun), - conn->sess->se_sess->cmd_cnt); + conn->cmd_cnt); pr_debug("Got SCSI Command, ITT: 0x%08x, CmdSN: 0x%08x," " ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt,
@@ -2057,7 +2057,7 @@ iscsit_handle_task_mgt_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, conn->sess->se_sess,0 ,DMA_NONE ,TCM_SIMPLE_TAG , cmd->sense_buffer +2 ,scsilun_to_int (&hdr->lun), - conn->sess->se_sess->cmd_cnt); + conn->cmd_cnt);target_get_sess_cmd (&cmd->se_cmd, true);
drivers/target/iscsi/iscsi_target_login.c +7 -10
@@ -324,18 +324,8 @@ static int iscsi_login_zero_tsih_s1( goto free_ops; } -/* -* This is temp for iser. It will be moved to per conn in later -* patches for iscsi. -*/ - sess->se_sess->cmd_cnt =target_alloc_cmd_counter (); -if (!sess->se_sess->cmd_cnt) - goto free_se_sess; -return 0 ; -free_se_sess: -transport_free_session (sess->se_sess); free_ops:kfree (sess->sess_ops); free_id:
@@ -1157,8 +1147,14 @@ static struct iscsit_conn *iscsit_alloc_conn(struct iscsi_np *np) goto free_conn_cpumask; } + conn->cmd_cnt =target_alloc_cmd_counter (); +if (!conn->cmd_cnt) + goto free_conn_allowed_cpumask; +return conn; +free_conn_allowed_cpumask: +free_cpumask_var (conn->allowed_cpumask); free_conn_cpumask:free_cpumask_var (conn->conn_cpumask); free_conn_ops:
@@ -1172,6 +1168,7 @@ static struct iscsit_conn *iscsit_alloc_conn(struct iscsi_np *np)void iscsit_free_conn (struct iscsit_conn *conn) { +target_free_cmd_counter (conn->cmd_cnt);free_cpumask_var (conn->allowed_cpumask);free_cpumask_var (conn->conn_cpumask);kfree (conn->conn_ops);
drivers/target/target_core_transport.c +6 -3
@@ -254,7 +254,7 @@ struct target_cmd_counter *target_alloc_cmd_counter(void) }EXPORT_SYMBOL_GPL (target_alloc_cmd_counter); -static void target_free_cmd_counter (struct target_cmd_counter *cmd_cnt) +void target_free_cmd_counter (struct target_cmd_counter *cmd_cnt) {/* * Drivers like loop do not call target_stop_session during session
@@ -265,6 +265,7 @@ static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt)percpu_ref_exit (&cmd_cnt->refcnt); } +EXPORT_SYMBOL_GPL (target_free_cmd_counter);/** * transport_init_session - initialize a session object
@@ -3170,13 +3171,14 @@ static void target_stop_cmd_counter_confirm(struct percpu_ref *ref)* target_stop_cmd_counter - Stop new IO from being added to the counter. * @cmd_cnt: counter to stop */ -static void target_stop_cmd_counter (struct target_cmd_counter *cmd_cnt) +void target_stop_cmd_counter (struct target_cmd_counter *cmd_cnt) {pr_debug ("Stopping command counter.\n" );if (!atomic_cmpxchg (&cmd_cnt->stopped,0 ,1 ))percpu_ref_kill_and_confirm (&cmd_cnt->refcnt, target_stop_cmd_counter_confirm); } +EXPORT_SYMBOL_GPL (target_stop_cmd_counter);/** * target_stop_session - Stop new IO from being queued on the session.
@@ -3192,7 +3194,7 @@ EXPORT_SYMBOL(target_stop_session);* target_wait_for_cmds - Wait for outstanding cmds. * @cmd_cnt: counter to wait for active I/O for. */ -static void target_wait_for_cmds (struct target_cmd_counter *cmd_cnt) +void target_wait_for_cmds (struct target_cmd_counter *cmd_cnt) {int ret;
@@ -3208,6 +3210,7 @@ static void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt)wait_for_completion (&cmd_cnt->stop_done);pr_debug ("Waiting for cmds done.\n" ); } +EXPORT_SYMBOL_GPL (target_wait_for_cmds);/** * target_wait_for_sess_cmds - Wait for outstanding commands
include/target/target_core_fabric.h +3 -0
@@ -133,7 +133,10 @@ struct se_session *target_setup_session(struct se_portal_group *, struct se_session *, void *));void target_remove_session (struct se_session *); +void target_stop_cmd_counter (struct target_cmd_counter *cmd_cnt); +void target_wait_for_cmds (struct target_cmd_counter *cmd_cnt);struct target_cmd_counter *target_alloc_cmd_counter (void ); +void target_free_cmd_counter (struct target_cmd_counter *cmd_cnt);void transport_init_session (struct se_session *se_sess);struct se_session *transport_alloc_session (enum target_prot_op );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 298/611 scsi: target: iscsit: Stop/wait on cmds during conn close
In reply to Greg Kroah-HartmanFrom: Mike Christie <[email protected]>
[ Upstream commit 395cee83d02de3073211b04fc85724f4abc663ad ]
This fixes a bug added in commit f36199355c64 ("scsi: target: iscsi: Fix cmd abort fabric stop race").
If we have multiple sessions to the same se_device we can hit a race where a LUN_RESET on one session cleans up the se_cmds from under another session which is being closed. This results in the closing session freeing its conn/session structs while they are still in use.
The bug is:
1. Session1 has IO se_cmd1.
2. Session2 can also have se_cmds for I/O and optionally TMRs for ABORTS but then gets a LUN_RESET.
3. The LUN_RESET on session2 sees the se_cmds on session1 and during the drain stages marks them all with CMD_T_ABORTED.
4. session1 is now closed so iscsit_release_commands_from_conn() only sees se_cmds with the CMD_T_ABORTED bit set and returns immediately even though we have outstanding commands.
5. session1's connection and session are freed.
6. The backend request for se_cmd1 completes and it accesses the freed connection/session.
This hooks the iscsit layer into the cmd counter code, so we can wait for all outstanding se_cmds before freeing the connection.
--- drivers/target/iscsi/iscsi_target.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/target/iscsi/iscsi_target.c +10 -0
@@ -4245,6 +4245,16 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn)iscsit_free_cmd (cmd, true); } + +/* +* Wait on commands that were cleaned up via the aborted_task path. +* LLDs that implement iscsit_wait_conn will already have waited for +* commands. +*/ +if (!conn->conn_transport->iscsit_wait_conn) { +target_stop_cmd_counter (conn->cmd_cnt); +target_wait_for_cmds (conn->cmd_cnt); + } } static void iscsit_stop_timers_for_cmds(
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 299/611 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
@@ -782,6 +782,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
@@ -870,6 +870,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 300/611 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
@@ -4220,9 +4220,12 @@ static void iscsit_release_commands_from_conn(struct iscsit_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
@@ -4230,11 +4233,10 @@ static void iscsit_release_commands_from_conn(struct iscsit_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 301/611 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
@@ -1441,6 +1441,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 302/611 net: sunhme: Fix uninitialized return code
In reply to Greg Kroah-HartmanFrom: Sean Anderson <[email protected]>
[ Upstream commit d61157414d0a591d10d27d0ce5873916614e5e31 ]
Fix an uninitialized return code if we never found a qfe slot. It would be a bug if we ever got into this situation, but it's good to return something tracable.
--- drivers/net/ethernet/sun/sunhme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/sun/sunhme.c +1 -1
@@ -2834,7 +2834,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,int i, qfe_slot =-1 ;char prom_name[64 ];u8 addr[ETH_ALEN ]; -int err; +int err = -ENODEV ;/* Now make sure pci_dev cookie is there. */ #ifdef CONFIG_SPARC
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 303/611 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
@@ -3004,15 +3004,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 304/611 f2fs: fix uninitialized skipped_gc_rwsem
In reply to Greg Kroah-HartmanFrom: Yonggil Song <[email protected]>
[ Upstream commit c17caf0ba3aa3411b96c71b4ce24be1040b8f3e8 ]
When f2fs skipped a gc round during victim migration, there was a bug which would skip all upcoming gc rounds unconditionally because skipped_gc_rwsem was not initialized. It fixes the bug by correctly initializing the skipped_gc_rwsem inside the gc loop.
--- fs/f2fs/gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/gc.c +1 -1
@@ -1792,8 +1792,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) prefree_segments(sbi)); cpc.reason =__get_cp_reason (sbi); - sbi->skipped_gc_rwsem =0 ; gc_more: + sbi->skipped_gc_rwsem =0 ;if (unlikely (!(sbi->sb->s_flags &SB_ACTIVE ))) { ret = -EINVAL ; goto stop;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 305/611 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
@@ -4916,48 +4916,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
@@ -4970,23 +4928,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);
@@ -5020,11 +4968,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)
@@ -5039,7 +4982,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 306/611 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
@@ -1462,6 +1462,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 307/611 f2fs: fix scheduling while atomic in decompression path
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 1aa161e43106d46ca8e9a86f4aa28d420258134b ]
[ 16.945668][ C0] Call trace: [ 16.945678][ C0] dump_backtrace+0x110/0x204 [ 16.945706][ C0] dump_stack_lvl+0x84/0xbc [ 16.945735][ C0] __schedule_bug+0xb8/0x1ac [ 16.945756][ C0] __schedule+0x724/0xbdc [ 16.945778][ C0] schedule+0x154/0x258 [ 16.945793][ C0] bit_wait_io+0x48/0xa4 [ 16.945808][ C0] out_of_line_wait_on_bit+0x114/0x198 [ 16.945824][ C0] __sync_dirty_buffer+0x1f8/0x2e8 [ 16.945853][ C0] __f2fs_commit_super+0x140/0x1f4 [ 16.945881][ C0] f2fs_commit_super+0x110/0x28c [ 16.945898][ C0] f2fs_handle_error+0x1f4/0x2f4 [ 16.945917][ C0] f2fs_decompress_cluster+0xc4/0x450 [ 16.945942][ C0] f2fs_end_read_compressed_page+0xc0/0xfc [ 16.945959][ C0] f2fs_handle_step_decompress+0x118/0x1cc [ 16.945978][ C0] f2fs_read_end_io+0x168/0x2b0 [ 16.945993][ C0] bio_endio+0x25c/0x2c8 [ 16.946015][ C0] dm_io_dec_pending+0x3e8/0x57c [ 16.946052][ C0] clone_endio+0x134/0x254 [ 16.946069][ C0] bio_endio+0x25c/0x2c8 [ 16.946084][ C0] blk_update_request+0x1d4/0x478 [ 16.946103][ C0] scsi_end_request+0x38/0x4cc [ 16.946129][ C0] scsi_io_completion+0x94/0x184 [ 16.946147][ C0] scsi_finish_command+0xe8/0x154 [ 16.946164][ C0] scsi_complete+0x90/0x1d8 [ 16.946181][ C0] blk_done_softirq+0xa4/0x11c [ 16.946198][ C0] _stext+0x184/0x614 [ 16.946214][ C0] __irq_exit_rcu+0x78/0x144 [ 16.946234][ C0] handle_domain_irq+0xd4/0x154 [ 16.946260][ C0] gic_handle_irq.33881+0x5c/0x27c [ 16.946281][ C0] call_on_irq_stack+0x40/0x70 [ 16.946298][ C0] do_interrupt_handler+0x48/0xa4 [ 16.946313][ C0] el1_interrupt+0x38/0x68 [ 16.946346][ C0] el1h_64_irq_handler+0x20/0x30 [ 16.946362][ C0] el1h_64_irq+0x78/0x7c [ 16.946377][ C0] finish_task_switch+0xc8/0x3d8 [ 16.946394][ C0] __schedule+0x600/0xbdc [ 16.946408][ C0] preempt_schedule_common+0x34/0x5c [ 16.946423][ C0] preempt_schedule+0x44/0x48 [ 16.946438][ C0] process_one_work+0x30c/0x550 [ 16.946456][ C0] worker_thread+0x414/0x8bc [ 16.946472][ C0] kthread+0x16c/0x1e0 [ 16.946486][ C0] ret_from_fork+0x10/0x20
--- fs/f2fs/compress.c | 7 ++++++- fs/f2fs/f2fs.h | 1 + fs/f2fs/super.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-)
fs/f2fs/compress.c +6 -1
@@ -762,7 +762,12 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task)if (dic->clen >PAGE_SIZE * dic->nr_cpages -COMPRESS_HEADER_SIZE ) { ret = -EFSCORRUPTED ; -f2fs_handle_error (sbi,ERROR_FAIL_DECOMPRESSION ); + +/* Avoid f2fs_commit_super in irq context */ +if (in_task) +f2fs_save_errors (sbi,ERROR_FAIL_DECOMPRESSION ); +else +f2fs_handle_error (sbi,ERROR_FAIL_DECOMPRESSION ); goto out_release; }
fs/f2fs/f2fs.h +1 -0
@@ -3569,6 +3569,7 @@ int f2fs_quota_sync(struct super_block *sb, int type);loff_t max_file_blocks (struct inode *inode);void f2fs_quota_off_umount (struct super_block *sb);void f2fs_handle_stop (struct f2fs_sb_info *sbi,unsigned char reason); +void f2fs_save_errors (struct f2fs_sb_info *sbi,unsigned char flag);void f2fs_handle_error (struct f2fs_sb_info *sbi,unsigned char error);int f2fs_commit_super (struct f2fs_sb_info *sbi,bool recover);int f2fs_sync_fs (struct super_block *sb,int sync);
fs/f2fs/super.c +1 -1
@@ -3861,7 +3861,7 @@ void f2fs_handle_stop(struct f2fs_sb_info *sbi, unsigned char reason)f2fs_up_write (&sbi->sb_lock); } -static void f2fs_save_errors (struct f2fs_sb_info *sbi,unsigned char flag) +void f2fs_save_errors (struct f2fs_sb_info *sbi,unsigned char flag) {spin_lock (&sbi->error_lock);if (!test_bit (flag, (unsigned long *)sbi->errors)) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 308/611 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 309/611 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
@@ -810,6 +810,7 @@ config CRYPTO_DEV_SA2UL select CRYPTO_AES 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 310/611 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 311/611 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 312/611 scsi: libsas: Add sas_ata_device_link_abort()
In reply to Greg Kroah-HartmanFrom: John Garry <[email protected]>
[ Upstream commit 44112922674b94a7d699dfff6307fc830018df7c ]
Similar to how AHCI handles NCQ errors in ahci_error_intr() -> ata_port_abort() -> ata_do_link_abort(), add an NCQ error handler for LLDDs to call to initiate a link abort.
This will mark all outstanding QCs as failed and kick-off EH.
Note:
A "force reset" argument is added for drivers which require the ATA error handling to always reset the device.
A driver may require this feature for when SATA device per-SCSI cmnd resources are only released during reset for ATA EH. As such, we need an option to force reset to be done, regardless of what any EH autopsy decides.
The SATA device FIS fields are set to indicate a device error from ata_eh_analyze_tf().
Stable-dep-of: bb544224da77 ("scsi: hisi_sas: Handle NCQ error when IPTT is valid")
--- drivers/scsi/libsas/sas_ata.c | 15 +++++++++++++++ include/scsi/sas_ata.h | 6 ++++++ 2 files changed, 21 insertions(+)
drivers/scsi/libsas/sas_ata.c +15 -0
@@ -886,6 +886,21 @@ void sas_ata_wait_eh(struct domain_device *dev)ata_port_wait_eh (ap); } +void sas_ata_device_link_abort (struct domain_device *device,bool force_reset) +{ +struct ata_port *ap = device->sata_dev.ap; +struct ata_link *link = &ap->link; + + device->sata_dev.fis[2 ] =ATA_ERR |ATA_DRDY ;/* tf status */ + device->sata_dev.fis[3 ] =ATA_ABORTED ;/* tf error */ + + link->eh_info.err_mask |=AC_ERR_DEV ; +if (force_reset) + link->eh_info.action |=ATA_EH_RESET ; +ata_link_abort (link); +} +EXPORT_SYMBOL_GPL (sas_ata_device_link_abort); +int sas_execute_ata_cmd (struct domain_device *device,u8 *fis,int force_phy_id) {struct sas_tmf_task tmf_task = {};
include/scsi/sas_ata.h +6 -0
@@ -32,6 +32,7 @@ void sas_probe_sata(struct asd_sas_port *port);void sas_suspend_sata (struct asd_sas_port *port);void sas_resume_sata (struct asd_sas_port *port);void sas_ata_end_eh (struct ata_port *ap); +void sas_ata_device_link_abort (struct domain_device *dev,bool force_reset);int sas_execute_ata_cmd (struct domain_device *device,u8 *fis,int force_phy_id);int sas_ata_wait_after_reset (struct domain_device *dev,unsigned long deadline);
@@ -88,6 +89,11 @@ static inline void sas_ata_end_eh(struct ata_port *ap) { } +static inline void sas_ata_device_link_abort (struct domain_device *dev, +bool force_reset) +{ +} +static inline int sas_execute_ata_cmd (struct domain_device *device,u8 *fis,int force_phy_id) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 313/611 scsi: hisi_sas: Handle NCQ error when IPTT is valid
In reply to Greg Kroah-HartmanFrom: Xingui Yang <[email protected]>
[ Upstream commit bb544224da77b96b2c11a13872bf91ede1e015be ]
If an NCQ error occurs when the IPTT is valid and slot->abort flag is set in completion path, sas_task_abort() will be called to abort only one NCQ command now, and the host would be set to SHOST_RECOVERY state. But this may not kick-off EH Immediately until other outstanding QCs timeouts. As a result, the host may remain in the SHOST_RECOVERY state for up to 30 seconds, such as follows:
[7972317.645234] hisi_sas_v3_hw 0000:74:04.0: erroneous completion iptt=3264 task=00000000466116b8 dev id=2 sas_addr=0x5000000000000502 CQ hdr: 0x1883 0x20cc0 0x40000 0x20420000 Error info: 0x0 0x0 0x200000 0x0 [7972341.508264] sas: Enter sas_scsi_recover_host busy: 32 failed: 32 [7972341.984731] sas: --- Exit sas_scsi_recover_host: busy: 0 failed: 32 tries: 1
All NCQ commands that are in the queue should be aborted when an NCQ error occurs in this scenario.
--- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 6 +++++- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 6 +++++- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +5 -1
@@ -1258,7 +1258,11 @@ static void slot_complete_v1_hw(struct hisi_hba *hisi_hba,slot_err_v1_hw (hisi_hba, task, slot);if (unlikely (slot->abort)) { -sas_task_abort (task); +if (dev_is_sata (device) && task->ata_task.use_ncq) +sas_ata_device_link_abort (device, true); +else +sas_task_abort (task); +return ; } goto out;
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +5 -1
@@ -2404,7 +2404,11 @@ static void slot_complete_v2_hw(struct hisi_hba *hisi_hba, error_info[2], error_info[3]);if (unlikely (slot->abort)) { -sas_task_abort (task); +if (dev_is_sata (device) && task->ata_task.use_ncq) +sas_ata_device_link_abort (device, true); +else +sas_task_abort (task); +return ; } goto out;
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +5 -1
@@ -2293,7 +2293,11 @@ static void slot_complete_v3_hw(struct hisi_hba *hisi_hba, error_info[0 ], error_info[1 ], error_info[2], error_info[3]);if (unlikely (slot->abort)) { -sas_task_abort (task); +if (dev_is_sata (device) && task->ata_task.use_ncq) +sas_ata_device_link_abort (device, true); +else +sas_task_abort (task); +return ; } goto out;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 314/611 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 const struct ieee80211_tpt_blink rt2x00_tpt_blink[] = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 315/611 f2fs: fix iostat lock protection
In reply to Greg Kroah-HartmanFrom: Qilin Tan <[email protected]>
[ Upstream commit 144f1cd40bf91fb3ac1d41806470756ce774f389 ]
Made iostat lock irq safe to avoid potentinal deadlock.
Deadlock scenario:f2fs_attr_store
-> f2fs_sbi_store
-> _sbi_store
-> spin_lock(sbi->iostat_lock)
<interrupt request>
-> scsi_end_request
-> bio_endio
-> f2fs_dio_read_end_io
-> f2fs_update_iostat
-> spin_lock_irqsave(sbi->iostat_lock) ===> Dead lock here--- fs/f2fs/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/sysfs.c +2 -2
@@ -550,9 +550,9 @@ static ssize_t __sbi_store(struct f2fs_attr *a,if (!strcmp (a->attr.name,"iostat_period_ms" )) {if (t <MIN_IOSTAT_PERIOD_MS || t >MAX_IOSTAT_PERIOD_MS )return -EINVAL ; -spin_lock (&sbi->iostat_lock); +spin_lock_irq (&sbi->iostat_lock); sbi->iostat_period_ms = (unsigned int )t; -spin_unlock (&sbi->iostat_lock); +spin_unlock_irq (&sbi->iostat_lock);return count; }#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 316/611 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 317/611 selftests: xsk: Use correct UMEM size in testapp_invalid_desc
In reply to Greg Kroah-HartmanFrom: Kal Conley <[email protected]>
[ Upstream commit 7a2050df244e2c9a4e90882052b7907450ad10ed ]
Avoid UMEM_SIZE macro in testapp_invalid_desc which is incorrect when the frame size is not XSK_UMEM__DEFAULT_FRAME_SIZE. Also remove the macro since it's no longer being used.
--- tools/testing/selftests/bpf/xskxceiver.c | 9 +++++---- tools/testing/selftests/bpf/xskxceiver.h | 1 - 2 files changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/bpf/xskxceiver.c +5 -4
@@ -1661,6 +1661,7 @@ static void testapp_single_pkt(struct test_spec *test)static void testapp_invalid_desc (struct test_spec *test) { +u64 umem_size = test->ifobj_tx->umem->num_frames * test->ifobj_tx->umem->frame_size;struct pkt pkts[] = {/* Zero packet address allowed */ {0 ,PKT_SIZE ,0 , true},
@@ -1671,9 +1672,9 @@ static void testapp_invalid_desc(struct test_spec *test)/* Packet too large */ {0x2000, XSK_UMEM__INVALID_FRAME_SIZE, 0, false},/* After umem ends */ - {UMEM_SIZE, PKT_SIZE, 0, false}, + {umem_size, PKT_SIZE, 0, false},/* Straddle the end of umem */ - {UMEM_SIZE - PKT_SIZE / 2, PKT_SIZE, 0, false}, + {umem_size - PKT_SIZE / 2, PKT_SIZE, 0, false},/* Straddle a page boundrary */ {0x3000 - PKT_SIZE / 2, PKT_SIZE, 0, false}, /* Straddle a 2K boundrary */
@@ -1691,8 +1692,8 @@ static void testapp_invalid_desc(struct test_spec *test) }if (test->ifobj_tx->shared_umem) { - pkts[4 ].addr +=UMEM_SIZE ; - pkts[5 ].addr +=UMEM_SIZE ; + pkts[4 ].addr += umem_size; + pkts[5 ].addr += umem_size; }pkt_stream_generate_custom (test, pkts,ARRAY_SIZE (pkts));
tools/testing/selftests/bpf/xskxceiver.h +0 -1
@@ -52,7 +52,6 @@#define THREAD_TMOUT 3#define DEFAULT_PKT_CNT (4 * 1024)#define DEFAULT_UMEM_BUFFERS (DEFAULT_PKT_CNT / 4) -#define UMEM_SIZE (DEFAULT_UMEM_BUFFERS * XSK_UMEM__DEFAULT_FRAME_SIZE)#define RX_FULL_RXQSIZE 32#define UMEM_HEADROOM_TEST_SIZE 128#define XSK_UMEM__INVALID_FRAME_SIZE (XSK_UMEM__DEFAULT_FRAME_SIZE + 1)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 318/611 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
@@ -118,6 +118,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 319/611 selftests: xsk: Deflakify STATS_RX_DROPPED test
In reply to Greg Kroah-HartmanFrom: Kal Conley <[email protected]>
[ Upstream commit 68e7322142f5e731af222892d384d311835db0f1 ]
Fix flaky STATS_RX_DROPPED test. The receiver calls getsockopt after receiving the last (valid) packet which is not the final packet sent in the test (valid and invalid packets are sent in alternating fashion with the final packet being invalid). Since the last packet may or may not have been dropped already, both outcomes must be allowed.
This issue could also be fixed by making sure the last packet sent is valid. This alternative is left as an exercise to the reader (or the benevolent maintainers of this file).
This problem was quite visible on certain setups. On one machine this failure was observed 50% of the time.
Also, remove a redundant assignment of pkt_stream->nb_pkts. This field is already initialized by __pkt_stream_alloc.
--- tools/testing/selftests/bpf/xskxceiver.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/xskxceiver.c +8 -2
@@ -649,7 +649,6 @@ static struct pkt_stream *pkt_stream_generate(struct xsk_umem_info *umem, u32 nbif (!pkt_stream)exit_with_error (ENOMEM ); - pkt_stream->nb_pkts = nb_pkts;for (i =0 ; i < nb_pkts; i++) {pkt_set (umem, &pkt_stream->pkts[i], (i % umem->num_frames) * umem->frame_size, pkt_len);
@@ -1141,7 +1140,14 @@ static int validate_rx_dropped(struct ifobject *ifobject)if (err)return TEST_FAILURE ; -if (stats.rx_dropped == ifobject->pkt_stream->nb_pkts /2 ) +/* The receiver calls getsockopt after receiving the last (valid) +* packet which is not the final packet sent in this test (valid and +* invalid packets are sent in alternating fashion with the final +* packet being invalid). Since the last packet may or may not have +* been dropped already, both outcomes must be allowed. +*/ +if (stats.rx_dropped == ifobject->pkt_stream->nb_pkts /2 || + stats.rx_dropped == ifobject->pkt_stream->nb_pkts /2 -1 )return TEST_PASS ;return TEST_FAILURE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 320/611 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 321/611 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
@@ -370,8 +370,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 322/611 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
@@ -1546,7 +1546,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 323/611 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
@@ -175,13 +175,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
@@ -161,6 +161,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 324/611 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
@@ -858,6 +858,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;
@@ -2886,7 +2888,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 325/611 wifi: iwlwifi: fix duplicate entry in iwl_dev_info_table
In reply to Greg Kroah-HartmanFrom: Gregory Greenman <[email protected]>
[ Upstream commit fc3c2f0ed86b65dff4b6844c59c597b977cae533 ]
There're two identical entries for ax1650 device in iwl_dev_info_table. Remove one of the duplicate entries.
--- drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/pcie/drv.c +0 -1
@@ -565,7 +565,6 @@ static const struct iwl_dev_info iwl_dev_info_table[] = {IWL_DEV_INFO (0x43F0 ,0x1652 , killer1650i_2ax_cfg_qu_b0_hr_b0, iwl_ax201_killer_1650i_name),IWL_DEV_INFO (0x43F0 ,0x2074 , iwl_ax201_cfg_qu_hr,NULL ),IWL_DEV_INFO (0x43F0 ,0x4070 , iwl_ax201_cfg_qu_hr,NULL ), -IWL_DEV_INFO (0x43F0 ,0x1651 , killer1650s_2ax_cfg_qu_b0_hr_b0, iwl_ax201_killer_1650s_name),IWL_DEV_INFO (0xA0F0 ,0x0070 , iwl_ax201_cfg_qu_hr,NULL ),IWL_DEV_INFO (0xA0F0 ,0x0074 , iwl_ax201_cfg_qu_hr,NULL ), IWL_DEV_INFO(0xA0F0, 0x0078, iwl_ax201_cfg_qu_hr, NULL),
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 326/611 bpf/btf: Fix is_int_ptr()
In reply to Greg Kroah-HartmanFrom: Feng Zhou <[email protected]>
[ Upstream commit 91f2dc6838c19342f7f2993627c622835cc24890 ]
When tracing a kernel function with arg type is u32*, btf_ctx_access() would report error: arg2 type INT is not a struct.
The commit bb6728d75611 ("bpf: Allow access to int pointer arguments in tracing programs") added support for int pointer, but did not skip modifiers before checking it's type. This patch fixes it.
--- kernel/bpf/btf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/bpf/btf.c +2 -6
@@ -5333,12 +5333,8 @@ struct btf *bpf_prog_get_target_btf(const struct bpf_prog *prog)static bool is_int_ptr (struct btf *btf,const struct btf_type *t) { -/* t comes in already as a pointer */ - t =btf_type_by_id (btf, t->type); - -/* allow const */ -if (BTF_INFO_KIND (t->info) ==BTF_KIND_CONST ) - t =btf_type_by_id (btf, t->type); +/* skip modifiers */ + t =btf_type_skip_modifiers (btf, t->type,NULL );return btf_type_is_int (t); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 327/611 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
@@ -11971,7 +11971,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; } }
@@ -11989,7 +11989,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; }
@@ -12014,9 +12014,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 328/611 net: ethernet: stmmac: dwmac-rk: rework optional clock handling
In reply to Greg Kroah-HartmanFrom: Sebastian Reichel <[email protected]>
[ Upstream commit ea449f7fa0bf3fcd02e04a770b9ff707bf5e8f96 ]
The clock requesting code is quite repetitive. Fix this by requesting the clocks via devm_clk_bulk_get_optional. The optional variant has been used, since this is effectively what the old code did. The exact clocks required depend on the platform and configuration. As a side effect this change adds correct -EPROBE_DEFER handling.
--- .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 183 +++++++----------- 1 file changed, 70 insertions(+), 113 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +70 -113
@@ -39,6 +39,24 @@ struct rk_gmac_ops {u32 regs[]; }; +static const char *const rk_clocks[] = { +"aclk_mac" ,"pclk_mac" ,"mac_clk_tx" ,"clk_mac_speed" , +}; + +static const char *const rk_rmii_clocks[] = { +"mac_clk_rx" ,"clk_mac_ref" ,"clk_mac_refout" , +}; + +enum rk_clocks_index { +RK_ACLK_MAC =0 , +RK_PCLK_MAC , +RK_MAC_CLK_TX , +RK_CLK_MAC_SPEED , +RK_MAC_CLK_RX , +RK_CLK_MAC_REF , +RK_CLK_MAC_REFOUT , +}; +struct rk_priv_data {struct platform_device *pdev;phy_interface_t phy_iface;
@@ -51,15 +69,9 @@ struct rk_priv_data {bool clock_input;bool integrated_phy; +struct clk_bulk_data *clks; +int num_clks;struct clk *clk_mac; -struct clk *gmac_clkin; -struct clk *mac_clk_rx; -struct clk *mac_clk_tx; -struct clk *clk_mac_ref; -struct clk *clk_mac_refout; -struct clk *clk_mac_speed; -struct clk *aclk_mac; -struct clk *pclk_mac;struct clk *clk_phy;struct reset_control *phy_reset;
@@ -104,10 +116,11 @@ static void px30_set_to_rmii(struct rk_priv_data *bsp_priv)static void px30_set_rmii_speed (struct rk_priv_data *bsp_priv,int speed) { +struct clk *clk_mac_speed = bsp_priv->clks[RK_CLK_MAC_SPEED ].clk;struct device *dev = &bsp_priv->pdev->dev;int ret; -if (IS_ERR (bsp_priv->clk_mac_speed)) { +if (!clk_mac_speed) {dev_err (dev,"%s: Missing clk_mac_speed clock\n" , __func__);return ; }
@@ -116,7 +129,7 @@ static void px30_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)regmap_write (bsp_priv->grf,PX30_GRF_GMAC_CON1 ,PX30_GMAC_SPEED_10M ); - ret =clk_set_rate (bsp_priv->clk_mac_speed,2500000 ); + ret =clk_set_rate (clk_mac_speed,2500000 );if (ret)dev_err (dev,"%s: set clk_mac_speed rate 2500000 failed: %d\n" , __func__, ret);
@@ -124,7 +137,7 @@ static void px30_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)regmap_write (bsp_priv->grf,PX30_GRF_GMAC_CON1 ,PX30_GMAC_SPEED_100M ); - ret =clk_set_rate (bsp_priv->clk_mac_speed,25000000 ); + ret =clk_set_rate (clk_mac_speed,25000000 );if (ret)dev_err (dev,"%s: set clk_mac_speed rate 25000000 failed: %d\n" , __func__, ret);
@@ -1066,6 +1079,7 @@ static void rk3568_set_to_rmii(struct rk_priv_data *bsp_priv)static void rk3568_set_gmac_speed (struct rk_priv_data *bsp_priv,int speed) { +struct clk *clk_mac_speed = bsp_priv->clks[RK_CLK_MAC_SPEED ].clk;struct device *dev = &bsp_priv->pdev->dev;unsigned long rate;int ret;
@@ -1085,7 +1099,7 @@ static void rk3568_set_gmac_speed(struct rk_priv_data *bsp_priv, int speed)return ; } - ret =clk_set_rate (bsp_priv->clk_mac_speed, rate); + ret =clk_set_rate (clk_mac_speed, rate);if (ret)dev_err (dev,"%s: set clk_mac_speed rate %ld failed %d\n" , __func__, rate, ret);
@@ -1371,6 +1385,7 @@ static void rv1126_set_to_rmii(struct rk_priv_data *bsp_priv)static void rv1126_set_rgmii_speed (struct rk_priv_data *bsp_priv,int speed) { +struct clk *clk_mac_speed = bsp_priv->clks[RK_CLK_MAC_SPEED ].clk;struct device *dev = &bsp_priv->pdev->dev;unsigned long rate;int ret;
@@ -1390,7 +1405,7 @@ static void rv1126_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed)return ; } - ret =clk_set_rate (bsp_priv->clk_mac_speed, rate); + ret =clk_set_rate (clk_mac_speed, rate);if (ret)dev_err (dev,"%s: set clk_mac_speed rate %ld failed %d\n" , __func__, rate, ret);
@@ -1398,6 +1413,7 @@ static void rv1126_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed)static void rv1126_set_rmii_speed (struct rk_priv_data *bsp_priv,int speed) { +struct clk *clk_mac_speed = bsp_priv->clks[RK_CLK_MAC_SPEED ].clk;struct device *dev = &bsp_priv->pdev->dev;unsigned long rate;int ret;
@@ -1414,7 +1430,7 @@ static void rv1126_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)return ; } - ret =clk_set_rate (bsp_priv->clk_mac_speed, rate); + ret =clk_set_rate (clk_mac_speed, rate);if (ret)dev_err (dev,"%s: set clk_mac_speed rate %ld failed %d\n" , __func__, rate, ret);
@@ -1475,68 +1491,50 @@ static int rk_gmac_clk_init(struct plat_stmmacenet_data *plat) {struct rk_priv_data *bsp_priv = plat->bsp_priv;struct device *dev = &bsp_priv->pdev->dev; -int ret; +int phy_iface = bsp_priv->phy_iface; +int i, j, ret; bsp_priv->clk_enabled = false; - bsp_priv->mac_clk_rx =devm_clk_get (dev,"mac_clk_rx" ); -if (IS_ERR (bsp_priv->mac_clk_rx)) -dev_err (dev,"cannot get clock %s\n" , -"mac_clk_rx" ); - - bsp_priv->mac_clk_tx =devm_clk_get (dev,"mac_clk_tx" ); -if (IS_ERR (bsp_priv->mac_clk_tx)) -dev_err (dev,"cannot get clock %s\n" , -"mac_clk_tx" ); + bsp_priv->num_clks =ARRAY_SIZE (rk_clocks); +if (phy_iface ==PHY_INTERFACE_MODE_RMII ) + bsp_priv->num_clks +=ARRAY_SIZE (rk_rmii_clocks); - bsp_priv->aclk_mac =devm_clk_get (dev,"aclk_mac" ); -if (IS_ERR (bsp_priv->aclk_mac)) -dev_err (dev,"cannot get clock %s\n" , -"aclk_mac" ); + bsp_priv->clks =devm_kcalloc (dev, bsp_priv->num_clks, +sizeof (*bsp_priv->clks),GFP_KERNEL ); +if (!bsp_priv->clks) +return -ENOMEM ; - bsp_priv->pclk_mac =devm_clk_get (dev,"pclk_mac" ); -if (IS_ERR (bsp_priv->pclk_mac)) -dev_err (dev,"cannot get clock %s\n" , -"pclk_mac" ); +for (i =0 ; i <ARRAY_SIZE (rk_clocks); i++) + bsp_priv->clks[i].id = rk_clocks[i]; - bsp_priv->clk_mac =devm_clk_get (dev,"stmmaceth" ); -if (IS_ERR (bsp_priv->clk_mac)) -dev_err (dev,"cannot get clock %s\n" , -"stmmaceth" ); - -if (bsp_priv->phy_iface ==PHY_INTERFACE_MODE_RMII ) { - bsp_priv->clk_mac_ref =devm_clk_get (dev,"clk_mac_ref" ); -if (IS_ERR (bsp_priv->clk_mac_ref)) -dev_err (dev,"cannot get clock %s\n" , -"clk_mac_ref" ); - -if (!bsp_priv->clock_input) { - bsp_priv->clk_mac_refout = -devm_clk_get (dev,"clk_mac_refout" ); -if (IS_ERR (bsp_priv->clk_mac_refout)) -dev_err (dev,"cannot get clock %s\n" , -"clk_mac_refout" ); - } +if (phy_iface ==PHY_INTERFACE_MODE_RMII ) { +for (j =0 ; j <ARRAY_SIZE (rk_rmii_clocks); j++) + bsp_priv->clks[i++].id = rk_rmii_clocks[j]; } - bsp_priv->clk_mac_speed =devm_clk_get (dev,"clk_mac_speed" ); -if (IS_ERR (bsp_priv->clk_mac_speed)) -dev_err (dev,"cannot get clock %s\n" ,"clk_mac_speed" ); + ret =devm_clk_bulk_get_optional (dev, bsp_priv->num_clks, + bsp_priv->clks); +if (ret) +return dev_err_probe (dev, ret,"Failed to get clocks\n" ); + +/* "stmmaceth" will be enabled by the core */ + bsp_priv->clk_mac =devm_clk_get (dev,"stmmaceth" ); + ret =PTR_ERR_OR_ZERO (bsp_priv->clk_mac); +if (ret) +return dev_err_probe (dev, ret,"Cannot get stmmaceth clock\n" );if (bsp_priv->clock_input) {dev_info (dev,"clock input from PHY\n" ); - }else { -if (bsp_priv->phy_iface ==PHY_INTERFACE_MODE_RMII ) -clk_set_rate (bsp_priv->clk_mac,50000000 ); + }else if (phy_iface ==PHY_INTERFACE_MODE_RMII ) { +clk_set_rate (bsp_priv->clk_mac,50000000 ); }if (plat->phy_node && bsp_priv->integrated_phy) { bsp_priv->clk_phy =of_clk_get (plat->phy_node,0 ); -if (IS_ERR (bsp_priv->clk_phy)) { - ret =PTR_ERR (bsp_priv->clk_phy); -dev_err (dev,"Cannot get PHY clock: %d\n" , ret); -return -EINVAL ; - } + ret =PTR_ERR_OR_ZERO (bsp_priv->clk_phy); +if (ret) +return dev_err_probe (dev, ret,"Cannot get PHY clock\n" );clk_set_rate (bsp_priv->clk_phy,50000000 ); }
@@ -1545,77 +1543,36 @@ static int rk_gmac_clk_init(struct plat_stmmacenet_data *plat)static int gmac_clk_enable (struct rk_priv_data *bsp_priv,bool enable) { -int phy_iface = bsp_priv->phy_iface; +int ret;if (enable) {if (!bsp_priv->clk_enabled) { -if (phy_iface ==PHY_INTERFACE_MODE_RMII ) { -if (!IS_ERR (bsp_priv->mac_clk_rx)) -clk_prepare_enable ( - bsp_priv->mac_clk_rx); - -if (!IS_ERR (bsp_priv->clk_mac_ref)) -clk_prepare_enable ( - bsp_priv->clk_mac_ref); - -if (!IS_ERR (bsp_priv->clk_mac_refout)) -clk_prepare_enable ( - bsp_priv->clk_mac_refout); - } - -if (!IS_ERR (bsp_priv->clk_phy)) -clk_prepare_enable (bsp_priv->clk_phy); - -if (!IS_ERR (bsp_priv->aclk_mac)) -clk_prepare_enable (bsp_priv->aclk_mac); - -if (!IS_ERR (bsp_priv->pclk_mac)) -clk_prepare_enable (bsp_priv->pclk_mac); - -if (!IS_ERR (bsp_priv->mac_clk_tx)) -clk_prepare_enable (bsp_priv->mac_clk_tx); + ret =clk_bulk_prepare_enable (bsp_priv->num_clks, + bsp_priv->clks); +if (ret) +return ret; -if (!IS_ERR (bsp_priv->clk_mac_speed)) -clk_prepare_enable (bsp_priv->clk_mac_speed); + ret =clk_prepare_enable (bsp_priv->clk_phy); +if (ret) +return ret;if (bsp_priv->ops && bsp_priv->ops->set_clock_selection) bsp_priv->ops->set_clock_selection (bsp_priv, bsp_priv->clock_input, true); -/** -* if (!IS_ERR(bsp_priv->clk_mac)) -* clk_prepare_enable(bsp_priv->clk_mac); -*/ mdelay (5 ); bsp_priv->clk_enabled = true; } }else {if (bsp_priv->clk_enabled) { -if (phy_iface ==PHY_INTERFACE_MODE_RMII ) { -clk_disable_unprepare (bsp_priv->mac_clk_rx); - -clk_disable_unprepare (bsp_priv->clk_mac_ref); - -clk_disable_unprepare (bsp_priv->clk_mac_refout); - } - +clk_bulk_disable_unprepare (bsp_priv->num_clks, + bsp_priv->clks);clk_disable_unprepare (bsp_priv->clk_phy); -clk_disable_unprepare (bsp_priv->aclk_mac); - -clk_disable_unprepare (bsp_priv->pclk_mac); - -clk_disable_unprepare (bsp_priv->mac_clk_tx); - -clk_disable_unprepare (bsp_priv->clk_mac_speed); -if (bsp_priv->ops && bsp_priv->ops->set_clock_selection) bsp_priv->ops->set_clock_selection (bsp_priv, bsp_priv->clock_input, false); -/** -* if (!IS_ERR(bsp_priv->clk_mac)) -* clk_disable_unprepare(bsp_priv->clk_mac); -*/ + bsp_priv->clk_enabled = false; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 329/611 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
@@ -1586,9 +1586,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)
@@ -1636,14 +1633,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 330/611 wifi: ath11k: fix writing to unintended memory region
In reply to Greg Kroah-HartmanFrom: P Praneesh <[email protected]>
[ Upstream commit 756a7f90878f0866fd2fe167ef37e90b47326b96 ]
While initializing spectral, the magic value is getting written to the invalid memory address leading to random boot-up crash. This occurs due to the incorrect index increment in ath11k_dbring_fill_magic_value function. Fix it by replacing the existing logic with memset32 to ensure there is no invalid memory access.
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.4.0.1-01838-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/dbring.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath11k/dbring.c +6 -6
@@ -26,13 +26,13 @@ int ath11k_dbring_validate_buffer(struct ath11k *ar, void *buffer, u32 size)static void ath11k_dbring_fill_magic_value (struct ath11k *ar,void *buffer,u32 size) { -u32 *temp; -int idx; - - size = size >>2 ; +/* memset32 function fills buffer payload with the ATH11K_DB_MAGIC_VALUE +* and the variable size is expected to be the number of u32 values +* to be stored, not the number of bytes. +*/ + size = size /sizeof (u32); -for (idx =0 , temp = buffer; idx < size; idx++, temp++) - *temp++ =ATH11K_DB_MAGIC_VALUE ; +memset32 (buffer,ATH11K_DB_MAGIC_VALUE , size); } static int ath11k_dbring_bufs_replenish(struct ath11k *ar,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 331/611 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; }
@@ -923,11 +924,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);
@@ -935,7 +937,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 332/611 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 333/611 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
@@ -693,13 +693,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 334/611 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
@@ -706,11 +706,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 335/611 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
@@ -719,13 +719,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 336/611 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
@@ -686,6 +686,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 ))
@@ -709,13 +716,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
@@ -578,7 +578,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 337/611 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
@@ -4769,8 +4769,6 @@ static bool nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)u32 aer_notice_type =nvme_aer_subtype (result);bool requeue = true; -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);
@@ -4806,7 +4804,6 @@ static bool 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); }
@@ -4822,6 +4819,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 : requeue =nvme_handle_aen_notice (ctrl, result);
@@ -4839,7 +4837,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 338/611 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 339/611 selftests/bpf: Use read_perf_max_sample_freq() in perf_event_stackmap
In reply to Greg Kroah-HartmanFrom: Song Liu <[email protected]>
[ Upstream commit de6d014a09bf12a9a8959d60c0a1d4a41d394a89 ]
Currently, perf_event sample period in perf_event_stackmap is set too low that the test fails randomly. Fix this by using the max sample frequency, from read_perf_max_sample_freq().
Move read_perf_max_sample_freq() to testing_helpers.c. Replace the CHECK() with if-printf, as CHECK is not available in testing_helpers.c.
--- .../bpf/prog_tests/perf_event_stackmap.c | 3 ++- .../bpf/prog_tests/stacktrace_build_id_nmi.c | 15 -------------- tools/testing/selftests/bpf/testing_helpers.c | 20 +++++++++++++++++++ tools/testing/selftests/bpf/testing_helpers.h | 2 ++ 4 files changed, 24 insertions(+), 16 deletions(-)
tools/testing/selftests/bpf/prog_tests/perf_event_stackmap.c +2 -1
@@ -63,7 +63,8 @@ void test_perf_event_stackmap(void)PERF_SAMPLE_BRANCH_NO_FLAGS |PERF_SAMPLE_BRANCH_NO_CYCLES | PERF_SAMPLE_BRANCH_CALL_STACK, - .sample_period = 5000, + .freq = 1, + .sample_freq = read_perf_max_sample_freq(), .size = sizeof(struct perf_event_attr), };struct perf_event_stackmap *skel;
tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c +0 -15
@@ -2,21 +2,6 @@#include <test_progs.h> #include "test_stacktrace_build_id.skel.h" -static __u64 read_perf_max_sample_freq (void ) -{ -__u64 sample_freq =5000 ;/* fallback to 5000 on error */ -FILE *f; -__u32 duration =0 ; - - f =fopen ("/proc/sys/kernel/perf_event_max_sample_rate" ,"r" ); -if (f ==NULL ) -return sample_freq; -CHECK (fscanf (f,"%llu" , &sample_freq) !=1 ,"Get max sample rate" , -"return default value: 5000,err %d\n" , -errno); -fclose (f); -return sample_freq; -} -void test_stacktrace_build_id_nmi (void ) {int control_map_fd, stackid_hmap_fd, stackmap_fd;
tools/testing/selftests/bpf/testing_helpers.c +20 -0
@@ -229,3 +229,23 @@ int bpf_test_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,return bpf_prog_load (type,NULL , license, insns, insns_cnt, &opts); } + +__u64 read_perf_max_sample_freq (void ) +{ +__u64 sample_freq =5000 ;/* fallback to 5000 on error */ +FILE *f; + + f =fopen ("/proc/sys/kernel/perf_event_max_sample_rate" ,"r" ); +if (f ==NULL ) { +printf ("Failed to open /proc/sys/kernel/perf_event_max_sample_rate: err %d\n" +"return default value: 5000\n" , -errno); +return sample_freq; + } +if (fscanf (f,"%llu" , &sample_freq) !=1 ) { +printf ("Failed to parse /proc/sys/kernel/perf_event_max_sample_rate: err %d\n" +"return default value: 5000\n" , -errno); + } + +fclose (f); +return sample_freq; +}
tools/testing/selftests/bpf/testing_helpers.h +2 -0
@@ -20,3 +20,5 @@ struct test_filter_set;int parse_test_list (const char *s,struct test_filter_set *test_set,bool is_glob_pattern); + +__u64 read_perf_max_sample_freq (void );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 340/611 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 341/611 blk-mq: dont plug for head insertions in blk_execute_rq_nowait
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 50947d7fe9fa6abe3ddc40769dfb02a51c58edb6 ]
Plugs never insert at head, so don't plug for head insertions.
--- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-mq.c +1 -1
@@ -1313,7 +1313,7 @@ void blk_execute_rq_nowait(struct request *rq, bool at_head)* device, directly accessing the plug instead of using blk_mq_plug() * should not have any consequences. */ -if (current->plug) +if (current->plug && !at_head)blk_add_rq_to_plug (current->plug, rq);else blk_mq_sched_insert_request (rq, at_head, true, false);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 342/611 wifi: iwlwifi: debug: fix crash in __iwl_err()
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 634c7b1bd08ca322537ab389f8cbd7bb543b5e45 ]
In __iwl_err(), if we rate-limit the message away, then vaf.va is still NULL-initialized by the time we get to the tracing code, which then crashes. When it doesn't get rate-limited out, it's still wrong to reuse the old args2 that was already printed, which is why we bother making a copy in the first place.
Assign vaf.va properly to fix this.
--- drivers/net/wireless/intel/iwlwifi/iwl-debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/iwl-debug.c +2 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* -* Copyright (C) 2005-2011, 2021 Intel Corporation +* Copyright (C) 2005-2011, 2021-2022 Intel Corporation */ #include <linux/device.h> #include <linux/interrupt.h>
@@ -57,6 +57,7 @@ void __iwl_err(struct device *dev, enum iwl_err_mode mode, const char *fmt, ...)default :break ; } + vaf.va = &args;trace_iwlwifi_err (&vaf);va_end (args); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 343/611 wifi: iwlwifi: trans: dont trigger d3 interrupt twice
In reply to Greg Kroah-HartmanFrom: Avraham Stern <[email protected]>
[ Upstream commit 277f56a141fc54ef7f9e09dba65fb2e12021411d ]
When the IPC registers are used for sleep control, setting the IPC sleep bit already triggers an interrupt to the fw, so there is no need to also set the doorbell. Setting also the doorbell triggers the sleep interrupt twice which lead to an assert.
--- drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/wireless/intel/iwlwifi/pcie/trans.c +3 -6
@@ -1522,19 +1522,16 @@ static int iwl_pcie_d3_handshake(struct iwl_trans *trans, bool suspend)struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans);int ret; -if (trans->trans_cfg->device_family ==IWL_DEVICE_FAMILY_AX210 ) { +if (trans->trans_cfg->device_family ==IWL_DEVICE_FAMILY_AX210 )iwl_write_umac_prph (trans,UREG_DOORBELL_TO_ISR6 , suspend ?UREG_DOORBELL_TO_ISR6_SUSPEND :UREG_DOORBELL_TO_ISR6_RESUME ); - }else if (trans->trans_cfg->device_family >=IWL_DEVICE_FAMILY_BZ ) { +else if (trans->trans_cfg->device_family >=IWL_DEVICE_FAMILY_BZ )iwl_write32 (trans,CSR_IPC_SLEEP_CONTROL , suspend ?CSR_IPC_SLEEP_CONTROL_SUSPEND :CSR_IPC_SLEEP_CONTROL_RESUME ); -iwl_write_umac_prph (trans,UREG_DOORBELL_TO_ISR6 , -UREG_DOORBELL_TO_ISR6_SLEEP_CTRL ); - }else { +else return 0 ; - } ret =wait_event_timeout (trans_pcie->sx_waitq, trans_pcie->sx_complete,2 *HZ );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 344/611 wifi: iwlwifi: mvm: dont set CHECKSUM_COMPLETE for unsupported protocols
In reply to Greg Kroah-HartmanFrom: Avraham Stern <[email protected]>
[ Upstream commit 217f3c52f00d3419ecdd38a99a7eceecb11679b2 ]
On Bz devices, CHECKSUM_COMPLETE was set for unsupported protocols which results in a warning. Fix it.
--- drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +2 -3
@@ -193,8 +193,7 @@ static int iwl_mvm_create_skb(struct iwl_mvm *mvm, struct sk_buff *skb,* Starting from Bz hardware, it calculates starting directly after * the MAC header, so that matches mac80211's expectation. */ -if (skb->ip_summed ==CHECKSUM_COMPLETE && - mvm->trans->trans_cfg->device_family <IWL_DEVICE_FAMILY_BZ ) { +if (skb->ip_summed ==CHECKSUM_COMPLETE ) {struct {u8 hdr[6 ];__be16 type;
@@ -209,7 +208,7 @@ static int iwl_mvm_create_skb(struct iwl_mvm *mvm, struct sk_buff *skb, shdr->type !=htons (ETH_P_PAE ) && shdr->type != htons(ETH_P_TDLS)))) skb->ip_summed = CHECKSUM_NONE; - else + else if (mvm->trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_BZ) /* mac80211 assumes full CSUM including SNAP header */ skb_postpush_rcsum(skb, shdr, sizeof(*shdr)); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 345/611 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; }
@@ -924,12 +923,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);
@@ -937,7 +935,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 346/611 f2fs: fix to check return value of f2fs_do_truncate_blocks()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit b851ee6ba3cc212641e622ebcf92b950c7bafa07 ]
Otherwise, if truncation on cow_inode failed, remained data may pollute current transaction of atomic write.
--- fs/f2fs/file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/file.c +5 -1
@@ -2115,7 +2115,11 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)clear_inode_flag (fi->cow_inode,FI_INLINE_DATA ); }else {/* Reuse the already created COW inode */ -f2fs_do_truncate_blocks (fi->cow_inode,0 , true); + ret =f2fs_do_truncate_blocks (fi->cow_inode,0 , true); +if (ret) { +f2fs_up_write (&fi->i_gc_rwsem[WRITE ]); + goto out; + } }f2fs_write_inode (inode,NULL );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 347/611 f2fs: fix to check return value of inc_valid_block_count()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 935fc6fa6466cf18dd72dd1518ebc7bfc4cd58a4 ]
In __replace_atomic_write_block(), we missed to check return value of inc_valid_block_count(), for extreme testcase that f2fs image is run out of space, it may cause inconsistent status in between SIT table and total valid block count.
--- fs/f2fs/segment.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +7 -1
@@ -245,10 +245,16 @@ static int __replace_atomic_write_block(struct inode *inode, pgoff_t index, }else {blkcnt_t count =1 ; + err =inc_valid_block_count (sbi, inode, &count); +if (err) { +f2fs_put_dnode (&dn); +return err; + } + *old_addr = dn.data_blkaddr;f2fs_truncate_data_blocks_range (&dn,1 );dec_valid_block_count (sbi,F2FS_I (inode)->cow_inode, count); -inc_valid_block_count (sbi, inode, &count); +f2fs_replace_block (sbi, &dn, dn.data_blkaddr, new_addr, ni.version, true, false); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 348/611 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
@@ -995,11 +995,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; }
@@ -2978,9 +2982,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 349/611 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
@@ -2613,11 +2613,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 ; }
@@ -2626,14 +2637,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 350/611 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
@@ -4015,6 +4015,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 ;
@@ -4097,13 +4111,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); }
@@ -4294,10 +4302,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 ;
@@ -4305,15 +4310,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 351/611 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
@@ -4148,6 +4148,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;
@@ -4160,9 +4163,6 @@ static int raid10_run(struct mddev *mddev) } } - mddev->thread = conf->thread; - conf->thread =NULL ; -if (mddev->queue) {blk_queue_max_write_zeroes_sectors (mddev->queue,0 );blk_queue_io_min (mddev->queue, mddev->chunk_sectors <<9 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 352/611 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
@@ -1248,7 +1248,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_alloc_clone (rdev->bdev, bio, gfp, &mddev->bio_set);
@@ -1578,6 +1579,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 353/611 wifi: iwlwifi: mvm: dont drop unencrypted MCAST frames
In reply to Greg Kroah-HartmanFrom: Ayala Beker <[email protected]>
[ Upstream commit 8e5a26360cbe29b896b6758518280d41c3704d43 ]
MCAST frames are filtered out by the driver if we are not authorized yet.
Fix it to filter out only protected frames.
--- drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/rx.c +3 -2
@@ -384,9 +384,10 @@ void iwl_mvm_rx_rx_mpdu(struct iwl_mvm *mvm, struct napi_struct *napi,* Don't even try to decrypt a MCAST frame that was received * before the managed vif is authorized, we'd fail anyway. */ -if (vif->type ==NL80211_IFTYPE_STATION && +if (is_multicast_ether_addr (hdr->addr1) && + vif->type ==NL80211_IFTYPE_STATION && !mvmvif->authorized && -is_multicast_ether_addr (hdr->addr1)) { +ieee80211_has_protected (hdr->frame_control)) {IWL_DEBUG_DROP (mvm,"MCAST before the vif is authorized\n" );kfree_skb (skb);rcu_read_unlock ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 354/611 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
@@ -1038,7 +1038,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); }
@@ -1562,7 +1562,7 @@ iwl_dump_ini_dbgi_sram_iter(struct iwl_fw_runtime *fwrt, prph_data =iwl_read_prph_no_grab (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 355/611 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
@@ -138,6 +138,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 356/611 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
@@ -563,6 +563,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 357/611 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
@@ -1388,13 +1388,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 358/611 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
@@ -2387,6 +2387,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 359/611 io_uring/rsrc: use nospeced indexes
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ Upstream commit 953c37e066f05a3dca2d74643574b8dfe8a83983 ]
We use array_index_nospec() for registered buffer indexes, but don't use it while poking into rsrc tags, fix that.
--- io_uring/rsrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/rsrc.c +1 -1
@@ -562,7 +562,7 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx, } ctx->user_bufs[i] = imu; - *io_get_tag_slot (ctx->buf_data, offset) = tag; + *io_get_tag_slot (ctx->buf_data, i) = tag; }if (needs_switch)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 360/611 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
@@ -599,7 +599,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" );
@@ -616,6 +615,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 361/611 wifi: mt76: mt7915: expose device tree match table
In reply to Greg Kroah-HartmanFrom: Lorenz Brun <[email protected]>
[ Upstream commit 90fb69212c60e26ef70ed0e8532b116c7649ac88 ]
On MT7986 the WiFi driver currently does not get automatically loaded, requiring manual modprobing because the device tree compatibles are not exported into metadata.
Add the missing MODULE_DEVICE_TABLE macro to fix this.
--- drivers/net/wireless/mediatek/mt76/mt7915/soc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/soc.c +2 -0
@@ -1228,6 +1228,8 @@ static const struct of_device_id mt7986_wmac_of_match[] = { {}, }; +MODULE_DEVICE_TABLE (of, mt7986_wmac_of_match); +struct platform_driver mt7986_wmac_driver = { .driver = { .name ="mt7986-wmac" ,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 362/611 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
@@ -2343,7 +2343,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 ; }
@@ -2353,6 +2353,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 363/611 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
@@ -904,10 +904,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 364/611 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
@@ -90,9 +90,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 365/611 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
@@ -1561,8 +1561,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 ];
@@ -1582,7 +1590,6 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, } 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 366/611 mt76: mt7921: fix kernel panic by accessing unallocated eeprom.data
In reply to Greg Kroah-HartmanFrom: Sean Wang <[email protected]>
[ Upstream commit 12db28c3ef31f719bd18fa186a40bb152e6a527c ]
The MT7921 driver no longer uses eeprom.data, but the relevant code has not been removed completely since
commit 16d98b548365 ("mt76: mt7921: rely on mcu_get_nic_capability"). This could result in potential invalid memory access.
To fix the kernel panic issue in mt7921, it is necessary to avoid accessing unallocated eeprom.data which can lead to invalid memory access.
Furthermore, it is possible to entirely eliminate the mt7921_mcu_parse_eeprom function and solely depend on mt7921_mcu_parse_response to divide the RxD header.
[2.702735] BUG: kernel NULL pointer dereference, address: 0000000000000550 [2.702740] #PF: supervisor write access in kernel mode [2.702741] #PF: error_code(0x0002) - not-present page [2.702743] PGD 0 P4D 0 [2.702747] Oops: 0002 [#1] PREEMPT SMP NOPTI [2.702755] RIP: 0010:mt7921_mcu_parse_response+0x147/0x170 [mt7921_common] [2.702758] RSP: 0018:ffffae7c00fef828 EFLAGS: 00010286 [2.702760] RAX: ffffa367f57be024 RBX: ffffa367cc7bf500 RCX: 0000000000000000 [2.702762] RDX: 0000000000000550 RSI: 0000000000000000 RDI: ffffa367cc7bf500 [2.702763] RBP: ffffae7c00fef840 R08: ffffa367cb167000 R09: 0000000000000005 [2.702764] R10: 0000000000000000 R11: ffffffffc04702e4 R12: ffffa367e8329f40 [2.702766] R13: 0000000000000000 R14: 0000000000000001 R15: ffffa367e8329f40 [2.702768] FS: 000079ee6cf20c40(0000) GS:ffffa36b2f940000(0000) knlGS:0000000000000000 [2.702769] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [2.702775] CR2: 0000000000000550 CR3: 00000001233c6004 CR4: 0000000000770ee0 [2.702776] PKRU: 55555554 [2.702777] Call Trace: [2.702782] mt76_mcu_skb_send_and_get_msg+0xc3/0x11e [mt76 <HASH:1bc4 5>] [2.702785] mt7921_run_firmware+0x241/0x853 [mt7921_common <HASH:6a2f 6>] [2.702789] mt7921e_mcu_init+0x2b/0x56 [mt7921e <HASH:d290 7>] [2.702792] mt7921_register_device+0x2eb/0x5a5 [mt7921_common <HASH:6a2f 6>] [2.702795] ? mt7921_irq_tasklet+0x1d4/0x1d4 [mt7921e <HASH:d290 7>] [2.702797] mt7921_pci_probe+0x2d6/0x319 [mt7921e <HASH:d290 7>] [2.702799] pci_device_probe+0x9f/0x12a
--- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 20 ------------------- 1 file changed, 20 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +0 -20
@@ -16,24 +16,6 @@ static bool mt7921_disable_clc;module_param_named (disable_clc, mt7921_disable_clc, bool,0644 );MODULE_PARM_DESC (disable_clc,"disable CLC support" ); -static int -mt7921_mcu_parse_eeprom (struct mt76_dev *dev,struct sk_buff *skb) -{ -struct mt7921_mcu_eeprom_info *res; -u8 *buf; - -if (!skb) -return -EINVAL ; - -skb_pull (skb,sizeof (struct mt76_connac2_mcu_rxd )); - - res = (struct mt7921_mcu_eeprom_info *)skb->data; - buf = dev->eeprom.data +le32_to_cpu (res->addr); -memcpy (buf, res->data,16 ); - -return 0 ; -} -int mt7921_mcu_parse_response (struct mt76_dev *mdev,int cmd,struct sk_buff *skb,int seq) {
@@ -60,8 +42,6 @@ int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd, }else if (cmd ==MCU_EXT_CMD (THERMAL_CTRL )) {skb_pull (skb,sizeof (*rxd) +4 ); ret =le32_to_cpu (*(__le32 *)skb->data); - }else if (cmd ==MCU_EXT_CMD (EFUSE_ACCESS )) { - ret =mt7921_mcu_parse_eeprom (mdev, skb); } else if (cmd == MCU_UNI_CMD(DEV_INFO_UPDATE) || cmd == MCU_UNI_CMD(BSS_INFO_UPDATE) || cmd == MCU_UNI_CMD(STA_REC_UPDATE) ||
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 367/611 wifi: mt76: mt7921: fix missing unwind goto in `mt7921u_probe`
In reply to Greg Kroah-HartmanFrom: Jiefeng Li <[email protected]>
[ Upstream commit 5c47cdebbaeb7724df6f9f46917c93e53f791547 ]
mt7921u_dma_init can only return zero or negative number according to its definition. When it returns non-zero number, there exists an error and this function should handle this error rather than return directly.
--- drivers/net/wireless/mediatek/mt76/mt7921/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7921/usb.c +1 -1
@@ -252,7 +252,7 @@ static int mt7921u_probe(struct usb_interface *usb_intf, ret =mt7921u_dma_init (dev, false);if (ret) -return ret; + goto error; hw =mt76_hw (dev);/* check hw sg support in order to enable AMSDU */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 368/611 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
@@ -66,22 +66,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 |
@@ -95,6 +79,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 ; }
@@ -301,6 +301,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 369/611 wifi: mt76: mt7921e: stop chip reset worker in unregister hook
In reply to Greg Kroah-HartmanFrom: Quan Zhou <[email protected]>
[ Upstream commit 3d78c46423c6567ed25ca033e086865b1b4d5ae1 ]
If the chip reset worker is triggered during the remove process, the chip DMA may not be properly pushed back to the idle state. This can lead to corruption of the DMA flow due to the chip reset. Therefore, it is necessary to stop the chip reset before the DMA is finalized.
To avoid resetting the chip after the reset worker is cancelled, use __mt7921_mcu_drv_pmctrl() instead of mt7921_mcu_drv_pmctrl(). It is safe to ignore the pm mutex because the pm worker and wake worker have already been cancelled.
--- drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +2 -1
@@ -111,9 +111,10 @@ static void mt7921e_unregister_device(struct mt7921_dev *dev)napi_disable (&dev->mt76.napi[i]);cancel_delayed_work_sync (&pm->ps_work);cancel_work_sync (&pm->wake_work); +cancel_work_sync (&dev->reset_work);mt7921_tx_token_put (dev); -mt7921_mcu_drv_pmctrl (dev); +__mt7921_mcu_drv_pmctrl (dev);mt7921_dma_cleanup (dev);mt7921_wfsys_reset (dev);skb_queue_purge (&dev->mt76.mcu.res_q);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 370/611 wifi: mt76: connac: fix txd multicast rate setting
In reply to Greg Kroah-HartmanFrom: Ryder Lee <[email protected]>
[ Upstream commit 3d2892e05086d09aecf14ea64b2debbf495e313c ]
The vif->bss_conf.mcast_rate should be applied to multicast data frame only.
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +2 -1
@@ -539,7 +539,8 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,if (txwi[2 ] &cpu_to_le32 (MT_TXD2_FIX_RATE )) {/* Fixed rata is available just for 802.11 txd */ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; -bool multicast =is_multicast_ether_addr (hdr->addr1); +bool multicast =ieee80211_is_data (hdr->frame_control) && +is_multicast_ether_addr (hdr->addr1);u16 rate =mt76_connac2_mac_tx_rate_val (mphy, vif, beacon, multicast);u32 val =MT_TXD6_FIXED_BW ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 371/611 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
@@ -1745,6 +1745,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 ;
@@ -1821,6 +1826,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 372/611 netfilter: conntrack: restore IPS_CONFIRMED out of nf_conntrack_hash_check_insert()
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 2cdaa3eefed83082923cf219c8b6a314e622da74 ]
e6d57e9ff0ae ("netfilter: conntrack: fix rmmod double-free race") consolidates IPS_CONFIRMED bit set in nf_conntrack_hash_check_insert(). However, this breaks ctnetlink:
# conntrack -I -p tcp --timeout 123 --src 1.2.3.4 --dst 5.6.7.8 --state ESTABLISHED --sport 1 --dport 4 -u SEEN_REPLY conntrack v1.4.6 (conntrack-tools): Operation failed: Device or resource busy
This is a partial revert of the aforementioned commit to restore IPS_CONFIRMED.
--- net/netfilter/nf_conntrack_bpf.c | 1 + net/netfilter/nf_conntrack_core.c | 1 - net/netfilter/nf_conntrack_netlink.c | 3 +++ 3 files changed, 4 insertions(+), 1 deletion(-)
net/netfilter/nf_conntrack_bpf.c +1 -0
@@ -384,6 +384,7 @@ struct nf_conn *bpf_ct_insert_entry(struct nf_conn___init *nfct_i)struct nf_conn *nfct = (struct nf_conn *)nfct_i;int err; + nfct->status |=IPS_CONFIRMED ; err =nf_conntrack_hash_check_insert (nfct);if (err <0 ) {nf_conntrack_free (nfct);
net/netfilter/nf_conntrack_core.c +0 -1
@@ -938,7 +938,6 @@ nf_conntrack_hash_check_insert(struct nf_conn *ct) goto out; } - ct->status |=IPS_CONFIRMED ;smp_wmb ();/* The caller holds a reference to this object */ refcount_set (&ct->ct_general.use,2 );
net/netfilter/nf_conntrack_netlink.c +3 -0
@@ -2316,6 +2316,9 @@ ctnetlink_create_conntrack(struct net *net,nfct_seqadj_ext_add (ct);nfct_synproxy_ext_add (ct); +/* we must add conntrack extensions before confirmation. */ + ct->status |=IPS_CONFIRMED ; +if (cda[CTA_STATUS ]) { err =ctnetlink_change_status (ct, cda);if (err <0 )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 373/611 netfilter: conntrack: fix wrong ct->timeout value
In reply to Greg Kroah-HartmanFrom: Tzung-Bi Shih <[email protected]>
[ Upstream commit 73db1b8f2bb6725b7391e85aab41fdf592b3c0c1 ]
(struct nf_conn)->timeout is an interval before the conntrack confirmed. After confirmed, it becomes a timestamp.
It is observed that timeout of an unconfirmed conntrack:
- Set by calling ctnetlink_change_timeout(). As a result, nfct_time_stamp was wrongly added to ct->timeout twice.
- Get by calling ctnetlink_dump_timeout(). As a result, nfct_time_stamp was wrongly subtracted.
Call Trace: <TASK> dump_stack_lvl ctnetlink_dump_timeout __ctnetlink_glue_build ctnetlink_glue_build __nfqnl_enqueue_packet nf_queue nf_hook_slow ip_mc_output ? __pfx_ip_finish_output ip_send_skb ? __pfx_dst_output udp_send_skb udp_sendmsg ? __pfx_ip_generic_getfrag sock_sendmsg
Separate the 2 cases in:
- Setting ct->timeout in __nf_ct_set_timeout().
- Getting ct->timeout in ctnetlink_dump_timeout().
Pablo appends:
Update ctnetlink to set up the timeout _after_ the IPS_CONFIRMED flag is set on, otherwise conntrack creation via ctnetlink breaks.
Note that the problem described in this patch occurs since the introduction of the nfnetlink_queue conntrack support, select a sufficiently old Fixes: tag for -stable kernel to pick up this fix.
--- include/net/netfilter/nf_conntrack_core.h | 6 +++++- net/netfilter/nf_conntrack_netlink.c | 13 +++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-)
include/net/netfilter/nf_conntrack_core.h +5 -1
@@ -90,7 +90,11 @@ static inline void __nf_ct_set_timeout(struct nf_conn *ct, u64 timeout) {if (timeout >INT_MAX ) timeout =INT_MAX ; -WRITE_ONCE (ct->timeout, nfct_time_stamp + (u32 )timeout); + +if (nf_ct_is_confirmed (ct)) +WRITE_ONCE (ct->timeout, nfct_time_stamp + (u32 )timeout); +else + ct->timeout = (u32 )timeout; }int __nf_ct_change_timeout (struct nf_conn *ct,u64 cta_timeout);
net/netfilter/nf_conntrack_netlink.c +9 -4
@@ -176,7 +176,12 @@ static int ctnetlink_dump_status(struct sk_buff *skb, const struct nf_conn *ct)static int ctnetlink_dump_timeout (struct sk_buff *skb,const struct nf_conn *ct,bool skip_zero) { -long timeout =nf_ct_expires (ct) /HZ ; +long timeout; + +if (nf_ct_is_confirmed (ct)) + timeout =nf_ct_expires (ct) /HZ ; +else + timeout = ct->timeout /HZ ;if (skip_zero && timeout ==0 )return 0 ;
@@ -2253,9 +2258,6 @@ ctnetlink_create_conntrack(struct net *net,if (!cda[CTA_TIMEOUT ]) goto err1; - timeout = (u64 )ntohl (nla_get_be32 (cda[CTA_TIMEOUT ])) *HZ ; -__nf_ct_set_timeout (ct, timeout); -rcu_read_lock ();if (cda[CTA_HELP ]) {char *helpname =NULL ;
@@ -2319,6 +2321,9 @@ ctnetlink_create_conntrack(struct net *net,/* we must add conntrack extensions before confirmation. */ ct->status |=IPS_CONFIRMED ; + timeout = (u64 )ntohl (nla_get_be32 (cda[CTA_TIMEOUT ])) *HZ ; +__nf_ct_set_timeout (ct, timeout); +if (cda[CTA_STATUS ]) { err =ctnetlink_change_status (ct, cda);if (err <0 )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 374/611 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 375/611 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
@@ -3100,8 +3100,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 376/611 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
@@ -2634,6 +2634,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) {
@@ -2642,7 +2650,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 :
@@ -3044,14 +3053,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 377/611 net/mlx5e: Dont clone flow post action attributes second time
In reply to Greg Kroah-HartmanFrom: Vlad Buslov <[email protected]>
[ Upstream commit e9fce818fe003b6c527f25517b9ac08eb4661b5d ]
The code already clones post action attributes in mlx5e_clone_flow_attr_for_post_act(). Creating another copy in mlx5e_tc_post_act_add() is a erroneous leftover from original implementation. Instead, assign handle->attribute to post_attr provided by the caller. Note that cloning the attribute second time is not just wasteful but also causes issues like second copy not being properly updated in neigh update code which leads to following use-after-free:
Feb 21 09:02:00 c-237-177-40-045 kernel: BUG: KASAN: use-after-free in mlx5_cmd_set_fte+0x200d/0x24c0 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_report+0xbb/0x1a0 Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_save_stack+0x1e/0x40 Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_set_track+0x21/0x30 Feb 21 09:02:00 c-237-177-40-045 kernel: __kasan_kmalloc+0x7a/0x90 Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_save_stack+0x1e/0x40 Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_set_track+0x21/0x30 Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_save_free_info+0x2a/0x40 Feb 21 09:02:00 c-237-177-40-045 kernel: ____kasan_slab_free+0x11a/0x1b0 Feb 21 09:02:00 c-237-177-40-045 kernel: page dumped because: kasan: bad access detected Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5_core 0000:08:00.0: mlx5_cmd_out_err:803:(pid 8833): SET_FLOW_TABLE_ENTRY(0x936) op_mod(0x0) failed, status bad resource state(0x9), syndrome (0xf2ff71), err(-22) Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5_core 0000:08:00.0 enp8s0f0: Failed to add post action rule Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5_core 0000:08:00.0: mlx5e_tc_encap_flows_add:190:(pid 8833): Failed to update flow post acts, -22 Feb 21 09:02:00 c-237-177-40-045 kernel: Call Trace: Feb 21 09:02:00 c-237-177-40-045 kernel: <TASK> Feb 21 09:02:00 c-237-177-40-045 kernel: dump_stack_lvl+0x57/0x7d Feb 21 09:02:00 c-237-177-40-045 kernel: print_report+0x170/0x471 Feb 21 09:02:00 c-237-177-40-045 kernel: ? mlx5_cmd_set_fte+0x200d/0x24c0 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_report+0xbb/0x1a0 Feb 21 09:02:00 c-237-177-40-045 kernel: ? mlx5_cmd_set_fte+0x200d/0x24c0 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5_cmd_set_fte+0x200d/0x24c0 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: ? __module_address.part.0+0x62/0x200 Feb 21 09:02:00 c-237-177-40-045 kernel: ? mlx5_cmd_stub_create_flow_table+0xd0/0xd0 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: ? __raw_spin_lock_init+0x3b/0x110 Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5_cmd_create_fte+0x80/0xb0 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: add_rule_fg+0xe80/0x19c0 [mlx5_core] -- Feb 21 09:02:00 c-237-177-40-045 kernel: Allocated by task 13476: Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_save_stack+0x1e/0x40 Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_set_track+0x21/0x30 Feb 21 09:02:00 c-237-177-40-045 kernel: __kasan_kmalloc+0x7a/0x90 Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5_packet_reformat_alloc+0x7b/0x230 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5e_tc_tun_create_header_ipv4+0x977/0xf10 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5e_attach_encap+0x15b4/0x1e10 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: post_process_attr+0x305/0xa30 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5e_tc_add_fdb_flow+0x4c0/0xcf0 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: __mlx5e_add_fdb_flow+0x7cf/0xe90 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5e_configure_flower+0xcaa/0x4b90 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5e_rep_setup_tc_cls_flower+0x99/0x1b0 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5e_rep_setup_tc_cb+0x133/0x1e0 [mlx5_core] -- Feb 21 09:02:00 c-237-177-40-045 kernel: Freed by task 8833: Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_save_stack+0x1e/0x40 Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_set_track+0x21/0x30 Feb 21 09:02:00 c-237-177-40-045 kernel: kasan_save_free_info+0x2a/0x40 Feb 21 09:02:00 c-237-177-40-045 kernel: ____kasan_slab_free+0x11a/0x1b0 Feb 21 09:02:00 c-237-177-40-045 kernel: __kmem_cache_free+0x1de/0x400 Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5_packet_reformat_dealloc+0xad/0x100 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5e_tc_encap_flows_del+0x3c0/0x500 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5e_rep_update_flows+0x40c/0xa80 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: mlx5e_rep_neigh_update+0x473/0x7a0 [mlx5_core] Feb 21 09:02:00 c-237-177-40-045 kernel: process_one_work+0x7c2/0x1310 Feb 21 09:02:00 c-237-177-40-045 kernel: worker_thread+0x59d/0xec0 Feb 21 09:02:00 c-237-177-40-045 kernel: kthread+0x28f/0x330
--- .../net/ethernet/mellanox/mlx5/core/en/tc/post_act.c | 11 ++--------- .../net/ethernet/mellanox/mlx5/core/en/tc/post_act.h | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c +2 -9
@@ -106,22 +106,17 @@ mlx5e_tc_post_act_offload(struct mlx5e_post_act *post_act, }struct mlx5e_post_act_handle * -mlx5e_tc_post_act_add (struct mlx5e_post_act *post_act,struct mlx5_flow_attr *attr) +mlx5e_tc_post_act_add (struct mlx5e_post_act *post_act,struct mlx5_flow_attr *post_attr) { -u32 attr_sz =ns_to_attr_sz (post_act->ns_type);struct mlx5e_post_act_handle *handle; -struct mlx5_flow_attr *post_attr;int err; handle =kzalloc (sizeof (*handle),GFP_KERNEL ); - post_attr =mlx5_alloc_flow_attr (post_act->ns_type); -if (!handle || !post_attr) { -kfree (post_attr); +if (!handle) {kfree (handle);return ERR_PTR (-ENOMEM ); } -memcpy (post_attr, attr, attr_sz); post_attr->chain =0 ; post_attr->prio =0 ; post_attr->ft = post_act->ft;
@@ -145,7 +140,6 @@ mlx5e_tc_post_act_add(struct mlx5e_post_act *post_act, struct mlx5_flow_attr *atreturn handle; err_xarray: -kfree (post_attr);kfree (handle);return ERR_PTR (err); }
@@ -164,7 +158,6 @@ mlx5e_tc_post_act_del(struct mlx5e_post_act *post_act, struct mlx5e_post_act_hanif (!IS_ERR_OR_NULL (handle->rule))mlx5e_tc_post_act_unoffload (post_act, handle);xa_erase (&post_act->ids, handle->id); -kfree (handle->attr);kfree (handle); }
drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.h +1 -1
@@ -19,7 +19,7 @@ void mlx5e_tc_post_act_destroy(struct mlx5e_post_act *post_act);struct mlx5e_post_act_handle * -mlx5e_tc_post_act_add (struct mlx5e_post_act *post_act,struct mlx5_flow_attr *attr); +mlx5e_tc_post_act_add (struct mlx5e_post_act *post_act,struct mlx5_flow_attr *post_attr);void mlx5e_tc_post_act_del (struct mlx5e_post_act *post_act,struct mlx5e_post_act_handle *handle);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 378/611 net/mlx5: E-switch, Create per vport table based on devlink encap mode
In reply to Greg Kroah-HartmanFrom: Chris Mi <[email protected]>
[ Upstream commit fd745f4c0abe41ebb09d11bf622b054a0f3e7b49 ]
Currently when creating per vport table, create flags are hardcoded. Devlink encap mode is set based on user input and HW capability. Create per vport table based on devlink encap mode.
--- .../net/ethernet/mellanox/mlx5/core/en/tc/sample.c | 4 ++-- .../net/ethernet/mellanox/mlx5/core/esw/vporttbl.c | 12 +++++++++++- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 2 +- .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c +2 -2
@@ -14,10 +14,10 @@#define MLX5_ESW_VPORT_TBL_SIZE_SAMPLE (64 * 1024) -static const struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_sample_ns = { +static struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_sample_ns = { .max_fte =MLX5_ESW_VPORT_TBL_SIZE_SAMPLE , .max_num_groups =0 ,/* default num of groups */ - .flags =MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT |MLX5_FLOW_TABLE_TUNNEL_EN_DECAP , + .flags =0 , };struct mlx5e_tc_psample {
drivers/net/ethernet/mellanox/mlx5/core/esw/vporttbl.c +11 -1
@@ -11,7 +11,7 @@ struct mlx5_vport_key {u16 prio;u16 vport;u16 vhca_id; -const struct esw_vport_tbl_namespace *vport_ns; +struct esw_vport_tbl_namespace *vport_ns; } __packed;struct mlx5_vport_table {
@@ -21,6 +21,14 @@ struct mlx5_vport_table {struct mlx5_vport_key key; }; +static void +esw_vport_tbl_init (struct mlx5_eswitch *esw,struct esw_vport_tbl_namespace *ns) +{ +if (esw->offloads.encap !=DEVLINK_ESWITCH_ENCAP_MODE_NONE ) + ns->flags |= (MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT | +MLX5_FLOW_TABLE_TUNNEL_EN_DECAP ); +} +static struct mlx5_flow_table *esw_vport_tbl_create (struct mlx5_eswitch *esw,struct mlx5_flow_namespace *ns,const struct esw_vport_tbl_namespace *vport_ns)
@@ -80,6 +88,7 @@ mlx5_esw_vporttbl_get(struct mlx5_eswitch *esw, struct mlx5_vport_tbl_attr *attru32 hkey;mutex_lock (&esw->fdb_table.offloads.vports.lock); +esw_vport_tbl_init (esw, attr->vport_ns); hkey =flow_attr_to_vport_key (esw, attr, &skey); e =esw_vport_tbl_lookup (esw, &skey, hkey);if (e) {
@@ -127,6 +136,7 @@ mlx5_esw_vporttbl_put(struct mlx5_eswitch *esw, struct mlx5_vport_tbl_attr *attru32 hkey;mutex_lock (&esw->fdb_table.offloads.vports.lock); +esw_vport_tbl_init (esw, attr->vport_ns); hkey =flow_attr_to_vport_key (esw, attr, &key); e =esw_vport_tbl_lookup (esw, &key, hkey);if (!e || --e->num_rules)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -1
@@ -668,7 +668,7 @@ struct mlx5_vport_tbl_attr {u32 chain;u16 prio;u16 vport; -const struct esw_vport_tbl_namespace *vport_ns; +struct esw_vport_tbl_namespace *vport_ns; }; struct mlx5_flow_table *
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +1 -1
@@ -72,7 +72,7 @@#define MLX5_ESW_FT_OFFLOADS_DROP_RULE (1) -static const struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_mirror_ns = { +static struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_mirror_ns = { .max_fte =MLX5_ESW_VPORT_TBL_SIZE , .max_num_groups =MLX5_ESW_VPORT_TBL_NUM_GROUPS , .flags =0 ,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 379/611 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
@@ -733,7 +733,6 @@ mlx5_eswitch_add_fwd_rule(struct mlx5_eswitch *esw,kfree (dest);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 );
@@ -776,7 +775,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 380/611 net/mlx5e: Fix error flow in representor failing to add vport rx rule
In reply to Greg Kroah-HartmanFrom: Roi Dayan <[email protected]>
[ Upstream commit 0a6b069cc60d68d33b4f6e7dd7f1adc3ec749766 ]
On representor init rx error flow the flow steering pointer is being released so mlx5e_attach_netdev() doesn't have a valid fs pointer in its error flow. Make sure the pointer is nullified when released and add a check in mlx5e_fs_cleanup() to verify fs is not null as representor cleanup callback would be called anyway.
--- drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 2 ++ 3 files changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +2 -0
@@ -1471,6 +1471,8 @@ struct mlx5e_flow_steering *mlx5e_fs_init(const struct mlx5e_profile *profile,void mlx5e_fs_cleanup (struct mlx5e_flow_steering *fs) { +if (!fs) +return ;mlx5e_fs_ethtool_free (fs);mlx5e_fs_tc_free (fs);mlx5e_fs_vlan_free (fs);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -0
@@ -5201,6 +5201,7 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)mlx5e_ktls_cleanup (priv);mlx5e_ipsec_cleanup (priv);mlx5e_fs_cleanup (priv->fs); + priv->fs =NULL ; }static int mlx5e_init_nic_rx (struct mlx5e_priv *priv)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 -0
@@ -783,6 +783,7 @@ static void mlx5e_cleanup_rep(struct mlx5e_priv *priv) {mlx5e_fs_cleanup (priv->fs);mlx5e_ipsec_cleanup (priv); + priv->fs =NULL ; }static int mlx5e_create_rep_ttc_table (struct mlx5e_priv *priv)
@@ -949,6 +950,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) priv->rx_res =NULL ; err_free_fs:mlx5e_fs_cleanup (priv->fs); + priv->fs =NULL ;return err; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 381/611 net/mlx5: Remove "recovery" arg from mlx5_load_one() function
In reply to Greg Kroah-HartmanFrom: Jiri Pirko <[email protected]>
[ Upstream commit 5977ac3910f1cbaf44dca48179118b25c206ac29 ]
mlx5_load_one() is always called with recovery==false, so remove the unneeded function arg.
Stable-dep-of: dfad99750c0f ("net/mlx5: Use recovery timeout on sync reset flow")
--- drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/main.c | 9 ++++----- drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +1 -1
@@ -154,7 +154,7 @@ static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev)if (mlx5_health_wait_pci_up (dev))mlx5_core_err (dev,"reset reload flow aborted, PCI reads still not working\n" );else -mlx5_load_one (dev, false); +mlx5_load_one (dev);devlink_remote_reload_actions_performed (priv_to_devlink (dev),0 ,BIT (DEVLINK_RELOAD_ACTION_DRIVER_REINIT ) |BIT (DEVLINK_RELOAD_ACTION_FW_ACTIVATE ));
drivers/net/ethernet/mellanox/mlx5/core/main.c +4 -5
@@ -1484,13 +1484,13 @@ int mlx5_load_one_devl_locked(struct mlx5_core_dev *dev, bool recovery)return err; } -int mlx5_load_one (struct mlx5_core_dev *dev,bool recovery) +int mlx5_load_one (struct mlx5_core_dev *dev) {struct devlink *devlink =priv_to_devlink (dev);int ret;devl_lock (devlink); - ret =mlx5_load_one_devl_locked (dev, recovery); + ret =mlx5_load_one_devl_locked (dev, false);devl_unlock (devlink);return ret; }
@@ -1875,8 +1875,7 @@ static void mlx5_pci_resume(struct pci_dev *pdev)mlx5_pci_trace (dev,"Enter, loading driver..\n" ); - err =mlx5_load_one (dev, false); - + err =mlx5_load_one (dev);if (!err)devlink_health_reporter_state_update (dev->priv.health.fw_fatal_reporter,DEVLINK_HEALTH_REPORTER_STATE_HEALTHY );
@@ -1967,7 +1966,7 @@ static int mlx5_resume(struct pci_dev *pdev) {struct mlx5_core_dev *dev =pci_get_drvdata (pdev); -return mlx5_load_one (dev, false); +return mlx5_load_one (dev); }static const struct pci_device_id mlx5_core_pci_table[] = {
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +1 -1
@@ -321,7 +321,7 @@ int mlx5_init_one(struct mlx5_core_dev *dev);void mlx5_uninit_one (struct mlx5_core_dev *dev);void mlx5_unload_one (struct mlx5_core_dev *dev);void mlx5_unload_one_devl_locked (struct mlx5_core_dev *dev); -int mlx5_load_one (struct mlx5_core_dev *dev,bool recovery); +int mlx5_load_one (struct mlx5_core_dev *dev);int mlx5_load_one_devl_locked (struct mlx5_core_dev *dev,bool recovery);int mlx5_vport_get_other_func_cap (struct mlx5_core_dev *dev,u16 function_id,void *out);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 382/611 net/mlx5: Suspend auxiliary devices only in case of PCI device suspend
In reply to Greg Kroah-HartmanFrom: Jiri Pirko <[email protected]>
[ Upstream commit 72ed5d5624af384eaf74d84915810d54486a75e2 ]
The original behavior introduced by commit c6acd629eec7 ("net/mlx5e: Add support for devlink-port in non-representors mode") correctly re-instantiated uplink devlink port and related netdevice during devlink reload. However with migration to auxiliary devices, this behaviour changed.
Restore the original behaviour and tear down auxiliary devices completely during devlink reload.
Stable-dep-of: dfad99750c0f ("net/mlx5: Use recovery timeout on sync reset flow")
--- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 4 ++-- .../net/ethernet/mellanox/mlx5/core/devlink.c | 4 ++-- .../net/ethernet/mellanox/mlx5/core/fw_reset.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/health.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/main.c | 16 ++++++++-------- .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 6 +++--- .../ethernet/mellanox/mlx5/core/sf/dev/driver.c | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/dev.c +2 -2
@@ -396,7 +396,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)return ret; } -void mlx5_detach_device (struct mlx5_core_dev *dev) +void mlx5_detach_device (struct mlx5_core_dev *dev,bool suspend) {struct mlx5_priv *priv = &dev->priv;struct auxiliary_device *adev;
@@ -426,7 +426,7 @@ void mlx5_detach_device(struct mlx5_core_dev *dev) adrv =to_auxiliary_drv (adev->dev.driver); -if (adrv->suspend) { +if (adrv->suspend && suspend) { adrv->suspend (adev, pm);continue ; }
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +2 -2
@@ -108,7 +108,7 @@ static int mlx5_devlink_reload_fw_activate(struct devlink *devlink, struct netliif (err)return err; -mlx5_unload_one_devl_locked (dev); +mlx5_unload_one_devl_locked (dev, true); err =mlx5_health_wait_pci_up (dev);if (err)NL_SET_ERR_MSG_MOD (extack,"FW activate aborted, PCI reads fail after reset" );
@@ -166,7 +166,7 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,switch (action) {case DEVLINK_RELOAD_ACTION_DRIVER_REINIT : -mlx5_unload_one_devl_locked (dev); +mlx5_unload_one_devl_locked (dev, false);break ;case DEVLINK_RELOAD_ACTION_FW_ACTIVATE :if (limit ==DEVLINK_RELOAD_LIMIT_NO_RESET )
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +2 -2
@@ -150,7 +150,7 @@ static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev)if (test_bit (MLX5_FW_RESET_FLAGS_PENDING_COMP , &fw_reset->reset_flags)) {complete (&fw_reset->done); }else { -mlx5_unload_one (dev); +mlx5_unload_one (dev, false);if (mlx5_health_wait_pci_up (dev))mlx5_core_err (dev,"reset reload flow aborted, PCI reads still not working\n" );else
@@ -484,7 +484,7 @@ int mlx5_fw_reset_wait_reset_done(struct mlx5_core_dev *dev) } err = fw_reset->ret;if (test_and_clear_bit (MLX5_FW_RESET_FLAGS_RELOAD_REQUIRED , &fw_reset->reset_flags)) { -mlx5_unload_one_devl_locked (dev); +mlx5_unload_one_devl_locked (dev, false);mlx5_load_one_devl_locked (dev, false); } out:
drivers/net/ethernet/mellanox/mlx5/core/health.c +1 -1
@@ -699,7 +699,7 @@ static void mlx5_fw_fatal_reporter_err_work(struct work_struct *work)* requests from the kernel. */ mlx5_core_err (dev,"Driver is in error state. Unloading\n" ); -mlx5_unload_one (dev); +mlx5_unload_one (dev, false); } }
drivers/net/ethernet/mellanox/mlx5/core/main.c +8 -8
@@ -1495,12 +1495,12 @@ int mlx5_load_one(struct mlx5_core_dev *dev)return ret; } -void mlx5_unload_one_devl_locked (struct mlx5_core_dev *dev) +void mlx5_unload_one_devl_locked (struct mlx5_core_dev *dev,bool suspend) {devl_assert_locked (priv_to_devlink (dev));mutex_lock (&dev->intf_state_mutex); -mlx5_detach_device (dev); +mlx5_detach_device (dev, suspend);if (!test_bit (MLX5_INTERFACE_STATE_UP , &dev->intf_state)) { mlx5_core_warn(dev, "%s: interface is down, NOP\n",
@@ -1515,12 +1515,12 @@ void mlx5_unload_one_devl_locked(struct mlx5_core_dev *dev)mutex_unlock (&dev->intf_state_mutex); } -void mlx5_unload_one (struct mlx5_core_dev *dev) +void mlx5_unload_one (struct mlx5_core_dev *dev,bool suspend) {struct devlink *devlink =priv_to_devlink (dev);devl_lock (devlink); -mlx5_unload_one_devl_locked (dev); +mlx5_unload_one_devl_locked (dev, suspend);devl_unlock (devlink); }
@@ -1793,7 +1793,7 @@ static pci_ers_result_t mlx5_pci_err_detected(struct pci_dev *pdev,mlx5_enter_error_state (dev, false);mlx5_error_sw_reset (dev); -mlx5_unload_one (dev); +mlx5_unload_one (dev, true);mlx5_drain_health_wq (dev);mlx5_pci_disable_device (dev);
@@ -1949,7 +1949,7 @@ static void shutdown(struct pci_dev *pdev)set_bit (MLX5_BREAK_FW_WAIT , &dev->intf_state); err =mlx5_try_fast_unload (dev);if (err) -mlx5_unload_one (dev); +mlx5_unload_one (dev, false);mlx5_pci_disable_device (dev); }
@@ -1957,7 +1957,7 @@ static int mlx5_suspend(struct pci_dev *pdev, pm_message_t state) {struct mlx5_core_dev *dev =pci_get_drvdata (pdev); -mlx5_unload_one (dev); +mlx5_unload_one (dev, true);return 0 ; }
@@ -2000,7 +2000,7 @@ MODULE_DEVICE_TABLE(pci, mlx5_core_pci_table);void mlx5_disable_device (struct mlx5_core_dev *dev) {mlx5_error_sw_reset (dev); -mlx5_unload_one_devl_locked (dev); +mlx5_unload_one_devl_locked (dev, false); }int mlx5_recover_device (struct mlx5_core_dev *dev)
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +3 -3
@@ -236,7 +236,7 @@ void mlx5_adev_cleanup(struct mlx5_core_dev *dev);int mlx5_adev_init (struct mlx5_core_dev *dev);int mlx5_attach_device (struct mlx5_core_dev *dev); -void mlx5_detach_device (struct mlx5_core_dev *dev); +void mlx5_detach_device (struct mlx5_core_dev *dev,bool suspend);int mlx5_register_device (struct mlx5_core_dev *dev);void mlx5_unregister_device (struct mlx5_core_dev *dev);struct mlx5_core_dev *mlx5_get_next_phys_dev_lag (struct mlx5_core_dev *dev);
@@ -319,8 +319,8 @@ int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx);void mlx5_mdev_uninit (struct mlx5_core_dev *dev);int mlx5_init_one (struct mlx5_core_dev *dev);void mlx5_uninit_one (struct mlx5_core_dev *dev); -void mlx5_unload_one (struct mlx5_core_dev *dev); -void mlx5_unload_one_devl_locked (struct mlx5_core_dev *dev); +void mlx5_unload_one (struct mlx5_core_dev *dev,bool suspend); +void mlx5_unload_one_devl_locked (struct mlx5_core_dev *dev,bool suspend);int mlx5_load_one (struct mlx5_core_dev *dev);int mlx5_load_one_devl_locked (struct mlx5_core_dev *dev,bool recovery);
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c +1 -1
@@ -74,7 +74,7 @@ static void mlx5_sf_dev_shutdown(struct auxiliary_device *adev) { struct mlx5_sf_dev *sf_dev = container_of(adev, struct mlx5_sf_dev, adev); -mlx5_unload_one (sf_dev->mdev); +mlx5_unload_one (sf_dev->mdev, false); }static const struct auxiliary_device_id mlx5_sf_dev_id_table[] = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 383/611 Revert "net/mlx5: Remove "recovery" arg from mlx5_load_one() function"
In reply to Greg Kroah-HartmanFrom: Moshe Shemesh <[email protected]>
[ Upstream commit 21608a2cf38e9f743636b5f86507ffbca18ecee7 ]
This reverts commit 5977ac3910f1cbaf44dca48179118b25c206ac29.
Revert this patch as we need the "recovery" arg back in mlx5_load_one() function. This arg will be used in the next patch for using recovery timeout during sync reset flow.
Stable-dep-of: dfad99750c0f ("net/mlx5: Use recovery timeout on sync reset flow")
--- drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/main.c | 9 +++++---- drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +1 -1
@@ -154,7 +154,7 @@ static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev)if (mlx5_health_wait_pci_up (dev))mlx5_core_err (dev,"reset reload flow aborted, PCI reads still not working\n" );else -mlx5_load_one (dev); +mlx5_load_one (dev, false);devlink_remote_reload_actions_performed (priv_to_devlink (dev),0 ,BIT (DEVLINK_RELOAD_ACTION_DRIVER_REINIT ) |BIT (DEVLINK_RELOAD_ACTION_FW_ACTIVATE ));
drivers/net/ethernet/mellanox/mlx5/core/main.c +5 -4
@@ -1484,13 +1484,13 @@ int mlx5_load_one_devl_locked(struct mlx5_core_dev *dev, bool recovery)return err; } -int mlx5_load_one (struct mlx5_core_dev *dev) +int mlx5_load_one (struct mlx5_core_dev *dev,bool recovery) {struct devlink *devlink =priv_to_devlink (dev);int ret;devl_lock (devlink); - ret =mlx5_load_one_devl_locked (dev, false); + ret =mlx5_load_one_devl_locked (dev, recovery);devl_unlock (devlink);return ret; }
@@ -1875,7 +1875,8 @@ static void mlx5_pci_resume(struct pci_dev *pdev)mlx5_pci_trace (dev,"Enter, loading driver..\n" ); - err =mlx5_load_one (dev); + err =mlx5_load_one (dev, false); +if (!err)devlink_health_reporter_state_update (dev->priv.health.fw_fatal_reporter,DEVLINK_HEALTH_REPORTER_STATE_HEALTHY );
@@ -1966,7 +1967,7 @@ static int mlx5_resume(struct pci_dev *pdev) {struct mlx5_core_dev *dev =pci_get_drvdata (pdev); -return mlx5_load_one (dev); +return mlx5_load_one (dev, false); }static const struct pci_device_id mlx5_core_pci_table[] = {
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +1 -1
@@ -321,7 +321,7 @@ int mlx5_init_one(struct mlx5_core_dev *dev);void mlx5_uninit_one (struct mlx5_core_dev *dev);void mlx5_unload_one (struct mlx5_core_dev *dev,bool suspend);void mlx5_unload_one_devl_locked (struct mlx5_core_dev *dev,bool suspend); -int mlx5_load_one (struct mlx5_core_dev *dev); +int mlx5_load_one (struct mlx5_core_dev *dev,bool recovery);int mlx5_load_one_devl_locked (struct mlx5_core_dev *dev,bool recovery);int mlx5_vport_get_other_func_cap (struct mlx5_core_dev *dev,u16 function_id,void *out);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 384/611 net/mlx5: Use recovery timeout on sync reset flow
In reply to Greg Kroah-HartmanFrom: Moshe Shemesh <[email protected]>
[ Upstream commit dfad99750c0f83b0242572a573afa2c055f85b36 ]
Use the same timeout for sync reset flow and health recovery flow, since the former involves driver's recovery from firmware reset, which is similar to health recovery. Otherwise, in some cases, such as a firmware upgrade on the DPU, the firmware pre-init bit may not be ready within current timeout and the driver will abort loading back after reset.
--- drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +1 -1
@@ -200,7 +200,7 @@ static int mlx5_devlink_reload_up(struct devlink *devlink, enum devlink_reload_abreak ;/* On fw_activate action, also driver is reloaded and reinit performed */ *actions_performed |=BIT (DEVLINK_RELOAD_ACTION_DRIVER_REINIT ); - ret =mlx5_load_one_devl_locked (dev, false); + ret =mlx5_load_one_devl_locked (dev, true);break ;default :/* Unsupported action should not get to this function */
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +2 -2
@@ -154,7 +154,7 @@ static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev)if (mlx5_health_wait_pci_up (dev))mlx5_core_err (dev,"reset reload flow aborted, PCI reads still not working\n" );else -mlx5_load_one (dev, false); +mlx5_load_one (dev, true);devlink_remote_reload_actions_performed (priv_to_devlink (dev),0 ,BIT (DEVLINK_RELOAD_ACTION_DRIVER_REINIT ) |BIT (DEVLINK_RELOAD_ACTION_FW_ACTIVATE ));
@@ -485,7 +485,7 @@ int mlx5_fw_reset_wait_reset_done(struct mlx5_core_dev *dev) err = fw_reset->ret;if (test_and_clear_bit (MLX5_FW_RESET_FLAGS_RELOAD_REQUIRED , &fw_reset->reset_flags)) {mlx5_unload_one_devl_locked (dev, false); -mlx5_load_one_devl_locked (dev, false); +mlx5_load_one_devl_locked (dev, true); } out:clear_bit (MLX5_FW_RESET_FLAGS_PENDING_COMP , &fw_reset->reset_flags);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 385/611 net/mlx5e: Nullify table pointer when failing to create
In reply to Greg Kroah-HartmanFrom: Aya Levin <[email protected]>
[ Upstream commit 1b540decd03acd736693aabb6cb46c71fca38ae6 ]
On failing to create promisc flow steering table, the pointer is returned with an error. Nullify it so unloading the driver won't try to destroy a non existing table.
Failing to create promisc table may happen over BF devices when the ARM side is going through a firmware tear down. The host side start a reload flow. While the driver unloads, it tries to remove the promisc table. Remove WARN in this state as it is a valid error flow.
--- drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +2 -1
@@ -776,6 +776,7 @@ static int mlx5e_create_promisc_table(struct mlx5e_flow_steering *fs) ft->t =mlx5_create_auto_grouped_flow_table (fs->ns, &ft_attr);if (IS_ERR (ft->t)) { err =PTR_ERR (ft->t); + ft->t =NULL ;fs_err (fs,"fail to create promisc table err=%d\n" , err);return err; }
@@ -803,7 +804,7 @@ static void mlx5e_del_promisc_rule(struct mlx5e_flow_steering *fs)static void mlx5e_destroy_promisc_table (struct mlx5e_flow_steering *fs) { -if (WARN (!fs->promisc.ft.t,"Trying to remove non-existing promiscuous table" )) +if (!fs->promisc.ft.t)return ;mlx5e_del_promisc_rule (fs);mlx5_destroy_flow_table (fs->promisc.ft.t);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 386/611 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
@@ -6346,6 +6346,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;
@@ -6353,16 +6357,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 387/611 bpf: Fix race between btf_put and btf_idr walk.
In reply to Greg Kroah-HartmanFrom: Alexei Starovoitov <[email protected]>
[ Upstream commit acf1c3d68e9a31f10d92bc67ad4673cdae5e8d92 ]
Florian and Eduard reported hard dead lock:
[ 58.433327] _raw_spin_lock_irqsave+0x40/0x50 [ 58.433334] btf_put+0x43/0x90 [ 58.433338] bpf_find_btf_id+0x157/0x240 [ 58.433353] btf_parse_fields+0x921/0x11c0
This happens since btf->refcount can be 1 at the time of btf_put() and btf_put() will call btf_free_id() which will try to grab btf_idr_lock and will dead lock.
Avoid the issue by doing btf_put() without locking.
--- kernel/bpf/btf.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/bpf/btf.c +3 -5
@@ -572,8 +572,8 @@ static s32 bpf_find_btf_id(const char *name, u32 kind, struct btf **btf_p) *btf_p = btf;return ret; } -spin_lock_bh (&btf_idr_lock);btf_put (btf); +spin_lock_bh (&btf_idr_lock); }spin_unlock_bh (&btf_idr_lock);return ret;
@@ -7957,12 +7957,10 @@ bpf_core_find_cands(struct bpf_core_ctx *ctx, u32 local_type_id)btf_get (mod_btf);spin_unlock_bh (&btf_idr_lock); cands =bpf_core_add_cands (cands, mod_btf,btf_nr_types (main_btf)); -if (IS_ERR (cands)) { -btf_put (mod_btf); +btf_put (mod_btf); +if (IS_ERR (cands))return ERR_CAST (cands); - }spin_lock_bh (&btf_idr_lock); -btf_put (mod_btf); }spin_unlock_bh (&btf_idr_lock);/* cands is a pointer to kmalloced memory here if cands->cnt > 0
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 388/611 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
@@ -1921,14 +1921,17 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level,if (ret <0 ) goto out; -if (ctx.optlen > max_optlen || ctx.optlen <0 ) { +if (optval && (ctx.optlen > max_optlen || ctx.optlen <0 )) { ret = -EFAULT ; goto out; }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 389/611 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
@@ -8517,6 +8517,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 ; }
@@ -9437,11 +9439,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) {
@@ -9475,7 +9472,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
@@ -590,8 +590,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 390/611 net: dpaa: Fix uninitialized variable in dpaa_stop()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 461bb5b97049a149278f2c27a3aa12af16da6a2e ]
The return value is not initialized on the success path.
--- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +2 -1
@@ -283,7 +283,8 @@ static int dpaa_stop(struct net_device *net_dev) {struct mac_device *mac_dev;struct dpaa_priv *priv; -int i, err, error; +int i, error; +int err =0 ; priv =netdev_priv (net_dev); mac_dev = priv->mac_dev;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 391/611 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 ++++- .../tc-testing/tc-tests/qdiscs/fq.json | 22 +++++++++++++++++++ 2 files changed, 27 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 },
tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq.json +22 -0
@@ -114,6 +114,28 @@ "$IP link del dev $DUMMY type dummy" ] }, + { + "id": "10f7", + "name": "Create FQ with invalid initial_quantum setting", + "category": [ + "qdisc", + "fq" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$IP link add dev $DUMMY type dummy || /bin/true" + ], + "cmdUnderTest": "$TC qdisc add dev $DUMMY handle 1: root fq initial_quantum 0x80000000", + "expExitCode": "2", + "verifyCmd": "$TC qdisc show dev $DUMMY", + "matchPattern": "qdisc fq 1: root.*initial_quantum 2048Mb", + "matchCount": "0", + "teardown": [ + "$IP link del dev $DUMMY type dummy" + ] + }, { "id": "9398", "name": "Create FQ with maxrate setting",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 392/611 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
@@ -1570,9 +1570,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 393/611 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
@@ -354,7 +354,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 394/611 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
@@ -1731,7 +1731,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 ;
@@ -1743,39 +1744,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))
@@ -1792,40 +1771,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 395/611 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
@@ -651,7 +651,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 396/611 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
@@ -4972,6 +4972,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 397/611 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
@@ -162,7 +162,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 398/611 ASoC: cs35l41: Only disable internal boost
In reply to Greg Kroah-HartmanFrom: Lucas Tanure <[email protected]>
[ Upstream commit 4658de99d43cd740e019e7fd124b4128f8f4027f ]
In error situations, only the internal boost case should be disabled and re-enabled.
Also, for other boost cases re-enabling the boost to the default internal boost config is incorrect.
--- sound/soc/codecs/cs35l41.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
sound/soc/codecs/cs35l41.c +19 -15
@@ -356,6 +356,19 @@ static const struct snd_kcontrol_new cs35l41_aud_controls[] = { WM_ADSP_FW_CONTROL("DSP1", 0), }; +static void cs35l41_boost_enable (struct cs35l41_private *cs35l41,unsigned int enable) +{ +switch (cs35l41->hw_cfg.bst_type) { +case CS35L41_INT_BOOST : + enable = enable ?CS35L41_BST_EN_DEFAULT :CS35L41_BST_DIS_FET_OFF ; +regmap_update_bits (cs35l41->regmap,CS35L41_PWR_CTRL2 ,CS35L41_BST_EN_MASK , + enable <<CS35L41_BST_EN_SHIFT ); +break ; +default : +break ; + } +} +static irqreturn_t cs35l41_irq (int irq,void *data) {struct cs35l41_private *cs35l41 = data;
@@ -431,8 +444,7 @@ static irqreturn_t cs35l41_irq(int irq, void *data)if (status[0 ] &CS35L41_BST_OVP_ERR ) {dev_crit_ratelimited (cs35l41->dev,"VBST Over Voltage error\n" ); -regmap_update_bits (cs35l41->regmap,CS35L41_PWR_CTRL2 , -CS35L41_BST_EN_MASK ,0 ); +cs35l41_boost_enable (cs35l41,0 );regmap_write (cs35l41->regmap,CS35L41_IRQ1_STATUS1 ,CS35L41_BST_OVP_ERR );regmap_write (cs35l41->regmap,CS35L41_PROTECT_REL_ERR_IGN ,0 );
@@ -441,16 +453,13 @@ static irqreturn_t cs35l41_irq(int irq, void *data) CS35L41_BST_OVP_ERR_RLS);regmap_update_bits (cs35l41->regmap,CS35L41_PROTECT_REL_ERR_IGN ,CS35L41_BST_OVP_ERR_RLS ,0 ); -regmap_update_bits (cs35l41->regmap,CS35L41_PWR_CTRL2 , -CS35L41_BST_EN_MASK , -CS35L41_BST_EN_DEFAULT <<CS35L41_BST_EN_SHIFT ); +cs35l41_boost_enable (cs35l41,1 ); ret =IRQ_HANDLED ; }if (status[0 ] &CS35L41_BST_DCM_UVP_ERR ) {dev_crit_ratelimited (cs35l41->dev,"DCM VBST Under Voltage Error\n" ); -regmap_update_bits (cs35l41->regmap,CS35L41_PWR_CTRL2 , -CS35L41_BST_EN_MASK ,0 ); +cs35l41_boost_enable (cs35l41,0 );regmap_write (cs35l41->regmap,CS35L41_IRQ1_STATUS1 ,CS35L41_BST_DCM_UVP_ERR );regmap_write (cs35l41->regmap,CS35L41_PROTECT_REL_ERR_IGN ,0 );
@@ -459,16 +468,13 @@ static irqreturn_t cs35l41_irq(int irq, void *data) CS35L41_BST_UVP_ERR_RLS);regmap_update_bits (cs35l41->regmap,CS35L41_PROTECT_REL_ERR_IGN ,CS35L41_BST_UVP_ERR_RLS ,0 ); -regmap_update_bits (cs35l41->regmap,CS35L41_PWR_CTRL2 , -CS35L41_BST_EN_MASK , -CS35L41_BST_EN_DEFAULT <<CS35L41_BST_EN_SHIFT ); +cs35l41_boost_enable (cs35l41,1 ); ret =IRQ_HANDLED ; }if (status[0 ] &CS35L41_BST_SHORT_ERR ) {dev_crit_ratelimited (cs35l41->dev,"LBST error: powering off!\n" ); -regmap_update_bits (cs35l41->regmap,CS35L41_PWR_CTRL2 , -CS35L41_BST_EN_MASK ,0 ); +cs35l41_boost_enable (cs35l41,0 );regmap_write (cs35l41->regmap,CS35L41_IRQ1_STATUS1 ,CS35L41_BST_SHORT_ERR );regmap_write (cs35l41->regmap,CS35L41_PROTECT_REL_ERR_IGN ,0 );
@@ -477,9 +483,7 @@ static irqreturn_t cs35l41_irq(int irq, void *data) CS35L41_BST_SHORT_ERR_RLS);regmap_update_bits (cs35l41->regmap,CS35L41_PROTECT_REL_ERR_IGN ,CS35L41_BST_SHORT_ERR_RLS ,0 ); -regmap_update_bits (cs35l41->regmap,CS35L41_PWR_CTRL2 , -CS35L41_BST_EN_MASK , -CS35L41_BST_EN_DEFAULT <<CS35L41_BST_EN_SHIFT ); +cs35l41_boost_enable (cs35l41,1 ); ret =IRQ_HANDLED ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 399/611 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
@@ -1549,7 +1549,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 ) {
@@ -1577,7 +1577,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 400/611 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
@@ -1590,11 +1590,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 401/611 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 402/611 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 403/611 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
@@ -4252,15 +4252,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 404/611 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
@@ -690,8 +690,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 405/611 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 406/611 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 407/611 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
@@ -1016,14 +1016,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;
@@ -1031,7 +1033,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 " );
@@ -1118,7 +1121,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; }
@@ -1130,7 +1135,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 408/611 spi: atmel-quadspi: Dont leak clk enable count in pm resume
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit c18bbac353ffed50be134b0a2a059a2bd540c503 ]
The pm resume call is supposed to enable two clocks. If the second enable fails the callback reports failure but doesn't undo the first enable.
So call clk_disable() for the first clock when clk_enable() for the second one fails.
--- drivers/spi/atmel-quadspi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/spi/atmel-quadspi.c +5 -1
@@ -752,7 +752,11 @@ static int __maybe_unused atmel_qspi_runtime_resume(struct device *dev)if (ret)return ret; -return clk_enable (aq->qspick); + ret =clk_enable (aq->qspick); +if (ret) +clk_disable (aq->pclk); + +return ret; }static const struct dev_pm_ops __maybe_unused atmel_qspi_pm_ops = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 409/611 spi: atmel-quadspi: Free resources even if runtime resume failed in .remove()
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 9448bc1dee65f86c0fe64d9dea8b410af0586886 ]
An early error exit in atmel_qspi_remove() doesn't prevent the device unbind. So this results in an spi controller with an unbound parent and unmapped register space (because devm_ioremap_resource() is undone). So using the remaining spi controller probably results in an oops.
Instead unregister the controller unconditionally and only skip hardware access and clk disable.
Also add a warning about resume failing and return zero unconditionally. The latter has the only effect to suppress a less helpful error message by the spi core.
--- drivers/spi/atmel-quadspi.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/spi/atmel-quadspi.c +17 -7
@@ -672,18 +672,28 @@ static int atmel_qspi_remove(struct platform_device *pdev)struct atmel_qspi *aq =spi_controller_get_devdata (ctrl);int ret; - ret =pm_runtime_resume_and_get (&pdev->dev); -if (ret <0 ) -return ret; -spi_unregister_controller (ctrl); -atmel_qspi_write (QSPI_CR_QSPIDIS , aq,QSPI_CR ); + + ret =pm_runtime_get_sync (&pdev->dev); +if (ret >=0 ) { +atmel_qspi_write (QSPI_CR_QSPIDIS , aq,QSPI_CR ); +clk_disable (aq->qspick); +clk_disable (aq->pclk); + }else { +/* +* atmel_qspi_runtime_{suspend,resume} just disable and enable +* the two clks respectively. So after resume failed these are +* off, and we skip hardware access and disabling these clks again. +*/ +dev_warn (&pdev->dev,"Failed to resume device on remove\n" ); + } + +clk_unprepare (aq->qspick); +clk_unprepare (aq->pclk);pm_runtime_disable (&pdev->dev);pm_runtime_put_noidle (&pdev->dev); -clk_disable_unprepare (aq->qspick); -clk_disable_unprepare (aq->pclk);return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 410/611 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
@@ -1864,13 +1864,11 @@ static int spi_imx_remove(struct platform_device *pdev)spi_unregister_controller (controller); - 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