From patchwork Fri Jun 9 11:13:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 105559 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp873567vqr; Fri, 9 Jun 2023 04:28:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ46I4ctBbtamp5tVP4cJwAIYMzZf8eIBvz3r8AalZA6VZXFBvfKgpYZoaANAX5y/EaGodRK X-Received: by 2002:a17:902:b10d:b0:1b3:8aea:515c with SMTP id q13-20020a170902b10d00b001b38aea515cmr395973plr.54.1686310080352; Fri, 09 Jun 2023 04:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686310080; cv=none; d=google.com; s=arc-20160816; b=iUG9g1mSyx/q4ilx/UpLyIOVjDgExB5SPSYAhfoIFFb/oqqtQGd2duH+fkZ35Ojj/c 9hbmuqDuP+0iMNm6GPl3kD0l2SVl6PtL6klKfMHWBb3WBPRwhe+E7vgUDRMlZdAcIspq 3PvBTi+T0SOfxAHPiKTwwR97FSfI56ULyH5xcd5P88yLJc9I4ktHEjZ/Kc266PbA82zt AdTMSk7Y28A0Rtq6wdK4E9ye9MIqyvZ9w+fm0u2ZViCb6zluWsrSlxLyjK+petQlP6k7 BgDeutM/P++04lRHZUffXnS+7ONnBTZMwBtRLVZF0FW67qJ5MeSxoD6T1/cU7mDEYYCG FixQ== 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=HtizpSkxYlWAXraFNdbEL4Y1/gcbY1LlaDxMnphho2M=; b=nmdJ0Upm9EFvnhmK+GpU0RUCbNAN3yC+bDu9wVCLAI6mR2Kn46sjywaCuJtGWsWcxu IiUWkYUSerNj2XQ9jDpQBgCSr8rG2vD2AxOQ3zNUOy2CDZLrQP2/sUCiU6CY+lyRiYnq FeaQvKdNyBCOYuGI7Yrt6mjNaoGvK6NwlhabQwD/qFxWVsDAdkNYeyKd/PCNyl9ZcsNt gliO6uhqqHRmbvtZF9orZsLbZoqO6gJfJhhvIKVmTB9EmIBnoHHDm4njsStDl+FEQPri kgUK/FX4H32UoF/J2V0HiAKhgp+Uk79+292caWlJw1cK8YxWM5dFBok5hhDHo5k3p9BJ J+dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=UfksIQJp; 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 j8-20020a170902da8800b001b01fc73474si2590030plx.588.2023.06.09.04.27.45; Fri, 09 Jun 2023 04:28:00 -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=UfksIQJp; 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 S239330AbjFILN2 (ORCPT + 99 others); Fri, 9 Jun 2023 07:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239066AbjFILNS (ORCPT ); Fri, 9 Jun 2023 07:13:18 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D44D11FDC for ; Fri, 9 Jun 2023 04:13:17 -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 7F7FA1FDF8; Fri, 9 Jun 2023 11:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1686309196; 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=HtizpSkxYlWAXraFNdbEL4Y1/gcbY1LlaDxMnphho2M=; b=UfksIQJpywX61OplTPxdtEDNEBSpbS3sTOKsu5I1T09Sg+g+iZOZnic15IyTQ7jF02wqJk cAAUC0lHEDfDIMbPAsSptmzLjsj6Dep7T7jvofqOl+VMNFnCp2oHgBAm79TsGGQojOkRph pzQb8epcwfI04NZZLFJoct3BG1dBTzQ= 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 2BBDA139C8; Fri, 9 Jun 2023 11:13:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cAXTB0wJg2ReIwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 11:13:16 +0000 From: Nikolay Borisov To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, mhocko@suse.com, jslaby@suse.cz, Nikolay Borisov Subject: [PATCH v2 4/4] x86: Disable laoding 32bit processes if ia32_disabled is true Date: Fri, 9 Jun 2023 14:13:11 +0300 Message-Id: <20230609111311.4110901-5-nik.borisov@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609111311.4110901-1-nik.borisov@suse.com> References: <20230609111311.4110901-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?1768224278500984705?= X-GMAIL-MSGID: =?utf-8?q?1768224278500984705?= In addition to disabling 32bit syscall interface let's also disable the ability to load 32bit compat processes. Signed-off-by: Nikolay Borisov --- arch/x86/include/asm/elf.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index 18fd06f7936a..0fa49388ff16 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h @@ -148,9 +148,16 @@ do { \ #define elf_check_arch(x) \ ((x)->e_machine == EM_X86_64) +#ifdef CONFIG_IA32_EMULATION +extern bool ia32_disabled; #define compat_elf_check_arch(x) \ - (elf_check_arch_ia32(x) || \ + ((elf_check_arch_ia32(x) && !ia32_disabled) || \ (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64)) +#else +#define compat_elf_check_arch(x) \ + (elf_check_arch_ia32(x) || \ + (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64)) +#endif static inline void elf_common_init(struct thread_struct *t, struct pt_regs *regs, const u16 ds)