Skip to contentSkip to conversation

binder: free fd fixups on superseded transaction teardown

PATCH In review Tristan Madani 3 participants 3 messages Jun 19 – Jun 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 binder: free fd fixups on superseded transaction teardown

From: Tristan Madani <[email protected]>

When a TF_UPDATE_TXN oneway transaction supersedes an outdated pending transaction, the outdated transaction is freed with kfree() but its fd_fixups list is not cleaned up first. Each binder_txn_fd_fixup on the list holds a reference to a struct file (from fget in the sender path) that is never released.

All other transaction teardown paths (binder_free_transaction and the error paths in binder_transaction) correctly call binder_free_txn_fixups() before freeing. Apply the same cleanup to the t_outdated teardown path.

Fixes 9864bb480133 ("Binder: add TF_UPDATE_TXN to replace outdated txn")
---
 drivers/android/binder.c | 1 +
 1 file changed, 1 insertion(+)
drivers/android/binder.c +1 -0
index 5fc2c8ee61b1..955bdfb4d907 100644
@@ -2920,6 +2920,7 @@ static int binder_proc_transaction(struct binder_transaction *t,
 		trace_binder_transaction_update_buffer_release(buffer);
 		binder_release_entire_buffer(proc, NULL, buffer, false);
 		binder_alloc_free_buf(&proc->alloc, buffer);
+		binder_free_txn_fixups(t_outdated);
 		kfree(t_outdated);
 		binder_stats_deleted(BINDER_STAT_TRANSACTION);
 	}
Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Tristan Madani

From: Tristan Madani <[email protected]>

When a TF_UPDATE_TXN oneway transaction supersedes an outdated pending transaction, the outdated transaction is freed with kfree() but its fd_fixups list is not cleaned up first. Each binder_txn_fd_fixup on the list holds a reference to a struct file (from fget in the sender path) that is never released.

Quoted 8 lines

All other transaction teardown paths (binder_free_transaction and the error paths in binder_transaction) correctly call binder_free_txn_fixups() before freeing. Apply the same cleanup to the t_outdated teardown path.

Fixes 9864bb480133 ("Binder: add TF_UPDATE_TXN to replace outdated txn")

Seems reasonable to me.

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Tristan Madani
Quoted 35 lines · Tristan Madani

From: Tristan Madani <[email protected]>

When a TF_UPDATE_TXN oneway transaction supersedes an outdated pending transaction, the outdated transaction is freed with kfree() but its fd_fixups list is not cleaned up first. Each binder_txn_fd_fixup on the list holds a reference to a struct file (from fget in the sender path) that is never released.

All other transaction teardown paths (binder_free_transaction and the error paths in binder_transaction) correctly call binder_free_txn_fixups() before freeing. Apply the same cleanup to the t_outdated teardown path.

Fixes 9864bb480133 ("Binder: add TF_UPDATE_TXN to replace outdated txn")
---
 drivers/android/binder.c | 1 +
 1 file changed, 1 insertion(+)
drivers/android/binder.c +1 -0
index 5fc2c8ee61b1..955bdfb4d907 100644
@@ -2920,6 +2920,7 @@ static int binder_proc_transaction(struct binder_transaction *t,
 		trace_binder_transaction_update_buffer_release(buffer);
 		binder_release_entire_buffer(proc, NULL, buffer, false);
 		binder_alloc_free_buf(&proc->alloc, buffer);
+		binder_free_txn_fixups(t_outdated);
 		kfree(t_outdated);
 		binder_stats_deleted(BINDER_STAT_TRANSACTION);
 	}
Signature · 1 line
2.47.3

Thanks Tristan,