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 18B931A6192; Tue, 30 Jul 2024 17:04:38 +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=1722359078; cv=none; b=NP0JQ32qQ0ouPQGhiASb+LZvWJN1UcAchnlW0yWmi4P9WzOHivqqamOVOmRkGzaJrq/XLZDy3Xn+P6n3l5mHvKC6roZnP/6BVozxOvTi58TwPP0j/JQdhkBGHaO+SNGUZIInAUvsS9vj+TrA/H0/5c5ckn8rfdgAWQuKvK6rMXM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722359078; c=relaxed/simple; bh=vFlSyb+ruMjaU/AixZ+ZPpGk8D8hORkC47ojcc6mKFY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h7J/GpM/s4GsW7bDfN3VNQ3iPBv8Bt4ovDSpMRDPk8LygRM56N+K1XNvZ+JeHg9LKWD3z1E/V0fa+Ltc4b0sGEfCnXv0f4pweAsxv4p+pvtI6Vr05mEVEUc9xvXK2607rJCnKRrOBSO3u435nhKexEl0mpKjdAH/AAljYLp8xKE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Cm14WFDf; 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="Cm14WFDf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96F38C32782; Tue, 30 Jul 2024 17:04:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722359078; bh=vFlSyb+ruMjaU/AixZ+ZPpGk8D8hORkC47ojcc6mKFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cm14WFDf2v3sFNWWnyCml1WgHZXrbWyia2qe/kO4w9QraNaLv0m7l0CaCkikYA4kb s7nRlAxbcdZAGod6kOwEYdi1jJv3K2dHNLXn7TPSe4WSpSvyODUFjBa+Vz4/8w0a1R cZWokW+7wc6NMd3aeUWSuBgIy4JasWjbhXqGZ2uI= 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.6 429/568] binder: fix hang of unregistered readers Date: Tue, 30 Jul 2024 17:48:56 +0200 Message-ID: <20240730151656.637438720@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730151639.792277039@linuxfoundation.org> References: <20240730151639.792277039@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.6-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,