From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
kernel test robot <lkp@intel.com>,
"Yury Norov (NVIDIA)" <yury.norov@gmail.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 6.17-5.4] m68k: bitops: Fix find_*_bit() signatures
Date: Thu, 2 Oct 2025 11:29:53 -0400 [thread overview]
Message-ID: <20251002153025.2209281-6-sashal@kernel.org> (raw)
In-Reply-To: <20251002153025.2209281-1-sashal@kernel.org>
From: Geert Uytterhoeven <geert@linux-m68k.org>
[ Upstream commit 6d5674090543b89aac0c177d67e5fb32ddc53804 ]
The function signatures of the m68k-optimized implementations of the
find_{first,next}_{,zero_}bit() helpers do not match the generic
variants.
Fix this by changing all non-pointer inputs and outputs to "unsigned
long", and updating a few local variables.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202509092305.ncd9mzaZ-lkp@intel.com/
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: "Yury Norov (NVIDIA)" <yury.norov@gmail.com>
Link: https://patch.msgid.link/de6919554fbb4cd1427155c6bafbac8a9df822c8.1757517135.git.geert@linux-m68k.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
Based on my thorough analysis of this commit, here is my assessment:
## Backport Recommendation: **YES**
### Extensive Analysis
#### 1. **Nature of the Bug**
This commit fixes an **API signature mismatch** between m68k-specific
implementations of `find_{first,next}_{,zero_}bit()` and the generic
variants defined in `include/linux/find.h`.
**Specific Issues Fixed:**
- **Return type mismatch**: m68k returned `int` instead of `unsigned
long`
- **Parameter type mismatch**: m68k used `int`/`unsigned int` for
size/offset parameters instead of `unsigned long`
- **Internal variable types**: Updated `res` from `int` to `unsigned
long` and `words` from `unsigned int` to `unsigned long` for
consistency
**Code Changes:**
```c
// Before (incorrect):
static inline int find_first_zero_bit(const unsigned long *vaddr,
unsigned size)
{
int res = 32;
unsigned int words;
...
}
// After (correct):
static inline unsigned long find_first_zero_bit(const unsigned long
*vaddr, unsigned long size)
{
unsigned long res = 32;
unsigned long words;
...
}
```
#### 2. **Root Cause and Discovery**
**Historical Context:**
- The generic `find_*_bit()` API has used `unsigned long` for return
values and size/offset parameters since at least **May 2021** (commit
2cc7b6a44ac21d)
- In **June 2022**, commit 0e862838f2901 unified non-atomic bitops
prototypes across architectures, but m68k's `find_*_bit()` functions
were missed
- m68k did update `__fls()` to return `unsigned long` in 2022, but
`find_*_bit()` was overlooked
**Discovery:**
- Reported by kernel test robot on **September 9, 2025**
- Triggered by the `gpio-mpsse` driver (introduced in v6.13) when
compiled for m68k with GCC 15.1.0
- Build warning: `warning: format '%ld' expects argument of type 'long
int', but argument 3 has type 'int' [-Wformat=]`
- The gpio-mpsse driver correctly assumed `find_first_bit()` returns
`unsigned long` and used `%ld` format specifier
#### 3. **Impact Assessment**
**Build Impact:**
- Causes `-Wformat` warnings with modern compilers (GCC 15.1.0+)
- Breaks W=1 builds (extra warnings enabled)
- Affects m68k-allmodconfig builds
**Runtime Impact:**
- **On m68k (32-bit)**: Both `int` and `long` are 32 bits, so no data
corruption or truncation at runtime
- **Type safety**: Violates API contract and breaks type safety
guarantees
- **Future-proofing**: Could cause issues with future compiler
optimizations or analysis tools
**Affected Code:**
- Any code using these functions with format strings (like gpio-mpsse)
- Any code relying on proper type signatures for static analysis
#### 4. **Fix Quality Assessment**
**Strengths:**
- **Small and focused**: Only changes type signatures, no logic changes
- **Self-contained**: No dependencies on other commits
- **Low risk**: On m68k, `int` and `unsigned long` have identical size
and alignment
- **Well-tested**: The generic API with these signatures has been used
successfully across all other architectures since 2021
- **Maintainer approval**: Acked by Yury Norov (NVIDIA), the maintainer
of bitmap/find_bit subsystem
**Changes Made:**
1. Function return types: `int` → `unsigned long` (4 functions)
2. Size parameters: `unsigned size` → `unsigned long size`
3. Offset parameters: `int offset` → `unsigned long offset`
4. Internal variables: `int res` → `unsigned long res`, `unsigned int
words` → `unsigned long words`
#### 5. **Consistency with Kernel Standards**
This fix brings m68k in line with:
- The generic API defined in `include/linux/find.h` (lines 385, 179,
206, 60)
- All other architecture-specific implementations
- The kernel's bitmap subsystem standards established in 2021-2022
#### 6. **Backport Suitability**
**Meets Stable Kernel Criteria:**
✅ **Fixes important bug**: API signature mismatch causing build warnings
✅ **Small and contained**: ~20 lines changed, type-only modifications
✅ **No architectural changes**: Pure signature corrections
✅ **Minimal regression risk**: Same size types on target architecture
✅ **No new features**: Only fixes existing API compliance
**Priority by Kernel Version:**
- **High priority for 6.13+**: Contains gpio-mpsse driver that exposes
the bug
- **Medium priority for 6.6-6.12**: No immediate triggering code, but
bug exists
- **Low priority for <6.6**: Older compilers less likely to catch the
issue, but correctness still matters
**Dependencies:**
None - the fix is self-contained and applies cleanly to any kernel with
the current m68k bitops.h structure (present since at least 2021).
#### 7. **Potential Risks**
**Minimal risks identified:**
- On m68k, `int` and `unsigned long` are both 32-bit, so binary
compatibility is preserved
- No ABI changes (inline functions)
- No performance impact
- No behavior changes
### Conclusion
This commit is an **excellent candidate for backporting** to stable
kernel trees. It fixes a long-standing API compliance bug with minimal
risk, improves type safety, resolves build warnings with modern
compilers, and aligns m68k with kernel-wide standards. The fix is small,
focused, well-reviewed, and has no dependencies, making it ideal for
stable tree inclusion.
arch/m68k/include/asm/bitops.h | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/arch/m68k/include/asm/bitops.h b/arch/m68k/include/asm/bitops.h
index 14c64a6f12176..50ec92651d5a5 100644
--- a/arch/m68k/include/asm/bitops.h
+++ b/arch/m68k/include/asm/bitops.h
@@ -350,12 +350,12 @@ static inline bool xor_unlock_is_negative_byte(unsigned long mask,
#include <asm-generic/bitops/ffz.h>
#else
-static inline int find_first_zero_bit(const unsigned long *vaddr,
- unsigned size)
+static inline unsigned long find_first_zero_bit(const unsigned long *vaddr,
+ unsigned long size)
{
const unsigned long *p = vaddr;
- int res = 32;
- unsigned int words;
+ unsigned long res = 32;
+ unsigned long words;
unsigned long num;
if (!size)
@@ -376,8 +376,9 @@ static inline int find_first_zero_bit(const unsigned long *vaddr,
}
#define find_first_zero_bit find_first_zero_bit
-static inline int find_next_zero_bit(const unsigned long *vaddr, int size,
- int offset)
+static inline unsigned long find_next_zero_bit(const unsigned long *vaddr,
+ unsigned long size,
+ unsigned long offset)
{
const unsigned long *p = vaddr + (offset >> 5);
int bit = offset & 31UL, res;
@@ -406,11 +407,12 @@ static inline int find_next_zero_bit(const unsigned long *vaddr, int size,
}
#define find_next_zero_bit find_next_zero_bit
-static inline int find_first_bit(const unsigned long *vaddr, unsigned size)
+static inline unsigned long find_first_bit(const unsigned long *vaddr,
+ unsigned long size)
{
const unsigned long *p = vaddr;
- int res = 32;
- unsigned int words;
+ unsigned long res = 32;
+ unsigned long words;
unsigned long num;
if (!size)
@@ -431,8 +433,9 @@ static inline int find_first_bit(const unsigned long *vaddr, unsigned size)
}
#define find_first_bit find_first_bit
-static inline int find_next_bit(const unsigned long *vaddr, int size,
- int offset)
+static inline unsigned long find_next_bit(const unsigned long *vaddr,
+ unsigned long size,
+ unsigned long offset)
{
const unsigned long *p = vaddr + (offset >> 5);
int bit = offset & 31UL, res;
--
2.51.0
next prev parent reply other threads:[~2025-10-02 15:30 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-02 15:29 [PATCH AUTOSEL 6.17-5.4] hfs: fix KMSAN uninit-value issue in hfs_find_set_zero_bits() Sasha Levin
2025-10-02 15:29 ` [PATCH AUTOSEL 6.17-6.12] arm64: sysreg: Correct sign definitions for EIESB and DoubleLock Sasha Levin
2025-10-02 15:29 ` [PATCH AUTOSEL 6.17-5.4] hfs: clear offset and space out of valid records in b-tree node Sasha Levin
2025-10-02 15:29 ` [PATCH AUTOSEL 6.17-5.4] hfsplus: return EIO when type of hidden directory mismatch in hfsplus_fill_super() Sasha Levin
2025-10-02 15:29 ` [PATCH AUTOSEL 6.17-6.1] powerpc/32: Remove PAGE_KERNEL_TEXT to fix startup failure Sasha Levin
2025-10-02 15:29 ` Sasha Levin [this message]
2025-10-02 15:29 ` [PATCH AUTOSEL 6.17] smb: client: make use of ib_wc_status_msg() and skip IB_WC_WR_FLUSH_ERR logging Sasha Levin
2025-10-02 15:29 ` [PATCH AUTOSEL 6.17-6.16] arm64: realm: ioremap: Allow mapping memory as encrypted Sasha Levin
2025-10-02 16:43 ` Suzuki K Poulose
2025-10-21 15:38 ` Sasha Levin
2025-10-02 15:29 ` [PATCH AUTOSEL 6.17-6.12] gfs2: Fix unlikely race in gdlm_put_lock Sasha Levin
2025-10-02 15:29 ` [PATCH AUTOSEL 6.17-6.1] smb: server: let smb_direct_flush_send_list() invalidate a remote key first Sasha Levin
2025-10-02 15:29 ` [PATCH AUTOSEL 6.17-5.15] nios2: ensure that memblock.current_limit is set when setting pfn limits Sasha Levin
2025-10-02 15:29 ` [PATCH AUTOSEL 6.17-6.12] s390/mm: Use __GFP_ACCOUNT for user page table allocations Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.16] riscv: mm: Return intended SATP mode for noXlvl options Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.16] gfs2: Fix LM_FLAG_TRY* logic in add_to_queue Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.16] dlm: move to rinfo for all middle conversion cases Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-5.4] hfsplus: fix KMSAN uninit-value issue in hfsplus_delete_cat() Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-5.4] exec: Fix incorrect type for ret Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-5.4] hfsplus: fix KMSAN uninit-value issue in __hfsplus_ext_cache_extent() Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.1] lkdtm: fortify: Fix potential NULL dereference on kmalloc failure Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.16] riscv: mm: Use mmu-type from FDT to limit SATP mode Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.6] Unbreak 'make tools/*' for user-space targets Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-5.4] hfs: make proper initalization of struct hfs_find_data Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-5.4] hfsplus: fix slab-out-of-bounds read in hfsplus_strcasecmp() Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.16] riscv: cpufeature: add validation for zfa, zfh and zfhmin Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.12] PCI: Test for bit underflow in pcie_set_readrq() Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.16] s390/pkey: Forward keygenflags to ep11_unwrapkey Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.6] drivers/perf: hisi: Relax the event ID check in the framework Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-5.4] hfs: validate record offset in hfsplus_bmap_alloc Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17] smb: client: limit the range of info->receive_credit_target Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-5.4] dlm: check for defined force value in dlm_lockspace_release Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.12] binfmt_elf: preserve original ELF e_flags for core dumps Sasha Levin
2025-10-02 15:58 ` Kees Cook
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.16] arm64: errata: Apply workarounds for Neoverse-V3AE Sasha Levin
2025-10-02 15:30 ` [PATCH AUTOSEL 6.17-6.16] smb: client: queue post_recv_credits_work also if the peer raises the credit target 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=20251002153025.2209281-6-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=geert@linux-m68k.org \
--cc=lkp@intel.com \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=yury.norov@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).