From patchwork Fri Jan 12 09:44:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 762300 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 DECA95EE68; Fri, 12 Jan 2024 09:50:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="j+BsR9iy"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="mk/3nm62"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="cwoZj0Mo"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="pddCMPLm" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EEBB721E35; Fri, 12 Jan 2024 09:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705053005; 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=+9cuiaFBoH53rifqhpcKmv1PSCTBZIUqSH8muwBZX6s=; b=j+BsR9iyg49q923nvujno/zOi3cl1WICdMdV51hqEFmgX2Tzyti+eMMMojLvRN4gO5CnKu JW8tJdTiFRWeRByLLJ3th/dQPZZN9OSsbeSDNhBXnf7cOZjnVO8FkT2ffTy/pEDrQzY0sG SUEJ/7YJT1fDnghNgsSZhcU9+X9DKKw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705053005; 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=+9cuiaFBoH53rifqhpcKmv1PSCTBZIUqSH8muwBZX6s=; b=mk/3nm62pQU4PfejH1xpzkMvDSW0jNmO+YnDQ8tKofjWkwXn1pdXEehMNSrdQdNzBhcF+r +Mg+O1I9YKhhUwBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705053004; 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=+9cuiaFBoH53rifqhpcKmv1PSCTBZIUqSH8muwBZX6s=; b=cwoZj0MomxWw5pTNr0Mnd1y2n7VkebTedmgCW+xV+uui8F6TuJbPVFt7cwrTwcFiOltlOc rjb8trG3f1hww8zc3QxHBa/mQqJVwM9G01aWeLEorqTc8G5e8g+hq+teR+P09+X1+pwkiL OH6vXBPfYSI4suoZJs1exnUpAEgMQ8o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705053004; 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=+9cuiaFBoH53rifqhpcKmv1PSCTBZIUqSH8muwBZX6s=; b=pddCMPLmTc4ekiqlkpOQpkEs/jHK5lJ6kNg6AVikMyUD9tLvNlH7SK/L91vvO5/HIZBfrD ctizaQ/H76EQ3sAw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 56EAD139A1; Fri, 12 Jan 2024 09:50:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eILsE0wLoWVmOgAAD6G6ig (envelope-from ); Fri, 12 Jan 2024 09:50:04 +0000 From: Thomas Zimmermann To: ardb@kernel.org, nathan@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, bhelgaas@google.com, arnd@arndb.de, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, javierm@redhat.com Cc: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v5 3/4] arch/x86: Implement arch_ima_efi_boot_mode() in source file Date: Fri, 12 Jan 2024 10:44:38 +0100 Message-ID: <20240112095000.8952-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240112095000.8952-1-tzimmermann@suse.de> References: <20240112095000.8952-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: ***** X-Spam-Score: 5.20 X-Spamd-Result: default: False [5.20 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_HAM(-0.00)[23.80%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_RATELIMIT(0.00)[to_ip_from(RLf6fmkuiuubj71hj5sz5bt3qt)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_TWELVE(0.00)[23]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FREEMAIL_TO(0.00)[kernel.org,linutronix.de,redhat.com,alien8.de,linux.intel.com,zytor.com,google.com,arndb.de,linux.ibm.com,gmail.com,paul-moore.com,namei.org,hallyn.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Flag: NO The x86 implementation of arch_ima_efi_boot_mode() uses the global boot_param state. Move it into a source file to clean up the header. Avoid potential rebuilds of unrelated source files if boot_params changes. Suggested-by: Ard Biesheuvel Signed-off-by: Thomas Zimmermann --- arch/x86/include/asm/efi.h | 5 +++-- arch/x86/platform/efi/efi.c | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index a5d7a83e4c2a..1dc600fa3ba5 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -409,8 +409,9 @@ extern int __init efi_memmap_split_count(efi_memory_desc_t *md, extern void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf, struct efi_mem_range *mem); -#define arch_ima_efi_boot_mode \ - ({ extern struct boot_params boot_params; boot_params.secure_boot; }) +extern enum efi_secureboot_mode __x86_ima_efi_boot_mode(void); + +#define arch_ima_efi_boot_mode __x86_ima_efi_boot_mode() #ifdef CONFIG_EFI_RUNTIME_MAP int efi_get_runtime_map_size(void); diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index e9f99c56f3ce..f090ec972d7b 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -950,3 +950,8 @@ umode_t efi_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) } return attr->mode; } + +enum efi_secureboot_mode __x86_ima_efi_boot_mode(void) +{ + return boot_params.secure_boot; +}