/memcheck/tests/linux/.deps
/memcheck/tests/linux/aligned_alloc
/memcheck/tests/linux/brk
+/memcheck/tests/linux/bug420682_1
+/memcheck/tests/linux/bug420682_2
/memcheck/tests/linux/bug480706
/memcheck/tests/linux/capget
/memcheck/tests/linux/check_preadv2_pwritev2
are not entered into bugzilla tend to get forgotten about or ignored.
396415 Valgrind is not looking up $ORIGIN rpath of shebang programs
+420682 io_pgetevents is not supported
469782 Valgrind does not support zstd-compressed debug sections
487296 --track-fds=yes and --track-fds=all report erroneous information
when fds 0, 1, or 2 are used as non-std
AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
+AC_MSG_CHECKING([for __NR_io_pgetevents])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <linux/unistd.h>
+]], [[
+return __NR_io_pgetevents
+]])], [
+ac_have_nr_io_pgetevents=yes
+AC_MSG_RESULT([yes])
+], [
+ac_have_nr_io_pgetevents=no
+AC_MSG_RESULT([no])
+])
+
+AM_CONDITIONAL(HAVE_NR_IO_PGETEVENTS, [test x$ac_have_nr_io_pgetevents = xyes])
+
+safe_LIBS="$LIBS"
+LIBS="-laio"
+AC_MSG_CHECKING([for libaio])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <libaio.h>
+]], [[
+io_context_t ctx;
+io_submit(ctx, 1, NULL);
+]])], [
+ac_have_libaio=yes
+AC_MSG_RESULT([yes])
+], [
+ac_have_libaio=no
+AC_MSG_RESULT([no])
+])
+
+AM_CONDITIONAL(HAVE_LIBAIO, [test x$ac_have_libaio = xyes])
+LIBS=$safe_LIBS
+
#----------------------------------------------------------------------------
# Checking for supported compiler flags.
#----------------------------------------------------------------------------
DECL_TEMPLATE(linux, sys_preadv2);
DECL_TEMPLATE(linux, sys_pwritev);
DECL_TEMPLATE(linux, sys_pwritev2);
+DECL_TEMPLATE(linux, sys_io_pgetevents);
DECL_TEMPLATE(linux, sys_sendmmsg);
DECL_TEMPLATE(linux, sys_recvmmsg);
DECL_TEMPLATE(linux, sys_dup3);
LINX_(__NR_pkey_alloc, sys_pkey_alloc), // 330
LINX_(__NR_pkey_free, sys_pkey_free), // 331
+ LINX_(__NR_io_pgetevents, sys_io_pgetevents), // 333
+
LINXY(__NR_io_uring_setup, sys_io_uring_setup), // 425
LINXY(__NR_io_uring_enter, sys_io_uring_enter), // 426
LINXY(__NR_io_uring_register, sys_io_uring_register), // 427
// (__NR_pkey_alloc, sys_ni_syscall), // 289
// (__NR_pkey_free, sys_ni_syscall), // 290
LINXY(__NR_statx, sys_statx), // 291
+ LINX_(__NR_io_pgetevents, sys_io_pgetevents), // 292
+
GENX_(__NR_rseq, sys_ni_syscall), // 293
}
}
-PRE(sys_io_getevents)
+static
+void common_pre_io_getevents(ThreadId tid, UWord a1, UWord a2, UWord a3, UWord a4, UWord a5, UWord a6, UWord* flags, const HChar* funtion_name)
{
+ HChar buf[25];
*flags |= SfMayBlock;
- PRINT("sys_io_getevents ( %llu, %lld, %lld, %#" FMT_REGWORD "x, %#"
- FMT_REGWORD "x )",
- (ULong)ARG1,(Long)ARG2,(Long)ARG3,ARG4,ARG5);
+ PRINT("sys_%s ( %llu, %lld, %lld, %#" FMT_REGWORD "x, %#"
+ FMT_REGWORD "x )", funtion_name,
+ (ULong)a1,(Long)a2,(Long)a3,a4,a5);
+ if (a3 > 0) {
+ VG_(snprintf)(buf, 25, "%s(events)", funtion_name);
+ PRE_MEM_WRITE( buf, a4, sizeof(struct vki_io_event)*a3 );
+ }
+ if (a5 != 0) {
+ VG_(snprintf)(buf, 25, "%s(timeout)", funtion_name);
+ PRE_MEM_READ( buf, a5, sizeof(struct vki_timespec));
+ }
+
+ if (a6 != 0) {
+ // only for io_pgetevents
+ PRE_MEM_READ("io_pgetevents(usig)",
+ a6, sizeof(struct vki__aio_sigset));
+ }
+}
+
+PRE(sys_io_getevents)
+{
PRE_REG_READ5(long, "io_getevents",
vki_aio_context_t, ctx_id, long, min_nr, long, nr,
struct io_event *, events,
struct timespec *, timeout);
- if (ARG3 > 0)
- PRE_MEM_WRITE( "io_getevents(events)",
- ARG4, sizeof(struct vki_io_event)*ARG3 );
- if (ARG5 != 0)
- PRE_MEM_READ( "io_getevents(timeout)",
- ARG5, sizeof(struct vki_timespec));
+ common_pre_io_getevents(tid, ARG1, ARG2, ARG3, ARG4, ARG5, 0U, flags, "io_getevents");
}
-POST(sys_io_getevents)
+
+static
+void common_post_sys_io_events(ThreadId tid, UWord a4, SyscallStatus* status, const HChar* funtion_name)
{
Int i;
vg_assert(SUCCESS);
if (RES > 0) {
- POST_MEM_WRITE( ARG4, sizeof(struct vki_io_event)*RES );
+ POST_MEM_WRITE( a4, sizeof(struct vki_io_event)*RES );
for (i = 0; i < RES; i++) {
const struct vki_io_event *vev =
- ((struct vki_io_event *)(Addr)ARG4) + i;
+ ((struct vki_io_event *)(Addr)a4) + i;
const struct vki_iocb *cb = (struct vki_iocb *)(Addr)vev->obj;
switch (cb->aio_lio_opcode) {
break;
case VKI_IOCB_CMD_PREADV:
- if (vev->result > 0) {
- struct vki_iovec * vec = (struct vki_iovec *)(Addr)cb->aio_buf;
- Int remains = vev->result;
- Int j;
-
- for (j = 0; j < cb->aio_nbytes; j++) {
- Int nReadThisBuf = vec[j].iov_len;
- if (nReadThisBuf > remains) nReadThisBuf = remains;
- POST_MEM_WRITE( (Addr)vec[j].iov_base, nReadThisBuf );
- remains -= nReadThisBuf;
- if (remains < 0) VG_(core_panic)("io_getevents(PREADV): remains < 0");
- }
- }
- break;
+ if (vev->result > 0) {
+ struct vki_iovec * vec = (struct vki_iovec *)(Addr)cb->aio_buf;
+ Int remains = vev->result;
+ Int j;
+
+ for (j = 0; j < cb->aio_nbytes; j++) {
+ Int nReadThisBuf = vec[j].iov_len;
+ if (nReadThisBuf > remains) nReadThisBuf = remains;
+ POST_MEM_WRITE( (Addr)vec[j].iov_base, nReadThisBuf );
+ remains -= nReadThisBuf;
+ if (remains < 0) VG_(core_panic)("io_getevents(PREADV): remains < 0");
+ }
+ }
+ break;
case VKI_IOCB_CMD_PWRITEV:
break;
default:
VG_(message)(Vg_DebugMsg,
- "Warning: unhandled io_getevents opcode: %u\n",
+ "Warning: unhandled %s opcode: %u\n",
+ funtion_name,
cb->aio_lio_opcode);
break;
}
}
}
+POST(sys_io_getevents)
+{
+ common_post_sys_io_events(tid, ARG4, status, "io_getevents");
+}
+
PRE(sys_io_submit)
{
Int i, j;
SET_STATUS_Failure( VKI_EINVAL );
}
+PRE(sys_io_pgetevents)
+{
+ PRE_REG_READ5(long, "io_pgetevents",
+ vki_aio_context_t, ctx_id, long, min_nr, long, nr,
+ struct io_event *, events,
+ struct timespec *, timeout);
+ common_pre_io_getevents(tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, flags, "io_pgetevents");
+}
+
+POST(sys_io_pgetevents)
+{
+ common_post_sys_io_events(tid, ARG4, status, "io_pgetevents");
+}
+
PRE(sys_pkey_mprotect)
{
PRINT("sys_pkey_mprotect ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %"
//..
LINXY(__NR_statx, sys_statx), // 366
GENX_(__NR_rseq, sys_ni_syscall), // 367
+ LINX_(__NR_io_pgetevents, sys_io_pgetevents), // 368
LINX_(__NR_semget, sys_semget), // 393
LINXY(__NR_semctl, sys_semctl), // 394
LINX_ (__NR_syncfs, sys_syncfs),
LINXY (__NR_statx, sys_statx),
GENX_ (__NR_rseq, sys_ni_syscall),
+ LINX_ (__NR_io_pgetevents, sys_io_pgetevents),
LINX_ (__NR_setns, sys_setns),
LINXY (__NR_io_uring_setup, sys_io_uring_setup),
LINXY (__NR_io_uring_enter, sys_io_uring_enter),
LINXY(__NR_preadv2, sys_preadv2), /* 286 */
LINX_(__NR_pwritev2, sys_pwritev2), /* 287 */
LINXY(__NR_statx, sys_statx), /* 291 */
+ LINX_(__NR_io_pgetevents, sys_io_pgetevents), /* 292 */
GENX_(__NR_rseq, sys_ni_syscall), /* 293 */
LINXY(__NR_io_uring_setup, sys_io_uring_setup), /* 425 */
LINXY(__NR_io_uring_enter, sys_io_uring_enter), /* 426 */
LINXY(__NR_statx, sys_statx), // 379
GENX_(__NR_rseq, sys_ni_syscall), // 381
+ LINX_(__NR_io_pgetevents, sys_io_pgetevents), // 382
LINXY(__NR_io_uring_setup, sys_io_uring_setup), // 425
LINXY(__NR_io_uring_enter, sys_io_uring_enter), // 426
/* Explicitly not supported on i386 yet. */
GENX_(__NR_arch_prctl, sys_ni_syscall), // 384
+ LINX_(__NR_io_pgetevents, sys_io_pgetevents), // 385
GENX_(__NR_rseq, sys_ni_syscall), // 386
LINX_(__NR_shmget, sys_shmget), // 395
#define VKI_BTRFS_SUPER_MAGIC 0x9123683E
+struct vki__aio_sigset {
+ const vki_sigset_t __user *sigmask;
+ vki_size_t sigsetsize;
+};
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
#define __NR_pkey_alloc 289
#define __NR_pkey_free 290
#define __NR_statx 291
-#define __NR_io_pgetevents 291
+#define __NR_io_pgetevents 292
#define __NR_rseq 293
#undef __NR_syscalls
#define __NR_pwritev2 287
#define __NR_pkey_free 290
#define __NR_statx 291
+#define __NR_io_pgetevents 292
#define __NR_rseq 293
#define __NR_io_uring_setup 425
#define __NR_io_uring_enter 426
aligned_alloc.stderr.exp-glibc238 \
brk.stderr.exp brk.vgtest \
bug480706.stderr.exp bug480706.vgtest \
+ bug420682_1.stderr.exp bug420682_1.vgtest \
+ bug420682_2.stderr.exp bug420682_2.vgtest \
capget.vgtest capget.stderr.exp capget.stderr.exp2 capget.stderr.exp3 \
capget.stderr.exp4 \
debuginfod-check.stderr.exp debuginfod-check.vgtest.in \
check_PROGRAMS += strlcat_strlcpy
endif
+if HAVE_LIBAIO
+ check_PROGRAMS += bug420682_1
+if HAVE_NR_IO_PGETEVENTS
+ check_PROGRAMS += bug420682_2
+endif
+endif
+
AM_CFLAGS += $(AM_FLAG_M3264_PRI)
AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
bug480706_LDADD = -lcrypto
endif
+if HAVE_LIBAIO
+bug420682_1_LDADD = -laio
+endif
+
+if HAVE_NR_IO_PGETEVENTS
+bug420682_2_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_UNINITIALIZED@
+endif
+
# Build shared object for dlclose_leak
dlclose_leak_so_so_SOURCES = dlclose_leak_so.c
dlclose_leak_so_so_CFLAGS = $(AM_CFLAGS) -fpic -g -O0
--- /dev/null
+/*
+ * See https://bugs.kde.org/show_bug.cgi?id=420682
+ *
+ */
+#include <assert.h>
+#include <fcntl.h>
+#include <libaio.h>
+#include <unistd.h>
+
+int main(void)
+{
+ const char *msg = "hello world\n";
+ struct iocb iocb = {};
+ struct io_event event;
+ io_context_t ctx = 0;
+ struct iocb *iocbp;
+ int rc, fd;
+
+ rc = io_setup(1, &ctx);
+ assert(rc == 0);
+
+ fd = open("test.txt", O_CREAT | O_RDWR, 0666);
+ assert(fd >= 0);
+
+ io_prep_pwrite(&iocb, fd, (void *)msg, 12, 0);
+ iocbp = &iocb;
+
+ rc = io_submit(ctx, 1, &iocbp);
+ assert(rc == 1);
+
+ rc = io_getevents(ctx, 1, 1, &event, NULL);
+ assert(rc == 1);
+
+ close(fd);
+
+ io_destroy(ctx);
+}
--- /dev/null
+prereq: test -e bug420682_1
+prog: bug420682_1
+vgopts: -q
+post: rm -f test.txt
--- /dev/null
+/*
+ * See https://bugs.kde.org/show_bug.cgi?id=420682
+ *
+ * Some scalar-style errors.
+ */
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/syscall.h>
+#include <libaio.h>
+#include "../../../memcheck/memcheck.h"
+
+int main(void)
+{
+ long* px = malloc(sizeof(long));
+ long x0 = px[0];
+ syscall(__NR_io_pgetevents, x0-1, x0, x0, x0+1, x0+1, x0+1);
+
+ struct timespec ts;
+ struct aio_sigset {
+ const sigset_t* sigmask;
+ size_t sigsetsize;
+ } as;
+ struct io_event event;
+
+ VALGRIND_MAKE_MEM_UNDEFINED(&event, sizeof(event));
+ VALGRIND_MAKE_MEM_UNDEFINED(&ts, sizeof(ts));
+ VALGRIND_MAKE_MEM_UNDEFINED(&as, sizeof(as));
+
+ syscall(__NR_io_pgetevents, x0-1, x0, x0, &event, &ts, &as);
+
+ free(px);
+}
--- /dev/null
+Syscall param io_pgetevents(ctx_id) contains uninitialised byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:16)
+
+Syscall param io_pgetevents(min_nr) contains uninitialised byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:16)
+
+Syscall param io_pgetevents(nr) contains uninitialised byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:16)
+
+Syscall param io_pgetevents(events) contains uninitialised byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:16)
+
+Syscall param io_pgetevents(timeout) contains uninitialised byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:16)
+
+Syscall param io_pgetevents(timeout) points to unaddressable byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:16)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param io_pgetevents(usig) points to unaddressable byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:16)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param io_pgetevents(ctx_id) contains uninitialised byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:29)
+
+Syscall param io_pgetevents(min_nr) contains uninitialised byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:29)
+
+Syscall param io_pgetevents(nr) contains uninitialised byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:29)
+
+Syscall param io_pgetevents(timeout) points to uninitialised byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:29)
+ Address 0x........ is on thread 1's stack
+ in frame #1, created by main (bug420682_2.c:13)
+
+Syscall param io_pgetevents(usig) points to uninitialised byte(s)
+ ...
+ by 0x........: main (bug420682_2.c:29)
+ Address 0x........ is on thread 1's stack
+ in frame #1, created by main (bug420682_2.c:13)
+
--- /dev/null
+prereq: test -e bug420682_2
+prog: bug420682_2
+vgopts: -q
+