Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp883194rdg; Fri, 13 Oct 2023 04:19:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeoEQtoQ1mYvzYdGtEeOIKdiTaJ97Rp3FHi6hzk5787LECgSyWgMwigCblE4hmGsvfIUE+ X-Received: by 2002:a9d:62d6:0:b0:6c4:c151:8ebe with SMTP id z22-20020a9d62d6000000b006c4c1518ebemr29108077otk.22.1697195942919; Fri, 13 Oct 2023 04:19:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697195942; cv=none; d=google.com; s=arc-20160816; b=pomeL7hmdS2g60QVoSuZoeRhZ/m+ZOBoraRSKgvGEnGyU20hw1d5tiLwCsxTyIi4Mt nlPuEWRm7kgCKuyo/Cl4i7kxbP+GT6y4aOBGa4Dmb+ur5Mfasbae7eUW1yvznKArmudl D7Q+7pZ1Vw6GNsC3NLYF0/ooyQBWbAYQq57icaFM1BmFnTTrN7WDgWFmsDEReih21/7N 3jSCW/AyLBaOQuvryYzBfU1nZh2G3jfwMc+dM34KFa6ixn6iGpeBtaBNITByG0UVPuJJ nCsJk7UAiImRWWkg6L6fclkQfv7DglPS8fxURJq17AlKYsh3hMe/q/gfZ6yJ6GCLCbYQ g6KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=ihpIi2zGpV5iO/jJMKvvrWvIgzFRX85SMyep/niyOVw=; fh=rgFuo364X/bMod36etsfjmew4T/qgY2GNOeHFq2LY2k=; b=qID+jH+rvgPabIqV3pNo9+ue/23eLHfMXPs+C+CYElZBgnT2ybV6I87Va1N0I/87fP WK6gio1N/wW2Xt51anx9cM7IxWmJuvwP+WWbT7NTIbDSTczmzcHh2HUu3sYrJAEGbiW6 fL4YOMKiQ/VfzKU7AtPzR4e6kW6Sy8sXgOPt7+msb3sAnEaLKSXL5dHk0APxrhUVJ+Q4 n4wfQkcRYC19G8iqQXdoyaEMXgNNd/UxUhovfFo5XS34241GP2wPtsb6WQAKdjnb6epY ve/4Sj6wHThYCLCCPHNVWnfHicKBT9GqD1Vt/jDbrK2v6/LtML+ztBXmETHKj0VgIEqn dmeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VveKxmNq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Q5fTleJK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id v17-20020a63f851000000b0055fd1bfb109si4108318pgj.679.2023.10.13.04.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:19:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VveKxmNq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Q5fTleJK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 8BC338217A45; Fri, 13 Oct 2023 04:19:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231166AbjJMLSh (ORCPT + 99 others); Fri, 13 Oct 2023 07:18:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbjJMLSd (ORCPT ); Fri, 13 Oct 2023 07:18:33 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFA43C0; Fri, 13 Oct 2023 04:18:29 -0700 (PDT) Date: Fri, 13 Oct 2023 11:18:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697195907; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ihpIi2zGpV5iO/jJMKvvrWvIgzFRX85SMyep/niyOVw=; b=VveKxmNqOx7pw67Y8bqrI1W0+budg++VYzA6N/TVK1zRbilqaVLpaQRDUCG+CZ/DST9fwt 1T/2QW5pmt0FdYVtSu8OuGNnVY25UR9oRbBVMAWIkDonAAmDCB0lDyCOvVsMTSEYZ18+H5 RtYydfb7Ti7ydrDqHG8+EGVClvJ4CIqjs/jDzSbOALLhoRCmyTpGpfW7P27swMmH7U9u3X oV9Ahehk+cKsurYoEdAOrA3xqvWUbaKmZs+l0uq2tOBDWnMU/VjNI+rPS1ipMffA1/3QXa U4Dw7Eg83a3VWRc/M7E/GiT8ccAR1g1biPajS3h0b+mtF8SD0Wd5it6fY7Br2g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697195907; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ihpIi2zGpV5iO/jJMKvvrWvIgzFRX85SMyep/niyOVw=; b=Q5fTleJKNiHeF1s0R7vK/nO0PDS6X07j7xhaUw56bYEBmZW9c26wwnDJVFUb7js4jlzOe6 7ZUf7F/8o9+ZNKBQ== From: "tip-bot2 for Brian Gerst" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/entry] x86/entry/64: Use TASK_SIZE_MAX for canonical RIP test Cc: Brian Gerst , Ingo Molnar , Andy Lutomirski , Borislav Petkov , Denys Vlasenko , "H. Peter Anvin" , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Josh Poimboeuf , Uros Bizjak , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231011224351.130935-3-brgerst@gmail.com> References: <20231011224351.130935-3-brgerst@gmail.com> MIME-Version: 1.0 Message-ID: <169719590716.3135.10309736631158969894.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Fri, 13 Oct 2023 04:19:00 -0700 (PDT) The following commit has been merged into the x86/entry branch of tip: Commit-ID: 58978b44df7276f7c75a2c6aad6c201421cd4daa Gitweb: https://git.kernel.org/tip/58978b44df7276f7c75a2c6aad6c201421cd4daa Author: Brian Gerst AuthorDate: Wed, 11 Oct 2023 18:43:50 -04:00 Committer: Ingo Molnar CommitterDate: Fri, 13 Oct 2023 13:05:28 +02:00 x86/entry/64: Use TASK_SIZE_MAX for canonical RIP test Using shifts to determine if an address is canonical is difficult for the compiler to optimize when the virtual address width is variable (LA57 feature) without using inline assembly. Instead, compare RIP against TASK_SIZE_MAX. The only user executable address outside of that range is the deprecated vsyscall page, which can fall back to using IRET. Signed-off-by: Brian Gerst Signed-off-by: Ingo Molnar Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Josh Poimboeuf Cc: Uros Bizjak Link: https://lore.kernel.org/r/20231011224351.130935-3-brgerst@gmail.com --- arch/x86/entry/common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index 9021465..4c7154d 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -110,10 +110,10 @@ __visible noinstr bool do_syscall_64(struct pt_regs *regs, int nr) * in kernel space. This essentially lets the user take over * the kernel, since userspace controls RSP. * - * Change top bits to match the most significant bit (47th or 56th bit - * depending on paging mode) in the address. + * TASK_SIZE_MAX covers all user-accessible addresses other than + * the deprecated vsyscall page. */ - if (unlikely(!__is_canonical_address(regs->ip, __VIRTUAL_MASK_SHIFT + 1))) + if (unlikely(regs->ip >= TASK_SIZE_MAX)) return false; /*