mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-13 05:54:23 +08:00
uprobes: get rid of enum uprobe_filter_ctx in uprobe filter callbacks
It serves no purpose beyond adding unnecessray argument passed to the filter callback. Just get rid of it, no one is actually using it. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Oleg Nesterov <oleg@redhat.com> Link: https://lore.kernel.org/r/20240903174603.3554182-4-andrii@kernel.org
This commit is contained in:
parent
8617408f7a
commit
59da880afe
@ -28,20 +28,12 @@ struct page;
|
||||
|
||||
#define MAX_URETPROBE_DEPTH 64
|
||||
|
||||
enum uprobe_filter_ctx {
|
||||
UPROBE_FILTER_REGISTER,
|
||||
UPROBE_FILTER_UNREGISTER,
|
||||
UPROBE_FILTER_MMAP,
|
||||
};
|
||||
|
||||
struct uprobe_consumer {
|
||||
int (*handler)(struct uprobe_consumer *self, struct pt_regs *regs);
|
||||
int (*ret_handler)(struct uprobe_consumer *self,
|
||||
unsigned long func,
|
||||
struct pt_regs *regs);
|
||||
bool (*filter)(struct uprobe_consumer *self,
|
||||
enum uprobe_filter_ctx ctx,
|
||||
struct mm_struct *mm);
|
||||
bool (*filter)(struct uprobe_consumer *self, struct mm_struct *mm);
|
||||
|
||||
struct uprobe_consumer *next;
|
||||
};
|
||||
|
@ -918,21 +918,19 @@ static int prepare_uprobe(struct uprobe *uprobe, struct file *file,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline bool consumer_filter(struct uprobe_consumer *uc,
|
||||
enum uprobe_filter_ctx ctx, struct mm_struct *mm)
|
||||
static inline bool consumer_filter(struct uprobe_consumer *uc, struct mm_struct *mm)
|
||||
{
|
||||
return !uc->filter || uc->filter(uc, ctx, mm);
|
||||
return !uc->filter || uc->filter(uc, mm);
|
||||
}
|
||||
|
||||
static bool filter_chain(struct uprobe *uprobe,
|
||||
enum uprobe_filter_ctx ctx, struct mm_struct *mm)
|
||||
static bool filter_chain(struct uprobe *uprobe, struct mm_struct *mm)
|
||||
{
|
||||
struct uprobe_consumer *uc;
|
||||
bool ret = false;
|
||||
|
||||
down_read(&uprobe->consumer_rwsem);
|
||||
for (uc = uprobe->consumers; uc; uc = uc->next) {
|
||||
ret = consumer_filter(uc, ctx, mm);
|
||||
ret = consumer_filter(uc, mm);
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
@ -1099,12 +1097,10 @@ register_for_each_vma(struct uprobe *uprobe, struct uprobe_consumer *new)
|
||||
|
||||
if (is_register) {
|
||||
/* consult only the "caller", new consumer. */
|
||||
if (consumer_filter(new,
|
||||
UPROBE_FILTER_REGISTER, mm))
|
||||
if (consumer_filter(new, mm))
|
||||
err = install_breakpoint(uprobe, mm, vma, info->vaddr);
|
||||
} else if (test_bit(MMF_HAS_UPROBES, &mm->flags)) {
|
||||
if (!filter_chain(uprobe,
|
||||
UPROBE_FILTER_UNREGISTER, mm))
|
||||
if (!filter_chain(uprobe, mm))
|
||||
err |= remove_breakpoint(uprobe, mm, info->vaddr);
|
||||
}
|
||||
|
||||
@ -1387,7 +1383,7 @@ int uprobe_mmap(struct vm_area_struct *vma)
|
||||
*/
|
||||
list_for_each_entry_safe(uprobe, u, &tmp_list, pending_list) {
|
||||
if (!fatal_signal_pending(current) &&
|
||||
filter_chain(uprobe, UPROBE_FILTER_MMAP, vma->vm_mm)) {
|
||||
filter_chain(uprobe, vma->vm_mm)) {
|
||||
unsigned long vaddr = offset_to_vaddr(vma, uprobe->offset);
|
||||
install_breakpoint(uprobe, vma->vm_mm, vma, vaddr);
|
||||
}
|
||||
|
@ -3320,8 +3320,7 @@ static int uprobe_prog_run(struct bpf_uprobe *uprobe,
|
||||
}
|
||||
|
||||
static bool
|
||||
uprobe_multi_link_filter(struct uprobe_consumer *con, enum uprobe_filter_ctx ctx,
|
||||
struct mm_struct *mm)
|
||||
uprobe_multi_link_filter(struct uprobe_consumer *con, struct mm_struct *mm)
|
||||
{
|
||||
struct bpf_uprobe *uprobe;
|
||||
|
||||
|
@ -1078,9 +1078,7 @@ print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *e
|
||||
return trace_handle_return(s);
|
||||
}
|
||||
|
||||
typedef bool (*filter_func_t)(struct uprobe_consumer *self,
|
||||
enum uprobe_filter_ctx ctx,
|
||||
struct mm_struct *mm);
|
||||
typedef bool (*filter_func_t)(struct uprobe_consumer *self, struct mm_struct *mm);
|
||||
|
||||
static int trace_uprobe_enable(struct trace_uprobe *tu, filter_func_t filter)
|
||||
{
|
||||
@ -1339,8 +1337,7 @@ static int uprobe_perf_open(struct trace_event_call *call,
|
||||
return err;
|
||||
}
|
||||
|
||||
static bool uprobe_perf_filter(struct uprobe_consumer *uc,
|
||||
enum uprobe_filter_ctx ctx, struct mm_struct *mm)
|
||||
static bool uprobe_perf_filter(struct uprobe_consumer *uc, struct mm_struct *mm)
|
||||
{
|
||||
struct trace_uprobe_filter *filter;
|
||||
struct trace_uprobe *tu;
|
||||
@ -1426,7 +1423,7 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,
|
||||
static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs,
|
||||
struct uprobe_cpu_buffer **ucbp)
|
||||
{
|
||||
if (!uprobe_perf_filter(&tu->consumer, 0, current->mm))
|
||||
if (!uprobe_perf_filter(&tu->consumer, current->mm))
|
||||
return UPROBE_HANDLER_REMOVE;
|
||||
|
||||
if (!is_ret_probe(tu))
|
||||
|
Loading…
Reference in New Issue
Block a user