From patchwork Wed Dec 6 00:43:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Luczaj X-Patchwork-Id: 174249 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3814451vqy; Tue, 5 Dec 2023 17:16:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqv6+V7v0LlAGC/iqt0yYGeuI9iVrbeVszy2IBVgecejtnXFCc0fUjs0SrGKLK3XYWf8zF X-Received: by 2002:a17:902:ed01:b0:1d0:6ffd:ae0d with SMTP id b1-20020a170902ed0100b001d06ffdae0dmr56175pld.116.1701825384957; Tue, 05 Dec 2023 17:16:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701825384; cv=none; d=google.com; s=arc-20160816; b=mkOc8rBASULltFMQ78IelubfI2wKR4GszNqc2xhJuCPWJ7nCuMaAyR3DeePzVldeRv X50UVwduOaBK4qEXm7eCPtSy0wfynhEmqNv+0TVUhkLfslqi83zhculomOiCIXHr/TJy y03imq+LP6oCSz2FgSe3r+ChYIiA08PcoQBD6F8zWsuLTL+1DAud1QbB4X18keo2HsFc yUsh+hGIrS+u4w9h9fvNLoG2KU3crBPmA7jTTfKpbjUVjMAZJO5E4yir3vgKG0X1tAHi GiFM18Rz/eV2+peKaiwTMxECEvC7B2FNROGCGXn6r4k7EvLc7O9l60d3lV8NKRI2C88i MCRg== 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=a+Blmlooy40wuxd6EVVL4ZFgXJ/+LK2NPLR98nHVQXg=; fh=QpG4oSCzjvlRc4Wvk4YBLwgk9OlswdupxNttoshDpeA=; b=lfSDCBNsi4OAtaCirrgyLihs1XWkQOjjvrcgJfYMEEi/hhXpc6djzhKZLCDVNCg8Yy g/qkQ/A+KjOg+KbfQmb2wcWSE1WiVF5cBLeR0hySjbV1bbLHFdJ3XuMhG3Gcq0BKYi5k li9WsLtYvQarGH/RKhsIJBkG29cCtrMEi76F8v6+oc2c2dX1YON9/O/HTYYZC1fqGMca AVpPNkwMaNEAzbfmVKVu0B9vbr/UXrajn0PTuM+nHI9RWDSlSC2GDx0gbajJiJaksGzh RcGtfUSB5OK/r3XkhUK6AyrkmuUyUCksPhN3IiQZkC9UPHHCQheb/w7/SroNxZoyIUm4 7Fkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rbox.co header.s=selector2 header.b=ZM5E98Gl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=rbox.co Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id p5-20020a170902e74500b001d0bf633521si2708932plf.125.2023.12.05.17.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 17:16:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@rbox.co header.s=selector2 header.b=ZM5E98Gl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=rbox.co Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7C4398031133; Tue, 5 Dec 2023 17:16:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229676AbjLFBQD (ORCPT + 99 others); Tue, 5 Dec 2023 20:16:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229617AbjLFBQC (ORCPT ); Tue, 5 Dec 2023 20:16:02 -0500 X-Greylist: delayed 1488 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 05 Dec 2023 17:16:07 PST Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [IPv6:2a0c:5a00:149::26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 193C0181 for ; Tue, 5 Dec 2023 17:16:06 -0800 (PST) Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1rAg7y-000DVy-MM; Wed, 06 Dec 2023 01:51:02 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rbox.co; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From; bh=a+Blmlooy40wuxd6EVVL4ZFgXJ/+LK2NPLR98nHVQXg=; b=ZM5E98GluA2CEKQ4iDCTpp3ApO NuDgEWwDpJwBak4MATBt4IGDgXmiyIWu+1Pfd+9Ppch8pA1b6fRg97+jlfwMAIlpoZkgL4qSNHc4x 2Re1i2ExHhf7idHVedHsfCr+krVOY1+xqiNvN+LXvKyjlDGYTO1aotBexZlKh9nWNrZGnfv0aWkv2 NYzXZV7cGfUURAtkgar1CLWd8ll0mBcQnWCjUPBp0vAzNKBepBJ6/zk/DptQkOlHhzJwPIoCefgI/ cZOEHBkN/z+CKmkYC7MuKE3JLg+RyatsbZd1/oaBZCTolZdEqbflwTtQ+q13d4ppgZFVxhIfXt0TI 278olAlA==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1rAg7y-0001zg-5R; Wed, 06 Dec 2023 01:51:02 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (604044)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1rAg7k-00CFCn-3w; Wed, 06 Dec 2023 01:50:48 +0100 From: Michal Luczaj To: x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, shuah@kernel.org, luto@kernel.org, torvalds@linuxfoundation.org, linux-kernel@vger.kernel.org, Michal Luczaj Subject: [PATCH 1/2] x86/traps: Attempt UMIP fixup only on #GP(0) Date: Wed, 6 Dec 2023 01:43:44 +0100 Message-ID: <20231206004654.2986026-2-mhal@rbox.co> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231206004654.2986026-1-mhal@rbox.co> References: <20231206004654.2986026-1-mhal@rbox.co> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 05 Dec 2023 17:16:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784493254359095215 X-GMAIL-MSGID: 1784493254359095215 Do not allow for UMIP exception fixup if the exception did not come directly from the user space. This excludes #GP due to a bad IRET. Signed-off-by: Michal Luczaj --- arch/x86/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index c876f1d36a81..1daa7cd9a76c 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -651,7 +651,7 @@ DEFINE_IDTENTRY_ERRORCODE(exc_general_protection) cond_local_irq_enable(regs); if (static_cpu_has(X86_FEATURE_UMIP)) { - if (user_mode(regs) && fixup_umip_exception(regs)) + if (user_mode(regs) && !error_code && fixup_umip_exception(regs)) goto exit; }