check_zeroed_user(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… check_zeroed_user(9) β€” like, the Kernel API Manual page, bestie ✨

Okay so this is check_zeroed_user(9) from the Kernel API Manual, and it is literally the most useful little function you didn't know you needed. Grab a snack, we're checking bytes πŸ“


🌸 NAME

check_zeroed_user β€” check if a userspace buffer only contains zero bytes. That's it. That's the whole vibe check 🫢


✨ SYNOPSIS

int check_zeroed_user (const void __user *from , size_t size );

πŸŽ€ ARGUMENTS

  • from β€” Source address, in userspace. Yes bestie, userspace β€” do not come in here with a kernel pointer, that's not the assignment πŸ™ˆ
  • size β€” Size of buffer. How much of it are we sniffing for zeros, mmkay?

πŸ’– DESCRIPTION

So the way this works is: it's effectively shorthand for "memchr_inv(from, 0, size) == NULL" β€” but for userspace addresses. And it's more efficient, because honestly? We don't care where the first non-zero byte is. We just need to know if one exists. No cap. πŸ’…


πŸ”₯ RETURN

  • 0 β€” There were non-zero bytes present in the buffer. Something's in there, icon.
  • 1 β€” The buffer was full of zero bytes. All zeros, no notes, slay ⭐
  • -EFAULT β€” access to userspace failed 😭 (it happens to the best of us)

πŸ¦‹ SEE ALSO

Kernel file ./lib/usercopy.c β€” go read it, iykyk πŸ‘‘


ngl this one's short but it ate. Zero bytes? Checked. Main character energy? Immaculate. 🌈

Source directory: ./lib Β· Version date: October 2026 Β· check_zeroed_user(9) β€” mwah, thanks for reading bestie, ily, go forth and check those zeros πŸ§šπŸ’œ

πŸ“¦ where this page comes from