BPF List
 help / color / mirror / Atom feed
From: Jens Remus <jremus@linux.ibm.com>
To: Steven Rostedt <rostedt@kernel.org>,
	Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Indu Bhagat <ibhagatgnu@gmail.com>,
	bpf@vger.kernel.org, sashiko@lists.linux.dev,
	Heiko Carstens <hca@linux.ibm.com>
Subject: Re: [PATCH v14 05/19] unwind_user/sframe: Add support for reading .sframe contents
Date: Tue, 12 May 2026 15:35:09 +0200	[thread overview]
Message-ID: <5e7a8a95-fee6-42f7-9c17-a8c1684240ec@linux.ibm.com> (raw)
In-Reply-To: <20260506110142.7b2943d7@fedora>

On 5/6/2026 5:01 PM, Steven Rostedt wrote:
> On Wed, 6 May 2026 16:34:34 +0200
> Jens Remus <jremus@linux.ibm.com> wrote:
> 
>>>> +static __always_inline int __read_fre(struct sframe_section *sec,
>>>> +				      struct sframe_fde_internal *fde,
>>>> +				      unsigned long fre_addr,
>>>> +				      struct sframe_fre_internal *fre)
>>>> +{  
>>> [ ... ]  
>>>> +	if (fre_addr + addr_size + 1 > sec->fres_end)
>>>> +		return -EFAULT;
>>>> +
>>>> +	UNSAFE_GET_USER_INC(ip_off, cur, addr_size, Efault);  
>>>
>>> Will this cause alignment faults on architectures with strict alignment
>>> requirements?
>>>
>>> The .sframe format uses packed structures and variable-length datawords. The
>>> cur pointer might be unaligned here, and UNSAFE_GET_USER_INC() performs
>>> 16-bit or 32-bit reads via unsafe_get_user().  
>>
>> IIUC this should not be an issue for x86-64, s390, and arm64.
> 
> Do we have a way to make sure that sframe support will always be for
> architectures that can handle alignment issues like this? There should
> be something to force this via configs or something that will trigger a
> warning or bug if this is built for architectures that can't handle
> this alignment.

Config option HAVE_EFFICIENT_UNALIGNED_ACCESS seems to be the one that
is used for exactly this purpose.


IIUC config options that get selected should not depend on.  So the
following would not be ok, although it seems to work?

diff --git a/arch/Kconfig b/arch/Kconfig
@@ -495,6 +495,8 @@ config HAVE_UNWIND_USER_FP

 config HAVE_UNWIND_USER_SFRAME
	bool
+	depends on 64BIT
+	depends on HAVE_EFFICIENT_UNALIGNED_ACCESS
	select UNWIND_USER

 config SFRAME_VALIDATION

This would trigger a warning if HAVE_UNWIND_USER_SFRAME is enabled when
64BIT and/or HAVE_EFFICIENT_UNALIGNED_ACCESS are not enabled (disabled
on purpose for testing below):

$ PATH=$HOME/temp/binutils-sframe/bin:$PATH make defconfig W=e
*** Default configuration is based on 'defconfig'

WARNING: unmet direct dependencies detected for HAVE_UNWIND_USER_SFRAME
  Depends on [n]: 64BIT [=y] && HAVE_EFFICIENT_UNALIGNED_ACCESS [=n]
  Selected by [y]:
  - S390 [=y]


Shall I better use BUILD_BUG_ON(!IS_ENABLED(CONFIG_...)) instead?  Would
I add that to all functions that are affected (i.e. __read_fre(),
__read_default_fre_datawords(), and __read_flex_fde_fre_datawords()),
duplicating the build-time error message, or would I better introduce a
dummy function to check this precondition (and 64-bit arch), for
instance:

diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c
@@ -886,3 +904,20 @@ void sframe_free_mm(struct mm_struct *mm)

        mtree_destroy(&mm->sframe_mt);
 }
+
+void __init sframe_check(void);
+
+/*
+ * Dummy function to break the build if preconditions not met.
+ */
+void __init sframe_check(void)
+{
+       /* SFrame V3 is only supported on 64-bit architectures */
+       BUILD_BUG_ON(!IS_ENABLED(CONFIG_64BIT));
+
+       /*
+        * Unaligned access to 16/32-bit SFrame FRE fields and datawords
+        * using unsafe_get_user() via UNSAFE_GET_USER_INC()
+        */
+       BUILD_BUG_ON(!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS));
+}

Thanks and regards,
Jens
-- 
Jens Remus
Linux on Z Development (D3303)
jremus@de.ibm.com / jremus@linux.ibm.com

IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Ehningen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/


  parent reply	other threads:[~2026-05-12 13:35 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-05 12:16 [PATCH v14 00/19] unwind_deferred: Implement sframe handling Jens Remus
2026-05-05 12:17 ` [PATCH v14 01/19] unwind_user: Add generic and arch-specific headers to MAINTAINERS Jens Remus
2026-05-05 12:17 ` [PATCH v14 02/19] unwind_user/sframe: Add support for reading .sframe headers Jens Remus
2026-05-05 12:49   ` sashiko-bot
2026-05-06 13:42     ` Jens Remus
2026-05-07 14:55       ` Jens Remus
2026-05-08 23:02       ` Indu Bhagat
2026-05-11 10:05         ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 03/19] unwind_user/sframe: Store .sframe section data in per-mm maple tree Jens Remus
2026-05-05 18:51   ` sashiko-bot
2026-05-06 13:50     ` Jens Remus
2026-05-06 15:21       ` Steven Rostedt
2026-05-12 15:52         ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 04/19] x86/uaccess: Add unsafe_copy_from_user() implementation Jens Remus
2026-05-05 18:22   ` sashiko-bot
2026-05-06 14:13     ` Jens Remus
2026-05-06 15:05       ` Steven Rostedt
2026-05-06 14:09   ` Jens Remus
2026-05-06 15:03     ` Steven Rostedt
2026-05-06 21:13     ` David Laight
2026-05-06 21:17       ` David Laight
2026-05-05 12:17 ` [PATCH v14 05/19] unwind_user/sframe: Add support for reading .sframe contents Jens Remus
2026-05-05 18:59   ` sashiko-bot
2026-05-06 14:34     ` Jens Remus
2026-05-06 15:01       ` Steven Rostedt
2026-05-06 15:29         ` Jens Remus
2026-05-08  9:49         ` Jens Remus
2026-05-08 23:04           ` Indu Bhagat
2026-05-12 13:35         ` Jens Remus [this message]
2026-05-13 12:22           ` Steven Rostedt
2026-05-08 23:03       ` Indu Bhagat
2026-05-08 10:50   ` Jens Remus
2026-05-11 16:16   ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 06/19] unwind_user/sframe: Detect .sframe sections in executables Jens Remus
2026-05-05 12:53   ` sashiko-bot
2026-05-06 14:56     ` Jens Remus
2026-05-06 15:36       ` Steven Rostedt
2026-05-08 23:05         ` Indu Bhagat
2026-05-05 12:17 ` [PATCH v14 07/19] unwind_user/sframe: Wire up unwind_user to sframe Jens Remus
2026-05-05 18:55   ` sashiko-bot
2026-05-07 16:18     ` Jens Remus
2026-05-08 23:07       ` Indu Bhagat
2026-05-11 16:46         ` Steven Rostedt
2026-05-05 12:17 ` [PATCH v14 08/19] unwind_user: Stop when reaching an outermost frame Jens Remus
2026-05-05 12:40   ` sashiko-bot
2026-05-06 15:01     ` Jens Remus
2026-05-06 15:40       ` Steven Rostedt
2026-05-05 12:17 ` [PATCH v14 09/19] unwind_user/sframe: Add support for outermost frame indication Jens Remus
2026-05-05 12:17 ` [PATCH v14 10/19] unwind_user/sframe: Remove .sframe section on detected corruption Jens Remus
2026-05-05 20:39   ` sashiko-bot
2026-05-07 16:23     ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 11/19] unwind_user/sframe: Show file name in debug output Jens Remus
2026-05-05 18:46   ` sashiko-bot
2026-05-12 14:52     ` Jens Remus
2026-05-13  9:20       ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 12/19] unwind_user/sframe: Add .sframe validation option Jens Remus
2026-05-05 18:32   ` sashiko-bot
2026-05-12 14:23     ` Jens Remus
2026-05-13 12:30       ` Steven Rostedt
2026-05-08 10:51   ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 13/19] unwind_user: Enable archs that pass RA in a register Jens Remus
2026-05-05 18:35   ` sashiko-bot
2026-05-05 12:17 ` [PATCH v14 14/19] unwind_user: Flexible FP/RA recovery rules Jens Remus
2026-05-05 18:34   ` sashiko-bot
2026-05-05 12:17 ` [PATCH v14 15/19] unwind_user: Flexible CFA " Jens Remus
2026-05-05 12:17 ` [PATCH v14 16/19] unwind_user/sframe: Add support for SFrame V3 flexible FDEs Jens Remus
2026-05-05 18:55   ` sashiko-bot
2026-05-07 15:30     ` Jens Remus
2026-05-13  6:26       ` Indu Bhagat
2026-05-13 13:50         ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 17/19] unwind_user/sframe: Separate reading of FRE from reading of FRE data words Jens Remus
2026-05-05 19:05   ` sashiko-bot
2026-05-07 16:01     ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 18/19] unwind_user/sframe/x86: Enable sframe unwinding on x86 Jens Remus
2026-05-05 19:07   ` sashiko-bot
2026-05-05 12:17 ` [PATCH v14 19/19] unwind_user/sframe: Add prctl() interface for registering .sframe sections Jens Remus
2026-05-05 18:45   ` sashiko-bot
2026-05-07 14:14     ` Jens Remus
2026-05-05 12:25 ` [PATCH v14 00/19] unwind_deferred: Implement sframe handling Jens Remus

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=5e7a8a95-fee6-42f7-9c17-a8c1684240ec@linux.ibm.com \
    --to=jremus@linux.ibm.com \
    --cc=bpf@vger.kernel.org \
    --cc=hca@linux.ibm.com \
    --cc=ibhagatgnu@gmail.com \
    --cc=jpoimboe@kernel.org \
    --cc=rostedt@kernel.org \
    --cc=sashiko@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