From: Paul Floyd Date: Sun, 22 Jan 2023 20:48:51 +0000 (+0100) Subject: FreeBSD: start adding more checks for /proc X-Git-Tag: VALGRIND_3_21_0~210 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c15993dcb4d454ab74f2a37b76391006d5e3637d;p=thirdparty%2Fvalgrind.git FreeBSD: start adding more checks for /proc Also add a couple of expecteds. --- diff --git a/coregrind/m_clientstate.c b/coregrind/m_clientstate.c index 93662dcb3d..7b343f27a5 100644 --- a/coregrind/m_clientstate.c +++ b/coregrind/m_clientstate.c @@ -129,6 +129,10 @@ client__gnu_get_libc_version_type VG_(client__gnu_get_libc_version_addr) = 0; Int* VG_(vfork_fildes_addr) = 0; #endif +#if defined(VGO_freebsd) +Bool VG_(have_slash_proc) = False; +#endif + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 27ec451433..7a22b088a0 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -1719,6 +1719,18 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp ) } #endif +#if defined(VGO_freebsd) + /* On FreeBSD /proc is optional + * Most functionality is accessed through sysctl instead */ + if (!need_help) { + struct vg_stat statbuf; + SysRes statres = VG_(stat)("/proc", &statbuf); + if (!sr_isError(statres) || VKI_S_ISLNK(statbuf.mode)) { + VG_(have_slash_proc) = True; + } + } +#endif + //-------------------------------------------------------------- // Init tool part 1: pre_clo_init // p: setup_client_stack() [for 'VG_(client_arg[cv]'] diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index 129df533df..401a7ba8ee 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -5334,21 +5334,23 @@ PRE(sys_readlinkat) PRE_MEM_RASCIIZ( "readlinkat(path)", ARG2 ); PRE_MEM_WRITE( "readlinkat(buf)", ARG3,ARG4 ); - /* - * Handle the case where readlinkat is looking at /proc/curproc/file or - * /proc//file. - */ - VG_(sprintf)(name, "/proc/%d/file", VG_(getpid)()); - if (ML_(safe_to_deref)((void*)ARG2, 1) - && (VG_(strcmp)((HChar *)ARG2, name) == 0 - || VG_(strcmp)((HChar *)ARG2, "/proc/curproc/file") == 0)) { - VG_(sprintf)(name, "/proc/self/fd/%d", VG_(cl_exec_fd)); - SET_STATUS_from_SysRes( VG_(do_syscall4)(saved, ARG1, (UWord)name, - ARG3, ARG4)); - } else { - /* Normal case */ - SET_STATUS_from_SysRes( VG_(do_syscall4)(saved, ARG1, ARG2, ARG3, ARG4)); + if (VG_(have_slash_proc) == True) { + /* + * Handle the case where readlinkat is looking at /proc/curproc/file or + * /proc//file. + */ + VG_(sprintf)(name, "/proc/%d/file", VG_(getpid)()); + if (ML_(safe_to_deref)((void*)ARG2, 1) + && (VG_(strcmp)((HChar *)ARG2, name) == 0 + || VG_(strcmp)((HChar *)ARG2, "/proc/curproc/file") == 0)) { + VG_(sprintf)(name, "/proc/curproc/fd/%d", VG_(cl_exec_fd)); + SET_STATUS_from_SysRes( VG_(do_syscall4)(saved, ARG1, (UWord)name, + ARG3, ARG4)); + return; + } } + /* Normal case */ + SET_STATUS_from_SysRes( VG_(do_syscall4)(saved, ARG1, ARG2, ARG3, ARG4)); } POST(sys_readlinkat) diff --git a/coregrind/pub_core_clientstate.h b/coregrind/pub_core_clientstate.h index 824ce1e05f..dceece9b90 100644 --- a/coregrind/pub_core_clientstate.h +++ b/coregrind/pub_core_clientstate.h @@ -127,6 +127,10 @@ extern client__gnu_get_libc_version_type VG_(client__gnu_get_libc_version_addr); extern Int* VG_(vfork_fildes_addr); #endif +#if defined(VGO_freebsd) +extern Bool VG_(have_slash_proc); +#endif + #endif // __PUB_CORE_CLIENTSTATE_H /*--------------------------------------------------------------------*/ diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index c382af5e07..aa936ac05e 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -249,8 +249,6 @@ EXTRA_DIST = \ origin5-bz2.stderr.exp-glibc27-ppc64 \ origin5-bz2.stderr.exp-glibc212-s390x \ origin5-bz2.stderr.exp-glibc234-s390x \ - origin5-bz2.stderr.exp-freebsd \ - origin5-bz2.stderr.exp-freebsd-x86 \ origin5-bz2.stderr.exp-glibc218-mips32 \ origin6-fp.vgtest origin6-fp.stdout.exp \ origin6-fp.stderr.exp-glibc25-amd64 \ diff --git a/memcheck/tests/origin5-bz2.stderr.exp-freebsd b/memcheck/tests/origin5-bz2.stderr.exp-freebsd deleted file mode 100644 index b1ac2cd5e0..0000000000 --- a/memcheck/tests/origin5-bz2.stderr.exp-freebsd +++ /dev/null @@ -1,158 +0,0 @@ -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (origin5-bz2.c:6481) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: copy_input_until_stop (origin5-bz2.c:4686) - by 0x........: handle_compress (origin5-bz2.c:4750) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: copy_input_until_stop (origin5-bz2.c:4686) - by 0x........: handle_compress (origin5-bz2.c:4750) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: copy_input_until_stop (origin5-bz2.c:4686) - by 0x........: handle_compress (origin5-bz2.c:4750) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: mainSort (origin5-bz2.c:2820) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: mainSort (origin5-bz2.c:2823) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: mainSort (origin5-bz2.c:2854) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: mainSort (origin5-bz2.c:2855) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: mainSort (origin5-bz2.c:2858) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: mainSort (origin5-bz2.c:2859) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: mainSort (origin5-bz2.c:2963) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: mainSort (origin5-bz2.c:2964) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: fallbackSort (origin5-bz2.c:2269) - by 0x........: BZ2_blockSort (origin5-bz2.c:3116) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: fallbackSort (origin5-bz2.c:2275) - by 0x........: BZ2_blockSort (origin5-bz2.c:3116) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 8 - at 0x........: fallbackSort (origin5-bz2.c:2276) - by 0x........: BZ2_blockSort (origin5-bz2.c:3116) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (origin5-bz2.c:6512) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - diff --git a/memcheck/tests/origin5-bz2.stderr.exp-freebsd-x86 b/memcheck/tests/origin5-bz2.stderr.exp-freebsd-x86 deleted file mode 100644 index 7e6dd6fab2..0000000000 --- a/memcheck/tests/origin5-bz2.stderr.exp-freebsd-x86 +++ /dev/null @@ -1,158 +0,0 @@ -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (origin5-bz2.c:6481) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: copy_input_until_stop (origin5-bz2.c:4686) - by 0x........: handle_compress (origin5-bz2.c:4750) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: copy_input_until_stop (origin5-bz2.c:4686) - by 0x........: handle_compress (origin5-bz2.c:4750) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: copy_input_until_stop (origin5-bz2.c:4686) - by 0x........: handle_compress (origin5-bz2.c:4750) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: mainSort (origin5-bz2.c:2820) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: mainSort (origin5-bz2.c:2823) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: mainSort (origin5-bz2.c:2854) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: mainSort (origin5-bz2.c:2855) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: mainSort (origin5-bz2.c:2858) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: mainSort (origin5-bz2.c:2859) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: mainSort (origin5-bz2.c:2963) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: mainSort (origin5-bz2.c:2964) - by 0x........: BZ2_blockSort (origin5-bz2.c:3105) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: fallbackSort (origin5-bz2.c:2269) - by 0x........: BZ2_blockSort (origin5-bz2.c:3116) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: fallbackSort (origin5-bz2.c:2275) - by 0x........: BZ2_blockSort (origin5-bz2.c:3116) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Use of uninitialised value of size 4 - at 0x........: fallbackSort (origin5-bz2.c:2276) - by 0x........: BZ2_blockSort (origin5-bz2.c:3116) - by 0x........: BZ2_compressBlock (origin5-bz2.c:4034) - by 0x........: handle_compress (origin5-bz2.c:4753) - by 0x........: BZ2_bzCompress (origin5-bz2.c:4822) - by 0x........: BZ2_bzBuffToBuffCompress (origin5-bz2.c:5630) - by 0x........: main (origin5-bz2.c:6484) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) - -Conditional jump or move depends on uninitialised value(s) - at 0x........: main (origin5-bz2.c:6512) - Uninitialised value was created by a client request - at 0x........: main (origin5-bz2.c:6479) -