Received: by 2002:a05:6520:1682:b0:147:d1a0:b502 with SMTP id ck2csp5595898lkb; Mon, 11 Oct 2021 09:38:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtbwxGXxPneotMCTJ1ojYHFpWpBzOaDyI+jyT0kQwfESauP3XKMCHrkXl5+E8+cyzgkw/k X-Received: by 2002:a17:902:6849:b0:13e:97cf:416a with SMTP id f9-20020a170902684900b0013e97cf416amr24922625pln.79.1633970294750; Mon, 11 Oct 2021 09:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633970294; cv=none; d=google.com; s=arc-20160816; b=gm02ll0s4c9aWYjImE+9E3OpH5crf+r0aIR1EDX/QZUgZDtgfa1grjVm/8iYS5pY3H 253mHUcLh6sky+Arf9Z5YxWWqgXzMpgPS7+pEJIN7dgTFIZNwOsdFZ+lX1TuZMDGn/4V 1ceG219nhLalsMgddER/c5Fp6o6y9wGAulSUZvs9QeUoH9UN9K3Namx9haRGXxGxBfev okKeiUNmOyGxx7Q83IRy+3EE/zRTzGSEKEHKxrEE/u0YT7mtB2tEzx6HVUVROfhcJ2Q5 +M3CjeUscOYa+9mBrggYVBksypMG13O4n73TgqdPsByAtv+1pdO/pIQVQ0J/8dFR/SB9 +0Fg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FLAtdyRUaoELaTMAd5vj2dNXUxRVkU1mgXWx5u9rqhg=; b=Q2tFaSb9C0JAoLNeHHzPG3xk5gvz7W00DZGsBWMsf6b1Eu/u47c8ZP/IGSH2vDszow 8SCvmsZrdvsXkNsyCIdHbEejpWVel2PgJ2dRMLBbdzskm2V1zrn2JwCSHaY31+2iRsVF PhDGx+Dioac9ocx+5m7PRHkD8+s8UCw2SAkCLOjHbqcmBWIwEeFchAaX0xsuqdviX89G K4FbvcXPa46eQhetyFpguoccIJQ1DJg6YIYp07lmd0cXlulw+Nu0yTUGPOOXFruP/RKD xAG7LnHfyIXHjDbDB4pDexpcJXwSIw7aFdx7oc6PAVyh7QDVH8+FRsRRq6OOkYq1u9LE L5DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wd2h5Mbu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si11887384pgg.456.2021.10.11.09.38.00; Mon, 11 Oct 2021 09:38:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wd2h5Mbu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244110AbhJKOQ3 (ORCPT + 99 others); Mon, 11 Oct 2021 10:16:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:33954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243984AbhJKONb (ORCPT ); Mon, 11 Oct 2021 10:13:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8409F60C49; Mon, 11 Oct 2021 14:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633961068; bh=sP/k0sPMtXGbC4p13c1Boye9VVTcVoWXLD4I77BSL9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wd2h5MbuZJnU5dNvN5k6u75lW/NIVScjDbsA/Hf+nQ5yQ7QX3VxxzgfFL7pkLQ1M1 xDdijYzxPP6AtAaERwrMLZghtjrz0N5PdkHAavAskeiPOsElZn1s/yYGqmMkf9jDle EVVxVVSXD/MMqkylC1+XrW4ecG0XxU6guei0B1bY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vegard Nossum , Borislav Petkov Subject: [PATCH 5.14 149/151] x86/entry: Clear X86_FEATURE_SMAP when CONFIG_X86_SMAP=n Date: Mon, 11 Oct 2021 15:47:01 +0200 Message-Id: <20211011134522.644823620@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011134517.833565002@linuxfoundation.org> References: <20211011134517.833565002@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vegard Nossum commit 3958b9c34c2729597e182cc606cc43942fd19f7c upstream. Commit 3c73b81a9164 ("x86/entry, selftests: Further improve user entry sanity checks") added a warning if AC is set when in the kernel. Commit 662a0221893a3d ("x86/entry: Fix AC assertion") changed the warning to only fire if the CPU supports SMAP. However, the warning can still trigger on a machine that supports SMAP but where it's disabled in the kernel config and when running the syscall_nt selftest, for example: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 49 at irqentry_enter_from_user_mode CPU: 0 PID: 49 Comm: init Tainted: G T 5.15.0-rc4+ #98 e6202628ee053b4f310759978284bd8bb0ce6905 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 RIP: 0010:irqentry_enter_from_user_mode ... Call Trace: ? irqentry_enter ? exc_general_protection ? asm_exc_general_protection ? asm_exc_general_protectio IS_ENABLED(CONFIG_X86_SMAP) could be added to the warning condition, but even this would not be enough in case SMAP is disabled at boot time with the "nosmap" parameter. To be consistent with "nosmap" behaviour, clear X86_FEATURE_SMAP when !CONFIG_X86_SMAP. Found using entry-fuzz + satrandconfig. [ bp: Massage commit message. ] Fixes: 3c73b81a9164 ("x86/entry, selftests: Further improve user entry sanity checks") Fixes: 662a0221893a ("x86/entry: Fix AC assertion") Signed-off-by: Vegard Nossum Signed-off-by: Borislav Petkov Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20211003223423.8666-1-vegard.nossum@oracle.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/common.c | 1 + 1 file changed, 1 insertion(+) --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -320,6 +320,7 @@ static __always_inline void setup_smap(s #ifdef CONFIG_X86_SMAP cr4_set_bits(X86_CR4_SMAP); #else + clear_cpu_cap(c, X86_FEATURE_SMAP); cr4_clear_bits(X86_CR4_SMAP); #endif }