Message ID | 20231130155213.1407-1-bp@alien8.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp485150vqy; Thu, 30 Nov 2023 07:52:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5WxZq/ZOUd+ePACfSg+ZYuwP7pKNl8nUwyobEYbJsKjahnuwg37PNNS4XOd0bz9xwcMuQ X-Received: by 2002:a05:6a00:2d86:b0:6cd:daa5:138f with SMTP id fb6-20020a056a002d8600b006cddaa5138fmr4988032pfb.0.1701359556512; Thu, 30 Nov 2023 07:52:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701359556; cv=none; d=google.com; s=arc-20160816; b=HHBf0EhGYF1t7uZXbZmJ4dw19JIKWQHdH3euTH2M0yjqnwRyHUe2uQX9UvdC7lEijN OyxG4QukGUzicBe36ATb7oCVuMHI1ZKoBJkilP6LQ6346MHivhB002I9z1LWchEVtpgq V1o5h2PM+v7AMjOsoek96FS34isCcmKfSr1moRBb/cpRiC6Pc17XhWgGXbcW1etY+n6v JryKvxM1p75eHDRRUPpDHvIFAhFZjBJY0/+CH9AwyUkYWkXz+xyvP2LWlowHg5F4QJ3b tsnJPcDePGHHw7QTRfq+AyHjbZj4En641ETsn/HhE/C2zl88Z3a8IJBWspUL/K5MosQm 9xgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ADYN6dWPItd1IsqAjbO2u9TyH3SkemuY2SLJR5gqYA8=; fh=x7tgAp3UTdwCJoo3nncPbyjpkD3LzARVzJidJz0MiQY=; b=DHpBJwyei4iqrIkB7CaiEfw02hb3Kvy2/KODpAr1QwUwmirlGAxZytJ5JSi1G/o0tk XnRQ8tn8jjR6Op1X4vjR0sBEWa8S0Xi3w1CbwrBmhili4RTIRhiP8tOr24rx5AK1ghMs F0c3ofKpZ9TMJxJkcws+Pl0m04zL8Uvjloc6AjlgR90WOA1UH3de/pNygk6zv2M1BS2k frB1GmWEP1zwJT9dJW0RtZwGsqhFf8EPNcOcC0oKjs/BgzQlPjFkX6JB7DB6layKDZe8 l6GOSMCNLdFG7uazcpwSdj4LBvZNII0i35+bUkYVcSME6u3GuTQ0ZNNGHDaG9znpuzb8 s8sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=G6+Y9s9n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id q33-20020a635061000000b005c615702198si1577690pgl.703.2023.11.30.07.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 07:52:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=G6+Y9s9n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4DAA38076152; Thu, 30 Nov 2023 07:52:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346413AbjK3PwX (ORCPT <rfc822;ruipengqi7@gmail.com> + 99 others); Thu, 30 Nov 2023 10:52:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232208AbjK3PwW (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 30 Nov 2023 10:52:22 -0500 Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87347C1 for <linux-kernel@vger.kernel.org>; Thu, 30 Nov 2023 07:52:28 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id D187D40E025A; Thu, 30 Nov 2023 15:52:26 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=fail (4096-bit key) reason="fail (body has been altered)" header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id roX7NmhyTv2K; Thu, 30 Nov 2023 15:52:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1701359544; bh=6WfUnJiXA2QiPh24Z3FXnc7gIpfIQPu99AkmUbKS270=; h=From:To:Cc:Subject:Date:From; b=G6+Y9s9nJtOCY9G7xvc7cKGe4PFI1YTxq46AEbvLIkP8BvJrAVZtNsWHQ41BMMZxf dZkLwmIF6M/3tIF1//aivo8WAArNk0hACsKlLjHYmLdyjRFXYaQVg7HjyOPxfMXrhV It+NReVcYdleX3//2KKcEx0qvJGb0fiQI88evyidwcp+9+4ThiylmvJJmdfC6qbQ3K JE0XjvWAwaHKD9igoGwHIHQSvkhXUHwnbyKUFTn9+nPxhanFdANYaL0E/oBG2zrTmo EINGzrtaMF8WPfhJ+h2MpS2u/Kp8FPO48x1jJ/w+1oPHJ50WNwOGnTTaKDzrvPWWdH 2I9TLcxxyKxMvul8o58dFfK5wSL9EAg5xKrwhEzx5JKYEpwPT/0Or0dZwxQz74Virs Yh7XKJkU+aJHp298GuBHpxFvovqmXIUATe/qEhWUMpoHMkd3dg2hjZ1Yvk2EXTrKqH nL7oHMbbw82CQPkrN35/9bY62lICP58ZbEE0XxV8v5lEeZg+ZFo8wWxEZYZkPi6FLc O0l+qN97IgFnAYDOBKDHvHN1GSuxckIyw1R8Y4KoBy210ORfiY4ES8bFTSrMDEkXja tVnQKBcBVoNC2vCroToX2E3vjGnhhWgtUfvXwsFCQ739fY07geYrUtjbI1+u6jPQbM aKttNBD1GrzY2ptjYd3tKFwM= Received: from zn.tnic (pd95304da.dip0.t-ipconnect.de [217.83.4.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id F13D540E0239; Thu, 30 Nov 2023 15:52:20 +0000 (UTC) From: Borislav Petkov <bp@alien8.de> To: X86 ML <x86@kernel.org> Cc: LKML <linux-kernel@vger.kernel.org>, Nikolay Borisov <nik.borisov@suse.com> Subject: [PATCH] x86/ia32: State that IA32 emulation is disabled Date: Thu, 30 Nov 2023 16:52:13 +0100 Message-ID: <20231130155213.1407-1-bp@alien8.de> X-Mailer: git-send-email 2.42.0.rc0.25.ga82fb66fed25 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 30 Nov 2023 07:52:32 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784004798052446001 X-GMAIL-MSGID: 1784004798052446001 |
Series |
x86/ia32: State that IA32 emulation is disabled
|
|
Commit Message
Borislav Petkov
Nov. 30, 2023, 3:52 p.m. UTC
From: "Borislav Petkov (AMD)" <bp@alien8.de> Issue a short message once, on the first try to load a 32-bit process to save people time when wondering why it won't load and says: -bash: ./strsep32: cannot execute binary file: Exec format error No functional changes. Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Cc: Nikolay Borisov <nik.borisov@suse.com> --- arch/x86/include/asm/elf.h | 2 +- arch/x86/include/asm/ia32.h | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-)
Comments
On 30.11.23 г. 17:52 ч., Borislav Petkov wrote: > From: "Borislav Petkov (AMD)" <bp@alien8.de> > > Issue a short message once, on the first try to load a 32-bit process to > save people time when wondering why it won't load and says: > > -bash: ./strsep32: cannot execute binary file: Exec format error > > No functional changes. > > Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> > Cc: Nikolay Borisov <nik.borisov@suse.com> LGTM: Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> Would have liked for this function to replace the non-verbose variant but since it's used in syscall it might be easier to miss. > --- > arch/x86/include/asm/elf.h | 2 +- > arch/x86/include/asm/ia32.h | 9 ++++++++- > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h > index a0234dfd1031..1e16bd5ac781 100644 > --- a/arch/x86/include/asm/elf.h > +++ b/arch/x86/include/asm/elf.h > @@ -150,7 +150,7 @@ do { \ > ((x)->e_machine == EM_X86_64) > > #define compat_elf_check_arch(x) \ > - ((elf_check_arch_ia32(x) && ia32_enabled()) || \ > + ((elf_check_arch_ia32(x) && ia32_enabled_verbose()) || \ > (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64)) > > static inline void elf_common_init(struct thread_struct *t, > diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h > index 5a2ae24b1204..43e02b52ad19 100644 > --- a/arch/x86/include/asm/ia32.h > +++ b/arch/x86/include/asm/ia32.h > @@ -2,7 +2,6 @@ > #ifndef _ASM_X86_IA32_H > #define _ASM_X86_IA32_H > > - > #ifdef CONFIG_IA32_EMULATION > > #include <linux/compat.h> > @@ -84,4 +83,12 @@ static inline bool ia32_enabled(void) > > #endif > > +static inline bool ia32_enabled_verbose(void) > +{ > +#ifdef CONFIG_IA32_EMULATION > + pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); > +#endif > + return ia32_enabled(); > +} > + > #endif /* _ASM_X86_IA32_H */
On 30.11.23 г. 17:52 ч., Borislav Petkov wrote: > From: "Borislav Petkov (AMD)" <bp@alien8.de> > > Issue a short message once, on the first try to load a 32-bit process to > save people time when wondering why it won't load and says: > > -bash: ./strsep32: cannot execute binary file: Exec format error > > No functional changes. > > Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> > Cc: Nikolay Borisov <nik.borisov@suse.com> > --- > arch/x86/include/asm/elf.h | 2 +- > arch/x86/include/asm/ia32.h | 9 ++++++++- > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h > index a0234dfd1031..1e16bd5ac781 100644 > --- a/arch/x86/include/asm/elf.h > +++ b/arch/x86/include/asm/elf.h > @@ -150,7 +150,7 @@ do { \ > ((x)->e_machine == EM_X86_64) > > #define compat_elf_check_arch(x) \ > - ((elf_check_arch_ia32(x) && ia32_enabled()) || \ > + ((elf_check_arch_ia32(x) && ia32_enabled_verbose()) || \ > (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64)) > > static inline void elf_common_init(struct thread_struct *t, > diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h > index 5a2ae24b1204..43e02b52ad19 100644 > --- a/arch/x86/include/asm/ia32.h > +++ b/arch/x86/include/asm/ia32.h > @@ -2,7 +2,6 @@ > #ifndef _ASM_X86_IA32_H > #define _ASM_X86_IA32_H > > - > #ifdef CONFIG_IA32_EMULATION > > #include <linux/compat.h> > @@ -84,4 +83,12 @@ static inline bool ia32_enabled(void) > > #endif > > +static inline bool ia32_enabled_verbose(void) > +{ > +#ifdef CONFIG_IA32_EMULATION Hang on, this is wrong, it should be CONFIG_IA32_EMULATION_DEFAULT_DISABLED > + pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); > +#endif > + return ia32_enabled(); > +} > + > #endif /* _ASM_X86_IA32_H */
On Thu, Nov 30, 2023 at 06:00:16PM +0200, Nikolay Borisov wrote:
> Hang on, this is wrong, it should be CONFIG_IA32_EMULATION_DEFAULT_DISABLED
Slow down pls and think: what happens if I boot with ia32_emulation=off
and CONFIG_IA32_EMULATION_DEFAULT_DISABLED is not set?
On 30.11.23 г. 17:52 ч., Borislav Petkov wrote: > From: "Borislav Petkov (AMD)" <bp@alien8.de> > > Issue a short message once, on the first try to load a 32-bit process to > save people time when wondering why it won't load and says: > > -bash: ./strsep32: cannot execute binary file: Exec format error > > No functional changes. > > Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> > Cc: Nikolay Borisov <nik.borisov@suse.com> > --- > arch/x86/include/asm/elf.h | 2 +- > arch/x86/include/asm/ia32.h | 9 ++++++++- > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h > index a0234dfd1031..1e16bd5ac781 100644 > --- a/arch/x86/include/asm/elf.h > +++ b/arch/x86/include/asm/elf.h > @@ -150,7 +150,7 @@ do { \ > ((x)->e_machine == EM_X86_64) > > #define compat_elf_check_arch(x) \ > - ((elf_check_arch_ia32(x) && ia32_enabled()) || \ > + ((elf_check_arch_ia32(x) && ia32_enabled_verbose()) || \ > (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64)) > > static inline void elf_common_init(struct thread_struct *t, > diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h > index 5a2ae24b1204..43e02b52ad19 100644 > --- a/arch/x86/include/asm/ia32.h > +++ b/arch/x86/include/asm/ia32.h > @@ -2,7 +2,6 @@ > #ifndef _ASM_X86_IA32_H > #define _ASM_X86_IA32_H > > - > #ifdef CONFIG_IA32_EMULATION > > #include <linux/compat.h> > @@ -84,4 +83,12 @@ static inline bool ia32_enabled(void) > > #endif > > +static inline bool ia32_enabled_verbose(void) > +{ > +#ifdef CONFIG_IA32_EMULATION > + pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); Actually this will result in a false-positive, even with the DEFAULT_DISABLED but booting with ia32_emulation = 0 so it's best if it's predicated on the output of ia32_enabled. This means we'll always pay the price of the branch even if it's disabled but removes a spurious notice in a certain case. > +#endif > + return ia32_enabled(); > +} > + > #endif /* _ASM_X86_IA32_H */
On Thu, Nov 30, 2023 at 04:52:13PM +0100, Borislav Petkov wrote: > +static inline bool ia32_enabled_verbose(void) > +{ > +#ifdef CONFIG_IA32_EMULATION > + pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); > +#endif > + return ia32_enabled(); > +} As Nik rightfully points out offlist, this should rather be something like: --- bool enabled = ia32_enabled(); #ifdef CONFIG_IA32_EMULATION if (!enabled) pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); #endif return enabled; --- Thx.
On Thu, Nov 30, 2023 at 11:09 AM Borislav Petkov <bp@alien8.de> wrote: > > On Thu, Nov 30, 2023 at 04:52:13PM +0100, Borislav Petkov wrote: > > +static inline bool ia32_enabled_verbose(void) > > +{ > > +#ifdef CONFIG_IA32_EMULATION > > + pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); > > +#endif > > + return ia32_enabled(); > > +} > > As Nik rightfully points out offlist, this should rather be something > like: > > --- > bool enabled = ia32_enabled(); > > #ifdef CONFIG_IA32_EMULATION > if (!enabled) > pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); > #endif > > return enabled; The #ifdef isn't necessary, as ia32_enabled() will always return false in that case. Brian Gerst
On Thu, Nov 30, 2023 at 11:42 AM Brian Gerst <brgerst@gmail.com> wrote: > > On Thu, Nov 30, 2023 at 11:09 AM Borislav Petkov <bp@alien8.de> wrote: > > > > On Thu, Nov 30, 2023 at 04:52:13PM +0100, Borislav Petkov wrote: > > > +static inline bool ia32_enabled_verbose(void) > > > +{ > > > +#ifdef CONFIG_IA32_EMULATION > > > + pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); > > > +#endif > > > + return ia32_enabled(); > > > +} > > > > As Nik rightfully points out offlist, this should rather be something > > like: > > > > --- > > bool enabled = ia32_enabled(); > > > > #ifdef CONFIG_IA32_EMULATION > > if (!enabled) > > pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); > > #endif > > > > return enabled; > > The #ifdef isn't necessary, as ia32_enabled() will always return false > in that case. Scratch that, I misread it. If compat is disabled at build time you don't want the message to appear, or at least would want a different message. Brian Gerst
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index a0234dfd1031..1e16bd5ac781 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h @@ -150,7 +150,7 @@ do { \ ((x)->e_machine == EM_X86_64) #define compat_elf_check_arch(x) \ - ((elf_check_arch_ia32(x) && ia32_enabled()) || \ + ((elf_check_arch_ia32(x) && ia32_enabled_verbose()) || \ (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64)) static inline void elf_common_init(struct thread_struct *t, diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h index 5a2ae24b1204..43e02b52ad19 100644 --- a/arch/x86/include/asm/ia32.h +++ b/arch/x86/include/asm/ia32.h @@ -2,7 +2,6 @@ #ifndef _ASM_X86_IA32_H #define _ASM_X86_IA32_H - #ifdef CONFIG_IA32_EMULATION #include <linux/compat.h> @@ -84,4 +83,12 @@ static inline bool ia32_enabled(void) #endif +static inline bool ia32_enabled_verbose(void) +{ +#ifdef CONFIG_IA32_EMULATION + pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); +#endif + return ia32_enabled(); +} + #endif /* _ASM_X86_IA32_H */