From patchwork Fri Jun 16 12:57:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 109120 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1334570vqr; Fri, 16 Jun 2023 06:15:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ79WIWUfuhwbZV4Y3/FMkPoY8rzqE9ofXMDJVt0ubS2EPH03DCFon9Df/nMbQvrkUxHOGZX X-Received: by 2002:a05:6a20:3d93:b0:10b:78d6:a2c8 with SMTP id s19-20020a056a203d9300b0010b78d6a2c8mr2462524pzi.15.1686921307356; Fri, 16 Jun 2023 06:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686921307; cv=none; d=google.com; s=arc-20160816; b=UunwWb96WqMlaLgPlqhqsobBBXJrchmWUYxoXY/B4U4yihbc10fwEpLiEzrUke4LFx SNOVr5gUHmYu5Ts/9CzMxMonb2x0zT9PYQLtqLMtZkc3DSKSXOl5H2IbzsEiqfnBRnhB +onyYjIXsxUZIH6MC8d7AAI8yO9PW23215E/cnlo+0KHjz8i/dylXTCLpgqB696g36vK iAGOm6DLP1fGHwRkLuTZXSycO96dzyjnJ/8OZDG1ZuQGmuNciX5AHJRYBNXkWOv6aqey Q612haWi6apA6ZKXv14a2VkMKAqvExL2Elva2bllpRUSXthXlLsENlKbc77eThufM6xA H5Rw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uebKOiOaouuF4hP+m2W8QMLwwo8lvdplmN5LTEefmQs=; b=xQZf0rFiEfqpIma3PQUS14xXS9cF5Of88vMVRVvWaBxrV9M6VSZPvts9iCevjj1OrZ RPOqB2TGtqxAHE+FCtI7SyuzPxISk3nFXwqyoa5M91jjj/7JweER1wG0TjWFYUAkfbAL g517fPVN/NSOOMt07wLhfQp1vEzGHiWG1ntf2hE3X4Oy//hTkzbB6OutdUkKIM9zeBVH Nx7NN/xT8+XGuqe/B/91D9EjgtQLRffibScgCVeAgEx/4edXDhCDdXTYEugGhGV6xd9k hs3kf8l+cCWx3gD/9drwdkDa7fhy93pMfGZGbqCfA6W2e67nU5ITv1kRH7XDLIeDIYUS KmDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ApQssAVD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020a63a84c000000b0054392750edfsi3092249pgp.744.2023.06.16.06.14.54; Fri, 16 Jun 2023 06:15:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ApQssAVD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345546AbjFPM6E (ORCPT + 99 others); Fri, 16 Jun 2023 08:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345513AbjFPM5y (ORCPT ); Fri, 16 Jun 2023 08:57:54 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 898F5358C for ; Fri, 16 Jun 2023 05:57:53 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 071211F8AC; Fri, 16 Jun 2023 12:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1686920272; 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=uebKOiOaouuF4hP+m2W8QMLwwo8lvdplmN5LTEefmQs=; b=ApQssAVDFiBkb791JaTp+XIxktjd23BYoBaEWhjnIkcR4UR6Ziljlnuq8PkAWp36ZWfp7h jRcdbUm7Ja7zjBEJRkdn4nGYBEExEXV4DKGne1uxAa6iUzNJXHCIvyNcaMiWdhX2FpuraS puIfvomTJiZ+hOjOPGeaATq5oWT8POs= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A41371330B; Fri, 16 Jun 2023 12:57:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aHRnJU9cjGTjNwAAMHmgww (envelope-from ); Fri, 16 Jun 2023 12:57:51 +0000 From: Nikolay Borisov To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, mhocko@suse.com, jslaby@suse.cz, Nikolay Borisov Subject: [PATCH v3 4/5] x86/elf: Make loading of 32bit processes depend on ia32_enabled() Date: Fri, 16 Jun 2023 15:57:29 +0300 Message-Id: <20230616125730.1164989-5-nik.borisov@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616125730.1164989-1-nik.borisov@suse.com> References: <20230616125730.1164989-1-nik.borisov@suse.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768865196986460786?= X-GMAIL-MSGID: =?utf-8?q?1768865196986460786?= Major aspect of ia32 emulation is the ability to load 32bit processes. That's currently decided (among others) by compat_elf_check_arch(). Make this macro also consider the runtime state of ia32 emulation before allowing to load a 32bit process. Signed-off-by: Nikolay Borisov --- arch/x86/include/asm/elf.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index 18fd06f7936a..a0234dfd1031 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -149,7 +150,7 @@ do { \ ((x)->e_machine == EM_X86_64) #define compat_elf_check_arch(x) \ - (elf_check_arch_ia32(x) || \ + ((elf_check_arch_ia32(x) && ia32_enabled()) || \ (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64)) static inline void elf_common_init(struct thread_struct *t,