Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1616295pxb; Mon, 11 Oct 2021 09:33:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDB6h2Wez0j3phaMnpIE3aKlfWfQCqF+Qev/6vky8+EkaLuMTz0/km9FykvoQN3YXQGtoI X-Received: by 2002:aa7:8149:0:b0:44c:916c:1fdb with SMTP id d9-20020aa78149000000b0044c916c1fdbmr27079462pfn.34.1633969991973; Mon, 11 Oct 2021 09:33:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633969991; cv=none; d=google.com; s=arc-20160816; b=ujt2bGKlaH/xAfUqiI4luwDLOYMkGCJRPMSqCUGvwgZ3+T2XS6hMM/HOuj/Qw4pxdX VJRcV1U/fQ+WB734D8BZeXXr0B6dIEXifqgm0I6GvHOZqzXviGX1EMQNprlYYuxneVOp YFcBwPp6iHHqlIVjUcWlWk10YN7iLkrfQs7iWH1nY/L3ELFC9v5Ze4OHvyyTBRQYG7wL tn9Q7zYNdkScBV1btBjFM5YoI4AG3gNaswaZERRdDssYeWfYlH6WyA0w2GcJinV9WSeO OmA+wji3aT+CDpIzEa4lGznopy4SKj00oGFK4wJsePv/CGIm2B3t/Egzc0uWDMRHJHqv XbTA== 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=OB8Ah/niNTjFq7SiMxEe67gQd1WW6oSnGuTF8fmFJQx2XXgTxGUBiGhV+srw9HbIex 8b5n8xTrn5/zTEXLEi0CKKwfo8Q4cT6GFZGt5QBaBjZXCF7JdEc2x8xdSg2oXQjHkvx+ eFtCOHOgLb8JsuLxDWX8A2dDCFvxwfcPPGADXmXNNMr/dgPIGa5QW80yVWirQ8HF44ko 0hKgs1AyCveL5ut/8s46p+LiF0+lMeXLgHbDFkLbUQ5M88gMhVCmxXeA3Tuo2rjLk/tn lJoVwIgwbWD3KB7o42Bey+lXdH9m8+gMUHS55PBKnxt7/AgwdJFlp709lWisBk0ReiKD iqNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OK5ruXQm; 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 v191si10520989pgd.610.2021.10.11.09.32.59; Mon, 11 Oct 2021 09:33:11 -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=OK5ruXQm; 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 S238328AbhJKOAm (ORCPT + 99 others); Mon, 11 Oct 2021 10:00:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:50384 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238380AbhJKN6i (ORCPT ); Mon, 11 Oct 2021 09:58:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F71A610F8; Mon, 11 Oct 2021 13:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633960511; bh=sP/k0sPMtXGbC4p13c1Boye9VVTcVoWXLD4I77BSL9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OK5ruXQmFqkIY09k4vDcR3cobqfU4G18v9ngQTDJvD22iioVmnzzaQHsoNdbSSfOk tY+bHM1BG3KhdtETOULKfiCbZL86kN5vR+hdsTajtwSQqrUhf3sDcOSfdQGG4tLq0w FX9lmzm7Ut5xVbVt8QD5ym/7D1PJ+UOJwCWib9kE= 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.10 81/83] x86/entry: Clear X86_FEATURE_SMAP when CONFIG_X86_SMAP=n Date: Mon, 11 Oct 2021 15:46:41 +0200 Message-Id: <20211011134511.168199120@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011134508.362906295@linuxfoundation.org> References: <20211011134508.362906295@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 }