Linux Perf Users
 help / color / mirror / Atom feed
From: Stian Halseth <stian@itx.no>
To: sashiko-reviews@lists.linux.dev
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf unwind-libdw: Fix reading the stack of a 32-bit task
Date: Wed, 23 Sep 2026 22:29:03 +0200	[thread overview]
Message-ID: <7d5c0a2bef048b885e389f53baecd3c083df9b26.camel@itx.no> (raw)
In-Reply-To: <20260923194534.C89B71F000FF@smtp.kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1383 bytes --]

On Wed, 2026-09-23 at 19:45 +0000, sashiko-bot@kernel.org wrote:
> 
> [Severity: Low]
> Does this bitwise logic truncate the offset to a 4-byte boundary?

Yes, it does, but only for an address that isn't 4-byte aligned, and I
don't think that can happen here.

libdw only uses memory_read() to restore registers, and the save slots
are always word-aligned on a 32-bit ABI.

In theory, a malformed CFI could ask for one, though. But if that were
the case, the read would stay inside the stack dump, and the unwind
would be wrong either way. On a strict-alignment machine like sparc,
the native reads would trap on such an address as well.

I'd rather avoid adding handling for a case that shouldn't occur, butif preferred, I can make the swapped case refuse an unaligned read 
instead of returning the aligned word.
> 
> If a DWARF CFI expression requests a stack read at an unaligned
> address
> during cross-endian unwinding, the calculation discards the unaligned
> bits.
> 
> While register unwinding typically targets 4-byte aligned addresses
> on
> 32-bit architectures, could a malformed or custom ELF with non-
> standard
> CFI trigger an unaligned read? If so, would this extract the wrong
> bytes
> instead of the requested data, potentially corrupting the unwind
> results?
> 
> > +	return bswap_32(u.val32[(offset & 4) / 4]);
> > +}
> 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-09-23 20:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 19:34 [PATCH] perf unwind-libdw: Fix reading the stack of a 32-bit task Stian Halseth
2026-09-23 19:45 ` sashiko-bot
2026-09-23 20:29   ` Stian Halseth [this message]
2026-09-23 20:33 ` Ian Rogers
2026-09-24 17:08   ` Arnaldo Carvalho de Melo

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=7d5c0a2bef048b885e389f53baecd3c083df9b26.camel@itx.no \
    --to=stian@itx.no \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox