From nobody Mon Dec 1 22:37:12 2025 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 700BD32E752 for ; Fri, 28 Nov 2025 14:00:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764338405; cv=none; b=XozzlpJOPVtJwOxCjUZmAhS4mlG1TQvmaBAIYwqbBKPuGlBCEu7wTMJ71Hxc6K8vyQE3+KpydWrqExzd0FKwpKOFiDFJpROdzesnMQ+yTBwhNzijHHmZGh49lSM0iEOx+wN3/HkK9E5CBy8PXfke7UG6raGhCoUeIzomftZHLGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764338405; c=relaxed/simple; bh=jMdGIaiNjsaJNWRxjHYVRP95WrGsTmB+8CyF8UuaBss=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o1CqIelTS0Tcr8+3vN4xTDsBgchUwoOqX/HEVjrsVn7Q59KWK+BUBCa6a5MXiRHt+qi/rizUh2vCH49GUuGZMCMbaIkHFBujvY+aNniIHKu4mNpADJvqI4BRFmUKYFnvMSIPo8BvkbiGByCq4fkN4DMEiRkTT7UetgSONLOjeBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=KYpEE3s0; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=KYpEE3s0; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="KYpEE3s0"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="KYpEE3s0" Received: from pathway.suse.cz (unknown [IPv6:2a07:de40:b2bf:1b::12bd]) by smtp-out2.suse.de (Postfix) with ESMTP id 7E2115BEA6; Fri, 28 Nov 2025 14:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1764338401; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wylU3OY7fMN/uQhBQWrcaA+DSc1Nc4S6NVrRKYD1sjY=; b=KYpEE3s0bA/Rml6wDkBS8181pIPAMFmbfWnNSgCW3FBtwp07xXVmg2E4inVsWuZE+OueQb Wifil7ZXEsP3GdwV47DUeLPzK/7tx+IiSWdGRN5igxUKprm2zFExBVRWI92SOmo+Ip++uF 1EpBSX+A/vLFPeDZGrK8KzF1FsWD+SU= Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=KYpEE3s0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1764338401; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wylU3OY7fMN/uQhBQWrcaA+DSc1Nc4S6NVrRKYD1sjY=; b=KYpEE3s0bA/Rml6wDkBS8181pIPAMFmbfWnNSgCW3FBtwp07xXVmg2E4inVsWuZE+OueQb Wifil7ZXEsP3GdwV47DUeLPzK/7tx+IiSWdGRN5igxUKprm2zFExBVRWI92SOmo+Ip++uF 1EpBSX+A/vLFPeDZGrK8KzF1FsWD+SU= From: Petr Mladek To: Petr Pavlu , Steven Rostedt , Alexei Starovoitov , Andrew Morton , Kees Cook Cc: Aaron Tomlin , Daniel Borkmann , John Fastabend , Masami Hiramatsu , Mark Rutland , Luis Chamberlain , Daniel Gomez , Sami Tolvanen , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-modules@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Petr Mladek , Daniel Gomez Subject: [PATCH v3 3/7] module: Add helper function for reading module_buildid() Date: Fri, 28 Nov 2025 14:59:16 +0100 Message-ID: <20251128135920.217303-4-pmladek@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251128135920.217303-1-pmladek@suse.com> References: <20251128135920.217303-1-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [15.12 / 50.00]; SPAM_FLAG(5.00)[]; NEURAL_SPAM_LONG(3.50)[1.000]; BAYES_HAM(-3.00)[100.00%]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; SUSPICIOUS_RECIPS(1.50)[]; ONCE_RECEIVED(1.20)[]; HFILTER_HELO_IP_A(1.00)[pathway.suse.cz]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; HFILTER_HELO_NORES_A_OR_MX(0.30)[pathway.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_SHORT(-0.07)[-0.374]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; DIRECT_TO_MX(0.00)[git-send-email 2.52.0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_TWELVE(0.00)[19]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; TAGGED_RCPT(0.00)[]; FREEMAIL_CC(0.00)[atomlin.com,iogearbox.net,gmail.com,kernel.org,arm.com,google.com,vger.kernel.org,suse.com,samsung.com]; DKIM_TRACE(0.00)[suse.com:+]; R_RATELIMIT(0.00)[to_ip_from(RL6jpahug3dm5x93mmnjuwit91)]; DBL_BLOCKED_OPENRESOLVER(0.00)[samsung.com:email,suse.com:mid,suse.com:dkim,suse.com:email,pathway.suse.cz:helo]; TO_DN_SOME(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b2bf:1b::12bd:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b2bf:1b::12bd:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spamd-Bar: +++++++++++++++ X-Rspamd-Queue-Id: 7E2115BEA6 X-Spam-Flag: YES X-Spam-Score: 15.12 X-Spam-Level: *************** X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: add header X-Spam: Yes Content-Type: text/plain; charset="utf-8" Add a helper function for reading the optional "build_id" member of struct module. It is going to be used also in ftrace_mod_address_lookup(). Use "#ifdef" instead of "#if IS_ENABLED()" to match the declaration of the optional field in struct module. Reviewed-by: Daniel Gomez Reviewed-by: Petr Pavlu Signed-off-by: Petr Mladek --- include/linux/module.h | 9 +++++++++ kernel/module/kallsyms.c | 9 ++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index e135cc79acee..4decae2b1675 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -747,6 +747,15 @@ static inline void __module_get(struct module *module) __mod ? __mod->name : "kernel"; \ }) =20 +static inline const unsigned char *module_buildid(struct module *mod) +{ +#ifdef CONFIG_STACKTRACE_BUILD_ID + return mod->build_id; +#else + return NULL; +#endif +} + /* Dereference module function descriptor */ void *dereference_module_function_descriptor(struct module *mod, void *ptr= ); =20 diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index 00a60796327c..0fc11e45df9b 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -334,13 +334,8 @@ int module_address_lookup(unsigned long addr, if (mod) { if (modname) *modname =3D mod->name; - if (modbuildid) { -#if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID) - *modbuildid =3D mod->build_id; -#else - *modbuildid =3D NULL; -#endif - } + if (modbuildid) + *modbuildid =3D module_buildid(mod); =20 sym =3D find_kallsyms_symbol(mod, addr, size, offset); =20 --=20 2.52.0