Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 460049f

Browse files
committedMar 16, 2025·
lkl: Fix up libhijack stat ABI
We are hijacking `stat`, where the size of the target struct is dependent on the wordsize. Delegating to `__xstat64` is incorrect, as it unconditionally uses the stat64 layout and will result in an out-of-bounds write on 32-bit architectures. Additionally, the specification claims that the version must be specified as 3 or the behavior is undefined. This only seems to affect 32-bit architectures, as 64-bit architectures require version 1 to produce correct outputs when `__xstat` is called. Fixes: d4b9b65 ("lkl: update dpdk version to 17.02 from 2.2") Signed-off-by: Tim Schumacher <[email protected]>
1 parent 1219089 commit 460049f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎tools/lkl/lib/hijack/hijack.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,15 @@ void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
587587
}
588588

589589
#ifndef __ANDROID__
590-
HOST_CALL(__xstat64)
590+
HOST_CALL(__xstat)
591591
int stat(const char *pathname, struct stat *buf)
592592
{
593-
CHECK_HOST_CALL(__xstat64);
594-
return host___xstat64(0, pathname, buf);
593+
CHECK_HOST_CALL(__xstat);
594+
#if defined(LKL_CONFIG_64BIT)
595+
return host___xstat(1, pathname, buf);
596+
#else
597+
return host___xstat(3, pathname, buf);
598+
#endif
595599
}
596600
#endif
597601

0 commit comments

Comments
 (0)
Please sign in to comment.