Skip to content

Commit ebae0b2

Browse files
author
Benjamin Tissoires
committed
HID: bpf: fix dispatch_hid_bpf_device_event uninitialized ret value
Looks like if a bpf program gets inserted and then removed, hdev->bpf.device_data is then allocated, but the loop iterating over the bpf program is never assigning ret. This is a problem and also revealed another bug in which only the last value of ret was checked. This effectively meant than only the last program in the chain could change the size of the incoming buffer. Reported-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/all/[email protected] Fixes: 4a86220 ("HID: bpf: remove tracing HID-BPF capability") Link: https://patch.msgid.link/[email protected] Acked-by: Jiri Kosina <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent 9e16bad commit ebae0b2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/hid/bpf/hid_bpf_dispatch.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ dispatch_hid_bpf_device_event(struct hid_device *hdev, enum hid_report_type type
5757
}
5858

5959
if (ret)
60-
ctx_kern.ctx.retval = ret;
60+
ctx_kern.ctx.size = ret;
6161
}
6262
}
6363
rcu_read_unlock();
6464

65+
ret = ctx_kern.ctx.size;
6566
if (ret) {
6667
if (ret > ctx_kern.ctx.allocated_size)
6768
return ERR_PTR(-EINVAL);

0 commit comments

Comments
 (0)