mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
selftests/landlock: Fix readlink check
The audit_init_filter_exe() helper incorrectly checks the readlink(2)
error because an unsigned integer is used to store the result. Use a
signed integer for this check.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/aDbFwyZ_fM-IO7sC@stanley.mountain
Fixes: 6a500b2297 ("selftests/landlock: Add tests for audit flags and domain IDs")
Reviewed-by: Günther Noack <gnoack@google.com>
Link: https://lore.kernel.org/r/20250528144426.1709063-1-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
This commit is contained in:
parent
e04c78d86a
commit
94a7ce2642
|
|
@ -403,11 +403,12 @@ static int audit_init_filter_exe(struct audit_filter *filter, const char *path)
|
|||
/* It is assume that there is not already filtering rules. */
|
||||
filter->record_type = AUDIT_EXE;
|
||||
if (!path) {
|
||||
filter->exe_len = readlink("/proc/self/exe", filter->exe,
|
||||
sizeof(filter->exe) - 1);
|
||||
if (filter->exe_len < 0)
|
||||
int ret = readlink("/proc/self/exe", filter->exe,
|
||||
sizeof(filter->exe) - 1);
|
||||
if (ret < 0)
|
||||
return -errno;
|
||||
|
||||
filter->exe_len = ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user