Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp461766rdb; Fri, 6 Oct 2023 08:30:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaDt7ha/Rs1CtNZ4Ufm2Aclk3IVsP2mp8fkBOXK52TPvMTcdNyp+gmO9Lar6KBrx7W9adk X-Received: by 2002:a17:90a:dc0c:b0:268:5c3b:6f37 with SMTP id i12-20020a17090adc0c00b002685c3b6f37mr8283942pjv.0.1696606224138; Fri, 06 Oct 2023 08:30:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696606224; cv=none; d=google.com; s=arc-20160816; b=qUjv20a8fK5D/tUc0/pDfY1gwkMKxeLZIoJgcXCxAITnWu1AiUUFDhBAuuzMAlvOJX Nyy9jFDCgm0KTRpFeAZdo8UgYUR14MhdNWJNlUje1c7fNjp39hY/Svp110Or5fae64RP CJEtLD4qJIMVwsuJVw0TC6RXDuqvcQ5AUU1llvc7sDYCcjasqMZ5sNB5ojEAz6nyNeY1 0G2wMs3OuRlrNDCvSIeIN6dtAk6eVokSxW9gdhnDRPUCB9QdMNO+99lOeJ1SAiuIgy9N /Ufvi92SrCNkT0KFOVT99pz/Ri+55oOqIRbOwWqBw50oqIyYLx47l8VFRc9BxzEPOqK0 Upvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:to:subject:message-id :date:from:in-reply-to:references:mime-version:dkim-signature; bh=ry4Fisj82tQviAwEIuy3+xbA50llOUgd81Tf+MVIXSY=; fh=g6J60yFS+s7DNa1xGru9lVu0df4NEut8v+W9s8pQuAs=; b=eACdyDrzcE8/opydicoPIBSarDP8inIkGXyJROGBzvL7Mx2LhvluXpdYMwRJq68Yqb eUldqgS5O6cC32dVMoZBhKex5uvnPGL5aoloBrPSq4gdTFRYOkkbT2xkHKvplVZZ0872 8mLTMROg1PnvktA1+wX9sFv/ULZoerEpi08veVe00EzmudHJh7DA5JEukvoT7GbCqBBf j7Gig7NEID2dkDn4F6XcBnFyrzWpXIR22oogTjuvf3QGxgdWFeOKXlwY9lrydYhldo1+ rYcsUgaCGri+Wf2wM1ffOezIAswFacT2jDkYJtXB8sJOUeaweozR7Y90D8eSRFtO//6W WJsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hTz0IABK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id v4-20020a17090ad58400b0027728f01512si3893779pju.167.2023.10.06.08.30.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 08:30:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hTz0IABK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3F87D8074512; Fri, 6 Oct 2023 08:30:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232787AbjJFPaH (ORCPT + 99 others); Fri, 6 Oct 2023 11:30:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232718AbjJFPaF (ORCPT ); Fri, 6 Oct 2023 11:30:05 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC29C9E for ; Fri, 6 Oct 2023 08:30:03 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-50348c54439so4345e87.1 for ; Fri, 06 Oct 2023 08:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696606202; x=1697211002; darn=vger.kernel.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ry4Fisj82tQviAwEIuy3+xbA50llOUgd81Tf+MVIXSY=; b=hTz0IABKAeiP3jVS10Yhx1un+rRamyNOfOoWTUrZjHcnkkG5bF9ZXymbBGnOtRDnKL kxC2IglomMx9ox7blLRzbPhjDu875aghVrtQSPEpXoCPmqL45ay0QkGEKDqwkzT1RrNC 1MB8diRC93itTb3pDHClBPWDrwbzMUJT/AEOQycEaDkuDfviZ2YIv0MW75gBH3N4p8y/ HYpgniINyHt1DAMmtRDSXkS6TRDCShstT3yU+/UzRogslW+PqbU2dytIIQ4LqawH16Id c62A7Ei6y/LLXS61j6zl5OSwcKiVh9keNyCLuxa4c7VdIk51zgPMqIkqO8dmriqw8jdJ 8bCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696606202; x=1697211002; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ry4Fisj82tQviAwEIuy3+xbA50llOUgd81Tf+MVIXSY=; b=XEoJNADtpe5ds8KZdwIm60tKR8rlib1kfN0P6T0FYiuuSW8TlMJggP5IKytS5rYoJT bhUSaK9W4Nxdto0aL78lldUCLEWsk9a8cpaLxbbebWJi+88PNlihQfnaaxE2Ua9jK8rJ 5Xf6Idl3Gj7KsGTJRpqb+FUPjT1wP37sPCEeOorA1BZvmE3SjR6KZ+tiCn7C3WAZDbTR UpKgBsf9HWSTj6MyL4e+F/G/xVpeQW0ZQKnRQsDcB6ls7CYfGEfisT1K5ve/gBczP3hM t/5mW8PxYt8bNC5NdhE+XEqwoefTFKKJjXy47TxemU51MnZMUY5ZydOV6KPtjis83K1C hnKA== X-Gm-Message-State: AOJu0YwcJkB3OUMJNlXxHxWXL1+54dKEmZdP9XUKEg7WO5xlOEhUdGPl jiBh5JsIhZxPI6/JB4+aqD/UTu/KZJVDquZIGWnHZw== X-Received: by 2002:a05:6512:48f:b0:505:6e12:9e70 with SMTP id v15-20020a056512048f00b005056e129e70mr133361lfq.6.1696606201784; Fri, 06 Oct 2023 08:30:01 -0700 (PDT) MIME-Version: 1.0 References: <20230907210533.3712979-1-irogers@google.com> In-Reply-To: <20230907210533.3712979-1-irogers@google.com> From: Ian Rogers Date: Fri, 6 Oct 2023 08:29:47 -0700 Message-ID: Subject: Re: [PATCH v1] perf parse-events: Avoid erange from hex numbers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Rob Herring , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 06 Oct 2023 08:30:16 -0700 (PDT) On Thu, Sep 7, 2023 at 2:05=E2=80=AFPM Ian Rogers wrot= e: > > We specify that a "num_hex" comprises 1 or more digits, however, that > allows strtoull to fail with ERANGE. Limit the number of hex digits to > being between 1 and 16. > > Before: > ``` > $ perf stat -e 'cpu/rE7574c47490475745/' true > perf: util/parse-events.c:215: fix_raw: Assertion `errno =3D=3D 0' failed= . > Aborted (core dumped) > ``` > > After: > ``` > $ perf stat -e 'cpu/rE7574c47490475745/' true > event syntax error: 'cpu/rE7574c47490475745/' > \___ Bad event or PMU > > Unable to find PMU or event on a PMU of 'cpu' > > Initial error: > event syntax error: 'cpu/rE7574c47490475745/' > \___ unknown term 'rE7574c47490475745' for pmu '= cpu' > > valid terms: event,pc,edge,offcore_rsp,ldlat,inv,umask,frontend,cmask,con= fig,config1,config2,config3,name,period,percore,metric-id > Run 'perf list' for a list of valid events > > Usage: perf stat [] [] > > -e, --event event selector. use 'perf list' to list availab= le events > ``` > > Issue found through fuzz testing. > > Signed-off-by: Ian Rogers Hi, would be nice to land this. Thanks! Ian > --- > tools/perf/util/parse-events.l | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-event= s.l > index 4ef4b6f171a0..f7df52b22c39 100644 > --- a/tools/perf/util/parse-events.l > +++ b/tools/perf/util/parse-events.l > @@ -156,8 +156,8 @@ event_pmu [^,{}/]+[/][^/]*[/][^,{}/]* > event [^,{}/]+ > > num_dec [0-9]+ > -num_hex 0x[a-fA-F0-9]+ > -num_raw_hex [a-fA-F0-9]+ > +num_hex 0x[a-fA-F0-9]{1,16} > +num_raw_hex [a-fA-F0-9]{1,16} > name [a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!\-]* > name_tag [\'][a-zA-Z_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=3D]*[\'] > name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]* > -- > 2.42.0.283.g2d96d420d3-goog >