All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sawan H N" <sawan.n@oss.qualcomm.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf/arm_brbe: fix shift-out-of-bounds in brbinf_get_cycles()
Date: Sun, 29 Nov 2026 20:05:54 +0000	[thread overview]
Message-ID: <sashiko-outbox-239992@kernel.org> (raw)
In-Reply-To: <20261129200217.3193798-1-sawan.n@oss.qualcomm.com>

> 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 == 33 yields a tiny cycle
> count instead of a saturated one.
> 
>     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'
> 
> Since (mant | 0x100) is 9 bits, the result exceeds U16_MAX once
> exp >= 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.
> 
> 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 <sawan.n@oss.qualcomm.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261129200217.3193798-1-sawan.n@oss.qualcomm.com?part=1

      reply	other threads:[~2026-11-29 20:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 20:02 [PATCH] perf/arm_brbe: fix shift-out-of-bounds in brbinf_get_cycles() Sawan H N
2026-11-29 20:05 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-239992@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sawan.n@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.