bpf: Disable migration when cloning sock storage
authorHou Tao <houtao1@huawei.com>
Wed, 8 Jan 2025 01:07:20 +0000 (09:07 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 9 Jan 2025 02:06:36 +0000 (18:06 -0800)
commitdfccfc47bde53f5df5bf42486d12a8a2ecdcea60
tree6ca15ad45b449b76fb2712fb39ea09d77a244a3f
parent7d1032d1e3031ef38d1a360380d755f75cb639b8
bpf: Disable migration when cloning sock storage

bpf_sk_storage_clone() will call bpf_selem_free() to free the clone
element when the allocation of new sock storage fails. bpf_selem_free()
will call check_and_free_fields() to free the special fields in the
element. Since the allocated element is not visible to bpf syscall or
bpf program when bpf_local_storage_alloc() fails, these special fields
in the element must be all zero when invoking bpf_selem_free().

To be uniform with other callers of bpf_selem_free(), disabling
migration when cloning sock storage. Adding migrate_{disable|enable}
pair also benefits the potential switching from kzalloc to bpf memory
allocator for sock storage.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20250108010728.207536-9-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
net/core/bpf_sk_storage.c