mirror of
https://github.com/torvalds/linux.git
synced 2026-06-05 13:06:59 +02:00
selftests/x86/lam: Zero out buffer for readlink()
[ Upstream commit2906063341] Zero out the buffer for readlink() since readlink() does not append a terminating null byte to the buffer. Also change the buffer length passed to readlink() to 'PATH_MAX - 1' to ensure the resulting string is always null terminated. Fixes:833c12ce0f("selftests/x86/lam: Add inherit test cases for linear-address masking") Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Link: https://lore.kernel.org/r/20231016062446.695-1-binbin.wu@linux.intel.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
b0ebeb5956
commit
b13513e764
|
|
@ -573,7 +573,7 @@ int do_uring(unsigned long lam)
|
|||
char path[PATH_MAX] = {0};
|
||||
|
||||
/* get current process path */
|
||||
if (readlink("/proc/self/exe", path, PATH_MAX) <= 0)
|
||||
if (readlink("/proc/self/exe", path, PATH_MAX - 1) <= 0)
|
||||
return 1;
|
||||
|
||||
int file_fd = open(path, O_RDONLY);
|
||||
|
|
@ -680,14 +680,14 @@ static int handle_execve(struct testcases *test)
|
|||
perror("Fork failed.");
|
||||
ret = 1;
|
||||
} else if (pid == 0) {
|
||||
char path[PATH_MAX];
|
||||
char path[PATH_MAX] = {0};
|
||||
|
||||
/* Set LAM mode in parent process */
|
||||
if (set_lam(lam) != 0)
|
||||
return 1;
|
||||
|
||||
/* Get current binary's path and the binary was run by execve */
|
||||
if (readlink("/proc/self/exe", path, PATH_MAX) <= 0)
|
||||
if (readlink("/proc/self/exe", path, PATH_MAX - 1) <= 0)
|
||||
exit(-1);
|
||||
|
||||
/* run binary to get LAM mode and return to parent process */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user