From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00B1633EB1A for ; Wed, 22 Jul 2026 08:31:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784709091; cv=none; b=s7MCplN7ja58GWVjwvOgJdGuQtWvx4N8x935fvquS/ej9ARIfBqT0HQ/yCOrRDnwHrEJN13Wy+6+m/yz/vo+1q3h56Yx29b5C2AdJYfQHBas4fHcJMsfbLZCAsCSjCKuc+NBE17rfdKVdkc42ujvyIVR2iBIUquOI7sOjCYrWaY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784709091; c=relaxed/simple; bh=7sHoe670l/nu7cqTiQ3TBHAuNon3qYK7zMopCUZjLjk=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=flyfoHP+qEQpYEZOoAGJjqw2ZchLobbEjyPLeqYB5CUu7/bBH9vI5L5OohA5uVQIPc/5KMBZ9yoQVqd2d7mU/LZzZK6zTLm/8NpA7btMy3TNrN0oRpzscCn7sZuWpeaufkqkR1NnazSuEJStv6vMdAKbMhpFLxl60DeOboTZTfQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=DN/fPE3h; arc=none smtp.client-ip=113.46.200.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="DN/fPE3h" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=/yWXkcRW0kmF0EbtQXKv5wRYzTy/Fum/ZnNTrlwYBL4=; b=DN/fPE3hLSnOCdfEdkXbpzScSL1RkHQY+X9DAYl6pfKwsnm7ddursC+P457yFn1SQqYpskh+7 tWGmeZJWK3KADeSbBMwHwZGgKe9e2YZ9qTRC4AUKGGKntnRNh6KHXmip//cUWXrFHfetaLYupBc yhYzH/tIStqAGMWzfmrAey8= Received: from mail.maildlp.com (unknown [172.19.162.140]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4h4nL36RGCzpT1C; Wed, 22 Jul 2026 16:22:19 +0800 (CST) Received: from dggpemr500006.china.huawei.com (unknown [7.185.36.185]) by mail.maildlp.com (Postfix) with ESMTPS id C6C6C202E6; Wed, 22 Jul 2026 16:31:24 +0800 (CST) Received: from localhost.localdomain (10.50.85.180) by dggpemr500006.china.huawei.com (7.185.36.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 22 Jul 2026 16:31:24 +0800 From: Yao Kai To: CC: , , , , , , , Subject: [PATCH v2 0/2] futex/requeue: Fix requeue PI races Date: Wed, 22 Jul 2026 16:51:38 +0800 Message-ID: <20260722085140.1949077-1-yaokai34@huawei.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To dggpemr500006.china.huawei.com (7.185.36.185) Hi, This series fixes two independent issues in the requeue PI wait path. Patch 1 restores rtmutex scheduling preparation when the temporary removal of futex_q during requeue causes futex_do_wait() to skip schedule(), while the proxy waiter still has to block on the target rtmutex. Patch 2 prevents the requeue side from accessing the waiter's stack-based futex_q after publishing Q_REQUEUE_PI_LOCKED. The saved-task wakeup in requeue_pi_wake_futex() also covers a waiter blocked in the rcuwait synchronization path. Changes since v1: - Replace the scheduler helper split in patch 1 with rt_mutex_pre_schedule()/rt_mutex_post_schedule() directly around rt_mutex_wait_proxy_lock(). - Expand patch 2's comment and changelog to explain why the saved-task wakeup covers rcuwait without losing a wakeup. Thanks to Sebastian for the review and for suggesting the simpler fix for patch 1. v1: https://lore.kernel.org/r/20260717084922.4153317-1-yaokai34@huawei.com Testing: - Build-tested with non-RT and PREEMPT_RT configurations. - The original rt_mutex_schedule() warning reproducer no longer triggers the warning. - The original PREEMPT_RT KASAN reproducer no longer reports an invalid access. - The futex requeue PI selftests and stress tests pass. Yao Yao Kai (2): futex/requeue: Fix rtmutex schedule preparation for requeue PI futex/requeue: Prevent rcuwait use-after-free during requeue PI kernel/futex/requeue.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) -- 2.43.0