glibc 2.42+ (with linux 6.13+) uses MADV_GUARD_INSTALL to setup stack
guard pages. valgrind currently isn't able to track this and such
guard pages also don't show up in /proc maps (only in /proc pagemap
since linux 6.14). For now valgrind fails a madvise MADV_GUARD_INSTALL
syscall with EINVAL. This causes glibc to fall back to mprotect
PROT_NONE which valgrind is able to track.
https://bugs.kde.org/show_bug.cgi?id=511717
Wasn't undefining the PLAT macros
Add FreeBSD to the head and tail comments for each arch
amd64 is getting crowded, if we add any more OSes then I think
just "amd64 platforms" will be enough rather than listing 5 or 6
or more platforms.
== 721 tests, 46 stderr failures, 6 stdout failures, 0 stderrB failures, 0 stdoutB failures, 4 post failures ==
A couple more failures in none (empty-exe and scripts/shell). Otherwise quite like
macOS 10.14.
Much of the code merged from Louis Brunner's git repo. Many thanks once again
Louis.
The lsm_list_modules syscall returns a list of the active LSM ids. On
success this function returns the number of @ids array elements. This
value may be zero if there are no LSMs active. If @size is insufficient
to contain the return data -E2BIG is returned and @size is set to the
minimum required size. In all other cases a negative value indicating
the error is returned.
SYSCALL_DEFINE3(lsm_list_modules, u64 __user *, ids, u32 __user *, size,
u32, flags)
Declare lsm_list_modules wrappers in priv_syswrap-linux.h and hook it
for {amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x,x86}-linux.
https://bugs.kde.org/show_bug.cgi?id=513257
The semaphore functions are not in the pthread library (similar to FreeBSD).
Change the redirs to use libsystem_kernel.dylib
Unfortunately this doesn't help much. Darwin has deprecated these functions
so the tests will compile (with a warning) but at runtime they all fail
with errors like ENOSYS and EBADF.
In the Darwin headers the macro __DARWIN_ALIGN32 is used for
the CMSG macros. We were using just ALIGN which looks like
it uses __DARWIN_ALIGN for 8 byte alignment. Using the
wrong alignment gate a wrong count of fds and check_cmsg_for_fds
was only calling ML_(record_fd_open_named) for one fd. The result
was fd errors when writing to a second fd that should have been
recorded.
Create a system call lsm_get_self_attr() to provide the security
module maintained attributes of the current process.
Create a system call lsm_set_self_attr() to set a security
module maintained attribute of the current process.
Historically these attributes have been exposed to user space via
entries in procfs under /proc/self/attr.
Declare lsm_get_self_attr and lsm_set_self_attr wrappers in
priv_syswrap-linux.h and hook it for {amd64,arm,arm64,mips64,\
ppc32,ppc64,riscv64,s390x,x86}-linux.
https://bugs.kde.org/show_bug.cgi?id=510563
Firstly make them a bit more similar. Secondly, switch Darwin
from using __NR_MAXSYSCALL which changes with every Darwin version
to using 1000 like FreeBSD.
Change NEWS for macOS 10.13, it has now progressed beyond
'preliminary'.
It doesn't do any checking yet. However, with this change running
TextEditor with --tool=none gets as far as drawing a white box on
the screen. Then it fails because there is a missing mach trap handler
for
/* 11 */ MACH_TRAP(_kernelrpc_mach_vm_purgable_control_trap, 4, 5, munge_wlww),
ARG4 can point to different things of varion sizes based on the
cmd arg. Handle all the possible options and provide missing
checks.
https://bugs.kde.org/show_bug.cgi?id=509634
Most of these changes are from Louis Brunner's GitHub repo.
The most imortant changes are to the memory space and to the code
related to getting the host filename during startup. This means
that when Valgrind crashes or hits an assert we now get a legible
host stacktrrace.
This also fixes none/tests/darwin/bug228343
The syscalls take fd and path. If path is absolute, fd is not
used. If path is empty, fd can be AT_FDCWD or any valid fd which
will be used to get/set attributes on.
https://bugs.kde.org/show_bug.cgi?id=510169
Fix ioctl(fd, PROCMAP_QUERY, ...) so that valgrind correctly considers
memory referenced by vma_name_size and vma_name_addr members of struct
procmap_query as initialized by ioctl().
Extend ioctl syscall wrappers with needed PRE_MEM_WRITE() and
mainly POST_MEM_WRITE(). Add a testcase.
https://bugs.kde.org/show_bug.cgi?id=508328
- Update COPYING and VEX/LICENSE.GPL to version 3.
- Update README, NEWS, docs/manual license and contributing text.
- Update file headers to say either version 3 of the License,
or (at your option) any later version.
- Leave tests and perf file headers as is, unless the code is derived
from Valgrind/VEX.
- Leave valgrind.h, cachegrind.h, callgrind.h, drd.h, helgrind.h,
memcheck.h and dhat.h Hybrid-BSD licensed.
Several files still said to write to the Free Software Foundation at a
particular address. Add a reference to <http://www.gnu.org/licenses/>
instead.
Some files that were imported into valgrind from other places still
mention the old address. They should be updated when new versions
get imported.
Most of the exe name functions can take a const char* for the name.
Indeed, on Linux this is a requirement since we also lookup
debuginfod-find using a const char string literal.
The exception to this rule is for scripts. In this case the script
shebang can refer to another script with another shebang. And so on
until eventually an ELF or macho file is encountered. In that case
VG_(args_the_exename) will get freed if necessary and reassigned
to a new string. So VG_(load_script) needs to be able to take a
non-const char* name, unlike VG_(load_ELF) and VG_(load_macho).
VG_(args_the_exename) is now non-const (which fixes a warning
when freeing it), VG_(load_script) takes a non-const name
and there is an ugly cast for the function pointer.
int syscall(SYS_mount_setattr, int dirfd, const char *pathname,
unsigned int flags, struct mount_attr *attr, size_t size);
The mount_setattr() system call changes the mount properties of a
mount or an entire mount tree. If pathname is a relative pathname,
then it is interpreted relative to the directory referred to by the
file descriptor dirfd. If dirfd is the special value AT_FDCWD, then
pathname is interpreted relative to the current working directory of
the calling process. If pathname is the empty string and
AT_EMPTY_PATH is specified in flags, then the mount properties of the
mount identified by dirfd are changed
Declare a mount_setattr wrapper in priv_syswrap-linux.h and hook it
for {amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x,x86}-linux
using LINX_ with PRE handler in syswrap-linux.c
Part of this update also is a fix of the sys_move_mount wrapper.
Specifically there was a typo mount_moce vs. move_mount, and also
there was a problem in handling VKI_AT_FDCWD special fd value in the
check for to_fd and to_pathname.
https://bugs.kde.org/show_bug.cgi?id=509566
The setdomainname() call sets the domain name to the value given in the
character array name. The len argument specifies the number of bytes in
name. (Thus, name does not require a terminating null byte.)
Declare a setdomainname wrapper in priv_syswrap-linux.h and hook it for
{amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x,x86}-linux using
LINX_ with PRE handler in syswrap-linux.c
https://bugs.kde.org/show_bug.cgi?id=369030
This update adds following ppc64le and s390x syswraps:
- sys_msgctl
- sys_semctl
- sys_semtimedop
- sys_sethostname
- sys_shmctl
- sys_sigpending
- sys_stime
This update adds following ppc64le syswraps:
- sys_setns
This update adds following s390x syswraps:
- sys_bpf
Blacklist the shmctl05, as it is a long running one. It does
pass on all architectures afaics, but needs a relatively high
LTP_TIMEOUT_MUL setting. So, let's skip that one.
https://bugs.kde.org/show_bug.cgi?id=509642https://bugs.kde.org/show_bug.cgi?id=509643
SYSCALL_DEFINE4(quotactl_fd,
unsigned int, fd,
unsigned int, cmd,
qid_t, id,
void __user *, addr)
The quotactl_fd works in a similar way to quotactl. They both manipulate
disk quotas. They differ in how the target file system is specified.
While quotactl takes path, quotactl_fd takes a file descriptor.
Declare a quotactl_fd wrapper in priv_syswrap-linux.h and hook it for
{amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x,x86}-linux using
LINX_ with PRE handler in syswrap-linux.c
https://bugs.kde.org/show_bug.cgi?id=509567
Wrap the futex2/futex_waitv syscall:
sys_futex_waitv(struct futex_waitv __user *, waiters,
unsigned int, nr_futexes, unsigned int, flags,
struct __kernel_timespec __user *, timeout, clockid_t, clockid)
sys_futex_waitv - Wait on a list of futexes
@waiters: List of futexes to wait on
@nr_futexes: Length of futexv
@flags: Flag for timeout (monotonic/realtime)
@timeout: Optional absolute timeout.
@clockid: Clock to be used for the timeout, realtime or monotonic.
Given an array of `struct futex_waitv`, wait on each uaddr. The thread wakes
if a futex_wake() is performed at any uaddr. The syscall returns immediately
if any waiter has *uaddr != val. *timeout is an optional timeout value for
the operation. Each waiter has individual flags. The `flags` argument for
the syscall should be used solely for specifying the timeout as realtime, if
needed. Flags for private futexes, sizes, etc. should be used on the
individual flags of each waiter. Returns the array index of one of the woken
futexes. No further information is provided.
Declare a futex_waitv wrapper in priv_syswrap-linux.h
and hook it for {amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x\
,x86}- linux using LINX_ with PRE handler in syswrap-linux.c
https://bugs.kde.org/show_bug.cgi?id=506816
The remap_file_pages() system call is used to create a nonlinear
mapping, that is, a mapping in which the pages of the file are
mapped into a nonsequential order in memory. It is deprecated
but in some cases it may still be used. LTP remap_file_pages01
and remap_file_pages02 test-cover it.
Declare a remap_file_pages wrapper in priv_syswrap-linux.h
and hook it for {amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x\
,x86}- linux using LINX_ with PRE handler in syswrap-linux.c
https://bugs.kde.org/show_bug.cgi?id=309554
This function was using SYS_lstat. It works OK with illumos
but not Solaris 11+ which has removed that syscall.
Instead do like Linux and FreeBSD, use SYS_fstatat with the flag
for no follow link.
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).
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
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
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
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
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
mseal takes address, size and flags. Flags are reserved for
future use. Modern CPUs support memory permissions such as RW and
NX bits. The mseal syscall takes address and size parameters to
additionally protect memory mapping against modifications.
FTR: https://docs.kernel.org/userspace-api/mseal.html
Declare a sys_mseal wrapper in priv_syswrap-linux.h and hook it
for {amd64,arm,arm64,mips64,nanomips,ppc32,ppc64,riscv64,s390x,x86}-linux
using LINX_ with PRE handler in syswrap-linux.c
https://bugs.kde.org/show_bug.cgi?id=505228