Skip to content

binder: fix premature fd_install() and buffer leak on read -EFAULT

Hui Peng lkml stable 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 1 replyIn review
  2. v11 patch 1 replySuperseded

Changes in v2 from the cover letter

- Split into a 2-patch series with separate single-purpose commits as requested by Greg Kroah-Hartman and Carlos Llamas.
- Added Reviewed-by tag from Carlos Llamas.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2binder: defer fd_install() until after copy_to_user() in binder_thread_read()drivers/android/binder.c+15 -70 replies
2/2binder: free transaction buffer via binder_free_buf() on read -EFAULTdrivers/android/binder.c+8 -00 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchCarlos Llamas
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] binder: fix premature fd_install() and buffer leak on read -EFAULT

This series fixes two error-handling issues in binder_thread_read():

1. Defer fd_install() until after put_user() and copy_to_user() succeed, preventing file descriptors from being prematurely installed into the recipient process's file descriptor table when userspace copy fails.
2. Call binder_free_buf() on -EFAULT error paths in binder_thread_read() so the transaction buffer and associated node/ref references are freed.

Changes in v2:
- Split into a 2-patch series with separate single-purpose commits as requested by Greg Kroah-Hartman and Carlos Llamas.
- Added Reviewed-by tag from Carlos Llamas.

Hui Peng (2):
binder: defer fd_install() until after copy_to_user() in binder_thread_read()
binder: free transaction buffer via binder_free_buf() on read -EFAULT

 drivers/android/binder.c | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)