Re: [PATCH v3 3/3] kernel/uprobes: Fix check for active uprobe
From: Oleg Nesterov
Date: Fri Sep 29 2017 - 12:54:33 EST
On 09/29, Srikar Dronamraju wrote:
>
> > This is correct because we do this check under mmap_sem so we can't race with
> > install_breakpoint(), so is_trap_at_addr() == T can't be falsely true if
> > UPROBE_COPY_INSN is not set.
> >
>
> Right, Given that we are doing this in the mmap_sem, we should also be
> removing the rmb/wmb pairs too.
Well, down_read(&mm->mmap_sem) can only guarantee that this mm can not be
modified by install_breakpoint().
But what if, say, another task with different ->mm does uprobe_mmap() and
calls prepare_uprobe() for the 1st time?
Or suppose we race with unregister+register...
OTOH, I agree that we can remove these barriers, but this needs a lengthy
comment while the current code looks "obviously correct" in that you do
not even need to think about potential races.
Oleg.