mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
Bug 451843 - valgrind fails to start on a FreeBSD system which enforces W^X
Also add FreeBSD 13.1 to configure.ac
This commit is contained in:
parent
aba645e5a5
commit
bbc3bcab0a
1
NEWS
1
NEWS
@ -85,6 +85,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
|
||||
450536 Powerpc: valgrind throws 'facility scv unavailable exception'
|
||||
451626 Syscall param bpf(attr->raw_tracepoint.name) points to unaddressable byte(s)
|
||||
451827 [ppc64le] VEX temporary storage exhausted with several vbpermq instructions
|
||||
451843 valgrind fails to start on a FreeBSD system which enforces W^X
|
||||
|
||||
To see details of a given bug, visit
|
||||
https://bugs.kde.org/show_bug.cgi?id=XXXXXX
|
||||
|
||||
23
configure.ac
23
configure.ac
@ -394,8 +394,10 @@ case "${host_os}" in
|
||||
freebsd_12=1200
|
||||
AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2])
|
||||
freebsd_12_2=1220
|
||||
AC_DEFINE([FREEBSD_13], 1300, [FREEBSD_VERS value for FreeBSD 13.x])
|
||||
freebsd_13=1300
|
||||
AC_DEFINE([FREEBSD_13_0], 1300, [FREEBSD_VERS value for FreeBSD 13.0])
|
||||
freebsd_13_0=1300
|
||||
AC_DEFINE([FREEBSD_13_1], 1310, [FREEBSD_VERS value for FreeBSD 13.1+])
|
||||
freebsd_13_1=1310
|
||||
AC_DEFINE([FREEBSD_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x])
|
||||
freebsd_14=1400
|
||||
|
||||
@ -428,9 +430,18 @@ case "${host_os}" in
|
||||
esac
|
||||
;;
|
||||
13.*)
|
||||
AC_MSG_RESULT([FreeBSD 13.x (${kernel})])
|
||||
AC_DEFINE([FREEBSD_VERS], FREEBSD_13, [FreeBSD version])
|
||||
freebsd_vers=$freebsd_13
|
||||
case "${kernel}" in
|
||||
13.0-*)
|
||||
AC_MSG_RESULT([FreeBSD 13.0 (${kernel})])
|
||||
AC_DEFINE([FREEBSD_VERS], FREEBSD_13_0, [FreeBSD version])
|
||||
freebsd_vers=$freebsd_13_0
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT([FreeBSD 13.1+ (${kernel})])
|
||||
AC_DEFINE([FREEBSD_VERS], FREEBSD_13_1, [FreeBSD version])
|
||||
freebsd_vers=$freebsd_13_1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
14.*)
|
||||
AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
|
||||
@ -4625,7 +4636,7 @@ fi # test "$VGCONF_OS" = "solaris"
|
||||
|
||||
if test "$VGCONF_OS" = "freebsd" ; then
|
||||
|
||||
AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13)
|
||||
AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
|
||||
|
||||
else
|
||||
|
||||
|
||||
@ -578,7 +578,7 @@ Addr setup_client_stack( void* init_sp,
|
||||
/* --- auxv --- */
|
||||
auxv = (struct auxv *)ptr;
|
||||
*client_auxv = (UInt *)auxv;
|
||||
#if defined(VGP_x86_freebsd) && (VGO_freebsd <= FREEBSD_13)
|
||||
#if defined(VGP_x86_freebsd) && (VGO_freebsd <= FREEBSD_13_0)
|
||||
int* pagesizes = NULL;
|
||||
#endif
|
||||
|
||||
@ -660,7 +660,7 @@ Addr setup_client_stack( void* init_sp,
|
||||
// case AT_CANARYLEN:
|
||||
// case AT_EXECPATH:
|
||||
// case AT_CANARY:
|
||||
#if defined(VGP_x86_freebsd) && (VGO_freebsd <= FREEBSD_13)
|
||||
#if defined(VGP_x86_freebsd) && (VGO_freebsd <= FREEBSD_13_0)
|
||||
case AT_PAGESIZESLEN:
|
||||
if (!VG_(is32on64)()) {
|
||||
VG_(debugLog)(2, "initimg",
|
||||
@ -685,7 +685,7 @@ Addr setup_client_stack( void* init_sp,
|
||||
// case AT_TIMEKEEP:
|
||||
break;
|
||||
|
||||
#if (FREEBSD_VERS >= FREEBSD_13)
|
||||
#if (FREEBSD_VERS >= FREEBSD_13_0)
|
||||
case AT_BSDFLAGS:
|
||||
case AT_ARGC:
|
||||
// case AT_ARGV:
|
||||
|
||||
@ -1348,14 +1348,14 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
|
||||
VG_(exit)(1);
|
||||
}
|
||||
|
||||
#if defined(VGO_freebsd)
|
||||
Int val;
|
||||
SizeT len = sizeof(val);
|
||||
//--------------------------------------------------------------
|
||||
// FreeBSD check security.bsd.unprivileged_proc_debug sysctl
|
||||
// This needs to be done before aspacemgr starts, otherwise that
|
||||
// will fail with mysterious error codes
|
||||
//--------------------------------------------------------------
|
||||
#if defined(VGO_freebsd)
|
||||
Int val;
|
||||
SizeT len = sizeof(val);
|
||||
Int error = VG_(sysctlbyname)("security.bsd.unprivileged_proc_debug", &val, &len, 0, 0);
|
||||
if (error != -1 && val != 1) {
|
||||
VG_(debugLog)(0, "main", "Valgrind: FATAL:\n");
|
||||
@ -1366,6 +1366,50 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
|
||||
|
||||
VG_(exit)(1);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// FreeBSD also check for sysctl kern.elf64.allow_wx=0
|
||||
// This is a sysctl that prevents applications from mmap'ing
|
||||
// segments that are writeable and executable
|
||||
//--------------------------------------------------------------
|
||||
#if defined(VGP_amd64_freebsd)
|
||||
error = VG_(sysctlbyname)("kern.elf64.allow_wx", &val, &len, 0, 0);
|
||||
if (error != -1 && val != 1) {
|
||||
VG_(debugLog)(0, "main", "Valgrind: FATAL:\n");
|
||||
VG_(debugLog)(0, "main", "sysctl kern.elf64.allow_wx sysctl is 0.\n");
|
||||
VG_(debugLog)(0, "main", " Set this sysctl with\n");
|
||||
VG_(debugLog)(0, "main", " 'sysctl kern.elf64.allow_wx sysctl=1'.\n");
|
||||
// the below code doesn't work as I expected
|
||||
// the proccontrol command doesn't cause sysctlbyname to get a modified value
|
||||
// which means that valgrind will still detect allow_wx == 0 and exit here
|
||||
//#if (FREEBSD_VERS >= FREEBSD_13_1)
|
||||
// VG_(debugLog)(0, "main", " Or, alternatively, run valgrind with\n");
|
||||
// VG_(debugLog)(0, "main", " 'proccontrol -m wxmap -s enable valgrind [options] prog-and-args'\n");
|
||||
//#endif
|
||||
VG_(debugLog)(0, "main", " Cannot continue.\n");
|
||||
|
||||
VG_(exit)(1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* also 323bit version */
|
||||
#if defined(VGP_x86_freebsd)
|
||||
error = VG_(sysctlbyname)("kern.elf32.allow_wx", &val, &len, 0, 0);
|
||||
if (error != -1 && val != 1) {
|
||||
VG_(debugLog)(0, "main", "Valgrind: FATAL:\n");
|
||||
VG_(debugLog)(0, "main", "sysctl kern.elf32.allow_wx sysctl is 0.\n");
|
||||
VG_(debugLog)(0, "main", " Set this sysctl with\n");
|
||||
VG_(debugLog)(0, "main", " 'sysctl kern.elf32.allow_wx sysctl=1'.\n");
|
||||
//#if (FREEBSD_VERS >= FREEBSD_13_1)
|
||||
// VG_(debugLog)(0, "main", " Or, alternatively, run valgrind with\n");
|
||||
// VG_(debugLog)(0, "main", " 'proccontrol -m wxmap -s enable valgrind [options] prog-and-args'\n");
|
||||
//#endif
|
||||
VG_(debugLog)(0, "main", " Cannot continue.\n");
|
||||
|
||||
VG_(exit)(1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -283,7 +283,7 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
|
||||
if (do_stats) stats.nr++;
|
||||
|
||||
// Does this apply to macOS 10.14 and earlier?
|
||||
# if defined(VGO_freebsd) && (FREEBSD_VERS < FREEBSD_13)
|
||||
# if defined(VGO_freebsd) && (FREEBSD_VERS < FREEBSD_13_0)
|
||||
if (VG_(is_valid_tid)(tid_if_known) &&
|
||||
VG_(is_in_syscall)(tid_if_known) &&
|
||||
i < max_n_ips) {
|
||||
|
||||
@ -524,7 +524,7 @@ DECL_TEMPLATE(freebsd, sys_fhreadlink) // 567
|
||||
// unimpl __NR_copy_file_range 569
|
||||
DECL_TEMPLATE(freebsd, sys___sysctlbyname) // 570
|
||||
|
||||
#if (FREEBSD_VERS >= FREEBSD_13)
|
||||
#if (FREEBSD_VERS >= FREEBSD_13_0)
|
||||
// looks like close_range got backported
|
||||
// to 12.2 leaving these 4 marked as UNIMPL in 12.2
|
||||
// unimpl __NR_shm_open2 571
|
||||
@ -537,7 +537,7 @@ DECL_TEMPLATE(freebsd, sys___realpathat) // 574
|
||||
|
||||
#endif
|
||||
|
||||
#if (FREEBSD_VERS >= FREEBSD_13)
|
||||
#if (FREEBSD_VERS >= FREEBSD_13_0)
|
||||
|
||||
// unimpl __NR_rpctls_syscall 576
|
||||
DECL_TEMPLATE(freebsd, sys___specialfd) // 577
|
||||
|
||||
@ -6208,7 +6208,7 @@ POST(sys___sysctlbyname)
|
||||
|
||||
#endif // (FREEBSD_VERS >= FREEBSD_12_2)
|
||||
|
||||
#if (FREEBSD_VERS >= FREEBSD_13)
|
||||
#if (FREEBSD_VERS >= FREEBSD_13_0)
|
||||
|
||||
// SYS___realpathat 474
|
||||
// from syscalls.master
|
||||
@ -6940,7 +6940,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
|
||||
// unimpl __NR_copy_file_range 569
|
||||
BSDXY(__NR___sysctlbyname, sys___sysctlbyname), // 570
|
||||
|
||||
#if (FREEBSD_VERS >= FREEBSD_13)
|
||||
#if (FREEBSD_VERS >= FREEBSD_13_0)
|
||||
// unimpl __NR_shm_open2 571
|
||||
// unimpl __NR_shm_rename 572
|
||||
// unimpl __NR_sigfastblock 573
|
||||
@ -6949,7 +6949,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
|
||||
// unimpl __NR_close_range 575
|
||||
#endif
|
||||
|
||||
#if (FREEBSD_VERS >= FREEBSD_13)
|
||||
#if (FREEBSD_VERS >= FREEBSD_13_0)
|
||||
// unimpl __NR_rpctls_syscall 576
|
||||
BSDX_(__NR___specialfd, sys___specialfd), // 577
|
||||
// unimpl __NR_aio_writev 578
|
||||
|
||||
@ -640,7 +640,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if (FREEBSD_VERS >= FREEBSD_13)
|
||||
#if (FREEBSD_VERS >= FREEBSD_13_0)
|
||||
|
||||
#define __NR_rpctls_syscall 576
|
||||
#define __NR___specialfd 577
|
||||
|
||||
@ -1615,7 +1615,7 @@ int main(void)
|
||||
SY(SYS_thr_kill2, x0-1, x0-1, x0+9999); FAIL;
|
||||
|
||||
/* SYS_shm_open 482 */
|
||||
#if (FREEBSD_VERS >= FREEBSD_13)
|
||||
#if (FREEBSD_VERS >= FREEBSD_13_0)
|
||||
GO(SYS_freebsd12_shm_open, "(SHM_ANON) 3s 0m");
|
||||
SY(SYS_freebsd12_shm_open, x0+SHM_ANON, x0+2, x0+9); SUCC;
|
||||
#else
|
||||
@ -1748,7 +1748,7 @@ int main(void)
|
||||
SY(SYS_jail_remove, x0+1); FAIL;
|
||||
|
||||
/* SYS_closefrom 509 */
|
||||
#if (FREEBSD_VERS >= FREEBSD_13)
|
||||
#if (FREEBSD_VERS >= FREEBSD_13_0)
|
||||
GO(SYS_freebsd12_closefrom, "1s 0m");
|
||||
SY(SYS_freebsd12_closefrom, x0+100000); SUCC;
|
||||
#else
|
||||
|
||||
@ -39,7 +39,7 @@ Elf_AuxStr aux_map[AT_COUNT] = {
|
||||
{"AT_HWCAP2", 26},
|
||||
// FreeBSD 12 and 11
|
||||
// {"AT_COUNT", 27},
|
||||
#if (FREEBSD_VERS >= FREEBSD_13)
|
||||
#if (FREEBSD_VERS >= FREEBSD_13_0)
|
||||
{"AT_BSDFLAGS", 27},
|
||||
{"AT_ARGC", 28},
|
||||
{"AT_ARGV", 29},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user