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 280EC31B80E; Mon, 27 Oct 2025 19:33:25 +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=1761593605; cv=none; b=StI0yADjkiyroTLtIL2/j3TwNjklwQkZIevwZ8kq1M1T2zmYBLTKaGZgSjlyVF22WbyiZsYnw0g+/MLITlMmeweNxVPOZ3Z0wBIqL3VAOnnNwhggjgiqIBNNvtMyWYlgVUZHchhVb74iOMMWB2YHaIWtRopqjlahNNh5STTGmNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761593605; c=relaxed/simple; bh=MNqezLtXtS8fpZ9zT1z0lS3Y2zxgfYFQua52IOctOho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GM3n25CVN9dtHcHk6SV3k+h9FNOjTzAj/uQnVqGnOa5bn2WCBmsxrCvNh2hESicoH6E/xFqmZhLCDzop/9kLlV9Bc5hvB5CqUbdgZ8bzaDWx75Wf3G+o/gEkGPiad+2YOboh3RgZ+zWoGy1FdQyX3IwhprYD6iNcGY5FprSSDKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HBVL1PBq; 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="HBVL1PBq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9974FC4CEF1; Mon, 27 Oct 2025 19:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761593605; bh=MNqezLtXtS8fpZ9zT1z0lS3Y2zxgfYFQua52IOctOho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HBVL1PBqHygHR7LXdDQr3DZXiZRAuC3WJ0L0LPqeb85fjaHV5Flh4JuehYNuqfvym QICJm8AwsqU1CUSYgk3hAJWryfiQSRlB/XMOkddFtANCMBTE7b7iBnxD8qTYjz+SiF 3iiMwYRLVI2mjzPkJA4HivE8PeF0WlgXW6ZQ9ilA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yu-Ting Tseng , Alice Ryhl Subject: [PATCH 6.17 157/184] binder: remove "invalid inc weak" check Date: Mon, 27 Oct 2025 19:37:19 +0100 Message-ID: <20251027183519.153495484@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027183514.934710872@linuxfoundation.org> References: <20251027183514.934710872@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: Alice Ryhl commit d90eeb8ecd227c204ab6c34a17b372bd950b7aa2 upstream. There are no scenarios where a weak increment is invalid on binder_node. The only possible case where it could be invalid is if the kernel delivers BR_DECREFS to the process that owns the node, and then increments the weak refcount again, effectively "reviving" a dead node. However, that is not possible: when the BR_DECREFS command is delivered, the kernel removes and frees the binder_node. The fact that you were able to call binder_inc_node_nilocked() implies that the node is not yet destroyed, which implies that BR_DECREFS has not been delivered to userspace, so incrementing the weak refcount is valid. Note that it's currently possible to trigger this condition if the owner calls BINDER_THREAD_EXIT while node->has_weak_ref is true. This causes BC_INCREFS on binder_ref instances to fail when they should not. Cc: stable@vger.kernel.org Fixes: 457b9a6f09f0 ("Staging: android: add binder driver") Reported-by: Yu-Ting Tseng Signed-off-by: Alice Ryhl Link: https://patch.msgid.link/20251015-binder-weak-inc-v1-1-7914b092c371@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/android/binder.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -850,17 +850,8 @@ static int binder_inc_node_nilocked(stru } else { if (!internal) node->local_weak_refs++; - if (!node->has_weak_ref && list_empty(&node->work.entry)) { - if (target_list == NULL) { - pr_err("invalid inc weak node for %d\n", - node->debug_id); - return -EINVAL; - } - /* - * See comment above - */ + if (!node->has_weak_ref && target_list && list_empty(&node->work.entry)) binder_enqueue_work_ilocked(&node->work, target_list); - } } return 0; }