Repository navigation
[Deepin-Kernel-SIG] [linux 6.6.y] [KABI] apply kabi fixes for 6.6.160-6.6.161 - #2267
Conversation
Reviewer's GuideData structuresKeep the futex identifier in reserved mm_struct storage without shifting the structure layout, with separate storage for 32-bit and 64-bit builds.
Preserve io_uring structure layouts while retaining the deferred poll-wake fields and relocated poll_refs counter.
Move needs_stable_writes to a KABI extension at the end of dm_target to avoid changing existing field layout.
Place perf_mlock at the end of user_struct through a KABI extension to preserve existing member offsets.
Hide unicode_map's RCU head in a KABI extension so its existing layout remains unchanged.
ImplementationCast the reserved futex identifier storage to atomic64_t at initialization and lookup sites so existing futex ID handling works with the new mm_struct layout.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="include/linux/mm_types.h" line_range="1061" />
<code_context>
} __randomize_layout;
+#ifdef CONFIG_FUTEX
+ DEEPIN_KABI_USE(1, 2, atomic64_t futex_unique_id)
+ DEEPIN_KABI_RESERVE(3)
+#else
</code_context>
<issue_to_address>
**32-bit futex builds fail**
When a 32-bit kernel is built with KABI reserves enabled and size/alignment checks active, `DEEPIN_KABI_USE` fails its size/alignment assertion because `atomic64_t` is larger or more aligned than the reserved slots. Without the checks, the field overruns its slot and shifts the remaining reserved layout, so the kernel build or ABI layout fails.
Reserve storage with sufficient size and alignment for `atomic64_t`, or avoid this replacement on affected 32-bit architectures.
</issue_to_address>
### Comment 2
<location path="include/linux/io_uring_types.h" line_range="367-368" />
<code_context>
/* deferred ->poll_wq wake up for local task_work */
- struct rcu_head poll_wq_rcu;
- atomic_t poll_wq_rcu_pending;
+ DEEPIN_KABI_EXTEND(struct rcu_head poll_wq_rcu)
+ DEEPIN_KABI_EXTEND(atomic_t poll_wq_rcu_pending)
struct list_head defer_list;
unsigned sq_thread_idle;
</code_context>
<issue_to_address>
**Older modules access shifted fields**
When an out-of-tree module built against the baseline layout accesses a later member of either struct, `DEEPIN_KABI_EXTEND` inserts runtime fields in the middle of the structs, and relocating `io_kiocb.poll_refs` also shifts later members; genksyms hides the additions, but the runtime offsets change, so the module reads or writes the wrong state and io_uring can fail or be corrupted.
Place the added fields at the ends of their structs, preserving the offsets of existing members.
Also at `include/linux/io_uring_types.h:594`.
</issue_to_address>| DEEPIN_KABI_EXTEND(struct rcu_head poll_wq_rcu) | ||
| DEEPIN_KABI_EXTEND(atomic_t poll_wq_rcu_pending) |
There was a problem hiding this comment.
🟠 High · Older modules access shifted fields
When an out-of-tree module built against the baseline layout accesses a later member of either struct, DEEPIN_KABI_EXTEND inserts runtime fields in the middle of the structs, and relocating io_kiocb.poll_refs also shifts later members; genksyms hides the additions, but the runtime offsets change, so the module reads or writes the wrong state and io_uring can fail or be corrupted.
Place the added fields at the ends of their structs, preserving the offsets of existing members.
Also at include/linux/io_uring_types.h:594.
Prompt for AI agents
In `include/linux/io_uring_types.h` at lines 367-368:
**Older modules access shifted fields**
When an out-of-tree module built against the baseline layout accesses a later member of either struct, `DEEPIN_KABI_EXTEND` inserts runtime fields in the middle of the structs, and relocating `io_kiocb.poll_refs` also shifts later members; genksyms hides the additions, but the runtime offsets change, so the module reads or writes the wrong state and io_uring can fail or be corrupted.
Place the added fields at the ends of their structs, preserving the offsets of existing members.
Also at `include/linux/io_uring_types.h:594`.There was a problem hiding this comment.
🟡 Changes recommended
Critical KABI issues remain: io_uring extensions shift existing member offsets, and the mm_types change fails the alignment assertion on 32-bit x86 with the relevant configuration enabled.
3 open issues
What changed in this PR
This PR applies Deepin kernel ABI compatibility adjustments for Linux 6.6.160–6.6.161 across several core structures.
Changes:
- Adds KABI extension and replacement annotations to recently changed fields.
- Relocates user-tracking and device-mapper fields to structure tails.
- Moves the memory-management futex identifier into reserved KABI slots.
| File | Description |
|---|---|
include/linux/unicode.h |
Marks the Unicode map’s RCU field as a KABI extension. |
include/linux/sched/user.h |
Moves perf_mlock to the structure tail and annotates it. |
include/linux/mm_types.h |
Places futex_unique_id in two reserved slots. |
include/linux/io_uring_types.h |
Adds KABI annotations for polling and cancellation fields. |
include/linux/device-mapper.h |
Moves needs_stable_writes to the structure tail and annotates it. |
Review effort: Balanced
6d364e7 to
5a317cd
Compare
There was a problem hiding this comment.
🟡 Changes recommended
With CONFIG_FUTEX=y, the change shifts cpu_bitmap eight bytes beyond its frozen 64-bit ABI offset, causing prebuilt modules using mm_cpumask() to read or overwrite the futex ID.
1 open issue
3 resolved since last review
Review effort: Balanced
5a317cd to
430f5b4
Compare
deepin inclusion category: kabi Commit 1addada ("futex: Fix mm reuse handling for FUT_OFF_MMSHARED") inserts atomic64_t futex_unique_id ahead of the hiwater counters in the middle of struct mm_struct, shifting the offsets of every following member and changing the genksyms checksums of exported symbols whose type graph reaches the struct. Place the counter in the trailing reserve slots with DEEPIN_KABI_USE() so genksyms keeps seeing the five reserve placeholders. The flexible cpu_bitmap array must stay at its baseline offset because prebuilt modules inline mm_cpumask() and read the offset directly, which symbol checksums cannot see; consuming existing slot storage instead of appending after it preserves that offset. On 64-bit a single eight-byte, eight-byte-aligned reserve word holds the atomic64_t as-is. On 32-bit the reserve words are four bytes each and only four-byte aligned: u64 is eight-byte aligned under the ARM EABI, so two u32 words back the counter instead, which passes the DEEPIN_KABI_SIZE_ALIGN_CHECKS assertions on every 32-bit ABI. The anonymous struct holding atomic64_t pinned_vm keeps this storage at an eight-byte-aligned offset in practice, so the use-site casts to atomic64_t stay safe. Fixes: 1addada ("futex: Fix mm reuse handling for FUT_OFF_MMSHARED") Change-Id: I5e8d625425a6b10a0a9733f0c70339939bfa0bfa Signed-off-by: shaoyang <shaoyang@uniontech.com> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
deepin inclusion category: kabi Commit d1c994e ("dm-integrity: require stable writes for internal hash modes") inserts the needs_stable_writes bit into the middle of the bitfield cluster at the end of struct dm_target, changing the storage unit layout and the genksyms checksums of exported symbols whose type graph reaches the struct. Move the bit to the tail of the struct with DEEPIN_KABI_EXTEND() so genksyms keeps seeing the original layout. struct dm_target is allocated only by the device-mapper core with sizeof() and is only passed to target modules by pointer, so appending the bit is safe and the runtime field remains accessible to both the core and the targets. Fixes: d1c994e ("dm-integrity: require stable writes for internal hash modes") Change-Id: I5e1f5b4096514a5aff5749526b9b484f74f32cd3 Signed-off-by: shaoyang <shaoyang@uniontech.com> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
deepin inclusion category: kabi Commit 89b23df ("unicode: free the map after a grace period") appends struct rcu_head rcu to struct unicode_map, growing the structure and changing the genksyms checksums of exported symbols whose type graph reaches the struct. Add the rcu_head with DEEPIN_KABI_EXTEND() instead. struct unicode_map is allocated only by the unicode core with sizeof() and is handed to its users by pointer, so the hidden tail extension is safe and kfree_rcu() keeps working unchanged. Fixes: 89b23df ("unicode: free the map after a grace period") Change-Id: I28f60e0c6b99d5f8d4a500cdf466e1b08ea2e76f Signed-off-by: shaoyang <shaoyang@uniontech.com> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
deepin inclusion category: kabi Commit 6bf27f8 ("perf: Track the perf mlock gift separately") inserts atomic_long_t perf_mlock ahead of the ratelimit state in the middle of struct user_struct, shifting the offsets of the following members and changing the genksyms checksums of exported symbols whose type graph reaches the struct. Move the counter to the tail of the struct with DEEPIN_KABI_EXTEND() so genksyms keeps seeing the original layout. struct user_struct is allocated only by the core uid cache with sizeof() and is only ever referenced through pointers, so the hidden tail extension is safe and the mlock accounting keeps working unchanged. Fixes: 6bf27f8 ("perf: Track the perf mlock gift separately") Change-Id: Iafc77c06212e33244670a3b1e4502874a900387c Signed-off-by: shaoyang <shaoyang@uniontech.com> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
deepin inclusion category: kabi Commit 7ecc426 ("io_uring/cancel: don't default to setting req->work.cancel_seq") replaces the poll_refs counter right after atomic_t refs with bool cancel_seq_set and re-adds poll_refs later in the struct, before link, changing the member layout seen by genksyms and the checksums of exported symbols whose type graph reaches struct io_kiocb. Use DEEPIN_KABI_REPLACE() at the original poll_refs position so genksyms keeps seeing the baseline layout while the runtime structure keeps cancel_seq_set, and hide the relocated poll_refs behind DEEPIN_KABI_EXTEND() appended after big_cqe, keeping every existing member at its baseline offset as the extension contract requires. The runtime structure is then laid out exactly as the macro contract allows, all in-tree users keep working unchanged and the macro adds compile-time size and alignment checks between the two views. Fixes: 7ecc426 ("io_uring/cancel: don't default to setting req->work.cancel_seq") Change-Id: Ic13cd5433bc312f0118f8c82e6d9345f73b5f1a7 Signed-off-by: shaoyang <shaoyang@uniontech.com> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
deepin inclusion category: kabi Commit cc8e033 ("io_uring: wake ring pollers for local task_work") adds struct rcu_head poll_wq_rcu and atomic_t poll_wq_rcu_pending to the middle of struct io_ring_ctx, shifting the offsets of the following members and changing the genksyms checksums of exported symbols whose type graph reaches the struct. Hide both fields behind DEEPIN_KABI_EXTEND() at the tail of the struct, after sqe_pages, so genksyms keeps seeing the baseline layout while the runtime structure retains the deferred poll-wq wake state. struct io_ring_ctx is allocated only by the io_uring core with sizeof() and is never embedded, so the hidden tail extension cannot break any existing user, and the wake logic keeps working unchanged. Fixes: cc8e033 ("io_uring: wake ring pollers for local task_work") Change-Id: I0e13ba4ec139094b93313c4785ba5dfd814371f1 Signed-off-by: shaoyang <shaoyang@uniontech.com> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
430f5b4 to
7beacf8
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
KABI preservation requires maintainer validation against frozen symbol CRC and structure-layout baselines, but baseline comparisons and cross-architecture build artifacts are missing, particularly for 32-bit alignment.
No open issues 🎉
1 resolved since last review
Review effort: Balanced

Summary by Sourcery
Apply Deepin KABI compatibility fixes for the 6.6.160–6.6.161 kernel updates.
Enhancements: