On 1/27/2026 4:05 PM, Jens Remus wrote:
> From: Josh Poimboeuf <[email protected]>
> 
> In preparation for using sframe to unwind user space stacks, add an
> sframe_find() interface for finding the sframe information associated
> with a given text address.
> 
> For performance, use user_read_access_begin() and the corresponding
> unsafe_*() accessors.  Note that use of pr_debug() in uaccess-enabled
> regions would break noinstr validation, so there aren't any debug
> messages yet.  That will be added in a subsequent commit.
> 
> Link: 
> https://lore.kernel.org/all/77c0d1ec143bf2a53d66c4ecb190e7e0a576fbfd.1737511963.git.jpoim...@kernel.org/
> Link: 
> https://lore.kernel.org/all/[email protected]/
> 
> [ Jens Remus: Add initial support for SFrame V3 (limited to regular
> FDEs).  Add support for PC-relative FDE function start offset.  Simplify
> logic by using an internal FDE representation.  Rename struct sframe_fre
> to sframe_fre_internal to align with struct sframe_fde_internal.
> Cleanup includes.  Fix checkpatch errors "spaces required around that
> ':'". ]

> diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c

> +static __always_inline int __read_fde(struct sframe_section *sec,
> +                                   unsigned int fde_num,
> +                                   struct sframe_fde_internal *fde)
> +{
> +     unsigned long fde_addr, fda_addr, func_addr;
> +     struct sframe_fde_v3 _fde;
> +     struct sframe_fda_v3 _fda;
> +
> +     fde_addr = sec->fdes_start + (fde_num * sizeof(struct sframe_fde_v3));
> +     unsafe_copy_from_user(&_fde, (void __user *)fde_addr,
> +                           sizeof(struct sframe_fde_v3), Efault);
> +
> +     func_addr = fde_addr + _fde.func_start_off;
> +     if (func_addr < sec->text_start || func_addr > sec->text_end)

sec->text_end points after the last byte of the .text section.
Therefore the check for whether FDE function start address is within the
section must be:

        if (func_addr < sec->text_start || func_addr >= sec->text_end)

> +             return -EINVAL;

Regards,
Jens
-- 
Jens Remus
Linux on Z Development (D3303)
[email protected] / [email protected]

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/


Reply via email to