diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2023-01-21 05:52:33 +0530 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-01-20 17:55:03 -0800 |
commit | f8064ab90d6644bc8338d2d7ff6a0d6e7a1b2ef3 (patch) | |
tree | 7f5a8a4095bd9bce4598762865fa89875f1c524e /net/mctp | |
parent | ef8fc7a07c0e161841779d6fe3f6acd5a05c547c (diff) | |
download | linux-f8064ab90d6644bc8338d2d7ff6a0d6e7a1b2ef3.tar.gz linux-f8064ab90d6644bc8338d2d7ff6a0d6e7a1b2ef3.tar.bz2 linux-f8064ab90d6644bc8338d2d7ff6a0d6e7a1b2ef3.zip |
bpf: Invalidate slices on destruction of dynptrs on stack
The previous commit implemented destroy_if_dynptr_stack_slot. It
destroys the dynptr which given spi belongs to, but still doesn't
invalidate the slices that belong to such a dynptr. While for the case
of referenced dynptr, we don't allow their overwrite and return an error
early, we still allow it and destroy the dynptr for unreferenced dynptr.
To be able to enable precise and scoped invalidation of dynptr slices in
this case, we must be able to associate the source dynptr of slices that
have been obtained using bpf_dynptr_data. When doing destruction, only
slices belonging to the dynptr being destructed should be invalidated,
and nothing else. Currently, dynptr slices belonging to different
dynptrs are indistinguishible.
Hence, allocate a unique id to each dynptr (CONST_PTR_TO_DYNPTR and
those on stack). This will be stored as part of reg->id. Whenever using
bpf_dynptr_data, transfer this unique dynptr id to the returned
PTR_TO_MEM_OR_NULL slice pointer, and store it in a new per-PTR_TO_MEM
dynptr_id register state member.
Finally, after establishing such a relationship between dynptrs and
their slices, implement precise invalidation logic that only invalidates
slices belong to the destroyed dynptr in destroy_if_dynptr_stack_slot.
Acked-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230121002241.2113993-5-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'net/mctp')
0 files changed, 0 insertions, 0 deletions