* [PATCH bpf-next] bpf: test_run: Fix overflow in xdp frags bpf_test_finish
@ 2022-02-28 23:23 Stanislav Fomichev
2022-03-01 16:33 ` Daniel Borkmann
2022-03-02 0:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Stanislav Fomichev @ 2022-02-28 23:23 UTC (permalink / raw)
To: netdev, bpf; +Cc: ast, daniel, andrii, Stanislav Fomichev, Lorenzo Bianconi
Syzkaller reports another issue:
WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
check_copy_size include/linux/thread_info.h:230 [inline]
WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
copy_to_user include/linux/uaccess.h:199 [inline]
WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
bpf_test_finish.isra.0+0x4b2/0x680 net/bpf/test_run.c:171
This can happen when the userspace buffer is smaller than head+frags.
Return ENOSPC in this case.
Fixes: 7855e0db150a ("bpf: test_run: add xdp_shared_info pointer in bpf_test_finish signature")
Cc: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
net/bpf/test_run.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index f08034500813..eb129e48f90b 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -150,6 +150,11 @@ static int bpf_test_finish(const union bpf_attr *kattr,
if (data_out) {
int len = sinfo ? copy_size - sinfo->xdp_frags_size : copy_size;
+ if (len < 0) {
+ err = -ENOSPC;
+ goto out;
+ }
+
if (copy_to_user(data_out, data, len))
goto out;
--
2.35.1.574.g5d30c73bfb-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] bpf: test_run: Fix overflow in xdp frags bpf_test_finish
2022-02-28 23:23 [PATCH bpf-next] bpf: test_run: Fix overflow in xdp frags bpf_test_finish Stanislav Fomichev
@ 2022-03-01 16:33 ` Daniel Borkmann
2022-03-01 16:38 ` Stanislav Fomichev
2022-03-02 0:20 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Borkmann @ 2022-03-01 16:33 UTC (permalink / raw)
To: Stanislav Fomichev, netdev, bpf; +Cc: ast, andrii, Lorenzo Bianconi
On 3/1/22 12:23 AM, Stanislav Fomichev wrote:
> Syzkaller reports another issue:
> WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
> check_copy_size include/linux/thread_info.h:230 [inline]
> WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
> copy_to_user include/linux/uaccess.h:199 [inline]
> WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
> bpf_test_finish.isra.0+0x4b2/0x680 net/bpf/test_run.c:171
>
> This can happen when the userspace buffer is smaller than head+frags.
> Return ENOSPC in this case.
>
> Fixes: 7855e0db150a ("bpf: test_run: add xdp_shared_info pointer in bpf_test_finish signature")
> Cc: Lorenzo Bianconi <lorenzo@kernel.org>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
Do we have a Reported-by tag for syzkaller so it can match against its report?
Thanks,
Daniel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] bpf: test_run: Fix overflow in xdp frags bpf_test_finish
2022-03-01 16:33 ` Daniel Borkmann
@ 2022-03-01 16:38 ` Stanislav Fomichev
0 siblings, 0 replies; 4+ messages in thread
From: Stanislav Fomichev @ 2022-03-01 16:38 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: netdev, bpf, ast, andrii, Lorenzo Bianconi
On Tue, Mar 1, 2022 at 8:33 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 3/1/22 12:23 AM, Stanislav Fomichev wrote:
> > Syzkaller reports another issue:
> > WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
> > check_copy_size include/linux/thread_info.h:230 [inline]
> > WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
> > copy_to_user include/linux/uaccess.h:199 [inline]
> > WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
> > bpf_test_finish.isra.0+0x4b2/0x680 net/bpf/test_run.c:171
> >
> > This can happen when the userspace buffer is smaller than head+frags.
> > Return ENOSPC in this case.
> >
> > Fixes: 7855e0db150a ("bpf: test_run: add xdp_shared_info pointer in bpf_test_finish signature")
> > Cc: Lorenzo Bianconi <lorenzo@kernel.org>
> > Signed-off-by: Stanislav Fomichev <sdf@google.com>
>
> Do we have a Reported-by tag for syzkaller so it can match against its report?
Oops, sorry, totally forgot:
Reported-by: syzbot+5f81df6205ecbbc56ab5@syzkaller.appspotmail.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] bpf: test_run: Fix overflow in xdp frags bpf_test_finish
2022-02-28 23:23 [PATCH bpf-next] bpf: test_run: Fix overflow in xdp frags bpf_test_finish Stanislav Fomichev
2022-03-01 16:33 ` Daniel Borkmann
@ 2022-03-02 0:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-02 0:20 UTC (permalink / raw)
To: Stanislav Fomichev; +Cc: netdev, bpf, ast, daniel, andrii, lorenzo
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:
On Mon, 28 Feb 2022 15:23:32 -0800 you wrote:
> Syzkaller reports another issue:
> WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
> check_copy_size include/linux/thread_info.h:230 [inline]
> WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
> copy_to_user include/linux/uaccess.h:199 [inline]
> WARNING: CPU: 0 PID: 10775 at include/linux/thread_info.h:230
> bpf_test_finish.isra.0+0x4b2/0x680 net/bpf/test_run.c:171
>
> [...]
Here is the summary with links:
- [bpf-next] bpf: test_run: Fix overflow in xdp frags bpf_test_finish
https://git.kernel.org/bpf/bpf-next/c/530e214c5b5a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-02 0:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 23:23 [PATCH bpf-next] bpf: test_run: Fix overflow in xdp frags bpf_test_finish Stanislav Fomichev
2022-03-01 16:33 ` Daniel Borkmann
2022-03-01 16:38 ` Stanislav Fomichev
2022-03-02 0:20 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.