Skip to content

Commit

Permalink
The in_atomic macro cannot always detect atomic context. In particular,
Browse files Browse the repository at this point in the history
it cannot know about held spinlocks in non-preemptible kernels. Although,
there is no user call bpf_link_put() with holding spinlock now. Be the
safe side, we can avoid this in the feature.

Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 kernel/bpf/syscall.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
  • Loading branch information
Muchun Song authored and kernel-patches-bot committed Sep 18, 2020
1 parent 2e5f44d commit 8fe91eb
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions kernel/bpf/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -2345,12 +2345,8 @@ void bpf_link_put(struct bpf_link *link)
if (!atomic64_dec_and_test(&link->refcnt))
return;

if (in_atomic()) {
INIT_WORK(&link->work, bpf_link_put_deferred);
schedule_work(&link->work);
} else {
bpf_link_free(link);
}
INIT_WORK(&link->work, bpf_link_put_deferred);
schedule_work(&link->work);
}

static int bpf_link_release(struct inode *inode, struct file *filp)
Expand Down

0 comments on commit 8fe91eb

Please sign in to comment.