On 5/5/2026 2:17 PM, Jens Remus wrote:
> From: Josh Poimboeuf <[email protected]>
>
> Add a debug feature to validate all .sframe sections when first loading
> the file rather than on demand.
>
> [ Jens Remus: Add support for SFrame V3. Add support for PC-relative
> FDE function start offset. Adjust to rename of struct sframe_fre to
> sframe_fre_internal. Use %#x/%#lx format specifiers. ]
> diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c
> +static int safe_read_fde(struct sframe_section *sec,
> + unsigned int fde_num, struct sframe_fde_internal *fde)
> +{
> + int ret;
> +
> + if (!user_read_access_begin((void __user *)sec->sframe_start,
> + sec->sframe_end - sec->sframe_start))
> + return -EFAULT;
> + ret = __read_fde(sec, fde_num, fde);
> + user_read_access_end();
> + return ret;
> +}
> +static int sframe_validate_section(struct sframe_section *sec)
> +{
> + unsigned long prev_ip = 0;
> + unsigned int i;
> +
> + for (i = 0; i < sec->num_fdes; i++) {
> + struct sframe_fre_internal *fre, *prev_fre = NULL;
> + unsigned long ip, fre_addr;
> + struct sframe_fde_internal fde;
> + struct sframe_fre_internal fres[2];
> + bool which = false;
> + unsigned int j;
> + int ret;
> +
> + ret = safe_read_fde(sec, i, &fde);
Iterating over all FDEs may cause __read_fde() and thus safe_read_fde()
to fail if one sframe section covers multiple text sections (regardless
of whether it is also registered for multiple text sections), as
__read_fde() checks whether the read FDE function start address is
within [sec->text_start, sec->text_end[.
See my related comments in my reply to [PATCH v14 05/19] unwind_user/
sframe: Add support for reading .sframe contents.
> + if (ret) {
> + dbg_sec("safe_read_fde(%u) failed\n", i);
> + return ret;
> + }
> +
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/