[PATCH v2] ima: Fix out-of-bounds read in ima_read_policy()

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Dec 2 11:01:21 UTC 2026


> From: Roberto Sassu <roberto.sassu at huawei.com>
> 
> ima_read_policy() reads the policy file with kernel_read_file_from_path()
> and splits it into rules with strsep(). However, the buffer allocated by
> kernel_read_file_from_path() is exactly the size of the file and is not
> NUL-terminated. If the policy file does not end with a newline, strsep()
> scans past the end of the buffer while looking for the next separator. If
> the file size is a multiple of PAGE_SIZE, the scan reaches the vmalloc
> guard page and the kernel oopses.
> 
> To avoid the problem, reject the read policy if does not end with a newline
> or the NUL terminator.
> 
> Fixes: 7429b092811f ("ima: load policy using path")
> Reported-by: Fabrice Derepas <fabrice.derepas at canonical.com>
> Closes: https://lore.kernel.org/linux-integrity/20260814085443.1211989-1-fabrice.derepas@canonical.com/
> Suggested-by: Mimi Zohar <zohar at linux.ibm.com>
> Signed-off-by: Roberto Sassu <roberto.sassu at huawei.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202105724.3056284-1-roberto.sassu@huaweicloud.com?part=1



More information about the Linux-security-module-archive mailing list