Skip to content
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

Closed

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: verify scalar ids mapping in regsafe()
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=754644

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: aa7881f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=754644
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 67faabb
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=754644
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 67faabb
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=755875
version: 4

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: b23ed4d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=755875
version: 4

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: b23ed4d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=756370
version: 5

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: ba49f97
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=756370
version: 5

@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=756370 expired. Closing PR.

Kernel Patches Daemon and others added 5 commits June 12, 2023 15:19
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>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 25085b4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=756796
version: 6

@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=756796 irrelevant now. Closing PR.

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot deleted the series/752388=>bpf-next branch June 13, 2023 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant