lkml.org 
[lkml]   [2019]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] perf: Fix oops when kthread execs user process
    On Wed, May 29, 2019 at 02:55:57PM +0200, Peter Zijlstra wrote:
    > On Wed, May 29, 2019 at 11:20:22AM +0100, Will Deacon wrote:
    > > Anyway, you can add my ack to your patch, but I bet we can remove that mm
    > > check :D
    >
    > I've ended up with the below. Ravi, can you test if that does indeed
    > obsolete your PPC patch?
    >
    > ---
    > Subject: perf: Fix perf_sample_regs_user()
    > From: Peter Zijlstra <peterz@infradead.org>
    > Date: Wed May 29 14:37:24 CEST 2019
    >
    > perf_sample_regs_user() uses 'current->mm' to test for the presence of
    > userspace, but this is insufficient, consider use_mm().
    >
    > A better test is: '!(current->flags & PF_KTHREAD)', exec() clears
    > PF_KTHREAD after it sets the new ->mm but before it drops to userspace
    > for the first time.
    >
    > Possibly obsoletes: bf05fc25f268 ("powerpc/perf: Fix oops when kthread execs user process")
    >
    > Reported-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
    > Reported-by: Young Xiao <92siuyang@gmail.com>
    > Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
    > Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    > Cc: Michael Ellerman <mpe@ellerman.id.au>
    > Cc: Jiri Olsa <jolsa@redhat.com>
    > Cc: Frederic Weisbecker <fweisbec@gmail.com>
    > Cc: Stephane Eranian <eranian@google.com>
    > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    > Acked-by: Will Deacon <will.deacon@arm.com>
    > Fixes: 4018994f3d87 ("perf: Add ability to attach user level registers dump to sample")
    > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    > ---
    > kernel/events/core.c | 2 +-
    > 1 file changed, 1 insertion(+), 1 deletion(-)
    >
    > --- a/kernel/events/core.c
    > +++ b/kernel/events/core.c
    > @@ -5923,7 +5923,7 @@ static void perf_sample_regs_user(struct
    > if (user_mode(regs)) {

    Hmm, so it just occurred to me that Mark's observation is that the regs
    can be junk in some cases. In which case, should we be checking for
    kthreads first?

    Will

    \
     
     \ /
      Last update: 2019-05-29 15:06    [W:6.024 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site