From patchwork Tue Jun 11 20:11:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuxuan Luo X-Patchwork-Id: 1946546 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VzKb04Lx2z23v2 for ; Wed, 12 Jun 2024 06:12:11 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sH7qa-0004Wf-Pm; Tue, 11 Jun 2024 20:12:00 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sH7qZ-0004VA-6q for kernel-team@lists.ubuntu.com; Tue, 11 Jun 2024 20:11:59 +0000 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 188C23F63C for ; Tue, 11 Jun 2024 20:11:59 +0000 (UTC) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-795d19c522eso231103685a.1 for ; Tue, 11 Jun 2024 13:11:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718136717; x=1718741517; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5zrYeyYzZiVJKRpQCsluhQotfktaDC5YkgAsBgsGuuM=; b=i8aPlZY6+NbijIpWn0qLFKQ9XIv3+2Vx+DVAP/gAfXJPzBtVsbttlLZPTJvoXVt6LF BpCBnqkOixGNJfm7cv8wKQAjHDZlIq6r+6O9eCEYyGh4BMps1KhvC0znppacaP2KVp4l kurSmGclv92diYsi3nnZvrrgHGtlA5Y1YfRRuIMow9sQEFYb/4WLMKG4f8mHh38sj8Fc rnKDnpYGHn9XpPUKAdlPy/uZiUff65jZpS6692S3ooCH/HpsTm/VOqMFvcWBJc+WzITo V3np22AWxgwn+TJs40HsPLYY3Bl97gTZMEUhile7z2d+NKSHXJ3kXqy5k3Vds8gRo8HB J+fQ== X-Gm-Message-State: AOJu0Yz65Xei2gBLZo87Hs2YiF9xDDRlE7SFILs8vsBELWQGPjcinFLk CNeJEi6Xr9qVnR6BaunSEWftnp/09dGNijwZBXkykZYlzoT6vxjBAnQO51WVuseE3iSuKTWefV8 r2nw0gOuu+UwHMNgJm6b6fOkAJl03gqfiAbSsi9ahp5VsT/XQnPp4olA9H12kuM/22V35Dt+S7T NaSS5KwCGGUg== X-Received: by 2002:a05:620a:1723:b0:795:5224:6a75 with SMTP id af79cd13be357-79552246afbmr1273821685a.10.1718136716955; Tue, 11 Jun 2024 13:11:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDIUHMGN9tXjdRjw1tdCMruHKiMcBNmXwtleytRIhDVYssIsqEviqo7mQsi7PCWJTlXl8MRg== X-Received: by 2002:a05:620a:1723:b0:795:5224:6a75 with SMTP id af79cd13be357-79552246afbmr1273818685a.10.1718136716428; Tue, 11 Jun 2024 13:11:56 -0700 (PDT) Received: from localhost.localdomain ([2001:67c:1562:8007::aac:4795]) by smtp.gmail.com with ESMTPSA id af79cd13be357-795331c493asm545340885a.104.2024.06.11.13.11.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 13:11:55 -0700 (PDT) From: Yuxuan Luo To: kernel-team@lists.ubuntu.com Subject: [Jammy][PATCH 2/6] x86: Introduce ia32_enabled() Date: Tue, 11 Jun 2024 16:11:41 -0400 Message-Id: <20240611201145.183510-6-yuxuan.luo@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240611201145.183510-1-yuxuan.luo@canonical.com> References: <20240611201145.183510-1-yuxuan.luo@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Nikolay Borisov IA32 support on 64bit kernels depends on whether CONFIG_IA32_EMULATION is selected or not. As it is a compile time option it doesn't provide the flexibility to have distributions set their own policy for IA32 support and give the user the flexibility to override it. As a first step introduce ia32_enabled() which abstracts whether IA32 compat is turned on or off. Upcoming patches will implement the ability to set IA32 compat state at boot time. Signed-off-by: Nikolay Borisov Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20230623111409.3047467-2-nik.borisov@suse.com (cherry picked from commit 1da5c9bc119d3a749b519596b93f9b2667e93c4a) CVE-2024-25744 Signed-off-by: Yuxuan Luo --- arch/x86/entry/common.c | 4 ++++ arch/x86/include/asm/ia32.h | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index e160f502d1dcf..3ea32cbca6513 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -96,6 +96,10 @@ static __always_inline int syscall_32_enter(struct pt_regs *regs) return (int)regs->orig_ax; } +#ifdef CONFIG_IA32_EMULATION +bool __ia32_enabled __ro_after_init = true; +#endif + /* * Invoke a 32-bit syscall. Called with IRQs on in CONTEXT_KERNEL. */ diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h index fada857f0a1ed..5a2ae24b1204f 100644 --- a/arch/x86/include/asm/ia32.h +++ b/arch/x86/include/asm/ia32.h @@ -68,6 +68,20 @@ extern void ia32_pick_mmap_layout(struct mm_struct *mm); #endif -#endif /* CONFIG_IA32_EMULATION */ +extern bool __ia32_enabled; + +static inline bool ia32_enabled(void) +{ + return __ia32_enabled; +} + +#else /* !CONFIG_IA32_EMULATION */ + +static inline bool ia32_enabled(void) +{ + return IS_ENABLED(CONFIG_X86_32); +} + +#endif #endif /* _ASM_X86_IA32_H */