Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757410Ab3FMOUf (ORCPT ); Thu, 13 Jun 2013 10:20:35 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:43252 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751483Ab3FMOUd (ORCPT ); Thu, 13 Jun 2013 10:20:33 -0400 Date: Thu, 13 Jun 2013 16:20:28 +0200 From: Frederic Weisbecker To: Oleg Nesterov Cc: Vince Weaver , linux-kernel@vger.kernel.org, Peter Zijlstra , Paul Mackerras , Ingo Molnar , Arnaldo Carvalho de Melo , trinity@vger.kernel.org, Jiri Olsa Subject: Re: [PATCH 1/2] hw_breakpoint: Fix cpu check in task_bp_pinned(cpu) Message-ID: <20130613142026.GC16339@somewhere> References: <20130601182057.GA4861@redhat.com> <20130601182120.GB4861@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130601182120.GB4861@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2251 Lines: 60 On Sat, Jun 01, 2013 at 08:21:20PM +0200, Oleg Nesterov wrote: > trinity fuzzer triggered WARN_ONCE("Can't find any breakpoint slot") > in arch_install_hw_breakpoint() but the problem is not arch-specific. > > The problem is, task_bp_pinned(cpu) checks "cpu == iter->cpu" but > this doesn't account the "all cpus" events with iter->cpu < 0. > > This means that, say, register_user_hw_breakpoint(tsk) can happily > create the arbitrary number > HBP_NUM of breakpoints which can not > be activated. toggle_bp_task_slot() is equally wrong by the same > reason and nr_task_bp_pinned[] can have negative entries. > > Simple test: > > # perl -e 'sleep 1 while 1' & > # perf record -e mem:0x10,mem:0x10,mem:0x10,mem:0x10,mem:0x10 -p `pidof perl` > > Before this patch this triggers the same problem/WARN_ON(), after > the patch it correctly fails with -ENOSPC. > > Reported-by: Vince Weaver > Signed-off-by: Oleg Nesterov > Cc: Looks good, thanks! Acked-by: Frederic Weisbecker > --- > kernel/events/hw_breakpoint.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c > index ed1c897..29d3abe 100644 > --- a/kernel/events/hw_breakpoint.c > +++ b/kernel/events/hw_breakpoint.c > @@ -120,7 +120,7 @@ static int task_bp_pinned(int cpu, struct perf_event *bp, enum bp_type_idx type) > list_for_each_entry(iter, &bp_task_head, hw.bp_list) { > if (iter->hw.bp_target == tsk && > find_slot_idx(iter) == type && > - cpu == iter->cpu) > + (iter->cpu < 0 || cpu == iter->cpu)) > count += hw_breakpoint_weight(iter); > } > > -- > 1.5.5.1 > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/