Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350086
b: refs/heads/master
c: 8a7f2fa
h: refs/heads/master
v: v3
  • Loading branch information
Oleg Nesterov committed Feb 8, 2013
1 parent baf02fc commit 7e68085
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 806a98bdf2a862fef0fc880399d677b35ba525ff
refs/heads/master: 8a7f2fa0dea3b019500961b86d765e6fdd4bffb2
9 changes: 9 additions & 0 deletions trunk/include/linux/uprobes.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,17 @@ struct inode;
# include <asm/uprobes.h>
#endif

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);
bool (*filter)(struct uprobe_consumer *self,
enum uprobe_filter_ctx ctx,
struct mm_struct *mm);

struct uprobe_consumer *next;
};
Expand Down
18 changes: 11 additions & 7 deletions trunk/kernel/events/uprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,19 +579,21 @@ static int prepare_uprobe(struct uprobe *uprobe, struct file *file,
return ret;
}

static inline bool consumer_filter(struct uprobe_consumer *uc)
static inline bool consumer_filter(struct uprobe_consumer *uc,
enum uprobe_filter_ctx ctx, struct mm_struct *mm)
{
return true; /* TODO: !uc->filter || uc->filter(...) */
return !uc->filter || uc->filter(uc, ctx, mm);
}

static bool filter_chain(struct uprobe *uprobe)
static bool filter_chain(struct uprobe *uprobe,
enum uprobe_filter_ctx ctx, 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);
ret = consumer_filter(uc, ctx, mm);
if (ret)
break;
}
Expand Down Expand Up @@ -772,10 +774,12 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register)

if (is_register) {
/* consult only the "caller", new consumer. */
if (consumer_filter(uprobe->consumers))
if (consumer_filter(uprobe->consumers,
UPROBE_FILTER_REGISTER, mm))
err = install_breakpoint(uprobe, mm, vma, info->vaddr);
} else if (test_bit(MMF_HAS_UPROBES, &mm->flags)) {
if (!filter_chain(uprobe))
if (!filter_chain(uprobe,
UPROBE_FILTER_UNREGISTER, mm))
err |= remove_breakpoint(uprobe, mm, info->vaddr);
}

Expand Down Expand Up @@ -968,7 +972,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)) {
filter_chain(uprobe, UPROBE_FILTER_MMAP, vma->vm_mm)) {
unsigned long vaddr = offset_to_vaddr(vma, uprobe->offset);
install_breakpoint(uprobe, vma->vm_mm, vma, vaddr);
}
Expand Down

0 comments on commit 7e68085

Please sign in to comment.