From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: "Sami Tolvanen" <samitolvanen@google.com>,
"Michal Suchánek" <msuchanek@suse.de>,
"Sasha Levin" <sashal@kernel.org>,
linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org
Subject: [PATCH AUTOSEL 6.19-6.18] gendwarfksyms: Fix build on 32-bit hosts
Date: Wed, 11 Feb 2026 20:09:25 -0500 [thread overview]
Message-ID: <20260212010955.3480391-2-sashal@kernel.org> (raw)
In-Reply-To: <20260212010955.3480391-1-sashal@kernel.org>
From: Sami Tolvanen <samitolvanen@google.com>
[ Upstream commit ddc54f912a551f6eb0bbcfc3880f45fe27a252cb ]
We have interchangeably used unsigned long for some of the types
defined in elfutils, assuming they're always 64-bit. This obviously
fails when building gendwarfksyms on 32-bit hosts. Fix the types.
Reported-by: Michal Suchánek <msuchanek@suse.de>
Closes: https://lore.kernel.org/linux-modules/aRcxzPxtJblVSh1y@kitsune.suse.cz/
Tested-by: Michal Suchánek <msuchanek@suse.de>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
Now I have a complete picture. Let me write my analysis.
---
## Comprehensive Analysis
### 1. COMMIT MESSAGE ANALYSIS
The subject "gendwarfksyms: Fix build on 32-bit hosts" clearly
identifies this as a **build fix**. The message explains that `unsigned
long` was used interchangeably with elfutils types that are always
64-bit (`uint64_t`), which breaks compilation on 32-bit hosts where
`unsigned long` is only 32 bits.
Key indicators:
- **Reported-by:** Michal Suchanek (SUSE engineer) - a real user who hit
this building kernels
- **Tested-by:** Same reporter - confirms the fix works
- **Closes:** link to lore.kernel.org bug report - documented issue
### 2. CODE CHANGE ANALYSIS
The fix addresses three distinct but related 32-bit portability bugs
across two files:
**Bug 1 - `dwarf.c` (`process_enumerator_type`):**
The type chain is:
- `Dwarf_Word` = `GElf_Xword` = `Elf64_Xword` = `uint64_t` (always
64-bit)
- `unsigned long` = 32-bit on 32-bit hosts
The pre-fix code passes `&value` (where `value` is `Dwarf_Word` /
`uint64_t`) to `kabi_get_enumerator_value()`, which expects `unsigned
long *`. On a 32-bit host, this is a type mismatch: passing a
`uint64_t*` where `unsigned long*` (4 bytes) is expected. The function
would write only 4 bytes to a memory location expected to hold 8 bytes,
leaving the upper half uninitialized. This is both a **compiler
error/warning** and a **correctness bug**.
The fix introduces a properly-typed `unsigned long override` variable,
passes it to the function, then assigns `value = override;` to widen it
back.
**Bug 2 - `symbols.c` (format strings):**
`shdr->sh_entsize` is `GElf_Xword` = `uint64_t`, but was printed with
`%lu` (expects `unsigned long`, 32-bit). Fixed to `"%" PRIu64`.
Similarly, `sym->addr.address` is `Elf64_Addr` = `uint64_t`, but was
printed with `%lx`. Fixed to `"%" PRIx64`. The missing `#include
<inttypes.h>` is added for the `PRIu64`/`PRIx64` macros.
On 32-bit hosts, these format mismatches would cause:
- Compiler warnings (`-Wformat`) or errors (`-Werror`)
- Incorrect printed values (reading wrong stack slots for variadic args)
### 3. CLASSIFICATION
This is unambiguously a **build fix**. Build fixes are explicitly listed
in the stable kernel rules as appropriate for backporting. They don't
introduce new features or change runtime behavior - they simply make the
code compile correctly.
### 4. SCOPE AND RISK ASSESSMENT
- **Files changed:** 2 (`dwarf.c`, `symbols.c`)
- **Lines changed:** ~10 meaningful lines
- **Risk:** Extremely low. The changes are format specifier corrections
and a type-narrowing variable addition. They cannot introduce
regressions.
- **Subsystem:** `scripts/gendwarfksyms/` - a build-time host tool, not
runtime kernel code. Even if there were a mistake, it couldn't crash
the kernel.
### 5. APPLICABILITY TO STABLE TREES
`gendwarfksyms` was introduced in **v6.14-rc1** (commit
`f28568841ae0a`). I verified:
- **v6.12 and earlier (LTS):** Do NOT have `gendwarfksyms` - this fix is
**not applicable**
- **v6.14 through v6.19:** All have the buggy code - this fix IS
applicable
The buggy code (`%lu` formats, `Dwarf_Word`/`unsigned long` mismatch)
has existed since the initial introduction in v6.14-rc1. All three bug
patterns exist in `git show v6.14:scripts/gendwarfksyms/symbols.c` and
`git show v6.14:scripts/gendwarfksyms/dwarf.c`.
Active stable trees that benefit: **v6.18.y** (and potentially v6.14.y
through v6.17.y if still maintained).
### 6. USER IMPACT
This affects anyone building a 6.14+ kernel on a 32-bit host system with
`CONFIG_GENDWARFKSYMS` enabled. While 32-bit build hosts are
increasingly rare, they are still used in some enterprise and embedded
development environments. The reporter is from SUSE, indicating this
affects enterprise distribution builds. Without this fix, the build
simply **fails** on 32-bit hosts.
### 7. DEPENDENCY CHECK
The fix is completely self-contained. It changes format specifiers, adds
a standard C include, and introduces a temporary variable. It has **zero
dependencies** on other commits.
### 8. VERDICT
**Meets stable criteria:**
- Obviously correct and tested (type/format corrections, Tested-by tag)
- Fixes a real bug (build failure on 32-bit hosts + potential incorrect
behavior)
- Small and contained (~10 lines across 2 files)
- No new features, no API changes, no behavioral changes
- Build fixes are explicitly allowed in stable
**Risk vs. benefit:**
- Risk: Near zero - trivial type corrections in a host build tool
- Benefit: Enables building the kernel on 32-bit hosts when
gendwarfksyms is enabled
The only limitation is that this fix is only applicable to stable trees
v6.14.y and newer, since `gendwarfksyms` doesn't exist in the main LTS
trees (6.12.y, 6.6.y, 6.1.y). But for the trees where it applies, it's a
clear and necessary build fix.
**YES**
scripts/gendwarfksyms/dwarf.c | 4 +++-
scripts/gendwarfksyms/symbols.c | 5 +++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/scripts/gendwarfksyms/dwarf.c b/scripts/gendwarfksyms/dwarf.c
index 3538a7d9cb070..e76d732f5f602 100644
--- a/scripts/gendwarfksyms/dwarf.c
+++ b/scripts/gendwarfksyms/dwarf.c
@@ -750,6 +750,7 @@ static void process_enumerator_type(struct state *state, struct die *cache,
Dwarf_Die *die)
{
bool overridden = false;
+ unsigned long override;
Dwarf_Word value;
if (stable) {
@@ -761,7 +762,8 @@ static void process_enumerator_type(struct state *state, struct die *cache,
return;
overridden = kabi_get_enumerator_value(
- state->expand.current_fqn, cache->fqn, &value);
+ state->expand.current_fqn, cache->fqn, &override);
+ value = override;
}
process_list_comma(state, cache);
diff --git a/scripts/gendwarfksyms/symbols.c b/scripts/gendwarfksyms/symbols.c
index ecddcb5ffcdfb..42cd27c9cec4f 100644
--- a/scripts/gendwarfksyms/symbols.c
+++ b/scripts/gendwarfksyms/symbols.c
@@ -3,6 +3,7 @@
* Copyright (C) 2024 Google LLC
*/
+#include <inttypes.h>
#include "gendwarfksyms.h"
#define SYMBOL_HASH_BITS 12
@@ -242,7 +243,7 @@ static void elf_for_each_global(int fd, elf_symbol_callback_t func, void *arg)
error("elf_getdata failed: %s", elf_errmsg(-1));
if (shdr->sh_entsize != sym_size)
- error("expected sh_entsize (%lu) to be %zu",
+ error("expected sh_entsize (%" PRIu64 ") to be %zu",
shdr->sh_entsize, sym_size);
nsyms = shdr->sh_size / shdr->sh_entsize;
@@ -292,7 +293,7 @@ static void set_symbol_addr(struct symbol *sym, void *arg)
hash_add(symbol_addrs, &sym->addr_hash,
symbol_addr_hash(&sym->addr));
- debug("%s -> { %u, %lx }", sym->name, sym->addr.section,
+ debug("%s -> { %u, %" PRIx64 " }", sym->name, sym->addr.section,
sym->addr.address);
} else if (sym->addr.section != addr->section ||
sym->addr.address != addr->address) {
--
2.51.0
next prev parent reply other threads:[~2026-02-12 1:09 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 1:09 [PATCH AUTOSEL 6.19-5.10] clocksource/drivers/sh_tmu: Always leave device running after probe Sasha Levin
2026-02-12 1:09 ` Sasha Levin [this message]
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.18] arm64/ftrace,bpf: Fix partial regs after bpf_prog_run Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.18] bpftool: Fix dependencies for static build Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.12] perf/x86/msr: Add Airmont NP Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.18] genirq/cpuhotplug: Notify about affinity changes breaking the affinity mask Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-5.15] char: tpm: cr50: Remove IRQF_ONESHOT Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.6] crypto: hisilicon/qm - move the barrier before writing to the mailbox register Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.12] sched/debug: Fix updating of ppos on server write ops Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.18] perf/x86/intel: Add Airmont NP Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.18] bpf: Properly mark live registers for indirect jumps Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-5.10] mailbox: bcm-ferxrm-mailbox: Use default primary handler Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.18] perf/core: Fix slow perf_event_task_exit() with LBR callstacks Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.12] perf/x86/cstate: Add Airmont NP Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-5.10] clocksource/drivers/timer-integrator-ap: Add missing Kconfig dependency on OF Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-5.10] bpf: verifier improvement in 32bit shift sign extension pattern Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.12] bpf: Recognize special arithmetic shift in the verifier Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.12] bpf: crypto: Use the correct destructor kfunc type Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-5.10] pstore: ram_core: fix incorrect success return when vmap() fails Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.18] bpf: net_sched: Use the correct destructor kfunc type Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.18] irqchip/riscv-imsic: Add a CPU pm notifier to restore the IMSIC on exit Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.1] PCI/MSI: Unmap MSI-X region on error Sasha Levin
2026-02-12 1:09 ` [PATCH AUTOSEL 6.19-6.18] rust: sync: Implement Unpin for ARef Sasha Levin
2026-02-12 12:11 ` Miguel Ojeda
2026-02-26 13:45 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260212010955.3480391-2-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=msuchanek@suse.de \
--cc=patches@lists.linux.dev \
--cc=samitolvanen@google.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox