* [PATCH] binder: fix sender fd 0 close and file refcount leak on TF_UPDATE_TXN
@ 2026-09-19 21:36 Hui Peng
2026-09-20 5:00 ` Greg KH
2026-09-20 5:00 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Hui Peng @ 2026-09-19 21:36 UTC (permalink / raw)
To: gregkh, arve, tkjos, brauner, cmllamas, aliceryhl; +Cc: linux-kernel
In `binder_proc_transaction()`, when a oneway transaction with
`TF_UPDATE_TXN` supersedes an outdated pending transaction
(`t_outdated`), the driver calls `binder_release_entire_buffer(proc,
NULL, buffer, false)` and `kfree(t_outdated)`.
Passing `is_failure = false` while `buffer->transaction` has already
been set to `NULL` causes two bugs when `t_outdated` contained
`BINDER_TYPE_FDA` or `BINDER_TYPE_FD` objects:
1. For `BINDER_TYPE_FDA`, `binder_translate_fd_array()` never wrote
recipient file descriptors into the buffer (it only appended `struct
file *` entries to `t_outdated->fd_fixups`), so the FD array in
`buffer` still contains zeros (or sender-supplied offsets). Because
`is_failure` is `false`, `binder_transaction_buffer_release()`
executes the `!is_failure` branch on `BINDER_TYPE_FDA` and calls
`binder_deferred_fd_close(fd)` (closing `fd 0` in `current->files`,
which is the **sender** process!).
2. `t_outdated` is freed via `kfree(t_outdated)` without calling
`binder_free_txn_fixups(t_outdated)`, permanently leaking every
translated `struct file` reference in `t_outdated->fd_fixups`.
Pass `is_failure = true` to `binder_release_entire_buffer()` and call
`binder_free_txn_fixups(t_outdated)` before freeing `t_outdated`.
Fixes: 9864bb480133 ("Binder: add TF_UPDATE_TXN to replace outdated txn")
Fixes: bdc1c5fac982 ("binder: fix UAF caused by faulty buffer cleanup")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
drivers/android/binder.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 8f2ef1bd539f..bc8bc9ee43a5 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2930,8 +2930,9 @@ static int binder_proc_transaction(struct binder_transaction *t,
t_outdated->buffer = NULL;
buffer->transaction = NULL;
trace_binder_transaction_update_buffer_release(buffer);
- binder_release_entire_buffer(proc, NULL, buffer, false);
+ binder_release_entire_buffer(proc, NULL, buffer, true);
binder_alloc_free_buf(&proc->alloc, buffer);
+ binder_free_txn_fixups(t_outdated);
kfree(t_outdated);
binder_stats_deleted(BINDER_STAT_TRANSACTION);
}
--
2.55.0.1082.g2b9226bbc0-goog
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] binder: fix sender fd 0 close and file refcount leak on TF_UPDATE_TXN
2026-09-19 21:36 [PATCH] binder: fix sender fd 0 close and file refcount leak on TF_UPDATE_TXN Hui Peng
@ 2026-09-20 5:00 ` Greg KH
2026-09-20 5:00 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-09-20 5:00 UTC (permalink / raw)
To: Hui Peng; +Cc: arve, tkjos, brauner, cmllamas, aliceryhl, linux-kernel
On Sat, Sep 19, 2026 at 09:36:48PM +0000, Hui Peng wrote:
> In `binder_proc_transaction()`, when a oneway transaction with
> `TF_UPDATE_TXN` supersedes an outdated pending transaction
> (`t_outdated`), the driver calls `binder_release_entire_buffer(proc,
> NULL, buffer, false)` and `kfree(t_outdated)`.
>
> Passing `is_failure = false` while `buffer->transaction` has already
> been set to `NULL` causes two bugs when `t_outdated` contained
> `BINDER_TYPE_FDA` or `BINDER_TYPE_FD` objects:
>
> 1. For `BINDER_TYPE_FDA`, `binder_translate_fd_array()` never wrote
> recipient file descriptors into the buffer (it only appended `struct
> file *` entries to `t_outdated->fd_fixups`), so the FD array in
> `buffer` still contains zeros (or sender-supplied offsets). Because
> `is_failure` is `false`, `binder_transaction_buffer_release()`
> executes the `!is_failure` branch on `BINDER_TYPE_FDA` and calls
> `binder_deferred_fd_close(fd)` (closing `fd 0` in `current->files`,
> which is the **sender** process!).
> 2. `t_outdated` is freed via `kfree(t_outdated)` without calling
> `binder_free_txn_fixups(t_outdated)`, permanently leaking every
> translated `struct file` reference in `t_outdated->fd_fixups`.
>
> Pass `is_failure = true` to `binder_release_entire_buffer()` and call
> `binder_free_txn_fixups(t_outdated)` before freeing `t_outdated`.
>
> Fixes: 9864bb480133 ("Binder: add TF_UPDATE_TXN to replace outdated txn")
> Fixes: bdc1c5fac982 ("binder: fix UAF caused by faulty buffer cleanup")
> Assisted-by: LLM
> Signed-off-by: Hui Peng <benquike@gmail.com>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- You sent multiple patches, yet no indication of which ones should be
applied in which order. Greg could just guess, but if you are
receiving this email, he guessed wrong and the patches didn't apply.
Please read the section entitled "The canonical patch format" in the
kernel file, Documentation/process/submitting-patches.rst for a
description of how to do this so that Greg has a chance to apply these
correctly.
- You have marked a patch with a "Fixes:" tag for a commit that is in an
older released kernel, yet you do not have a cc: stable line in the
signed-off-by area at all, which means that the patch will not be
applied to any older kernel releases. To properly fix this, please
follow the documented rules in the
Documentation/process/stable-kernel-rules.rst file for how to resolve
this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] binder: fix sender fd 0 close and file refcount leak on TF_UPDATE_TXN
2026-09-19 21:36 [PATCH] binder: fix sender fd 0 close and file refcount leak on TF_UPDATE_TXN Hui Peng
2026-09-20 5:00 ` Greg KH
@ 2026-09-20 5:00 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-09-20 5:00 UTC (permalink / raw)
To: Hui Peng; +Cc: arve, tkjos, brauner, cmllamas, aliceryhl, linux-kernel
On Sat, Sep 19, 2026 at 09:36:48PM +0000, Hui Peng wrote:
> In `binder_proc_transaction()`, when a oneway transaction with
> `TF_UPDATE_TXN` supersedes an outdated pending transaction
> (`t_outdated`), the driver calls `binder_release_entire_buffer(proc,
> NULL, buffer, false)` and `kfree(t_outdated)`.
>
> Passing `is_failure = false` while `buffer->transaction` has already
> been set to `NULL` causes two bugs when `t_outdated` contained
> `BINDER_TYPE_FDA` or `BINDER_TYPE_FD` objects:
>
> 1. For `BINDER_TYPE_FDA`, `binder_translate_fd_array()` never wrote
> recipient file descriptors into the buffer (it only appended `struct
> file *` entries to `t_outdated->fd_fixups`), so the FD array in
> `buffer` still contains zeros (or sender-supplied offsets). Because
> `is_failure` is `false`, `binder_transaction_buffer_release()`
> executes the `!is_failure` branch on `BINDER_TYPE_FDA` and calls
> `binder_deferred_fd_close(fd)` (closing `fd 0` in `current->files`,
> which is the **sender** process!).
> 2. `t_outdated` is freed via `kfree(t_outdated)` without calling
> `binder_free_txn_fixups(t_outdated)`, permanently leaking every
> translated `struct file` reference in `t_outdated->fd_fixups`.
>
> Pass `is_failure = true` to `binder_release_entire_buffer()` and call
> `binder_free_txn_fixups(t_outdated)` before freeing `t_outdated`.
Please delete all LLM-generated changelog text and rewrite it in your
own words to explain the problem and why this patch is needed (same for
your other 6 patches). Also, how were these all tested?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-20 5:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-19 21:36 [PATCH] binder: fix sender fd 0 close and file refcount leak on TF_UPDATE_TXN Hui Peng
2026-09-20 5:00 ` Greg KH
2026-09-20 5:00 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®