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 149EF1A619E; Tue, 30 Jul 2024 16:43:01 +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=1722357781; cv=none; b=OfXIQ4vAnPpZZMXv0M7KQR0U32fJ2uJYDjwx0FZbQ9BpG4VB7+CtjDvgxAfK6ptF0mlj1xuTiImbpgRotDOG+uGsRdE7u2u0ycRQyQ2QjNU0sZBFVYlDlyNpVExbRGTveyIBcj9i7Hh7aaQRzSgpkBVeJ40gMXHA0xlVmHJFsow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722357781; c=relaxed/simple; bh=oyKW7o5EHzD8jP1rX041uVmjCtZFBuJGluI/5wJX+ms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P6N4A3s+WubdmRBS9WNSgWiGuw02kZ/3oR9lzRAtj4pt6SwVu7wJeKdVD0S8tMXAxbKwQw7ZzasrDvo5JfrSaBhpNpDZ73PGxrL9WLGbnx/pwy9Kje1olpT5rFefezyYHYinHM/ICc1/dLjULWkcYizv9lbNN5YnzqdJNzVXhBo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=k6C3yWS7; 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="k6C3yWS7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C83EC32782; Tue, 30 Jul 2024 16:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722357781; bh=oyKW7o5EHzD8jP1rX041uVmjCtZFBuJGluI/5wJX+ms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k6C3yWS7XYdPOYHxJbstQTuPbxTXqyh6VE+ZSeiWT5qhc0Xp8ANorSe9fzscnVXxV +P7XtbSTrLFfb5z+E2NwHnjMFAzuq/kTfGGfFkZTznyBJTct4t7D3xwPJPZOkOtVcS RdykYx04w1gOEqO0Bm+7ZOAgKmf2sMhCY2ue12GM= 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.1 326/440] binder: fix hang of unregistered readers Date: Tue, 30 Jul 2024 17:49:19 +0200 Message-ID: <20240730151628.553169073@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730151615.753688326@linuxfoundation.org> References: <20240730151615.753688326@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.1-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 @@ -569,9 +569,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,