]> git.ipfire.org Git - thirdparty/valgrind.git/log
thirdparty/valgrind.git
21 hours agoAdd several missing syscall hooks to ppc64-linux master
Martin Cermak [Fri, 8 Aug 2025 21:46:53 +0000 (23:46 +0200)] 
Add several missing syscall hooks to ppc64-linux

Specifically:

sys_getrlimit
sys_mincore
sys_tkill
sys_unshare
sys_splice
sys_tee
sys_vmsplice
sys_fanotify_init
sys_fanotify_mark
sys_kcmp
sys_bpf

https://bugs.kde.org/show_bug.cgi?id=508030

22 hours agoReview the vmsplice syscall wrapper
Martin Cermak [Fri, 8 Aug 2025 21:38:33 +0000 (23:38 +0200)] 
Review the vmsplice syscall wrapper

Reuse the vmsplice syscall wrapper in coregrind/m_syswrap/syswrap-linux.c
for mips64 as well. And make sure arm64-linux and riscv64-linux also use
the POST vmsplice wrapper.

3 days agoDistribute auxprogs scripts and data files
Mark Wielaard [Wed, 6 Aug 2025 22:21:42 +0000 (00:21 +0200)] 
Distribute auxprogs scripts and data files

Make sure pybuild.sh, ltp-tester.sh, ltp-apply-patches.sh,
s390-check-opcodes.pl, s390-runone scripts, ltp filters, ltp patches
and pylintrc are added to the dist.

This makes sure users can run the scripts and make ltpchecks not just
from a git checkout, but also from a release or snapshots tar.

Also use the ustar format to package files, the path under
valgrind-x.yy.z/auxprogs/ltp-patches might be larger than 99
chars. automake 1.18 already defaults to the ustar format.

3 days agoThe futimesat syscall wrapper doesn't handle AT_FDCWD
Martin Cermak [Tue, 5 Aug 2025 14:54:54 +0000 (16:54 +0200)] 
The futimesat syscall wrapper doesn't handle AT_FDCWD

Update futimesat syscall wrapper so that it doesn't consider the
special value AT_FDCWD (-100) an invalid file descriptor.

https://bugs.kde.org/show_bug.cgi?id=507868

3 days agoMake fchmodat and fchmodat2 syscall wrappers accept AT_FDCWD
Martin Cermak [Tue, 5 Aug 2025 15:36:29 +0000 (17:36 +0200)] 
Make fchmodat and fchmodat2 syscall wrappers accept AT_FDCWD

The fchmodat and fchmodat2 syscall wrappers should accept special
value AT_FDCWD as a valid file descriptor.

https://bugs.kde.org/show_bug.cgi?id=507873

3 days agoAllow for patching LTP sources
Martin Cermak [Tue, 5 Aug 2025 16:06:08 +0000 (18:06 +0200)] 
Allow for patching LTP sources

Sometimes there's an upstream LTP patch that helps testing
valgrind, but it's not yet part of the official LTP tarball.
In such cases it's helpful to be able to patch the LTP sources.
Attached patch allows for that.  It comes with a real life
example patch: LTP commit b62b831cf.

4 days agoAdd bug 503241 s390x: Support z17 changes to the NNPA instruction to NEWS
Mark Wielaard [Tue, 5 Aug 2025 20:29:14 +0000 (22:29 +0200)] 
Add bug 503241 s390x: Support z17 changes to the NNPA instruction to NEWS

This was added in commit 24b634e8ce04de70d4aa6c61a12149df223f9c68

https://bugs.kde.org/show_bug.cgi?id=503241

7 days agoARM64 specific changes for BZ 507033
Florian Krohm [Sat, 2 Aug 2025 13:22:50 +0000 (13:22 +0000)] 
ARM64 specific changes for BZ 507033

Replace the deprecated Iop_Clz64 with Iop_ClzNat64 which have the
same semantics for non-zero inputs.

Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033

7 days agoARM specific changes for BZ 507033
Florian Krohm [Sat, 2 Aug 2025 13:14:31 +0000 (13:14 +0000)] 
ARM specific changes for BZ 507033

Rework code to use Iop_ClzNat32 instead of the deprecated Iop_Clz32.

Iop_Clz32 --isel--> ARMun_CLZ --emit--> CLZ insn  with CLZ(0) == 32
Hence, any workaround for a zero input value can be removed.

Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033

7 days agomips specific changes for BZ 507033
Florian Krohm [Sat, 2 Aug 2025 12:43:54 +0000 (12:43 +0000)] 
mips specific changes for BZ 507033

Rework code to use Iop_ClzNat32 instead of the deprecated Iop_Clz32.
Likewise for Iop_Clz64.

For Iop_Clz32 a CLZ insn will be emitted which behaves naturally when
its input is 0. That is: CLZ(0) == 32.
Similarly, for Iop_Clz64 a DCLZ will be emitted with DCLZ(0) == 64.
That means we can replace Iop_Clz32/64 with Iop_ClzNat32/64 and remove
any IR that handles the input-is-zero case.
See also commit a5c48217e94.

Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033

7 days agoFix execveat() with AT_FDCWD and relative path, add more checks
Martin Cermak [Fri, 1 Aug 2025 13:35:04 +0000 (15:35 +0200)] 
Fix execveat() with AT_FDCWD and relative path, add more checks

This update does address two closely related problems:

1) In case execveat() is called with a special file descriptor value
of AT_FDCWD (-100), it should accept this special value, and
interpret the provided pathname as relative to the current working
directory of the calling process (like execve(2)) instead of
failing with EBADF, as it does without this patch.

Covered by LTP testcase execveat01.

https://bugs.kde.org/show_bug.cgi?id=506806

2) Add checks preventing execveat() of symlinked programs in case
AT_SYMLINK_NOFOLLOW was specified.

Add checks preventing execveat() from passing in case invalid
flag was specified.

Covered by LTP testcase execveat02.

https://bugs.kde.org/show_bug.cgi?id=506813

8 days agoWrap linux specific syscall sysfs
Martin Cermak [Fri, 1 Aug 2025 12:04:24 +0000 (14:04 +0200)] 
Wrap linux specific syscall sysfs

The sysfs syscall is deprecated, but in some cases it may still
be used.  The Linux Test Project covers it.

The (obsolete) sysfs() system call returns information about the
filesystem types currently present in the kernel.  The specific
form of the sysfs() call and the information returned depends on
the option in effect:

1  Translate the filesystem identifier string fsname into a
   filesystem type index.

2  Translate the filesystem type index fs_index into a null-
   terminated filesystem identifier string.  This string will be
   written to the buffer pointed to by buf.  Make sure that buf
   has enough space to accept the string.

3  Return the total number of filesystem types currently present
   in the kernel.

Declare a sys_sysfs wrapper in priv_syswrap-linux.h and hook it
for {amd64,arm,mips32,mips64,ppc32,ppc64,s390x,x86}-linux
using LINXY with PRE and POST handler in syswrap-linux.c

https://bugs.kde.org/show_bug.cgi?id=506929

9 days agonanomips specific changes for BZ 507033
Florian Krohm [Thu, 31 Jul 2025 21:28:39 +0000 (21:28 +0000)] 
nanomips specific changes for BZ 507033

Rework code to use Iop_ClzNat32 instead of the deprecated Iop_Clz32.

Iop_Clz32 is used to implement the CLZ insn which behaves naturally
when the input is 0:  CLZ(0) == 32
So it seems as if using Iop_Clz32 is wrong because it has undefined
behaviour when the input value is 0. However, the VEX pipeline
does this:

CLZ insn --ir--> Iop_Clz32 --isel--> NMun_CLZ --emit--> CLZ

So it all works out. Essentially the semantics of Iop_Clz32 were
redefined to be like Iop_ClzNat32.

In IR generation we can drop the special handling for CLO(0) because
Iop_ClzNat32 takes care of that.

Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033

9 days agox86 specific changes for BZ 507033
Florian Krohm [Thu, 31 Jul 2025 20:56:34 +0000 (20:56 +0000)] 
x86 specific changes for BZ 507033

Rework code to use Iop_ClzNat32 instead of the deprecated Iop_Clz32.
Likewise for Iop_Ctz32.

Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033

9 days agoamd64 specific changes for BZ 507033
Florian Krohm [Thu, 31 Jul 2025 20:45:29 +0000 (20:45 +0000)] 
amd64 specific changes for BZ 507033

Rework code to use Iop_ClzNat64 instead of the deprecated Iop_Clz64.
Likewise for Iop_Ctz64.

Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033

9 days agomemcheck/tests/mallinfo2.c use %zu to print mallinfo2 fields
Mark Wielaard [Thu, 31 Jul 2025 16:34:31 +0000 (18:34 +0200)] 
memcheck/tests/mallinfo2.c use %zu to print mallinfo2 fields

9 days agoImplement and override mallinfo2
Martin Cermak [Fri, 18 Jul 2025 15:11:49 +0000 (17:11 +0200)] 
Implement and override mallinfo2

Implement and override mallinfo2.  Add a testcase covering mallinfo2.
Exclude irrelevant LTP tests trying to cover mallinfo2.

https://bugs.kde.org/show_bug.cgi?id=506967

10 days agoAdd fd_allowed and POST_newFd_RES to all syscalls that use or return fds
Alexandra Hájková [Tue, 29 Jul 2025 13:49:26 +0000 (09:49 -0400)] 
Add fd_allowed and POST_newFd_RES to all syscalls that use or return fds

This makes sure all file descriptors that take a file descriptor check
that the file descriptor is valid. Also makes sure that the
--modify-fds=high option affects all sycalls that return a file
descriptor.

https://bugs.kde.org/show_bug.cgi?id=493430

10 days agoFix a panic message.
Florian Krohm [Wed, 30 Jul 2025 14:44:40 +0000 (14:44 +0000)] 
Fix a panic message.

That code snippet is executed for both Iend_BE and Iend_LE.

10 days agos390: New Principles of Operations is out
Florian Krohm [Wed, 30 Jul 2025 14:08:32 +0000 (14:08 +0000)] 
s390: New Principles of Operations is out

12 days agoREADME_DEVELOPERS: change a few path names for consistency
Florian Krohm [Mon, 28 Jul 2025 09:51:55 +0000 (09:51 +0000)] 
README_DEVELOPERS: change a few path names for consistency

2 weeks agoiropt-test: .vgtest tweaks
Florian Krohm [Fri, 25 Jul 2025 21:20:47 +0000 (21:20 +0000)] 
iropt-test: .vgtest tweaks

2 weeks agoiropt-test: Refactor code
Florian Krohm [Fri, 25 Jul 2025 21:11:57 +0000 (21:11 +0000)] 
iropt-test: Refactor code

Refactor code in preparation for running each testcase twice: once
with constant folding and once without.
- remove function print_opnd
- remove function complain
- factor out function get_expected_value
- checking the result moved to valgrind_execute_test
- make IRICB a static global in valgrind.c
- new_iricb now returns a pointer to it

2 weeks agoFreeBSD regtest: update 32bit scalar expected
Paul Floyd [Fri, 25 Jul 2025 05:48:25 +0000 (07:48 +0200)] 
FreeBSD regtest: update 32bit scalar expected

2 weeks agoFreeBSD syscall: improve sigwait and sigwaitinfo wrapper.
Paul Floyd [Thu, 24 Jul 2025 20:45:01 +0000 (22:45 +0200)] 
FreeBSD syscall: improve sigwait and sigwaitinfo wrapper.

Both take two pointers. We were allowing null pointers for all
of them. Only the 2nd argument of sigwaitinfo, info, is
allowed to be NULL. Update the scalar test with some NULL
arguments for these syscalls.

2 weeks agoREADME_DEVELOPERS: more on scalar test
Paul Floyd [Thu, 24 Jul 2025 20:44:09 +0000 (22:44 +0200)] 
README_DEVELOPERS: more on scalar test

One typo and add an example.

2 weeks agoREADME_DEVELOPERS: add some description of scalar tests
Paul Floyd [Thu, 24 Jul 2025 20:41:11 +0000 (22:41 +0200)] 
README_DEVELOPERS: add some description of scalar tests

2 weeks agotests/x86_amd_features.c: followup to 4810c14b5d
Florian Krohm [Thu, 24 Jul 2025 09:43:04 +0000 (09:43 +0000)] 
tests/x86_amd_features.c: followup to 4810c14b5d

Do not rely on hardware identifying itself in a particular way.
Enable lzcnt for non-AMD hardware.

2 weeks agotests/x86_amd_features.c: also recognise GenuineIntel
Florian Krohm [Wed, 23 Jul 2025 20:20:54 +0000 (20:20 +0000)] 
tests/x86_amd_features.c: also recognise GenuineIntel

Enables running certain testcases on hardware that identifies itself
as "GenuineIntel".

2 weeks agoFreeBSD regtest: remove stray backslash in a string in scalar test
Paul Floyd [Mon, 21 Jul 2025 06:01:13 +0000 (08:01 +0200)] 
FreeBSD regtest: remove stray backslash in a string in scalar test

2 weeks agogdbserver regtest: remove extra lines containing syscall_cancel.S
Paul Floyd [Mon, 21 Jul 2025 05:07:23 +0000 (07:07 +0200)] 
gdbserver regtest: remove extra lines containing syscall_cancel.S

Should fix some fails that we see on Tom's Fedora 42 nightly.

2 weeks agoFix compiler warnings on ppc due to unused s390 specific variables.
Florian Krohm [Sun, 20 Jul 2025 17:58:10 +0000 (17:58 +0000)] 
Fix compiler warnings on ppc due to unused s390 specific variables.

2 weeks agoFreeBSD compiler warnings
Paul Floyd [Sun, 20 Jul 2025 17:08:46 +0000 (19:08 +0200)] 
FreeBSD compiler warnings

Fix a few warnings that I now get with clang 19 on FreeBSD 15.

2 weeks agoFreeBSD regtest: add a testcase for exterrctl
Paul Floyd [Sun, 20 Jul 2025 16:56:44 +0000 (18:56 +0200)] 
FreeBSD regtest: add a testcase for exterrctl

This is a function for libc internal use only, so this
test doesn't really add much compared to the scalar test.

2 weeks agoSort NEWS entries.
Florian Krohm [Sun, 20 Jul 2025 09:05:23 +0000 (09:05 +0000)] 
Sort NEWS entries.

2 weeks agos390x: Fix crash when constant folding is disabled (BZ 507173)
Florian Krohm [Sun, 20 Jul 2025 08:58:46 +0000 (08:58 +0000)] 
s390x: Fix crash when constant folding is disabled  (BZ 507173)

Followup to 942a48c1d which fixed the register usage of conditional
moves for s390_insn_get_reg_usage. A similar fix is needed for
s390_insn_map_regs considering the case when the condition is
S390_CC_NEVER.

Fixes https://bugs.kde.org/show_bug.cgi?id=507173

2 weeks agofdleak.h: Mark close_inherited as possible unused because it is.
Florian Krohm [Sun, 20 Jul 2025 08:39:40 +0000 (08:39 +0000)] 
fdleak.h: Mark close_inherited as possible unused because it is.

Avoids compiler warning for track_bad.c

2 weeks agoFreeBSD regtest: make memcheck/tests/freebsd/setcred consistent on arm64 and amd64
Paul Floyd [Sun, 20 Jul 2025 08:19:00 +0000 (10:19 +0200)] 
FreeBSD regtest: make memcheck/tests/freebsd/setcred consistent on arm64 and amd64

Was getting different errors due to the contents of junk pointers.

2 weeks agoFreeBSD regtest: filter leak from memcheck/tests/gone_abrt_xml
Paul Floyd [Sun, 20 Jul 2025 07:59:51 +0000 (09:59 +0200)] 
FreeBSD regtest: filter leak from memcheck/tests/gone_abrt_xml

On amd64 there is a suppressed reachable that shows up in the
leak summary. On arm64 there is no leak. So add a filter
for leaks in xml files.

2 weeks agoLinux regtest: fix build of tests on old systems without openat2
Paul Floyd [Sun, 20 Jul 2025 05:46:47 +0000 (07:46 +0200)] 
Linux regtest: fix build of tests on old systems without openat2

3 weeks agoJust set filename ARG to handle /proc/self/exe in open, openat and openat2
Mark Wielaard [Sat, 19 Jul 2025 20:19:08 +0000 (22:19 +0200)] 
Just set filename ARG to handle /proc/self/exe in open, openat and openat2

This simplifies the logic a little and makes reasoning about how the
PRE handler works slightly simpler.

3 weeks agoLinux arm64 and riscv64: for build for VG_(lstat)
Paul Floyd [Sat, 19 Jul 2025 20:13:15 +0000 (22:13 +0200)] 
Linux arm64 and riscv64: for build for VG_(lstat)

These 'new' architectures don't have 'old' syscalls like __NR_lstat
so use __NR_newfstatat instead.

Also modify the oen_client testcase so that it checks for the 'old' open
syscall.

3 weeks agoBug 506910 - openat2 with RESOLVE_NO_MAGICLINKS succeeds on /proc/self/exe
Paul Floyd [Sat, 19 Jul 2025 16:17:35 +0000 (18:17 +0200)] 
Bug 506910 - openat2 with RESOLVE_NO_MAGICLINKS succeeds on /proc/self/exe

Previous change did most of the work but need to return without setting
SfMayBlock. Add a testcase covering /proc/self/exe and /proc/PID/exe.

3 weeks agoBug 505673 - Valgrind crashes with an internal error and SIGBUS when the guest tries...
Paul Floyd [Sat, 19 Jul 2025 13:10:31 +0000 (15:10 +0200)] 
Bug 505673 - Valgrind crashes with an internal error and SIGBUS when the guest tries to open its own file with O_WRONLY|O_CREAT|O_TRUNC

This is all quite messy.

It affects open() openat() and openat2() (the last of which is Linux only).
On Linux we also need to check for /proc/self/exe and /proc/PID/exe.
On Linux there are also a couple of RESOLVE flags for openat2() that
mean _don't_ check /proc magic links.
In the general case we need to have some reference to check whether
the filename matches the guest filename. So I've added that as
VG_(resolved_exename) (which I was already using on FreeBSD).
The pathname also needs to be canonicalised. It may be a
relative path, symlink or use RESOLVE_IN_ROOT. That uses
VG_(realpath) (again which was already present for FreBSD).
On illumos the man page says that opening running binaries for
writing failes with errno set to ETXTBSY but that's not what
the open functions do - they just open the file. So I've done nothing
for illumos or Solaris. Maybe I'll open an illumos ticket.
I haven't tried on Darwin.

The Linux open functions with /proc/self/exe and /proc/PID/exe
were just calling dup on the fd that we hold for the client exe.
That means that we were ignoring any other flags. That has now changed.
If the open doesn't fail because the WRONLY/RDWR flags are set then
the syscall gets called from the PRE wrapper using VG_(resolved_exename)
instewad of the /proc pathname.

I haven't tried to handle all of the Linux openat2 RESOLVE*
flags. RESOLVE_NO_MAGICLINKS is handled and I see the LTS test
openat202 now passing, so this should also fix Bug 506910.

I'm not sure that VG_(realpath) handles all forms of weird path
resolution on Linux (on FreeBSD it uses a syscall so that should
work OK).

3 weeks agoFreeBSD: fix check for mmap flags
Paul Floyd [Fri, 18 Jul 2025 11:21:26 +0000 (13:21 +0200)] 
FreeBSD: fix check for mmap flags

On FreeBSD, mmap also has MAP_STACK and MAP_GUARD that can
be mapped without a backing file referred to by fd.

As a result during ld.so startup and thread creation mmap for
stacks was failing. So no guest could be load and execute,
with errors like

ld-elf.so.1: /home/paulf/scratch/valgrind_nightly/nightly/valgrind-new/.in_place/vgpreload_core-amd64-freebsd.so: mmap of entire address space failed: Bad file descriptor

3 weeks agoConstant folding for various division IROps. (BZ 506211)
Florian Krohm [Thu, 17 Jul 2025 20:39:12 +0000 (20:39 +0000)] 
Constant folding for various division IROps. (BZ 506211)

Part of fixing https://bugs.kde.org/show_bug.cgi?id=506211

3 weeks agoiropt regtest: use mrand32() instead of rand()
Paul Floyd [Thu, 17 Jul 2025 18:38:54 +0000 (20:38 +0200)] 
iropt regtest: use mrand32() instead of rand()

On illumos rand() has a RAND_MAX of 32k only. That's not enough to
generate 64bit values easily. So use mrand48() which genrerates
the full range of 32bit int values.

3 weeks agoConstant folding for various multiplication IROps. (BZ 506211)
Florian Krohm [Thu, 17 Jul 2025 14:04:50 +0000 (14:04 +0000)] 
Constant folding for various multiplication IROps. (BZ 506211)

Part of fixing https://bugs.kde.org/show_bug.cgi?id=506211

3 weeks agoConstant folding for Iop_CmpORD.. and Iop_8HLto16, Iop16HLto32. (BZ 506211)
Florian Krohm [Thu, 17 Jul 2025 12:23:22 +0000 (12:23 +0000)] 
Constant folding for Iop_CmpORD.. and Iop_8HLto16, Iop16HLto32. (BZ 506211)

Part of fixing https://bugs.kde.org/show_bug.cgi?id=506211

3 weeks agoWrap linux specific syscall 22 (ustat)
Martin Cermak [Thu, 17 Jul 2025 07:16:53 +0000 (09:16 +0200)] 
Wrap linux specific syscall 22 (ustat)

The ustat syscall comes from pre-git linux history.  It is
deprecated in favor of statfs.  But in some cases it may
still be used.

int ustat(dev_t dev, struct ustat *ubuf); returns information
about a mounted filesystem.  dev is a device number identifying
a device containing a mounted filesystem.  ubuf is a pointer to
a ustat structure.

Declare a sys_ustat wrapper in priv_syswrap-linux.h and hook
it for {amd64,arm,arm64,mips64,nanomips,ppc32,ppc64,riscv64,\
s390x,x86}-linux using LINXY with PRE and POST handler in
syswrap-linux.c

https://bugs.kde.org/show_bug.cgi?id=506928

3 weeks agoCheck mmap fd is valid, if used, and fail early with EBADF if not
Mark Wielaard [Wed, 16 Jul 2025 00:45:39 +0000 (02:45 +0200)] 
Check mmap fd is valid, if used, and fail early with EBADF if not

mmap should fail with EBADF if the given fd is bad (or used by valgrind
itself) when used (flags does not contain MAP_ANONYMOUS).

Check both with ML_(fd_allowed) (which might only warn) and fcntl
(VKI_F_GETFD) to see if the file descriptor is valid. Fail early so
the address space manager and the actual mmap call don't do
unnecessary work (and might fail with a different error code).

This fixes the LTP mmap08 testcase.

https://bugs.kde.org/show_bug.cgi?id=506970

3 weeks agoConstant folding for Iop_Shl8/16, Iop_Shr8/16 and Iop_Sar8/16. (BZ 506211)
Florian Krohm [Thu, 17 Jul 2025 07:04:03 +0000 (07:04 +0000)] 
Constant folding for Iop_Shl8/16, Iop_Shr8/16 and Iop_Sar8/16. (BZ 506211)

Part of fixing https://bugs.kde.org/show_bug.cgi?id=506211

3 weeks agoConstant folding for various binary IRops. (BZ 506211)
Florian Krohm [Wed, 16 Jul 2025 20:01:54 +0000 (20:01 +0000)] 
Constant folding for various binary IRops. (BZ 506211)

Iop_Add16, Iop_Sub16,
Iop_CmpEQ8/16, Iop_CasCmpEQ8/16/32/64, Iop_CmpNE16, Iop_CasCmpNE16,
Iop_ExpCmpNE16

Part of fixing https://bugs.kde.org/show_bug.cgi?id=506211

3 weeks agoConstant folding for Iop_CtzNat32/64. (BZ 506211)
Florian Krohm [Wed, 16 Jul 2025 17:43:34 +0000 (17:43 +0000)] 
Constant folding for Iop_CtzNat32/64. (BZ 506211)

Part of fixing https://bugs.kde.org/show_bug.cgi?id=506211

3 weeks agoConstant folding for Iop_ClzNat32/64. (BZ 506211)
Florian Krohm [Wed, 16 Jul 2025 14:54:44 +0000 (14:54 +0000)] 
Constant folding for Iop_ClzNat32/64. (BZ 506211)

Part of fixing https://bugs.kde.org/show_bug.cgi?id=506211

3 weeks agoiropt-test: Also test with random inputs; reorg the code a bit
Florian Krohm [Wed, 16 Jul 2025 11:51:15 +0000 (11:51 +0000)] 
iropt-test: Also test with random inputs; reorg the code a bit

New utility functions: get_random_value and get_selected_values
Add command line option -rNUM to specify the number of random tests
per operator.

3 weeks agoChange [a]sync_sighandler to [a]sync_signalhandler in comments
Paul Floyd [Wed, 16 Jul 2025 05:09:37 +0000 (07:09 +0200)] 
Change [a]sync_sighandler to [a]sync_signalhandler in comments

and in one "if (0)" VG_(printf).

3 weeks agoSupport mmap MAP_FIXED_NOREPLACE if defined
Mark Wielaard [Tue, 15 Jul 2025 21:49:36 +0000 (23:49 +0200)] 
Support mmap MAP_FIXED_NOREPLACE if defined

Define VKI_MAP_FIXED_NOREPLACE for amd64-linux, arm-linux,
arm64-linux, mips32-linux, mips64-linux, riscv64-linux and x86-linux.

If it is defined then ML_(generic_PRE_sys_mmap) will also interpret
VKI_MAP_FIXED_NOREPLACE as an MFixed hint. If the aspace manager
doesn't find a MAP_FIXED_NOREPLACE ok, then fail with EEXIST. If the
actual kernel mmap request fails and MAP_FIXED_NOREPLACE is set also
immediately fail with EEXIST without retrying.

This fixes the LTP mmap17 testcase.

https://bugs.kde.org/show_bug.cgi?id=418756

3 weeks agoHandle SIGSYS and SIGSTKFLT when defined
Mark Wielaard [Mon, 14 Jul 2025 22:00:44 +0000 (00:00 +0200)] 
Handle SIGSYS and SIGSTKFLT when defined

Both signals were already partially handled. But calculate_SKSS_from_SCSS
only handled SIGSYS on freebsd. default_action didn't handle SIGSTKFLT.
And sync_signalhandler didn't expect to have to handle SIGSYS.

This fixes LTP tests kill11 and waitpid01.

https://bugs.kde.org/show_bug.cgi?id=506890

3 weeks agoReject any attempt to set the handler for SIGKILL/STOP
Mark Wielaard [Mon, 14 Jul 2025 21:23:23 +0000 (23:23 +0200)] 
Reject any attempt to set the handler for SIGKILL/STOP

Even though resetting SIGKILL or SIGSTOP to SIG_DFL would be a noop it
isn't allowed. Just always return EINVAL if an attempt is made to set
the signal handler for SIGKILL or SIGSTOP. There is an LTP test for
this signal01.

https://bugs.kde.org/show_bug.cgi?id=506930

3 weeks agoSolaris gitignore: wildcard diff files
Paul Floyd [Mon, 14 Jul 2025 18:48:34 +0000 (20:48 +0200)] 
Solaris gitignore: wildcard diff files

3 weeks agoAdd folding for Iop_PopCount32/64 and Iop_CmpNEZ16 (BZ 506211)
Florian Krohm [Mon, 14 Jul 2025 16:32:06 +0000 (16:32 +0000)] 
Add folding for Iop_PopCount32/64 and Iop_CmpNEZ16  (BZ 506211)

Part of fixing https://bugs.kde.org/show_bug.cgi?id=506211

3 weeks agoEnable folding for Iop_Left8/16
Florian Krohm [Mon, 14 Jul 2025 13:11:01 +0000 (13:11 +0000)] 
Enable folding for Iop_Left8/16

In iropt-test add independent implementation of the "Left" operator
for checking purposes.

3 weeks agoiropt-test: Reorder IROps.
Florian Krohm [Mon, 14 Jul 2025 10:21:44 +0000 (10:21 +0000)] 
iropt-test: Reorder IROps.

3 weeks agoAdd VEX/useful/vec to gitignore
Paul Floyd [Mon, 14 Jul 2025 09:42:28 +0000 (11:42 +0200)] 
Add VEX/useful/vec to gitignore

3 weeks agoReformat wcpncpy in vg_replace_strmem.c
Paul Floyd [Sun, 13 Jul 2025 08:47:04 +0000 (10:47 +0200)] 
Reformat wcpncpy in vg_replace_strmem.c

4 weeks agoltp-excludes.txt: Add tests that use unsupported clone flags
Mark Wielaard [Sat, 12 Jul 2025 22:31:26 +0000 (00:31 +0200)] 
ltp-excludes.txt: Add tests that use unsupported clone flags

Add clone08, close_range02 and kcmp03.

4 weeks agoBug 506499 - Unhandled syscall 592 (exterrctl - FreeBSD)
Paul Floyd [Sat, 12 Jul 2025 20:23:05 +0000 (22:23 +0200)] 
Bug 506499 - Unhandled syscall 592 (exterrctl - FreeBSD)

Also add wrapers for inotify_add_watch_at and inotify_rm_watch

No specific tests for these yet.

4 weeks agoFreeBSD regtest: more kenv churn
Paul Floyd [Sat, 12 Jul 2025 19:45:10 +0000 (21:45 +0200)] 
FreeBSD regtest: more kenv churn

Haste makes Waste. Filter was broken (and thererfore the expected
not correct either).

4 weeks agoFreeBSD regtst: add filter for kenv test
Paul Floyd [Sat, 12 Jul 2025 18:31:31 +0000 (20:31 +0200)] 
FreeBSD regtst: add filter for kenv test

The size of the kernel environment depends on the FreeBSD version.
So add a filter for the total of all alocations.

4 weeks agoFreeBSD regtest: small cleanup of kenv test
Paul Floyd [Sat, 12 Jul 2025 18:20:06 +0000 (20:20 +0200)] 
FreeBSD regtest: small cleanup of kenv test

Suppress uninitialised warning
Remove res variable that was copied and pasted

4 weeks agoFreeBSD syscall: improve kenv wrapper and add a test for it
Paul Floyd [Sat, 12 Jul 2025 14:21:29 +0000 (16:21 +0200)] 
FreeBSD syscall: improve kenv wrapper and add a test for it

4 weeks agoAdd program to double-check VEX constant folding. BZ 506211
Florian Krohm [Sat, 12 Jul 2025 13:32:14 +0000 (13:32 +0000)] 
Add program to double-check VEX constant folding. BZ 506211

Using IR injection. Essentially:
- prepare input values for an IROp
- create an IRExpr for the IRop
- constant fold the expression
- make sure the result is an IRConst with the expected value

Only IROps with integer operands and result are supported.
No vector and floating point IROps. Maximum bit width is 64.

Part of fixing https://bugs.kde.org/show_bug.cgi?id=506211

4 weeks agolinux mseal PRE wrapper should First check for overflow
Mark Wielaard [Fri, 11 Jul 2025 17:58:53 +0000 (19:58 +0200)] 
linux mseal PRE wrapper should First check for overflow

According to https://docs.kernel.org/next/userspace-api/mseal.html
mseal returns -EINVAL when Address range (addr + len) overflow. The
LTP test mseal02 checks this. So do this check first before checking
for valid_client_addr (which returns -ENOMEM).

4 weeks agoAdd auxprogs/filters/prctl10
Mark Wielaard [Fri, 11 Jul 2025 15:36:05 +0000 (17:36 +0200)] 
Add auxprogs/filters/prctl10

The LTP prctl10 test under memcheck has a child process dumping core.
Filter out the normal warning about this.

4 weeks agoCheck ppoll ufds array is safe to deref before checking fd members
Mark Wielaard [Fri, 11 Jul 2025 15:18:47 +0000 (17:18 +0200)] 
Check ppoll ufds array is safe to deref before checking fd members

LTP ppoll01 provides a bad fds array to ppoll as a testcase.
memcheck should warn (through PRE_MEM_READ) this array is bad.
But it shouldn't try to derefence anything if is isn't safe.

4 weeks agoAdd fcntl14{,_64}, fcntl34{,_64} and fcntl36{,_64} to ltp-excludes.txt
Mark Wielaard [Thu, 10 Jul 2025 21:09:18 +0000 (23:09 +0200)] 
Add fcntl14{,_64}, fcntl34{,_64} and fcntl36{,_64} to ltp-excludes.txt

These fcntl syscall tests time out and would need at least
LTP_TIMEOUT_MUL=5 when run under memcheck, which is several minutes,
so exclude them for now.

4 weeks agoFreeBSD syscall: make syscall kenv unhandles actions a -v warning
Paul Floyd [Thu, 10 Jul 2025 18:40:43 +0000 (20:40 +0200)] 
FreeBSD syscall: make syscall kenv unhandles actions a -v warning

Was VG_(unimplemented) which bombs. That's a bit drastic for a syscall intented
to be called directly by users.

4 weeks agoFreeBSD syscall: remove duplicate dead code from sysarch PRE wrapper
Paul Floyd [Thu, 10 Jul 2025 18:20:20 +0000 (20:20 +0200)] 
FreeBSD syscall: remove duplicate dead code from sysarch PRE wrapper

Probably a copy and paste error.

4 weeks agoSuppress unimplemented fcntl command warning with -q
Mark Wielaard [Wed, 9 Jul 2025 16:27:17 +0000 (18:27 +0200)] 
Suppress unimplemented fcntl command warning with -q

LTP tests fcntl13 and fcntl13_64 fail because even with -q valgrind
emits warnings about unknown (999) fcntl commands. Don't emit that
message with -q, just fail with EINVAL.

4 weeks agoBetter report which clone flag are problematic
Mark Wielaard [Wed, 9 Jul 2025 11:04:51 +0000 (13:04 +0200)] 
Better report which clone flag are problematic

Be explict about which combination of CLONE_VM, CLONE_FS, CLONE_FILES
and CLONE_VFORK flags are supported and which combination isn't.

https://bugs.kde.org/show_bug.cgi?id=506795

4 weeks agoFix operand / result types of Iop_DivU128[E], Iop_ModU128 and their signed counterparts
Florian Krohm [Wed, 9 Jul 2025 20:15:46 +0000 (20:15 +0000)] 
Fix operand / result types of Iop_DivU128[E], Iop_ModU128 and their signed counterparts

In libvex_ir.h these IROps are described to operate on Ity_I128 operands and produce a like typed result. This contradicts the specification in ir_defs.c
(function typeOfprimop) which claims Ity_V128 for operands and result.

Above IROps are used exclusively by ppc for the following opcodes:
Iop_DivU128  --> vdivuq  Vector Divide Unsigned Quadword
Iop_DivS128  --> vdivsq  Vector Divide Signed Quadword
Iop_DivU128E --> vdiveuq Vector Divide Extended Unsigned Quadword
Iop_DivS128E --> vdivesq Vector Divide Extended Signed Quadword
Iop_ModU128  --> vmoduq  Vector Modulo Unsigned Quadword
Iop_ModS128  --> vmodsq  Vector Modulo Signed Quadword

Reading the ISA document, it is clear, that those opcodes perform an
integer division / modulo operation. Technically, they work on vector
registers, presumably because vector registers are the only resource
wide enough to store a quadword. Perhaps that is where the confusion
comes from.
So Ity_I128 it is.

4 weeks agoRefactor IRICB
Florian Krohm [Tue, 8 Jul 2025 09:45:47 +0000 (09:45 +0000)] 
Refactor IRICB

So far there was only one application of IR injection, namely vbit-test.
Soonish there will be another.
Refactor the IRICB to separate out the structure for the application's
payload.

4 weeks agoFix VEX/useful/Makefile-vex again
Paul Floyd [Tue, 8 Jul 2025 06:27:20 +0000 (08:27 +0200)] 
Fix VEX/useful/Makefile-vex again

Again a hard coded error, using cc. Replace that with ${CC} so that
it uses the default system or user specified compiler.

4 weeks agoFix VEX/useful/Makefile-vex
Paul Floyd [Tue, 8 Jul 2025 06:14:56 +0000 (08:14 +0200)] 
Fix VEX/useful/Makefile-vex

This uses hard coded 'make' which may mean Solaris make or
BSD make ratheer than the initial invokation (e.g., gmake or some
other make that is not first inthe PATH). Use ${MAKE} instead
so that the same make is used for the second invokation.

4 weeks agoFix VEX/Makefile-gcc
Florian Krohm [Mon, 7 Jul 2025 20:17:38 +0000 (20:17 +0000)] 
Fix VEX/Makefile-gcc

Compile errors because config.h not found. Turns out libvex_inner.h
Also missing was priv/host_generic_reg_alloc3.o causing linking to fail.
Now fixed.

4 weeks agoAdd vgstack to NEWS
Paul Floyd [Mon, 7 Jul 2025 18:05:50 +0000 (20:05 +0200)] 
Add vgstack to NEWS

4 weeks agos390x: Minor fix for vbit-test
Florian Krohm [Mon, 7 Jul 2025 13:51:29 +0000 (13:51 +0000)] 
s390x: Minor fix for vbit-test

Add a big comment as to why Ity_I1 type values are stored in a
32-bit entity.

5 weeks agoCheck dup2 oldfd before allowing the syscall
Mark Wielaard [Fri, 4 Jul 2025 22:51:36 +0000 (00:51 +0200)] 
Check dup2 oldfd before allowing the syscall

The dup201 LTP test fails with TFAIL: dup2(1024, 5) succeeded

That is because 1024 here is the soft file limit (so one higher than
the max number of fds). Valgrind raises the soft limit a little
internally to have a few private fds for itself. So this dup2 call
succeeds (and possibly dups and internal valgrind fd into the
newfd). We should check the oldfd before allowing the dup2 syscall,
like we already check the newfd.

5 weeks agoSanity check io_submit addresses before dereferencing
Mark Wielaard [Fri, 4 Jul 2025 21:14:18 +0000 (23:14 +0200)] 
Sanity check io_submit addresses before dereferencing

The LTP io_submit03 test fails under valgrind memcheck because it
tests bad struct iocb attay addresses. Fix this by explicitly checking
the struct iocb pointer and each array element pointer are safe to
deref in the linux sys_io_submit PRE handler.

5 weeks agoImplement fcntl F_CREATED_QUERY
Alexandra Hájková [Fri, 4 Jul 2025 11:35:13 +0000 (07:35 -0400)] 
Implement fcntl F_CREATED_QUERY

Define VKI_F_CREATED_QUERY in vki-linux.h.
Recognize it in PRE(sys_fcntl).
This fixes ltp tests failures. When running:
make ltpchecks TESTS="fcntl40 fcntl40_64
the tests would fail with:
fcntl40: unempty log2.filtered:
==1809471== Warning: unimplemented fcntl command: 1028

https://bugs.kde.org/show_bug.cgi?id=506076

5 weeks agoFreeBSD syscall: harden sysctl kern.proc.pathname
Paul Floyd [Thu, 3 Jul 2025 20:06:49 +0000 (22:06 +0200)] 
FreeBSD syscall: harden sysctl kern.proc.pathname

Add handling for NULL len pointer and not enough space
for path. Also extend the bug470713 with a few more checks.

Need to add some more inaccessible memory checks.

5 weeks agos390x: Fix diagnostic for S390_DECODE_UNKNOWN_SPECIAL_INSN
Florian Krohm [Mon, 30 Jun 2025 19:31:33 +0000 (19:31 +0000)] 
s390x: Fix diagnostic for S390_DECODE_UNKNOWN_SPECIAL_INSN

When decoding fails the insn bytes (at most 6) are shown. However,
"special insns" are 10 bytes with the last 2 bytes being the interesting
ones. Print them all.

5 weeks agos390x: Add script s390-runone to help debugging small code snippets
Florian Krohm [Mon, 30 Jun 2025 08:27:18 +0000 (08:27 +0000)] 
s390x: Add script s390-runone to help debugging small code snippets

6 weeks agomips32: Use LINXY for statmount and listmount
Mark Wielaard [Sat, 28 Jun 2025 16:33:29 +0000 (18:33 +0200)] 
mips32: Use LINXY for statmount and listmount

commit 57152acfc6a8 "Wrap linux specific syscalls 457 (listmount) and
458 (statmount)" added LINXY wrappers for all arches, except for
mips32 where it used LINX_. This was a typo/mistake. Make sure mips32
also uses LINXY wrappers.

Suggested-by: Matthias Schwarzott <zzam@gentoo.org>
6 weeks agoNon-Linux regtest: update none cmdline2 stdout expected
Paul Floyd [Sat, 28 Jun 2025 07:00:13 +0000 (09:00 +0200)] 
Non-Linux regtest: update none cmdline2 stdout expected

6 weeks agoWrap linux specific syscalls 457 (listmount) and 458 (statmount)
Martin Cermak [Fri, 27 Jun 2025 20:36:03 +0000 (22:36 +0200)] 
Wrap linux specific syscalls 457 (listmount) and 458 (statmount)

The listmount syscall returns a list of mount IDs under the req.mnt_id.
This is meant to be used in conjunction with statmount(2) in order to
provide a way to iterate and discover mounted file systems.

The statmount syscall returns information about a mount, storing it in
the buffer pointed to by smbuf.  The returned buffer is a struct
statmount which is of size bufsize.

Declare a sys_{lis,sta}tmount wrapper in priv_syswrap-linux.h and hook it
for {amd64,arm,arm64,mips64,nanomips,ppc32,ppc64,riscv64,s390x,x86}-linux
using LINXY with PRE and POST handler in syswrap-linux.c

Both syscalls need CAP_SYS_ADMIN, to successfully test.

Resolves: https://bugs.kde.org/show_bug.cgi?id=502968

6 weeks agoAdd "bad" option for --track-fds.
Alexandra Hájková [Fri, 20 Jun 2025 07:21:41 +0000 (03:21 -0400)] 
Add "bad" option for --track-fds.

When --track-fds=bad is specified, do not warn about
leaked file descriptors and only warn about file decriptors
which was not opened or already closed.

Update the documentation in docs/xml/manual-core.xml.

Add none/tests/track_bad test to test the new option.

Adjust none/tests/cmdline1 and  none/tests/cmdline2 expected
outputs.

https://bugs.kde.org/show_bug.cgi?id=493434

6 weeks agoBug 503241 - s390x: Support z17 changes to the NNPA instruction
Andreas Arnez [Wed, 25 Jun 2025 14:35:04 +0000 (16:35 +0200)] 
Bug 503241 - s390x: Support z17 changes to the NNPA instruction

This adds support for the NNPA enhancements that are implemented with z17.

7 weeks agoUpdate DW_TAG_subprogram parsing for clang
Mark Wielaard [Sat, 21 Jun 2025 21:04:04 +0000 (23:04 +0200)] 
Update DW_TAG_subprogram parsing for clang

Clang doesn't give a name for some artificial subprograms. In that
case just use "<artificial>" as the name of the DW_TAG_subprogram.

Clang also sometimes generates a DW_TAG_subprogram without any
attributes. These aren't really useful for us. So just silently skip
them.

If we warn about subprograms without a name, specification or abstract
origin, also emit the index in the .debug_info section to make it
easier to look them up.