# Re: \[RFC PATCH v2 15/24\] unwind\_user/eh\_frame: Duplicate registered .eh\_frame\[\_hdr\] section data on clone/fork

- From: sashiko-bot@kernel.org
- Date: 2026-08-21 20:09:50 
- List: linux-trace-kernel
- Page: https://ratatoskr.run/linux-trace-kernel/2026/08/17446976
- Thread: https://ratatoskr.run/linux-s390/2026/08/17446896/t.md

```text
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Blindly duplicating all eh_frame sections ignores VMA inheritance rules (e.g., VM_DONTCOPY), leading to stale unwinding data.
- [Medium] Mixing goto-based error handling with guard() cleanup in the same function.
--

--- Patch [15]: [RFC PATCH v2 15/24] unwind_user/eh_frame: Duplicate registered .eh_frame[_hdr] section data on clone/fork ---
commit cedc4c84b3351e03d89a9e7fc338f35818891c5a
Author: Jens Remus [ref]

unwind_user/eh_frame: Duplicate registered .eh_frame[_hdr] section data on clone/fork

When duplicating a process' virtual memory mappings also duplicate all
of its registered .eh_frame_hdr sections stored in the per-mm maple tree
to enable stacktracing using eh_frame of the child process.

> diff --git a/kernel/unwind/eh_frame.c b/kernel/unwind/eh_frame.c
> index b0be56e315080..1ac7308814a16 100644
> --- a/kernel/unwind/eh_frame.c
> +++ b/kernel/unwind/eh_frame.c
[ ... ]
> @@ -1501,6 +1501,54 @@ int eh_frame_remove_section(unsigned long eh_frame_hdr_start)
>  	return 0;
>  }
>  
> +static void __eh_frame_dup_section(struct eh_frame_section *sec,
> +				   struct eh_frame_section *oldsec)
> +{
[ ... ]
> +}
> +
> +int eh_frame_dup_mm(struct mm_struct *mm, struct mm_struct *oldmm)
> +{
> +	struct eh_frame_section *sec, *oldsec;
> +	unsigned long index = 0;
> +	int ret;
> +
> +	guard(srcu)(&eh_frame_srcu);

[Severity: Medium]
Is it acceptable to mix goto-based error handling with guard() in the same
function? The cleanup guidelines suggest converting all resources to
scope-based cleanup or none to avoid confusing ownership semantics.

> +
> +	mt_for_each(&oldmm->eh_frame_mt, oldsec, index, ULONG_MAX) {

[Severity: High]
Does this unconditionally duplicate all eh_frame sections from the parent
without checking if the underlying VMA was actually copied during the fork?

If a process sets a region to VM_DONTCOPY or VM_WIPEONFORK before forking,
the child won't inherit the VMA, but it appears it will still inherit
the eh_frame section here. If the child process later maps new executable
code at the same address, could the unwinder use the parent's stale rules?

> +		sec = kzalloc(sizeof(*sec), GFP_KERNEL_ACCOUNT);
> +		if (!sec)
> +			return -ENOMEM;
> +
> +		__eh_frame_dup_section(sec, oldsec);
> +
> +		ret = mtree_insert_range(&mm->eh_frame_mt,
> +					 sec->text_start,
> +					 sec->text_end - 1,
> +					 sec, GFP_KERNEL_ACCOUNT);
> +		if (ret)
> +			goto err_free;
> +	}
> +
> +	return 0;
> +
> +err_free:
> +	free_section(sec);
> +	return ret;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260821195259.2688377-1-jremus@linux.ibm.com?part=15
```
