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 9B02C1A76A1; Tue, 30 Jul 2024 17:24:07 +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=1722360247; cv=none; b=tuWo6Yx4CTrhGe9uhKQwBdJQXFmnb6tC1uY4giJECcN/d2f3ouOENQHjcf6dsgftEnDnO/cSQIg97soCml8FmncmgXg0F87rOtLgcNKDFJhXSpz64uTrr7yPs7QsclHZ6sr7rR3lH/yE0kfQro4YhzAGUrIVYTwwTSHIeHTpw9w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722360247; c=relaxed/simple; bh=1RtCZw7E0Esj1Ik9ZeA1a6/cZ6SHx8Vh871wSqSpQlI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NAdkOQyTbc0TWY+Pg3KRKid977rtPT/XFsjkkJME/yVQClKqz+8xW/oKK0nZohhSqR3qQWmnhweN+fF4tj4qT+FbgbBTCdPlr3l5X1VzHpRWRXN1+N/HR1719Vfaen50heSDD9Zurr9p5kJx4ddXXQFD2QoXcFYDM1o/2AuF8Tw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Y0flB5jz; 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="Y0flB5jz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0ACD0C4AF0E; Tue, 30 Jul 2024 17:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722360247; bh=1RtCZw7E0Esj1Ik9ZeA1a6/cZ6SHx8Vh871wSqSpQlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y0flB5jzu52sjU0iJ57+io1GpKrAJI32RUnCGXgkfJ32IdfbQHtWhVN+0uZdEaqh3 0EjcaUryFmwGFFlCB1v4Ck/Z6paQLEKhnb/7Tp5vkyKYno7/dC9h+ZN3fG3ROHlXQQ DTeINrw5dGqFboZ2bAhK7pVGwq3qGOuVLDIJrjhk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Martijn Coenen , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Carlos Llamas Subject: [PATCH 6.10 642/809] binder: fix hang of unregistered readers Date: Tue, 30 Jul 2024 17:48:38 +0200 Message-ID: <20240730151750.221430575@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730151724.637682316@linuxfoundation.org> References: <20240730151724.637682316@linuxfoundation.org> User-Agent: quilt/0.67 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Carlos Llamas commit 31643d84b8c3d9c846aa0e20bc033e46c68c7e7d upstream. With the introduction of binder_available_for_proc_work_ilocked() in commit 1b77e9dcc3da ("ANDROID: binder: remove proc waitqueue") a binder thread can only "wait_for_proc_work" after its thread->looper has been marked as BINDER_LOOPER_STATE_{ENTERED|REGISTERED}. This means an unregistered reader risks waiting indefinitely for work since it never gets added to the proc->waiting_threads. If there are no further references to its waitqueue either the task will hang. The same applies to readers using the (e)poll interface. I couldn't find the rationale behind this restriction. So this patch restores the previous behavior of allowing unregistered threads to "wait_for_proc_work". Note that an error message for this scenario, which had previously become unreachable, is now re-enabled. Fixes: 1b77e9dcc3da ("ANDROID: binder: remove proc waitqueue") Cc: stable@vger.kernel.org Cc: Martijn Coenen Cc: Arve Hjønnevåg Signed-off-by: Carlos Llamas Link: https://lore.kernel.org/r/20240711201452.2017543-1-cmllamas@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/android/binder.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -570,9 +570,7 @@ static bool binder_has_work(struct binde static bool binder_available_for_proc_work_ilocked(struct binder_thread *thread) { return !thread->transaction_stack && - binder_worklist_empty_ilocked(&thread->todo) && - (thread->looper & (BINDER_LOOPER_STATE_ENTERED | - BINDER_LOOPER_STATE_REGISTERED)); + binder_worklist_empty_ilocked(&thread->todo); } static void binder_wakeup_poll_threads_ilocked(struct binder_proc *proc,