query_data(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… query_data β€” the kernel API manual, bestie edition πŸŽ€

okay so this is query_data(9) from the Kernel API Manual and honestly? she's a little icon. let's get into it ✨


✨ NAME ✨

query_data β€” queries a policy and writes its data to buf πŸ’–

like, you ask a policy a question and she answers by yeeting her data straight into buf. no cap.


🌸 SYNOPSIS 🌸

ssize_t query_data (char *buf , size_t buf_len , char *query , size_t
       query_len );

that's the whole vibe right there ^^ four arguments, one ssize_t return, periodt.


πŸ¦‹ ARGUMENTS πŸ¦‹

  • buf β€” the resulting data is stored here (NOT NULL) 🫢 like this is where the answer goes. and no, she cannot be NULL, don't even try it.
  • buf_len β€” size of buf ✨ gotta tell her how much room she's working with.
  • query β€” query string used to retrieve data 🌸 the actual question, bestie.
  • query_len β€” size of query including second NUL byte πŸ‘€ yes, the second one. it's counting that extra NUL, keep up.

πŸ’œ DESCRIPTION πŸ’œ

okay so the buffers pointed to by buf and query may overlap. the way that this is totally fine because the query buffer is parsed before buf is written to β€” so she reads first, writes second, no drama πŸ’…

the query should look like "<LABEL> <KEY> ", where <LABEL> is the name of the security confinement context and <KEY> is the name of the data to retrieve πŸ”₯

and listen β€” <LABEL> and <KEY> must not be NUL-terminated. like, don't. that's not the assignment πŸ™ˆ

⚠️ real talk: don't expect the contents of buf to be preserved on failure. if it flops, buf is in whatever state it's in. she's not cleaning up after herself, and you shouldn't assume she did 😭

⭐ RETURN ⭐

number of characters written to buf, or -errno on failure πŸ’€ that's it, that's the whole return section. slay.


🌈 SEE ALSO 🌈

buckle up bestie, this list is long and we are not skipping a single one, iykyk πŸ‘‘

Kernel file ./security/apparmor/apparmorfs.c:

every single one, accounted for, no crumbs left behind πŸ“


k that's the whole page, hope it ate πŸ’– this masterpiece lives over at ./security/apparmor and she's stamped October 2026 β€” go off, calendar queen πŸ‘‘βœ¨

πŸ“¦ where this page comes from