selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh
Subsystems (9)
Sasha Levin
maintainerPATCH 1/13 selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh
From: "Alessandro Carminati (Red Hat)" <[email protected]>
[ Upstream commit f803bcf9208a2540acb4c32bdc3616673169f490 ]
In some systems, the netcat server can incur in delay to start listening. When this happens, the test can randomly fail in various points. This is an example error message:
# ip gre none gso # encap 192.168.1.1 to 192.168.1.2, type gre, mac none len 2000 # test basic connectivity # Ncat: Connection refused.
The issue stems from a race condition between the netcat client and server. The test author had addressed this problem by implementing a sleep, which I have removed in this patch.
This patch introduces a function capable of sleeping for up to two seconds. However, it can terminate the waiting period early if the port is reported to be listening.
--- tools/testing/selftests/bpf/test_tc_tunnel.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/test_tc_tunnel.sh +12 -1
@@ -71,7 +71,6 @@ cleanup() { server_listen() { ip netns exec "${ns2}" nc "${netcat_opt}" -l -p "${port}" > "${outfile}" & server_pid=$! - sleep 0.2 } client_connect() {
@@ -92,6 +91,16 @@ verify_data() { fi } +wait_for_port() { + for i in $(seq 20); do + if ip netns exec "${ns2}" ss ${2:--4}OHntl | grep -q "$1"; then + return 0 + fi + sleep 0.1 + done + return 1 +} + set -e # no arguments: automated test, run all
@@ -183,6 +192,7 @@ setup # basic communication works echo "test basic connectivity" server_listen +wait_for_port ${port} ${netcat_opt} client_connect verify_data
@@ -194,6 +204,7 @@ ip netns exec "${ns1}" tc filter add dev veth1 egress \ section "encap_${tuntype}_${mac}" echo "test bpf encap without decap (expect failure)" server_listen +wait_for_port ${port} ${netcat_opt} ! client_connect if [[ "$tuntype" =~ "udp" ]]; then
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/13 selftests/bpf: Fix flaky test btf_map_in_map/lookup_update
From: Yonghong Song <[email protected]>
[ Upstream commit 14bb1e8c8d4ad5d9d2febb7d19c70a3cf536e1e5 ]
Recently, I frequently hit the following test failure:
[root@arch-fb-vm1 bpf]# ./test_progs -n 33/1 test_lookup_update:PASS:skel_open 0 nsec [...]
test_lookup_update:PASS:sync_rcu 0 nsec test_lookup_update:FAIL:map1_leak inner_map1 leaked!
#33/1 btf_map_in_map/lookup_update:FAIL
#33 btf_map_in_map:FAIL
In the test, after map is closed and then after two rcu grace periods, it is assumed that map_id is not available to user space.
But the above assumption cannot be guaranteed. After zero or one or two rcu grace periods in different siturations, the actual freeing-map-work is put into a workqueue. Later on, when the work is dequeued, the map will be actually freed.
See bpf_map_put() in kernel/bpf/syscall.c.
By using workqueue, there is no ganrantee that map will be actually freed after a couple of rcu grace periods. This patch removed such map leak detection and then the test can pass consistently.
--- .../selftests/bpf/prog_tests/btf_map_in_map.c | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-)
tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c +1 -25
@@ -58,7 +58,7 @@ static void test_lookup_update(void)int map1_fd, map2_fd, map3_fd, map4_fd, map5_fd, map1_id, map2_id;int outer_arr_fd, outer_hash_fd, outer_arr_dyn_fd;struct test_btf_map_in_map *skel; -int err, key =0 , val, i, fd; +int err, key =0 , val, i; skel =test_btf_map_in_map__open_and_load ();if (CHECK (!skel,"skel_open" ,"failed to open&load skeleton\n" ))
@@ -135,30 +135,6 @@ static void test_lookup_update(void)CHECK (map1_id ==0 ,"map1_id" ,"failed to get ID 1\n" );CHECK (map2_id ==0 ,"map2_id" ,"failed to get ID 2\n" ); -test_btf_map_in_map__destroy (skel); - skel =NULL ; - -/* we need to either wait for or force synchronize_rcu(), before -* checking for "still exists" condition, otherwise map could still be -* resolvable by ID, causing false positives. -* -* Older kernels (5.8 and earlier) freed map only after two -* synchronize_rcu()s, so trigger two, to be entirely sure. -*/ -CHECK (kern_sync_rcu (),"sync_rcu" ,"failed\n" ); -CHECK (kern_sync_rcu (),"sync_rcu" ,"failed\n" ); - - fd =bpf_map_get_fd_by_id (map1_id); -if (CHECK (fd >=0 ,"map1_leak" ,"inner_map1 leaked!\n" )) { -close (fd); - goto cleanup; - } - fd =bpf_map_get_fd_by_id (map2_id); -if (CHECK (fd >=0 ,"map2_leak" ,"inner_map2 leaked!\n" )) { -close (fd); - goto cleanup; - } - cleanup:test_btf_map_in_map__destroy (skel); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/13 batman-adv: bypass empty buckets in batadv_purge_orig_ref()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 40dc8ab605894acae1473e434944924a22cfaaa0 ]
Many syzbot reports are pointing to soft lockups in batadv_purge_orig_ref() [1]
Root cause is unknown, but we can avoid spending too much time there and perhaps get more interesting reports.
[1]
watchdog: BUG: soft lockup - CPU#0 stuck for 27s! [kworker/u4:6:621] Modules linked in: irq event stamp: 6182794 hardirqs last enabled at (6182793): [<ffff8000801dae10>] __local_bh_enable_ip+0x224/0x44c kernel/softirq.c:386 hardirqs last disabled at (6182794): [<ffff80008ad66a78>] __el1_irq arch/arm64/kernel/entry-common.c:533 [inline] hardirqs last disabled at (6182794): [<ffff80008ad66a78>] el1_interrupt+0x24/0x68 arch/arm64/kernel/entry-common.c:551 softirqs last enabled at (6182792): [<ffff80008aab71c4>] spin_unlock_bh include/linux/spinlock.h:396 [inline] softirqs last enabled at (6182792): [<ffff80008aab71c4>] batadv_purge_orig_ref+0x114c/0x1228 net/batman-adv/originator.c:1287 softirqs last disabled at (6182790): [<ffff80008aab61dc>] spin_lock_bh include/linux/spinlock.h:356 [inline] softirqs last disabled at (6182790): [<ffff80008aab61dc>] batadv_purge_orig_ref+0x164/0x1228 net/batman-adv/originator.c:1271 CPU: 0 PID: 621 Comm: kworker/u4:6 Not tainted 6.8.0-rc7-syzkaller-g707081b61156 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024 Workqueue: bat_events batadv_purge_orig pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : should_resched arch/arm64/include/asm/preempt.h:79 [inline] pc : __local_bh_enable_ip+0x228/0x44c kernel/softirq.c:388 lr : __local_bh_enable_ip+0x224/0x44c kernel/softirq.c:386
sp : ffff800099007970
x29: ffff800099007980 x28: 1fffe00018fce1bd x27: dfff800000000000
x26: ffff0000d2620008 x25: ffff0000c7e70de8 x24: 0000000000000001
x23: 1fffe00018e57781 x22: dfff800000000000 x21: ffff80008aab71c4
x20: ffff0001b40136c0 x19: ffff0000c72bbc08 x18: 1fffe0001a817bb0
x17: ffff800125414000 x16: ffff80008032116c x15: 0000000000000001
x14: 1fffe0001ee9d610 x13: 0000000000000000 x12: 0000000000000003
x11: 0000000000000000 x10: 0000000000ff0100 x9 : 0000000000000000 x8 : 00000000005e5789 x7 : ffff80008aab61dc x6 : 0000000000000000 x5 : 0000000000000000 x4 : 0000000000000001 x3 : 0000000000000000 x2 : 0000000000000006 x1 : 0000000000000080 x0 : ffff800125414000
Call trace: __daif_local_irq_enable arch/arm64/include/asm/irqflags.h:27 [inline] arch_local_irq_enable arch/arm64/include/asm/irqflags.h:49 [inline] __local_bh_enable_ip+0x228/0x44c kernel/softirq.c:386 __raw_spin_unlock_bh include/linux/spinlock_api_smp.h:167 [inline] _raw_spin_unlock_bh+0x3c/0x4c kernel/locking/spinlock.c:210 spin_unlock_bh include/linux/spinlock.h:396 [inline] batadv_purge_orig_ref+0x114c/0x1228 net/batman-adv/originator.c:1287 batadv_purge_orig+0x20/0x70 net/batman-adv/originator.c:1300 process_one_work+0x694/0x1204 kernel/workqueue.c:2633 process_scheduled_works kernel/workqueue.c:2706 [inline] worker_thread+0x938/0xef4 kernel/workqueue.c:2787 kthread+0x288/0x310 kernel/kthread.c:388 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860 Sending NMI from CPU 0 to CPUs 1: NMI backtrace for cpu 1 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.8.0-rc7-syzkaller-g707081b61156 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024 pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : arch_local_irq_enable+0x8/0xc arch/arm64/include/asm/irqflags.h:51 lr : default_idle_call+0xf8/0x128 kernel/sched/idle.c:103
sp : ffff800093a17d30
x29: ffff800093a17d30 x28: dfff800000000000 x27: 1ffff00012742fb4
x26: ffff80008ec9d000 x25: 0000000000000000 x24: 0000000000000002
x23: 1ffff00011d93a74 x22: ffff80008ec9d3a0 x21: 0000000000000000
x20: ffff0000c19dbc00 x19: ffff8000802d0fd8 x18: 1fffe00036804396
x17: ffff80008ec9d000 x16: ffff8000802d089c x15: 0000000000000001
x14: 1fffe00036805f10 x13: 0000000000000000 x12: 0000000000000003
x11: 0000000000000001 x10: 0000000000000003 x9 : 0000000000000000 x8 : 00000000000ce8d1 x7 : ffff8000804609e4 x6 : 0000000000000000 x5 : 0000000000000001 x4 : 0000000000000001 x3 : ffff80008ad6aac0 x2 : 0000000000000000 x1 : ffff80008aedea60 x0 : ffff800125436000
Call trace: __daif_local_irq_enable arch/arm64/include/asm/irqflags.h:27 [inline] arch_local_irq_enable+0x8/0xc arch/arm64/include/asm/irqflags.h:49 cpuidle_idle_call kernel/sched/idle.c:170 [inline] do_idle+0x1f0/0x4e8 kernel/sched/idle.c:312 cpu_startup_entry+0x5c/0x74 kernel/sched/idle.c:410 secondary_start_kernel+0x198/0x1c0 arch/arm64/kernel/smp.c:272 __secondary_switched+0xb8/0xbc arch/arm64/kernel/head.S:404
--- net/batman-adv/originator.c | 2 ++ 1 file changed, 2 insertions(+)
net/batman-adv/originator.c +2 -0
@@ -1285,6 +1285,8 @@ void batadv_purge_orig_ref(struct batadv_priv *bat_priv)/* for all origins... */ for (i =0 ; i < hash->size; i++) { head = &hash->table[i]; +if (hlist_empty (head)) +continue ; list_lock = &hash->list_locks[i];spin_lock_bh (list_lock);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/13 wifi: ath9k: work around memset overflow warning
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 61752ac69b69ed2e04444d090f6917c77ab36d42 ]
gcc-9 and some other older versions produce a false-positive warning for zeroing two fields
In file included from include/linux/string.h:369,
from drivers/net/wireless/ath/ath9k/main.c:18:
In function 'fortify_memset_chk',
inlined from 'ath9k_ps_wakeup' at drivers/net/wireless/ath/ath9k/main.c:140:3:include/linux/fortify-string.h:462:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
462 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Using a struct_group seems to reliably avoid the warning and not make the code much uglier. The combined memset() should even save a couple of cpu cycles.
--- drivers/net/wireless/ath/ath.h | 6 ++++-- drivers/net/wireless/ath/ath9k/main.c | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath.h +4 -2
@@ -171,8 +171,10 @@ struct ath_common {unsigned int clockrate;spinlock_t cc_lock; -struct ath_cycle_counters cc_ani; -struct ath_cycle_counters cc_survey; +struct_group (cc, + struct ath_cycle_counters cc_ani; + struct ath_cycle_counters cc_survey; + );struct ath_regulatory regulatory;struct ath_regulatory reg_world_copy;
drivers/net/wireless/ath/ath9k/main.c +1 -2
@@ -135,8 +135,7 @@ void ath9k_ps_wakeup(struct ath_softc *sc)if (power_mode !=ATH9K_PM_AWAKE ) {spin_lock (&common->cc_lock);ath_hw_cycle_counters_update (common); -memset (&common->cc_survey,0 ,sizeof (common->cc_survey)); -memset (&common->cc_ani,0 ,sizeof (common->cc_ani)); +memset (&common->cc,0 ,sizeof (common->cc));spin_unlock (&common->cc_lock); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/13 af_packet: avoid a false positive warning in packet_setsockopt()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 86d43e2bf93ccac88ef71cee36a23282ebd9e427 ]
Although the code is correct, the following line
copy_from_sockptr(&req_u.req, optval, len));
triggers this warning :
memcpy: detected field-spanning write (size 28) of single field "dst" at include/linux/sockptr.h:49 (size 16)
Refactor the code to be more explicit.
--- net/packet/af_packet.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
net/packet/af_packet.c +14 -12
@@ -3762,28 +3762,30 @@ packet_setsockopt(struct socket *sock, int level, int optname, sockptr_t optval,case PACKET_TX_RING : {union tpacket_req_u req_u; -int len; + ret = -EINVAL ;lock_sock (sk);switch (po->tp_version) {case TPACKET_V1 :case TPACKET_V2 : - len =sizeof (req_u.req); +if (optlen <sizeof (req_u.req)) +break ; + ret =copy_from_sockptr (&req_u.req, optval, +sizeof (req_u.req)) ? + -EINVAL :0 ;break ;case TPACKET_V3 :default : - len =sizeof (req_u.req3); +if (optlen <sizeof (req_u.req3)) +break ; + ret =copy_from_sockptr (&req_u.req3, optval, +sizeof (req_u.req3)) ? + -EINVAL :0 ;break ; } -if (optlen < len) { - ret = -EINVAL ; - }else { -if (copy_from_sockptr (&req_u.req, optval, len)) - ret = -EFAULT ; -else - ret =packet_set_ring (sk, &req_u,0 , - optname ==PACKET_TX_RING ); - } +if (!ret) + ret =packet_set_ring (sk, &req_u,0 , + optname ==PACKET_TX_RING );release_sock (sk);return ret; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/13 drop_monitor: replace spin_lock by raw_spin_lock
In reply to Sasha LevinFrom: Wander Lairson Costa <[email protected]>
[ Upstream commit f1e197a665c2148ebc25fe09c53689e60afea195 ]
trace_drop_common() is called with preemption disabled, and it acquires a spin_lock. This is problematic for RT kernels because spin_locks are sleeping locks in this configuration, which causes the following splat:
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 449, name: rcuc/47preempt_count: 1, expected: 0
RCU nest depth: 2, expected: 2
5 locks held by rcuc/47/449:
#0: ff1100086ec30a60 ((softirq_ctrl.lock)){+.+.}-{2:2}, at: __local_bh_disable_ip+0x105/0x210 #1: ffffffffb394a280 (rcu_read_lock){....}-{1:2}, at: rt_spin_lock+0xbf/0x130 #2: ffffffffb394a280 (rcu_read_lock){....}-{1:2}, at: __local_bh_disable_ip+0x11c/0x210 #3: ffffffffb394a160 (rcu_callback){....}-{0:0}, at: rcu_do_batch+0x360/0xc70 #4: ff1100086ee07520 (&data->lock){+.+.}-{2:2}, at: trace_drop_common.constprop.0+0xb5/0x290
irq event stamp: 139909 hardirqs last enabled at (139908): [<ffffffffb1df2b33>] _raw_spin_unlock_irqrestore+0x63/0x80 hardirqs last disabled at (139909): [<ffffffffb19bd03d>] trace_drop_common.constprop.0+0x26d/0x290 softirqs last enabled at (139892): [<ffffffffb07a1083>] __local_bh_enable_ip+0x103/0x170 softirqs last disabled at (139898): [<ffffffffb0909b33>] rcu_cpu_kthread+0x93/0x1f0 Preemption disabled at: [<ffffffffb1de786b>] rt_mutex_slowunlock+0xab/0x2e0 CPU: 47 PID: 449 Comm: rcuc/47 Not tainted 6.9.0-rc2-rt1+ #7 Hardware name: Dell Inc. PowerEdge R650/0Y2G81, BIOS 1.6.5 04/15/2022 Call Trace: <TASK> dump_stack_lvl+0x8c/0xd0 dump_stack+0x14/0x20 __might_resched+0x21e/0x2f0 rt_spin_lock+0x5e/0x130 ? trace_drop_common.constprop.0+0xb5/0x290 ? skb_queue_purge_reason.part.0+0x1bf/0x230 trace_drop_common.constprop.0+0xb5/0x290 ? preempt_count_sub+0x1c/0xd0 ? _raw_spin_unlock_irqrestore+0x4a/0x80 ? __pfx_trace_drop_common.constprop.0+0x10/0x10 ? rt_mutex_slowunlock+0x26a/0x2e0 ? skb_queue_purge_reason.part.0+0x1bf/0x230 ? __pfx_rt_mutex_slowunlock+0x10/0x10 ? skb_queue_purge_reason.part.0+0x1bf/0x230 trace_kfree_skb_hit+0x15/0x20 trace_kfree_skb+0xe9/0x150 kfree_skb_reason+0x7b/0x110 skb_queue_purge_reason.part.0+0x1bf/0x230 ? __pfx_skb_queue_purge_reason.part.0+0x10/0x10 ? mark_lock.part.0+0x8a/0x520
...
trace_drop_common() also disables interrupts, but this is a minor issue because we could easily replace it with a local_lock.
Replace the spin_lock with raw_spin_lock to avoid sleeping in atomic context.
--- net/core/drop_monitor.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
net/core/drop_monitor.c +10 -10
@@ -73,7 +73,7 @@ struct net_dm_hw_entries { };struct per_cpu_dm_data { -spinlock_t lock;/* Protects 'skb', 'hw_entries' and +raw_spinlock_t lock;/* Protects 'skb', 'hw_entries' and * 'send_timer' */ union {
@@ -168,9 +168,9 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data) err:mod_timer (&data->send_timer, jiffies +HZ /10 ); out: -spin_lock_irqsave (&data->lock, flags); +raw_spin_lock_irqsave (&data->lock, flags);swap (data->skb, skb); -spin_unlock_irqrestore (&data->lock, flags); +raw_spin_unlock_irqrestore (&data->lock, flags);if (skb) {struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
@@ -225,7 +225,7 @@ static void trace_drop_common(struct sk_buff *skb, void *location)local_irq_save (flags); data =this_cpu_ptr (&dm_cpu_data); -spin_lock (&data->lock); +raw_spin_lock (&data->lock); dskb = data->skb;if (!dskb)
@@ -259,7 +259,7 @@ static void trace_drop_common(struct sk_buff *skb, void *location) } out: -spin_unlock_irqrestore (&data->lock, flags); +raw_spin_unlock_irqrestore (&data->lock, flags); }static void trace_kfree_skb_hit (void *ignore,struct sk_buff *skb,void *location)
@@ -318,9 +318,9 @@ net_dm_hw_reset_per_cpu_data(struct per_cpu_dm_data *hw_data)mod_timer (&hw_data->send_timer, jiffies +HZ /10 ); } -spin_lock_irqsave (&hw_data->lock, flags); +raw_spin_lock_irqsave (&hw_data->lock, flags);swap (hw_data->hw_entries, hw_entries); -spin_unlock_irqrestore (&hw_data->lock, flags); +raw_spin_unlock_irqrestore (&hw_data->lock, flags);return hw_entries; }
@@ -452,7 +452,7 @@ net_dm_hw_trap_summary_probe(void *ignore, const struct devlink *devlink,return ; hw_data =this_cpu_ptr (&dm_hw_cpu_data); -spin_lock_irqsave (&hw_data->lock, flags); +raw_spin_lock_irqsave (&hw_data->lock, flags); hw_entries = hw_data->hw_entries;if (!hw_entries)
@@ -481,7 +481,7 @@ net_dm_hw_trap_summary_probe(void *ignore, const struct devlink *devlink, } out: -spin_unlock_irqrestore (&hw_data->lock, flags); +raw_spin_unlock_irqrestore (&hw_data->lock, flags); }static const struct net_dm_alert_ops net_dm_alert_summary_ops = {
@@ -1669,7 +1669,7 @@ static struct notifier_block dropmon_net_notifier = {static void __net_dm_cpu_data_init (struct per_cpu_dm_data *data) { -spin_lock_init (&data->lock); +raw_spin_lock_init (&data->lock);skb_queue_head_init (&data->drop_queue);u64_stats_init (&data->stats.syncp); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/13 scsi: qedi: Fix crash while reading debugfs attribute
In reply to Sasha LevinFrom: Manish Rangankar <[email protected]>
[ Upstream commit 28027ec8e32ecbadcd67623edb290dad61e735b5 ]
The qedi_dbg_do_not_recover_cmd_read() function invokes sprintf() directly on a __user pointer, which results into the crash.
To fix this issue, use a small local stack buffer for sprintf() and then call simple_read_from_buffer(), which in turns make the copy_to_user() call.
BUG: unable to handle page fault for address: 00007f4801111000 PGD 8000000864df6067 P4D 8000000864df6067 PUD 864df7067 PMD 846028067 PTE 0 Oops: 0002 [#1] PREEMPT SMP PTI Hardware name: HPE ProLiant DL380 Gen10/ProLiant DL380 Gen10, BIOS U30 06/15/2023 RIP: 0010:memcpy_orig+0xcd/0x130 RSP: 0018:ffffb7a18c3ffc40 EFLAGS: 00010202 RAX: 00007f4801111000 RBX: 00007f4801111000 RCX: 000000000000000f RDX: 000000000000000f RSI: ffffffffc0bfd7a0 RDI: 00007f4801111000 RBP: ffffffffc0bfd7a0 R08: 725f746f6e5f6f64 R09: 3d7265766f636572 R10: ffffb7a18c3ffd08 R11: 0000000000000000 R12: 00007f4881110fff R13: 000000007fffffff R14: ffffb7a18c3ffca0 R15: ffffffffc0bfd7af FS: 00007f480118a740(0000) GS:ffff98e38af00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f4801111000 CR3: 0000000864b8e001 CR4: 00000000007706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: <TASK> ? __die_body+0x1a/0x60 ? page_fault_oops+0x183/0x510 ? exc_page_fault+0x69/0x150 ? asm_exc_page_fault+0x22/0x30 ? memcpy_orig+0xcd/0x130 vsnprintf+0x102/0x4c0 sprintf+0x51/0x80 qedi_dbg_do_not_recover_cmd_read+0x2f/0x50 [qedi 6bcfdeeecdea037da47069eca2ba717c84a77324] full_proxy_read+0x50/0x80 vfs_read+0xa5/0x2e0 ? folio_add_new_anon_rmap+0x44/0xa0 ? set_pte_at+0x15/0x30 ? do_pte_missing+0x426/0x7f0 ksys_read+0xa5/0xe0 do_syscall_64+0x58/0x80 ? __count_memcg_events+0x46/0x90 ? count_memcg_event_mm+0x3d/0x60 ? handle_mm_fault+0x196/0x2f0 ? do_user_addr_fault+0x267/0x890 ? exc_page_fault+0x69/0x150 entry_SYSCALL_64_after_hwframe+0x72/0xdc RIP: 0033:0x7f4800f20b4d
--- drivers/scsi/qedi/qedi_debugfs.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/scsi/qedi/qedi_debugfs.c +4 -8
@@ -120,15 +120,11 @@ static ssize_t qedi_dbg_do_not_recover_cmd_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos) { - size_t cnt = 0; - -if (*ppos) -return 0 ; + char buf[64]; +int len; - cnt =sprintf (buffer,"do_not_recover=%d\n" , qedi_do_not_recover); - cnt =min_t (int, count, cnt - *ppos); - *ppos += cnt; -return cnt; + len =sprintf (buf,"do_not_recover=%d\n" , qedi_do_not_recover); +return simple_read_from_buffer (buffer, count, ppos, buf, len); } static int
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 8/13 kselftest: arm64: Add a null pointer check
In reply to Sasha LevinFrom: Kunwu Chan <[email protected]>
[ Upstream commit 80164282b3620a3cb73de6ffda5592743e448d0e ]
There is a 'malloc' call, which can be unsuccessful. This patch will add the malloc failure checking
to avoid possible null dereference and give more information about test fail reasons.
--- tools/testing/selftests/arm64/tags/tags_test.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/arm64/tags/tags_test.c +4 -0
@@ -6,6 +6,7 @@#include <stdint.h> #include <sys/prctl.h> #include <sys/utsname.h> +#include "../../kselftest.h" #define SHIFT_TAG (tag) ((uint64_t)(tag) << 56)#define SET_TAG (ptr, tag) (((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \
@@ -21,6 +22,9 @@ int main(void)if (prctl (PR_SET_TAGGED_ADDR_CTRL ,PR_TAGGED_ADDR_ENABLE ,0 ,0 ,0 ) ==0 ) tbi_enabled =1 ; ptr = (struct utsname *)malloc (sizeof (*ptr)); +if (!ptr) +ksft_exit_fail_msg ("Failed to allocate utsname buffer\n" ); +if (tbi_enabled) tag =0x42 ; ptr = (struct utsname *)SET_TAG (ptr, tag);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 9/13 netpoll: Fix race condition in netpoll_owner_active
In reply to Sasha LevinFrom: Breno Leitao <[email protected]>
[ Upstream commit c2e6a872bde9912f1a7579639c5ca3adf1003916 ]
KCSAN detected a race condition in netpoll:
BUG: KCSAN: data-race in net_rx_action / netpoll_send_skb write (marked) to 0xffff8881164168b0 of 4 bytes by interrupt on cpu 10: net_rx_action (./include/linux/netpoll.h:90 net/core/dev.c:6712 net/core/dev.c:6822) <snip> read to 0xffff8881164168b0 of 4 bytes by task 1 on cpu 2: netpoll_send_skb (net/core/netpoll.c:319 net/core/netpoll.c:345 net/core/netpoll.c:393) netpoll_send_udp (net/core/netpoll.c:?) <snip> value changed: 0x0000000a -> 0xffffffff
This happens because netpoll_owner_active() needs to check if the current CPU is the owner of the lock, touching napi->poll_owner non atomically. The ->poll_owner field contains the current CPU holding the lock.
Use an atomic read to check if the poll owner is the current CPU.
--- net/core/netpoll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/netpoll.c +1 -1
@@ -316,7 +316,7 @@ static int netpoll_owner_active(struct net_device *dev)struct napi_struct *napi;list_for_each_entry_rcu (napi, &dev->napi_list, dev_list) { -if (napi->poll_owner ==smp_processor_id ()) +if (READ_ONCE (napi->poll_owner) ==smp_processor_id ())return 1 ; }return 0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 10/13 HID: Add quirk for Logitech Casa touchpad
In reply to Sasha LevinFrom: Sean O'Brien <[email protected]>
[ Upstream commit dd2c345a94cfa3873cc20db87387ee509c345c1b ]
This device sometimes doesn't send touch release signals when moving from >=4 fingers to <4 fingers. Using MT_QUIRK_NOT_SEEN_MEANS_UP instead of MT_QUIRK_ALWAYS_VALID makes sure that no touches become stuck.
MT_QUIRK_FORCE_MULTI_INPUT is not necessary for this device, but does no harm.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-multitouch.c | 6 ++++++ 2 files changed, 7 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -765,6 +765,7 @@#define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e#define USB_DEVICE_ID_LOGITECH_T651 0xb00c#define USB_DEVICE_ID_LOGITECH_DINOVO_EDGE_KBD 0xb309 +#define USB_DEVICE_ID_LOGITECH_CASA_TOUCHPAD 0xbb00#define USB_DEVICE_ID_LOGITECH_C007 0xc007#define USB_DEVICE_ID_LOGITECH_C077 0xc077#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101
drivers/hid/hid-multitouch.c +6 -0
@@ -1998,6 +1998,12 @@ static const struct hid_device_id mt_devices[] = { USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X12_TAB) }, +/* Logitech devices */ + { .driver_data = MT_CLS_NSMU, +HID_DEVICE (BUS_BLUETOOTH ,HID_GROUP_MULTITOUCH_WIN_8 , +USB_VENDOR_ID_LOGITECH , + USB_DEVICE_ID_LOGITECH_CASA_TOUCHPAD) }, + /* MosArt panels */ { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, MT_USB_DEVICE(USB_VENDOR_ID_ASUS,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 11/13 ACPI: video: Add backlight=native quirk for Lenovo Slim 7 16ARH7
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit c901f63dc142c48326931f164f787dfff69273d9 ]
Lenovo Slim 7 16ARH7 is a machine with switchable graphics between AMD and Nvidia, and the backlight can't be adjusted properly unless acpi_backlight=native is passed. Although nvidia-wmi-backlight is present and loaded, this doesn't work as expected at all.
For making it working as default, add the corresponding quirk entry with a DMI matching "LENOVO" "82UX".
--- drivers/acpi/video_detect.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/acpi/video_detect.c +8 -0
@@ -341,6 +341,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "82BK"), }, }, + { + .callback = video_detect_force_native, +/* Lenovo Slim 7 16ARH7 */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "82UX"), + }, + }, { .callback = video_detect_force_native,/* Lenovo ThinkPad X131e (3371 AMD version) */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 12/13 HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse
In reply to Sasha LevinFrom: Benjamin Tissoires <[email protected]>
[ Upstream commit 4e6d2a297dd5be26ad409b7a05b20bd033d1c95e ]
Duplicate of commit 0db117359e47 ("HID: add quirk for 03f0:464a HP Elite Presenter Mouse"), but in a slightly better way.
This time we actually change the application collection, making clearer for userspace what the second mouse is.
Note that having both hid-quirks fix and this HID-BPF fix is not a problem at all.
--- .../hid/bpf/progs/HP__Elite-Presenter.bpf.c | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c
drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c new file +58 -0
@@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (c) 2023 Benjamin Tissoires +*/ + +#include "vmlinux.h" +#include "hid_bpf.h" +#include "hid_bpf_helpers.h" +#include <bpf/bpf_tracing.h> + +#define VID_HP 0x03F0 +#define PID_ELITE_PRESENTER 0x464A + +HID_BPF_CONFIG ( +HID_DEVICE (BUS_BLUETOOTH ,HID_GROUP_GENERIC ,VID_HP ,PID_ELITE_PRESENTER ) +); + +/* +* Already fixed as of commit 0db117359e47 ("HID: add quirk for 03f0:464a +* HP Elite Presenter Mouse") in the kernel, but this is a slightly better +* fix. +* +* The HP Elite Presenter Mouse HID Record Descriptor shows +* two mice (Report ID 0x1 and 0x2), one keypad (Report ID 0x5), +* two Consumer Controls (Report IDs 0x6 and 0x3). +* Prior to these fixes it registers one mouse, one keypad +* and one Consumer Control, and it was usable only as a +* digital laser pointer (one of the two mouses). +* We replace the second mouse collection with a pointer collection, +* allowing to use the device both as a mouse and a digital laser +* pointer. +*/ + +SEC("fmod_ret/hid_bpf_rdesc_fixup") +int BPF_PROG (hid_fix_rdesc ,struct hid_bpf_ctx *hctx) +{ +__u8 *data =hid_bpf_get_data (hctx,0 /* offset */ ,4096 /* size */ ); + +if (!data) +return 0 ;/* EPERM check */ + +/* replace application mouse by application pointer on the second collection */ +if (data[79 ] ==0x02 ) + data[79 ] =0x01 ; + +return 0 ; +} + +SEC("syscall") +int probe (struct hid_bpf_probe_args *ctx) +{ + ctx->retval = ctx->rdesc_size !=264 ; +if (ctx->retval) + ctx->retval = -EINVAL ; + +return 0 ; +} + +char _license[] SEC("license") = "GPL";
Signature · 1 line
2.43.0
Benjamin Tissoires
maintainerRe: [PATCH AUTOSEL 5.10 12/13] HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse
Quoted 4 lines · Sasha Levin
From: Benjamin Tissoires <[email protected]>
[ Upstream commit
4e6d2a297dd5be26ad409b7a05b20bd033d1c95e]
Quoted 8 lines
Duplicate of commit
0db117359e47("HID: add quirk for 03f0:464a HP Elite Presenter Mouse"), but in a slightly better way.This time we actually change the application collection, making clearer for userspace what the second mouse is.
Note that having both hid-quirks fix and this HID-BPF fix is not a problem at all.
Please drop this patch in all backports (and FWIW, any fix in drivers/hid/bpf/progs/).
HID-BPF is only available since kernel v6.3, and the compilation output of the in-tree file is not used directly, but shipped from udev-hid-bpf.
TL;DR: this just adds noise to those stable kernel trees.
Cheers,
Benjamin
Quoted 77 lines
Reviewed-by Peter Hutterer <[email protected]>Signed-off-by Benjamin Tissoires <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- .../hid/bpf/progs/HP__Elite-Presenter.bpf.c | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.cdrivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c new file +58
-0@@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (c) 2023 Benjamin Tissoires +*/ + +#include "vmlinux.h" +#include "hid_bpf.h" +#include "hid_bpf_helpers.h" +#include <bpf/bpf_tracing.h> + +#define VID_HP 0x03F0 +#define PID_ELITE_PRESENTER 0x464A + +HID_BPF_CONFIG ( +HID_DEVICE (BUS_BLUETOOTH ,HID_GROUP_GENERIC ,VID_HP ,PID_ELITE_PRESENTER ) +); + +/* +* Already fixed as of commit 0db117359e47 ("HID: add quirk for 03f0:464a +* HP Elite Presenter Mouse") in the kernel, but this is a slightly better +* fix. +* +* The HP Elite Presenter Mouse HID Record Descriptor shows +* two mice (Report ID 0x1 and 0x2), one keypad (Report ID 0x5), +* two Consumer Controls (Report IDs 0x6 and 0x3). +* Prior to these fixes it registers one mouse, one keypad +* and one Consumer Control, and it was usable only as a +* digital laser pointer (one of the two mouses). +* We replace the second mouse collection with a pointer collection, +* allowing to use the device both as a mouse and a digital laser +* pointer. +*/ + +SEC("fmod_ret/hid_bpf_rdesc_fixup") +int BPF_PROG (hid_fix_rdesc ,struct hid_bpf_ctx *hctx) +{ +__u8 *data =hid_bpf_get_data (hctx,0 /* offset */ ,4096 /* size */ ); + +if (!data) +return 0 ;/* EPERM check */ + +/* replace application mouse by application pointer on the second collection */ +if (data[79 ] ==0x02 ) + data[79 ] =0x01 ; + +return 0 ; +} + +SEC("syscall") +int probe (struct hid_bpf_probe_args *ctx) +{ + ctx->retval = ctx->rdesc_size !=264 ; +if (ctx->retval) + ctx->retval = -EINVAL ; + +return 0 ; +} + +char _license[] SEC("license") = "GPL";Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 13/13 Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl
In reply to Sasha LevinFrom: Uri Arev <[email protected]>
[ Upstream commit 68aa21054ec3a1a313af90a5f95ade16c3326d20 ]
This fixes some CHECKs reported by the checkpatch script.
Issues reported in ath3k.c:
-------ath3k.c
-------
CHECK: Please don't use multiple blank lines
+
+
CHECK: Blank lines aren't necessary after an open brace '{' +static const struct usb_device_id ath3k_blist_tbl[] = { +
CHECK: Alignment should match open parenthesis +static int ath3k_load_firmware(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Alignment should match open parenthesis +static int ath3k_get_version(struct usb_device *udev,
+ struct ath3k_version *version)
CHECK: Alignment should match open parenthesis +static int ath3k_load_fwfile(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Blank lines aren't necessary after an open brace '{'
+ switch (fw_version.ref_clock) {
+
CHECK: Alignment should match open parenthesis
+ snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
+ le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
CHECK: Alignment should match open parenthesis +static int ath3k_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" not found",
+ ATH3K_FIRMWARE);
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" request failed (err=%d)",
+ ATH3K_FIRMWARE, ret);
total: 0 errors, 0 warnings, 14 checks, 540 lines checked
--- drivers/bluetooth/ath3k.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/bluetooth/ath3k.c +11 -14
@@ -3,7 +3,6 @@* Copyright (c) 2008-2009 Atheros Communications Inc. */ -#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h>
@@ -129,7 +128,6 @@ MODULE_DEVICE_TABLE(usb, ath3k_table);* for AR3012 */ static const struct usb_device_id ath3k_blist_tbl[] = { -/* Atheros AR3012 with sflash firmware*/ {USB_DEVICE (0x0489 ,0xe04e ), .driver_info =BTUSB_ATH3012 }, {USB_DEVICE (0x0489 ,0xe04d ), .driver_info =BTUSB_ATH3012 },
@@ -203,7 +201,7 @@ static inline void ath3k_log_failed_loading(int err, int len, int size,#define TIMEGAP_USEC_MAX 100static int ath3k_load_firmware (struct usb_device *udev, -const struct firmware *firmware) +const struct firmware *firmware) {u8 *send_buf;int len =0 ;
@@ -238,9 +236,9 @@ static int ath3k_load_firmware(struct usb_device *udev,memcpy (send_buf, firmware->data + sent, size); err =usb_bulk_msg (udev, pipe, send_buf, size, - &len,3000 ); + &len,3000 ); -if (err || (len != size)) { +if (err || len != size) {ath3k_log_failed_loading (err, len, size, count); goto error; }
@@ -263,7 +261,7 @@ static int ath3k_get_state(struct usb_device *udev, unsigned char *state) }static int ath3k_get_version (struct usb_device *udev, -struct ath3k_version *version) +struct ath3k_version *version) { return usb_control_msg_recv(udev, 0, ATH3K_GETVERSION, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
@@ -272,7 +270,7 @@ static int ath3k_get_version(struct usb_device *udev, }static int ath3k_load_fwfile (struct usb_device *udev, -const struct firmware *firmware) +const struct firmware *firmware) {u8 *send_buf;int len =0 ;
@@ -311,8 +309,8 @@ static int ath3k_load_fwfile(struct usb_device *udev,memcpy (send_buf, firmware->data + sent, size); err =usb_bulk_msg (udev, pipe, send_buf, size, - &len,3000 ); -if (err || (len != size)) { + &len,3000 ); +if (err || len != size) {ath3k_log_failed_loading (err, len, size, count);kfree (send_buf);return err;
@@ -426,7 +424,6 @@ static int ath3k_load_syscfg(struct usb_device *udev) }switch (fw_version.ref_clock) { -case ATH3K_XTAL_FREQ_26M : clk_value =26 ;break ;
@@ -442,7 +439,7 @@ static int ath3k_load_syscfg(struct usb_device *udev) }snprintf (filename,ATH3K_NAME_LEN ,"ar3k/ramps_0x%08x_%d%s" , -le32_to_cpu (fw_version.rom_version), clk_value,".dfu" ); +le32_to_cpu (fw_version.rom_version), clk_value,".dfu" ); ret =request_firmware (&firmware, filename, &udev->dev);if (ret <0 ) {
@@ -457,7 +454,7 @@ static int ath3k_load_syscfg(struct usb_device *udev) }static int ath3k_probe (struct usb_interface *intf, -const struct usb_device_id *id) +const struct usb_device_id *id) {const struct firmware *firmware;struct usb_device *udev =interface_to_usbdev (intf);
@@ -506,10 +503,10 @@ static int ath3k_probe(struct usb_interface *intf,if (ret <0 ) {if (ret == -ENOENT )BT_ERR ("Firmware file \"%s\" not found" , -ATH3K_FIRMWARE ); +ATH3K_FIRMWARE );else BT_ERR ("Firmware file \"%s\" request failed (err=%d)" , -ATH3K_FIRMWARE , ret); +ATH3K_FIRMWARE , ret);return ret; }
Signature · 1 line
2.43.0