diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2023-01-21 05:52:34 +0530 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-01-20 17:55:03 -0800 |
commit | 379d4ba831cfa895d0cc61d88cd0e1402f35818c (patch) | |
tree | c92abb771c014693238f181461d420eaf452484a /ipc | |
parent | f8064ab90d6644bc8338d2d7ff6a0d6e7a1b2ef3 (diff) |
bpf: Allow reinitializing unreferenced dynptr stack slots
Consider a program like below:
void prog(void)
{
{
struct bpf_dynptr ptr;
bpf_dynptr_from_mem(...);
}
...
{
struct bpf_dynptr ptr;
bpf_dynptr_from_mem(...);
}
}
Here, the C compiler based on lifetime rules in the C standard would be
well within in its rights to share stack storage for dynptr 'ptr' as
their lifetimes do not overlap in the two distinct scopes. Currently,
such an example would be rejected by the verifier, but this is too
strict. Instead, we should allow reinitializing over dynptr stack slots
and forget information about the old dynptr object.
The destroy_if_dynptr_stack_slot function already makes necessary checks
to avoid overwriting referenced dynptr slots. This is done to present a
better error message instead of forgetting dynptr information on stack
and preserving reference state, leading to an inevitable but
undecipherable error at the end about an unreleased reference which has
to be associated back to its allocating call instruction to make any
sense to the user.
Acked-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230121002241.2113993-6-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'ipc')
0 files changed, 0 insertions, 0 deletions