selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh
Subsystems (8)
Sasha Levin
maintainerPATCH 1/6 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/6 batman-adv: bypass empty buckets in batadv_purge_orig_ref()
From: 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
@@ -1345,6 +1345,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 3/6 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
@@ -71,7 +71,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 {
@@ -165,9 +165,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;
@@ -222,7 +222,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)
@@ -256,7 +256,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)
@@ -315,9 +315,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; }
@@ -445,7 +445,7 @@ net_dm_hw_summary_probe(struct sk_buff *skb,int i; 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)
@@ -474,7 +474,7 @@ net_dm_hw_summary_probe(struct sk_buff *skb, } 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 = {
@@ -1592,7 +1592,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 4/6 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 5/6 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.4 5/6] 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 6/6 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 ;
@@ -241,9 +239,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; }
@@ -278,7 +276,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) {int ret, pipe =0 ;struct ath3k_version *buf;
@@ -300,7 +298,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 ;
@@ -341,8 +339,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;
@@ -461,7 +459,6 @@ static int ath3k_load_syscfg(struct usb_device *udev) }switch (fw_version.ref_clock) { -case ATH3K_XTAL_FREQ_26M : clk_value =26 ;break ;
@@ -477,7 +474,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 ) {
@@ -492,7 +489,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);
@@ -541,10 +538,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