query_data(9)
π 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 beNULL, don't even try it.buf_lenβ size ofbufβ¨ gotta tell her how much room she's working with.queryβ query string used to retrieve data πΈ the actual question, bestie.query_lenβ size ofqueryincluding 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 ofbufto be preserved on failure. if it flops,bufis 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:
mangle_name(9)__aafs_setup_d_inode(9)aafs_create(9)aafs_create_file(9)aafs_create_dir(9)aafs_remove(9)aa_simple_write_to_buffer(9)aa_get_data_from_compressed(9)query_label(9)aa_write_access(9)__next_ns(9)__first_profile(9)__next_profile(9)next_profile(9)p_start(9)p_next(9)p_stop(9)seq_show_profile(9)entry_create_file(9)entry_create_dir(9)entry_remove_file(9)entry_remove_dir(9)aa_destroy_aafs(9)aa_create_aafs(9)
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
- 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