From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388441; b=wj7G7zGtyM9izy0qncrzdeBwU66AponBvrhqBEmiw053GZiK7DzEQvgBrMez8/pLSfbh GeXEnhr9TAdMJ1I0gLU2ripEod2KWoN+Daa+byOm7Twbemb8H98Qr7c9jbsEyr9OzU2O6 XVKxOaQ/t9Ep0D3GwPrRSZTIIdg1BP+MqKa8ZRDmZqacinrN4syqGVpGb29qYJaz0L2gn 1DutH8ZCpQbbBn8zJ+zOh4N4zLtJm6ujBg77BKsEnOcVODjutVX1DmXYhwjusOaOlnN5G jD6TTjBlVcYa22puuxQcamzzOIA0/K9nilFA5syYQl6Lk4c93wfErhGhZZ4rngT8Ryg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388441; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=tcDCYjGFMiwqXxBwllbP97w37MQSdQt0a589r4aF2NU=; b=wGsSMTsEFGR2T7bLcoRzSZiyD80tbRwn81rbQUBfZt7MJF8cdo3g/0dQqw78EMdkspI1 56fmcgsAcYUyhUmFZqrCR1bvda+9Ql7wgvYnFj8GMPzztswGAKM3zrfDTo96y95S4XUNS YrY0tOiKgWbVzBstYGOP5o9dJJ7Cp+3QGr9DrbueMc8PySyPNyOe3kHnLkFuHWs4bnojJ K+BYiF97kl6IkLu8Nd8wg/PN2uA4YByy8z0bmn/M6TAuy1QifTfd4DVuKX1or/+PNLOEv 7QGAKrn4pMC5bXZevWwmju+nopMQH2u7efz/a/Ux3PjfysCCgv760xgc52VOVUXJEIw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=K7MB9la9; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 841C4606A322; Fri, 4 Dec 2026 12:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=K7MB9la9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4F471F0092C; Fri, 4 Dec 2026 12:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388441; bh=tcDCYjGFMiwqXxBwllbP97w37MQSdQt0a589r4aF2NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=K7MB9la9DW2imccv2mjuulG8X7SrRTXSwLGQKoQfDCgDRLkQpfsKBJDpCZmKMl01v QDfHTVr1qJe7G0tcbM6/v73Vp3ccXJ2yX6j7xScSQv+GsSEs/85s87y2r+ktQM+Cz9 lHALXNUHVOSUS4MfUtIIaCaku8IrDqWAxLBxDzY8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Josef Bacik , Krzysztof Kozlowski Subject: [PATCH 6.1 0614/1059] w1: use the bus mutex for the "rw" file Date: Fri, 4 Dec 2026 19:02:25 +0900 Message-ID: <20261204100700.019738384@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik commit 8599e08648c0b4913ea7b202511f1294d176e793 upstream. Commit b02f8bede217 ("W1: split master mutex to avoid deadlocks.") gave the bus a mutex of its own, because the lock which protects the list of slaves is held while a slave is removed, which waits for the sysfs callbacks of the slave, so these must not take it. It converted all the slave drivers, but not the "rw" file of the default family in w1.c, which still takes the mutex of the master to talk on the bus. That has two consequences: - A deadlock. w1_process() holds the mutex of the master while it searches the bus and detaches the slaves which have gone: w1_process() read() of .../rw mutex_lock(&dev->mutex) kernfs active reference w1_search_process() rw_read() w1_slave_detach() mutex_lock(&master->mutex) w1_unref_slave() waits device_unregister() waits for the reference The file is readable for everybody. - The accesses through this file are not serialised with those of the slave drivers, which take bus_mutex, so that two transactions can get mixed up on the wire. Take bus_mutex here as well. It also excludes the search, which takes it for every pass. Fixes: b02f8bede217 ("W1: split master mutex to avoid deadlocks.") Cc: stable Signed-off-by: Josef Bacik Reviewed-by: Krzysztof Kozlowski Link: https://patch.msgid.link/20261027-llm-char-misc-w1-v1-1-d2e6bfafb6a4@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/w1/w1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -121,7 +121,7 @@ static ssize_t rw_write(struct file *fil { struct w1_slave *sl = kobj_to_w1_slave(kobj); - mutex_lock(&sl->master->mutex); + mutex_lock(&sl->master->bus_mutex); if (w1_reset_select_slave(sl)) { count = 0; goto out_up; @@ -130,7 +130,7 @@ static ssize_t rw_write(struct file *fil w1_write_block(sl->master, buf, count); out_up: - mutex_unlock(&sl->master->mutex); + mutex_unlock(&sl->master->bus_mutex); return count; } @@ -140,9 +140,9 @@ static ssize_t rw_read(struct file *filp { struct w1_slave *sl = kobj_to_w1_slave(kobj); - mutex_lock(&sl->master->mutex); + mutex_lock(&sl->master->bus_mutex); w1_read_block(sl->master, buf, count); - mutex_unlock(&sl->master->mutex); + mutex_unlock(&sl->master->bus_mutex); return count; }