check_buffer(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 β€” the binder_alloc for 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:

  1. The buffer is active β€” like, actually active β€” not just sitting there.
  2. 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:

  1. When the buffer is being created β€” that means (buffer->free == 0 && buffer->allow_user_free == 0).
  2. 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:


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