[PATCH] selftests/landlock: fix the regex_escape() error check

sashiko-bot at kernel.org sashiko-bot at kernel.org
Tue Nov 3 16:43:20 UTC 2026


> regex_escape() returns (char *)-ENOMEM when the buffer is too small, but
> matches_log_fs_extra() checks the returned pointer with "< 0", which is
> never true, and goes on with a bogus cursor. On 32-bit architectures gcc
> also warns about the cast of the pointer in the error return:
> 
>   fs_test.c:7474:24: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
> 
> Compare against (char *)-ENOMEM instead.
> 
> The size left after the escaped path also subtracts the prefix a second
> time, which can make a long path fail with -E2BIG. Compute it from the
> cursor instead.
> 
> Fixes: 316d06b01130 ("selftests/landlock: Add audit tests for filesystem")
> Signed-off-by: Sasha Levin <sashal at kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103163917.641130-1-sashal@kernel.org?part=1




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