-
Notifications
You must be signed in to change notification settings - Fork 5
bpf: Explicitly check accesses to bpf_sock_addr #5964
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
Conversation
|
Upstream branch: f36caa7 |
|
Upstream branch: f36caa7 |
f744821 to
20b1046
Compare
|
Upstream branch: f36caa7 |
20b1046 to
025f27c
Compare
Syzkaller found a kernel warning on the following sock_addr program:
0: r0 = 0
1: r2 = *(u32 *)(r1 +60)
2: exit
which triggers:
verifier bug: error during ctx access conversion (0)
This is happening because offset 60 in bpf_sock_addr corresponds to an
implicit padding of 4 bytes, right after msg_src_ip4. Access to this
padding isn't rejected in sock_addr_is_valid_access and it thus later
fails to convert the access.
This patch fixes it by explicitly checking the various fields of
bpf_sock_addr in sock_addr_is_valid_access.
I checked the other ctx structures and is_valid_access functions and
didn't find any other similar cases. Other cases of (properly handled)
padding are covered in new tests in a subsequent patch.
Fixes: 1cedee1 ("bpf: Hooks for sys_sendmsg")
Reported-by: [email protected]
Closes: https://syzkaller.appspot.com/bug?extid=136ca59d411f92e821b7
Signed-off-by: Paul Chaignon <[email protected]>
Acked-by: Eduard Zingerman <[email protected]>
|
Upstream branch: f36caa7 |
Move the sizeof_field and offsetofend macros from individual test files to the common bpf_misc.h to avoid duplication. Signed-off-by: Paul Chaignon <[email protected]> Acked-by: Eduard Zingerman <[email protected]>
This patch adds tests covering the various paddings in ctx structures. In case of sk_lookup BPF programs, the behavior is a bit different because accesses to the padding are explicitly allowed. Other cases result in a clear reject from the verifier. Signed-off-by: Paul Chaignon <[email protected]> Acked-by: Eduard Zingerman <[email protected]>
025f27c to
a315028
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1002970 expired. Closing PR. |
Pull request for series with
subject: bpf: Explicitly check accesses to bpf_sock_addr
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1002970