From patchwork Wed Aug 9 21:06:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 133561 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp34269vqi; Wed, 9 Aug 2023 15:04:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXY5faNUanRV45z7MN5erzpaSOlzwHvIww0Lv40bFlofcJH4REgTAlVjwKZIB0wkghsf0C X-Received: by 2002:a05:6a20:12d1:b0:140:3aa:e2c3 with SMTP id v17-20020a056a2012d100b0014003aae2c3mr632002pzg.37.1691618695554; Wed, 09 Aug 2023 15:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691618695; cv=none; d=google.com; s=arc-20160816; b=HIyWzKOeZgFpqhU+ZUIR65pmwXahDEUa1TUMl6+AGYmIJwWK8TO4/C0cDvBhIfPQnQ jdiXZxDvWzeTEkB0ZPYyzjbz5kWP/zjih/QVIEZHA3mQmSS9Ad0PE8/nxa1epbIU1AZe /IaNNFTl3bdf8J2sP8NZ0teatjvWQe5TI3zeRV/qOwJgcwuUzynITOguKBZ67QjmoML0 LM8fws3vRFvcQ/MvMR2icWdzcc6OPVtQD5GqB3UUnPQ3oQAkbAff7N6I3cEPEydQjljx a/3dsnGKa7vLRR8o1TSJ8sZUXqyww3EEgRtHlbA2ypakl5CEByRUNjMNhQm0HEcnOUr5 AngQ== 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:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=8iC6K4qMca1HxvCjZ+227qIOOBi29M4/B4ry0PMUGMM=; fh=dqeYxvdmvLni05CT6MX+jMaOWokq6vp9D/rttdGS/+4=; b=oDwduv7xkaJYiY0atF9mGSMJYX5KEeAUNyM4QdyP01K+j+Bu9sAkbjg6hU936N21/D PE7x2qFMBCcAcu8v+Go0MU3ebl8cUt0MjskDSuH7ZjwlOIE5Df++0KWVPJIO5AyiI6n1 7vbxdiaO6CA5XT/pgMwwUX6EpGmWsTz3qRlkK8vEf+M9c5d2EeKDudN/NmW0OXk+SJau cwvielpP0JFCHph82DtN+8heGhP/ykHRQRc+iBN5SuPxIdVzJnXOpFy3II6yvp++wxtB XTAdlNFMWIja9CkjxOYfCmLG8OFcdh24oh6AyqJ9ddhgBimRDFuaqXPIrYLFkPV6iXEn GJ/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lGWbP+0k; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ct5-20020a056a000f8500b00687f4ebfea9si130485pfb.319.2023.08.09.15.04.39; Wed, 09 Aug 2023 15:04:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lGWbP+0k; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230500AbjHIVG7 (ORCPT + 99 others); Wed, 9 Aug 2023 17:06:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjHIVG6 (ORCPT ); Wed, 9 Aug 2023 17:06:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E64E5138; Wed, 9 Aug 2023 14:06:56 -0700 (PDT) Date: Wed, 09 Aug 2023 21:06:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691615215; 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; bh=8iC6K4qMca1HxvCjZ+227qIOOBi29M4/B4ry0PMUGMM=; b=lGWbP+0kYVNSySa3BRb4DJv8qEN/FE/dh+bZIhuSWyJ/OrljPzjIdOihfEw65n8rTk29iE 7ZKlJO+9u6bPCcBWtRo+JfiSQr7w7915dNwwhIyS7UDXFMzEYNfR8Qlnju9aCovEM0gd49 H9ZmcSyH2KHE72/w5EdGOXaQ/0fMP/aHHa32Vlhm4jgZsGA5U7WGMfwDFfTEQ9rkFaeBHO loLs/SNY6zn+2/KBzlDHwyezIKpr9kGEwzB7sBHQVH5rrNFUBL0tZlBR9mG0XXhI8P+3PH Jb1nqqvAh5rKZqHrCWg614+jhtt4dCKOPgJvoEfBnNvhp3ulEVsHX47fLesQow== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691615215; 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; bh=8iC6K4qMca1HxvCjZ+227qIOOBi29M4/B4ry0PMUGMM=; b=8vqZKJqY3mB6hBcbwK9jhkZFRORLgSUeTBeLp3m4kqRrbVSzPtIPZNjFpY9Hx5RhRkDE4O BBE3C9EnprNJm4DQ== From: "tip-bot2 for Kirill A. Shutemov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/mm: Fix VDSO and VVAR placement on 5-level paging machines Cc: Yingcong Wu , "Kirill A. Shutemov" , Dave Hansen , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169161521427.27769.11895332773100602883.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773790765153575606 X-GMAIL-MSGID: 1773790765153575606 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 1b8b1aa90c9c0e825b181b98b8d9e249dc395470 Gitweb: https://git.kernel.org/tip/1b8b1aa90c9c0e825b181b98b8d9e249dc395470 Author: Kirill A. Shutemov AuthorDate: Thu, 03 Aug 2023 18:16:09 +03:00 Committer: Dave Hansen CommitterDate: Wed, 09 Aug 2023 13:38:48 -07:00 x86/mm: Fix VDSO and VVAR placement on 5-level paging machines Yingcong has noticed that on the 5-level paging machine, VDSO and VVAR VMAs are placed above the 47-bit border: 8000001a9000-8000001ad000 r--p 00000000 00:00 0 [vvar] 8000001ad000-8000001af000 r-xp 00000000 00:00 0 [vdso] This might confuse users who are not aware of 5-level paging and expect all userspace addresses to be under the 47-bit border. So far problem has only been triggered with ASLR disabled, although it may also occur with ASLR enabled if the layout is randomized in a just right way. The problem happens due to custom placement for the VMAs in the VDSO code: vdso_addr() tries to place them above the stack and checks the result against TASK_SIZE_MAX, which is wrong. TASK_SIZE_MAX is set to the 56-bit border on 5-level paging machines. Use DEFAULT_MAP_WINDOW instead. Fixes: b569bab78d8d ("x86/mm: Prepare to expose larger address space to userspace") Reported-by: Yingcong Wu Signed-off-by: Kirill A. Shutemov Signed-off-by: Dave Hansen Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/20230803151609.22141-1-kirill.shutemov%40linux.intel.com --- arch/x86/entry/vdso/vma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 11a5c68..7645730 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -299,8 +299,8 @@ static unsigned long vdso_addr(unsigned long start, unsigned len) /* Round the lowest possible end address up to a PMD boundary. */ end = (start + len + PMD_SIZE - 1) & PMD_MASK; - if (end >= TASK_SIZE_MAX) - end = TASK_SIZE_MAX; + if (end >= DEFAULT_MAP_WINDOW) + end = DEFAULT_MAP_WINDOW; end -= len; if (end > start) {