perf/bpf: Fix data race in __perf_event_overflow - #13220
perf/bpf: Fix data race in __perf_event_overflow#13220kernel-patches-daemon-bpf[bot] wants to merge 2 commits into
Conversation
|
Upstream branch: 07cb86a |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
|
Forwarding comment 5260785640 via email |
|
Upstream branch: 07cb86a |
ffa161d to
8ef3860
Compare
3bf3eae to
2f9c9e0
Compare
|
Upstream branch: 611a9f0 |
8ef3860 to
b196f44
Compare
2f9c9e0 to
239ce7e
Compare
|
Upstream branch: 3a59f11 |
b196f44 to
af548d8
Compare
239ce7e to
f9ee2fe
Compare
|
Upstream branch: 3a59f11 |
af548d8 to
7a0bed0
Compare
f9ee2fe to
7bfbd95
Compare
|
Upstream branch: 108d440 |
7a0bed0 to
79034a0
Compare
7bfbd95 to
f3e34e7
Compare
|
Upstream branch: a88dbe1 |
79034a0 to
f040b2b
Compare
f3e34e7 to
5182577
Compare
|
Upstream branch: 7c3e54c |
f040b2b to
80936ff
Compare
5182577 to
673b1f0
Compare
|
Upstream branch: 6f03361 |
80936ff to
6d24a64
Compare
673b1f0 to
dd132f6
Compare
|
Upstream branch: 9786d42 |
6d24a64 to
bfdf91c
Compare
dd132f6 to
6220a54
Compare
|
Upstream branch: 806c1a1 |
bfdf91c to
ada036a
Compare
6220a54 to
fa81f18
Compare
|
Upstream branch: aacd13e |
ada036a to
5163d2a
Compare
fa81f18 to
fdd9d75
Compare
|
Upstream branch: 259d60f |
perf_event_detach_bpf_prog() writes event->prog = NULL under bpf_event_mutex, while __perf_event_overflow() reads event->prog concurrently without any lock protection. This causes a data race detected by KCSAN. __perf_event_overflow() can be called from interrupt/NMI context, so it cannot acquire bpf_event_mutex. Fix the race by using WRITE_ONCE() in perf_event_detach_bpf_prog() and READ_ONCE() in __perf_event_overflow(). Also store the result of READ_ONCE() in a local variable to avoid reading event->prog twice which could result in a NULL pointer dereference if the pointer becomes NULL between the two reads. Reported-by: syzbot+651d2774bd1d8395595f@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=651d2774bd1d8395595f Fixes: f11f10b ("perf/bpf: Call BPF handler directly, not through overflow machinery") Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com> Reported-by: syzbot+651d2774bd1d8395595f@syzkaller.appspotmail.com Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com> Signed-off-by: appear twice. Also, the second Reported-by: is placed
5163d2a to
08384fc
Compare
fdd9d75 to
c66e1e2
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1144381 expired. Closing PR. |
Pull request for series with
subject: perf/bpf: Fix data race in __perf_event_overflow
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1144381