From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=216.40.44.16 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796138001; b=ebQr5IJsBV8965bQqwaLizt8+fgf4GkIR3YBWnHCxI1TTfSssIDMZsDaXUY9mxRMd8f9 Rhw6zkVOP8RfQaMi7P99pzbwUreLSjNtL90VmFfIyR9nOtKd0sUhI31FOcsSZ5R7KzA5U MHsyJIlZFwaZZpME5//VF03mfVdCh0WxuyE77i1oQ1uwFMdu4H8xOO7Yleum648PeqS9e UOOWgeyHxW7+UrEOU5kUB7sglR0KpeWuPUW3/KnHIRq16PCwpeVGnSKtdhrI3+uiTHzWS RqJg+59SiSrdhWzQDt+2wzICUqZbHQNeMTYUk4RGU2LivRbLkDRT87qJ7rtvuxJStaQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796138001; h=DMARC-Filter:Received:Received:Date:From:To:Cc:Subject:Message-ID: In-Reply-To:References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding:X-Rspamd-Queue-Id:X-Stat-Signature: X-Spam-Status:X-Rspamd-Server:X-Session-Marker:X-Session-ID: DKIM-Signature:X-HE-Tag:X-HE-Meta; bh=z2SCCsxhA6bek8eIVMiBEZZWhOh8VTLza8AMaPAYALE=; b=1VB4vvW/xaP0sLNwYQcqzXlXsttxaaGx6x2OcfzStSyy3dEqb3RLRpQgCChCNA6eT8f4 5I7/AWY/ItXlpg6xEuA1gr7ytBkuuloQ80vvWoRoMuB7fU6YJ9zoxSurfvIlhRs0QT2xl RjwKC5kUxIIeb3dm6/S6ymzI7ghaq4BbZ5kOYHk7DyVfWHymPDd7cCG5ug8nvURTPDLc2 J9kMQ8vF8G+LcG01Bt+1lvcu2b/XI2ygb9r9S+jdahnaTMD0Cfy2vm8pWDIJo/TL0wM39 WMOIFizppU1r3CUNORFgADvpGStHkJScJyY5xWEPJcEu12PjwChUIHy/WC/tC2ykJ5A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; dkim=pass header.d=goodmis.org header.i=@goodmis.org header.a=rsa-sha256 header.s=dkim1 header.b=fTcJH6NM; arc=none smtp.remote-ip=216.40.44.16 Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A80C2606A330 for ; Tue, 1 Dec 2026 15:13:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A80C2606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=goodmis.org header.i=@goodmis.org header.a=rsa-sha256 header.s=dkim1 header.b=fTcJH6NM Received: from omf12.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 45E98C0F42; Tue, 1 Dec 2026 15:13:18 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf12.hostedemail.com (Postfix) with ESMTPA id AB54917; Tue, 1 Dec 2026 15:13:15 +0000 (UTC) Date: Tue, 1 Dec 2026 10:13:14 -0500 From: Steven Rostedt To: Arnd Bergmann Cc: Kees Cook , Nathan Chancellor , Arnd Bergmann , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Shevchenko , Randy Dunlap , Alexei Starovoitov , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] seq_buf: avoid clang section mismatch from seq_buf_terminate optimization Message-ID: <20261201101314.233335f6@gandalf.local.home> In-Reply-To: <20261201090627.699022-1-arnd@kernel.org> References: <20261201090627.699022-1-arnd@kernel.org> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: AB54917 X-Stat-Signature: mu9x611nueteqas3483g4g78fjbt58e5 X-Rspamd-Server: rspamout02 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX18djR0T2teYFOwWga68Sdc9uoTgrEUljws= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=goodmis.org; h=date:from:to:cc:subject:message-id:in-reply-to:references:mime-version:content-type:content-transfer-encoding; s=dkim1; bh=z2SCCsxhA6bek8eIVMiBEZZWhOh8VTLza8AMaPAYALE=; b=fTcJH6NMU4c+ZimlXRA4GmHcnQv/w4omqnFLbdHsPlwEItEC7XU/KCTA6PGZ3o+mwQpP264Yk/thcXJpg+O5xxolqKO+kI5imH/A0eRC4jq6egBUUIVpPgrE8vFmIZLnsYg4WXrar48QritO64qR3rmmplS/yeUCx/5cRW5qG7M= X-HE-Tag: 1796137995-798320 X-HE-Meta: U2FsdGVkX1/tv7FU+STeR8arp4CyB+syW+9YWi30K/80NNBYQ2hfio/zU+whBA8byQAVvJvlZCBawBuiz4WVlMqcaYrAVzdU9B2ioHUYKtXyA3F8FnM7z98TcKlO3K9zmDqAvUrVCDaqZXXYq/nWakne6c70V+y3gp7t+YEhWQl2ESl2W44wkt71WCyPgFkS52qeEGnvNRJNMu5bLKilM0cfokViXS4zs4yeV4UvAnqGCyJn7g05qf1ua2HiLkZMtgZF72i9ZA6Q0602uFRHv0VUCiB2ToJVqRJGNi3lJ8eHDiCTE1Wd0E37SnLyudPDCY9TWGBC/fPNY76Y7QlRgiAlK+sSo5UdybmYqyZLx2/yGbanrCNf3Q== On Tue, 1 Dec 2026 10:06:16 +0100 Arnd Bergmann wrote: > From: Arnd Bergmann > > I observed clang-21 create a specialized version of seq_buf_terminate() The above line denotes what kind of bug this is. Clang is creating a "specialized version"! > that hardcodes the 'bootup_event_seq' argument since all callers pass > the same one. Since seq_buf_terminate is not marked __init, it does > not get inlined into the caller if that is __init, but the __initdata > argument does get referenced from the specialized version, causing a > section mismatch warning: > > WARNING: modpost: vmlinux: section mismatch in reference: __seq_buf_terminate+0x13 (section: .text) -> bootup_event_seq (section: .init.data) > WARNING: modpost: vmlinux: section mismatch in reference: seq_buf_terminate+0xda (section: .text) -> bootup_event_seq (section: .init.data) > ERROR: modpost: Section mismatches detected. > Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them. > > I'm unsure whether this should be considered a bug in clang or the > kernel, or what the best workaround is. The two options I considered > are: It's definitely a bug in clang. If it created a specialized version of a function and that version is now causing section mismatches, that's a bug in the compiler. The kernel did nothing wrong. > > - mark bootup_event_seq as non-__initdata to avoid this one instance, > slightly pessimizing this the runtime memory usage and possibly having > the same situation elsewhere > > - mark all three functions in the call chain as __always_inline, forcing > an inlining decision that the compiler would perhaps not make, but > preventing other instances of this issue as well. > > This is the second option. > > Fixes: 7b8cd26b6aab ("seq_buf: Mark a seq_buf overflowed when terminating it loses a byte") This doesn't fix that commit. It is a workaround to a clang bug. I really don't think this should be fixed in the kernel. -- Steve > Link: https://lore.kernel.org/all/20261118171346.FH6VoALE-lkp@intel.com/ > Signed-off-by: Arnd Bergmann > --- > include/linux/seq_buf.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h > index 6b915c67d235..43bc067c82cf 100644 > --- a/include/linux/seq_buf.h > +++ b/include/linux/seq_buf.h > @@ -74,7 +74,7 @@ seq_buf_has_overflowed(struct seq_buf *s) > * seq_buf_str() terminates it, so clear whatever was not written: a writer > * sets len to how much it filled, and anything past that was never adopted. > */ > -static inline void > +static __always_inline void > seq_buf_set_overflow(struct seq_buf *s) > { > if (s->len < s->size) > @@ -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;