linux/security/integrity/evm
Pengpeng Hou 8df81954d2 evm: terminate and bound the evm_xattrs read buffer
[ Upstream commit 11143a19f5 ]

evm_read_xattrs() allocates size + 1 bytes, fills them from the list of
enabled xattrs, and then passes strlen(temp) to
simple_read_from_buffer(). When no configured xattrs are enabled, the
fill loop stores nothing and temp[0] remains uninitialized, so strlen()
reads beyond initialized memory.

Explicitly terminate the buffer after allocation, use snprintf() for
each formatted line, and pass the accumulated length, without risk of
truncation, to simple_read_from_buffer().

Fixes: fa516b66a1 ("EVM: Allow runtime modification of the set of verified xattrs")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Reviewed-by: Roberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-07-24 15:51:28 +02:00
..
evm.h evm: Verify portable signatures against all protected xattrs 2021-06-01 15:17:31 -04:00
evm_crypto.c evm: Fix build warnings 2023-07-23 13:46:48 +02:00
evm_main.c evm: Fix build warnings 2023-07-23 13:46:48 +02:00
evm_posix_acl.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
evm_secfs.c evm: terminate and bound the evm_xattrs read buffer 2026-07-24 15:51:28 +02:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00