ath10k: Check tx_stats before use it
Subsystems (41)
Sasha Levin
maintainerPATCH 157/249 rtlwifi: rtl8192cu: fix error handle when usb probe failed
In reply to Sasha LevinFrom: Ping-Ke Shih <[email protected]>
[ Upstream commit 6c0ed66f1a5b84e2a812c7c2d6571a5621bf3396 ]
rtl_usb_probe() must do error handle rtl_deinit_core() only if rtl_init_core() is done, otherwise goto error_out2.
| usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 | rtl_usb: reg 0xf0, usbctrl_vendorreq TimeOut! status:0xffffffb9 value=0x0 | rtl8192cu: Chip version 0x10 | rtl_usb: reg 0xa, usbctrl_vendorreq TimeOut! status:0xffffffb9 value=0x0 | rtl_usb: Too few input end points found | INFO: trying to register non-static key. | the code is fine but needs lockdep annotation. | turning off the locking correctness validator. | CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.1.0-rc4-319354-g9a33b36 #3 | Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS | Google 01/01/2011 | Workqueue: usb_hub_wq hub_event | Call Trace: | __dump_stack lib/dump_stack.c:77 [inline] | dump_stack+0xe8/0x16e lib/dump_stack.c:113 | assign_lock_key kernel/locking/lockdep.c:786 [inline] | register_lock_class+0x11b8/0x1250 kernel/locking/lockdep.c:1095 | __lock_acquire+0xfb/0x37c0 kernel/locking/lockdep.c:3582 | lock_acquire+0x10d/0x2f0 kernel/locking/lockdep.c:4211 | __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] | _raw_spin_lock_irqsave+0x44/0x60 kernel/locking/spinlock.c:152 | rtl_c2hcmd_launcher+0xd1/0x390 | drivers/net/wireless/realtek/rtlwifi/base.c:2344 | rtl_deinit_core+0x25/0x2d0 drivers/net/wireless/realtek/rtlwifi/base.c:574 | rtl_usb_probe.cold+0x861/0xa70 | drivers/net/wireless/realtek/rtlwifi/usb.c:1093 | usb_probe_interface+0x31d/0x820 drivers/usb/core/driver.c:361 | really_probe+0x2da/0xb10 drivers/base/dd.c:509 | driver_probe_device+0x21d/0x350 drivers/base/dd.c:671 | __device_attach_driver+0x1d8/0x290 drivers/base/dd.c:778 | bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:454 | __device_attach+0x223/0x3a0 drivers/base/dd.c:844 | bus_probe_device+0x1f1/0x2a0 drivers/base/bus.c:514 | device_add+0xad2/0x16e0 drivers/base/core.c:2106 | usb_set_configuration+0xdf7/0x1740 drivers/usb/core/message.c:2021 | generic_probe+0xa2/0xda drivers/usb/core/generic.c:210 | usb_probe_device+0xc0/0x150 drivers/usb/core/driver.c:266 | really_probe+0x2da/0xb10 drivers/base/dd.c:509 | driver_probe_device+0x21d/0x350 drivers/base/dd.c:671 | __device_attach_driver+0x1d8/0x290 drivers/base/dd.c:778 | bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:454 | __device_attach+0x223/0x3a0 drivers/base/dd.c:844 | bus_probe_device+0x1f1/0x2a0 drivers/base/bus.c:514 | device_add+0xad2/0x16e0 drivers/base/core.c:2106 | usb_new_device.cold+0x537/0xccf drivers/usb/core/hub.c:2534 | hub_port_connect drivers/usb/core/hub.c:5089 [inline] | hub_port_connect_change drivers/usb/core/hub.c:5204 [inline] | port_event drivers/usb/core/hub.c:5350 [inline] | hub_event+0x138e/0x3b00 drivers/usb/core/hub.c:5432 | process_one_work+0x90f/0x1580 kernel/workqueue.c:2269 | worker_thread+0x9b/0xe20 kernel/workqueue.c:2415 | kthread+0x313/0x420 kernel/kthread.c:253 | ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352
--- drivers/net/wireless/realtek/rtlwifi/usb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtlwifi/usb.c +3 -2
@@ -1064,13 +1064,13 @@ int rtl_usb_probe(struct usb_interface *intf, rtlpriv->cfg->ops->read_eeprom_info (hw); err =_rtl_usb_init (hw);if (err) - goto error_out; + goto error_out2;rtl_usb_init_sw (hw);/* Init mac80211 sw */ err =rtl_init_core (hw);if (err) {pr_err ("Can't allocate sw for mac80211\n" ); - goto error_out; + goto error_out2; }if (rtlpriv->cfg->ops->init_sw_vars (hw)) {pr_err ("Can't init_sw_vars\n" );
@@ -1091,6 +1091,7 @@ int rtl_usb_probe(struct usb_interface *intf, error_out:rtl_deinit_core (hw); +error_out2:_rtl_usb_io_handler_release (hw);usb_put_dev (udev);complete (&rtlpriv->firmware_loading_complete);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 158/249 mt7601u: do not schedule rx_tasklet when the device has been disconnected
In reply to Sasha LevinFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 4079e8ccabc3b6d1b503f2376123cb515d14921f ]
Do not schedule rx_tasklet when the usb dongle is disconnected. Moreover do not grub rx_lock in mt7601u_kill_rx since usb_poison_urb can run concurrently with urb completion and we can unlink urbs from rx ring in any order.
This patch fixes the common kernel warning reported when
the device is removed.
[ 24.921354] usb 3-14: USB disconnect, device number 7 [ 24.921593] ------------[ cut here ]------------ [ 24.921594] RX urb mismatch [ 24.921675] WARNING: CPU: 4 PID: 163 at drivers/net/wireless/mediatek/mt7601u/dma.c:200 mt7601u_complete_rx+0xcb/0xd0 [mt7601u] [ 24.921769] CPU: 4 PID: 163 Comm: kworker/4:2 Tainted: G OE 4.19.31-041931-generic #201903231635 [ 24.921770] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./Z97 Extreme4, BIOS P1.30 05/23/2014 [ 24.921782] Workqueue: usb_hub_wq hub_event [ 24.921797] RIP: 0010:mt7601u_complete_rx+0xcb/0xd0 [mt7601u] [ 24.921800] RSP: 0018:ffff9bd9cfd03d08 EFLAGS: 00010086 [ 24.921802] RAX: 0000000000000000 RBX: ffff9bd9bf043540 RCX: 0000000000000006 [ 24.921803] RDX: 0000000000000007 RSI: 0000000000000096 RDI: ffff9bd9cfd16420 [ 24.921804] RBP: ffff9bd9cfd03d28 R08: 0000000000000002 R09: 00000000000003a8 [ 24.921805] R10: 0000002f485fca34 R11: 0000000000000000 R12: ffff9bd9bf043c1c [ 24.921806] R13: ffff9bd9c62fa3c0 R14: 0000000000000082 R15: 0000000000000000 [ 24.921807] FS: 0000000000000000(0000) GS:ffff9bd9cfd00000(0000) knlGS:0000000000000000 [ 24.921808] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 24.921808] CR2: 00007fb2648b0000 CR3: 0000000142c0a004 CR4: 00000000001606e0 [ 24.921809] Call Trace: [ 24.921812] <IRQ> [ 24.921819] __usb_hcd_giveback_urb+0x8b/0x140 [ 24.921821] usb_hcd_giveback_urb+0xca/0xe0 [ 24.921828] xhci_giveback_urb_in_irq.isra.42+0x82/0xf0 [ 24.921834] handle_cmd_completion+0xe02/0x10d0 [ 24.921837] xhci_irq+0x274/0x4a0 [ 24.921838] xhci_msi_irq+0x11/0x20 [ 24.921851] __handle_irq_event_percpu+0x44/0x190 [ 24.921856] handle_irq_event_percpu+0x32/0x80 [ 24.921861] handle_irq_event+0x3b/0x5a [ 24.921867] handle_edge_irq+0x80/0x190 [ 24.921874] handle_irq+0x20/0x30 [ 24.921889] do_IRQ+0x4e/0xe0 [ 24.921891] common_interrupt+0xf/0xf [ 24.921892] </IRQ> [ 24.921900] RIP: 0010:usb_hcd_flush_endpoint+0x78/0x180 [ 24.921354] usb 3-14: USB disconnect, device number 7
--- drivers/net/wireless/mediatek/mt7601u/dma.c | 33 +++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/net/wireless/mediatek/mt7601u/dma.c +18 -15
@@ -185,10 +185,23 @@ static void mt7601u_complete_rx(struct urb *urb)struct mt7601u_rx_queue *q = &dev->rx_q;unsigned long flags; -spin_lock_irqsave (&dev->rx_lock, flags); +/* do no schedule rx tasklet if urb has been unlinked +* or the device has been removed +*/ +switch (urb->status) { +case -ECONNRESET : +case -ESHUTDOWN : +case -ENOENT : +return ; +default : +dev_err_ratelimited (dev->dev,"rx urb failed: %d\n" , + urb->status); +/* fall through */ +case 0 : +break ; + } -if (mt7601u_urb_has_error (urb)) -dev_err (dev->dev,"Error: RX urb failed:%d\n" , urb->status); +spin_lock_irqsave (&dev->rx_lock, flags);if (WARN_ONCE (q->e[q->end].urb != urb,"RX urb mismatch" )) goto out;
@@ -355,19 +368,9 @@ int mt7601u_dma_enqueue_tx(struct mt7601u_dev *dev, struct sk_buff *skb,static void mt7601u_kill_rx (struct mt7601u_dev *dev) {int i; -unsigned long flags; -spin_lock_irqsave (&dev->rx_lock, flags); - -for (i =0 ; i < dev->rx_q.entries; i++) { -int next = dev->rx_q.end; - -spin_unlock_irqrestore (&dev->rx_lock, flags); -usb_poison_urb (dev->rx_q.e[next].urb); -spin_lock_irqsave (&dev->rx_lock, flags); - } - -spin_unlock_irqrestore (&dev->rx_lock, flags); +for (i =0 ; i < dev->rx_q.entries; i++) +usb_poison_urb (dev->rx_q.e[i].urb); } static int mt7601u_submit_rx_buf(struct mt7601u_dev *dev,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 159/249 x86/build: Add 'set -e' to mkcapflags.sh to delete broken capflags.c
In reply to Sasha LevinFrom: Masahiro Yamada <[email protected]>
[ Upstream commit bc53d3d777f81385c1bb08b07bd1c06450ecc2c1 ]
Without 'set -e', shell scripts continue running even after any error occurs. The missed 'set -e' is a typical bug in shell scripting.
For example, when a disk space shortage occurs while this script is running, it actually ends up with generating a truncated capflags.c.
Yet, mkcapflags.sh continues running and exits with 0. So, the build system assumes it has succeeded.
It will not be re-generated in the next invocation of Make since its timestamp is newer than that of any of the source files.
Add 'set -e' so that any error in this script is caught and propagated to the build system.
Since 9c2af1c7377a ("kbuild: add .DELETE_ON_ERROR special target"), make automatically deletes the target on any failure. So, the broken capflags.c will be deleted automatically.
--- arch/x86/kernel/cpu/mkcapflags.sh | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kernel/cpu/mkcapflags.sh +2 -0
@@ -4,6 +4,8 @@ # Generate the x86_cap/bug_flags[] arrays from include/asm/cpufeatures.h # +set -e + IN=$1 OUT=$2
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 160/249 mt7601u: fix possible memory leak when the device is disconnected
In reply to Sasha LevinFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 23377c200b2eb48a60d0f228b2a2e75ed6ee6060 ]
When the device is disconnected while passing traffic it is possible to receive out of order urbs causing a memory leak since the skb linked to the current tx urb is not removed. Fix the issue deallocating the skb cleaning up the tx ring. Moreover this patch fixes the following kernel warning
[ 57.480771] usb 1-1: USB disconnect, device number 2 [ 57.483451] ------------[ cut here ]------------ [ 57.483462] TX urb mismatch [ 57.483481] WARNING: CPU: 1 PID: 32 at drivers/net/wireless/mediatek/mt7601u/dma.c:245 mt7601u_complete_tx+0x165/00 [ 57.483483] Modules linked in: [ 57.483496] CPU: 1 PID: 32 Comm: kworker/1:1 Not tainted 5.2.0-rc1+ #72 [ 57.483498] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.12.0-2.fc30 04/01/2014 [ 57.483502] Workqueue: usb_hub_wq hub_event [ 57.483507] RIP: 0010:mt7601u_complete_tx+0x165/0x1e0 [ 57.483510] Code: 8b b5 10 04 00 00 8b 8d 14 04 00 00 eb 8b 80 3d b1 cb e1 00 00 75 9e 48 c7 c7 a4 ea 05 82 c6 05 f [ 57.483513] RSP: 0000:ffffc900000a0d28 EFLAGS: 00010092 [ 57.483516] RAX: 000000000000000f RBX: ffff88802c0a62c0 RCX: ffffc900000a0c2c [ 57.483518] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff810a8371 [ 57.483520] RBP: ffff88803ced6858 R08: 0000000000000000 R09: 0000000000000001 [ 57.483540] R10: 0000000000000002 R11: 0000000000000000 R12: 0000000000000046 [ 57.483542] R13: ffff88802c0a6c88 R14: ffff88803baab540 R15: ffff88803a0cc078 [ 57.483548] FS: 0000000000000000(0000) GS:ffff88803eb00000(0000) knlGS:0000000000000000 [ 57.483550] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 57.483552] CR2: 000055e7f6780100 CR3: 0000000028c86000 CR4: 00000000000006a0 [ 57.483554] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 57.483556] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 57.483559] Call Trace: [ 57.483561] <IRQ> [ 57.483565] __usb_hcd_giveback_urb+0x77/0xe0 [ 57.483570] xhci_giveback_urb_in_irq.isra.0+0x8b/0x140 [ 57.483574] handle_cmd_completion+0xf5b/0x12c0 [ 57.483577] xhci_irq+0x1f6/0x1810 [ 57.483581] ? lockdep_hardirqs_on+0x9e/0x180 [ 57.483584] ? _raw_spin_unlock_irq+0x24/0x30 [ 57.483588] __handle_irq_event_percpu+0x3a/0x260 [ 57.483592] handle_irq_event_percpu+0x1c/0x60 [ 57.483595] handle_irq_event+0x2f/0x4c [ 57.483599] handle_edge_irq+0x7e/0x1a0 [ 57.483603] handle_irq+0x17/0x20 [ 57.483607] do_IRQ+0x54/0x110 [ 57.483610] common_interrupt+0xf/0xf [ 57.483612] </IRQ>
--- drivers/net/wireless/mediatek/mt7601u/dma.c | 21 ++++++++++++++++----- drivers/net/wireless/mediatek/mt7601u/tx.c | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt7601u/dma.c +16 -5
@@ -233,14 +233,25 @@ static void mt7601u_complete_tx(struct urb *urb)struct sk_buff *skb;unsigned long flags; -spin_lock_irqsave (&dev->tx_lock, flags); +switch (urb->status) { +case -ECONNRESET : +case -ESHUTDOWN : +case -ENOENT : +return ; +default : +dev_err_ratelimited (dev->dev,"tx urb failed: %d\n" , + urb->status); +/* fall through */ +case 0 : +break ; + } -if (mt7601u_urb_has_error (urb)) -dev_err (dev->dev,"Error: TX urb failed:%d\n" , urb->status); +spin_lock_irqsave (&dev->tx_lock, flags);if (WARN_ONCE (q->e[q->start].urb != urb,"TX urb mismatch" )) goto out; skb = q->e[q->start].skb; + q->e[q->start].skb =NULL ;trace_mt_tx_dma_done (dev, skb);__skb_queue_tail (&dev->tx_skb_done, skb);
@@ -440,10 +451,10 @@ static void mt7601u_free_tx_queue(struct mt7601u_tx_queue *q) {int i; -WARN_ON (q->used); -for (i =0 ; i < q->entries; i++) {usb_poison_urb (q->e[i].urb); +if (q->e[i].skb) +mt7601u_tx_status (q->dev, q->e[i].skb);usb_free_urb (q->e[i].urb); } }
drivers/net/wireless/mediatek/mt7601u/tx.c +2 -2
@@ -109,9 +109,9 @@ void mt7601u_tx_status(struct mt7601u_dev *dev, struct sk_buff *skb) info->status.rates[0 ].idx =-1 ; info->flags |=IEEE80211_TX_STAT_ACK ; -spin_lock (&dev->mac_lock); +spin_lock_bh (&dev->mac_lock);ieee80211_tx_status (dev->hw, skb); -spin_unlock (&dev->mac_lock); +spin_unlock_bh (&dev->mac_lock); }static int mt7601u_skb_rooms (struct mt7601u_dev *dev,struct sk_buff *skb)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 161/249 ipvs: fix tinfo memory leak in start_sync_thread
In reply to Sasha LevinFrom: Julian Anastasov <[email protected]>
[ Upstream commit 5db7c8b9f9fc2aeec671ae3ca6375752c162e0e7 ]
syzkaller reports for memory leak in start_sync_thread [1]
As Eric points out, kthread may start and stop before the threadfn function is called, so there is no chance the data (tinfo in our case) to be released in thread.
Fix this by releasing tinfo in the controlling code instead.
[1]
BUG: memory leak
unreferenced object 0xffff8881206bf700 (size 32):
comm "syz-executor761", pid 7268, jiffies 4294943441 (age 20.470s) hex dump (first 32 bytes):
00 40 7c 09 81 88 ff ff 80 45 b8 21 81 88 ff ff .@|......E.!.... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000057619e23>] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline] [<0000000057619e23>] slab_post_alloc_hook mm/slab.h:439 [inline] [<0000000057619e23>] slab_alloc mm/slab.c:3326 [inline] [<0000000057619e23>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553 [<0000000086ce5479>] kmalloc include/linux/slab.h:547 [inline] [<0000000086ce5479>] start_sync_thread+0x5d2/0xe10 net/netfilter/ipvs/ip_vs_sync.c:1862 [<000000001a9229cc>] do_ip_vs_set_ctl+0x4c5/0x780 net/netfilter/ipvs/ip_vs_ctl.c:2402 [<00000000ece457c8>] nf_sockopt net/netfilter/nf_sockopt.c:106 [inline] [<00000000ece457c8>] nf_setsockopt+0x4c/0x80 net/netfilter/nf_sockopt.c:115 [<00000000942f62d4>] ip_setsockopt net/ipv4/ip_sockglue.c:1258 [inline] [<00000000942f62d4>] ip_setsockopt+0x9b/0xb0 net/ipv4/ip_sockglue.c:1238 [<00000000a56a8ffd>] udp_setsockopt+0x4e/0x90 net/ipv4/udp.c:2616 [<00000000fa895401>] sock_common_setsockopt+0x38/0x50 net/core/sock.c:3130 [<0000000095eef4cf>] __sys_setsockopt+0x98/0x120 net/socket.c:2078 [<000000009747cf88>] __do_sys_setsockopt net/socket.c:2089 [inline] [<000000009747cf88>] __se_sys_setsockopt net/socket.c:2086 [inline] [<000000009747cf88>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2086 [<00000000ded8ba80>] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301 [<00000000893b4ac8>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- include/net/ip_vs.h | 6 +- net/netfilter/ipvs/ip_vs_ctl.c | 4 - net/netfilter/ipvs/ip_vs_sync.c | 134 +++++++++++++++++--------------- 3 files changed, 76 insertions(+), 68 deletions(-)
include/net/ip_vs.h +4 -2
@@ -808,11 +808,12 @@ struct ipvs_master_sync_state {struct ip_vs_sync_buff *sync_buff;unsigned long sync_queue_len;unsigned int sync_queue_delay; -struct task_struct *master_thread;struct delayed_work master_wakeup_work;struct netns_ipvs *ipvs; }; +struct ip_vs_sync_thread_data ; +/* How much time to keep dests in trash */ #define IP_VS_DEST_TRASH_PERIOD (120 * HZ)
@@ -943,7 +944,8 @@ struct netns_ipvs {spinlock_t sync_lock;struct ipvs_master_sync_state *ms;spinlock_t sync_buff_lock; -struct task_struct **backup_threads; +struct ip_vs_sync_thread_data *master_tinfo; +struct ip_vs_sync_thread_data *backup_tinfo;int threads_mask;volatile int sync_state;struct mutex sync_mutex;
net/netfilter/ipvs/ip_vs_ctl.c +0 -4
@@ -2396,9 +2396,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) cfg.syncid = dm->syncid; ret =start_sync_thread (ipvs, &cfg, dm->state); }else { -mutex_lock (&ipvs->sync_mutex); ret =stop_sync_thread (ipvs, dm->state); -mutex_unlock (&ipvs->sync_mutex); } goto out_dec; }
@@ -3515,10 +3513,8 @@ static int ip_vs_genl_del_daemon(struct netns_ipvs *ipvs, struct nlattr **attrs)if (!attrs[IPVS_DAEMON_ATTR_STATE ])return -EINVAL ; -mutex_lock (&ipvs->sync_mutex); ret =stop_sync_thread (ipvs,nla_get_u32 (attrs[IPVS_DAEMON_ATTR_STATE ])); -mutex_unlock (&ipvs->sync_mutex);return ret; }
net/netfilter/ipvs/ip_vs_sync.c +72 -62
269 lines not on this page · raw message
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 162/249 mt76: mt7615: do not process rx packets if the device is not initialized
In reply to Sasha LevinFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 2dcb79cde6129d948a237ef7b48a73a0c82f1e01 ]
Fix following crash that occurs when the driver is processing rx packets while the device is not initialized yet
$ rmmod mt7615e [ 67.210261] mt7615e 0000:01:00.0: Message -239 (seq 2) timeout $ modprobe mt7615e [ 72.406937] bus=0x1, slot = 0x0, irq=0x16 [ 72.436590] CPU 0 Unable to handle kernel paging request at virtual address 00000004, epc == 8eec4240, ra == 8eec41e0 [ 72.450291] mt7615e 0000:01:00.0: Firmware is not ready for download [ 72.457724] Oops[#1]: [ 72.470494] mt7615e: probe of 0000:01:00.0 failed with error -5 [ 72.474829] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.14.114 #0 [ 72.498702] task: 805769e0 task.stack: 80564000 [ 72.507709] $ 0 : 00000000 00000001 00000000 00000001 [ 72.518106] $ 4 : 8f704dbc 00000000 00000000 8f7046c0 [ 72.528500] $ 8 : 00000024 8045e98c 81210008 11000000 [ 72.538895] $12 : 8fc09f60 00000008 00000019 00000033 [ 72.549289] $16 : 8f704d80 e00000ff 8f0c7800 3c182406 [ 72.559684] $20 : 00000006 8ee615a0 4e000108 00000000 [ 72.570078] $24 : 0000004c 8000cf94 [ 72.580474] $28 : 80564000 8fc09e38 00000001 8eec41e0 [ 72.590869] Hi : 00000001 [ 72.596582] Lo : 00000000 [ 72.602319] epc : 8eec4240 mt7615_mac_fill_rx+0xac/0x494 [mt7615e] [ 72.614953] ra : 8eec41e0 mt7615_mac_fill_rx+0x4c/0x494 [mt7615e] [ 72.627580] Status: 11008403 KERNEL EXL IE [ 72.635899] Cause : 40800008 (ExcCode 02) [ 72.643860] BadVA : 00000004 [ 72.649573] PrId : 0001992f (MIPS 1004Kc) [ 72.657704] Modules linked in: mt7615e pppoe ppp_async pppox ppp_generic nf_conntrack_ipv6 mt76x2e mt76x2_common mt76x02_lib mt7603e mt76 mac80211 iptable_nat ipt_REJECT ipt_MASQUERADE cfg80211 xt_time xt_tcpudp xt_state xt_nat xt_mu] [ 72.792717] Process swapper/0 (pid: 0, threadinfo=80564000, task=805769e0, tls=00000000) [ 72.808799] Stack : 8f0c7800 00000800 8f0c7800 8032b874 00000000 40000000 8f704d80 8ee615a0 [ 72.825428] 8dc88010 00000001 8ee615e0 8eec09b0 8dc88010 8032b914 8f3aee80 80567d20 [ 72.842055] 00000000 8ee615e0 40000000 8f0c7800 00000108 8eec9944 00000000 00000000 [ 72.858682] 80508f10 80510000 00000001 80567d20 8ee615a0 00000000 00000000 8ee61c00 [ 72.875308] 8ee61c40 00000040 80610000 80580000 00000000 8ee615dc 8ee61a68 00000001 [ 72.891936] ... [ 72.896793] Call Trace: [ 72.901649] [<8eec4240>] mt7615_mac_fill_rx+0xac/0x494 [mt7615e] [ 72.913602] [<8eec09b0>] mt7615_queue_rx_skb+0xe4/0x12c [mt7615e] [ 72.925734] [<8eec9944>] mt76_dma_cleanup+0x390/0x42c [mt76] [ 72.936988] Code: ae020018 8ea20004 24030001 <94420004> a602002a 8ea20004 90420000 14430003 a2020034 [ 72.956390] [ 72.959676] ---[ end trace f176967739edb19f ]---
--- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +3 -0
@@ -96,6 +96,9 @@ int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)bool unicast, remove_pad, insert_ccmp_hdr = false;int i, idx; +if (!test_bit (MT76_STATE_RUNNING , &dev->mt76.state)) +return -EINVAL ; +memset (status,0 ,sizeof (*status)); unicast = (rxd1 &MT_RXD1_NORMAL_ADDR_TYPE ) ==MT_RXD1_NORMAL_U2M ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 163/249 ath10k: add missing error handling
In reply to Sasha LevinFrom: Claire Chang <[email protected]>
[ Upstream commit 4b553f3ca4cbde67399aa3a756c37eb92145b8a1 ]
In function ath10k_sdio_mbox_rx_alloc() [sdio.c], ath10k_sdio_mbox_alloc_rx_pkt() is called without handling the error cases. This will make the driver think the allocation for skb is successful and try to access the skb. If we enable failslab, system will easily crash with NULL pointer dereferencing.
Call trace of CONFIG_FAILSLAB:
ath10k_sdio_irq_handler+0x570/0xa88 [ath10k_sdio] process_sdio_pending_irqs+0x4c/0x174 sdio_run_irqs+0x3c/0x64 sdio_irq_work+0x1c/0x28
--- drivers/net/wireless/ath/ath10k/sdio.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath10k/sdio.c +4 -0
@@ -602,6 +602,10 @@ static int ath10k_sdio_mbox_rx_alloc(struct ath10k *ar, full_len, last_in_bundle, last_in_bundle); +if (ret) { +ath10k_warn (ar,"alloc_rx_pkt error %d\n" , ret); + goto err; + } } ar_sdio->n_rx_pkts = i;
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 164/249 ath10k: fix fw crash by moving chip reset after napi disabled
In reply to Sasha LevinFrom: Miaoqing Pan <[email protected]>
[ Upstream commit 08d80e4cd27ba19f9bee9e5f788f9a9fc440a22f ]
On SMP platform, when continuously running wifi up/down, the napi poll can be scheduled during chip reset, which will call ath10k_pci_has_fw_crashed() to check the fw status. But in the reset period, the value from FW_INDICATOR_ADDRESS register will return 0xdeadbeef, which also be treated as fw crash. Fix the issue by moving chip reset after napi disabled.
ath10k_pci 0000:01:00.0: firmware crashed! (guid 73b30611-5b1e-4bdd-90b4-64c81eb947b6) ath10k_pci 0000:01:00.0: qca9984/qca9994 hw1.0 target 0x01000000 chip_id 0x00000000 sub 168c:cafe ath10k_pci 0000:01:00.0: htt-ver 2.2 wmi-op 6 htt-op 4 cal otp max-sta 512 raw 0 hwcrypto 1 ath10k_pci 0000:01:00.0: failed to get memcpy hi address for firmware address 4: -16 ath10k_pci 0000:01:00.0: failed to read firmware dump area: -16ath10k_pci 0000:01:00.0: Copy Engine register dump:
ath10k_pci 0000:01:00.0: [00]: 0x0004a000 0 0 0 0 ath10k_pci 0000:01:00.0: [01]: 0x0004a400 0 0 0 0 ath10k_pci 0000:01:00.0: [02]: 0x0004a800 0 0 0 0 ath10k_pci 0000:01:00.0: [03]: 0x0004ac00 0 0 0 0 ath10k_pci 0000:01:00.0: [04]: 0x0004b000 0 0 0 0 ath10k_pci 0000:01:00.0: [05]: 0x0004b400 0 0 0 0 ath10k_pci 0000:01:00.0: [06]: 0x0004b800 0 0 0 0 ath10k_pci 0000:01:00.0: [07]: 0x0004bc00 1 0 1 0 ath10k_pci 0000:01:00.0: [08]: 0x0004c000 0 0 0 0 ath10k_pci 0000:01:00.0: [09]: 0x0004c400 0 0 0 0 ath10k_pci 0000:01:00.0: [10]: 0x0004c800 0 0 0 0 ath10k_pci 0000:01:00.0: [11]: 0x0004cc00 0 0 0 0
Tested HW: QCA9984,QCA9887,WCN3990
--- drivers/net/wireless/ath/ath10k/pci.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +5 -4
@@ -2059,6 +2059,11 @@ static void ath10k_pci_hif_stop(struct ath10k *ar)ath10k_dbg (ar,ATH10K_DBG_BOOT ,"boot hif stop\n" ); +ath10k_pci_irq_disable (ar); +ath10k_pci_irq_sync (ar); +napi_synchronize (&ar->napi); +napi_disable (&ar->napi); +/* Most likely the device has HTT Rx ring configured. The only way to * prevent the device from accessing (and possible corrupting) host * memory is to reset the chip now.
@@ -2072,10 +2077,6 @@ static void ath10k_pci_hif_stop(struct ath10k *ar)*/ ath10k_pci_safe_chip_reset (ar); -ath10k_pci_irq_disable (ar); -ath10k_pci_irq_sync (ar); -napi_synchronize (&ar->napi); -napi_disable (&ar->napi);ath10k_pci_flush (ar);spin_lock_irqsave (&ar_pci->ps_lock, flags);
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 165/249 ath10k: fix PCIE device wake up failed
In reply to Sasha LevinFrom: Miaoqing Pan <[email protected]>
[ Upstream commit 011d4111c8c602ea829fa4917af1818eb0500a90 ]
Observed PCIE device wake up failed after ~120 iterations of soft-reboot test. The error message is
"ath10k_pci 0000:01:00.0: failed to wake up device : -110"
The call trace as below:ath10k_pci_probe -> ath10k_pci_force_wake -> ath10k_pci_wake_wait -> ath10k_pci_is_awake
Once trigger the device to wake up, we will continuously check the RTC state until it returns RTC_STATE_V_ON or timeout.
But for QCA99x0 chips, we use wrong value for RTC_STATE_V_ON. Occasionally, we get 0x7 on the fist read, we thought as a failure case, but actually is the right value, also verified with the spec. So fix the issue by changing RTC_STATE_V_ON from 0x5 to 0x7, passed ~2000 iterations.
Tested HW: QCA9984
--- drivers/net/wireless/ath/ath10k/hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/hw.c +1 -1
@@ -158,7 +158,7 @@ const struct ath10k_hw_values qca6174_values = { };const struct ath10k_hw_values qca99x0_values = { - .rtc_state_val_on =5 , + .rtc_state_val_on =7 , .ce_count =12 , .msi_assign_ce_max =12 , .num_target_ce_config_wlan =10 ,
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 166/249 ALSA: hdac: Fix codec name after machine driver is unloaded and reloaded
In reply to Sasha LevinFrom: Amadeusz Sławiński <[email protected]>
[ Upstream commit 8a5b0177a7f6099ff534a4d9ce72673af5c3cade ]
Currently on each driver reload internal counter is being increased. It causes failure to enumerate driver devices, as they have hardcoded:
.codec_name = "ehdaudio0D2",
As there is currently no devices with multiple hda codecs and there is currently no established way to reliably differentiate, between them, always assign bus->idx = 0;
This fixes a problem when we unload and reload machine driver idx gets incremented, so .codec_name would've needed to be set to "ehdaudio1D2" after first reload and so on.
--- sound/hda/ext/hdac_ext_bus.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
sound/hda/ext/hdac_ext_bus.c +6 -2
@@ -85,7 +85,6 @@ int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, const struct hdac_ext_bus_ops *ext_ops) {int ret; -static int idx;/* check if io ops are provided, if not load the defaults */ if (io_ops ==NULL )
@@ -96,7 +95,12 @@ int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev,return ret; bus->ext_ops = ext_ops; - bus->idx = idx++; +/* FIXME: +* Currently only one bus is supported, if there is device with more +* buses, bus->idx should be greater than 0, but there needs to be a +* reliable way to always assign same number. +*/ + bus->idx =0 ; bus->cmd_dma_state = true;return 0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 167/249 perf tools: Increase MAX_NR_CPUS and MAX_CACHES
In reply to Sasha LevinFrom: Kyle Meyer <[email protected]>
[ Upstream commit 9f94c7f947e919c343b30f080285af53d0fa9902 ]
Attempting to profile 1024 or more CPUs with perf causes two errors:
perf record -a
[ perf record: Woken up X times to write data ]
way too many cpu caches..
[ perf record: Captured and wrote X MB perf.data (X samples) ]
perf report -C 1024
Error: failed to set cpu bitmap
Requested CPU 1024 too large. Consider raising MAX_NR_CPUS
Increasing MAX_NR_CPUS from 1024 to 2048 and redefining MAX_CACHES as MAX_NR_CPUS * 4 returns normal functionality to perf:
perf record -a
[ perf record: Woken up X times to write data ]
[ perf record: Captured and wrote X MB perf.data (X samples) ]
perf report -C 1024
...
--- tools/perf/perf.h | 2 +- tools/perf/util/header.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/perf.h +1 -1
@@ -26,7 +26,7 @@ static inline unsigned long long rdclock(void) }#ifndef MAX_NR_CPUS -#define MAX_NR_CPUS 1024 +#define MAX_NR_CPUS 2048#endif extern const char *input_name;
tools/perf/util/header.c +1 -1
@@ -1100,7 +1100,7 @@ static int build_caches(struct cpu_cache_level caches[], u32 size, u32 *cntp)return 0 ; } -#define MAX_CACHES 2000 +#define MAX_CACHES (MAX_NR_CPUS * 4)static int write_cache (struct feat_fd *ff,struct perf_evlist *evlist__maybe_unused )
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 168/249 ASoC: Intel: hdac_hdmi: Set ops to NULL on remove
In reply to Sasha LevinFrom: Amadeusz Sławiński <[email protected]>
[ Upstream commit 0f6ff78540bd1b4df1e0f17806b0ce2e1dff0d78 ]
When we unload Skylake driver we may end up calling hdac_component_master_unbind(), it uses acomp->audio_ops, which we set in hdmi_codec_probe(), so we need to set it to NULL in hdmi_codec_remove(), otherwise we will dereference no longer existing pointer.
--- sound/soc/codecs/hdac_hdmi.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/soc/codecs/hdac_hdmi.c +6 -0
@@ -1859,6 +1859,12 @@ static void hdmi_codec_remove(struct snd_soc_component *component) {struct hdac_hdmi_priv *hdmi =snd_soc_component_get_drvdata (component);struct hdac_device *hdev = hdmi->hdev; +int ret; + + ret =snd_hdac_acomp_register_notifier (hdev->bus,NULL ); +if (ret <0 ) +dev_err (&hdev->dev,"notifier unregister failed: err: %d\n" , + ret);pm_runtime_disable (&hdev->dev); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 169/249 block, bfq: fix rq_in_driver check in bfq_update_inject_limit
In reply to Sasha LevinFrom: Paolo Valente <[email protected]>
[ Upstream commit db599f9ed9bd31b018b6c48ad7c6b21d5b790ecf ]
One of the cases where the parameters for injection may be updated is when there are no more in-flight I/O requests. The number of in-flight requests is stored in the field bfqd->rq_in_driver of the descriptor bfqd of the device. So, the controlled condition is bfqd->rq_in_driver == 0.
Unfortunately, this is wrong because, the instruction that checks this condition is in the code path that handles the completion of a request, and, in particular, the instruction is executed before bfqd->rq_in_driver is decremented in such a code path.
This commit fixes this issue by just replacing 0 with 1 in the comparison.
--- block/bfq-iosched.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
block/bfq-iosched.c +7 -1
@@ -5398,8 +5398,14 @@ static void bfq_update_inject_limit(struct bfq_data *bfqd,* total service time, and there seem to be the right * conditions to do it, or we can lower the last base value * computed. +* +* NOTE: (bfqd->rq_in_driver == 1) means that there is no I/O +* request in flight, because this function is in the code +* path that handles the completion of a request of bfqq, and, +* in particular, this function is executed before +* bfqd->rq_in_driver is decremented in such a code path. */ -if ((bfqq->last_serv_time_ns ==0 && bfqd->rq_in_driver ==0 ) || +if ((bfqq->last_serv_time_ns ==0 && bfqd->rq_in_driver ==1 ) || tot_time_ns < bfqq->last_serv_time_ns) { bfqq->last_serv_time_ns = tot_time_ns;/*
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 170/249 clocksource/drivers/tegra: Release all IRQ's on request_irq() error
In reply to Sasha LevinFrom: Dmitry Osipenko <[email protected]>
[ Upstream commit 7a3916706e858ad0bc3b5629c68168e1449de26a ]
Release all requested IRQ's on the request error to properly clean up allocated resources.
--- drivers/clocksource/timer-tegra20.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/clocksource/timer-tegra20.c +3 -2
@@ -288,7 +288,7 @@ static int __init tegra_init_timer(struct device_node *np)pr_err ("%s: can't map IRQ for CPU%d\n" , __func__, cpu); ret = -EINVAL ; - goto out; + goto out_irq; }irq_set_status_flags (cpu_to->clkevt.irq,IRQ_NOAUTOEN );
@@ -298,7 +298,8 @@ static int __init tegra_init_timer(struct device_node *np)if (ret) {pr_err ("%s: cannot setup irq %d for CPU%d\n" , __func__, cpu_to->clkevt.irq, cpu); - ret = -EINVAL ; +irq_dispose_mapping (cpu_to->clkevt.irq); + cpu_to->clkevt.irq =0 ; goto out_irq; } }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 171/249 libata: don't request sense data on !ZAC ATA devices
In reply to Sasha LevinFrom: Tejun Heo <[email protected]>
[ Upstream commit ca156e006add67e4beea7896be395160735e09b0 ]
ZAC support added sense data requesting on error for both ZAC and ATA devices. This seems to cause erratic error handling behaviors on some SSDs where the device reports sense data availability and then delivers the wrong content making EH take the wrong actions. The failure mode was sporadic on a LITE-ON ssd and couldn't be reliably reproduced.
There is no value in requesting sense data from non-ZAC ATA devices while there's a significant risk of introducing EH misbehaviors which are difficult to reproduce and fix. Let's do the sense data dancing only for ZAC devices.
--- drivers/ata/libata-eh.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/ata/libata-eh.c +5 -3
@@ -1469,7 +1469,7 @@ static int ata_eh_read_log_10h(struct ata_device *dev, tf->hob_lbah = buf[10 ]; tf->nsect = buf[12 ]; tf->hob_nsect = buf[13 ]; -if (ata_id_has_ncq_autosense (dev->id)) +if (dev->class ==ATA_DEV_ZAC &&ata_id_has_ncq_autosense (dev->id)) tf->auxiliary = buf[14 ] <<16 | buf[15 ] <<8 | buf[16 ];return 0 ;
@@ -1716,7 +1716,8 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)memcpy (&qc->result_tf, &tf,sizeof (tf)); qc->result_tf.flags =ATA_TFLAG_ISADDR |ATA_TFLAG_LBA |ATA_TFLAG_LBA48 ; qc->err_mask |=AC_ERR_DEV |AC_ERR_NCQ ; -if ((qc->result_tf.command &ATA_SENSE ) || qc->result_tf.auxiliary) { +if (dev->class ==ATA_DEV_ZAC && + ((qc->result_tf.command &ATA_SENSE ) || qc->result_tf.auxiliary)) {char sense_key, asc, ascq; sense_key = (qc->result_tf.auxiliary >>16 ) &0xff ;
@@ -1770,10 +1771,11 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc, }switch (qc->dev->class) { -case ATA_DEV_ATA :case ATA_DEV_ZAC :if (stat &ATA_SENSE )ata_eh_request_sense (qc, qc->scsicmd); +/* fall through */ +case ATA_DEV_ATA :if (err &ATA_ICRC ) qc->err_mask |=AC_ERR_ATA_BUS ;if (err & (ATA_UNC |ATA_AMNF ))
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 172/249 clocksource/drivers/tegra: Restore base address before cleanup
In reply to Sasha LevinFrom: Dmitry Osipenko <[email protected]>
[ Upstream commit fc9babc2574691d3bbf0428f007b22261fed55c6 ]
We're adjusting the timer's base for each per-CPU timer to point to the actual start of the timer since device-tree defines a compound registers range that includes all of the timers. In this case the original base need to be restore before calling iounmap to unmap the proper address.
--- drivers/clocksource/timer-tegra20.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clocksource/timer-tegra20.c +2 -0
@@ -319,6 +319,8 @@ static int __init tegra_init_timer(struct device_node *np)irq_dispose_mapping (cpu_to->clkevt.irq); } } + + to->of_base.base = timer_reg_base; out:timer_of_cleanup (to);return ret;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 173/249 clocksource/drivers/exynos_mct: Increase priority over ARM arch timer
In reply to Sasha LevinFrom: Marek Szyprowski <[email protected]>
[ Upstream commit 6282edb72bed5324352522d732080d4c1b9dfed6 ]
Exynos SoCs based on CA7/CA15 have 2 timer interfaces: custom Exynos MCT (Multi Core Timer) and standard ARM Architected Timers.
There are use cases, where both timer interfaces are used simultanously. One of such examples is using Exynos MCT for the main system timer and ARM Architected Timers for the KVM and virtualized guests (KVM requires arch timers).
Exynos Multi-Core Timer driver (exynos_mct) must be however started before ARM Architected Timers (arch_timer), because they both share some common hardware blocks (global system counter) and turning on MCT is needed to get ARM Architected Timer working properly.
To ensure selecting Exynos MCT as the main system timer, increase MCT timer rating. To ensure proper starting order of both timers during suspend/resume cycle, increase MCT hotplug priority over ARM Archictected Timers.
--- drivers/clocksource/exynos_mct.c | 4 ++-- include/linux/cpuhotplug.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/clocksource/exynos_mct.c +2 -2
@@ -206,7 +206,7 @@ static void exynos4_frc_resume(struct clocksource *cs)static struct clocksource mct_frc = { .name ="mct-frc" , - .rating =400 , + .rating =450 ,/* use value higher than ARM arch timer */ .read = exynos4_frc_read, .mask =CLOCKSOURCE_MASK (32 ), .flags =CLOCK_SOURCE_IS_CONTINUOUS ,
@@ -461,7 +461,7 @@ static int exynos4_mct_starting_cpu(unsigned int cpu) evt->set_state_oneshot_stopped = set_state_shutdown; evt->tick_resume = set_state_shutdown; evt->features =CLOCK_EVT_FEAT_PERIODIC |CLOCK_EVT_FEAT_ONESHOT ; - evt->rating =450 ; + evt->rating =500 ;/* use value higher than ARM arch timer */ exynos4_mct_write (TICK_BASE_CNT , mevt->base +MCT_L_TCNTB_OFFSET );
include/linux/cpuhotplug.h +1 -1
@@ -116,10 +116,10 @@ enum cpuhp_state {CPUHP_AP_PERF_ARM_ACPI_STARTING ,CPUHP_AP_PERF_ARM_STARTING ,CPUHP_AP_ARM_L2X0_STARTING , +CPUHP_AP_EXYNOS4_MCT_TIMER_STARTING ,CPUHP_AP_ARM_ARCH_TIMER_STARTING ,CPUHP_AP_ARM_GLOBAL_TIMER_STARTING ,CPUHP_AP_JCORE_TIMER_STARTING , -CPUHP_AP_EXYNOS4_MCT_TIMER_STARTING ,CPUHP_AP_ARM_TWD_STARTING ,CPUHP_AP_QCOM_TIMER_STARTING , CPUHP_AP_TEGRA_TIMER_STARTING,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 174/249 netfilter: ctnetlink: Fix regression in conntrack entry deletion
In reply to Sasha LevinFrom: Felix Kaechele <[email protected]>
[ Upstream commit e7600865db32b69deb0109b8254244dca592adcf ]
Commit f8e608982022 ("netfilter: ctnetlink: Resolve conntrack L3-protocol flush regression") introduced a regression in which deletion of conntrack entries would fail because the L3 protocol information is replaced by AF_UNSPEC. As a result the search for the entry to be deleted would turn up empty due to the tuple used to perform the search is now different from the tuple used to initially set up the entry.
For flushing the conntrack table we do however want to keep the option for nfgenmsg->version to have a non-zero value to allow for newer user-space tools to request treatment under the new behavior. With that it is possible to independently flush tables for a defined L3 protocol. This was introduced with the enhancements in in commit 59c08c69c278 ("netfilter: ctnetlink: Support L3 protocol-filter on flush").
Older user-space tools will retain the behavior of flushing all tables regardless of defined L3 protocol.
--- net/netfilter/nf_conntrack_netlink.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_netlink.c +4 -3
@@ -1256,7 +1256,6 @@ static int ctnetlink_del_conntrack(struct net *net, struct sock *ctnl,struct nf_conntrack_tuple tuple;struct nf_conn *ct;struct nfgenmsg *nfmsg =nlmsg_data (nlh); -u_int8_t u3 = nfmsg->version ? nfmsg->nfgen_family :AF_UNSPEC ;struct nf_conntrack_zone zone;int err;
@@ -1266,11 +1265,13 @@ static int ctnetlink_del_conntrack(struct net *net, struct sock *ctnl,if (cda[CTA_TUPLE_ORIG ]) err =ctnetlink_parse_tuple (cda, &tuple,CTA_TUPLE_ORIG , - u3, &zone); + nfmsg->nfgen_family, &zone);else if (cda[CTA_TUPLE_REPLY ]) err =ctnetlink_parse_tuple (cda, &tuple,CTA_TUPLE_REPLY , - u3, &zone); + nfmsg->nfgen_family, &zone);else { +u_int8_t u3 = nfmsg->version ? nfmsg->nfgen_family :AF_UNSPEC ; +return ctnetlink_flush_conntrack (net, cda,NETLINK_CB (skb).portid,nlmsg_report (nlh), u3);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 175/249 xsk: Properly terminate assignment in xskq_produce_flush_desc
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit f7019b7b0ad14bde732b8953161994edfc384953 ]
Clang warns:
In file included from net/xdp/xsk_queue.c:10:net/xdp/xsk_queue.h:292:2: warning: expression result unused [-Wunused-value]
WRITE_ONCE(q->ring->producer, q->prod_tail);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:284:6: note: expanded from macro 'WRITE_ONCE'
__u.__val; \
~~~ ^~~~~1 warning generated.
The q->prod_tail assignment has a comma at the end, not a semi-colon. Fix that so clang no longer warns and everything works as expected.
--- net/xdp/xsk_queue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/xdp/xsk_queue.h +1 -1
@@ -288,7 +288,7 @@ static inline void xskq_produce_flush_desc(struct xsk_queue *q)/* Order producer and data */ smp_wmb ();/* B, matches C */ - q->prod_tail = q->prod_head, + q->prod_tail = q->prod_head;WRITE_ONCE (q->ring->producer, q->prod_tail); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 176/249 rslib: Fix decoding of shortened codes
In reply to Sasha LevinFrom: Ferdinand Blomqvist <[email protected]>
[ Upstream commit 2034a42d1747fc1e1eeef2c6f1789c4d0762cb9c ]
The decoding of shortenend codes is broken. It only works as expected if there are no erasures.
When decoding with erasures, Lambda (the error and erasure locator polynomial) is initialized from the given erasure positions. The pad parameter is not accounted for by the initialisation code, and hence Lambda is initialized from incorrect erasure positions.
The fix is to adjust the erasure positions by the supplied pad.
--- lib/reed_solomon/decode_rs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/reed_solomon/decode_rs.c +2 -2
@@ -99,9 +99,9 @@if (no_eras >0 ) {/* Init lambda to be the erasure locator polynomial */ lambda[1 ] = alpha_to[rs_modnn (rs, - prim * (nn -1 - eras_pos[0 ]))]; + prim * (nn -1 - (eras_pos[0 ] + pad)))];for (i =1 ; i < no_eras; i++) { - u =rs_modnn (rs, prim * (nn -1 - eras_pos[i])); + u =rs_modnn (rs, prim * (nn -1 - (eras_pos[i] + pad)));for (j = i +1 ; j >0 ; j--) { tmp = index_of[lambda[j -1 ]];if (tmp != nn) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 177/249 bpf: fix BPF_ALU32 | BPF_ARSH on BE arches
In reply to Sasha LevinFrom: Jiong Wang <[email protected]>
[ Upstream commit 75672dda27bd00109a84cd975c17949ad9c45663 ]
Yauheni reported the following code do not work correctly on BE arches:
ALU_ARSH_X:
DST = (u64) (u32) ((*(s32 *) &DST) >> SRC);
CONT;
ALU_ARSH_K:
DST = (u64) (u32) ((*(s32 *) &DST) >> IMM);
CONT;and are causing failure of test_verifier test 'arsh32 on imm 2' on BE arches.
The code is taking address and interpreting memory directly, so is not endianness neutral. We should instead perform standard C type casting on the variable. A u64 to s32 conversion will drop the high 32-bit and reserve the low 32-bit as signed integer, this is all we want.
--- kernel/bpf/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/core.c +2 -2
@@ -1364,10 +1364,10 @@ static u64 ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn, u64 *stack) insn++;CONT ; ALU_ARSH_X: -DST = (u64) (u32) ((*(s32 *) &DST ) >>SRC ); +DST = (u64) (u32) (((s32 )DST ) >>SRC );CONT ; ALU_ARSH_K: -DST = (u64) (u32) ((*(s32 *) &DST ) >>IMM ); +DST = (u64) (u32) (((s32 )DST ) >>IMM );CONT ; ALU64_ARSH_X: (*(s64 *) &DST ) >>=SRC ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 178/249 rslib: Fix handling of of caller provided syndrome
In reply to Sasha LevinFrom: Ferdinand Blomqvist <[email protected]>
[ Upstream commit ef4d6a8556b637ad27c8c2a2cff1dda3da38e9a9 ]
Check if the syndrome provided by the caller is zero, and act accordingly.
--- lib/reed_solomon/decode_rs.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
lib/reed_solomon/decode_rs.c +12 -2
@@ -42,8 +42,18 @@BUG_ON (pad <0 || pad >= nn);/* Does the caller provide the syndrome ? */ -if (s !=NULL ) - goto decode; +if (s !=NULL ) { +for (i =0 ; i < nroots; i++) { +/* The syndrome is in index form, +* so nn represents zero +*/ +if (s[i] != nn) + goto decode; + } + +/* syndrome is zero, no errors to correct */ +return 0 ; + }/* form the syndromes; i.e., evaluate data(x) at roots of * g(x) */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 179/249 gpio: Fix return value mismatch of function gpiod_get_from_of_node()
In reply to Sasha LevinFrom: Waibel Georg <[email protected]>
[ Upstream commit 025bf37725f1929542361eef2245df30badf242e ]
In case the requested gpio property is not found in the device tree, some callers of gpiod_get_from_of_node() expect a return value of NULL, others expect -ENOENT.
In particular devm_fwnode_get_index_gpiod_from_child() expects -ENOENT. Currently it gets a NULL, which breaks the loop that tries all gpio_suffixes. The result is that a gpio property is not found, even though it is there.
This patch changes gpiod_get_from_of_node() to return -ENOENT instead of NULL when the requested gpio property is not found in the device tree. Additionally it modifies all calling functions to properly evaluate the return value.
Another approach would be to leave the return value of gpiod_get_from_of_node() as is and fix the bug in devm_fwnode_get_index_gpiod_from_child(). Other callers would still need to be reworked. The effort would be the same as with the chosen solution.
--- drivers/gpio/gpiolib.c | 6 +----- drivers/regulator/da9211-regulator.c | 2 ++ drivers/regulator/s2mps11.c | 4 +++- drivers/regulator/s5m8767.c | 4 +++- drivers/regulator/tps65090-regulator.c | 7 ++++--- 5 files changed, 13 insertions(+), 10 deletions(-)
drivers/gpio/gpiolib.c +1 -5
@@ -4244,8 +4244,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);* * Returns: * On successful request the GPIO pin is configured in accordance with -* provided @dflags. If the node does not have the requested GPIO -* property, NULL is returned. +* provided @dflags. * * In case of error an ERR_PTR() is returned. */
@@ -4267,9 +4266,6 @@ struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, index, &flags);if (!desc ||IS_ERR (desc)) { -/* If it is not there, just return NULL */ -if (PTR_ERR (desc) == -ENOENT ) -return NULL ;return desc; }
drivers/regulator/da9211-regulator.c +2 -0
@@ -289,6 +289,8 @@ static struct da9211_pdata *da9211_parse_regulators_dt(0 ,GPIOD_OUT_HIGH |GPIOD_FLAGS_BIT_NONEXCLUSIVE , "da9211-enable"); +if (IS_ERR (pdata->gpiod_ren[n])) + pdata->gpiod_ren[n] =NULL ; n++; }
drivers/regulator/s2mps11.c +3 -1
@@ -821,7 +821,9 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev,0 ,GPIOD_OUT_HIGH |GPIOD_FLAGS_BIT_NONEXCLUSIVE , "s2mps11-regulator"); -if (IS_ERR (gpio[reg])) { +if (PTR_ERR (gpio[reg]) == -ENOENT ) + gpio[reg] =NULL ; +else if (IS_ERR (gpio[reg])) {dev_err (&pdev->dev,"Failed to get control GPIO for %d/%s\n" , reg, rdata[reg].name);continue ;
drivers/regulator/s5m8767.c +3 -1
@@ -574,7 +574,9 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,0 ,GPIOD_OUT_HIGH |GPIOD_FLAGS_BIT_NONEXCLUSIVE , "s5m8767"); -if (IS_ERR (rdata->ext_control_gpiod)) +if (PTR_ERR (rdata->ext_control_gpiod) == -ENOENT ) + rdata->ext_control_gpiod =NULL ; +else if (IS_ERR (rdata->ext_control_gpiod))return PTR_ERR (rdata->ext_control_gpiod); rdata->id = i;
drivers/regulator/tps65090-regulator.c +4 -3
@@ -371,11 +371,12 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data("dcdc-ext-control-gpios" ,0 , gflags, "tps65090"); -if (IS_ERR (rpdata->gpiod)) -return ERR_CAST (rpdata->gpiod); -if (!rpdata->gpiod) +if (PTR_ERR (rpdata->gpiod) == -ENOENT ) {dev_err (&pdev->dev,"could not find DCDC external control GPIO\n" ); + rpdata->gpiod =NULL ; + }else if (IS_ERR (rpdata->gpiod)) +return ERR_CAST (rpdata->gpiod); } if (of_property_read_u32(tps65090_matches[idx].of_node,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 180/249 net: hns3: restore the MAC autoneg state after reset
In reply to Sasha LevinFrom: Jian Shen <[email protected]>
[ Upstream commit d736fc6c68a5f76e89a6c2c4100e3678706003a3 ]
When doing global reset, the MAC autoneg state of fibre port is set to default, which may cause user configuration lost. This patch fixes it by restore the MAC autoneg state after reset.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +9 -0
@@ -2389,6 +2389,15 @@ static int hclge_mac_init(struct hclge_dev *hdev)return ret; } +if (hdev->hw.mac.support_autoneg) { + ret =hclge_set_autoneg_en (hdev, hdev->hw.mac.autoneg); +if (ret) { +dev_err (&hdev->pdev->dev, +"Config mac autoneg fail ret=%d\n" , ret); +return ret; + } + } + mac->link =0 ;if (mac->user_fec_mode &BIT (HNAE3_FEC_USER_DEF )) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 181/249 net/mlx5: Get vport ACL namespace by vport index
In reply to Sasha LevinFrom: Jianbo Liu <[email protected]>
[ Upstream commit f53297d67800feb5fafd94abd926c889aefee690 ]
The ingress and egress ACL root namespaces are created per vport and stored into arrays. However, the vport number is not the same as the index. Passing the array index, instead of vport number, to get the correct ingress and egress acl namespace.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +2 -2
@@ -939,7 +939,7 @@ int esw_vport_enable_egress_acl(struct mlx5_eswitch *esw, vport->vport, MLX5_CAP_ESW_EGRESS_ACL(dev, log_max_ft_size)); root_ns =mlx5_get_flow_vport_acl_namespace (dev,MLX5_FLOW_NAMESPACE_ESW_EGRESS , - vport->vport); +mlx5_eswitch_vport_num_to_index (esw, vport->vport));if (!root_ns) {esw_warn (dev,"Failed to get E-Switch egress flow namespace for vport (%d)\n" , vport->vport);return -EOPNOTSUPP ;
@@ -1057,7 +1057,7 @@ int esw_vport_enable_ingress_acl(struct mlx5_eswitch *esw, vport->vport, MLX5_CAP_ESW_INGRESS_ACL(dev, log_max_ft_size)); root_ns =mlx5_get_flow_vport_acl_namespace (dev,MLX5_FLOW_NAMESPACE_ESW_INGRESS , - vport->vport); +mlx5_eswitch_vport_num_to_index (esw, vport->vport));if (!root_ns) {esw_warn (dev,"Failed to get E-Switch ingress flow namespace for vport (%d)\n" , vport->vport);return -EOPNOTSUPP ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 182/249 ixgbe: Check DDM existence in transceiver before access
In reply to Sasha LevinFrom: "Mauro S. M. Rodrigues" <[email protected]>
[ Upstream commit 655c91414579d7bb115a4f7898ee726fc18e0984 ]
Some transceivers may comply with SFF-8472 but not implement the Digital Diagnostic Monitoring (DDM) interface described in it. The existence of such area is specified by bit 6 of byte 92, set to 1 if implemented.
Currently, due to not checking this bit ixgbe fails trying to read SFP module's eeprom with the follow message:
ethtool -m enP51p1s0f0
Cannot get Module EEPROM data: Input/output error
Because it fails to read the additional 256 bytes in which it was assumed to exist the DDM data.
This issue was noticed using a Mellanox Passive DAC PN 01FT738. The eeprom data was confirmed by Mellanox as correct and present in other Passive DACs in from other manufacturers.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 3 ++- drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +2 -1
@@ -3226,7 +3226,8 @@ static int ixgbe_get_module_info(struct net_device *dev, page_swap = true; } -if (sff8472_rev ==IXGBE_SFF_SFF_8472_UNSUP || page_swap) { +if (sff8472_rev ==IXGBE_SFF_SFF_8472_UNSUP || page_swap || + !(addr_mode &IXGBE_SFF_DDM_IMPLEMENTED )) {/* We have a SFP, but it does not support SFF-8472 */ modinfo->type =ETH_MODULE_SFF_8079 ; modinfo->eeprom_len =ETH_MODULE_SFF_8079_LEN ;
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h +1 -0
@@ -45,6 +45,7 @@#define IXGBE_SFF_SOFT_RS_SELECT_10G 0x8#define IXGBE_SFF_SOFT_RS_SELECT_1G 0x0#define IXGBE_SFF_ADDRESSING_MODE 0x4 +#define IXGBE_SFF_DDM_IMPLEMENTED 0x40#define IXGBE_SFF_QSFP_DA_ACTIVE_CABLE 0x1#define IXGBE_SFF_QSFP_DA_PASSIVE_CABLE 0x8#define IXGBE_SFF_QSFP_CONNECTOR_NOT_SEPARABLE 0x23
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 183/249 crypto: serpent - mark __serpent_setkey_sbox noinline
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 473971187d6727609951858c63bf12b0307ef015 ]
The same bug that gcc hit in the past is apparently now showing up with clang, which decides to inline __serpent_setkey_sbox:
crypto/serpent_generic.c:268:5: error: stack frame size of 2112 bytes in function '__serpent_setkey' [-Werror,-Wframe-larger-than=]
Marking it 'noinline' reduces the stack usage from 2112 bytes to 192 and 96 bytes, respectively, and seems to generate more useful object code.
--- crypto/serpent_generic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
crypto/serpent_generic.c +7 -1
@@ -225,7 +225,13 @@ x4 ^= x2; \ }) -static void __serpent_setkey_sbox (u32 r0,u32 r1,u32 r2,u32 r3,u32 r4,u32 *k) +/* +* both gcc and clang have misoptimized this function in the past, +* producing horrible object code from spilling temporary variables +* on the stack. Forcing this part out of line avoids that. +*/ +static noinline void __serpent_setkey_sbox(u32 r0, u32 r1, u32 r2, +u32 r3,u32 r4,u32 *k) { k +=100 ;S3 (r3, r4, r0, r1, r2);store_and_load_keys (r1, r2, r4, r3,28 ,24 );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 184/249 crypto: asymmetric_keys - select CRYPTO_HASH where needed
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 90acc0653d2bee203174e66d519fbaaa513502de ]
Build testing with some core crypto options disabled revealed a few modules that are missing CRYPTO_HASH:
crypto/asymmetric_keys/x509_public_key.o: In function `x509_get_sig_params':
x509_public_key.c:(.text+0x4c7): undefined reference to crypto_alloc_shash' x509_public_key.c:(.text+0x5e5): undefined reference to crypto_shash_digest' crypto/asymmetric_keys/pkcs7_verify.o: In function `pkcs7_digest.isra.0':
pkcs7_verify.c:(.text+0xab): undefined reference to crypto_alloc_shash' pkcs7_verify.c:(.text+0x1b2): undefined reference to crypto_shash_digest' pkcs7_verify.c:(.text+0x3c1): undefined reference to crypto_shash_update' pkcs7_verify.c:(.text+0x411): undefined reference to crypto_shash_finup'
This normally doesn't show up in randconfig tests because there is a large number of other options that select CRYPTO_HASH.
--- crypto/asymmetric_keys/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
crypto/asymmetric_keys/Kconfig +3 -0
@@ -15,6 +15,7 @@ config ASYMMETRIC_PUBLIC_KEY_SUBTYPE select MPILIB select CRYPTO_HASH_INFO select CRYPTO_AKCIPHER + select CRYPTO_HASH help This option provides support for asymmetric public key type handling. If signature generation and/or verification are to be used,
@@ -65,6 +66,7 @@ config TPM_KEY_PARSER config PKCS7_MESSAGE_PARSER tristate "PKCS#7 message parser" depends on X509_CERTIFICATE_PARSER + select CRYPTO_HASH select ASN1 select OID_REGISTRY help
@@ -87,6 +89,7 @@ config SIGNED_PE_FILE_VERIFICATION bool "Support for PE file signature verification" depends on PKCS7_MESSAGE_PARSER=y depends on SYSTEM_DATA_VERIFICATION + select CRYPTO_HASH select ASN1 select OID_REGISTRY help
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 185/249 PCI / ACPI: Use cached ACPI device state to get PCI device power state
In reply to Sasha LevinFrom: Mika Westerberg <[email protected]>
[ Upstream commit 83a16e3f6d70da99896c7a2639c0b60fff13afb8 ]
The ACPI power state returned by acpi_device_get_power() may depend on the configuration of ACPI power resources in the system which may change any time after acpi_device_get_power() has returned, unless the reference counters of the ACPI power resources in question are set to prevent that from happening. Thus it is invalid to use acpi_device_get_power() in acpi_pci_get_power_state() the way it is done now and the value of the ->power.state field in the corresponding struct acpi_device objects (which reflects the ACPI power resources reference counting, among other things) should be used instead.
As an example where this becomes an issue is Intel Ice Lake where the Thunderbolt controller (NHI), two PCIe root ports (RP0 and RP1) and xHCI all share the same power resources. The following picture with power resources marked with [] shows the topology:
Host bridge
|
+- RP0 ---\
+- RP1 ---|--+--> [TBT]
+- NHI --/ |
| |
| v
+- xHCI --> [D3C]Here TBT and D3C are the shared ACPI power resources. ACPI _PR3() method of the devices in question returns either TBT or D3C or both.
Say we runtime suspend first the root ports RP0 and RP1, then NHI. Now since the TBT power resource is still on when the root ports are runtime suspended their dev->current_state is set to D3hot. When NHI is runtime suspended TBT is finally turned off but state of the root ports remain to be D3hot. Now when the xHCI is runtime suspended D3C gets also turned off. PCI core thus has power states of these devices cached in their dev->current_state as follows:
RP0 -> D3hot
RP1 -> D3hot
NHI -> D3cold
xHCI -> D3cold
If the user now runs lspci for instance, the result is all 1's like in the below output (00:07.0 is the first root port, RP0):
00:07.0 PCI bridge: Intel Corporation Device 8a1d (rev ff) (prog-if ff)
!!! Unknown header type 7f
Kernel driver in use: pcieport
In short the hardware state is not in sync with the software state anymore. The exact same thing happens with the PME polling thread which ends up bringing the root ports back into D0 after they are runtime suspended.
For this reason, modify acpi_pci_get_power_state() so that it uses the ACPI device power state that was cached by the ACPI core. This makes the PCI device power state match the ACPI device power state regardless of state of the shared power resources which may still be on at this point.
--- drivers/pci/pci-acpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/pci-acpi.c +2 -1
@@ -685,7 +685,8 @@ static pci_power_t acpi_pci_get_power_state(struct pci_dev *dev)if (!adev || !acpi_device_power_manageable (adev))return PCI_UNKNOWN ; -if (acpi_device_get_power (adev, &state) || state ==ACPI_STATE_UNKNOWN ) + state = adev->power.state; +if (state ==ACPI_STATE_UNKNOWN )return PCI_UNKNOWN ;return state_conv[state];
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 186/249 ath9k: correctly handle short radar pulses
In reply to Sasha LevinFrom: Zefir Kurtisi <[email protected]>
[ Upstream commit df5c4150501ee7e86383be88f6490d970adcf157 ]
In commit 3c0efb745a17 ("ath9k: discard undersized packets") the lower bound of RX packets was set to 10 (min ACK size) to filter those that would otherwise be treated as invalid at mac80211.
Alas, short radar pulses are reported as PHY_ERROR frames with length set to 3. Therefore their detection stopped working after that commit.
NOTE: ath9k drivers built thereafter will not pass DFS certification.
This extends the criteria for short packets to explicitly handle PHY_ERROR frames.
--- drivers/net/wireless/ath/ath9k/recv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/recv.c +5 -1
@@ -815,6 +815,7 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,struct ath_common *common =ath9k_hw_common (ah);struct ieee80211_hdr *hdr;bool discard_current = sc->rx.discard_next; +bool is_phyerr;/* * Discard corrupt descriptors which are marked in
@@ -827,8 +828,11 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,/* * Discard zero-length packets and packets smaller than an ACK +* which are not PHY_ERROR (short radar pulses have a length of 3) */ -if (rx_stats->rs_datalen <10 ) { + is_phyerr = rx_stats->rs_status &ATH9K_RXERR_PHY ; +if (!rx_stats->rs_datalen || + (rx_stats->rs_datalen <10 && !is_phyerr)) {RX_STAT_INC (sc, rx_len_err); goto corrupt; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 187/249 wil6210: drop old event after wmi_call timeout
In reply to Sasha LevinFrom: Ahmad Masri <[email protected]>
[ Upstream commit 1a276003111c0404f6bfeffe924c5a21f482428b ]
This change fixes a rare race condition of handling WMI events after wmi_call expires.
wmi_recv_cmd immediately handles an event when reply_buf is defined and a wmi_call is waiting for the event.
However, in case the wmi_call has already timed-out, there will be no waiting/running wmi_call and the event will be queued in WMI queue and will be handled later in wmi_event_handle.
Meanwhile, a new similar wmi_call for the same command and event may be issued. In this case, when handling the queued event we got WARN_ON printed.
Fixing this case as a valid timeout and drop the unexpected event.
--- drivers/net/wireless/ath/wil6210/wmi.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/wil6210/wmi.c +12 -1
@@ -3220,7 +3220,18 @@ static void wmi_event_handle(struct wil6210_priv *wil,/* check if someone waits for this event */ if (wil->reply_id && wil->reply_id == id && wil->reply_mid == mid) { -WARN_ON (wil->reply_buf); +if (wil->reply_buf) { +/* event received while wmi_call is waiting +* with a buffer. Such event should be handled +* in wmi_recv_cmd function. Handling the event +* here means a previous wmi_call was timeout. +* Drop the event and do not handle it. +*/ +wil_err (wil, +"Old event (%d, %s) while wmi_call is waiting. Drop it and Continue waiting\n" , + id,eventid2name (id)); +return ; + }wmi_evt_call_handler (vif, id, evt_data, len -sizeof (*wmi));
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 188/249 EDAC: Fix global-out-of-bounds write when setting edac_mc_poll_msec
In reply to Sasha LevinFrom: Eiichi Tsukata <[email protected]>
[ Upstream commit d8655e7630dafa88bc37f101640e39c736399771 ]
Commit 9da21b1509d8 ("EDAC: Poll timeout cannot be zero, p2") assumes edac_mc_poll_msec to be unsigned long, but the type of the variable still remained as int. Setting edac_mc_poll_msec can trigger out-of-bounds write.
Reproducer:
# echo 1001 > /sys/module/edac_core/parameters/edac_mc_poll_msec
KASAN report:
BUG: KASAN: global-out-of-bounds in edac_set_poll_msec+0x140/0x150
Write of size 8 at addr ffffffffb91b2d00 by task bash/1996
CPU: 1 PID: 1996 Comm: bash Not tainted 5.2.0-rc6+ #23
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014
Call Trace:
dump_stack+0xca/0x13e
print_address_description.cold+0x5/0x246
__kasan_report.cold+0x75/0x9a
? edac_set_poll_msec+0x140/0x150
kasan_report+0xe/0x20
edac_set_poll_msec+0x140/0x150
? dimmdev_location_show+0x30/0x30
? vfs_lock_file+0xe0/0xe0
? _raw_spin_lock+0x87/0xe0
param_attr_store+0x1b5/0x310
? param_array_set+0x4f0/0x4f0
module_attr_store+0x58/0x80
? module_attr_show+0x80/0x80
sysfs_kf_write+0x13d/0x1a0
kernfs_fop_write+0x2bc/0x460
? sysfs_kf_bin_read+0x270/0x270
? kernfs_notify+0x1f0/0x1f0
__vfs_write+0x81/0x100
vfs_write+0x1e1/0x560
ksys_write+0x126/0x250
? __ia32_sys_read+0xb0/0xb0
? do_syscall_64+0x1f/0x390
do_syscall_64+0xc1/0x390
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7fa7caa5e970
Code: 73 01 c3 48 8b 0d 28 d5 2b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 99 2d 2c 00 00 75 10 b8 01 00 00 00 04
RSP: 002b:00007fff6acfdfe8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007fa7caa5e970
RDX: 0000000000000005 RSI: 0000000000e95c08 RDI: 0000000000000001
RBP: 0000000000e95c08 R08: 00007fa7cad1e760 R09: 00007fa7cb36a700
R10: 0000000000000073 R11: 0000000000000246 R12: 0000000000000005
R13: 0000000000000001 R14: 00007fa7cad1d600 R15: 0000000000000005
The buggy address belongs to the variable:
edac_mc_poll_msec+0x0/0x40
Memory state around the buggy address:
ffffffffb91b2c00: 00 00 00 00 fa fa fa fa 00 00 00 00 fa fa fa fa
ffffffffb91b2c80: 00 00 00 00 fa fa fa fa 00 00 00 00 fa fa fa fa
>ffffffffb91b2d00: 04 fa fa fa fa fa fa fa 04 fa fa fa fa fa fa fa
^
ffffffffb91b2d80: 04 fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
ffffffffb91b2e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00Fix it by changing the type of edac_mc_poll_msec to unsigned int. The reason why this patch adopts unsigned int rather than unsigned long is msecs_to_jiffies() assumes arg to be unsigned int. We can avoid integer conversion bugs and unsigned int will be large enough for edac_mc_poll_msec.
--- drivers/edac/edac_mc_sysfs.c | 16 ++++++++-------- drivers/edac/edac_module.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/edac/edac_mc_sysfs.c +8 -8
@@ -26,7 +26,7 @@static int edac_mc_log_ue =1 ;static int edac_mc_log_ce =1 ;static int edac_mc_panic_on_ue; -static int edac_mc_poll_msec =1000 ; +static unsigned int edac_mc_poll_msec =1000 ;/* Getter functions for above */ int edac_mc_get_log_ue (void )
@@ -45,30 +45,30 @@ int edac_mc_get_panic_on_ue(void) }/* this is temporary */ -int edac_mc_get_poll_msec (void ) +unsigned int edac_mc_get_poll_msec (void ) {return edac_mc_poll_msec; }static int edac_set_poll_msec (const char *val,const struct kernel_param *kp) { -unsigned long l; +unsigned int i;int ret;if (!val)return -EINVAL ; - ret =kstrtoul (val,0 , &l); + ret =kstrtouint (val,0 , &i);if (ret)return ret; -if (l <1000 ) +if (i <1000 )return -EINVAL ; - *((unsigned long *)kp->arg) = l; + *((unsigned int *)kp->arg) = i;/* notify edac_mc engine to reset the poll period */ -edac_mc_reset_delay_period (l); +edac_mc_reset_delay_period (i);return 0 ; }
@@ -82,7 +82,7 @@ MODULE_PARM_DESC(edac_mc_log_ue,module_param (edac_mc_log_ce, int,0644 );MODULE_PARM_DESC (edac_mc_log_ce,"Log correctable error to console: 0=off 1=on" ); -module_param_call (edac_mc_poll_msec, edac_set_poll_msec, param_get_int, +module_param_call (edac_mc_poll_msec, edac_set_poll_msec, param_get_uint, &edac_mc_poll_msec,0644 );MODULE_PARM_DESC (edac_mc_poll_msec,"Polling period in milliseconds" );
drivers/edac/edac_module.h +1 -1
@@ -36,7 +36,7 @@ extern int edac_mc_get_log_ue(void);extern int edac_mc_get_log_ce (void );extern int edac_mc_get_panic_on_ue (void );extern int edac_get_poll_msec (void ); -extern int edac_mc_get_poll_msec (void ); +extern unsigned int edac_mc_get_poll_msec (void );unsigned edac_dimm_info_location (struct dimm_info *dimm,char *buf,unsigned len);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 189/249 net/mlx5e: Attach/detach XDP program safely
In reply to Sasha LevinFrom: Maxim Mikityanskiy <[email protected]>
[ Upstream commit e18953240de8b46360a67090c87ee1ef8160b35d ]
When an XDP program is set, a full reopen of all channels happens in two cases:
1. When there was no program set, and a new one is being set.
2. When there was a program set, but it's being unset.
The full reopen is necessary, because the channel parameters may change if XDP is enabled or disabled. However, it's performed in an unsafe way:
if the new channels fail to open, the old ones are already closed, and the interface goes down. Use the safe way to switch channels instead. The same way is already used for other configuration changes.
--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +20 -11
@@ -4192,8 +4192,6 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)/* no need for full reset when exchanging programs */ reset = (!priv->channels.params.xdp_prog || !prog); -if (was_opened && reset) -mlx5e_close_locked (netdev);if (was_opened && !reset) {/* num_channels is invariant here, so we can take the * batched reference right upfront.
@@ -4205,20 +4203,31 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog) } } -/* exchange programs, extra prog reference we got from caller -* as long as we don't fail from this point onwards. -*/ - old_prog =xchg (&priv->channels.params.xdp_prog, prog); +if (was_opened && reset) { +struct mlx5e_channels new_channels = {}; + + new_channels.params = priv->channels.params; + new_channels.params.xdp_prog = prog; +mlx5e_set_rq_type (priv->mdev, &new_channels.params); + old_prog = priv->channels.params.xdp_prog; + + err =mlx5e_safe_switch_channels (priv, &new_channels,NULL ); +if (err) + goto unlock; + }else { +/* exchange programs, extra prog reference we got from caller +* as long as we don't fail from this point onwards. +*/ + old_prog =xchg (&priv->channels.params.xdp_prog, prog); + } +if (old_prog)bpf_prog_put (old_prog); -if (reset)/* change RQ type according to priv->xdp_prog */ +if (!was_opened && reset)/* change RQ type according to priv->xdp_prog */ mlx5e_set_rq_type (priv->mdev, &priv->channels.params); -if (was_opened && reset) - err =mlx5e_open_locked (netdev); - -if (!test_bit (MLX5E_STATE_OPENED , &priv->state) || reset) +if (!was_opened || reset) goto unlock;/* exchanging programs w/o reset, we update ref counts on behalf
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 190/249 cpufreq: Avoid calling cpufreq_verify_current_freq() from handle_update()
In reply to Sasha LevinFrom: Viresh Kumar <[email protected]>
[ Upstream commit 70a59fde6e69d1d8579f84bf4555bfffb3ce452d ]
On some occasions cpufreq_verify_current_freq() schedules a work whose callback is handle_update(), which further calls cpufreq_update_policy() which may end up calling cpufreq_verify_current_freq() again.
On the other hand, when cpufreq_update_policy() is called from handle_update(), the pointer to the cpufreq policy is already available, but cpufreq_cpu_acquire() is still called to get it in cpufreq_update_policy(), which should be avoided as well.
To fix these issues, create a new helper, refresh_frequency_limits(), and make both handle_update() call it cpufreq_update_policy().
--- drivers/cpufreq/cpufreq.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/cpufreq/cpufreq.c +16 -10
@@ -1114,13 +1114,25 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cpreturn ret; } +static void refresh_frequency_limits (struct cpufreq_policy *policy) +{ +struct cpufreq_policy new_policy = *policy; + +pr_debug ("updating policy for CPU %u\n" , policy->cpu); + + new_policy.min = policy->user_policy.min; + new_policy.max = policy->user_policy.max; + +cpufreq_set_policy (policy, &new_policy); +} +static void handle_update (struct work_struct *work) {struct cpufreq_policy *policy = container_of(work, struct cpufreq_policy, update); -unsigned int cpu = policy->cpu; -pr_debug ("handle_update for cpu %u called\n" , cpu); -cpufreq_update_policy (cpu); + +pr_debug ("handle_update for cpu %u called\n" , policy->cpu); +refresh_frequency_limits (policy); }static struct cpufreq_policy *cpufreq_policy_alloc (unsigned int cpu)
@@ -2392,7 +2404,6 @@ int cpufreq_set_policy(struct cpufreq_policy *policy,void cpufreq_update_policy (unsigned int cpu) {struct cpufreq_policy *policy =cpufreq_cpu_acquire (cpu); -struct cpufreq_policy new_policy;if (!policy)return ;
@@ -2405,12 +2416,7 @@ void cpufreq_update_policy(unsigned int cpu) (cpufreq_suspended || WARN_ON(!cpufreq_update_current_freq(policy)))) goto unlock; -pr_debug ("updating policy for CPU %u\n" , cpu); -memcpy (&new_policy, policy,sizeof (*policy)); - new_policy.min = policy->user_policy.min; - new_policy.max = policy->user_policy.max; - -cpufreq_set_policy (policy, &new_policy); +refresh_frequency_limits (policy); unlock:cpufreq_cpu_release (policy);
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.2 190/249] cpufreq: Avoid calling cpufreq_verify_current_freq() from handle_update()
Quoted 70 lines · Sasha Levin
From: Viresh Kumar <[email protected]>
[ Upstream commit
70a59fde6e69d1d8579f84bf4555bfffb3ce452d]On some occasions
cpufreq_verify_current_freq()schedules a work whose callback ishandle_update(), which further callscpufreq_update_policy()which may end up callingcpufreq_verify_current_freq()again.On the other hand, when
cpufreq_update_policy()is called fromhandle_update(), the pointer to the cpufreq policy is already available, butcpufreq_cpu_acquire()is still called to get it incpufreq_update_policy(), which should be avoided as well.To fix these issues, create a new helper,
refresh_frequency_limits(), and make bothhandle_update()call itcpufreq_update_policy().Signed-off-by Viresh Kumar <[email protected]>[ rjw: Rename reeval_frequency_limits() as refresh_frequency_limits() ][ rjw: Changelog ]Signed-off-by Rafael J. Wysocki <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/cpufreq/cpufreq.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)drivers/cpufreq/cpufreq.c +15
-4@@ -1114,13 +1114,25 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cpreturn ret; } +static void refresh_frequency_limits (struct cpufreq_policy *policy) +{ +struct cpufreq_policy new_policy = *policy; + +pr_debug ("updating policy for CPU %u\n" , policy->cpu); + + new_policy.min = policy->user_policy.min; + new_policy.max = policy->user_policy.max; + +cpufreq_set_policy (policy, &new_policy); +} +static void handle_update (struct work_struct *work) {struct cpufreq_policy *policy = container_of(work, struct cpufreq_policy, update); -unsigned int cpu = policy->cpu; -pr_debug ("handle_update for cpu %u called\n" , cpu); -cpufreq_update_policy (cpu); + +pr_debug ("handle_update for cpu %u called\n" , policy->cpu); +refresh_frequency_limits (policy); }static struct cpufreq_policy *cpufreq_policy_alloc (unsigned int cpu)@@ -2392,7 +2404,6 @@ int cpufreq_set_policy(struct cpufreq_policy *policy,void cpufreq_update_policy (unsigned int cpu) {struct cpufreq_policy *policy =cpufreq_cpu_acquire (cpu); -struct cpufreq_policy new_policy;if (!policy)return ;@@ -2405,12 +2416,7 @@ void cpufreq_update_policy(unsigned int cpu) (cpufreq_suspended || WARN_ON(!cpufreq_update_current_freq(policy)))) goto unlock;
drivers/cpufreq/cpufreq.c void cpufreq_update_policy(unsigned int cpu) · line 2422
Quoted 10 lines
drivers/cpufreq/cpufreq.c +1
-6-pr_debug ("updating policy for CPU %u\n" , cpu); -memcpy (&new_policy, policy,sizeof (*policy)); - new_policy.min = policy->user_policy.min; - new_policy.max = policy->user_policy.max; - -cpufreq_set_policy (policy, &new_policy); +refresh_frequency_limits (policy); unlock:cpufreq_cpu_release (policy);
I don't think this is suitable for -stable.
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.2 190/249] cpufreq: Avoid calling cpufreq_verify_current_freq() from handle_update()
Quoted 70 lines · Rafael J. Wysocki
Quoted 69 lines · Sasha Levin
From: Viresh Kumar <[email protected]>
[ Upstream commit
70a59fde6e69d1d8579f84bf4555bfffb3ce452d]On some occasions
cpufreq_verify_current_freq()schedules a work whose callback ishandle_update(), which further callscpufreq_update_policy()which may end up callingcpufreq_verify_current_freq()again.On the other hand, when
cpufreq_update_policy()is called fromhandle_update(), the pointer to the cpufreq policy is already available, butcpufreq_cpu_acquire()is still called to get it incpufreq_update_policy(), which should be avoided as well.To fix these issues, create a new helper,
refresh_frequency_limits(), and make bothhandle_update()call itcpufreq_update_policy().Signed-off-by Viresh Kumar <[email protected]>[ rjw: Rename reeval_frequency_limits() as refresh_frequency_limits() ][ rjw: Changelog ]Signed-off-by Rafael J. Wysocki <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/cpufreq/cpufreq.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)drivers/cpufreq/cpufreq.c +15
-7@@ -1114,13 +1114,25 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cpreturn ret; } +static void refresh_frequency_limits (struct cpufreq_policy *policy) +{ +struct cpufreq_policy new_policy = *policy; + +pr_debug ("updating policy for CPU %u\n" , policy->cpu); + + new_policy.min = policy->user_policy.min; + new_policy.max = policy->user_policy.max; + +cpufreq_set_policy (policy, &new_policy); +} +static void handle_update (struct work_struct *work) {struct cpufreq_policy *policy = container_of(work, struct cpufreq_policy, update); -unsigned int cpu = policy->cpu; -pr_debug ("handle_update for cpu %u called\n" , cpu); -cpufreq_update_policy (cpu); + +pr_debug ("handle_update for cpu %u called\n" , policy->cpu); +refresh_frequency_limits (policy); }static struct cpufreq_policy *cpufreq_policy_alloc (unsigned int cpu)@@ -2392,7 +2404,6 @@ int cpufreq_set_policy(struct cpufreq_policy *policy,void cpufreq_update_policy (unsigned int cpu) {struct cpufreq_policy *policy =cpufreq_cpu_acquire (cpu); -struct cpufreq_policy new_policy;if (!policy)return ;@@ -2405,12 +2416,7 @@ void cpufreq_update_policy(unsigned int cpu) (cpufreq_suspended || WARN_ON(!cpufreq_update_current_freq(policy)))) goto unlock; -pr_debug ("updating policy for CPU %u\n" , cpu); -memcpy (&new_policy, policy,sizeof (*policy)); - new_policy.min = policy->user_policy.min;
Quoted 8 lines
drivers/cpufreq/cpufreq.c void cpufreq_update_policy(unsigned int cpu) · line 2422
Quoted 6 lines
drivers/cpufreq/cpufreq.c +1
-3- new_policy.max = policy->user_policy.max; - -cpufreq_set_policy (policy, &new_policy); +refresh_frequency_limits (policy); unlock:cpufreq_cpu_release (policy);I don't think this is suitable for -stable.
I've dropped it, thanks!
--
Thanks,
Sasha
Sasha Levin
maintainerPATCH 191/249 cpufreq: Don't skip frequency validation for has_target() drivers
In reply to Sasha LevinFrom: Viresh Kumar <[email protected]>
[ Upstream commit 9801522840cc1073f8064b4c979b7b6995c74bca ]
CPUFREQ_CONST_LOOPS was introduced in a very old commit from pre-2.6 kernel release by commit 6a4a93f9c0d5 ("[CPUFREQ] Fix 'out of sync' issue").
Basically, that commit does two things:
- It adds the frequency verification code (which is quite similar to what we have today as well).
- And it sets the CPUFREQ_CONST_LOOPS flag only for setpolicy drivers, rightly so based on the code we had then. The idea was to avoid frequency validation for setpolicy drivers as the cpufreq core doesn't know what frequency the hardware is running at and so no point in doing frequency verification.
The problem happened when we started to use the same CPUFREQ_CONST_LOOPS flag for constant loops-per-jiffy thing as well and many has_target() drivers started using the same flag and unknowingly skipped the verification of frequency. There is no logical reason behind skipping frequency validation because of the presence of CPUFREQ_CONST_LOOPS flag otherwise.
Fix this issue by skipping frequency validation only for setpolicy drivers and always doing it for has_target() drivers irrespective of the presence or absence of CPUFREQ_CONST_LOOPS flag.
cpufreq_notify_transition() is only called for has_target() type driver and not for set_policy type, and the check is simply redundant. Remove it as well.
Also remove () around freq comparison statement as they aren't required and checkpatch also warns for them.
--- drivers/cpufreq/cpufreq.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/cpufreq/cpufreq.c +5 -8
@@ -356,12 +356,10 @@ static void cpufreq_notify_transition(struct cpufreq_policy *policy,* which is not equal to what the cpufreq core thinks is * "old frequency". */ -if (!(cpufreq_driver->flags &CPUFREQ_CONST_LOOPS )) { -if (policy->cur && (policy->cur != freqs->old)) { -pr_debug ("Warning: CPU frequency is %u, cpufreq assumed %u kHz\n" , - freqs->old, policy->cur); - freqs->old = policy->cur; - } +if (policy->cur && policy->cur != freqs->old) { +pr_debug ("Warning: CPU frequency is %u, cpufreq assumed %u kHz\n" , + freqs->old, policy->cur); + freqs->old = policy->cur; } srcu_notifier_call_chain(&cpufreq_transition_notifier_list,
@@ -1627,8 +1625,7 @@ static unsigned int __cpufreq_get(struct cpufreq_policy *policy)if (policy->fast_switch_enabled)return ret_freq; -if (ret_freq && policy->cur && - !(cpufreq_driver->flags &CPUFREQ_CONST_LOOPS )) { +if (has_target () && ret_freq && policy->cur) {/* verify no discrepancy between actual and saved value exists */ if (unlikely (ret_freq != policy->cur)) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 192/249 bcache: fix return value error in bch_journal_read()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit 0ae49cb7aa005ed18fe8f4d6ccf73019b78ac7b2 ]
When everything is OK in bch_journal_read(), finally the return value is returned by,
return ret;
which assumes ret will be 0 here. This assumption is wrong when all journal buckets as are full and filled with valid journal entries. In such cache the last location referencess read_bucket() sets 'ret' to 1, which means new jset added into jset list. The jset list is list 'journal' in caller run_cache_set().
Return 1 to run_cache_set() means something wrong and the cache set won't start, but indeed everything is OK.
This patch changes the line at end of bch_journal_read() to directly return 0 since everything if verything is good. Then a bogus error is fixed.
--- drivers/md/bcache/journal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/journal.c +1 -1
@@ -268,7 +268,7 @@ int bch_journal_read(struct cache_set *c, struct list_head *list) struct journal_replay, list)->j.seq; -return ret; +return 0 ;#undef read_bucket }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 193/249 bcache: check CACHE_SET_IO_DISABLE in allocator code
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit e775339e1ae1205b47d94881db124c11385e597c ]
If CACHE_SET_IO_DISABLE of a cache set flag is set by too many I/O errors, currently allocator routines can still continue allocate space which may introduce inconsistent metadata state.
This patch checkes CACHE_SET_IO_DISABLE bit in following allocator routines,
- bch_bucket_alloc()
- __bch_bucket_alloc_set()
Once CACHE_SET_IO_DISABLE is set on cache set, the allocator routines may reject allocation request earlier to avoid potential inconsistent metadata.
--- drivers/md/bcache/alloc.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/md/bcache/alloc.c +9 -0
@@ -393,6 +393,11 @@ long bch_bucket_alloc(struct cache *ca, unsigned int reserve, bool wait)struct bucket *b;long r; + +/* No allocation if CACHE_SET_IO_DISABLE bit is set */ +if (unlikely (test_bit (CACHE_SET_IO_DISABLE , &ca->set->flags))) +return -1 ; +/* fastpath */ if (fifo_pop (&ca->free[RESERVE_NONE ], r) ||fifo_pop (&ca->free[reserve], r))
@@ -484,6 +489,10 @@ int __bch_bucket_alloc_set(struct cache_set *c, unsigned int reserve, {int i; +/* No allocation if CACHE_SET_IO_DISABLE bit is set */ +if (unlikely (test_bit (CACHE_SET_IO_DISABLE , &c->flags))) +return -1 ; +lockdep_assert_held (&c->bucket_lock);BUG_ON (!n || n > c->caches_loaded || n >MAX_CACHES_PER_SET );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 194/249 bcache: check CACHE_SET_IO_DISABLE bit in bch_journal()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit 383ff2183ad16a8842d1fbd9dd3e1cbd66813e64 ]
When too many I/O errors happen on cache set and CACHE_SET_IO_DISABLE bit is set, bch_journal() may continue to work because the journaling bkey might be still in write set yet. The caller of bch_journal() may believe the journal still work but the truth is in-memory journal write set won't be written into cache device any more. This behavior may introduce potential inconsistent metadata status.
This patch checks CACHE_SET_IO_DISABLE bit at the head of bch_journal(), if the bit is set, bch_journal() returns NULL immediately to notice caller to know journal does not work.
--- drivers/md/bcache/journal.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/md/bcache/journal.c +4 -0
@@ -811,6 +811,10 @@ atomic_t *bch_journal(struct cache_set *c,struct journal_write *w;atomic_t *ret; +/* No journaling if CACHE_SET_IO_DISABLE set already */ +if (unlikely (test_bit (CACHE_SET_IO_DISABLE , &c->flags))) +return NULL ; +if (!CACHE_SYNC (&c->sb))return NULL ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 195/249 bcache: acquire bch_register_lock later in cached_dev_free()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit 80265d8dfd77792e133793cef44a21323aac2908 ]
When enable lockdep engine, a lockdep warning can be observed when reboot or shutdown system,
[ 3142.764557][ T1] bcache: bcache_reboot() Stopping all devices:
[ 3142.776265][ T2649]
[ 3142.777159][ T2649] ======================================================
[ 3142.780039][ T2649] WARNING: possible circular locking dependency detected
[ 3142.782869][ T2649] 5.2.0-rc4-lp151.20-default+ #1 Tainted: G W
[ 3142.785684][ T2649] ------------------------------------------------------
[ 3142.788479][ T2649] kworker/3:67/2649 is trying to acquire lock:
[ 3142.790738][ T2649] 00000000aaf02291 ((wq_completion)bcache_writeback_wq){+.+.}, at: flush_workqueue+0x87/0x4c0
[ 3142.794678][ T2649]
[ 3142.794678][ T2649] but task is already holding lock:
[ 3142.797402][ T2649] 000000004fcf89c5 (&bch_register_lock){+.+.}, at: cached_dev_free+0x17/0x120 [bcache]
[ 3142.801462][ T2649]
[ 3142.801462][ T2649] which lock already depends on the new lock.
[ 3142.801462][ T2649]
[ 3142.805277][ T2649]
[ 3142.805277][ T2649] the existing dependency chain (in reverse order) is:
[ 3142.808902][ T2649]
[ 3142.808902][ T2649] -> #2 (&bch_register_lock){+.+.}:
[ 3142.812396][ T2649] __mutex_lock+0x7a/0x9d0
[ 3142.814184][ T2649] cached_dev_free+0x17/0x120 [bcache]
[ 3142.816415][ T2649] process_one_work+0x2a4/0x640
[ 3142.818413][ T2649] worker_thread+0x39/0x3f0
[ 3142.820276][ T2649] kthread+0x125/0x140
[ 3142.822061][ T2649] ret_from_fork+0x3a/0x50
[ 3142.823965][ T2649]
[ 3142.823965][ T2649] -> #1 ((work_completion)(&cl->work)#2){+.+.}:
[ 3142.827244][ T2649] process_one_work+0x277/0x640
[ 3142.829160][ T2649] worker_thread+0x39/0x3f0
[ 3142.830958][ T2649] kthread+0x125/0x140
[ 3142.832674][ T2649] ret_from_fork+0x3a/0x50
[ 3142.834915][ T2649]
[ 3142.834915][ T2649] -> #0 ((wq_completion)bcache_writeback_wq){+.+.}:
[ 3142.838121][ T2649] lock_acquire+0xb4/0x1c0
[ 3142.840025][ T2649] flush_workqueue+0xae/0x4c0
[ 3142.842035][ T2649] drain_workqueue+0xa9/0x180
[ 3142.844042][ T2649] destroy_workqueue+0x17/0x250
[ 3142.846142][ T2649] cached_dev_free+0x52/0x120 [bcache]
[ 3142.848530][ T2649] process_one_work+0x2a4/0x640
[ 3142.850663][ T2649] worker_thread+0x39/0x3f0
[ 3142.852464][ T2649] kthread+0x125/0x140
[ 3142.854106][ T2649] ret_from_fork+0x3a/0x50
[ 3142.855880][ T2649]
[ 3142.855880][ T2649] other info that might help us debug this:
[ 3142.855880][ T2649]
[ 3142.859663][ T2649] Chain exists of:
[ 3142.859663][ T2649] (wq_completion)bcache_writeback_wq --> (work_completion)(&cl->work)#2 --> &bch_register_lock
[ 3142.859663][ T2649]
[ 3142.865424][ T2649] Possible unsafe locking scenario:
[ 3142.865424][ T2649]
[ 3142.868022][ T2649] CPU0 CPU1
[ 3142.869885][ T2649] ---- ----
[ 3142.871751][ T2649] lock(&bch_register_lock);
[ 3142.873379][ T2649] lock((work_completion)(&cl->work)#2);
[ 3142.876399][ T2649] lock(&bch_register_lock);
[ 3142.879727][ T2649] lock((wq_completion)bcache_writeback_wq);
[ 3142.882064][ T2649]
[ 3142.882064][ T2649] *** DEADLOCK ***
[ 3142.882064][ T2649]
[ 3142.885060][ T2649] 3 locks held by kworker/3:67/2649:
[ 3142.887245][ T2649] #0: 00000000e774cdd0 ((wq_completion)events){+.+.}, at: process_one_work+0x21e/0x640
[ 3142.890815][ T2649] #1: 00000000f7df89da ((work_completion)(&cl->work)#2){+.+.}, at: process_one_work+0x21e/0x640
[ 3142.894884][ T2649] #2: 000000004fcf89c5 (&bch_register_lock){+.+.}, at: cached_dev_free+0x17/0x120 [bcache]
[ 3142.898797][ T2649]
[ 3142.898797][ T2649] stack backtrace:
[ 3142.900961][ T2649] CPU: 3 PID: 2649 Comm: kworker/3:67 Tainted: G W 5.2.0-rc4-lp151.20-default+ #1
[ 3142.904789][ T2649] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 04/13/2018
[ 3142.909168][ T2649] Workqueue: events cached_dev_free [bcache]
[ 3142.911422][ T2649] Call Trace:
[ 3142.912656][ T2649] dump_stack+0x85/0xcb
[ 3142.914181][ T2649] print_circular_bug+0x19a/0x1f0
[ 3142.916193][ T2649] __lock_acquire+0x16cd/0x1850
[ 3142.917936][ T2649] ? __lock_acquire+0x6a8/0x1850
[ 3142.919704][ T2649] ? lock_acquire+0xb4/0x1c0
[ 3142.921335][ T2649] ? find_held_lock+0x34/0xa0
[ 3142.923052][ T2649] lock_acquire+0xb4/0x1c0
[ 3142.924635][ T2649] ? flush_workqueue+0x87/0x4c0
[ 3142.926375][ T2649] flush_workqueue+0xae/0x4c0
[ 3142.928047][ T2649] ? flush_workqueue+0x87/0x4c0
[ 3142.929824][ T2649] ? drain_workqueue+0xa9/0x180
[ 3142.931686][ T2649] drain_workqueue+0xa9/0x180
[ 3142.933534][ T2649] destroy_workqueue+0x17/0x250
[ 3142.935787][ T2649] cached_dev_free+0x52/0x120 [bcache]
[ 3142.937795][ T2649] process_one_work+0x2a4/0x640
[ 3142.939803][ T2649] worker_thread+0x39/0x3f0
[ 3142.941487][ T2649] ? process_one_work+0x640/0x640
[ 3142.943389][ T2649] kthread+0x125/0x140
[ 3142.944894][ T2649] ? kthread_create_worker_on_cpu+0x70/0x70
[ 3142.947744][ T2649] ret_from_fork+0x3a/0x50
[ 3142.970358][ T2649] bcache: bcache_device_free() bcache0 stoppedHere is how the deadlock happens.
1) bcache_reboot() calls bcache_device_stop(), then inside bcache_device_stop() BCACHE_DEV_CLOSING bit is set on d->flags. Then closure_queue(&d->cl) is called to invoke cached_dev_flush().
2) In cached_dev_flush(), cached_dev_free() is called by continu_at().
3) In cached_dev_free(), when stopping the writeback kthread of the cached device by kthread_stop(), dc->writeback_thread will be waken up to quite the kthread while-loop, then cached_dev_put() is called in bch_writeback_thread().
4) Calling cached_dev_put() in writeback kthread may drop dc->count to 0, then dc->detach kworker is scheduled, which is initialized as cached_dev_detach_finish().
5) Inside cached_dev_detach_finish(), the last line of code is to call closure_put(&dc->disk.cl), which drops the last reference counter of closrure dc->disk.cl, then the callback cached_dev_flush() gets called.
Now cached_dev_flush() is called for second time in the code path, the first time is in step 2). And again bch_register_lock will be acquired again, and a A-A lock (lockdep terminology) is happening.
The root cause of the above A-A lock is in cached_dev_free(), mutex bch_register_lock is held before stopping writeback kthread and other kworkers. Fortunately now we have variable 'bcache_is_reboot', which may prevent device registration or unregistration during reboot/shutdown time, so it is unncessary to hold bch_register_lock such early now.
This is how this patch fixes the reboot/shutdown time A-A lock issue:
After moving mutex_lock(&bch_register_lock) to a later location where before atomic_read(&dc->running) in cached_dev_free(), such A-A lock problem can be solved without any reboot time registration race.
--- drivers/md/bcache/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/bcache/super.c +2 -2
@@ -1190,8 +1190,6 @@ static void cached_dev_free(struct closure *cl) { struct cached_dev *dc = container_of(cl, struct cached_dev, disk.cl); -mutex_lock (&bch_register_lock); -if (test_and_clear_bit (BCACHE_DEV_WB_RUNNING , &dc->disk.flags))cancel_writeback_rate_update_dwork (dc);
@@ -1202,6 +1200,8 @@ static void cached_dev_free(struct closure *cl)if (!IS_ERR_OR_NULL (dc->status_update_thread))kthread_stop (dc->status_update_thread); +mutex_lock (&bch_register_lock); +if (atomic_read (&dc->running))bd_unlink_disk_holder (dc->bdev, dc->disk.disk);bcache_device_free (&dc->disk);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 196/249 bcache: check c->gc_thread by IS_ERR_OR_NULL in cache_set_flush()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit b387e9b58679c60f5b1e4313939bd4878204fc37 ]
When system memory is in heavy pressure, bch_gc_thread_start() from run_cache_set() may fail due to out of memory. In such condition, c->gc_thread is assigned to -ENOMEM, not NULL pointer. Then in following failure code path bch_cache_set_error(), when cache_set_flush() gets called, the code piece to stop c->gc_thread is broken,
if (!IS_ERR_OR_NULL(c->gc_thread))
kthread_stop(c->gc_thread);And KASAN catches such NULL pointer deference problem, with the warning information:
[ 561.207881] ================================================================== [ 561.207900] BUG: KASAN: null-ptr-deref in kthread_stop+0x3b/0x440 [ 561.207904] Write of size 4 at addr 000000000000001c by task kworker/15:1/313
[ 561.207913] CPU: 15 PID: 313 Comm: kworker/15:1 Tainted: G W 5.0.0-vanilla+ #3 [ 561.207916] Hardware name: Lenovo ThinkSystem SR650 -[7X05CTO1WW]-/-[7X05CTO1WW]-, BIOS -[IVE136T-2.10]- 03/22/2019 [ 561.207935] Workqueue: events cache_set_flush [bcache] [ 561.207940] Call Trace: [ 561.207948] dump_stack+0x9a/0xeb [ 561.207955] ? kthread_stop+0x3b/0x440 [ 561.207960] ? kthread_stop+0x3b/0x440 [ 561.207965] kasan_report+0x176/0x192 [ 561.207973] ? kthread_stop+0x3b/0x440 [ 561.207981] kthread_stop+0x3b/0x440 [ 561.207995] cache_set_flush+0xd4/0x6d0 [bcache] [ 561.208008] process_one_work+0x856/0x1620 [ 561.208015] ? find_held_lock+0x39/0x1d0 [ 561.208028] ? drain_workqueue+0x380/0x380 [ 561.208048] worker_thread+0x87/0xb80 [ 561.208058] ? __kthread_parkme+0xb6/0x180 [ 561.208067] ? process_one_work+0x1620/0x1620 [ 561.208072] kthread+0x326/0x3e0 [ 561.208079] ? kthread_create_worker_on_cpu+0xc0/0xc0 [ 561.208090] ret_from_fork+0x3a/0x50 [ 561.208110] ================================================================== [ 561.208113] Disabling lock debugging due to kernel taint [ 561.208115] irq event stamp: 11800231 [ 561.208126] hardirqs last enabled at (11800231): [<ffffffff83008538>] do_syscall_64+0x18/0x410 [ 561.208127] BUG: unable to handle kernel NULL pointer dereference at 000000000000001c [ 561.208129] #PF error: [WRITE] [ 561.312253] hardirqs last disabled at (11800230): [<ffffffff830052ff>] trace_hardirqs_off_thunk+0x1a/0x1c [ 561.312259] softirqs last enabled at (11799832): [<ffffffff850005c7>] __do_softirq+0x5c7/0x8c3 [ 561.405975] PGD 0 P4D 0 [ 561.442494] softirqs last disabled at (11799821): [<ffffffff831add2c>] irq_exit+0x1ac/0x1e0 [ 561.791359] Oops: 0002 [#1] SMP KASAN NOPTI [ 561.791362] CPU: 15 PID: 313 Comm: kworker/15:1 Tainted: G B W 5.0.0-vanilla+ #3 [ 561.791363] Hardware name: Lenovo ThinkSystem SR650 -[7X05CTO1WW]-/-[7X05CTO1WW]-, BIOS -[IVE136T-2.10]- 03/22/2019 [ 561.791371] Workqueue: events cache_set_flush [bcache] [ 561.791374] RIP: 0010:kthread_stop+0x3b/0x440 [ 561.791376] Code: 00 00 65 8b 05 26 d5 e0 7c 89 c0 48 0f a3 05 ec aa df 02 0f 82 dc 02 00 00 4c 8d 63 20 be 04 00 00 00 4c 89 e7 e8 65 c5 53 00 <f0> ff 43 20 48 8d 7b 24 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 [ 561.791377] RSP: 0018:ffff88872fc8fd10 EFLAGS: 00010286 [ 561.838895] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 561.838916] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 561.838934] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 561.838948] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 561.838966] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 561.838979] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 561.838996] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 563.067028] RAX: 0000000000000000 RBX: fffffffffffffffc RCX: ffffffff832dd314 [ 563.067030] RDX: 0000000000000000 RSI: 0000000000000004 RDI: 0000000000000297 [ 563.067032] RBP: ffff88872fc8fe88 R08: fffffbfff0b8213d R09: fffffbfff0b8213d [ 563.067034] R10: 0000000000000001 R11: fffffbfff0b8213c R12: 000000000000001c [ 563.408618] R13: ffff88dc61cc0f68 R14: ffff888102b94900 R15: ffff88dc61cc0f68 [ 563.408620] FS: 0000000000000000(0000) GS:ffff888f7dc00000(0000) knlGS:0000000000000000 [ 563.408622] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 563.408623] CR2: 000000000000001c CR3: 0000000f48a1a004 CR4: 00000000007606e0 [ 563.408625] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 563.408627] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 563.904795] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 563.915796] PKRU: 55555554 [ 563.915797] Call Trace: [ 563.915807] cache_set_flush+0xd4/0x6d0 [bcache] [ 563.915812] process_one_work+0x856/0x1620 [ 564.001226] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 564.033563] ? find_held_lock+0x39/0x1d0 [ 564.033567] ? drain_workqueue+0x380/0x380 [ 564.033574] worker_thread+0x87/0xb80 [ 564.062823] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 564.118042] ? __kthread_parkme+0xb6/0x180 [ 564.118046] ? process_one_work+0x1620/0x1620 [ 564.118048] kthread+0x326/0x3e0 [ 564.118050] ? kthread_create_worker_on_cpu+0xc0/0xc0 [ 564.167066] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 564.252441] ret_from_fork+0x3a/0x50 [ 564.252447] Modules linked in: msr rpcrdma sunrpc rdma_ucm ib_iser ib_umad rdma_cm ib_ipoib i40iw configfs iw_cm ib_cm libiscsi scsi_transport_iscsi mlx4_ib ib_uverbs mlx4_en ib_core nls_iso8859_1 nls_cp437 vfat fat intel_rapl skx_edac x86_pkg_temp_thermal coretemp iTCO_wdt iTCO_vendor_support crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel ses raid0 aesni_intel cdc_ether enclosure usbnet ipmi_ssif joydev aes_x86_64 i40e scsi_transport_sas mii bcache md_mod crypto_simd mei_me ioatdma crc64 ptp cryptd pcspkr i2c_i801 mlx4_core glue_helper pps_core mei lpc_ich dca wmi ipmi_si ipmi_devintf nd_pmem dax_pmem nd_btt ipmi_msghandler device_dax pcc_cpufreq button hid_generic usbhid mgag200 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect xhci_pci sysimgblt fb_sys_fops xhci_hcd ttm megaraid_sas drm usbcore nfit libnvdimm sg dm_multipath dm_mod scsi_dh_rdac scsi_dh_emc scsi_dh_alua efivarfs [ 564.299390] bcache: bch_count_io_errors() nvme0n1: IO error on writing btree. [ 564.348360] CR2: 000000000000001c [ 564.348362] ---[ end trace b7f0e5cc7b2103b0 ]---
Therefore, it is not enough to only check whether c->gc_thread is NULL, we should use IS_ERR_OR_NULL() to check both NULL pointer and error value.
This patch changes the above buggy code piece in this way,
if (!IS_ERR_OR_NULL(c->gc_thread))
kthread_stop(c->gc_thread);--- drivers/md/bcache/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/super.c +1 -1
@@ -1564,7 +1564,7 @@ static void cache_set_flush(struct closure *cl)kobject_put (&c->internal);kobject_del (&c->kobj); -if (c->gc_thread) +if (!IS_ERR_OR_NULL (c->gc_thread))kthread_stop (c->gc_thread);if (!IS_ERR_OR_NULL (c->root))
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 197/249 bcache: avoid a deadlock in bcache_reboot()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit a59ff6ccc2bf2e2934b31bbf734f0bc04b5ec78a ]
It is quite frequently to observe deadlock in bcache_reboot() happens and hang the system reboot process. The reason is, in bcache_reboot() when calling bch_cache_set_stop() and bcache_device_stop() the mutex bch_register_lock is held. But in the process to stop cache set and bcache device, bch_register_lock will be acquired again. If this mutex is held here, deadlock will happen inside the stopping process. The aftermath of the deadlock is, whole system reboot gets hung.
The fix is to avoid holding bch_register_lock for the following loops in bcache_reboot(),
list_for_each_entry_safe(c, tc, &bch_cache_sets, list)
bch_cache_set_stop(c);
list_for_each_entry_safe(dc, tdc, &uncached_devices, list)
bcache_device_stop(&dc->disk);
A module range variable 'bcache_is_reboot' is added, it sets to true in bcache_reboot(). In register_bcache(), if bcache_is_reboot is checked to be true, reject the registration by returning -EBUSY immediately.
--- drivers/md/bcache/super.c | 40 ++++++++++++++++++++++++++++++++++++++- drivers/md/bcache/sysfs.c | 26 +++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-)
drivers/md/bcache/super.c +39 -1
@@ -40,6 +40,7 @@ static const char invalid_uuid[] = {static struct kobject *bcache_kobj;struct mutex bch_register_lock; +bool bcache_is_reboot;LIST_HEAD (bch_cache_sets);static LIST_HEAD (uncached_devices);
@@ -49,6 +50,7 @@ static wait_queue_head_t unregister_wait;struct workqueue_struct *bcache_wq;struct workqueue_struct *bch_journal_wq; +#define BTREE_MAX_PAGES (256 * 1024 / PAGE_SIZE)/* limitation of partitions number on single bcache device */ #define BCACHE_MINORS 128
@@ -2301,6 +2303,11 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,if (!try_module_get (THIS_MODULE ))return -EBUSY ; +/* For latest state of bcache_is_reboot */ +smp_mb (); +if (bcache_is_reboot) +return -EBUSY ; + path =kstrndup (buffer, size,GFP_KERNEL );if (!path) goto err;
@@ -2380,6 +2387,9 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,static int bcache_reboot (struct notifier_block *n,unsigned long code,void *x) { +if (bcache_is_reboot) +return NOTIFY_DONE ; +if (code ==SYS_DOWN || code ==SYS_HALT || code ==SYS_POWER_OFF ) {
@@ -2392,19 +2402,45 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x)mutex_lock (&bch_register_lock); +if (bcache_is_reboot) + goto out; + +/* New registration is rejected since now */ + bcache_is_reboot = true; +/* +* Make registering caller (if there is) on other CPU +* core know bcache_is_reboot set to true earlier +*/ +smp_mb (); +if (list_empty (&bch_cache_sets) &&list_empty (&uncached_devices)) goto out; +mutex_unlock (&bch_register_lock); +pr_info ("Stopping all devices:" ); +/* +* The reason bch_register_lock is not held to call +* bch_cache_set_stop() and bcache_device_stop() is to +* avoid potential deadlock during reboot, because cache +* set or bcache device stopping process will acqurie +* bch_register_lock too. +* +* We are safe here because bcache_is_reboot sets to +* true already, register_bcache() will reject new +* registration now. bcache_is_reboot also makes sure +* bcache_reboot() won't be re-entered on by other thread, +* so there is no race in following list iteration by +* list_for_each_entry_safe(). +*/ list_for_each_entry_safe (c, tc, &bch_cache_sets, list)bch_cache_set_stop (c);list_for_each_entry_safe (dc, tdc, &uncached_devices, list)bcache_device_stop (&dc->disk); -mutex_unlock (&bch_register_lock);/* * Give an early chance for other kthreads and
@@ -2531,6 +2567,8 @@ static int __init bcache_init(void)bch_debug_init ();closure_debug_init (); + bcache_is_reboot = false; +return 0 ; err:bcache_exit ();
drivers/md/bcache/sysfs.c +26 -0
@@ -16,6 +16,8 @@#include <linux/sort.h> #include <linux/sched/clock.h> +extern bool bcache_is_reboot; +/* Default is 0 ("writethrough") */ static const char *const bch_cache_modes[] = {"writethrough" ,
@@ -271,6 +273,10 @@ STORE(__cached_dev)struct cache_set *c;struct kobj_uevent_env *env; +/* no user space access if system is rebooting */ +if (bcache_is_reboot) +return -EBUSY ; +#define d_strtoul (var) sysfs_strtoul(var, dc->var)#define d_strtoul_nonzero (var) sysfs_strtoul_clamp(var, dc->var, 1, INT_MAX)#define d_strtoi_h (var) sysfs_hatoi(var, dc->var)
@@ -408,6 +414,10 @@ STORE(bch_cached_dev) struct cached_dev *dc = container_of(kobj, struct cached_dev, disk.kobj); +/* no user space access if system is rebooting */ +if (bcache_is_reboot) +return -EBUSY ; +mutex_lock (&bch_register_lock); size =__cached_dev_store (kobj, attr, buf, size);
@@ -511,6 +521,10 @@ STORE(__bch_flash_dev) kobj);struct uuid_entry *u = &d->c->uuids[d->id]; +/* no user space access if system is rebooting */ +if (bcache_is_reboot) +return -EBUSY ; +sysfs_strtoul (data_csum, d->data_csum);if (attr == &sysfs_size) {
@@ -746,6 +760,10 @@ STORE(__bch_cache_set) struct cache_set *c = container_of(kobj, struct cache_set, kobj);ssize_t v; +/* no user space access if system is rebooting */ +if (bcache_is_reboot) +return -EBUSY ; +if (attr == &sysfs_unregister)bch_cache_set_unregister (c);
@@ -865,6 +883,10 @@ STORE(bch_cache_set_internal) { struct cache_set *c = container_of(kobj, struct cache_set, internal); +/* no user space access if system is rebooting */ +if (bcache_is_reboot) +return -EBUSY ; +return bch_cache_set_store (&c->kobj, attr, buf, size); }
@@ -1050,6 +1072,10 @@ STORE(__bch_cache) struct cache *ca = container_of(kobj, struct cache, kobj);ssize_t v; +/* no user space access if system is rebooting */ +if (bcache_is_reboot) +return -EBUSY ; +if (attr == &sysfs_discard) {bool v =strtoul_or_return (buf);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 198/249 bcache: fix potential deadlock in cached_def_free()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit 7e865eba00a3df2dc8c4746173a8ca1c1c7f042e ]
When enable lockdep and reboot system with a writeback mode bcache device, the following potential deadlock warning is reported by lockdep engine.
[ 101.536569][ T401] kworker/2:2/401 is trying to acquire lock:
[ 101.538575][ T401] 00000000bbf6e6c7 ((wq_completion)bcache_writeback_wq){+.+.}, at: flush_workqueue+0x87/0x4c0
[ 101.542054][ T401]
[ 101.542054][ T401] but task is already holding lock:
[ 101.544587][ T401] 00000000f5f305b3 ((work_completion)(&cl->work)#2){+.+.}, at: process_one_work+0x21e/0x640
[ 101.548386][ T401]
[ 101.548386][ T401] which lock already depends on the new lock.
[ 101.548386][ T401]
[ 101.551874][ T401]
[ 101.551874][ T401] the existing dependency chain (in reverse order) is:
[ 101.555000][ T401]
[ 101.555000][ T401] -> #1 ((work_completion)(&cl->work)#2){+.+.}:
[ 101.557860][ T401] process_one_work+0x277/0x640
[ 101.559661][ T401] worker_thread+0x39/0x3f0
[ 101.561340][ T401] kthread+0x125/0x140
[ 101.562963][ T401] ret_from_fork+0x3a/0x50
[ 101.564718][ T401]
[ 101.564718][ T401] -> #0 ((wq_completion)bcache_writeback_wq){+.+.}:
[ 101.567701][ T401] lock_acquire+0xb4/0x1c0
[ 101.569651][ T401] flush_workqueue+0xae/0x4c0
[ 101.571494][ T401] drain_workqueue+0xa9/0x180
[ 101.573234][ T401] destroy_workqueue+0x17/0x250
[ 101.575109][ T401] cached_dev_free+0x44/0x120 [bcache]
[ 101.577304][ T401] process_one_work+0x2a4/0x640
[ 101.579357][ T401] worker_thread+0x39/0x3f0
[ 101.581055][ T401] kthread+0x125/0x140
[ 101.582709][ T401] ret_from_fork+0x3a/0x50
[ 101.584592][ T401]
[ 101.584592][ T401] other info that might help us debug this:
[ 101.584592][ T401]
[ 101.588355][ T401] Possible unsafe locking scenario:
[ 101.588355][ T401]
[ 101.590974][ T401] CPU0 CPU1
[ 101.592889][ T401] ---- ----
[ 101.594743][ T401] lock((work_completion)(&cl->work)#2);
[ 101.596785][ T401] lock((wq_completion)bcache_writeback_wq);
[ 101.600072][ T401] lock((work_completion)(&cl->work)#2);
[ 101.602971][ T401] lock((wq_completion)bcache_writeback_wq);
[ 101.605255][ T401]
[ 101.605255][ T401] *** DEADLOCK ***
[ 101.605255][ T401]
[ 101.608310][ T401] 2 locks held by kworker/2:2/401:
[ 101.610208][ T401] #0: 00000000cf2c7d17 ((wq_completion)events){+.+.}, at: process_one_work+0x21e/0x640
[ 101.613709][ T401] #1: 00000000f5f305b3 ((work_completion)(&cl->work)#2){+.+.}, at: process_one_work+0x21e/0x640
[ 101.617480][ T401]
[ 101.617480][ T401] stack backtrace:
[ 101.619539][ T401] CPU: 2 PID: 401 Comm: kworker/2:2 Tainted: G W 5.2.0-rc4-lp151.20-default+ #1
[ 101.623225][ T401] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 04/13/2018
[ 101.627210][ T401] Workqueue: events cached_dev_free [bcache]
[ 101.629239][ T401] Call Trace:
[ 101.630360][ T401] dump_stack+0x85/0xcb
[ 101.631777][ T401] print_circular_bug+0x19a/0x1f0
[ 101.633485][ T401] __lock_acquire+0x16cd/0x1850
[ 101.635184][ T401] ? __lock_acquire+0x6a8/0x1850
[ 101.636863][ T401] ? lock_acquire+0xb4/0x1c0
[ 101.638421][ T401] ? find_held_lock+0x34/0xa0
[ 101.640015][ T401] lock_acquire+0xb4/0x1c0
[ 101.641513][ T401] ? flush_workqueue+0x87/0x4c0
[ 101.643248][ T401] flush_workqueue+0xae/0x4c0
[ 101.644832][ T401] ? flush_workqueue+0x87/0x4c0
[ 101.646476][ T401] ? drain_workqueue+0xa9/0x180
[ 101.648303][ T401] drain_workqueue+0xa9/0x180
[ 101.649867][ T401] destroy_workqueue+0x17/0x250
[ 101.651503][ T401] cached_dev_free+0x44/0x120 [bcache]
[ 101.653328][ T401] process_one_work+0x2a4/0x640
[ 101.655029][ T401] worker_thread+0x39/0x3f0
[ 101.656693][ T401] ? process_one_work+0x640/0x640
[ 101.658501][ T401] kthread+0x125/0x140
[ 101.660012][ T401] ? kthread_create_worker_on_cpu+0x70/0x70
[ 101.661985][ T401] ret_from_fork+0x3a/0x50
[ 101.691318][ T401] bcache: bcache_device_free() bcache0 stoppedHere is how the above potential deadlock may happen in reboot/shutdown code path,
1) bcache_reboot() is called firstly in the reboot/shutdown code path, then in bcache_reboot(), bcache_device_stop() is called.
2) bcache_device_stop() sets BCACHE_DEV_CLOSING on d->falgs, then call closure_queue(&d->cl) to invoke cached_dev_flush(). And in turn cached_dev_flush() calls cached_dev_free() via closure_at()
3) In cached_dev_free(), after stopped writebach kthread dc->writeback_thread, the kwork dc->writeback_write_wq is stopping by destroy_workqueue().
4) Inside destroy_workqueue(), drain_workqueue() is called. Inside drain_workqueue(), flush_workqueue() is called. Then wq->lockdep_map is acquired by lock_map_acquire() in flush_workqueue(). After the lock acquired the rest part of flush_workqueue() just wait for the workqueue to complete.
5) Now we look back at writeback thread routine bch_writeback_thread(), in the main while-loop, write_dirty() is called via continue_at() in read_dirty_submit(), which is called via continue_at() in while-loop level called function read_dirty(). Inside write_dirty() it may be re-called on workqueeu dc->writeback_write_wq via continue_at(). It means when the writeback kthread is stopped in cached_dev_free() there might be still one kworker queued on dc->writeback_write_wq to execute write_dirty() again.
6) Now this kworker is scheduled on dc->writeback_write_wq to run by process_one_work() (which is called by worker_thread()). Before calling the kwork routine, wq->lockdep_map is acquired.
7) But wq->lockdep_map is acquired already in step 4), so a A-A lock (lockdep terminology) scenario happens.
Indeed on multiple cores syatem, the above deadlock is very rare to happen, just as the code comments in process_one_work() says,
2263 * AFAICT there is no possible deadlock scenario between the
2264 * flush_work() and complete() primitives (except for
single-threaded
2265 * workqueues), so hiding them isn't a problem.
But it is still good to fix such lockdep warning, even no one running bcache on single core system.
The fix is simple. This patch solves the above potential deadlock by,
- Do not destroy workqueue dc->writeback_write_wq in cached_dev_free().
- Flush and destroy dc->writeback_write_wq in writebach kthread routine bch_writeback_thread(), where after quit the thread main while-loop and before cached_dev_put() is called.
By this fix, dc->writeback_write_wq will be stopped and destroy before the writeback kthread stopped, so the chance for a A-A locking on wq->lockdep_map is disappeared, such A-A deadlock won't happen any more.
--- drivers/md/bcache/super.c | 2 -- drivers/md/bcache/writeback.c | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/md/bcache/super.c +0 -2
@@ -1197,8 +1197,6 @@ static void cached_dev_free(struct closure *cl)if (!IS_ERR_OR_NULL (dc->writeback_thread))kthread_stop (dc->writeback_thread); -if (dc->writeback_write_wq) -destroy_workqueue (dc->writeback_write_wq);if (!IS_ERR_OR_NULL (dc->status_update_thread))kthread_stop (dc->status_update_thread);
drivers/md/bcache/writeback.c +4 -0
@@ -735,6 +735,10 @@ static int bch_writeback_thread(void *arg) } } +if (dc->writeback_write_wq) { +flush_workqueue (dc->writeback_write_wq); +destroy_workqueue (dc->writeback_write_wq); + }cached_dev_put (dc);wait_for_kthread_stop ();
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 199/249 net: hns3: fix a -Wformat-nonliteral compile warning
In reply to Sasha LevinFrom: Yonglong Liu <[email protected]>
[ Upstream commit 18d219b783da61a6cc77581f55fc4af2fa16bc36 ]
When setting -Wformat=2, there is a compiler warning like this:
hclge_main.c:xxx:x: warning: format not a string literal and no format arguments [-Wformat-nonliteral]
strs[i].desc);
^~~~
This patch adds missing format parameter "%s" to snprintf() to fix it.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +1 -2
@@ -552,8 +552,7 @@ static u8 *hclge_comm_get_strings(u32 stringset,return buff;for (i =0 ; i < size; i++) { -snprintf (buff,ETH_GSTRING_LEN , - strs[i].desc); +snprintf (buff,ETH_GSTRING_LEN ,"%s" , strs[i].desc); buff = buff +ETH_GSTRING_LEN ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 200/249 net: hns3: add some error checking in hclge_tm module
In reply to Sasha LevinFrom: Yunsheng Lin <[email protected]>
[ Upstream commit 04f25edb48c441fc278ecc154c270f16966cbb90 ]
When hdev->tx_sch_mode is HCLGE_FLAG_VNET_BASE_SCH_MODE, the hclge_tm_schd_mode_vnet_base_cfg calls hclge_tm_pri_schd_mode_cfg with vport->vport_id as pri_id, which is used as index for hdev->tm_info.tc_info, it will cause out of bound access issue if vport_id is equal to or larger than HNAE3_MAX_TC.
Also hardware only support maximum speed of HCLGE_ETHER_MAX_RATE.
So this patch adds two checks for above cases.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +5 -1
@@ -54,7 +54,8 @@ static int hclge_shaper_para_calc(u32 ir, u8 shaper_level,u32 tick;/* Calc tick */ -if (shaper_level >=HCLGE_SHAPER_LVL_CNT ) +if (shaper_level >=HCLGE_SHAPER_LVL_CNT || + ir >HCLGE_ETHER_MAX_RATE )return -EINVAL ; tick = tick_array[shaper_level];
@@ -1124,6 +1125,9 @@ static int hclge_tm_schd_mode_vnet_base_cfg(struct hclge_vport *vport)int ret;u8 i; +if (vport->vport_id >=HNAE3_MAX_TC ) +return -EINVAL ; + ret =hclge_tm_pri_schd_mode_cfg (hdev, vport->vport_id);if (ret)return ret;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 201/249 ath10k: Fix memory leak in qmi
In reply to Sasha LevinFrom: Dundi Raviteja <[email protected]>
[ Upstream commit c709df58832c5f575f0255bea4b09ad477fc62ea ]
Currently the memory allocated for qmi handle is not being freed during de-init which leads to memory leak.
Free the allocated qmi memory in qmi deinit
to avoid memory leak.
Tested HW: WCN3990
Tested FW: WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1
--- drivers/net/wireless/ath/ath10k/qmi.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath10k/qmi.c +1 -0
@@ -1002,6 +1002,7 @@ int ath10k_qmi_deinit(struct ath10k *ar)qmi_handle_release (&qmi->qmi_hdl);cancel_work_sync (&qmi->event_work);destroy_workqueue (qmi->event_wq); +kfree (qmi); ar_snoc->qmi =NULL ;return 0 ;
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 202/249 ath10k: destroy sdio workqueue while remove sdio module
In reply to Sasha LevinFrom: Wen Gong <[email protected]>
[ Upstream commit 3ed39f8e747a7aafeec07bb244f2c3a1bdca5730 ]
The workqueue need to flush and destory while remove sdio module, otherwise it will have thread which is not destory after remove sdio modules.
Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-00007-QCARMSWP-1.
--- drivers/net/wireless/ath/ath10k/sdio.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath10k/sdio.c +3 -0
@@ -2081,6 +2081,9 @@ static void ath10k_sdio_remove(struct sdio_func *func)cancel_work_sync (&ar_sdio->wr_async_work);ath10k_core_unregister (ar);ath10k_core_destroy (ar); + +flush_workqueue (ar_sdio->workqueue); +destroy_workqueue (ar_sdio->workqueue); }static const struct sdio_device_id ath10k_sdio_devices[] = {
Signature · 7 lines
2.20.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 203/249 net: mvpp2: prs: Don't override the sign bit in SRAM parser shift
In reply to Sasha LevinFrom: Maxime Chevallier <[email protected]>
[ Upstream commit 8ec3ede559956f8ad58db7b57d25ac724bab69e9 ]
The Header Parser allows identifying various fields in the packet headers, used for various kind of filtering and classification steps.
This is a re-entrant process, where the offset in the packet header depends on the previous lookup results. This offset is represented in the SRAM results of the TCAM, as a shift to be operated.
This shift can be negative in some cases, such as in IPv6 parsing.
This commit prevents overriding the sign bit when setting the shift value, which could cause instabilities when parsing IPv6 flows.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c +2 -1
@@ -312,7 +312,8 @@ static void mvpp2_prs_sram_shift_set(struct mvpp2_prs_entry *pe, int shift, }/* Set value */ - pe->sram[MVPP2_BIT_TO_WORD (MVPP2_PRS_SRAM_SHIFT_OFFS )] = shift &MVPP2_PRS_SRAM_SHIFT_MASK ; + pe->sram[MVPP2_BIT_TO_WORD (MVPP2_PRS_SRAM_SHIFT_OFFS )] |= + shift &MVPP2_PRS_SRAM_SHIFT_MASK ;/* Reset and set operation */ mvpp2_prs_sram_bits_clear(pe, MVPP2_PRS_SRAM_OP_SEL_SHIFT_OFFS,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 204/249 igb: clear out skb->tstamp after reading the txtime
In reply to Sasha LevinFrom: Vedang Patel <[email protected]>
[ Upstream commit 1e08511d5d01884a3c9070afd52a47799312074a ]
If a packet which is utilizing the launchtime feature (via SO_TXTIME socket option) also requests the hardware transmit timestamp, the hardware timestamp is not delivered to the userspace. This is because the value in skb->tstamp is mistaken as the software timestamp.
Applications, like ptp4l, request a hardware timestamp by setting the SOF_TIMESTAMPING_TX_HARDWARE socket option. Whenever a new timestamp is detected by the driver (this work is done in igb_ptp_tx_work() which calls igb_ptp_tx_hwtstamps() in igb_ptp.c[1]), it will queue the timestamp in the ERR_QUEUE for the userspace to read. When the userspace is ready, it will issue a recvmsg() call to collect this timestamp. The problem is in this recvmsg() call. If the skb->tstamp is not cleared out, it will be interpreted as a software timestamp and the hardware tx timestamp will not be successfully sent to the userspace. Look at skb_is_swtx_tstamp() and the callee function __sock_recv_timestamp() in net/socket.c for more details.
--- drivers/net/ethernet/intel/igb/igb_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/igb/igb_main.c +1 -0
@@ -5687,6 +5687,7 @@ static void igb_tx_ctxtdesc(struct igb_ring *tx_ring,*/ if (tx_ring->launchtime_enable) { ts =ns_to_timespec64 (first->skb->tstamp); + first->skb->tstamp =0 ; context_desc->seqnum_seed =cpu_to_le32 (ts.tv_nsec /32 ); }else { context_desc->seqnum_seed =0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 205/249 net: hns3: add Asym Pause support to fix autoneg problem
In reply to Sasha LevinFrom: Yonglong Liu <[email protected]>
[ Upstream commit bc3781edcea017aa1a29abd953b776cdba298ce2 ]
Local device and link partner config auto-negotiation on both, local device config pause frame use as: rx on/tx off, link partner config pause frame use as: rx off/tx on.
We except the result is:
Local device:
Autonegotiate: on RX: on TX: off RX negotiated: on TX negotiated: off
Link partner:
Autonegotiate: on RX: off TX: on RX negotiated: off TX negotiated: on
But actually, the result of Local device and link partner is both:
Autonegotiate: on RX: off TX: off RX negotiated: off TX negotiated: off
The root cause is that the supported flag is has only Pause, reference to the function genphy_config_advert():
static int genphy_config_advert(struct phy_device *phydev)
{
...
linkmode_and(phydev->advertising, phydev->advertising,
phydev->supported);
...
}The pause frame use of link partner is rx off/tx on, so its advertising only set the bit Asym_Pause, and the supported is only set the bit Pause, so the result of linkmode_and(), is rx off/tx off.
This patch adds Asym_Pause to the supported flag to fix it.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 1 + drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 7 +++++++ 2 files changed, 8 insertions(+)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +1 -0
@@ -1057,6 +1057,7 @@ static void hclge_parse_copper_link_mode(struct hclge_dev *hdev,linkmode_set_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, supported);linkmode_set_bit (ETHTOOL_LINK_MODE_TP_BIT , supported);linkmode_set_bit (ETHTOOL_LINK_MODE_Pause_BIT, supported); +linkmode_set_bit (ETHTOOL_LINK_MODE_Asym_Pause_BIT, supported); }static void hclge_parse_link_mode (struct hclge_dev *hdev,u8 speed_ability)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c +7 -0
@@ -224,6 +224,13 @@ int hclge_mac_connect_phy(struct hnae3_handle *handle)linkmode_and (phydev->supported, phydev->supported, mask);linkmode_copy (phydev->advertising, phydev->supported); +/* supported flag is Pause and Asym Pause, but default advertising +* should be rx on, tx on, so need clear Asym Pause in advertising +* flag +*/ +linkmode_clear_bit (ETHTOOL_LINK_MODE_Asym_Pause_BIT, + phydev->advertising); +return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 206/249 net: ethernet: ti: cpsw: Assign OF node to slave devices
In reply to Sasha LevinFrom: Marek Vasut <[email protected]>
[ Upstream commit 337d1727a3895775b5e5ef67d3ca0fea2e2ae768 ]
Assign OF node to CPSW slave devices, otherwise it is not possible to bind e.g. DSA switch to them. Without this patch, the DSA code tries to find the ethernet device by OF match, but fails to do so because the slave device has NULL OF node.
--- drivers/net/ethernet/ti/cpsw.c | 3 +++ drivers/net/ethernet/ti/cpsw_priv.h | 1 + 2 files changed, 4 insertions(+)
drivers/net/ethernet/ti/cpsw.c +3 -0
@@ -2179,6 +2179,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,return ret; } + slave_data->slave_node = slave_node; slave_data->phy_node =of_parse_phandle (slave_node,"phy-handle" ,0 ); parp =of_get_property (slave_node,"phy_id" , &lenp);
@@ -2330,6 +2331,7 @@ static int cpsw_probe_dual_emac(struct cpsw_priv *priv)/* register the network device */ SET_NETDEV_DEV (ndev, cpsw->dev); + ndev->dev.of_node = cpsw->slaves[1 ].data->slave_node; ret =register_netdev (ndev);if (ret)dev_err (cpsw->dev,"cpsw: error registering net device\n" );
@@ -2507,6 +2509,7 @@ static int cpsw_probe(struct platform_device *pdev)/* register the network device */ SET_NETDEV_DEV (ndev, dev); + ndev->dev.of_node = cpsw->slaves[0 ].data->slave_node; ret =register_netdev (ndev);if (ret) {dev_err (dev,"error registering net device\n" );
drivers/net/ethernet/ti/cpsw_priv.h +1 -0
@@ -272,6 +272,7 @@ struct cpsw_host_regs { };struct cpsw_slave_data { +struct device_node *slave_node;struct device_node *phy_node;char phy_id[MII_BUS_ID_SIZE ];int phy_if;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 207/249 ixgbe: Avoid NULL pointer dereference with VF on non-IPsec hw
In reply to Sasha LevinFrom: Dann Frazier <[email protected]>
[ Upstream commit 92924064106e410cdc015f1dbfc0499309f9f5b1 ]
An ipsec structure will not be allocated if the hardware does not support offload. Fixes the following Oops:
[ 191.045452] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 [ 191.054232] Mem abort info: [ 191.057014] ESR = 0x96000004 [ 191.060057] Exception class = DABT (current EL), IL = 32 bits [ 191.065963] SET = 0, FnV = 0 [ 191.069004] EA = 0, S1PTW = 0 [ 191.072132] Data abort info: [ 191.074999] ISV = 0, ISS = 0x00000004 [ 191.078822] CM = 0, WnR = 0 [ 191.081780] user pgtable: 4k pages, 48-bit VAs, pgdp = 0000000043d9e467 [ 191.088382] [0000000000000000] pgd=0000000000000000 [ 191.093252] Internal error: Oops: 96000004 [#1] SMP [ 191.098119] Modules linked in: vhost_net vhost tap vfio_pci vfio_virqfd vfio_iommu_type1 vfio xt_CHECKSUM iptable_mangle ipt_MASQUERADE iptable_nat nf_nat_ipv4 nf_nat xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ipt_REJECT nf_reject_ipv4 xt_tcpudp bridge stp llc ebtable_filter devlink ebtables ip6table_filter ip6_tables iptable_filter bpfilter ipmi_ssif nls_iso8859_1 input_leds joydev ipmi_si hns_roce_hw_v2 ipmi_devintf hns_roce ipmi_msghandler cppc_cpufreq sch_fq_codel ib_iser rdma_cm iw_cm ib_cm ib_core iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ip_tables x_tables autofs4 ses enclosure btrfs zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor hid_generic usbhid hid raid6_pq libcrc32c raid1 raid0 multipath linear ixgbevf hibmc_drm ttm [ 191.168607] drm_kms_helper aes_ce_blk aes_ce_cipher syscopyarea crct10dif_ce sysfillrect ghash_ce qla2xxx sysimgblt sha2_ce sha256_arm64 hisi_sas_v3_hw fb_sys_fops sha1_ce uas nvme_fc mpt3sas ixgbe drm hisi_sas_main nvme_fabrics usb_storage hclge scsi_transport_fc ahci libsas hnae3 raid_class libahci xfrm_algo scsi_transport_sas mdio aes_neon_bs aes_neon_blk crypto_simd cryptd aes_arm64 [ 191.202952] CPU: 94 PID: 0 Comm: swapper/94 Not tainted 4.19.0-rc1+ #11 [ 191.209553] Hardware name: Huawei D06 /D06, BIOS Hisilicon D06 UEFI RC0 - V1.20.01 04/26/2019 [ 191.218064] pstate: 20400089 (nzCv daIf +PAN -UAO) [ 191.222873] pc : ixgbe_ipsec_vf_clear+0x60/0xd0 [ixgbe] [ 191.228093] lr : ixgbe_msg_task+0x2d0/0x1088 [ixgbe] [ 191.233044] sp : ffff000009b3bcd0 [ 191.236346] x29: ffff000009b3bcd0 x28: 0000000000000000 [ 191.241647] x27: ffff000009628000 x26: 0000000000000000 [ 191.246946] x25: ffff803f652d7600 x24: 0000000000000004 [ 191.252246] x23: ffff803f6a718900 x22: 0000000000000000 [ 191.257546] x21: 0000000000000000 x20: 0000000000000000 [ 191.262845] x19: 0000000000000000 x18: 0000000000000000 [ 191.268144] x17: 0000000000000000 x16: 0000000000000000 [ 191.273443] x15: 0000000000000000 x14: 0000000100000026 [ 191.278742] x13: 0000000100000025 x12: ffff8a5f7fbe0df0 [ 191.284042] x11: 000000010000000b x10: 0000000000000040 [ 191.289341] x9 : 0000000000001100 x8 : ffff803f6a824fd8 [ 191.294640] x7 : ffff803f6a825098 x6 : 0000000000000001 [ 191.299939] x5 : ffff000000f0ffc0 x4 : 0000000000000000 [ 191.305238] x3 : ffff000028c00000 x2 : ffff803f652d7600 [ 191.310538] x1 : 0000000000000000 x0 : ffff000000f205f0 [ 191.315838] Process swapper/94 (pid: 0, stack limit = 0x00000000addfed5a) [ 191.322613] Call trace: [ 191.325055] ixgbe_ipsec_vf_clear+0x60/0xd0 [ixgbe] [ 191.329927] ixgbe_msg_task+0x2d0/0x1088 [ixgbe] [ 191.334536] ixgbe_msix_other+0x274/0x330 [ixgbe] [ 191.339233] __handle_irq_event_percpu+0x78/0x270 [ 191.343924] handle_irq_event_percpu+0x40/0x98 [ 191.348355] handle_irq_event+0x50/0xa8 [ 191.352180] handle_fasteoi_irq+0xbc/0x148 [ 191.356263] generic_handle_irq+0x34/0x50 [ 191.360259] __handle_domain_irq+0x68/0xc0 [ 191.364343] gic_handle_irq+0x84/0x180 [ 191.368079] el1_irq+0xe8/0x180 [ 191.371208] arch_cpu_idle+0x30/0x1a8 [ 191.374860] do_idle+0x1dc/0x2a0 [ 191.378077] cpu_startup_entry+0x2c/0x30 [ 191.381988] secondary_start_kernel+0x150/0x1e0 [ 191.386506] Code: 6b15003f 54000320 f1404a9f 54000060 (79400260)
--- drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c +3 -0
@@ -842,6 +842,9 @@ void ixgbe_ipsec_vf_clear(struct ixgbe_adapter *adapter, u32 vf)struct ixgbe_ipsec *ipsec = adapter->ipsec;int i; +if (!ipsec) +return ; +/* search rx sa table */ for (i =0 ; i <IXGBE_IPSEC_MAX_SA_COUNT && ipsec->num_rx_sa; i++) {if (!ipsec->rx_tbl[i].used)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 208/249 iwlwifi: mvm: Drop large non sta frames
In reply to Sasha LevinFrom: Andrei Otcheretianski <[email protected]>
[ Upstream commit ac70499ee97231a418dc1a4d6c9dc102e8f64631 ]
In some buggy scenarios we could possible attempt to transmit frames larger than maximum MSDU size. Since our devices don't know how to handle this, it may result in asserts, hangs etc.
This can happen, for example, when we receive a large multicast frame and try to transmit it back to the air in AP mode.
Since in a legal scenario this should never happen, drop such frames and warn about it.
--- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +3 -0
@@ -726,6 +726,9 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)memcpy (&info, skb->cb,sizeof (info)); +if (WARN_ON_ONCE (skb->len >IEEE80211_MAX_DATA_LEN + hdrlen)) +return -1 ; +if (WARN_ON_ONCE (info.flags &IEEE80211_TX_CTL_AMPDU ))return -1 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 209/249 bpf: fix uapi bpf_prog_info fields alignment
In reply to Sasha LevinFrom: Baruch Siach <[email protected]>
[ Upstream commit 0472301a28f6cf53a6bc5783e48a2d0bbff4682f ]
Merge commit 1c8c5a9d38f60 ("Mergegit://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next") undid the fix from commit 36f9814a494 ("bpf: fix uapi hole for 32 bit compat applications") by taking the gpl_compatible 1-bit field definition from commit b85fab0e67b162 ("bpf: Add gpl_compatible flag to struct bpf_prog_info") as is. That breaks architectures with 16-bit alignment like m68k. Add 31-bit pad after gpl_compatible to restore alignment of following fields.
Thanks to Dmitry V. Levin his analysis of this bug history.
--- include/uapi/linux/bpf.h | 1 + tools/include/uapi/linux/bpf.h | 1 + 2 files changed, 2 insertions(+)
include/uapi/linux/bpf.h +1 -0
@@ -3143,6 +3143,7 @@ struct bpf_prog_info {char name[BPF_OBJ_NAME_LEN ];__u32 ifindex; __u32 gpl_compatible:1; + __u32 :31 ;/* alignment pad */ __u64 netns_dev;__u64 netns_ino;__u32 nr_jited_ksyms;
tools/include/uapi/linux/bpf.h +1 -0
@@ -3143,6 +3143,7 @@ struct bpf_prog_info {char name[BPF_OBJ_NAME_LEN ];__u32 ifindex; __u32 gpl_compatible:1; + __u32 :31 ;/* alignment pad */ __u64 netns_dev;__u64 netns_ino;__u32 nr_jited_ksyms;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 210/249 netfilter: Fix remainder of pseudo-header protocol 0
In reply to Sasha LevinFrom: He Zhe <[email protected]>
[ Upstream commit 5d1549847c76b1ffcf8e388ef4d0f229bdd1d7e8 ]
Since v5.1-rc1, some types of packets do not get unreachable reply with the following iptables setting. Fox example,
$ iptables -A INPUT -p icmp --icmp-type 8 -j REJECT $ ping 127.0.0.1 -c 1 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. — 127.0.0.1 ping statistics — 1 packets transmitted, 0 received, 100% packet loss, time 0ms
We should have got the following reply from command line, but we did not. From 127.0.0.1 icmp_seq=1 Destination Port Unreachable
Yi Zhao reported it and narrowed it down to:7fc38225363d ("netfilter: reject: skip csum verification for protocols that don't support it"),
This is because nf_ip_checksum still expects pseudo-header protocol type 0 for packets that are of neither TCP or UDP, and thus ICMP packets are mistakenly treated as TCP/UDP.
This patch corrects the conditions in nf_ip_checksum and all other places that still call it with protocol 0.
--- net/netfilter/nf_conntrack_proto_icmp.c | 2 +- net/netfilter/nf_nat_proto.c | 2 +- net/netfilter/utils.c | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-)
net/netfilter/nf_conntrack_proto_icmp.c +1 -1
@@ -218,7 +218,7 @@ int nf_conntrack_icmpv4_error(struct nf_conn *tmpl,/* See ip_conntrack_proto_tcp.c */ if (state->net->ct.sysctl_checksum && state->hook ==NF_INET_PRE_ROUTING && -nf_ip_checksum (skb, state->hook, dataoff,0 )) { +nf_ip_checksum (skb, state->hook, dataoff,IPPROTO_ICMP )) {icmp_error_log (skb, state,"bad hw icmp checksum" );return -NF_ACCEPT ; }
net/netfilter/nf_nat_proto.c +1 -1
@@ -564,7 +564,7 @@ int nf_nat_icmp_reply_translation(struct sk_buff *skb,if (!skb_make_writable (skb, hdrlen +sizeof (*inside)))return 0 ; -if (nf_ip_checksum (skb, hooknum, hdrlen,0 )) +if (nf_ip_checksum (skb, hooknum, hdrlen,IPPROTO_ICMP ))return 0 ; inside = (void *)skb->data + hdrlen;
net/netfilter/utils.c +3 -2
@@ -17,7 +17,8 @@ __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook,case CHECKSUM_COMPLETE :if (hook !=NF_INET_PRE_ROUTING && hook !=NF_INET_LOCAL_IN )break ; -if ((protocol ==0 && !csum_fold (skb->csum)) || +if ((protocol !=IPPROTO_TCP && protocol !=IPPROTO_UDP && + !csum_fold (skb->csum)) || !csum_tcpudp_magic (iph->saddr, iph->daddr, skb->len - dataoff, protocol, skb->csum)) {
@@ -26,7 +27,7 @@ __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook, }/* fall through */ case CHECKSUM_NONE : -if (protocol ==0 ) +if (protocol !=IPPROTO_TCP && protocol !=IPPROTO_UDP ) skb->csum =0 ;else skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 211/249 iwlwifi: dbg: fix debug monitor stop and restart delays
In reply to Sasha LevinFrom: Shahar S Matityahu <[email protected]>
[ Upstream commit fc838c775f35e272e5cc7ef43853f0b55babbe37 ]
The driver should delay only in recording stop flow between writing to DBGC_IN_SAMPLE register and DBGC_OUT_CTRL register. Any other delay is not needed.
Change the following:
1. Remove any unnecessary delays in the flow
2. Increase the delay in the stop recording flow since 100 micro is not enough
3. Use usleep_range instead of delay since the driver is allowed to sleep in this flow.
--- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 2 -- drivers/net/wireless/intel/iwlwifi/fw/dbg.h | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +0 -2
@@ -2303,8 +2303,6 @@ void iwl_fw_dbg_collect_sync(struct iwl_fw_runtime *fwrt)/* start recording again if the firmware is not crashed */ if (!test_bit (STATUS_FW_ERROR , &fwrt->trans->status) && fwrt->fw->dbg.dest_tlv) { -/* wait before we collect the data till the DBGC stop */ -udelay (500 );iwl_fw_dbg_restart_recording (fwrt, ¶ms); } }
drivers/net/wireless/intel/iwlwifi/fw/dbg.h +4 -2
@@ -294,7 +294,10 @@ _iwl_fw_dbg_stop_recording(struct iwl_trans *trans, }iwl_write_umac_prph (trans,DBGC_IN_SAMPLE ,0 ); -udelay (100 ); +/* wait for the DBGC to finish writing the internal buffer to DRAM to +* avoid halting the HW while writing +*/ +usleep_range (700 ,1000 );iwl_write_umac_prph (trans,DBGC_OUT_CTRL ,0 );#ifdef CONFIG_IWLWIFI_DEBUGFS trans->dbg_rec_on = false;
@@ -324,7 +327,6 @@ _iwl_fw_dbg_restart_recording(struct iwl_trans *trans,iwl_set_bits_prph (trans,MON_BUFF_SAMPLE_CTL ,0x1 ); }else {iwl_write_umac_prph (trans,DBGC_IN_SAMPLE , params->in_sample); -udelay (100 );iwl_write_umac_prph (trans,DBGC_OUT_CTRL , params->out_ctrl); } }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 212/249 bnxt_en: Disable bus master during PCI shutdown and driver unload.
In reply to Sasha LevinFrom: Michael Chan <[email protected]>
[ Upstream commit c20dc142dd7b2884b8570eeab323bcd4a84294fa ]
Some chips with older firmware can continue to perform DMA read from context memory even after the memory has been freed. In the PCI shutdown method, we need to call pci_disable_device() to shutdown DMA to prevent this DMA before we put the device into D3hot. DMA memory request in D3hot state will generate PCI fatal error. Similarly, in the driver remove method, the context memory should only be freed after DMA has been shutdown for correctness.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -1
@@ -10262,10 +10262,10 @@ static void bnxt_remove_one(struct pci_dev *pdev)bnxt_dcb_free (bp);kfree (bp->edev); bp->edev =NULL ; +bnxt_cleanup_pci (bp);bnxt_free_ctx_mem (bp);kfree (bp->ctx); bp->ctx =NULL ; -bnxt_cleanup_pci (bp);bnxt_free_port_stats (bp);free_netdev (dev); }
@@ -10859,6 +10859,7 @@ static void bnxt_shutdown(struct pci_dev *pdev)if (system_state ==SYSTEM_POWER_OFF ) {bnxt_clear_int_mode (bp); +pci_disable_device (pdev);pci_wake_from_d3 (pdev, bp->wol);pci_set_power_state (pdev, PCI_D3hot); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 213/249 bnxt_en: Fix statistics context reservation logic for RDMA driver.
In reply to Sasha LevinFrom: Michael Chan <[email protected]>
[ Upstream commit d77b1ad8e87dc5a6cd0d9158b097a4817946ca3b ]
The current logic assumes that the RDMA driver uses one statistics context adjacent to the ones used by the network driver. This assumption is not true and the statistics context used by the RDMA driver is tied to its MSIX base vector. This wrong assumption can cause RDMA driver failure after changing ethtool rings on the network side. Fix the statistics reservation logic accordingly.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +11 -6
@@ -5508,7 +5508,16 @@ static int bnxt_cp_rings_in_use(struct bnxt *bp)static int bnxt_get_func_stat_ctxs (struct bnxt *bp) { -return bp->cp_nr_rings +bnxt_get_ulp_stat_ctxs (bp); +int ulp_stat =bnxt_get_ulp_stat_ctxs (bp); +int cp = bp->cp_nr_rings; + +if (!ulp_stat) +return cp; + +if (bnxt_nq_rings_in_use (bp) > cp +bnxt_get_ulp_msix_num (bp)) +return bnxt_get_ulp_msix_base (bp) + ulp_stat; + +return cp + ulp_stat; }static bool bnxt_need_reserve_rings (struct bnxt *bp)
@@ -7477,11 +7486,7 @@ unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp)unsigned int bnxt_get_avail_stat_ctxs_for_en (struct bnxt *bp) { -unsigned int stat; - - stat =bnxt_get_max_func_stat_ctxs (bp) -bnxt_get_ulp_stat_ctxs (bp); - stat -= bp->cp_nr_rings; -return stat; +return bnxt_get_max_func_stat_ctxs (bp) -bnxt_get_func_stat_ctxs (bp); }int bnxt_get_avail_msix (struct bnxt *bp,int num)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 214/249 bnxt_en: Cap the returned MSIX vectors to the RDMA driver.
In reply to Sasha LevinFrom: Michael Chan <[email protected]>
[ Upstream commit 1dbc59fa4bbaa108b641cd65a54f662b75e4ed36 ]
In an earlier commit to improve NQ reservations on 57500 chips, we set the resv_irqs on the 57500 VFs to the fixed value assigned by the PF regardless of how many are actually used. The current code assumes that resv_irqs minus the ones used by the network driver must be the ones for the RDMA driver. This is no longer true and we may return more MSIX vectors than requested, causing inconsistency. Fix it by capping the value.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +3 -1
@@ -157,8 +157,10 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,if (BNXT_NEW_RM (bp)) {struct bnxt_hw_resc *hw_resc = &bp->hw_resc; +int resv_msix; - avail_msix = hw_resc->resv_irqs - bp->cp_nr_rings; + resv_msix = hw_resc->resv_irqs - bp->cp_nr_rings; + avail_msix =min_t (int, resv_msix, avail_msix); edev->ulp_tbl[ulp_id].msix_requested = avail_msix; }bnxt_fill_msix_vecs (bp, ent);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 215/249 ALSA: hda: Fix a headphone detection issue when using SOF
In reply to Sasha LevinFrom: Rander Wang <[email protected]>
[ Upstream commit 7c2b3629d09ddec810dc4c1d3a6657c32def8f71 ]
To save power, the hda hdmi driver in ASoC invokes snd_hdac_ext_bus_link_put to disable CORB/RIRB buffers DMA if there is no user of bus and invokes snd_hdac_ext_bus_link_get to set up CORB/RIRB buffers when it is used. Unsolicited responses is disabled in snd_hdac_bus_stop_cmd_io called by snd_hdac_ext_bus_link_put , but it is not enabled in snd_hdac_bus_init_cmd_io called by snd_hdac_ext_bus_link_get. So for put-get sequence, Unsolicited responses is disabled and headphone can't be detected by hda codecs.
Now unsolicited responses is only enabled in snd_hdac_bus_reset_link which resets controller. The function is only called for setup of controller. This patch enables Unsolicited responses after RIRB is initialized in snd_hdac_bus_init_cmd_io which works together with snd_hdac_bus_reset_link to set up controller.
Tested legacy hda driver and SOF driver on intel whiskeylake.
--- sound/hda/hdac_controller.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
sound/hda/hdac_controller.c +2 -3
@@ -79,6 +79,8 @@ void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus)snd_hdac_chip_writew (bus,RINTCNT ,1 );/* enable rirb dma and response irq */ snd_hdac_chip_writeb (bus,RIRBCTL ,AZX_RBCTL_DMA_EN |AZX_RBCTL_IRQ_EN ); +/* Accept unsolicited responses */ +snd_hdac_chip_updatel (bus,GCTL ,AZX_GCTL_UNSOL ,AZX_GCTL_UNSOL );spin_unlock_irq (&bus->reg_lock); }EXPORT_SYMBOL_GPL (snd_hdac_bus_init_cmd_io);
@@ -415,9 +417,6 @@ int snd_hdac_bus_reset_link(struct hdac_bus *bus, bool full_reset)return -EBUSY ; } -/* Accept unsolicited responses */ -snd_hdac_chip_updatel (bus,GCTL ,AZX_GCTL_UNSOL ,AZX_GCTL_UNSOL ); -/* detect codecs */ if (!bus->codec_mask) { bus->codec_mask =snd_hdac_chip_readw (bus,STATESTS );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 216/249 perf stat: Make metric event lookup more robust
In reply to Sasha LevinFrom: Andi Kleen <[email protected]>
[ Upstream commit 145c407c808352acd625be793396fd4f33c794f8 ]
After setting up metric groups through the event parser, the metricgroup code looks them up again in the event list.
Make sure we only look up events that haven't been used by some other metric. The data structures currently cannot handle more than one metric per event. This avoids problems with multiple events partially overlapping.
--- tools/perf/util/stat-shadow.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/util/stat-shadow.c +3 -2
@@ -303,7 +303,7 @@ static struct perf_evsel *perf_stat__find_event(struct perf_evlist *evsel_list,struct perf_evsel *c2; evlist__for_each_entry (evsel_list, c2) { -if (!strcasecmp (c2->name, name)) +if (!strcasecmp (c2->name, name) && !c2->collect_stat)return c2; }return NULL ;
@@ -342,7 +342,8 @@ void perf_stat__collect_metric_expr(struct perf_evlist *evsel_list)if (leader) {/* Search in group */ for_each_group_member (oc, leader) { -if (!strcasecmp (oc->name, metric_names[i])) { +if (!strcasecmp (oc->name, metric_names[i]) && + !oc->collect_stat) { found = true;break ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 217/249 perf stat: Fix metrics with --no-merge
In reply to Sasha LevinFrom: Andi Kleen <[email protected]>
[ Upstream commit e3a9427323a53ceee540276a74af7706f350d052 ]
Since Fixes: 8c5421c016a4 ("perf pmu: Display pmu name when printing unmerged events in stat") using --no-merge adds the PMU name to the evsel name.
This breaks the metric value lookup because the parser doesn't know about this.
Remove the extra postfixes for the metric evaluation.
--- tools/perf/util/stat-shadow.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
tools/perf/util/stat-shadow.c +17 -1
@@ -723,6 +723,7 @@ static void generic_metric(struct perf_stat_config *config,double ratio;int i;void *ctxp = out->ctx; +char *n, *pn;expr__ctx_init (&pctx);expr__add_id (&pctx, name, avg);
@@ -742,7 +743,19 @@ static void generic_metric(struct perf_stat_config *config, stats = &v->stats; scale =1.0 ; } -expr__add_id (&pctx, metric_events[i]->name,avg_stats (stats)*scale); + + n =strdup (metric_events[i]->name); +if (!n) +return ; +/* +* This display code with --no-merge adds [cpu] postfixes. +* These are not supported by the parser. Remove everything +* after the space. +*/ + pn =strchr (n,' ' ); +if (pn) + *pn =0 ; +expr__add_id (&pctx, n,avg_stats (stats)*scale); }if (!metric_events[i]) {const char *p = metric_expr;
@@ -759,6 +772,9 @@ static void generic_metric(struct perf_stat_config *config, (metric_name ? metric_name : name) : "", 0); }else print_metric (config, ctxp,NULL ,NULL ,"" ,0 ); + +for (i =1 ; i < pctx.num_ids; i++) +free ((void *)pctx.ids[i].name); } void perf_stat__print_shadow_stats(struct perf_stat_config *config,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 218/249 perf stat: Don't merge events in the same PMU
In reply to Sasha LevinFrom: Andi Kleen <[email protected]>
[ Upstream commit 6c5f4e5cb35b4694dc035d91092d23f596ecd06a ]
Event merging is mainly to collapse similar events in lots of different duplicated PMUs.
It can break metric displaying. It's possible for two metrics to have the same event, and when the two events happen in a row the second wouldn't be displayed. This would also not show the second metric.
To avoid this don't merge events in the same PMU. This makes sense, if we have multiple events in the same PMU there is likely some reason for it (e.g. using multiple groups) and we better not merge them.
While in theory it would be possible to construct metrics that have events with the same name in different PMU no current metrics have this problem.
This is the fix for perf stat -M UPI,IPC (needs also another bug fix to completely work)
--- tools/perf/util/stat-display.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/stat-display.c +2 -1
@@ -542,7 +542,8 @@ static void collect_all_aliases(struct perf_stat_config *config, struct perf_evs alias->scale != counter->scale || alias->cgrp != counter->cgrp ||strcmp (alias->unit, counter->unit) || - perf_evsel__is_clock(alias) != perf_evsel__is_clock(counter)) +perf_evsel__is_clock (alias) !=perf_evsel__is_clock (counter) || + !strcmp(alias->pmu_name, counter->pmu_name)) break; alias->merged_stat = true;cb (config, alias, data, false);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 219/249 perf stat: Fix group lookup for metric group
In reply to Sasha LevinFrom: Andi Kleen <[email protected]>
[ Upstream commit 2f87f33f4226523df9c9cc28f9874ea02fcc3d3f ]
The metric group code tries to find a group it added earlier in the evlist. Fix the lookup to handle groups with partially overlaps correctly. When a sub string match fails and we reset the match, we have to compare the first element again.
I also renamed the find_evsel function to find_evsel_group to make its purpose clearer.
With the earlier changes this fixes:
Before:
% perf stat -M UPI,IPC sleep 1
...
1,032,922 uops_retired.retire_slots # 1.1 UPI
1,896,096 inst_retired.any
1,896,096 inst_retired.any
1,177,254 cpu_clk_unhalted.threadAfter:
% perf stat -M UPI,IPC sleep 1
...
1,013,193 uops_retired.retire_slots # 1.1 UPI
932,033 inst_retired.any
932,033 inst_retired.any # 0.9 IPC
1,091,245 cpu_clk_unhalted.thread--- tools/perf/util/metricgroup.c | 47 ++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-)
tools/perf/util/metricgroup.c +35 -12
@@ -85,26 +85,49 @@ struct egroup {const char *metric_expr; }; -static struct perf_evsel *find_evsel (struct perf_evlist *perf_evlist, -const char **ids, -int idnum, -struct perf_evsel **metric_events) +static bool record_evsel (int *ind,struct perf_evsel **start, +int idnum, +struct perf_evsel **metric_events, +struct perf_evsel *ev) +{ + metric_events[*ind] = ev; +if (*ind ==0 ) + *start = ev; +if (++*ind == idnum) { + metric_events[*ind] =NULL ; +return true; + } +return false; +} + +static struct perf_evsel *find_evsel_group (struct perf_evlist *perf_evlist, +const char **ids, +int idnum, +struct perf_evsel **metric_events) {struct perf_evsel *ev, *start =NULL ;int ind =0 ; evlist__for_each_entry (perf_evlist, ev) { +if (ev->collect_stat) +continue ;if (!strcmp (ev->name, ids[ind])) { - metric_events[ind] = ev; -if (ind ==0 ) - start = ev; -if (++ind == idnum) { - metric_events[ind] =NULL ; +if (record_evsel (&ind, &start, idnum, + metric_events, ev))return start; - } }else { +/* +* We saw some other event that is not +* in our list of events. Discard +* the whole match and start again. +*/ ind =0 ; start =NULL ; +if (!strcmp (ev->name, ids[ind])) { +if (record_evsel (&ind, &start, idnum, + metric_events, ev)) +return start; + } } }/*
@@ -134,8 +157,8 @@ static int metricgroup__setup_events(struct list_head *groups, ret = -ENOMEM ;break ; } - evsel =find_evsel (perf_evlist, eg->ids, eg->idnum, - metric_events); + evsel =find_evsel_group (perf_evlist, eg->ids, eg->idnum, + metric_events);if (!evsel) {pr_debug ("Cannot resolve %s: %s\n" , eg->metric_name, eg->metric_expr);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 220/249 vxlan: do not destroy fdb if register_netdevice() is failed
In reply to Sasha LevinFrom: Taehee Yoo <[email protected]>
[ Upstream commit 7c31e54aeee517d1318dfc0bde9fa7de75893dc6 ]
__vxlan_dev_create() destroys FDB using specific pointer which indicates a fdb when error occurs.
But that pointer should not be used when register_netdevice() fails because register_netdevice() internally destroys fdb when error occurs.
This patch makes vxlan_fdb_create() to do not link fdb entry to vxlan dev internally.
Instead, a new function vxlan_fdb_insert() is added to link fdb to vxlan dev.
vxlan_fdb_insert() is called after calling register_netdevice(). This routine can avoid situation that ->ndo_uninit() destroys fdb entry in error path of register_netdevice().
Hence, error path of __vxlan_dev_create() routine can have an opportunity to destroy default fdb entry by hand.
Test command
ip link add bonding_masters type vxlan id 0 group 239.1.1.1 \ dev enp0s9 dstport 4789
Splat looks like:
[ 213.392816] kasan: GPF could be caused by NULL-ptr deref or user memory access [ 213.401257] general protection fault: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI [ 213.402178] CPU: 0 PID: 1414 Comm: ip Not tainted 5.2.0-rc5+ #256 [ 213.402178] RIP: 0010:vxlan_fdb_destroy+0x120/0x220 [vxlan] [ 213.402178] Code: df 48 8b 2b 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 06 01 00 00 4c 8b 63 08 48 b8 00 00 00 00 00 fc d [ 213.402178] RSP: 0018:ffff88810cb9f0a0 EFLAGS: 00010202 [ 213.402178] RAX: dffffc0000000000 RBX: ffff888101d4a8c8 RCX: 0000000000000000 [ 213.402178] RDX: 1bd5a00000000040 RSI: ffff888101d4a8c8 RDI: ffff888101d4a8d0 [ 213.402178] RBP: 0000000000000000 R08: fffffbfff22b72d9 R09: 0000000000000000 [ 213.402178] R10: 00000000ffffffef R11: 0000000000000000 R12: dead000000000200 [ 213.402178] R13: ffff88810cb9f1f8 R14: ffff88810efccda0 R15: ffff88810efccda0 [ 213.402178] FS: 00007f7f6621a0c0(0000) GS:ffff88811b000000(0000) knlGS:0000000000000000 [ 213.402178] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 213.402178] CR2: 000055746f0807d0 CR3: 00000001123e0000 CR4: 00000000001006f0 [ 213.402178] Call Trace: [ 213.402178] __vxlan_dev_create+0x3a9/0x7d0 [vxlan] [ 213.402178] ? vxlan_changelink+0x740/0x740 [vxlan] [ 213.402178] ? rcu_read_unlock+0x60/0x60 [vxlan] [ 213.402178] ? __kasan_kmalloc.constprop.3+0xa0/0xd0 [ 213.402178] vxlan_newlink+0x8d/0xc0 [vxlan] [ 213.402178] ? __vxlan_dev_create+0x7d0/0x7d0 [vxlan] [ 213.554119] ? __netlink_ns_capable+0xc3/0xf0 [ 213.554119] __rtnl_newlink+0xb75/0x1180 [ 213.554119] ? rtnl_link_unregister+0x230/0x230
[ ... ]
--- drivers/net/vxlan.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
drivers/net/vxlan.c +27 -10
@@ -804,6 +804,14 @@ static struct vxlan_fdb *vxlan_fdb_alloc(struct vxlan_dev *vxlan,return f; } +static void vxlan_fdb_insert (struct vxlan_dev *vxlan,const u8 *mac, +__be32 src_vni,struct vxlan_fdb *f) +{ + ++vxlan->addrcnt; +hlist_add_head_rcu (&f->hlist, +vxlan_fdb_head (vxlan, mac, src_vni)); +} + static int vxlan_fdb_create(struct vxlan_dev *vxlan, const u8 *mac, union vxlan_addr *ip, __u16 state, __be16 port, __be32 src_vni,
@@ -829,18 +837,13 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,return rc; } - ++vxlan->addrcnt; -hlist_add_head_rcu (&f->hlist, -vxlan_fdb_head (vxlan, mac, src_vni)); - *fdb = f;return 0 ; } -static void vxlan_fdb_free (struct rcu_head *head) +static void __vxlan_fdb_free (struct vxlan_fdb *f) { - struct vxlan_fdb *f = container_of(head, struct vxlan_fdb, rcu);struct vxlan_rdst *rd, *nd;list_for_each_entry_safe (rd, nd, &f->remotes, list) {
@@ -850,6 +853,13 @@ static void vxlan_fdb_free(struct rcu_head *head)kfree (f); } +static void vxlan_fdb_free (struct rcu_head *head) +{ + struct vxlan_fdb *f = container_of(head, struct vxlan_fdb, rcu); + +__vxlan_fdb_free (f); +} +static void vxlan_fdb_destroy (struct vxlan_dev *vxlan,struct vxlan_fdb *f,bool do_notify,bool swdev_notify) {
@@ -977,6 +987,7 @@ static int vxlan_fdb_update_create(struct vxlan_dev *vxlan,if (rc <0 )return rc; +vxlan_fdb_insert (vxlan, mac, src_vni, f); rc =vxlan_fdb_notify (vxlan, f,first_remote_rtnl (f),RTM_NEWNEIGH , swdev_notify, extack);if (rc)
@@ -3571,12 +3582,17 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev,if (err) goto errout; -/* notify default fdb entry */ if (f) { +vxlan_fdb_insert (vxlan, all_zeros_mac, + vxlan->default_dst.remote_vni, f); + +/* notify default fdb entry */ err =vxlan_fdb_notify (vxlan, f,first_remote_rtnl (f),RTM_NEWNEIGH , true, extack); -if (err) - goto errout; +if (err) { +vxlan_fdb_destroy (vxlan, f, false, false); + goto unregister; + } }list_add (&vxlan->next, &vn->vxlan_list);
@@ -3588,7 +3604,8 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev,* destroy the entry by hand here. */ if (f) -vxlan_fdb_destroy (vxlan, f, false, false); +__vxlan_fdb_free (f); +unregister:if (unregister)unregister_netdevice (dev);return err;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 221/249 bnx2x: Prevent ptp_task to be rescheduled indefinitely
In reply to Sasha LevinFrom: "Guilherme G. Piccoli" <[email protected]>
[ Upstream commit 3c91f25c2f72ba6001775a5932857c1d2131c531 ]
Currently bnx2x ptp worker tries to read a register with timestamp information in case of TX packet timestamping and in case it fails, the routine reschedules itself indefinitely. This was reported as a kworker always at 100% of CPU usage, which was narrowed down to be bnx2x ptp_task.
By following the ioctl handler, we could narrow down the problem to an NTP tool (chrony) requesting HW timestamping from bnx2x NIC with RX filter zeroed; this isn't reproducible for example with ptp4l (from linuxptp) since this tool requests a supported RX filter. It seems NIC FW timestamp mechanism cannot work well with RX_FILTER_NONE - driver's PTP filter init routine skips a register write to the adapter if there's not a supported filter request.
This patch addresses the problem of bnx2x ptp thread's everlasting reschedule by retrying the register read 10 times; between the read attempts the thread sleeps for an increasing amount of time starting in 1ms to give FW some time to perform the timestamping. If it still fails after all retries, we bail out in order to prevent an unbound resource consumption from bnx2x.
The patch also adds an ethtool statistic for accounting the skipped TX timestamp packets and it reduces the priority of timestamping error messages to prevent log flooding. The code was tested using both linuxptp and chrony.
--- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 5 ++- .../ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 4 ++- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 33 ++++++++++++++----- .../net/ethernet/broadcom/bnx2x/bnx2x_stats.h | 3 ++ 4 files changed, 34 insertions(+), 11 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +4 -1
@@ -3857,9 +3857,12 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)if (unlikely (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP )) {if (!(bp->flags &TX_TIMESTAMPING_EN )) { + bp->eth_stats.ptp_skip_tx_ts++;BNX2X_ERR ("Tx timestamping was not enabled, this packet will not be timestamped\n" ); }else if (bp->ptp_tx_skb) { -BNX2X_ERR ("The device supports only a single outstanding packet to timestamp, this packet will not be timestamped\n" ); + bp->eth_stats.ptp_skip_tx_ts++; +netdev_err_once (bp->dev, +"Device supports only a single outstanding packet to timestamp, this packet won't be timestamped\n" ); }else {skb_shinfo (skb)->tx_flags |=SKBTX_IN_PROGRESS ;/* schedule check for Tx timestamp */
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +3 -1
@@ -182,7 +182,9 @@ static const struct { {STATS_OFFSET32 (driver_filtered_tx_pkt), 4, false, "driver_filtered_tx_pkt" }, { STATS_OFFSET32(eee_tx_lpi), - 4, true, "Tx LPI entry count"} + 4, true, "Tx LPI entry count"}, + { STATS_OFFSET32(ptp_skip_tx_ts), + 4, false, "ptp_skipped_tx_tstamp" }, };#define BNX2X_NUM_STATS ARRAY_SIZE(bnx2x_stats_arr)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +24 -9
@@ -15214,11 +15214,24 @@ static void bnx2x_ptp_task(struct work_struct *work)u32 val_seq;u64 timestamp, ns;struct skb_shared_hwtstamps shhwtstamps; +bool bail = true; +int i; + +/* FW may take a while to complete timestamping; try a bit and if it's +* still not complete, may indicate an error state - bail out then. +*/ +for (i =0 ; i <10 ; i++) { +/* Read Tx timestamp registers */ + val_seq =REG_RD (bp, port ?NIG_REG_P1_TLLH_PTP_BUF_SEQID : +NIG_REG_P0_TLLH_PTP_BUF_SEQID ); +if (val_seq &0x10000 ) { + bail = false; +break ; + } +msleep (1 << i); + } -/* Read Tx timestamp registers */ - val_seq =REG_RD (bp, port ?NIG_REG_P1_TLLH_PTP_BUF_SEQID : -NIG_REG_P0_TLLH_PTP_BUF_SEQID ); -if (val_seq &0x10000 ) { +if (!bail) {/* There is a valid timestamp value */ timestamp =REG_RD (bp, port ?NIG_REG_P1_TLLH_PTP_BUF_TS_MSB :NIG_REG_P0_TLLH_PTP_BUF_TS_MSB );
@@ -15233,16 +15246,18 @@ static void bnx2x_ptp_task(struct work_struct *work)memset (&shhwtstamps,0 ,sizeof (shhwtstamps)); shhwtstamps.hwtstamp =ns_to_ktime (ns);skb_tstamp_tx (bp->ptp_tx_skb, &shhwtstamps); -dev_kfree_skb_any (bp->ptp_tx_skb); - bp->ptp_tx_skb =NULL ;DP (BNX2X_MSG_PTP ,"Tx timestamp, timestamp cycles = %llu, ns = %llu\n" , timestamp, ns); }else { -DP (BNX2X_MSG_PTP ,"There is no valid Tx timestamp yet\n" ); -/* Reschedule to keep checking for a valid timestamp value */ -schedule_work (&bp->ptp_task); +DP (BNX2X_MSG_PTP , +"Tx timestamp is not recorded (register read=%u)\n" , + val_seq); + bp->eth_stats.ptp_skip_tx_ts++; } + +dev_kfree_skb_any (bp->ptp_tx_skb); + bp->ptp_tx_skb =NULL ; }void bnx2x_set_rx_ts (struct bnx2x *bp,struct sk_buff *skb)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h +3 -0
@@ -207,6 +207,9 @@ struct bnx2x_eth_stats {u32 driver_filtered_tx_pkt;/* src: Clear-on-Read register; Will not survive PMF Migration */ u32 eee_tx_lpi; + +/* PTP */ +u32 ptp_skip_tx_ts; };struct bnx2x_eth_q_stats {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 222/249 net: usb: asix: init MAC address buffers
In reply to Sasha LevinFrom: Phong Tran <[email protected]>
[ Upstream commit 78226f6eaac80bf30256a33a4926c194ceefdf36 ]
This is for fixing bug KMSAN: uninit-value in ax88772_bind
Tested by
https://groups.google.com/d/msg/syzkaller-bugs/aFQurGotng4/eB_HlNhhCwAJ
syzbot found the following crash on:
HEAD commit: f75e4cfe kmsan: use kmsan_handle_urb() in urb.c git tree: kmsan console output: https://syzkaller.appspot.com/x/log.txt?x=136d720ea00000
kernel config:
https://syzkaller.appspot.com/x/.config?x=602468164ccdc30a
dashboard link:
https://syzkaller.appspot.com/bug?extid=8a3fc6674bbc3978ed4e
compiler: clang version 9.0.0 (/home/glider/llvm/clang06d00afa61eef8f7f501ebdb4e8612ea43ec2d78)
syz repro:
https://syzkaller.appspot.com/x/repro.syz?x=12788316a00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=120359aaa00000
==================================================================
BUG: KMSAN: uninit-value in is_valid_ether_addr include/linux/etherdevice.h:200 [inline] BUG: KMSAN: uninit-value in asix_set_netdev_dev_addr drivers/net/usb/asix_devices.c:73 [inline] BUG: KMSAN: uninit-value in ax88772_bind+0x93d/0x11e0 drivers/net/usb/asix_devices.c:724 CPU: 0 PID: 3348 Comm: kworker/0:2 Not tainted 5.1.0+ #1 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x191/0x1f0 lib/dump_stack.c:113 kmsan_report+0x130/0x2a0 mm/kmsan/kmsan.c:622 __msan_warning+0x75/0xe0 mm/kmsan/kmsan_instr.c:310 is_valid_ether_addr include/linux/etherdevice.h:200 [inline] asix_set_netdev_dev_addr drivers/net/usb/asix_devices.c:73 [inline] ax88772_bind+0x93d/0x11e0 drivers/net/usb/asix_devices.c:724 usbnet_probe+0x10f5/0x3940 drivers/net/usb/usbnet.c:1728 usb_probe_interface+0xd66/0x1320 drivers/usb/core/driver.c:361 really_probe+0xdae/0x1d80 drivers/base/dd.c:513 driver_probe_device+0x1b3/0x4f0 drivers/base/dd.c:671 __device_attach_driver+0x5b8/0x790 drivers/base/dd.c:778 bus_for_each_drv+0x28e/0x3b0 drivers/base/bus.c:454 __device_attach+0x454/0x730 drivers/base/dd.c:844 device_initial_probe+0x4a/0x60 drivers/base/dd.c:891 bus_probe_device+0x137/0x390 drivers/base/bus.c:514 device_add+0x288d/0x30e0 drivers/base/core.c:2106 usb_set_configuration+0x30dc/0x3750 drivers/usb/core/message.c:2027 generic_probe+0xe7/0x280 drivers/usb/core/generic.c:210 usb_probe_device+0x14c/0x200 drivers/usb/core/driver.c:266 really_probe+0xdae/0x1d80 drivers/base/dd.c:513 driver_probe_device+0x1b3/0x4f0 drivers/base/dd.c:671 __device_attach_driver+0x5b8/0x790 drivers/base/dd.c:778 bus_for_each_drv+0x28e/0x3b0 drivers/base/bus.c:454 __device_attach+0x454/0x730 drivers/base/dd.c:844 device_initial_probe+0x4a/0x60 drivers/base/dd.c:891 bus_probe_device+0x137/0x390 drivers/base/bus.c:514 device_add+0x288d/0x30e0 drivers/base/core.c:2106 usb_new_device+0x23e5/0x2ff0 drivers/usb/core/hub.c:2534 hub_port_connect drivers/usb/core/hub.c:5089 [inline] hub_port_connect_change drivers/usb/core/hub.c:5204 [inline] port_event drivers/usb/core/hub.c:5350 [inline] hub_event+0x48d1/0x7290 drivers/usb/core/hub.c:5432 process_one_work+0x1572/0x1f00 kernel/workqueue.c:2269 process_scheduled_works kernel/workqueue.c:2331 [inline] worker_thread+0x189c/0x2460 kernel/workqueue.c:2417 kthread+0x4b5/0x4f0 kernel/kthread.c:254 ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:355
--- drivers/net/usb/asix_devices.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/usb/asix_devices.c +3 -3
@@ -226,7 +226,7 @@ static void asix_phy_reset(struct usbnet *dev, unsigned int reset_bits)static int ax88172_bind (struct usbnet *dev,struct usb_interface *intf) {int ret =0 ; -u8 buf[ETH_ALEN ]; +u8 buf[ETH_ALEN ] = {0 };int i;unsigned long gpio_bits = dev->driver_info->data;
@@ -677,7 +677,7 @@ static int asix_resume(struct usb_interface *intf)static int ax88772_bind (struct usbnet *dev,struct usb_interface *intf) {int ret, i; -u8 buf[ETH_ALEN ], chipcode =0 ; +u8 buf[ETH_ALEN ] = {0 }, chipcode =0 ;u32 phyid;struct asix_common_private *priv;
@@ -1061,7 +1061,7 @@ static const struct net_device_ops ax88178_netdev_ops = {static int ax88178_bind (struct usbnet *dev,struct usb_interface *intf) {int ret; -u8 buf[ETH_ALEN ]; +u8 buf[ETH_ALEN ] = {0 };usbnet_get_endpoints (dev,intf);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 223/249 rxrpc: Fix oops in tracepoint
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit 99f0eae653b2db64917d0b58099eb51e300b311d ]
If the rxrpc_eproto tracepoint is enabled, an oops will be cause by the trace line that rxrpc_extract_header() tries to emit when a protocol error occurs (typically because the packet is short) because the call argument is NULL.
Fix this by using ?: to assume 0 as the debug_id if call is NULL.
This can then be induced by:
echo -e '\0\0\0\0\0\0\0\0' | ncat -4u --send-only <addr> 20001
where addr has the following program running on it:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <linux/rxrpc.h>
int main(void)
{
struct sockaddr_rxrpc srx;
int fd;
memset(&srx, 0, sizeof(srx));
srx.srx_family = AF_RXRPC;
srx.srx_service = 0;
srx.transport_type = AF_INET;
srx.transport_len = sizeof(srx.transport.sin);
srx.transport.sin.sin_family = AF_INET;
srx.transport.sin.sin_port = htons(0x4e21);
fd = socket(AF_RXRPC, SOCK_DGRAM, AF_INET6);
bind(fd, (struct sockaddr *)&srx, sizeof(srx));
sleep(20);
return 0;
}It results in the following oops.
BUG: kernel NULL pointer dereference, address: 0000000000000340 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page ... RIP: 0010:trace_event_raw_event_rxrpc_rx_eproto+0x47/0xac ... Call Trace: <IRQ> rxrpc_extract_header+0x86/0x171 ? rcu_read_lock_sched_held+0x5d/0x63 ? rxrpc_new_skb+0xd4/0x109 rxrpc_input_packet+0xef/0x14fc ? rxrpc_input_data+0x986/0x986 udp_queue_rcv_one_skb+0xbf/0x3d0 udp_unicast_rcv_skb.isra.8+0x64/0x71 ip_protocol_deliver_rcu+0xe4/0x1b4 ip_local_deliver+0xf0/0x154 __netif_receive_skb_one_core+0x50/0x6c netif_receive_skb_internal+0x26b/0x2e9 napi_gro_receive+0xf8/0x1da rtl8169_poll+0x303/0x4c4 net_rx_action+0x10e/0x333 __do_softirq+0x1a5/0x38f irq_exit+0x54/0xc4 do_IRQ+0xda/0xf8 common_interrupt+0xf/0xf </IRQ> ... ? cpuidle_enter_state+0x23c/0x34d cpuidle_enter+0x2a/0x36 do_idle+0x163/0x1ea cpu_startup_entry+0x1d/0x1f start_secondary+0x157/0x172 secondary_startup_64+0xa4/0xb0
--- include/trace/events/rxrpc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/rxrpc.h +1 -1
@@ -1379,7 +1379,7 @@ TRACE_EVENT(rxrpc_rx_eproto, ), TP_fast_assign( - __entry->call = call->debug_id; + __entry->call = call ? call->debug_id : 0; __entry->serial = serial; __entry->why = why; ),
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 224/249 libbpf: fix GCC8 warning for strncpy
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit cdfc7f888c2a355b01308e97c6df108f1c2b64e8 ]
GCC8 started emitting warning about using strncpy with number of bytes exactly equal destination size, which is generally unsafe, as can lead to non-zero terminated string being copied. Use IFNAMSIZ - 1 as number of bytes to ensure name is always zero-terminated.
--- tools/lib/bpf/xsk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/lib/bpf/xsk.c +2 -1
@@ -337,7 +337,8 @@ static int xsk_get_max_queues(struct xsk_socket *xsk) channels.cmd =ETHTOOL_GCHANNELS ; ifr.ifr_data = (void *)&channels; -strncpy (ifr.ifr_name, xsk->ifname,IFNAMSIZ ); +strncpy (ifr.ifr_name, xsk->ifname,IFNAMSIZ -1 ); + ifr.ifr_name[IFNAMSIZ -1 ] ='\0' ; err =ioctl (fd,SIOCETHTOOL , &ifr);if (err && errno !=EOPNOTSUPP ) { ret = -errno;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 225/249 bpf, libbpf, smatch: Fix potential NULL pointer dereference
In reply to Sasha LevinFrom: Leo Yan <[email protected]>
[ Upstream commit 33bae185f74d49a0d7b1bfaafb8e959efce0f243 ]
Based on the following report from Smatch, fix the potential NULL pointer dereference check:
tools/lib/bpf/libbpf.c:3493
bpf_prog_load_xattr() warn: variable dereferenced before check 'attr' (see line 3483)
3479 int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,
3480 struct bpf_object **pobj, int *prog_fd)
3481 {
3482 struct bpf_object_open_attr open_attr = {
3483 .file = attr->file,
3484 .prog_type = attr->prog_type,
^^^^^^3485 };
At the head of function, it directly access 'attr' without checking if it's NULL pointer. This patch moves the values assignment after validating 'attr' and 'attr->file'.
--- tools/lib/bpf/libbpf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/lib/bpf/libbpf.c +4 -4
@@ -3487,10 +3487,7 @@ int bpf_prog_load(const char *file, enum bpf_prog_type type,int bpf_prog_load_xattr (const struct bpf_prog_load_attr *attr,struct bpf_object **pobj,int *prog_fd) { -struct bpf_object_open_attr open_attr = { - .file = attr->file, - .prog_type = attr->prog_type, - }; +struct bpf_object_open_attr open_attr = {};struct bpf_program *prog, *first_prog =NULL ;enum bpf_attach_type expected_attach_type;enum bpf_prog_type prog_type;
@@ -3503,6 +3500,9 @@ int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,if (!attr->file)return -EINVAL ; + open_attr.file = attr->file; + open_attr.prog_type = attr->prog_type; + obj =bpf_object__open_xattr (&open_attr);if (IS_ERR_OR_NULL (obj))return -ENOENT ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 226/249 selftests: bpf: fix inlines in test_lwt_seg6local
In reply to Sasha LevinFrom: Jiri Benc <[email protected]>
[ Upstream commit 11aca65ec4db09527d3e9b6b41a0615b7da4386b ]
Selftests are reporting this failure in test_lwt_seg6local.sh:
+ ip netns exec ns2 ip -6 route add fb00::6 encap bpf in obj test_lwt_seg6local.o sec encap_srh dev veth2 Error fetching program/map!
Failed to parse eBPF program: Operation not permitted
The problem is __attribute__((always_inline)) alone is not enough to prevent clang from inserting those functions in .text. In that case, .text is not marked as relocateable.
See the output of objdump -h test_lwt_seg6local.o:
Idx Name Size VMA LMA File off Algn 0 .text 00003530 0000000000000000 0000000000000000 00000040 2**3
CONTENTS, ALLOC, LOAD, READONLY, CODE
This causes the iproute bpf loader to fail in bpf_fetch_prog_sec:bpf_has_call_data returns true but bpf_fetch_prog_relo fails as there's no relocateable .text section in the file.
To fix this, convert to 'static __always_inline'.
v2: Use 'static __always_inline' instead of 'static inline
__attribute__((always_inline))'
--- .../testing/selftests/bpf/progs/test_lwt_seg6local.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/bpf/progs/test_lwt_seg6local.c +6 -6
@@ -61,7 +61,7 @@ struct sr6_tlv_t {unsigned char value[0 ]; }BPF_PACKET_HEADER ; -__attribute__((always_inline))struct ip6_srh_t *get_srh (struct __sk_buff *skb) +static __always_inline struct ip6_srh_t *get_srh(struct __sk_buff *skb) {void *cursor, *data_end;struct ip6_srh_t *srh;
@@ -95,7 +95,7 @@ __attribute__((always_inline)) struct ip6_srh_t *get_srh(struct __sk_buff *skb)return srh; } -__attribute__((always_inline)) +static __always_inline int update_tlv_pad(struct __sk_buff *skb, uint32_t new_pad,uint32_t old_pad,uint32_t pad_off) {
@@ -125,7 +125,7 @@ int update_tlv_pad(struct __sk_buff *skb, uint32_t new_pad,return 0 ; } -__attribute__((always_inline)) +static __always_inline int is_valid_tlv_boundary(struct __sk_buff *skb, struct ip6_srh_t *srh,uint32_t *tlv_off,uint32_t *pad_size,uint32_t *pad_off)
@@ -184,7 +184,7 @@ int is_valid_tlv_boundary(struct __sk_buff *skb, struct ip6_srh_t *srh,return 0 ; } -__attribute__((always_inline)) +static __always_inline int add_tlv(struct __sk_buff *skb, struct ip6_srh_t *srh, uint32_t tlv_off,struct sr6_tlv_t *itlv,uint8_t tlv_size) {
@@ -228,7 +228,7 @@ int add_tlv(struct __sk_buff *skb, struct ip6_srh_t *srh, uint32_t tlv_off,return update_tlv_pad (skb, new_pad, pad_size, pad_off); } -__attribute__((always_inline)) +static __always_inline int delete_tlv(struct __sk_buff *skb, struct ip6_srh_t *srh,uint32_t tlv_off) {
@@ -266,7 +266,7 @@ int delete_tlv(struct __sk_buff *skb, struct ip6_srh_t *srh,return update_tlv_pad (skb, new_pad, pad_size, pad_off); } -__attribute__((always_inline)) +static __always_inline int has_egr_tlv(struct __sk_buff *skb, struct ip6_srh_t *srh) { int tlv_offset = sizeof(struct ip6_t) + sizeof(struct ip6_srh_t) +
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.2 226/249] selftests: bpf: fix inlines in test_lwt_seg6local
Quoted 5 lines · Sasha Levin
From: Jiri Benc <[email protected]>
[ Upstream commit
11aca65ec4db09527d3e9b6b41a0615b7da4386b]Selftests are reporting this failure in
test_lwt_seg6local.sh:
I don't think this is critical in any way and I don't think this is a stable material. How was this selected?
Jiri
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.2 226/249] selftests: bpf: fix inlines in test_lwt_seg6local
Quoted 9 lines · Jiri Benc
Quoted 5 lines · Sasha Levin
From: Jiri Benc <[email protected]>
[ Upstream commit
11aca65ec4db09527d3e9b6b41a0615b7da4386b]Selftests are reporting this failure in
test_lwt_seg6local.sh:I don't think this is critical in any way and I don't think this is a stable material. How was this selected?
It fixes a bug, right?
--
Thanks,
Sasha
Re: [PATCH AUTOSEL 5.2 226/249] selftests: bpf: fix inlines in test_lwt_seg6local
Quoted 1 line · Sasha Levin
It fixes a bug, right?
A bug in selftests. And quite likely, it probably happens only with some compiler versions.
I don't think patches only touching tools/testing/selftests/ qualify for stable in general. They don't affect the end users.
Jiri
David Miller
maintainerRe: [PATCH AUTOSEL 5.2 226/249] selftests: bpf: fix inlines in test_lwt_seg6local
From: Jiri Benc <[email protected]>
Date: Thu, 18 Jul 2019 09:36:54 +0200
Quoted 8 lines · Sasha Levin
Quoted 1 line
It fixes a bug, right?
A bug in selftests. And quite likely, it probably happens only with some compiler versions.
I don't think patches only touching
tools/testing/selftests/qualify for stable in general. They don't affect the end users.
It has a significant impact on automated testing which lots of individuals and entities perform, therefore I think it very much is -stable material.
Re: [PATCH AUTOSEL 5.2 226/249] selftests: bpf: fix inlines in test_lwt_seg6local
Quoted 3 lines · David Miller
It has a significant impact on automated testing which lots of individuals and entities perform, therefore I think it very much is -stable material.
Okay.
Thanks,
Jiri
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.2 226/249] selftests: bpf: fix inlines in test_lwt_seg6local
In reply to Jiri BencQuoted 8 lines · Jiri Benc
Quoted 1 line · Sasha Levin
It fixes a bug, right?
A bug in selftests. And quite likely, it probably happens only with some compiler versions.
I don't think patches only touching
tools/testing/selftests/qualify for stable in general. They don't affect the end users.
I'd argue that a bug in your tests is just as (if not even more) worse than a bug in the code.
--
Thanks,
Sasha
Sasha Levin
maintainerPATCH 227/249 bonding: validate ip header before check IPPROTO_IGMP
In reply to Sasha LevinFrom: Cong Wang <[email protected]>
[ Upstream commit 9d1bc24b52fb8c5d859f9a47084bf1179470e04c ]
bond_xmit_roundrobin() checks for IGMP packets but it parses the IP header even before checking skb->protocol.
We should validate the IP header with pskb_may_pull() before using iph->protocol.
--- drivers/net/bonding/bond_main.c | 37 ++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-)
drivers/net/bonding/bond_main.c +23 -14
@@ -3866,8 +3866,8 @@ static netdev_tx_t bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev) {struct bonding *bond =netdev_priv (bond_dev); -struct iphdr *iph =ip_hdr (skb);struct slave *slave; +int slave_cnt;u32 slave_id;/* Start with the curr_active_slave that joined the bond as the
@@ -3876,23 +3876,32 @@ static netdev_tx_t bond_xmit_roundrobin(struct sk_buff *skb,* send the join/membership reports. The curr_active_slave found * will send all of this type of traffic. */ -if (iph->protocol ==IPPROTO_IGMP && skb->protocol ==htons (ETH_P_IP )) { - slave =rcu_dereference (bond->curr_active_slave); -if (slave) -bond_dev_queue_xmit (bond, skb, slave->dev); -else -bond_xmit_slave_id (bond, skb,0 ); - }else { -int slave_cnt =READ_ONCE (bond->slave_cnt); +if (skb->protocol ==htons (ETH_P_IP )) { +int noff =skb_network_offset (skb); +struct iphdr *iph; -if (likely (slave_cnt)) { - slave_id =bond_rr_gen_slave_id (bond); -bond_xmit_slave_id (bond, skb, slave_id % slave_cnt); - }else { -bond_tx_drop (bond_dev, skb); +if (unlikely (!pskb_may_pull (skb, noff +sizeof (*iph)))) + goto non_igmp; + + iph =ip_hdr (skb); +if (iph->protocol ==IPPROTO_IGMP ) { + slave =rcu_dereference (bond->curr_active_slave); +if (slave) +bond_dev_queue_xmit (bond, skb, slave->dev); +else +bond_xmit_slave_id (bond, skb,0 ); +return NETDEV_TX_OK ; } } +non_igmp: + slave_cnt =READ_ONCE (bond->slave_cnt); +if (likely (slave_cnt)) { + slave_id =bond_rr_gen_slave_id (bond); +bond_xmit_slave_id (bond, skb, slave_id % slave_cnt); + }else { +bond_tx_drop (bond_dev, skb); + }return NETDEV_TX_OK ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 228/249 gpiolib: Fix references to gpiod_[gs]et_*value_cansleep() variants
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 3285170f28a850638794cdfe712eb6d93e51e706 ]
Commit 372e722ea4dd4ca1 ("gpiolib: use descriptors internally") renamed the functions to use a "gpiod" prefix, and commit 79a9becda8940deb ("gpiolib: export descriptor-based GPIO interface") introduced the "raw" variants, but both changes forgot to update the comments.
Readd a similar reference to gpiod_set_value(), which was accidentally removed by commit 1e77fc82110ac36f ("gpio: Add missing open drain/source handling to gpiod_set_value_cansleep()").
--- drivers/gpio/gpiolib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib.c +4 -3
@@ -3025,7 +3025,7 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep,int gpiod_get_raw_value (const struct gpio_desc *desc) {VALIDATE_DESC (desc); -/* Should be using gpio_get_value_cansleep() */ +/* Should be using gpiod_get_raw_value_cansleep() */ WARN_ON (desc->gdev->chip->can_sleep);return gpiod_get_raw_value_commit (desc); }
@@ -3046,7 +3046,7 @@ int gpiod_get_value(const struct gpio_desc *desc)int value;VALIDATE_DESC (desc); -/* Should be using gpio_get_value_cansleep() */ +/* Should be using gpiod_get_value_cansleep() */ WARN_ON (desc->gdev->chip->can_sleep); value =gpiod_get_raw_value_commit (desc);
@@ -3317,7 +3317,7 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep,void gpiod_set_raw_value (struct gpio_desc *desc,int value) {VALIDATE_DESC_VOID (desc); -/* Should be using gpiod_set_value_cansleep() */ +/* Should be using gpiod_set_raw_value_cansleep() */ WARN_ON (desc->gdev->chip->can_sleep);gpiod_set_raw_value_commit (desc, value); }
@@ -3358,6 +3358,7 @@ static void gpiod_set_value_nocheck(struct gpio_desc *desc, int value)void gpiod_set_value (struct gpio_desc *desc,int value) {VALIDATE_DESC_VOID (desc); +/* Should be using gpiod_set_value_cansleep() */ WARN_ON (desc->gdev->chip->can_sleep);gpiod_set_value_nocheck (desc, value); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 229/249 iommu/arm-smmu-v3: Invalidate ATC when detaching a device
In reply to Sasha LevinFrom: Jean-Philippe Brucker <[email protected]>
[ Upstream commit 8dd8f005bdd45823fc153ef490239558caf6ff20 ]
We make the invalid assumption in arm_smmu_detach_dev() that the ATC is clear after calling pci_disable_ats(). For one thing, only enabling the PCIe ATS capability constitutes an implicit invalidation event, so the comment was wrong. More importantly, the ATS capability isn't necessarily disabled by pci_disable_ats() in a PF, if the associated VFs have ATS enabled. Explicitly invalidate all ATC entries in arm_smmu_detach_dev(). The endpoint cannot form new ATC entries because STE.EATS is clear.
--- drivers/iommu/arm-smmu-v3.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iommu/arm-smmu-v3.c +4 -1
@@ -1884,9 +1884,13 @@ static int arm_smmu_enable_ats(struct arm_smmu_master *master)static void arm_smmu_disable_ats (struct arm_smmu_master *master) { +struct arm_smmu_cmdq_ent cmd; +if (!master->ats_enabled || !dev_is_pci (master->dev))return ; +arm_smmu_atc_inv_to_cmd (0 ,0 ,0 , &cmd); +arm_smmu_atc_inv_master (master, &cmd);pci_disable_ats (to_pci_dev (master->dev)); master->ats_enabled = false; }
@@ -1906,7 +1910,6 @@ static void arm_smmu_detach_dev(struct arm_smmu_master *master) master->domain =NULL ;arm_smmu_install_ste_for_dev (master); -/* Disabling ATS invalidates all ATC entries */ arm_smmu_disable_ats (master); }
Signature · 6 lines
2.20.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Sasha Levin
maintainerPATCH 230/249 ASoC: audio-graph-card: fix use-after-free in graph_for_each_link
In reply to Sasha LevinFrom: Wen Yang <[email protected]>
[ Upstream commit 1bcc1fd64e4dd903f4d868a9e053986e3b102713 ]
After calling of_node_put() on the codec_ep and codec_port variables, they are still being used, which may result in use-after-free. We fix this issue by calling of_node_put() after the last usage.
--- sound/soc/generic/audio-graph-card.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/generic/audio-graph-card.c +3 -3
@@ -435,9 +435,6 @@ static int graph_for_each_link(struct asoc_simple_priv *priv, codec_ep =of_graph_get_remote_endpoint (cpu_ep); codec_port =of_get_parent (codec_ep); -of_node_put (codec_ep); -of_node_put (codec_port); -/* get convert-xxx property */ memset (&adata,0 ,sizeof (adata));graph_parse_convert (dev, codec_ep, &adata);
@@ -457,6 +454,9 @@ static int graph_for_each_link(struct asoc_simple_priv *priv,else ret =func_noml (priv, cpu_ep, codec_ep, li); +of_node_put (codec_ep); +of_node_put (codec_port); +if (ret <0 )return ret;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 231/249 tools: bpftool: Fix json dump crash on powerpc
In reply to Sasha LevinFrom: Jiri Olsa <[email protected]>
[ Upstream commit aa52bcbe0e72fac36b1862db08b9c09c4caefae3 ]
Michael reported crash with by bpf program in json mode on powerpc:
# bpftool prog -p dump jited id 14
[{
"name": "0xd00000000a9aa760",
"insns": [{
"pc": "0x0",
"operation": "nop",
"operands": [null
]
},{
"pc": "0x4",
"operation": "nop",
"operands": [null
]
},{
"pc": "0x8",
"operation": "mflr",
Segmentation fault (core dumped)The code is assuming char pointers in format, which is not always true at least for powerpc. Fixing this by dumping the whole string into buffer based on its format.
Please note that libopcodes code does not check return values from fprintf callback, but as per Jakub suggestion returning -1 on allocation failure so we do the best effort to propagate the error.
--- tools/bpf/bpftool/jit_disasm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/bpf/bpftool/jit_disasm.c +7 -4
@@ -11,6 +11,8 @@* Licensed under the GNU General Public License, version 2.0 (GPLv2) */ +#define _GNU_SOURCE +#include <stdio.h> #include <stdarg.h> #include <stdint.h> #include <stdio.h>
@@ -44,11 +46,13 @@ static int fprintf_json(void *out, const char *fmt, ...)char *s;va_start (ap, fmt); +if (vasprintf (&s, fmt, ap) <0 ) +return -1 ; +va_end (ap); +if (!oper_count) {int i; - s = va_arg(ap, char *); -/* Strip trailing spaces */ i =strlen (s) -1 ;while (s[i] ==' ' )
@@ -61,11 +65,10 @@ static int fprintf_json(void *out, const char *fmt, ...) }else if (!strcmp (fmt,"," )) {/* Skip */ }else { - s = va_arg(ap, char *);jsonw_string (json_wtr, s); oper_count++; } -va_end (ap); +free (s);return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 232/249 net: hns3: enable broadcast promisc mode when initializing VF
In reply to Sasha LevinFrom: Jian Shen <[email protected]>
[ Upstream commit 2d5066fc175ea77a733d84df9ef414b34f311641 ]
For revision 0x20, the broadcast promisc is enabled by firmware, it's unnecessary to enable it when initializing VF.
For revision 0x21, it's necessary to enable broadcast promisc mode when initializing or re-initializing VF, otherwise, it will be unable to send and receive promisc packets.
--- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +11 -3
@@ -2512,6 +2512,12 @@ static int hclgevf_reset_hdev(struct hclgevf_dev *hdev)return ret; } +if (pdev->revision >=0x21 ) { + ret =hclgevf_set_promisc_mode (hdev, true); +if (ret) +return ret; + } +dev_info (&hdev->pdev->dev,"Reset done\n" );return 0 ;
@@ -2591,9 +2597,11 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)* firmware makes sure broadcast packets can be accepted. * For revision 0x21, default to enable broadcast promisc mode. */ - ret =hclgevf_set_promisc_mode (hdev, true); -if (ret) - goto err_config; +if (pdev->revision >=0x21 ) { + ret =hclgevf_set_promisc_mode (hdev, true); +if (ret) + goto err_config; + }/* Initialize RSS for this VF */ ret =hclgevf_rss_init_hw (hdev);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 233/249 net: hns3: fix port capbility updating issue
In reply to Sasha LevinFrom: Jian Shen <[email protected]>
[ Upstream commit 49b1255603de5183c5e377200be3b3afe0dcdb86 ]
Currently, the driver queries the media port information, and updates the port capability periodically. But it sets an error mac->speed_type value, which stops update port capability.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +1 -0
@@ -2592,6 +2592,7 @@ static int hclge_get_sfp_info(struct hclge_dev *hdev, struct hclge_mac *mac) mac->speed_ability =le32_to_cpu (resp->speed_ability); mac->autoneg = resp->autoneg; mac->support_autoneg = resp->autoneg_ability; + mac->speed_type =QUERY_ACTIVE_SPEED ;if (!resp->active_fec) mac->fec_mode =0 ;else
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 234/249 Bluetooth: hci_bcsp: Fix memory leak in rx_skb
In reply to Sasha LevinFrom: Tomas Bortoli <[email protected]>
[ Upstream commit 4ce9146e0370fcd573f0372d9b4e5a211112567c ]
Syzkaller found that it is possible to provoke a memory leak by never freeing rx_skb in struct bcsp_struct.
Fix by freeing in bcsp_close()
--- drivers/bluetooth/hci_bcsp.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/bluetooth/hci_bcsp.c +5 -0
@@ -744,6 +744,11 @@ static int bcsp_close(struct hci_uart *hu)skb_queue_purge (&bcsp->rel);skb_queue_purge (&bcsp->unrel); +if (bcsp->rx_skb) { +kfree_skb (bcsp->rx_skb); + bcsp->rx_skb =NULL ; + } +kfree (bcsp);return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 235/249 Bluetooth: Add new 13d3:3491 QCA_ROME device
In reply to Sasha LevinFrom: João Paulo Rechi Vita <[email protected]>
[ Upstream commit 44d34af2e4cfd0c5357182f8b43f3e0a1fe30a2e ]
Without the QCA ROME setup routine this adapter fails to establish a SCO connection.
T: Bus=01 Lev=01 Prnt=01 Port=08 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=13d3 ProdID=3491 Rev=00.01 C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I: If#=0x0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb I: If#=0x1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
--- drivers/bluetooth/btusb.c | 1 + 1 file changed, 1 insertion(+)
drivers/bluetooth/btusb.c +1 -0
@@ -264,6 +264,7 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x04ca, 0x3015), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x04ca, 0x3016), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x04ca, 0x301a), .driver_info = BTUSB_QCA_ROME }, + { USB_DEVICE(0x13d3, 0x3491), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME },/* Broadcom BCM2035 */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 236/249 Bluetooth: Add new 13d3:3501 QCA_ROME device
In reply to Sasha LevinFrom: João Paulo Rechi Vita <[email protected]>
[ Upstream commit 881cec4f6b4da78e54b73c046a60f39315964c7d ]
Without the QCA ROME setup routine this adapter fails to establish a SCO connection.
T: Bus=01 Lev=01 Prnt=01 Port=04 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=13d3 ProdID=3501 Rev=00.01 C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I: If#=0x0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb I: If#=0x1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
--- drivers/bluetooth/btusb.c | 1 + 1 file changed, 1 insertion(+)
drivers/bluetooth/btusb.c +1 -0
@@ -266,6 +266,7 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x04ca, 0x301a), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x13d3, 0x3491), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME }, + { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME }, /* Broadcom BCM2035 */ { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 },
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 237/249 Bluetooth: 6lowpan: search for destination address in all peers
In reply to Sasha LevinFrom: Josua Mayer <[email protected]>
[ Upstream commit b188b03270b7f8568fc714101ce82fbf5e811c5a ]
Handle overlooked case where the target address is assigned to a peer and neither route nor gateway exist.
For one peer, no checks are performed to see if it is meant to receive packets for a given address.
As soon as there is a second peer however, checks are performed to deal with routes and gateways for handling complex setups with multiple hops to a target address.
This logic assumed that no route and no gateway imply that the destination address can not be reached, which is false in case of a direct peer.
--- net/bluetooth/6lowpan.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/bluetooth/6lowpan.c +10 -4
@@ -180,10 +180,16 @@ static inline struct lowpan_peer *peer_lookup_dst(struct lowpan_btle_dev *dev, }if (!rt) { - nexthop = &lowpan_cb (skb)->gw; - -if (ipv6_addr_any (nexthop)) -return NULL ; +if (ipv6_addr_any (&lowpan_cb (skb)->gw)) { +/* There is neither route nor gateway, +* probably the destination is a direct peer. +*/ + nexthop = daddr; + }else { +/* There is a known gateway +*/ + nexthop = &lowpan_cb (skb)->gw; + } }else { nexthop =rt6_nexthop (rt, daddr);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 238/249 genirq: Update irq stats from NMI handlers
In reply to Sasha LevinFrom: Shijith Thotton <[email protected]>
[ Upstream commit c09cb1293523dd786ae54a12fd88001542cba2f6 ]
The NMI handlers handle_percpu_devid_fasteoi_nmi() and handle_fasteoi_nmi() do not update the interrupt counts. Due to that the NMI interrupt count does not show up correctly in /proc/interrupts.
Add the statistics and treat the NMI handlers in the same way as per cpu interrupts and prevent them from updating irq_desc::tot_count as this might be corrupted due to concurrency.
[ tglx: Massaged changelog ]
--- kernel/irq/chip.c | 4 ++++ kernel/irq/irqdesc.c | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-)
kernel/irq/chip.c +4 -0
@@ -748,6 +748,8 @@ void handle_fasteoi_nmi(struct irq_desc *desc)unsigned int irq =irq_desc_get_irq (desc);irqreturn_t res; +__kstat_incr_irqs_this_cpu (desc); +trace_irq_handler_entry (irq, action);/* * NMIs cannot be shared, there is only one action.
@@ -962,6 +964,8 @@ void handle_percpu_devid_fasteoi_nmi(struct irq_desc *desc)unsigned int irq =irq_desc_get_irq (desc);irqreturn_t res; +__kstat_incr_irqs_this_cpu (desc); +trace_irq_handler_entry (irq, action); res = action->handler (irq,raw_cpu_ptr (action->percpu_dev_id));trace_irq_handler_exit (irq, action, res);
kernel/irq/irqdesc.c +7 -1
@@ -946,6 +946,11 @@ unsigned int kstat_irqs_cpu(unsigned int irq, int cpu) *per_cpu_ptr(desc->kstat_irqs, cpu) : 0; } +static bool irq_is_nmi (struct irq_desc *desc) +{ +return desc->istate &IRQS_NMI ; +} +/** * kstat_irqs - Get the statistics for an interrupt * @irq: The interrupt number
@@ -963,7 +968,8 @@ unsigned int kstat_irqs(unsigned int irq)if (!desc || !desc->kstat_irqs)return 0 ;if (!irq_settings_is_per_cpu_devid (desc) && - !irq_settings_is_per_cpu (desc)) + !irq_settings_is_per_cpu (desc) && + !irq_is_nmi (desc))return desc->tot_count;for_each_possible_cpu (cpu)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 239/249 perf tests: Fix record+probe_libc_inet_pton.sh for powerpc64
In reply to Sasha LevinFrom: Seeteena Thoufeek <[email protected]>
[ Upstream commit bff5a556c149804de29347a88a884d25e4e4e3a2 ]
'probe libc's inet_pton & backtrace it with ping' testcase sometimes fails on powerpc because distro ping binary does not have symbol information and thus it prints "[unknown]" function name in the backtrace.
Accept "[unknown]" as valid function name for powerpc as well.
# perf test -v "probe libc's inet_pton & backtrace it with ping"
Before:
59: probe libc's inet_pton & backtrace it with ping :
--- start ---
test child forked, pid 79695
ping 79718 [077] 96483.787025: probe_libc:inet_pton: (7fff83a754c8) 7fff83a754c8 __GI___inet_pton+0x8 (/usr/lib64/power9/libc-2.28.so) 7fff83a2b7a0 gaih_inet.constprop.7+0x1020 (/usr/lib64/power9/libc-2.28.so)
7fff83a2c170 getaddrinfo+0x160 (/usr/lib64/power9/libc-2.28.so) 1171830f4 [unknown] (/usr/bin/ping)
FAIL: expected backtrace entry ".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$"
got "1171830f4 [unknown] (/usr/bin/ping)"
test child finished with -1
---- end ----
probe libc's inet_pton & backtrace it with ping: FAILED!
After:
59: probe libc's inet_pton & backtrace it with ping :
--- start ---
test child forked, pid 79085
ping 79108 [045] 96400.214177: probe_libc:inet_pton: (7fffbb9654c8) 7fffbb9654c8 __GI___inet_pton+0x8 (/usr/lib64/power9/libc-2.28.so) 7fffbb91b7a0 gaih_inet.constprop.7+0x1020 (/usr/lib64/power9/libc-2.28.so)
7fffbb91c170 getaddrinfo+0x160 (/usr/lib64/power9/libc-2.28.so) 132e830f4 [unknown] (/usr/bin/ping)
test child finished with 0
---- end ----
probe libc's inet_pton & backtrace it with ping: Ok
--- tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/record+probe_libc_inet_pton.sh +1 -1
@@ -44,7 +44,7 @@ trace_libc_inet_pton_backtrace() { eventattr='max-stack=4' echo "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected echo "getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$" >> $expected - echo ".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected + echo ".*(\+0x[[:xdigit:]]+|\[unknown\])[[:space:]]\(.*/bin/ping.*\)$" >> $expected ;; *) eventattr='max-stack=3'
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 240/249 Bluetooth: Check state in l2cap_disconnect_rsp
In reply to Sasha LevinFrom: Matias Karhumaa <[email protected]>
[ Upstream commit 28261da8a26f4915aa257d12d506c6ba179d961f ]
Because of both sides doing L2CAP disconnection at the same time, it was possible to receive L2CAP Disconnection Response with CID that was already freed. That caused problems if CID was already reused and L2CAP Connection Request with same CID was sent out. Before this patch kernel deleted channel context regardless of the state of the channel.
Example where leftover Disconnection Response (frame #402) causes local device to delete L2CAP channel which was not yet connected. This in turn confuses remote device's stack because same CID is re-used without properly disconnecting.
Btmon capture before patch:
** snip **
Quoted 1 line
ACL Data RX: Handle 43 flags
0x02dlen 8 #394 [hci1] 10.748949
Channel: 65 len 4 [PSM 3 mode 0] {chan 2}
RFCOMM: Disconnect (DISC) (0x43)
Address: 0x03 cr 1 dlci 0x00
Control: 0x53 poll/final 1
Length: 0
FCS: 0xfd
< ACL Data TX: Handle 43 flags 0x00 dlen 8 #395 [hci1] 10.749062
Channel: 65 len 4 [PSM 3 mode 0] {chan 2}
RFCOMM: Unnumbered Ack (UA) (0x63)
Address: 0x03 cr 1 dlci 0x00
Control: 0x73 poll/final 1
Length: 0
FCS: 0xd7< ACL Data TX: Handle 43 flags 0x00 dlen 12 #396 [hci1] 10.749073
L2CAP: Disconnection Request (0x06) ident 17 len 4
Destination CID: 65
Source CID: 65
Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #397 [hci1] 10.752391
Num handles: 1
Handle: 43
Count: 1
Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #398 [hci1] 10.753394
Num handles: 1
Handle: 43
Count: 1
Quoted 1 line
ACL Data RX: Handle 43 flags
0x02dlen 12 #399 [hci1] 10.756499
L2CAP: Disconnection Request (0x06) ident 26 len 4
Destination CID: 65
Source CID: 65
< ACL Data TX: Handle 43 flags 0x00 dlen 12 #400 [hci1] 10.756548
L2CAP: Disconnection Response (0x07) ident 26 len 4
Destination CID: 65
Source CID: 65
< ACL Data TX: Handle 43 flags 0x00 dlen 12 #401 [hci1] 10.757459
L2CAP: Connection Request (0x02) ident 18 len 4
PSM: 1 (0x0001)
Source CID: 65Quoted 1 line
ACL Data RX: Handle 43 flags
0x02dlen 12 #402 [hci1] 10.759148
L2CAP: Disconnection Response (0x07) ident 17 len 4
Destination CID: 65
Source CID: 65
= bluetoothd: 00:1E:AB:4C:56:54: error updating services: Input/o.. 10.759447
Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #403 [hci1] 10.759386
Num handles: 1
Handle: 43
Count: 1
Quoted 1 line
ACL Data RX: Handle 43 flags
0x02dlen 12 #404 [hci1] 10.760397
L2CAP: Connection Request (0x02) ident 27 len 4
PSM: 3 (0x0003)
Source CID: 65
< ACL Data TX: Handle 43 flags 0x00 dlen 16 #405 [hci1] 10.760441
L2CAP: Connection Response (0x03) ident 27 len 8
Destination CID: 65
Source CID: 65
Result: Connection successful (0x0000)
Status: No further information available (0x0000)< ACL Data TX: Handle 43 flags 0x00 dlen 27 #406 [hci1] 10.760449
L2CAP: Configure Request (0x04) ident 19 len 19
Destination CID: 65
Flags: 0x0000
Option: Maximum Transmission Unit (0x01) [mandatory]
MTU: 1013
Option: Retransmission and Flow Control (0x04) [mandatory]
Mode: Basic (0x00)
TX window size: 0
Max transmit: 0
Retransmission timeout: 0
Monitor timeout: 0
Maximum PDU size: 0
Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #407 [hci1] 10.761399
Num handles: 1
Handle: 43
Count: 1
Quoted 1 line
ACL Data RX: Handle 43 flags
0x02dlen 16 #408 [hci1] 10.762942
L2CAP: Connection Response (0x03) ident 18 len 8
Destination CID: 66
Source CID: 65
Result: Connection successful (0x0000)
Status: No further information available (0x0000)*snip*
Similar case after the patch:
*snip*
Quoted 1 line
ACL Data RX: Handle 43 flags
0x02dlen 8 #22702 [hci0] 1664.411056
Channel: 65 len 4 [PSM 3 mode 0] {chan 3}
RFCOMM: Disconnect (DISC) (0x43)
Address: 0x03 cr 1 dlci 0x00
Control: 0x53 poll/final 1
Length: 0
FCS: 0xfd
< ACL Data TX: Handle 43 flags 0x00 dlen 8 #22703 [hci0] 1664.411136
Channel: 65 len 4 [PSM 3 mode 0] {chan 3}
RFCOMM: Unnumbered Ack (UA) (0x63)
Address: 0x03 cr 1 dlci 0x00
Control: 0x73 poll/final 1
Length: 0
FCS: 0xd7< ACL Data TX: Handle 43 flags 0x00 dlen 12 #22704 [hci0] 1664.411143
L2CAP: Disconnection Request (0x06) ident 11 len 4
Destination CID: 65
Source CID: 65
Quoted 1 line
HCI Event: Number of Completed Pac.. (
0x13) plen 5 #22705 [hci0] 1664.414009
Num handles: 1
Handle: 43
Count: 1
Quoted 1 line
HCI Event: Number of Completed Pac.. (
0x13) plen 5 #22706 [hci0] 1664.415007
Num handles: 1
Handle: 43
Count: 1
Quoted 1 line
ACL Data RX: Handle 43 flags
0x02dlen 12 #22707 [hci0] 1664.418674
L2CAP: Disconnection Request (0x06) ident 17 len 4
Destination CID: 65
Source CID: 65
< ACL Data TX: Handle 43 flags 0x00 dlen 12 #22708 [hci0] 1664.418762
L2CAP: Disconnection Response (0x07) ident 17 len 4
Destination CID: 65
Source CID: 65
< ACL Data TX: Handle 43 flags 0x00 dlen 12 #22709 [hci0] 1664.421073
L2CAP: Connection Request (0x02) ident 12 len 4
PSM: 1 (0x0001)
Source CID: 65Quoted 1 line
ACL Data RX: Handle 43 flags
0x02dlen 12 #22710 [hci0] 1664.421371
L2CAP: Disconnection Response (0x07) ident 11 len 4
Destination CID: 65
Source CID: 65
Quoted 1 line
HCI Event: Number of Completed Pac.. (
0x13) plen 5 #22711 [hci0] 1664.424082
Num handles: 1
Handle: 43
Count: 1
Quoted 1 line
HCI Event: Number of Completed Pac.. (
0x13) plen 5 #22712 [hci0] 1664.425040
Num handles: 1
Handle: 43
Count: 1
Quoted 1 line
ACL Data RX: Handle 43 flags
0x02dlen 12 #22713 [hci0] 1664.426103
L2CAP: Connection Request (0x02) ident 18 len 4
PSM: 3 (0x0003)
Source CID: 65
< ACL Data TX: Handle 43 flags 0x00 dlen 16 #22714 [hci0] 1664.426186
L2CAP: Connection Response (0x03) ident 18 len 8
Destination CID: 66
Source CID: 65
Result: Connection successful (0x0000)
Status: No further information available (0x0000)< ACL Data TX: Handle 43 flags 0x00 dlen 27 #22715 [hci0] 1664.426196
L2CAP: Configure Request (0x04) ident 13 len 19
Destination CID: 65
Flags: 0x0000
Option: Maximum Transmission Unit (0x01) [mandatory]
MTU: 1013
Option: Retransmission and Flow Control (0x04) [mandatory]
Mode: Basic (0x00)
TX window size: 0
Max transmit: 0
Retransmission timeout: 0
Monitor timeout: 0
Maximum PDU size: 0
Quoted 1 line
ACL Data RX: Handle 43 flags
0x02dlen 16 #22716 [hci0] 1664.428804
L2CAP: Connection Response (0x03) ident 12 len 8
Destination CID: 66
Source CID: 65
Result: Connection successful (0x0000)
Status: No further information available (0x0000)*snip*
Fix is to check that channel is in state BT_DISCONN before deleting the channel.
This bug was found while fuzzing Bluez's OBEX implementation using Synopsys Defensics.
--- net/bluetooth/l2cap_core.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/bluetooth/l2cap_core.c +6 -0
@@ -4394,6 +4394,12 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn,l2cap_chan_lock (chan); +if (chan->state !=BT_DISCONN ) { +l2cap_chan_unlock (chan); +mutex_unlock (&conn->chan_lock); +return 0 ; + } +l2cap_chan_hold (chan);l2cap_chan_del (chan,0 );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 241/249 Bluetooth: hidp: NUL terminate a string in the compat ioctl
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit dcae9052ebb0c5b2614de620323d615fcbfda7f8 ]
This change is similar to commit a1616a5ac99e ("Bluetooth: hidp: fix buffer overflow") but for the compat ioctl. We take a string from the user and forgot to ensure that it's NUL terminated.
I have also changed the strncpy() in to strscpy() in hidp_setup_hid(). The difference is the strncpy() doesn't necessarily NUL terminate the destination string. Either change would fix the problem but it's nice to take a belt and suspenders approach and do both.
--- net/bluetooth/hidp/core.c | 2 +- net/bluetooth/hidp/sock.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/hidp/core.c +1 -1
@@ -775,7 +775,7 @@ static int hidp_setup_hid(struct hidp_session *session, hid->version = req->version; hid->country = req->country; -strncpy (hid->name, req->name,sizeof (hid->name)); +strscpy (hid->name, req->name,sizeof (hid->name));snprintf (hid->phys,sizeof (hid->phys),"%pMR" , &l2cap_pi (session->ctrl_sock->sk)->chan->src);
net/bluetooth/hidp/sock.c +1 -0
@@ -192,6 +192,7 @@ static int hidp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne ca.version = ca32.version; ca.flags = ca32.flags; ca.idle_to = ca32.idle_to; + ca32.name[sizeof (ca32.name) -1 ] ='\0' ;memcpy (ca.name, ca32.name,128 ); csock =sockfd_lookup (ca.ctrl_sock, &err);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 242/249 gtp: add missing gtp_encap_disable_sock() in gtp_encap_enable()
In reply to Sasha LevinFrom: Taehee Yoo <[email protected]>
[ Upstream commit e30155fd23c9c141cbe7d99b786e10a83a328837 ]
If an invalid role is sent from user space, gtp_encap_enable() will fail. Then, it should call gtp_encap_disable_sock() but current code doesn't. It makes memory leak.
--- drivers/net/gtp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/gtp.c +6 -1
@@ -843,8 +843,13 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[])if (data[IFLA_GTP_ROLE ]) { role =nla_get_u32 (data[IFLA_GTP_ROLE ]); -if (role >GTP_ROLE_SGSN ) +if (role >GTP_ROLE_SGSN ) { +if (sk0) +gtp_encap_disable_sock (sk0); +if (sk1u) +gtp_encap_disable_sock (sk1u);return -EINVAL ; + } } gtp->sk0 = sk0;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 243/249 Bluetooth: validate BLE connection interval updates
In reply to Sasha LevinFrom: csonsino <[email protected]>
[ Upstream commit c49a8682fc5d298d44e8d911f4fa14690ea9485e ]
Problem: The Linux Bluetooth stack yields complete control over the BLE connection interval to the remote device.
The Linux Bluetooth stack provides access to the BLE connection interval min and max values through /sys/kernel/debug/bluetooth/hci0/ conn_min_interval and /sys/kernel/debug/bluetooth/hci0/conn_max_interval. These values are used for initial BLE connections, but the remote device has the ability to request a connection parameter update. In the event that the remote side requests to change the connection interval, the Linux kernel currently only validates that the desired value is within the acceptable range in the Bluetooth specification (6 - 3200, corresponding to 7.5ms - 4000ms). There is currently no validation that the desired value requested by the remote device is within the min/max limits specified in the conn_min_interval/conn_max_interval configurations. This essentially leads to Linux yielding complete control over the connection interval to the remote device.
The proposed patch adds a verification step to the connection parameter update mechanism, ensuring that the desired value is within the min/max bounds of the current connection. If the desired value is outside of the current connection min/max values, then the connection parameter update request is rejected and the negative response is returned to the remote device. Recall that the initial connection is established using the local conn_min_interval/conn_max_interval values, so this allows the Linux administrator to retain control over the BLE connection interval.
The one downside that I see is that the current default Linux values for conn_min_interval and conn_max_interval typically correspond to 30ms and 50ms respectively. If this change were accepted, then it is feasible that some devices would no longer be able to negotiate to their desired connection interval values. This might be remedied by setting the default Linux conn_min_interval and conn_max_interval values to the widest supported range (6 - 3200 / 7.5ms - 4000ms). This could lead to the same behavior as the current implementation, where the remote device could request to change the connection interval value to any value that is permitted by the Bluetooth specification, and Linux would accept the desired value.
--- net/bluetooth/hci_event.c | 5 +++++ net/bluetooth/l2cap_core.c | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
net/bluetooth/hci_event.c +5 -0
@@ -5588,6 +5588,11 @@ static void hci_le_remote_conn_param_req_evt(struct hci_dev *hdev,return send_conn_param_neg_reply (hdev, handle,HCI_ERROR_UNKNOWN_CONN_ID ); +if (min < hcon->le_conn_min_interval || + max > hcon->le_conn_max_interval) +return send_conn_param_neg_reply (hdev, handle, +HCI_ERROR_INVALID_LL_PARAMS ); +if (hci_check_conn_params (min, max, latency, timeout))return send_conn_param_neg_reply (hdev, handle,HCI_ERROR_INVALID_LL_PARAMS );
net/bluetooth/l2cap_core.c +8 -1
@@ -5297,7 +5297,14 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,memset (&rsp,0 ,sizeof (rsp)); - err =hci_check_conn_params (min, max, latency, to_multiplier); +if (min < hcon->le_conn_min_interval || + max > hcon->le_conn_max_interval) { +BT_DBG ("requested connection interval exceeds current bounds." ); + err = -EINVAL ; + }else { + err =hci_check_conn_params (min, max, latency, to_multiplier); + } +if (err) rsp.result =cpu_to_le16 (L2CAP_CONN_PARAM_REJECTED );else
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 244/249 gtp: fix suspicious RCU usage
In reply to Sasha LevinFrom: Taehee Yoo <[email protected]>
[ Upstream commit e198987e7dd7d3645a53875151cd6f8fc425b706 ]
gtp_encap_enable_socket() and gtp_encap_destroy() are not protected by rcu_read_lock(). and it's not safe to write sk->sk_user_data. This patch make these functions to use lock_sock() instead of rcu_dereference_sk_user_data().
Test commands:
gtp-link add gtp1
Splat looks like:
[ 83.238315] =============================
[ 83.239127] WARNING: suspicious RCU usage
[ 83.239702] 5.2.0-rc6+ #49 Not tainted
[ 83.240268] -----------------------------
[ 83.241205] drivers/net/gtp.c:799 suspicious rcu_dereference_check() usage!
[ 83.243828]
[ 83.243828] other info that might help us debug this:
[ 83.243828]
[ 83.246325]
[ 83.246325] rcu_scheduler_active = 2, debug_locks = 1
[ 83.247314] 1 lock held by gtp-link/1008:
[ 83.248523] #0: 0000000017772c7f (rtnl_mutex){+.+.}, at: __rtnl_newlink+0x5f5/0x11b0
[ 83.251503]
[ 83.251503] stack backtrace:
[ 83.252173] CPU: 0 PID: 1008 Comm: gtp-link Not tainted 5.2.0-rc6+ #49
[ 83.253271] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[ 83.254562] Call Trace:
[ 83.254995] dump_stack+0x7c/0xbb
[ 83.255567] gtp_encap_enable_socket+0x2df/0x360 [gtp]
[ 83.256415] ? gtp_find_dev+0x1a0/0x1a0 [gtp]
[ 83.257161] ? memset+0x1f/0x40
[ 83.257843] gtp_newlink+0x90/0xa21 [gtp]
[ 83.258497] ? __netlink_ns_capable+0xc3/0xf0
[ 83.259260] __rtnl_newlink+0xb9f/0x11b0
[ 83.260022] ? rtnl_link_unregister+0x230/0x230[ ... ]
--- drivers/net/gtp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/gtp.c +6 -2
@@ -289,12 +289,14 @@ static void gtp_encap_destroy(struct sock *sk) {struct gtp_dev *gtp; - gtp =rcu_dereference_sk_user_data (sk); +lock_sock (sk); + gtp = sk->sk_user_data;if (gtp) {udp_sk (sk)->encap_type =0 ;rcu_assign_sk_user_data (sk,NULL );sock_put (sk); } +release_sock (sk); }static void gtp_encap_disable_sock (struct sock *sk)
@@ -796,7 +798,8 @@ static struct sock *gtp_encap_enable_socket(int fd, int type, goto out_sock; } -if (rcu_dereference_sk_user_data (sock->sk)) { +lock_sock (sock->sk); +if (sock->sk->sk_user_data) { sk =ERR_PTR (-EBUSY ); goto out_sock; }
@@ -812,6 +815,7 @@ static struct sock *gtp_encap_enable_socket(int fd, int type,setup_udp_tunnel_sock (sock_net (sock->sk), sock, &tuncfg); out_sock: +release_sock (sock->sk);sockfd_put (sock);return sk; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 245/249 gtp: fix Illegal context switch in RCU read-side critical section.
In reply to Sasha LevinFrom: Taehee Yoo <[email protected]>
[ Upstream commit 3f167e1921865b379a9becf03828e7202c7b4917 ]
ipv4_pdp_add() is called in RCU read-side critical section. So GFP_KERNEL should not be used in the function.
This patch make ipv4_pdp_add() to use GFP_ATOMIC instead of GFP_KERNEL.
Test commands:
gtp-link add gtp1 &
gtp-tunnel add gtp1 v1 100 200 1.1.1.1 2.2.2.2
Splat looks like:
[ 130.618881] =============================
[ 130.626382] WARNING: suspicious RCU usage
[ 130.626994] 5.2.0-rc6+ #50 Not tainted
[ 130.627622] -----------------------------
[ 130.628223] ./include/linux/rcupdate.h:266 Illegal context switch in RCU read-side critical section!
[ 130.629684]
[ 130.629684] other info that might help us debug this:
[ 130.629684]
[ 130.631022]
[ 130.631022] rcu_scheduler_active = 2, debug_locks = 1
[ 130.632136] 4 locks held by gtp-tunnel/1025:
[ 130.632925] #0: 000000002b93c8b7 (cb_lock){++++}, at: genl_rcv+0x15/0x40
[ 130.634159] #1: 00000000f17bc999 (genl_mutex){+.+.}, at: genl_rcv_msg+0xfb/0x130
[ 130.635487] #2: 00000000c644ed8e (rtnl_mutex){+.+.}, at: gtp_genl_new_pdp+0x18c/0x1150 [gtp]
[ 130.636936] #3: 0000000007a1cde7 (rcu_read_lock){....}, at: gtp_genl_new_pdp+0x187/0x1150 [gtp]
[ 130.638348]
[ 130.638348] stack backtrace:
[ 130.639062] CPU: 1 PID: 1025 Comm: gtp-tunnel Not tainted 5.2.0-rc6+ #50
[ 130.641318] Call Trace:
[ 130.641707] dump_stack+0x7c/0xbb
[ 130.642252] ___might_sleep+0x2c0/0x3b0
[ 130.642862] kmem_cache_alloc_trace+0x1cd/0x2b0
[ 130.643591] gtp_genl_new_pdp+0x6c5/0x1150 [gtp]
[ 130.644371] genl_family_rcv_msg+0x63a/0x1030
[ 130.645074] ? mutex_lock_io_nested+0x1090/0x1090
[ 130.645845] ? genl_unregister_family+0x630/0x630
[ 130.646592] ? debug_show_all_locks+0x2d0/0x2d0
[ 130.647293] ? check_flags.part.40+0x440/0x440
[ 130.648099] genl_rcv_msg+0xa3/0x130[ ... ]
--- drivers/net/gtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/gtp.c +1 -1
@@ -954,7 +954,7 @@ static int ipv4_pdp_add(struct gtp_dev *gtp, struct sock *sk, } - pctx =kmalloc (sizeof (struct pdp_ctx ),GFP_KERNEL ); + pctx =kmalloc (sizeof (*pctx),GFP_ATOMIC );if (pctx ==NULL )return -ENOMEM ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 246/249 gtp: fix use-after-free in gtp_encap_destroy()
In reply to Sasha LevinFrom: Taehee Yoo <[email protected]>
[ Upstream commit 1788b8569f5de27da09087fa3f6580d2aa04cc75 ]
gtp_encap_destroy() is called twice.
1. When interface is deleted.
2. When udp socket is destroyed.
either gtp->sk0 or gtp->sk1u could be freed by sock_put() in gtp_encap_destroy(). so, when gtp_encap_destroy() is called again, it would uses freed sk pointer.
patch makes gtp_encap_destroy() to set either gtp->sk0 or gtp->sk1u to null. in addition, both gtp->sk0 and gtp->sk1u pointer are protected by rtnl_lock. so, rtnl_lock() is added.
Test command:
gtp-link add gtp1 &
killall gtp-link
ip link del gtp1
Splat looks like:
[ 83.182767] BUG: KASAN: use-after-free in __lock_acquire+0x3a20/0x46a0 [ 83.184128] Read of size 8 at addr ffff8880cc7d5360 by task ip/1008 [ 83.185567] CPU: 1 PID: 1008 Comm: ip Not tainted 5.2.0-rc6+ #50 [ 83.188469] Call Trace: [ ... ] [ 83.200126] lock_acquire+0x141/0x380 [ 83.200575] ? lock_sock_nested+0x3a/0xf0 [ 83.201069] _raw_spin_lock_bh+0x38/0x70 [ 83.201551] ? lock_sock_nested+0x3a/0xf0 [ 83.202044] lock_sock_nested+0x3a/0xf0 [ 83.202520] gtp_encap_destroy+0x18/0xe0 [gtp] [ 83.203065] gtp_encap_disable.isra.14+0x13/0x50 [gtp] [ 83.203687] gtp_dellink+0x56/0x170 [gtp] [ 83.204190] rtnl_delete_link+0xb4/0x100 [ ... ] [ 83.236513] Allocated by task 976: [ 83.236925] save_stack+0x19/0x80 [ 83.237332] __kasan_kmalloc.constprop.3+0xa0/0xd0 [ 83.237894] kmem_cache_alloc+0xd8/0x280 [ 83.238360] sk_prot_alloc.isra.42+0x50/0x200 [ 83.238874] sk_alloc+0x32/0x940 [ 83.239264] inet_create+0x283/0xc20 [ 83.239684] __sock_create+0x2dd/0x540 [ 83.240136] __sys_socket+0xca/0x1a0 [ 83.240550] __x64_sys_socket+0x6f/0xb0 [ 83.240998] do_syscall_64+0x9c/0x450 [ 83.241466] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 83.242061] [ 83.242249] Freed by task 0: [ 83.242616] save_stack+0x19/0x80 [ 83.243013] __kasan_slab_free+0x111/0x150 [ 83.243498] kmem_cache_free+0x89/0x250 [ 83.244444] __sk_destruct+0x38f/0x5a0 [ 83.245366] rcu_core+0x7e9/0x1c20 [ 83.245766] __do_softirq+0x213/0x8fa
--- drivers/net/gtp.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/net/gtp.c +15 -2
@@ -285,13 +285,17 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb)return gtp_rx (pctx, skb, hdrlen, gtp->role); } -static void gtp_encap_destroy (struct sock *sk) +static void __gtp_encap_destroy (struct sock *sk) {struct gtp_dev *gtp;lock_sock (sk); gtp = sk->sk_user_data;if (gtp) { +if (gtp->sk0 == sk) + gtp->sk0 =NULL ; +else + gtp->sk1u =NULL ;udp_sk (sk)->encap_type =0 ;rcu_assign_sk_user_data (sk,NULL );sock_put (sk);
@@ -299,12 +303,19 @@ static void gtp_encap_destroy(struct sock *sk)release_sock (sk); } +static void gtp_encap_destroy (struct sock *sk) +{ +rtnl_lock (); +__gtp_encap_destroy (sk); +rtnl_unlock (); +} +static void gtp_encap_disable_sock (struct sock *sk) {if (!sk)return ; -gtp_encap_destroy (sk); +__gtp_encap_destroy (sk); }static void gtp_encap_disable (struct gtp_dev *gtp)
@@ -1043,6 +1054,7 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)return -EINVAL ; } +rtnl_lock ();rcu_read_lock (); gtp =gtp_find_dev (sock_net (skb->sk), info->attrs);
@@ -1067,6 +1079,7 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info) out_unlock:rcu_read_unlock (); +rtnl_unlock ();return err; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 247/249 gtp: fix use-after-free in gtp_newlink()
In reply to Sasha LevinFrom: Taehee Yoo <[email protected]>
[ Upstream commit a2bed90704c68d3763bf24decb1b781a45395de8 ]
Current gtp_newlink() could be called after unregister_pernet_subsys(). gtp_newlink() uses gtp_net but it can be destroyed by unregister_pernet_subsys().
So unregister_pernet_subsys() should be called after rtnl_link_unregister().
Test commands:
#SHELL 1
while :
do
for i in {1..5}
do
./gtp-link add gtp$i &
done
killall gtp-linkdone
#SHELL 2
while :
do
modprobe -rv gtp
done
Splat looks like:
[ 753.176631] BUG: KASAN: use-after-free in gtp_newlink+0x9b4/0xa5c [gtp] [ 753.177722] Read of size 8 at addr ffff8880d48f2458 by task gtp-link/7126 [ 753.179082] CPU: 0 PID: 7126 Comm: gtp-link Tainted: G W 5.2.0-rc6+ #50 [ 753.185801] Call Trace: [ 753.186264] dump_stack+0x7c/0xbb [ 753.186863] ? gtp_newlink+0x9b4/0xa5c [gtp] [ 753.187583] print_address_description+0xc7/0x240 [ 753.188382] ? gtp_newlink+0x9b4/0xa5c [gtp] [ 753.189097] ? gtp_newlink+0x9b4/0xa5c [gtp] [ 753.189846] __kasan_report+0x12a/0x16f [ 753.190542] ? gtp_newlink+0x9b4/0xa5c [gtp] [ 753.191298] kasan_report+0xe/0x20 [ 753.191893] gtp_newlink+0x9b4/0xa5c [gtp] [ 753.192580] ? __netlink_ns_capable+0xc3/0xf0 [ 753.193370] __rtnl_newlink+0xb9f/0x11b0 [ ... ] [ 753.241201] Allocated by task 7186: [ 753.241844] save_stack+0x19/0x80 [ 753.242399] __kasan_kmalloc.constprop.3+0xa0/0xd0 [ 753.243192] __kmalloc+0x13e/0x300 [ 753.243764] ops_init+0xd6/0x350 [ 753.244314] register_pernet_operations+0x249/0x6f0 [ ... ] [ 753.251770] Freed by task 7178: [ 753.252288] save_stack+0x19/0x80 [ 753.252833] __kasan_slab_free+0x111/0x150 [ 753.253962] kfree+0xc7/0x280 [ 753.254509] ops_free_list.part.11+0x1c4/0x2d0 [ 753.255241] unregister_pernet_operations+0x262/0x390 [ ... ] [ 753.285883] list_add corruption. next->prev should be prev (ffff8880d48f2458), but was ffff8880d497d878. (next. [ 753.287241] ------------[ cut here ]------------ [ 753.287794] kernel BUG at lib/list_debug.c:25! [ 753.288364] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI [ 753.289099] CPU: 0 PID: 7126 Comm: gtp-link Tainted: G B W 5.2.0-rc6+ #50 [ 753.291036] RIP: 0010:__list_add_valid+0x74/0xd0 [ 753.291589] Code: 48 39 da 75 27 48 39 f5 74 36 48 39 dd 74 31 48 83 c4 08 b8 01 00 00 00 5b 5d c3 48 89 d9 48b [ 753.293779] RSP: 0018:ffff8880cae8f398 EFLAGS: 00010286 [ 753.294401] RAX: 0000000000000075 RBX: ffff8880d497d878 RCX: 0000000000000000 [ 753.296260] RDX: 0000000000000075 RSI: 0000000000000008 RDI: ffffed10195d1e69 [ 753.297070] RBP: ffff8880cd250ae0 R08: ffffed101b4bff21 R09: ffffed101b4bff21 [ 753.297899] R10: 0000000000000001 R11: ffffed101b4bff20 R12: ffff8880d497d878 [ 753.298703] R13: 0000000000000000 R14: ffff8880cd250ae0 R15: ffff8880d48f2458 [ 753.299564] FS: 00007f5f79805740(0000) GS:ffff8880da400000(0000) knlGS:0000000000000000 [ 753.300533] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 753.301231] CR2: 00007fe8c7ef4f10 CR3: 00000000b71a6006 CR4: 00000000000606f0 [ 753.302183] Call Trace: [ 753.302530] gtp_newlink+0x5f6/0xa5c [gtp] [ 753.303037] ? __netlink_ns_capable+0xc3/0xf0 [ 753.303576] __rtnl_newlink+0xb9f/0x11b0 [ 753.304092] ? rtnl_link_unregister+0x230/0x230
--- drivers/net/gtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/gtp.c +1 -1
@@ -1382,9 +1382,9 @@ late_initcall(gtp_init); static void __exit gtp_fini(void) { -unregister_pernet_subsys (>p_net_ops);genl_unregister_family (>p_genl_family);rtnl_link_unregister (>p_link_ops); +unregister_pernet_subsys (>p_net_ops);pr_info ("GTP module unloaded\n" ); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 248/249 xdp: fix race on generic receive path
In reply to Sasha LevinFrom: Ilya Maximets <[email protected]>
[ Upstream commit bf0bdd1343efbbf65b4d53aef1fce14acbd79d50 ]
Unlike driver mode, generic xdp receive could be triggered by different threads on different CPU cores at the same time leading to the fill and rx queue breakage. For example, this could happen while sending packets from two processes to the first interface of veth pair while the second part of it is open with AF_XDP socket.
Need to take a lock for each generic receive to avoid race.
--- include/net/xdp_sock.h | 2 ++ net/xdp/xsk.c | 31 ++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-)
include/net/xdp_sock.h +2 -0
@@ -67,6 +67,8 @@ struct xdp_sock {* in the SKB destructor callback. */ spinlock_t tx_completion_lock; +/* Protects generic receive. */ +spinlock_t rx_lock;u64 rx_dropped; };
net/xdp/xsk.c +22 -9
@@ -123,13 +123,17 @@ int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)u64 addr;int err; -if (xs->dev != xdp->rxq->dev || xs->queue_id != xdp->rxq->queue_index) -return -EINVAL ; +spin_lock_bh (&xs->rx_lock); + +if (xs->dev != xdp->rxq->dev || xs->queue_id != xdp->rxq->queue_index) { + err = -EINVAL ; + goto out_unlock; + }if (!xskq_peek_addr (xs->umem->fq, &addr) || len > xs->umem->chunk_size_nohr -XDP_PACKET_HEADROOM ) { - xs->rx_dropped++; -return -ENOSPC ; + err = -ENOSPC ; + goto out_drop; } addr += xs->umem->headroom;
@@ -138,13 +142,21 @@ int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)memcpy (buffer, xdp->data_meta, len + metalen); addr += metalen; err =xskq_produce_batch_desc (xs->rx, addr, len); -if (!err) { -xskq_discard_addr (xs->umem->fq); -xsk_flush (xs); -return 0 ; - } +if (err) + goto out_drop; + +xskq_discard_addr (xs->umem->fq); +xskq_produce_flush_desc (xs->rx); +spin_unlock_bh (&xs->rx_lock); + + xs->sk.sk_data_ready (&xs->sk); +return 0 ; + +out_drop: xs->rx_dropped++; +out_unlock: +spin_unlock_bh (&xs->rx_lock);return err; }
@@ -765,6 +777,7 @@ static int xsk_create(struct net *net, struct socket *sock, int protocol, xs =xdp_sk (sk);mutex_init (&xs->mutex); +spin_lock_init (&xs->rx_lock);spin_lock_init (&xs->tx_completion_lock);mutex_lock (&net->xdp.lock);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 249/249 net: mvmdio: defer probe of orion-mdio if a clock is not ready
In reply to Sasha LevinFrom: Josua Mayer <[email protected]>
[ Upstream commit 433a06d7d74e677c40b1148c70c48677ff62fb6b ]
Defer probing of the orion-mdio interface when getting a clock returns EPROBE_DEFER. This avoids locking up the Armada 8k SoC when mdio is used before all clocks have been enabled.
--- drivers/net/ethernet/marvell/mvmdio.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/marvell/mvmdio.c +5 -0
@@ -321,6 +321,10 @@ static int orion_mdio_probe(struct platform_device *pdev)for (i =0 ; i <ARRAY_SIZE (dev->clk); i++) { dev->clk[i] =of_clk_get (pdev->dev.of_node, i); +if (PTR_ERR (dev->clk[i]) == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto out_clk; + }if (IS_ERR (dev->clk[i]))break ;clk_prepare_enable (dev->clk[i]);
@@ -362,6 +366,7 @@ static int orion_mdio_probe(struct platform_device *pdev)if (dev->err_interrupt >0 )writel (0 , dev->regs +MVMDIO_ERR_INT_MASK ); +out_clk:for (i =0 ; i <ARRAY_SIZE (dev->clk); i++) {if (IS_ERR (dev->clk[i]))break ;
Signature · 1 line
2.20.1