From nobody Wed Jun 17 05:11:44 2026 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76976359A74 for ; Thu, 23 Apr 2026 05:31:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776922276; cv=none; b=XGrTLb6rAUCDI3xFpLWCCGC0G80cS7BvgufLnDxomeR14ZPj1dTyCh4P2pML6nswDtJVhdQb9W37CBVtA6HLsOhRFXw2DKMWFDjJeOT2wd3N3AyyLsI9f2GG1m65Uv8UdrTSBW9Xkh5Dr6tMwz3OE2o9AvqF50u99ITO/dvcpWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776922276; c=relaxed/simple; bh=ixNZgL6I+s9Q7NnsT9wVdgFw1Ll16T9Sj/4u6fVFle8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JRloG882DUe2/5N2NZ4juacvedFreA3SQ3qRFcSyglRIE11QCPef97i5+E5/fYGmuYfNgE8qafL8ZmuZTnPDfYs/B+lx0eYamwYIp9QORjnY9mJBTn9sDub8ukEb8KD9c4Y3z717n5V3/McOSQQ6Y7DkIA7zawhefcTbfsg86BQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gB8YX9Iv; arc=none smtp.client-ip=209.85.215.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gB8YX9Iv" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-c7961d7bc09so2334047a12.1 for ; Wed, 22 Apr 2026 22:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776922275; x=1777527075; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=v/FD1FV0ffYsy3LxXhovkzmPDGgobrJWkZafkNu/+vQ=; b=gB8YX9IvCCfYnE2D/p+WBqgqZ9NCa1N3g91O+hKw604NwyqjScAzy9dADLgojN2YSM IAPl+SDOZVEu92i25NQAj/qNarF224YJKesS8050p5clv8Kh4xPOAvhtK2+qbmx6hyTl obdWLd6AcIihMLItsXao+i8Rou3TY3Se4fIMQx+cJoh5igbmMJIUh2wh95E/GIybr12B MJCvaCo8gNWRpA0ROH8YPurjLEMq59r5O3GqFzVN7eQhMMe+wRclJMKby4A5tli50iIm DVeL18opj6uraMjbJrOEn6hEY6BqNH97tmau2A5fQpVmkT8KAZu/f9HW2l0Af0sg+P4k +yzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776922275; x=1777527075; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=v/FD1FV0ffYsy3LxXhovkzmPDGgobrJWkZafkNu/+vQ=; b=q6wh1hab3mkZpJ7A0QIajk6uV9dD99KkBnYQ9h1ttnnkjGC6kMcilZMJivtXi9C/F1 U36F91hHfRw4gMwHsghKHI39jbluSHpOLstyq717pFTNCt3XOjqOUq2QW7BvDd/gRXI2 ZGjxeRVnZzeXq8Fpe25jCA5oGrvYz/XE1sn7OzA88nXSvbew3b/cAfRe0WzuAukPwmN9 /V914lE3E+FGEXNlNmgHiO0ewq81zAO+Y72HdEzgTzEFxJyN3r3JRR6u3aVeu1TRiA62 IVPjJxb44AfoixhInaw7QwRhYoqH1Svn/lcy/tS3boobuMrIXpITipI7cdR3lOwfAmF4 FspA== X-Forwarded-Encrypted: i=1; AFNElJ/Xmgin+zYtmu4LmPiykup2+CyeXhoFqVDtBR0qPi6YoNGGLHbsyXiTYu5dNN3rQBFAeO/IRTNYKt5JKYw=@vger.kernel.org X-Gm-Message-State: AOJu0YzlKtRleNsPkXYPAvG8BIlfLEtvgIVEXGWVoLd79hrxJo8NTDen e8YD80ui5se/3Gr5N8hhmyL+pdYeC5QNQCO3zdeGZF43hNmbLIBne7u7 X-Gm-Gg: AeBDievrQ9b0sQ0JeXoXWkPfviyoF/5SeuiU0Rc6ZhonpGc62UjpM6US/wNhbf1HxnT wflNPeHR4FOECyIUrG+77wv56bj1qBN6zEFpx3j/MBzRLMLvxp1z7YAUZqlPGFiYT3slKB2aWD4 zZShBCCW53F2Sakb+I/dBfqY/kJC/tcEVyjjbtnkOslnykO/Ub3uZmFWpdkLI1J3aTcO93ohaUs L3JpKWEeWlx4qWdNFtHHG9byaFeKbe/XwDzhcKWfbvdVL8mnyewNwxpBnIvRvVDsZR8MeJT++uh aDVIxhyvRTtrtrq63wsj2irwnuntoEWKrtVFt0ZM9PpFQFvcXq3IP2EMWkupd4mvIaTDCdzy9CG ij412xO3q8F9PiGDBQHiMPvqz87ahuHb6SmQfob2H0ptbNQJ0X5gZh1LaLlZ3SF7u/XRjv1Fduv tdNdUOaV0TgIow2JdV939WPJm0ySg5HZFsvgx7tay6+aPwlOfAl5ol4Q== X-Received: by 2002:a05:6a20:938e:b0:398:7ca0:43a9 with SMTP id adf61e73a8af0-3a08d89fa06mr25628629637.36.1776922274709; Wed, 22 Apr 2026 22:31:14 -0700 (PDT) Received: from localhost.localdomain ([14.22.11.165]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8ea09914sm18576129b3a.26.2026.04.22.22.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 22:31:14 -0700 (PDT) From: Jianping Liu To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, wangming01@loongson.cn, wangrui@loongson.cn, frankljpliu@gmail.com Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Jianping Liu Subject: [PATCH] perf annotate: Fix NULL pointer dereference in loongarch_call__parse Date: Thu, 23 Apr 2026 13:31:02 +0800 Message-ID: <20260423053102.3717015-1-frankljpliu@gmail.com> X-Mailer: git-send-email 2.43.7 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" loongarch_call__parse() dereferences the return value of strchr() without NULL check: name =3D strchr(endptr, '<'); name++; When objdump output for a 'bl' (branch-and-link) instruction does not contain a symbol name delimited by '<' and '>' (e.g., when the call target has no associated symbol), strchr() returns NULL, and the subsequent name++ produces a wild pointer (0x1). This leads to a segmentation fault when strchr() is later called with this invalid pointer: #0 __strchr_lasx () from /lib64/libc.so.6 #1 loongarch_call__parse () at arch/loongarch/annotate/instructions.c:29 #2 disasm_line__init_ins () at util/annotate.c:1205 ... The objdump line triggering the crash looks like: bl 98824 # 0x9000000000641ea0 Note the absence of "" after the address. Add a NULL check for the return value of strchr() before dereferencing it, consistent with s390_call__parse() which handles the same case correctly. Fixes: 4ca0d340ce20 ("perf annotate: Fix instruction association and parsin= g for LoongArch") Signed-off-by: Jianping Liu Reviewed-by: Ming Wang --- tools/perf/util/annotate-arch/annotate-loongarch.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/annotate-arch/annotate-loongarch.c b/tools/per= f/util/annotate-arch/annotate-loongarch.c index c2addca77320..0179062a6cf9 100644 --- a/tools/perf/util/annotate-arch/annotate-loongarch.c +++ b/tools/perf/util/annotate-arch/annotate-loongarch.c @@ -29,6 +29,9 @@ static int loongarch_call__parse(const struct arch *arch,= struct ins_operands *o ops->target.addr =3D strtoull(c, &endptr, 16); =20 name =3D strchr(endptr, '<'); + if (name =3D=3D NULL) + return -1; + name++; =20 if (arch->objdump.skip_functions_char && --=20 2.43.7