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 [off-list 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.
quoted hunk ↗ jump to hunk
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
[ ... ]
quoted hunk ↗ jump to hunk
@@ -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)
+{
[ ... ]
quoted hunk ↗ jump to hunk
+}
+
+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?
quoted hunk ↗ jump to hunk
+ 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