From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29116376A0C; Wed, 20 May 2026 17:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779298710; cv=none; b=aXn7++bbqCWLhtF+2Pd/oLTNPnMq4uFkjj8GuHsCxgWOSb1eA4v/vjN/uC4R6Jdib+Kmhrdy+KHy6K9Ydq9c/tYDHR5mrRb3dzhW/RHRouwUmYsrmzUHlsCEixNb7j+X9c2ZOVZe3EfSeM8Kf1a7pXKFpPfcOKg9k0z9pIvj/q4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779298710; c=relaxed/simple; bh=12aYwnQGjDkOZyNXwGmHmNqaDjoLHUZkK76QSFE6rX4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a9PjcEqW1zPHvpuQdUGXUR+XzfjWlu7leqfvhVSo/gH3zzN961ns/yxuvySRIWToN7kCidD2cH4+rGEIgG2v+AvK0AM9BITvp8EQcW/UcXu+DvU/d3dNIR1RmwT+itkw5nYoD6mGDeoyxJ6JSrZZwR+/+o/zSusSYv10m/IbQf8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uXXQz50Y; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uXXQz50Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F4E41F000E9; Wed, 20 May 2026 17:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779298709; bh=iGYMJiELae5sqbHUxWbV77O7tmKIMxiTWzD8GdLVTYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uXXQz50YepRJahFjszu178rn7DK70aTIL3m+L9ur+cnF0tcskpTdd14koYHkvrOP8 AC7A1mPOJxgNYLjteDK5TrOhAiWZsFnQql+W2l+5Jaj31vZXARTS/VIQGYR4nkhnAR dWu2Jb0yxV1FyDUizSBxbzDd8pFS+InM9JzNfdl0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Leo Yan , Ian Rogers , Namhyung Kim , Sasha Levin Subject: [PATCH 6.18 513/957] perf expr: Return -EINVAL for syntax error in expr__find_ids() Date: Wed, 20 May 2026 18:16:36 +0200 Message-ID: <20260520162145.661939301@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162134.554764788@linuxfoundation.org> References: <20260520162134.554764788@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Leo Yan [ Upstream commit 3a61fd866ef9aaa1d3158b460f852b74a2df07f4 ] expr__find_ids() propagates the parser return value directly. For syntax errors, the parser can return a positive value, but callers treat it as success, e.g., for below case on Arm64 platform: metric expr 100 * (STALL_SLOT_BACKEND / (CPU_CYCLES * #slots) - BR_MIS_PRED * 3 / CPU_CYCLES) for backend_bound parsing metric: 100 * (STALL_SLOT_BACKEND / (CPU_CYCLES * #slots) - BR_MIS_PRED * 3 / CPU_CYCLES) Failure to read '#slots' literal: #slots = nan syntax error Convert positive parser returns in expr__find_ids() to -EINVAL, as a result, the error value will be respected by callers. Before: perf stat -C 5 Failure to read '#slots'Failure to read '#slots'Failure to read '#slots'Failure to read '#slots'Segmentation fault After: perf stat -C 5 Failure to read '#slots'Cannot find metric or group `Default' Fixes: ded80bda8bc9 ("perf expr: Migrate expr ids table to a hashmap") Signed-off-by: Leo Yan Reviewed-by: Ian Rogers Signed-off-by: Namhyung Kim Signed-off-by: Sasha Levin --- tools/perf/util/expr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c index 7fda0ff89c168..0893c88a4ef83 100644 --- a/tools/perf/util/expr.c +++ b/tools/perf/util/expr.c @@ -376,7 +376,8 @@ int expr__find_ids(const char *expr, const char *one, if (one) expr__del_id(ctx, one); - return ret; + /* A positive value means syntax error, convert to -EINVAL */ + return ret > 0 ? -EINVAL : ret; } double expr_id_data__value(const struct expr_id_data *data) -- 2.53.0