From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795982755; b=cdZT06CJPumRM7NxBnxh5BT6EeX17quwtcFnkFBTsz4cKwYTI60O8YjeRbF8f4fCYSO8 RU/j9mtoAgpQSdYIr5KwEhb0HiOFx1402CG8SbWZcXPEX4UZnCU3//T+hh6w3mrq8MKy4 SwxkVDJZXrobEMycbSIHWPLPsBzoOa9R6rFHr/JQxa6o/dig+swXsna8bagTh7Ef/jxof 51m1dVESYURfwu/+bhuxyXj+OBR6qhLsHYgwgaJeaVYMhbMD41K0fHb1BXfy5gVmKibOd VIiJF0OgU2UithUAL1oQG+LcVXDAliUi4SDPlN6lA7l21egoRAz2HjzP2jnLNONYyzQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795982755; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=+yKEirJMHczif1uMgKbSCqdCsyHx3CF0SipMYo95tLM=; b=unWNwvIfAZyphWesWWZgAevQFgzRikS67o4cTYw7U19CzYG0GRhHoPisY9ZJQ6bSVcjO 2aYXg1DKYBa9PmtqxqN1QTC4QTNHVbjuufFFOteJBYJUdu61Jfy8ig668RTj44BwvZMLJ H/IJ23BgDKeSBhQrtwDORjkLz/r53hf4jFedTJ/EDmEwyb05zcv6b+5RTmf7jEP3CGEn1 vzW1qApIwaUraLe3iOnHcOoE1KFpaSJ1sq6+1y74MEqTbwPvdjd6L0ZjkCrXyW0IJqVwc aWnnYYZS4ZUz9FmgPonq4WHGAOgYAPRMJ8y5uxHnlytM9QwONHe2JSyiKUdZU6UllNw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=G9cVfFWy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F17B606A31C for ; Sun, 29 Nov 2026 20:05:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=G9cVfFWy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 846D11F00898; Sun, 29 Nov 2026 20:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795982754; bh=+yKEirJMHczif1uMgKbSCqdCsyHx3CF0SipMYo95tLM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=G9cVfFWy1jel8isqeohu5cVjJQ4tGQy3URk0dsAhyF3XDUhlPYSIwIf3awwvkzFRe J4GBprxozxbCA/AOtdS+HPl4rvmlwHfstf6U7dImN8vdwx5KG+3aH8oFGQ83Vlt0l1 gzNPjdbBLn2NmhZZWDuxndR3dNU71LjV4FuqmlrSavy7uEA4DDFG65yniTsFjsyT2N XozxsvsBQhhOe1/RtNDnu7QbPzDY2dyXhKdVntgQuZzzMDcIx/O/RIhNxFaXJOh8Ie 9ps7FrO7TZa44a9MBxZh9GahaK5dBSQ53cqNwm5kQc57kUCwJTP2E5f8y4vHrXmXY9 Kx2F+v+rbry/w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] perf/arm_brbe: fix shift-out-of-bounds in brbinf_get_cycles() Reply-To: sashiko-reviews@lists.linux.dev To: "Sawan H N" Cc: linux-perf-users@vger.kernel.org In-Reply-To: <20261129200217.3193798-1-sawan.n@oss.qualcomm.com> References: <20261129200217.3193798-1-sawan.n@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 20:05:54 +0000 X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > brbinf_get_cycles() computes (mant | 0x100) << (exp - 1) in a u32, but > CC_EXP is a 6-bit field, so the shift can reach 62. Shifting by 32 or > more is undefined: UBSAN reports it during "perf record -j any", and > in practice the shift count wraps, so exp =3D=3D 33 yields a tiny cycle > count instead of a saturated one. >=20 > UBSAN: shift-out-of-bounds in drivers/perf/arm_brbe.c:200:26 > shift exponent 62 is too large for 32-bit type 'unsigned int' >=20 > Since (mant | 0x100) is 9 bits, the result exceeds U16_MAX once > exp >=3D 9. Return U16_MAX for that case before shifting, which bounds > the shift to 7 on the remaining path. The min() clamp is then > redundant and is dropped. Decoding for exp < 9 is unchanged. >=20 > Fixes: 58074a0fce66 ("perf: arm_pmuv3: Add support for the Branch Record = Buffer Extension (BRBE)") > Cc: stable@vger.kernel.org # 6.17+ > Signed-off-by: Sawan H N Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129200217.3193= 798-1-sawan.n@oss.qualcomm.com?part=3D1