From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4F29727380A; Wed, 10 Dec 2025 07:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765352002; cv=none; b=l9M4owMAzVI4JaW7MBMxhGVwqgrptwjM9eKTjBIx0mcJcQu5NcnDDOxSwPAcTUuInJKl9wap6/+FtxQGlpF4/UajRkGBsitOrOwiV4zX82/8tN//G8stAtI4WFypK66lhGLmvKXaRc9rr1JVpXRE0ftOc3TdKhR0uZFrjB6HrfE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765352002; c=relaxed/simple; bh=M8zzeRoAKwLr7DZxuO7Oe6kty7r4a7kkH9o84KH7xMI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hucZMXpd5iVBEVOK3wtGnazmC4kglgd/FT0uOuxunb8mDY0G0TfC62Gig5MVnMHYinxUloqZkOeIWNLk0IUiruT0z32RUigiwy3hxxPXcelLO8WOXzTIXB/TOwvNIjUWM7LLm/yZ4NvAFXfuUp+wvTTaR9X34HY0a73l7qdq4po= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NX5IYqX3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NX5IYqX3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0D33C4CEF1; Wed, 10 Dec 2025 07:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1765352002; bh=M8zzeRoAKwLr7DZxuO7Oe6kty7r4a7kkH9o84KH7xMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NX5IYqX30T3MJwS+Q5ZiXyamzApmCXx6Uobjgg1yFTse1WNZBudNLQ9rAgm+xiHRk pjgG500KP4ngUerjqzmOOaFpwCbz/il2kd/InIrL9Nu5Dlfr9zwv95I6XtgNdBuars sV7fLhs3da0u60NpLlxeO0bvogQRFZkUc59MYxZ4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Adrian Freihofer , Alexander Sverdlin , Boqun Feng , "Peter Zijlstra (Intel)" , "Paul E. McKenney" , Waiman Long Subject: [PATCH 6.17 05/60] locking/spinlock/debug: Fix data-race in do_raw_write_lock Date: Wed, 10 Dec 2025 16:29:35 +0900 Message-ID: <20251210072947.978984051@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210072947.850479903@linuxfoundation.org> References: <20251210072947.850479903@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Sverdlin commit c14ecb555c3ee80eeb030a4e46d00e679537f03a upstream. KCSAN reports: BUG: KCSAN: data-race in do_raw_write_lock / do_raw_write_lock write (marked) to 0xffff800009cf504c of 4 bytes by task 1102 on cpu 1: do_raw_write_lock+0x120/0x204 _raw_write_lock_irq do_exit call_usermodehelper_exec_async ret_from_fork read to 0xffff800009cf504c of 4 bytes by task 1103 on cpu 0: do_raw_write_lock+0x88/0x204 _raw_write_lock_irq do_exit call_usermodehelper_exec_async ret_from_fork value changed: 0xffffffff -> 0x00000001 Reported by Kernel Concurrency Sanitizer on: CPU: 0 PID: 1103 Comm: kworker/u4:1 6.1.111 Commit 1a365e822372 ("locking/spinlock/debug: Fix various data races") has adressed most of these races, but seems to be not consistent/not complete. >>From do_raw_write_lock() only debug_write_lock_after() part has been converted to WRITE_ONCE(), but not debug_write_lock_before() part. Do it now. Fixes: 1a365e822372 ("locking/spinlock/debug: Fix various data races") Reported-by: Adrian Freihofer Signed-off-by: Alexander Sverdlin Signed-off-by: Boqun Feng Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Paul E. McKenney Acked-by: Waiman Long Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- kernel/locking/spinlock_debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/locking/spinlock_debug.c +++ b/kernel/locking/spinlock_debug.c @@ -184,8 +184,8 @@ void do_raw_read_unlock(rwlock_t *lock) static inline void debug_write_lock_before(rwlock_t *lock) { RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic"); - RWLOCK_BUG_ON(lock->owner == current, lock, "recursion"); - RWLOCK_BUG_ON(lock->owner_cpu == raw_smp_processor_id(), + RWLOCK_BUG_ON(READ_ONCE(lock->owner) == current, lock, "recursion"); + RWLOCK_BUG_ON(READ_ONCE(lock->owner_cpu) == raw_smp_processor_id(), lock, "cpu recursion"); }