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
verify scalar ids mapping in regsafe() #5180
Conversation
Upstream branch: aa7881f |
af29f6b
to
084d713
Compare
Upstream branch: 67faabb |
f6dff6d
to
09e94b4
Compare
Upstream branch: 67faabb |
09e94b4
to
0e9b2c5
Compare
084d713
to
634a1fc
Compare
Upstream branch: b23ed4d |
0e9b2c5
to
700ee05
Compare
Upstream branch: b23ed4d |
700ee05
to
06bf39f
Compare
634a1fc
to
52ddcf8
Compare
Upstream branch: ba49f97 |
06bf39f
to
dfebf0e
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=756370 expired. Closing PR. |
Change mark_chain_precision() to track precision in situations like below: r2 = unknown value ... --- state #0 --- ... r1 = r2 // r1 and r2 now share the same ID ... --- state #1 {r1.id = A, r2.id = A} --- ... if (r2 > 10) goto exit; // find_equal_scalars() assigns range to r1 ... --- state #2 {r1.id = A, r2.id = A} --- r3 = r10 r3 += r1 // need to mark both r1 and r2 At the beginning of the processing of each state, ensure that if a register with a scalar ID is marked as precise, all registers sharing this ID are also marked as precise. This property would be used by a follow-up change in regsafe(). Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Check __mark_chain_precision() log to verify that scalars with same IDs are marked as precise. Use several scenarios to test that precision marks are propagated through: - registers of scalar type with the same ID within one state; - registers of scalar type with the same ID cross several states; - registers of scalar type with the same ID cross several stack frames; - stack slot of scalar type with the same ID; - multiple scalar IDs are tracked independently. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Make sure that the following unsafe example is rejected by verifier: 1: r9 = ... some pointer with range X ... 2: r6 = ... unbound scalar ID=a ... 3: r7 = ... unbound scalar ID=b ... 4: if (r6 > r7) goto +1 5: r6 = r7 6: if (r6 > X) goto ...
Verify that the following example is rejected by verifier: r9 = ... some pointer with range X ... r6 = ... unbound scalar ID=a ... r7 = ... unbound scalar ID=b ... if (r6 > r7) goto +1 r7 = r6 if (r7 > X) goto exit r9 += r6 *(u64 *)r9 = Y Also add test cases to: - check that check_alu_op() for BPF_MOV instruction does not allocate scalar ID if source register is a constant; - check that unique scalar IDs are ignored when new verifier state is compared to cached verifier state; - check that two different scalar IDs in a verified state can't be mapped to the same scalar ID in current state. Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Upstream branch: 25085b4 |
dfebf0e
to
108c3fa
Compare
0dab44a
to
e9791ce
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=756796 irrelevant now. Closing PR. |
Pull request for series with
subject: verify scalar ids mapping in regsafe()
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=754644