-
Notifications
You must be signed in to change notification settings - Fork 5
LoongArch: BPF: Fix incorrect return pointer value in the eBPF program #5756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LoongArch: BPF: Fix incorrect return pointer value in the eBPF program #5756
Conversation
|
Upstream branch: 0786654 |
5e1a4c1 to
91606c1
Compare
|
Upstream branch: dc0fe95 |
26f7df5 to
b8655a1
Compare
91606c1 to
9e5d665
Compare
|
Upstream branch: c80d797 |
b8655a1 to
d374709
Compare
9e5d665 to
f86fd37
Compare
|
Upstream branch: abdaf49 |
d374709 to
d51d248
Compare
f86fd37 to
2842450
Compare
|
Upstream branch: 3ec8560 |
d51d248 to
d94dbe9
Compare
2842450 to
53b8665
Compare
|
Upstream branch: 1274163 |
d94dbe9 to
6cf323b
Compare
53b8665 to
26f4a08
Compare
|
Upstream branch: d87fdb1 |
6cf323b to
5303885
Compare
26f4a08 to
032ad98
Compare
|
Upstream branch: dbe99ea |
5303885 to
04f1680
Compare
032ad98 to
728c457
Compare
|
Upstream branch: 6850a33 |
04f1680 to
6a9ab7d
Compare
728c457 to
a5fe106
Compare
|
Upstream branch: dbe99ea |
6a9ab7d to
97b42d8
Compare
a5fe106 to
34c4028
Compare
|
Upstream branch: 5c42715 |
97b42d8 to
0884c58
Compare
34c4028 to
2ef6166
Compare
|
Upstream branch: bf7a6a6 |
In some eBPF programs, the return value is a pointer.
When the kernel call an eBPF program (such as struct_ops),
it expects a 64-bit address to be returned, but instead a 32-bit value.
Before applying this patch:
./test_progs -a ns_bpf_qdisc
CPU 7 Unable to handle kernel paging request at virtual
address 0000000010440158.
As shown in the following test case,
bpf_fifo_dequeue return value is a pointer.
progs/bpf_qdisc_fifo.c
SEC("struct_ops/bpf_fifo_dequeue")
struct sk_buff *BPF_PROG(bpf_fifo_dequeue, struct Qdisc *sch)
{
struct sk_buff *skb = NULL;
........
skb = bpf_kptr_xchg(&skbn->skb, skb);
........
return skb;
}
kernel call bpf_fifo_dequeue:
net/sched/sch_generic.c
static struct sk_buff *dequeue_skb(struct Qdisc *q, bool *validate,
int *packets)
{
struct sk_buff *skb = NULL;
........
skb = q->dequeue(q);
.........
}
When accessing the skb, an address exception error will occur.
because the value returned by q->dequeue at this point is a 32-bit
address rather than a 64-bit address.
After applying the patch:
./test_progs -a ns_bpf_qdisc
Warning: sch_htb: quantum of class 10001 is small. Consider r2q change.
213/1 ns_bpf_qdisc/fifo:OK
213/2 ns_bpf_qdisc/fq:OK
213/3 ns_bpf_qdisc/attach to mq:OK
213/4 ns_bpf_qdisc/attach to non root:OK
213/5 ns_bpf_qdisc/incompl_ops:OK
213 ns_bpf_qdisc:OK
Summary: 1/5 PASSED, 0 SKIPPED, 0 FAILED
Fixes: 73c359d ("LoongArch: BPF: Sign-extend return values")
Signed-off-by: Jinyang He <[email protected]>
Signed-off-by: Haoran Jiang <[email protected]>
----------
v2:
1,add emit_slt* helpers
2,Use slt/slld/srad instructions to avoid branch
0884c58 to
9527bcf
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=991838 irrelevant now. Closing PR. |
Pull request for series with
subject: LoongArch: BPF: Fix incorrect return pointer value in the eBPF program
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=991838