From patchwork Fri Oct 20 08:17:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 155871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp902036vqb; Fri, 20 Oct 2023 01:17:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXdVrwB2ALW5T8mQoEr3b3iKSq26krPv071U+GdOtGVUpzzWs/x+5d7gEw6A9lvW4vl0gE X-Received: by 2002:a05:6a20:671f:b0:172:eda5:36eb with SMTP id q31-20020a056a20671f00b00172eda536ebmr924481pzh.55.1697789854728; Fri, 20 Oct 2023 01:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697789854; cv=none; d=google.com; s=arc-20160816; b=NwJL9iEOAfpwAV4Q4WD1j8JNpdo8IgFmmAbYWTbX297HqDnnXmw4mVl5ZLZVIu3iI3 Y4eruG7QFMXXWbqTNSr1Y2boIEUWu8rzfzttb72TTx9GJqISEW6jbn7FGzGyBhUaBBRM 1wFW3HVVbbzbL+TDTTYgD7Egxm8vuQYre4USLAw9pOxmMF/e55bnlsHkm4BVNVQY0qkN UbsmgD/ZXr5vwjT0DeoPTkjk3k5sTtGUip4OBi+jxxvuv4uoU5iurKWic8JF9SHoGnXL La+HDxk6tQunW4pJA2uDDhoyLN5QzZCeESGT4hBwDpW8OUkFyQQXxyzya7TWtsrWLDyH 7wGg== 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=tsqPwfyurPJ1VtPXLRho0qj1rZQk0nk+5pGX9DJXsUY=; fh=XIoyqheQ3NGcePdSTEhKG+6uYxUD7hs++iT4wz58/Ss=; b=ib6LGa9ZzJ3RTilSGQ+ho3kBaJxlHvY4qvVLe88Smtbi/MVQDM3/8qs957DVBcUM0t duxmZ1Ikv8qCu6CO1IffcAUct+PSXG9RTuurislP53rCSLpJ2mZvhLX2PBFrrjJQZvah VLj6V4TDVcPc/+aEebmUWCEzrNGfXRvyioDLd/FmoCE/DSAeqU2swDVi5fJwsQPd8RPY kXRTkRkKZxaytqoPA2BFpZRVo2dGmeDTWUA6lldVkZM27BRgGDFY65Jgz9KqS6+NRSmn 7jqknflkLE2jy+Ec5InQO38sDu89Ckxt5rTZAnFQDZAOHHTAe4oKFUr0SDJO2NawqcFb hDNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yCDqz2C2; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n11-20020a17090a9f0b00b0027b49f7c003si3829199pjp.15.2023.10.20.01.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 01:17:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yCDqz2C2; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id B95B58298B47; Fri, 20 Oct 2023 01:17:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235655AbjJTIRW (ORCPT + 25 others); Fri, 20 Oct 2023 04:17:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233512AbjJTIRU (ORCPT ); Fri, 20 Oct 2023 04:17:20 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CC2ED4C; Fri, 20 Oct 2023 01:17:18 -0700 (PDT) Date: Fri, 20 Oct 2023 08:17:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697789837; 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=tsqPwfyurPJ1VtPXLRho0qj1rZQk0nk+5pGX9DJXsUY=; b=yCDqz2C29mZoRx932kaYG/ZhAG+T28J8Z8tiBn/ERJKT+VoRx/II02b0dO6pWnBWut+AVS hMqo2Rl9H8hpQ8Rr8rGQTbIspcTW8HxDFLTPn4ZD1BNCb294xDstbsTWG2Rc0pEkFgCvIg b2CPTMvYr3qVg6mOHt3DG/Jv4jH/e0c/7W9y5tVws5I7r8yUIfP2lCpTjWzb0MbhzoVmQT giS7ICUIQ4GYUFwbMV/TxS3a3kdVkDdyEBxcT7DZaKNmNqr1WK9Boc7UDhkrHBgDcK6AwL lZxCHxGdNMPlDpnqNSd3i0+iYEQWA4caxLWpJX4YkulvSnlXKOGN9gKWfEdQRw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697789837; 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=tsqPwfyurPJ1VtPXLRho0qj1rZQk0nk+5pGX9DJXsUY=; b=NStoGS8HezU5E7a5aR4Dsk3/dfk5hW1lWESEhqL98dFElSs6vlwqCJJn09Yb6nQNhuTo2m wMjYotDHN1KiB6Dw== From: "tip-bot2 for Ben Wolsieffer" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] futex: Don't include process in key on no-MMU Cc: Ben Wolsieffer , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Darren Hart , Davidlohr Bueso , andrealmeid@igalia.com, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231019204548.1236437-2-ben.wolsieffer@hefring.com> References: <20231019204548.1236437-2-ben.wolsieffer@hefring.com> MIME-Version: 1.0 Message-ID: <169778983624.3135.4029741609341875607.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 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 20 Oct 2023 01:17:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780218229759985835 X-GMAIL-MSGID: 1780261694233503264 The following commit has been merged into the locking/core branch of tip: Commit-ID: a684725f587b45955bfc0eadc5ebb36b6dbfb8b6 Gitweb: https://git.kernel.org/tip/a684725f587b45955bfc0eadc5ebb36b6dbfb8b6 Author: Ben Wolsieffer AuthorDate: Thu, 19 Oct 2023 16:45:49 -04:00 Committer: Ingo Molnar CommitterDate: Fri, 20 Oct 2023 10:12:16 +02:00 futex: Don't include process in key on no-MMU On no-MMU, all futexes are treated as private because there is no need to map a virtual address to physical to match the futex across processes. This doesn't quite work though, because private futexes include the current process's mm_struct as part of their key. This makes it impossible for one process to wake up a shared futex being waited on in another process. This patch fixes this bug by excluding the mm_struct from the key. With a single address space, the futex address is already a unique key. Fixes: 784bdf3bb694 ("futex: Assume all mappings are private on !MMU systems") Signed-off-by: Ben Wolsieffer Signed-off-by: Ingo Molnar Acked-by: Peter Zijlstra Cc: Thomas Gleixner Cc: Darren Hart Cc: Davidlohr Bueso Cc: André Almeida Link: https://lore.kernel.org/r/20231019204548.1236437-2-ben.wolsieffer@hefring.com --- kernel/futex/core.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/futex/core.c b/kernel/futex/core.c index ade7c73..52695c5 100644 --- a/kernel/futex/core.c +++ b/kernel/futex/core.c @@ -252,7 +252,17 @@ int get_futex_key(u32 __user *uaddr, unsigned int flags, union futex_key *key, * but access_ok() should be faster than find_vma() */ if (!fshared) { - key->private.mm = mm; + /* + * On no-MMU, shared futexes are treated as private, therefore + * we must not include the current process in the key. Since + * there is only one address space, the address is a unique key + * on its own. + */ + if (IS_ENABLED(CONFIG_MMU)) + key->private.mm = mm; + else + key->private.mm = NULL; + key->private.address = address; return 0; }