From 1b1f6f8f2df51ee21fe070750b5f52930b78aedc Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Wed, 8 May 2024 18:25:12 +0200 Subject: [PATCH] FreeBSD sanity check: enable dev/ino and offset checking. Works OK on ZFS, with the usual exeption of the RW segment of the tool itself that has a funky mapping optimization. --- coregrind/m_aspacemgr/aspacemgr-common.c | 6 +++++- coregrind/m_aspacemgr/aspacemgr-linux.c | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/coregrind/m_aspacemgr/aspacemgr-common.c b/coregrind/m_aspacemgr/aspacemgr-common.c index a0c18efac..d4845f113 100644 --- a/coregrind/m_aspacemgr/aspacemgr-common.c +++ b/coregrind/m_aspacemgr/aspacemgr-common.c @@ -394,7 +394,11 @@ Bool ML_(am_get_fd_d_i_m)( Int fd, SysRes res = VG_(do_syscall2)(__NR_fstat, fd, (UWord)&buf); #endif if (!sr_isError(res)) { - *dev = (ULong)buf.st_dev; + /* + * This gets compared to the value obtained by sysctl KERN_PROC_VMMAP. + * For some reson that only uses 32bits, so truncate this to match + */ + *dev = (UInt)buf.st_dev; *ino = (ULong)buf.st_ino; *mode = (UInt) buf.st_mode; return True; diff --git a/coregrind/m_aspacemgr/aspacemgr-linux.c b/coregrind/m_aspacemgr/aspacemgr-linux.c index 83875e89b..9362f65af 100644 --- a/coregrind/m_aspacemgr/aspacemgr-linux.c +++ b/coregrind/m_aspacemgr/aspacemgr-linux.c @@ -859,12 +859,20 @@ static void sync_check_mapping_callback ( Addr addr, SizeT len, UInt prot, if (nsegments[i].hasW) seg_prot |= VKI_PROT_WRITE; if (nsegments[i].hasX) seg_prot |= VKI_PROT_EXEC; -#if defined(VGO_darwin) || defined(VGO_freebsd) +#if defined(VGO_darwin) // GrP fixme kernel info doesn't have dev/inode cmp_devino = False; // GrP fixme V and kernel don't agree on offsets cmp_offsets = False; +#elif defined(VGO_freebsd) + cmp_offsets + = nsegments[i].kind == SkFileC || nsegments[i].kind == SkFileV; + cmp_offsets &= ignore_offset; + + cmp_devino + = nsegments[i].dev != 0 || nsegments[i].ino != 0; + cmp_devino &= ignore_offset; #else cmp_offsets = nsegments[i].kind == SkFileC || nsegments[i].kind == SkFileV; -- 2.47.2