check_buffer(9)
β¨ check_buffer β the vibe check for buffer safety β¨
Okay bestie, so picture this: it's check_buffer(9), a kernel API manual page (yeah, the 9 means section 9, kernel developer land π), and it's basically the bouncer at the club door of memory access. It checks if a buffer and an offset with a byte count are even safe to touch. No cap, this is important stuff. Let me break it down for you π
π SYNOPSIS
bool check_buffer (struct binder_alloc *alloc , struct binder_buffer
*buffer , binder_size_t offset , size_t bytes );
That's the whole vibe: takes some binder allocator info, a buffer, an offset into the buffer's data, and a byte count, then hands you back a bool. Slay.
πΈ ARGUMENTS
allocβ thebinder_allocfor this proc. Lowkey the home base for everything buffer-related.bufferβ the binder buffer that's getting accessed. The main character, honestly.offsetβ where in the buffer data you're looking. An offset into the buffer data, bestie.bytesβ how many bytes you're trying to touch starting from that offset.
π DESCRIPTION
So the actual job of this function is to verify that the offset/bytes pair fits inside the given buffer's size, and also that the buffer is currently active and not freeable. Two firm rules of the house:
- The buffer is active β like, actually active β not just sitting there.
- The offsets have to be multiples of
sizeof(u32). The kernel has standards, okay? π
The kernel is allowed to touch the buffer in exactly two situations:
- When the buffer is being created β that means
(buffer->free == 0 && buffer->allow_user_free == 0). - When the buffer is being torn down β that means
(buffer->free == 0 && buffer->transaction == NULL).
Outside of those two scenarios, it's a no. Nada. Not today. π
β¨ RETURN
Returns true if the buffer is safe to access. Otherwise it's giving false, and you should not touch that buffer, periodt.
π SEE ALSO
The kernel file lives at ./drivers/android/binder_alloc.c β that's the source, bestie.
Related functions, all in the binder_alloc family, all iconic in their own right:
binder_alloc_prepare_to_free(9)binder_alloc_new_buf(9)binder_alloc_get_page(9)binder_alloc_clear_buf(9)binder_alloc_free_buf(9)binder_alloc_mmap_handler(9)binder_alloc_print_allocated(9)binder_alloc_print_pages(9)binder_alloc_get_allocated_count(9)binder_alloc_vma_close(9)binder_alloc_free_page(9)binder_alloc_init(9)binder_alloc_copy_user_to_buffer(9)
That's the tea π Formatting note for the very end: this page ships with the Linux kernel v6.1 manual set, dated October 2026, and the source lives under ./drivers/android. So if anyone asks where this came from, that's the whole story. Byeee π«Άπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms