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=1796388437; b=ahxBvRSFG1xzS8RDXljZavfE4GVkVyoPlLVROaqvcJ0WZHzGx57qzQqsjjUd8xv3owrJ KM1/wF6Hd7uVw9prTfQoAoWJlodMkeFiZApAnIfivwDz6Q5aMny5BQyreq/iRbTPcyqcB q/oThtZ4tdaOI7+s3JR/hbBM9RJi26eoiEnHTyfGGVf/epVOIIHUsJ4x666bZrX70/n9I xrLv/m6NdAN+71MfBtRXsgJcSUg9elIZ5NhfdN5/FAyxa7iuPLlIc+avVpnHTwB4Nh78z UaQIDWkwYgsOEUSL9EcjkejNHTVRobEnLZBdaS+bkBLFUc1OjrXlW1fzeCQicAFLagw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388437; 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=JV4DUu/6GRgRD4dPoyjkKcfkd7+MU5rmNJIe+6WPgXs=; b=xFGG4nYEqofrTi9zYaEP3T5yAwipTiE39jUJmfYkwiWmz6HTCt6oMpwUzVqdD0Xffpll 5/cEzjxlDCd3CiPHZCW6B2SxTNMyaECLfyzonb0tCkKo8rInIFCec57dIgT/k2LRcq8Ym +iqn4ow3iEUbyDTjybKbyBFQBsCJGNdTaGdkZwq15WQz6Mdr0BY9U2fCJSNxzxRS65R7u tehRRW5GLGGeA5RnxEdmXG8+Pv5qgNjTOTl64L0a/RMgRLuXJEV/dusS+pHpyW+Y7DLWF sH3ylBjku3/D1CQB6RjDSS3V7gjnrJEWBZ7gaYYQlMe8PhUfpsEYUBEMnF32mQ1w2IQ== 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="E2HyO/Au"; 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 E601A606A336; Fri, 4 Dec 2026 12:47:16 +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=E2HyO/Au Received: by smtp.kernel.org (Postfix) with ESMTPSA id 017841F00897; Fri, 4 Dec 2026 12:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388436; bh=JV4DUu/6GRgRD4dPoyjkKcfkd7+MU5rmNJIe+6WPgXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=E2HyO/AupJ89oVqRyGzRv1F5QMaEqbfSXwVibb7W4Liu/G4fMqYVvYhMlBHKYREVD xOLlo/0vpqqDXiOZsY6MgLrLohiOvt3tDVur6yU3JY2sy+B9k7YrDNwm6L5vgJSqpK vfwgD3omQhZjYBjXJP/zYC+b7qZ4Q98QV6A/K5Gk= 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 0612/1059] w1: netlink: drop the slave after the bus is unlocked Date: Fri, 4 Dec 2026 19:02:23 +0900 Message-ID: <20261204100659.970297424@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 847fa880a3e1b2fdbbf72d89e830566108457637 upstream. w1_process_cb() executes the commands of a netlink message with bus_mutex held, and drops the reference to the slave which the message was addressed to before it unlocks the mutex. If the slave has been detached in the meantime, this is the last reference, and w1_unref_slave() tears the slave down on the spot. That waits - in device_unregister(), for the sysfs callbacks of the slave which are running, and - in w1_therm_remove_slave(), for the readers which have taken a reference to the family data, and both kinds take bus_mutex to talk to the slave. Whoever is waiting for the mutex at that moment is never going to finish, and neither is the thread of the bus master. Unlock the bus first. The reference keeps the slave, and with it the master, alive until then. Fixes: d3a8a9dbb903 ("w1: hold bus_mutex in netlink and search") Cc: stable Signed-off-by: Josef Bacik Reviewed-by: Krzysztof Kozlowski Link: https://patch.msgid.link/20261027-llm-char-misc-w1-v1-6-d2e6bfafb6a4@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/w1/w1_netlink.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/w1/w1_netlink.c +++ b/drivers/w1/w1_netlink.c @@ -478,15 +478,17 @@ static void w1_process_cb(struct w1_mast if (!cmd || err) w1_netlink_queue_status(node->block, node->msg, cmd, err); + dev->priv = NULL; + mutex_unlock(&dev->bus_mutex); + /* ref taken in w1_search_slave or w1_search_master_id when building - * the block + * the block. If it is the last one, the slave is removed, which waits + * for users of the bus. */ if (sl) w1_unref_slave(sl); else atomic_dec(&dev->refcnt); - dev->priv = NULL; - mutex_unlock(&dev->bus_mutex); mutex_lock(&dev->list_mutex); list_del(&async_cmd->async_entry);