This is a note to let you know that I've just added the patch titled binder: fix async space check for 0-sized buffers to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: binder-fix-async-space-check-for-0-sized-buffers.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 3091c21d3e9322428691ce0b7a0cfa9c0b239eeb Mon Sep 17 00:00:00 2001 From: Carlos Llamas <cmllamas@xxxxxxxxxx> Date: Fri, 1 Dec 2023 17:21:33 +0000 Subject: binder: fix async space check for 0-sized buffers From: Carlos Llamas <cmllamas@xxxxxxxxxx> commit 3091c21d3e9322428691ce0b7a0cfa9c0b239eeb upstream. Move the padding of 0-sized buffers to an earlier stage to account for this round up during the alloc->free_async_space check. Fixes: 74310e06be4d ("android: binder: Move buffer out of area shared with user space") Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx> Signed-off-by: Carlos Llamas <cmllamas@xxxxxxxxxx> Link: https://lore.kernel.org/r/20231201172212.1813387-5-cmllamas@xxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/android/binder_alloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c @@ -415,6 +415,10 @@ static struct binder_buffer *binder_allo alloc->pid, extra_buffers_size); return ERR_PTR(-EINVAL); } + + /* Pad 0-size buffers so they get assigned unique addresses */ + size = max(size, sizeof(void *)); + if (is_async && alloc->free_async_space < size + sizeof(struct binder_buffer)) { binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC, @@ -423,9 +427,6 @@ static struct binder_buffer *binder_allo return ERR_PTR(-ENOSPC); } - /* Pad 0-size buffers so they get assigned unique addresses */ - size = max(size, sizeof(void *)); - while (n) { buffer = rb_entry(n, struct binder_buffer, rb_node); BUG_ON(!buffer->free); Patches currently in stable-queue which might be from cmllamas@xxxxxxxxxx are queue-5.10/binder-use-epollerr-from-eventpoll.h.patch queue-5.10/binder-fix-async-space-check-for-0-sized-buffers.patch queue-5.10/binder-fix-comment-on-binder_alloc_new_buf-return-value.patch queue-5.10/binder-fix-trivial-typo-of-binder_free_buf_locked.patch queue-5.10/binder-fix-unused-alloc-free_async_space.patch