ima_file_hash(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ ima_file_hash(9) β€” a Kernel API Manual moment ✨

okay so bestie, welcome to the Kernel API Manual πŸ’– this one is literally about ima_file_hash(9), and it’s giving β€œget the measurement of the file” energy. stay with me, it’s not scary fr fr 🫢


🌸 NAME 🌸

ima_file_hash β€” return a measurement of the file ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

int ima_file_hash (struct file *file , char *buf , size_t buf_size );

πŸŽ€ ARGUMENTS πŸŽ€

  • file β€” pointer to the file πŸ‘€
  • buf β€” buffer in which to store the hash 🧺
  • buf_size β€” length of the buffer πŸ“

πŸ’… DESCRIPTION πŸ’…

On success, return the hash algorithm (as defined in the enum hash_algo) πŸ”₯ If buf is not NULL, this function also outputs the hash into buf. If the hash is larger than buf_size, then only buf_size bytes will be copied.

It generally just makes sense to pass a buffer capable of holding the largest possible hash: IMA_MAX_DIGEST_SIZE πŸ’– The file hash returned is based on the entire file, including the appended signature. no cap, the whole thing 🫢

If the measurement cannot be performed, return -EOPNOTSUPP 😭 If the parameters are incorrect, return -EINVAL πŸ’€


🌈 SEE ALSO 🌈

Kernel file ./security/integrity/ima/ima_main.c β€” and also, go say hi to these icons: ima_file_free(9), ima_file_mmap(9), ima_file_mprotect(9), ima_bprm_check(9), ima_creds_check(9), ima_bprm_creds_for_exec(9), ima_file_check(9), ima_inode_hash(9), ima_post_create_tmpfile(9), ima_post_path_mknod(9), ima_read_file(9), ima_post_read_file(9), ima_load_data(9), ima_post_load_data(9), process_buffer_measurement(9), ima_kexec_cmdline(9), ima_measure_critical_data(9), ima_measure_raw_policy(9), ima_kernel_module_request(9) ⭐


xoxo πŸ’… source/version: ./security/integrity/ima Β· date: October 2026 Β· title: ima_file_hash(9) β€” periodt πŸŽ€

πŸ“¦ where this page comes from