[PATCH] seq_buf: always inline seq_buf_terminate()

From: Sasha Levin

Date: Sun Nov 15 2026 - 10:34:39 EST


Commit 7b8cd26b6aab8 ("seq_buf: Mark a seq_buf overflowed when terminating it
loses a byte") made __seq_buf_terminate() bigger, and clang no longer inlines
seq_buf_terminate() into its two callers in kernel/trace/trace_events.c. Both
pass bootup_event_seq, which is __initdata, so the out-of-line copy sits in
.text with that address in it and modpost warns:

WARNING: modpost: vmlinux: section mismatch in reference: seq_buf_terminate+0x12 (section: .text) -> bootup_event_seq (section: .init.data)

Both callers are __init, so nothing uses the buffer after it is freed. But the
warning shows up in allmodconfig builds, and it is an error with
CONFIG_SECTION_MISMATCH_WARN_ONLY=n.

Mark seq_buf_terminate() and __seq_buf_terminate() __always_inline. Marking
only seq_buf_terminate() is not enough, as the same thing then happens to
__seq_buf_terminate().

Fixes: 7b8cd26b6aab8 ("seq_buf: Mark a seq_buf overflowed when terminating it loses a byte")
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/202611110802.zPIiPSnJ-lkp@xxxxxxxxx/
Closes: https://lore.kernel.org/oe-kbuild-all/202611120138.Fwm5Ljmj-lkp@xxxxxxxxx/
Closes: https://lore.kernel.org/oe-kbuild-all/202611122226.vTBpAmtr-lkp@xxxxxxxxx/
Closes: https://lore.kernel.org/oe-kbuild-all/202611122323.IvGv8FYK-lkp@xxxxxxxxx/
Suggested-by: Nathan Chancellor <nathan@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
7b8cd26b6aab8 is on both for-next/kspp and for-linus/hardening.

include/linux/seq_buf.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h
index 6b915c67d2358..f72dd258206fb 100644
--- a/include/linux/seq_buf.h
+++ b/include/linux/seq_buf.h
@@ -134,7 +134,7 @@ static inline unsigned int seq_buf_used(struct seq_buf *s)
*
* Returns: the offset of the NUL.
*/
-static inline size_t __seq_buf_terminate(struct seq_buf *s)
+static __always_inline size_t __seq_buf_terminate(struct seq_buf *s)
{
size_t end;

@@ -240,7 +240,7 @@ static inline size_t seq_buf_strlen(struct seq_buf *s)
* After this function is called, s->buffer is safe to use
* in string operations.
*/
-static inline void seq_buf_terminate(struct seq_buf *s)
+static __always_inline void seq_buf_terminate(struct seq_buf *s)
{
if (s->size == 0)
return;

base-commit: 7b8cd26b6aab8cf147165610d13964f79200a5a7
--
2.53.0