Revert "bpf: Remove bpf trampoline selector"
This reverts commit 8ea165e1f8
which is
commit 47e79cbeea4b3891ad476047f4c68543eb51c8e0 upstream.
It breaks the Android ABI and can be brought back in an abi-safe way in
the future if it is still needed.
Bug: 161946584
Change-Id: I6b0b4846d8ec26e44c6627b8b4cbb2c46cc01a13
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
17f0b3c7ee
commit
c057db2f88
@ -942,6 +942,7 @@ struct bpf_trampoline {
|
|||||||
int progs_cnt[BPF_TRAMP_MAX];
|
int progs_cnt[BPF_TRAMP_MAX];
|
||||||
/* Executable image of trampoline */
|
/* Executable image of trampoline */
|
||||||
struct bpf_tramp_image *cur_image;
|
struct bpf_tramp_image *cur_image;
|
||||||
|
u64 selector;
|
||||||
struct module *mod;
|
struct module *mod;
|
||||||
ANDROID_KABI_RESERVE(1);
|
ANDROID_KABI_RESERVE(1);
|
||||||
};
|
};
|
||||||
|
@ -377,7 +377,7 @@ static void bpf_tramp_image_put(struct bpf_tramp_image *im)
|
|||||||
call_rcu_tasks_trace(&im->rcu, __bpf_tramp_image_put_rcu_tasks);
|
call_rcu_tasks_trace(&im->rcu, __bpf_tramp_image_put_rcu_tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key)
|
static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key, u32 idx)
|
||||||
{
|
{
|
||||||
struct bpf_tramp_image *im;
|
struct bpf_tramp_image *im;
|
||||||
struct bpf_ksym *ksym;
|
struct bpf_ksym *ksym;
|
||||||
@ -404,7 +404,7 @@ static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key)
|
|||||||
|
|
||||||
ksym = &im->ksym;
|
ksym = &im->ksym;
|
||||||
INIT_LIST_HEAD_RCU(&ksym->lnode);
|
INIT_LIST_HEAD_RCU(&ksym->lnode);
|
||||||
snprintf(ksym->name, KSYM_NAME_LEN, "bpf_trampoline_%llu", key);
|
snprintf(ksym->name, KSYM_NAME_LEN, "bpf_trampoline_%llu_%u", key, idx);
|
||||||
bpf_image_ksym_add(image, ksym);
|
bpf_image_ksym_add(image, ksym);
|
||||||
return im;
|
return im;
|
||||||
|
|
||||||
@ -434,10 +434,11 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mut
|
|||||||
err = unregister_fentry(tr, tr->cur_image->image);
|
err = unregister_fentry(tr, tr->cur_image->image);
|
||||||
bpf_tramp_image_put(tr->cur_image);
|
bpf_tramp_image_put(tr->cur_image);
|
||||||
tr->cur_image = NULL;
|
tr->cur_image = NULL;
|
||||||
|
tr->selector = 0;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
im = bpf_tramp_image_alloc(tr->key);
|
im = bpf_tramp_image_alloc(tr->key, tr->selector);
|
||||||
if (IS_ERR(im)) {
|
if (IS_ERR(im)) {
|
||||||
err = PTR_ERR(im);
|
err = PTR_ERR(im);
|
||||||
goto out;
|
goto out;
|
||||||
@ -475,7 +476,8 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mut
|
|||||||
set_memory_ro((long)im->image, 1);
|
set_memory_ro((long)im->image, 1);
|
||||||
set_memory_x((long)im->image, 1);
|
set_memory_x((long)im->image, 1);
|
||||||
|
|
||||||
WARN_ON(tr->cur_image && total == 0);
|
WARN_ON(tr->cur_image && tr->selector == 0);
|
||||||
|
WARN_ON(!tr->cur_image && tr->selector);
|
||||||
if (tr->cur_image)
|
if (tr->cur_image)
|
||||||
/* progs already running at this address */
|
/* progs already running at this address */
|
||||||
err = modify_fentry(tr, tr->cur_image->image, im->image, lock_direct_mutex);
|
err = modify_fentry(tr, tr->cur_image->image, im->image, lock_direct_mutex);
|
||||||
@ -505,6 +507,7 @@ static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mut
|
|||||||
if (tr->cur_image)
|
if (tr->cur_image)
|
||||||
bpf_tramp_image_put(tr->cur_image);
|
bpf_tramp_image_put(tr->cur_image);
|
||||||
tr->cur_image = im;
|
tr->cur_image = im;
|
||||||
|
tr->selector++;
|
||||||
out:
|
out:
|
||||||
/* If any error happens, restore previous flags */
|
/* If any error happens, restore previous flags */
|
||||||
if (err)
|
if (err)
|
||||||
|
Loading…
Reference in New Issue
Block a user