Skip to content

Commit 55d49f7

Browse files
Martin KaFai Lauborkmann
authored andcommitted
bpf: bpf_sk_storage: Fix the missing uncharge in sk_omem_alloc
The commit c83597f ("bpf: Refactor some inode/task/sk storage functions for reuse"), refactored the bpf_{sk,task,inode}_storage_free() into bpf_local_storage_unlink_nolock() which then later renamed to bpf_local_storage_destroy(). The commit accidentally passed the "bool uncharge_mem = false" argument to bpf_selem_unlink_storage_nolock() which then stopped the uncharge from happening to the sk->sk_omem_alloc. This missing uncharge only happens when the sk is going away (during __sk_destruct). This patch fixes it by always passing "uncharge_mem = true". It is a noop to the task/inode/cgroup storage because they do not have the map_local_storage_(un)charge enabled in the map_ops. A followup patch will be done in bpf-next to remove the uncharge_mem argument. A selftest is added in the next patch. Fixes: c83597f ("bpf: Refactor some inode/task/sk storage functions for reuse") Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20230901231129.578493-3-martin.lau@linux.dev
1 parent a96a44a commit 55d49f7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/bpf_local_storage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ void bpf_local_storage_destroy(struct bpf_local_storage *local_storage)
760760
* of the loop will set the free_cgroup_storage to true.
761761
*/
762762
free_storage = bpf_selem_unlink_storage_nolock(
763-
local_storage, selem, false, true);
763+
local_storage, selem, true, true);
764764
}
765765
raw_spin_unlock_irqrestore(&local_storage->lock, flags);
766766

0 commit comments

Comments
 (0)