Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350085
b: refs/heads/master
c: 806a98b
h: refs/heads/master
i:
  350083: c7b02cd
v: v3
  • Loading branch information
Oleg Nesterov committed Feb 8, 2013
1 parent 27994d5 commit baf02fc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 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: 66d06dffa5ef6f3544997440af63a91ef36a2171
refs/heads/master: 806a98bdf2a862fef0fc880399d677b35ba525ff
44 changes: 21 additions & 23 deletions trunk/kernel/events/uprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,15 +579,19 @@ static int prepare_uprobe(struct uprobe *uprobe, struct file *file,
return ret;
}

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

static bool filter_chain(struct uprobe *uprobe)
{
struct uprobe_consumer *uc;
bool ret = false;

down_read(&uprobe->consumer_rwsem);
for (uc = uprobe->consumers; uc; uc = uc->next) {
/* TODO: ret = uc->filter(...) */
ret = true;
ret = consumer_filter(uc);
if (ret)
break;
}
Expand All @@ -603,15 +607,6 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
bool first_uprobe;
int ret;

/*
* If probe is being deleted, unregister thread could be done with
* the vma-rmap-walk through. Adding a probe now can be fatal since
* nobody will be able to cleanup. But in this case filter_chain()
* must return false, all consumers have gone away.
*/
if (!filter_chain(uprobe))
return 0;

ret = prepare_uprobe(uprobe, vma->vm_file, mm, vaddr);
if (ret)
return ret;
Expand All @@ -636,12 +631,6 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
static int
remove_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, unsigned long vaddr)
{
if (!test_bit(MMF_HAS_UPROBES, &mm->flags))
return 0;

if (filter_chain(uprobe))
return 0;

set_bit(MMF_RECALC_UPROBES, &mm->flags);
return set_orig_insn(&uprobe->arch, mm, vaddr);
}
Expand Down Expand Up @@ -781,10 +770,14 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register)
vaddr_to_offset(vma, info->vaddr) != uprobe->offset)
goto unlock;

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

unlock:
up_write(&mm->mmap_sem);
Expand Down Expand Up @@ -968,9 +961,14 @@ int uprobe_mmap(struct vm_area_struct *vma)

mutex_lock(uprobes_mmap_hash(inode));
build_probe_list(inode, vma, vma->vm_start, vma->vm_end, &tmp_list);

/*
* We can race with uprobe_unregister(), this uprobe can be already
* removed. But in this case filter_chain() must return false, all
* consumers have gone away.
*/
list_for_each_entry_safe(uprobe, u, &tmp_list, pending_list) {
if (!fatal_signal_pending(current)) {
if (!fatal_signal_pending(current) &&
filter_chain(uprobe)) {
unsigned long vaddr = offset_to_vaddr(vma, uprobe->offset);
install_breakpoint(uprobe, vma->vm_mm, vma, vaddr);
}
Expand Down

0 comments on commit baf02fc

Please sign in to comment.