mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 23:36:40 +00:00
Adjust sanitizers for FreeBSD 64-bit inode update
Summary: Very recently, FreeBSD 12 has been updated to use 64-bit inode numbers: <https://svnweb.freebsd.org/changeset/base/318737>. This entails many user-visible changes, but for the sanitizers the modifications are limited in scope: * The `stat` and `lstat` syscalls were removed, and should be replaced with calls to `fstatat`. * The `getdents` syscall was removed, and should be replaced with calls to `getdirentries`. * The layout of `struct dirent` was changed to accomodate 64-bit inode numbers, and a new `d_off` field was added. * The system header <sys/_types.h> now contains a macro `__INO64` to determine whether the system uses 64-bit inode numbers. I tested these changes on both FreeBSD 12.0-CURRENT (after r318959, which adds the `__INO64` macro), and FreeBSD 11.0-STABLE (which still uses 32-bit inode numbers). Reviewers: emaste, kcc, vitalybuka, kubamracek Reviewed By: vitalybuka Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33600 llvm-svn: 304658
This commit is contained in:
parent
da197aab63
commit
6c00c9950c
@ -62,8 +62,6 @@
|
||||
#if SANITIZER_FREEBSD
|
||||
#include <sys/exec.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <vm/vm_param.h>
|
||||
#include <vm/pmap.h>
|
||||
#include <machine/atomic.h>
|
||||
extern "C" {
|
||||
// <sys/umtx.h> must be included after <errno.h> and <sys/types.h> on
|
||||
@ -227,7 +225,8 @@ static void kernel_stat_to_stat(struct kernel_stat *in, struct stat *out) {
|
||||
|
||||
uptr internal_stat(const char *path, void *buf) {
|
||||
#if SANITIZER_FREEBSD
|
||||
return internal_syscall(SYSCALL(stat), path, buf);
|
||||
return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path,
|
||||
(uptr)buf, 0);
|
||||
#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
|
||||
return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path,
|
||||
(uptr)buf, 0);
|
||||
@ -251,7 +250,8 @@ uptr internal_stat(const char *path, void *buf) {
|
||||
|
||||
uptr internal_lstat(const char *path, void *buf) {
|
||||
#if SANITIZER_FREEBSD
|
||||
return internal_syscall(SYSCALL(lstat), path, buf);
|
||||
return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path,
|
||||
(uptr)buf, AT_SYMLINK_NOFOLLOW);
|
||||
#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
|
||||
return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path,
|
||||
(uptr)buf, AT_SYMLINK_NOFOLLOW);
|
||||
@ -594,7 +594,9 @@ uptr internal_getppid() {
|
||||
}
|
||||
|
||||
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) {
|
||||
#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
|
||||
#if SANITIZER_FREEBSD
|
||||
return internal_syscall(SYSCALL(getdirentries), fd, (uptr)dirp, count, NULL);
|
||||
#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
|
||||
return internal_syscall(SYSCALL(getdents64), fd, (uptr)dirp, count);
|
||||
#else
|
||||
return internal_syscall(SYSCALL(getdents), fd, (uptr)dirp, count);
|
||||
|
@ -23,6 +23,9 @@
|
||||
// incorporates the map structure.
|
||||
# define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
|
||||
((link_map*)((handle) == nullptr ? nullptr : ((char*)(handle) + 544)))
|
||||
// Get sys/_types.h, because that tells us whether 64-bit inodes are
|
||||
// used in struct dirent below.
|
||||
#include <sys/_types.h>
|
||||
#else
|
||||
# define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) ((link_map*)(handle))
|
||||
#endif // !SANITIZER_FREEBSD
|
||||
@ -485,7 +488,12 @@ namespace __sanitizer {
|
||||
};
|
||||
#elif SANITIZER_FREEBSD
|
||||
struct __sanitizer_dirent {
|
||||
#if defined(__INO64)
|
||||
unsigned long long d_fileno;
|
||||
unsigned long long d_off;
|
||||
#else
|
||||
unsigned int d_fileno;
|
||||
#endif
|
||||
unsigned short d_reclen;
|
||||
// more fields that we don't care about
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user