summaryrefslogtreecommitdiff
path: root/include/linux/stacktrace.h
diff options
context:
space:
mode:
authorRoberto Sassu <roberto.sassu@huawei.com>2026-06-05 20:22:26 +0300
committerMimi Zohar <zohar@linux.ibm.com>2026-06-08 18:42:49 +0300
commit7bc01800a7739972626e366766f54c3e76cc3e69 (patch)
treec38c562294f1e81bde90d213c0a4eea915970833 /include/linux/stacktrace.h
parenta01183bd6fc66910e2837830aa21dd8da2b7795e (diff)
downloadlinux-7bc01800a7739972626e366766f54c3e76cc3e69.tar.xz
ima: Replace static htable queue with dynamically allocated array
The IMA hash table is a fixed-size array of hlist_head buckets: struct hlist_head ima_htable[IMA_MEASURE_HTABLE_SIZE]; IMA_MEASURE_HTABLE_SIZE is (1 << IMA_HASH_BITS) = 1024 buckets, each a struct hlist_head (one pointer, 8 bytes on 64-bit). That is 8 KiB allocated in BSS for every kernel, regardless of whether IMA is ever used, and regardless of how many measurements are actually made. Replace the fixed-size array with a RCU-protected pointer to a dynamically allocated array that is initialized in ima_init_htable(), which is called from ima_init() during early boot. ima_init_htable() calls the static function ima_alloc_replace_htable() which, other than initializing the hash table the first time, can also hot-swap the existing hash table with a blank one. The allocation in ima_alloc_replace_htable() uses kcalloc() so the buckets are zero-initialised (equivalent to HLIST_HEAD_INIT { .first = NULL }). Callers of ima_alloc_replace_htable() must call synchronize_rcu() and free the returned hash table. Finally, access the hash table with rcu_dereference() in ima_lookup_digest_entry() (reader side) and with rcu_dereference_protected() in ima_add_digest_entry() (writer side). No functional change: bucket count, hash function, and all locking remain identical. Link: https://github.com/linux-integrity/linux/issues/1 Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Diffstat (limited to 'include/linux/stacktrace.h')
0 files changed, 0 insertions, 0 deletions