public inbox for [email protected]
 help / color / mirror / Atom feed
* [io-uring] WARNING in io_issue_sqe
@ 2024-06-12 14:29 chase xd
  2024-06-12 15:41 ` Pavel Begunkov
  0 siblings, 1 reply; 3+ messages in thread
From: chase xd @ 2024-06-12 14:29 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov, io-uring, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 5517 bytes --]

Hi,

Syzkaller hits a new bug in branch 6.10.0-rc1-00004-gff802a9f35cf-dirty #7.
Note: this is also not a reliable repro, might need to try more times

```

[  153.857557][T21250] apt-get (21250) used greatest stack depth:
22240 bytes left
[  249.711259][T57846] ------------[ cut here ]------------
[  249.711626][T57846] WARNING: CPU: 1 PID: 57846 at
io_uring/refs.h:38 io_issue_sqe+0x10dc/0x1720
[  249.712188][T57846] Modules linked in:
[  249.712431][T57846] CPU: 1 PID: 57846 Comm: iou-wrk-57845 Not
tainted 6.10.0-rc1-00004-gff802a9f35cf-dirty #7
[  249.713020][T57846] Hardware name: QEMU Standard PC (i440FX + PIIX,
1996), BIOS 1.15.0-1 04/01/2014
[  249.713566][T57846] RIP: 0010:io_issue_sqe+0x10dc/0x1720
[  249.713894][T57846] Code: fc ff df 4c 89 e2 48 c1 ea 03 80 3c 02 00
0f 85 c6 05 00 00 49 89 1c 24 49f
[  249.715023][T57846] RSP: 0018:ffffc9000e84fc00 EFLAGS: 00010293
[  249.715389][T57846] RAX: 0000000000000000 RBX: 0000000000000000
RCX: ffffffff84139c3c
[  249.715855][T57846] RDX: ffff88801eaad640 RSI: ffffffff8413a70b
RDI: 0000000000000007
[  249.716300][T57846] RBP: ffffc9000e84fc80 R08: 0000000000000007
R09: 0000000000000000
[  249.716676][T57846] R10: 0000000000000000 R11: 0000000000000000
R12: ffff8880001c3a00
[  249.717042][T57846] R13: 0000000000000000 R14: ffff888010600040
R15: ffff8880001c3a48
[  249.717428][T57846] FS:  00007f58ce931800(0000)
GS:ffff88807ec00000(0000) knlGS:0000000000000000
[  249.717837][T57846] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  249.718135][T57846] CR2: 00007f58ce932128 CR3: 000000001b08a000
CR4: 00000000000006f0
[  249.718497][T57846] Call Trace:
[  249.718668][T57846]  <TASK>
[  249.718810][T57846]  ? __warn+0xc7/0x2f0
[  249.719003][T57846]  ? io_issue_sqe+0x10dc/0x1720
[  249.719233][T57846]  ? report_bug+0x347/0x410
[  249.719451][T57846]  ? handle_bug+0x3d/0x80
[  249.719654][T57846]  ? exc_invalid_op+0x18/0x50
[  249.719872][T57846]  ? asm_exc_invalid_op+0x1a/0x20
[  249.720127][T57846]  ? io_issue_sqe+0x60c/0x1720
[  249.720420][T57846]  ? io_issue_sqe+0x10db/0x1720
[  249.720711][T57846]  ? io_issue_sqe+0x10dc/0x1720
[  249.721012][T57846]  ? __fget_files+0x1bc/0x3d0
[  249.722194][T57846]  ? io_wq_submit_work+0x264/0xcb0
[  249.722521][T57846]  io_wq_submit_work+0x264/0xcb0
[  249.722826][T57846]  io_worker_handle_work+0x97e/0x1790
[  249.723159][T57846]  io_wq_worker+0x38e/0xe50
[  249.723435][T57846]  ? __pfx_io_wq_worker+0x10/0x10
[  249.723687][T57846]  ? ret_from_fork+0x16/0x70
[  249.723907][T57846]  ? __pfx_lock_release+0x10/0x10
[  249.724139][T57846]  ? do_raw_spin_lock+0x12c/0x2b0
[  249.724392][T57846]  ? __pfx_do_raw_spin_lock+0x10/0x10
[  249.724706][T57846]  ? __pfx_io_wq_worker+0x10/0x10
[  249.725015][T57846]  ret_from_fork+0x2f/0x70
[  249.725300][T57846]  ? __pfx_io_wq_worker+0x10/0x10
[  249.725603][T57846]  ret_from_fork_asm+0x1a/0x30
[  249.725897][T57846]  </TASK>
[  249.726083][T57846] Kernel panic - not syncing: kernel: panic_on_warn set ...
[  249.726521][T57846] CPU: 1 PID: 57846 Comm: iou-wrk-57845 Not
tainted 6.10.0-rc1-00004-gff802a9f35cf-dirty #7
[  249.727110][T57846] Hardware name: QEMU Standard PC (i440FX + PIIX,
1996), BIOS 1.15.0-1 04/01/2014
[  249.727647][T57846] Call Trace:
[  249.727842][T57846]  <TASK>
[  249.728018][T57846]  panic+0x4fa/0x5a0
[  249.728252][T57846]  ? __pfx_panic+0x10/0x10
[  249.728516][T57846]  ? show_trace_log_lvl+0x284/0x390
[  249.728832][T57846]  ? io_issue_sqe+0x10dc/0x1720
[  249.729120][T57846]  check_panic_on_warn+0x61/0x80
[  249.729416][T57846]  __warn+0xd3/0x2f0
[  249.729650][T57846]  ? io_issue_sqe+0x10dc/0x1720
[  249.729941][T57846]  report_bug+0x347/0x410
[  249.730206][T57846]  handle_bug+0x3d/0x80
[  249.730460][T57846]  exc_invalid_op+0x18/0x50
[  249.730730][T57846]  asm_exc_invalid_op+0x1a/0x20
[  249.731031][T57846] RIP: 0010:io_issue_sqe+0x10dc/0x1720
[  249.731365][T57846] Code: fc ff df 4c 89 e2 48 c1 ea 03 80 3c 02 00
0f 85 c6 05 00 00 49 89 1c 24 49f
[  249.732508][T57846] RSP: 0018:ffffc9000e84fc00 EFLAGS: 00010293
[  249.732873][T57846] RAX: 0000000000000000 RBX: 0000000000000000
RCX: ffffffff84139c3c
[  249.733351][T57846] RDX: ffff88801eaad640 RSI: ffffffff8413a70b
RDI: 0000000000000007
[  249.733822][T57846] RBP: ffffc9000e84fc80 R08: 0000000000000007
R09: 0000000000000000
[  249.734285][T57846] R10: 0000000000000000 R11: 0000000000000000
R12: ffff8880001c3a00
[  249.734757][T57846] R13: 0000000000000000 R14: ffff888010600040
R15: ffff8880001c3a48
[  249.735236][T57846]  ? io_issue_sqe+0x60c/0x1720
[  249.735529][T57846]  ? io_issue_sqe+0x10db/0x1720
[  249.735825][T57846]  ? __fget_files+0x1bc/0x3d0
[  249.736116][T57846]  ? io_wq_submit_work+0x264/0xcb0
[  249.736428][T57846]  io_wq_submit_work+0x264/0xcb0
[  249.736731][T57846]  io_worker_handle_work+0x97e/0x1790
[  249.737061][T57846]  io_wq_worker+0x38e/0xe50
[  249.737353][T57846]  ? __pfx_io_wq_worker+0x10/0x10
[  249.737646][T57846]  ? ret_from_fork+0x16/0x70
[  249.737861][T57846]  ? __pfx_lock_release+0x10/0x10
[  249.738091][T57846]  ? do_raw_spin_lock+0x12c/0x2b0
[  249.738398][T57846]  ? __pfx_do_raw_spin_lock+0x10/0x10
[  249.738729][T57846]  ? __pfx_io_wq_worker+0x10/0x10
[  249.739033][T57846]  ret_from_fork+0x2f/0x70
[  249.739308][T57846]  ? __pfx_io_wq_worker+0x10/0x10
[  249.739617][T57846]  ret_from_fork_asm+0x1a/0x30
[  249.739913][T57846]  </TASK>
[  249.740236][T57846] Kernel Offset: disabled
[  249.740518][T57846] Rebooting in 86400 seconds..

```

crepro is in attachments.

Regards

[-- Attachment #2: repro.c --]
[-- Type: application/octet-stream, Size: 25860 bytes --]

// autogenerated by syzkaller (https://github.com/google/syzkaller)

#define _GNU_SOURCE

#include <dirent.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>

#ifndef __NR_io_uring_enter
#define __NR_io_uring_enter 426
#endif
#ifndef __NR_io_uring_register
#define __NR_io_uring_register 427
#endif
#ifndef __NR_io_uring_setup
#define __NR_io_uring_setup 425
#endif

static __thread int clone_ongoing;
static __thread int skip_segv;
static __thread jmp_buf segv_env;

static void segv_handler(int sig, siginfo_t* info, void* ctx)
{
  if (__atomic_load_n(&clone_ongoing, __ATOMIC_RELAXED) != 0) {
    exit(sig);
  }
  uintptr_t addr = (uintptr_t)info->si_addr;
  const uintptr_t prog_start = 1 << 20;
  const uintptr_t prog_end = 100 << 20;
  int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0;
  int valid = addr < prog_start || addr > prog_end;
  if (skip && valid) {
    _longjmp(segv_env, 1);
  }
  exit(sig);
}

static void install_segv_handler(void)
{
  struct sigaction sa;
  memset(&sa, 0, sizeof(sa));
  sa.sa_handler = SIG_IGN;
  syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8);
  syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8);
  memset(&sa, 0, sizeof(sa));
  sa.sa_sigaction = segv_handler;
  sa.sa_flags = SA_NODEFER | SA_SIGINFO;
  sigaction(SIGSEGV, &sa, NULL);
  sigaction(SIGBUS, &sa, NULL);
}

#define NONFAILING(...)                                                        \
  ({                                                                           \
    int ok = 1;                                                                \
    __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST);                       \
    if (_setjmp(segv_env) == 0) {                                              \
      __VA_ARGS__;                                                             \
    } else                                                                     \
      ok = 0;                                                                  \
    __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST);                       \
    ok;                                                                        \
  })

static void sleep_ms(uint64_t ms)
{
  usleep(ms * 1000);
}

static uint64_t current_time_ms(void)
{
  struct timespec ts;
  if (clock_gettime(CLOCK_MONOTONIC, &ts))
    exit(1);
  return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
}

static bool write_file(const char* file, const char* what, ...)
{
  char buf[1024];
  va_list args;
  va_start(args, what);
  vsnprintf(buf, sizeof(buf), what, args);
  va_end(args);
  buf[sizeof(buf) - 1] = 0;
  int len = strlen(buf);
  int fd = open(file, O_WRONLY | O_CLOEXEC);
  if (fd == -1)
    return false;
  if (write(fd, buf, len) != len) {
    int err = errno;
    close(fd);
    errno = err;
    return false;
  }
  close(fd);
  return true;
}

#define SIZEOF_IO_URING_SQE 64
#define SIZEOF_IO_URING_CQE 16
#define SQ_HEAD_OFFSET 0
#define SQ_TAIL_OFFSET 64
#define SQ_RING_MASK_OFFSET 256
#define SQ_RING_ENTRIES_OFFSET 264
#define SQ_FLAGS_OFFSET 276
#define SQ_DROPPED_OFFSET 272
#define CQ_HEAD_OFFSET 128
#define CQ_TAIL_OFFSET 192
#define CQ_RING_MASK_OFFSET 260
#define CQ_RING_ENTRIES_OFFSET 268
#define CQ_RING_OVERFLOW_OFFSET 284
#define CQ_FLAGS_OFFSET 280
#define CQ_CQES_OFFSET 320

// From linux/io_uring.h
struct io_uring_cqe {
  uint64_t user_data;
  uint32_t res;
  uint32_t flags;
};

/* This is x86 specific */
#define read_barrier() __asm__ __volatile__("" ::: "memory")
#define write_barrier() __asm__ __volatile__("" ::: "memory")

struct io_sqring_offsets {
  uint32_t head;
  uint32_t tail;
  uint32_t ring_mask;
  uint32_t ring_entries;
  uint32_t flags;
  uint32_t dropped;
  uint32_t array;
  uint32_t resv1;
  uint64_t resv2;
};

struct io_cqring_offsets {
  uint32_t head;
  uint32_t tail;
  uint32_t ring_mask;
  uint32_t ring_entries;
  uint32_t overflow;
  uint32_t cqes;
  uint64_t resv[2];
};

struct io_uring_params {
  uint32_t sq_entries;
  uint32_t cq_entries;
  uint32_t flags;
  uint32_t sq_thread_cpu;
  uint32_t sq_thread_idle;
  uint32_t features;
  uint32_t resv[4];
  struct io_sqring_offsets sq_off;
  struct io_cqring_offsets cq_off;
};

#define IORING_OFF_SQ_RING 0
#define IORING_OFF_SQES 0x10000000ULL
#define IORING_SETUP_SQE128 (1U << 10)
#define IORING_SETUP_CQE32 (1U << 11)
#define IORING_SETUP_NO_SQARRAY (1U << 16)

static struct io_uring_params* io_uring_p;

static long syz_io_uring_complete(volatile long a0, volatile long a1)
{
  // syzlang: syz_io_uring_complete(ring_ptr ring_ptr)
  // C:       syz_io_uring_complete(char* ring_ptr)
  // It is not checked if the ring is empty
  // Cast to original
  long ring_ptr = a0;
  int* result_fd = (int*)a1;
  // result_fd = (int*)mmap(0, sizeof(int) * (io_uring_p->cq_entries), PROT_READ
  // | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); result_fd_cnt = (int*)mmap(0,
  // sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
  int cnt = 0;
  // head read once
  unsigned cq_head_raw = *(unsigned*)(io_uring_p->cq_off.head + ring_ptr);
  unsigned cq_ring_mask = *(unsigned*)(io_uring_p->cq_off.ring_mask + ring_ptr);
  do {

    read_barrier();
    // tail
    unsigned cq_tail_raw = *(unsigned*)(io_uring_p->cq_off.tail + ring_ptr);
    if (cq_head_raw == cq_tail_raw) {
      break;
    }
    // head != tail, retrieve cq from head
    unsigned cq_head = cq_head_raw & cq_ring_mask;
    struct io_uring_cqe* cqe;
    if ((io_uring_p->flags & IORING_SETUP_CQE32) == 0)
      cqe = (struct io_uring_cqe*)(io_uring_p->cq_off.cqes + ring_ptr +
                                   SIZEOF_IO_URING_CQE * cq_head);
    else
      cqe = (struct io_uring_cqe*)(io_uring_p->cq_off.cqes + ring_ptr +
                                   SIZEOF_IO_URING_CQE * 2 * cq_head);
    // In the descriptions (sys/linux/io_uring.txt), openat and openat2 are
    // passed with a unique range of sqe.user_data (0x12345 and 0x23456) to
    // identify the operations which produces an fd instance. Check
    // cqe.user_data, which should be the same as sqe.user_data for that
    // operation. If it falls in that unique range, return cqe.res as fd.
    // Otherwise, just return an invalid fd.
    if (cqe->user_data == 0x12345 || cqe->user_data == 0x23456)
      result_fd[cnt++] = cqe->res;
    cq_head_raw += 1;
  } while (1);
  *(unsigned*)(io_uring_p->cq_off.head + ring_ptr) = cq_head_raw;
  write_barrier();
  if (cnt == 0) {
    return -1;
  }
  return 0;
}

// Wrapper for io_uring_setup and the subsequent mmap calls that map the ring
// and the sqes
static long syz_io_uring_setup(volatile long a0, volatile long a1,
                               volatile long a2, volatile long a3)
{
  // syzlang: syz_io_uring_setup(entries int32[1:IORING_MAX_ENTRIES], params
  // ptr[inout, io_uring_params], ring_ptr ptr[out, ring_ptr], sqes_ptr ptr[out,
  // sqes_ptr]) fd_io_uring C:       syz_io_uring_setup(uint32_t entries, struct
  // io_uring_params* params, void** ring_ptr_out, void** sqes_ptr_out) //
  // returns uint32_t fd_io_uring Cast to original
  uint32_t entries = (uint32_t)a0;
  struct io_uring_params* setup_params = (struct io_uring_params*)a1;
  void** ring_ptr_out = (void**)a2;
  void** sqes_ptr_out = (void**)a3;
  // Temporarily disable IORING_SETUP_CQE32 and IORING_SETUP_SQE128 that may
  // change SIZEOF_IO_URING_CQE and SIZEOF_IO_URING_SQE. Tracking bug:
  // https://github.com/google/syzkaller/issues/4531.
  setup_params->flags &= ~(IORING_SETUP_CQE32 | IORING_SETUP_SQE128);
  uint32_t fd_io_uring = syscall(__NR_io_uring_setup, entries, setup_params);
  io_uring_p = setup_params;
  // Compute the ring sizes
  uint32_t sq_ring_sz =
      setup_params->sq_off.array + setup_params->sq_entries * sizeof(uint32_t);
  uint32_t cq_ring_sz = setup_params->cq_off.cqes +
                        setup_params->cq_entries * SIZEOF_IO_URING_CQE;
  // Asssumed IORING_FEAT_SINGLE_MMAP, which is always the case with the current
  // implementation The implication is that the sq_ring_ptr and the cq_ring_ptr
  // are the same but the difference is in the offsets to access the fields of
  // these rings.
  uint32_t ring_sz = sq_ring_sz > cq_ring_sz ? sq_ring_sz : cq_ring_sz;
  *ring_ptr_out =
      mmap(0, ring_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE,
           fd_io_uring, IORING_OFF_SQ_RING);
  uint32_t sqes_sz = setup_params->sq_entries * SIZEOF_IO_URING_SQE;
  *sqes_ptr_out = mmap(0, sqes_sz, PROT_READ | PROT_WRITE,
                       MAP_SHARED | MAP_POPULATE, fd_io_uring, IORING_OFF_SQES);
  return fd_io_uring;
}

static long syz_io_uring_submit(volatile long a0, volatile long a1,
                                volatile long a2)
{
  // syzlang: syz_io_uring_submit(ring_ptr ring_ptr, sqes_ptr sqes_ptr,
  // sqe ptr[in, io_uring_sqe]) C:       syz_io_uring_submit(char* ring_ptr,
  // io_uring_sqe* sqes_ptr,    io_uring_sqe* sqe) It is not checked if the ring
  // is full Cast to original
  long ring_ptr = a0; // This will be exposed to offsets in bytes
  char* sqes_ptr = (char*)a1;
  char* sqe = (char*)a2;
  unsigned sq_tail_raw = *(unsigned*)(io_uring_p->sq_off.tail + ring_ptr);
  unsigned sq_ring_mask = *(unsigned*)(io_uring_p->sq_off.ring_mask + ring_ptr);
  unsigned sq_tail = sq_tail_raw & sq_ring_mask;
  // write to current sq tail sqe
  void* sqe_dest;
  if ((io_uring_p->flags & IORING_SETUP_SQE128) == 0)
    sqe_dest = (void*)(sqes_ptr + SIZEOF_IO_URING_SQE * sq_tail);
  else {
    sqe_dest = (void*)(sqes_ptr + SIZEOF_IO_URING_SQE * sq_tail * 2);
  }

  // Write the sqe entry to its destination in sqes
  memcpy(sqe_dest, sqe, SIZEOF_IO_URING_SQE);
  // Advance the tail. Tail is a free-flowing integer and relies on natural
  // wrapping. Ensure that the kernel will never see a tail update without the
  // preceeding SQE stores being done.
  __atomic_store_n((unsigned*)(io_uring_p->sq_off.tail + ring_ptr),
                   sq_tail_raw + 1, __ATOMIC_RELEASE);
  // update sq array
  if ((io_uring_p->flags & IORING_SETUP_NO_SQARRAY) == 0)
    __atomic_store_n((unsigned*)(io_uring_p->sq_off.array + ring_ptr) + sq_tail,
                     sq_tail, __ATOMIC_RELEASE);
  // Now the application is free to call io_uring_enter() to submit the sqe
  return 0;
}

static void kill_and_wait(int pid, int* status)
{
  kill(-pid, SIGKILL);
  kill(pid, SIGKILL);
  for (int i = 0; i < 100; i++) {
    if (waitpid(-1, status, WNOHANG | __WALL) == pid)
      return;
    usleep(1000);
  }
  DIR* dir = opendir("/sys/fs/fuse/connections");
  if (dir) {
    for (;;) {
      struct dirent* ent = readdir(dir);
      if (!ent)
        break;
      if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
        continue;
      char abort[300];
      snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort",
               ent->d_name);
      int fd = open(abort, O_WRONLY);
      if (fd == -1) {
        continue;
      }
      if (write(fd, abort, 1) < 0) {
      }
      close(fd);
    }
    closedir(dir);
  } else {
  }
  while (waitpid(-1, status, __WALL) != pid) {
  }
}

static void setup_test()
{
  prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
  setpgrp();
  write_file("/proc/self/oom_score_adj", "1000");
}

static void execute_one(void);

#define WAIT_FLAGS __WALL

static void loop(void)
{
  int iter = 0;
  for (;; iter++) {
    int pid = fork();
    if (pid < 0)
      exit(1);
    if (pid == 0) {
      setup_test();
      execute_one();
      exit(0);
    }
    int status = 0;
    uint64_t start = current_time_ms();
    for (;;) {
      if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid)
        break;
      sleep_ms(1);
      if (current_time_ms() - start < 5000)
        continue;
      kill_and_wait(pid, &status);
      break;
    }
  }
}

uint64_t r[5] = {0x0, 0x0, 0x0, 0xffffffffffffff9c, 0x0};

void execute_one(void)
{
  intptr_t res = 0;
  NONFAILING(*(uint32_t*)0x20000004 = 0x649b);
  NONFAILING(*(uint32_t*)0x20000008 = 0x80);
  NONFAILING(*(uint32_t*)0x2000000c = 0);
  NONFAILING(*(uint32_t*)0x20000010 = 0x4315);
  NONFAILING(*(uint32_t*)0x20000018 = 0);
  NONFAILING(memset((void*)0x2000001c, 0, 12));
  res = -1;
  NONFAILING(res = syz_io_uring_setup(/*entries=*/0x4d84, /*params=*/0x20000000,
                                      /*ring_ptr=*/0x20000080,
                                      /*sqes_ptr=*/0x200000c0));
  if (res != -1) {
    r[0] = res;
    NONFAILING(r[1] = *(uint64_t*)0x20000080);
    NONFAILING(r[2] = *(uint64_t*)0x200000c0);
  }
  NONFAILING(memcpy((void*)0x20000100, "./file0\000", 8));
  syscall(__NR_open, /*file=*/0x20000100ul,
          /*flags=O_PATH|O_DIRECTORY|O_DIRECT|O_APPEND*/ 0x214400ul,
          /*mode=S_IROTH|S_IWUSR*/ 0x84ul);
  NONFAILING(memcpy((void*)0x20000140, "./file0\000", 8));
  res = syscall(__NR_open, /*file=*/0x20000140ul, /*flags=*/0ul, /*mode=*/0ul);
  if (res != -1)
    r[3] = res;
  res = syscall(__NR_socket, /*domain=AF_QIPCRTR*/ 0x2aul,
                /*type=SOCK_CLOEXEC|SOCK_NONBLOCK*/ 0x80800ul, /*proto=*/4);
  if (res != -1)
    r[4] = res;
  syscall(__NR_epoll_create1, /*flags=*/0ul);
  syscall(__NR_eventfd2, /*initval=*/-1,
          /*flags=EFD_NONBLOCK|0x100000*/ 0x100800ul);
  syscall(__NR_io_uring_register, /*fd=*/r[0], /*opcode=*/0x12ul, /*arg=*/0ul,
          /*nr_args=*/0ul);
  NONFAILING(*(uint8_t*)0x200001c0 = 0xd);
  NONFAILING(*(uint8_t*)0x200001c1 = 0x10);
  NONFAILING(*(uint16_t*)0x200001c2 = 1);
  NONFAILING(*(uint32_t*)0x200001c4 = r[4]);
  NONFAILING(*(uint64_t*)0x200001c8 = 0x20000200);
  NONFAILING(*(uint32_t*)0x20000200 = 0x80);
  NONFAILING(*(uint64_t*)0x200001d0 = 0x20000240);
  NONFAILING(*(uint32_t*)0x200001d8 = 0);
  NONFAILING(*(uint32_t*)0x200001dc = 0x800);
  NONFAILING(*(uint64_t*)0x200001e0 = 0);
  NONFAILING(*(uint16_t*)0x200001e8 = 0);
  NONFAILING(*(uint16_t*)0x200001ea = 0);
  NONFAILING(memset((void*)0x200001ec, 0, 4));
  NONFAILING(memset((void*)0x200001f0, 0, 16));
  NONFAILING(syz_io_uring_submit(/*ring_ptr=*/r[1], /*sqes_ptr=*/r[2],
                                 /*sqe=*/0x200001c0));
  syscall(__NR_io_uring_enter, /*fd=*/r[0], /*to_submit=*/1, /*min_complete=*/1,
          /*flags=IORING_ENTER_EXT_ARG|IORING_ENTER_GETEVENTS*/ 9ul,
          /*sigmask=*/0ul, /*size=*/0ul);
  NONFAILING(
      syz_io_uring_complete(/*ring_ptr=*/r[1], /*result_fd=*/0x20000380));
  NONFAILING(*(uint8_t*)0x20002900 = 0);
  NONFAILING(*(uint8_t*)0x20002901 = 0);
  NONFAILING(*(uint16_t*)0x20002902 = 0);
  NONFAILING(memset((void*)0x20002904, 0, 12));
  NONFAILING(*(uint8_t*)0x20002910 = 0);
  NONFAILING(*(uint8_t*)0x20002911 = 0);
  NONFAILING(*(uint16_t*)0x20002912 = 0);
  NONFAILING(*(uint32_t*)0x20002914 = 0);
  NONFAILING(*(uint8_t*)0x20002918 = 0);
  NONFAILING(*(uint8_t*)0x20002919 = 0);
  NONFAILING(*(uint16_t*)0x2000291a = 0);
  NONFAILING(*(uint32_t*)0x2000291c = 0);
  NONFAILING(*(uint8_t*)0x20002920 = 0);
  NONFAILING(*(uint8_t*)0x20002921 = 0);
  NONFAILING(*(uint16_t*)0x20002922 = 0);
  NONFAILING(*(uint32_t*)0x20002924 = 0);
  NONFAILING(*(uint8_t*)0x20002928 = 0);
  NONFAILING(*(uint8_t*)0x20002929 = 0);
  NONFAILING(*(uint16_t*)0x2000292a = 0);
  NONFAILING(*(uint32_t*)0x2000292c = 0);
  NONFAILING(*(uint8_t*)0x20002930 = 0);
  NONFAILING(*(uint8_t*)0x20002931 = 0);
  NONFAILING(*(uint16_t*)0x20002932 = 0);
  NONFAILING(*(uint32_t*)0x20002934 = 0);
  NONFAILING(*(uint8_t*)0x20002938 = 0);
  NONFAILING(*(uint8_t*)0x20002939 = 0);
  NONFAILING(*(uint16_t*)0x2000293a = 0);
  NONFAILING(*(uint32_t*)0x2000293c = 0);
  NONFAILING(*(uint8_t*)0x20002940 = 0);
  NONFAILING(*(uint8_t*)0x20002941 = 0);
  NONFAILING(*(uint16_t*)0x20002942 = 0);
  NONFAILING(*(uint32_t*)0x20002944 = 0);
  NONFAILING(*(uint8_t*)0x20002948 = 0);
  NONFAILING(*(uint8_t*)0x20002949 = 0);
  NONFAILING(*(uint16_t*)0x2000294a = 0);
  NONFAILING(*(uint32_t*)0x2000294c = 0);
  NONFAILING(*(uint8_t*)0x20002950 = 0);
  NONFAILING(*(uint8_t*)0x20002951 = 0);
  NONFAILING(*(uint16_t*)0x20002952 = 0);
  NONFAILING(*(uint32_t*)0x20002954 = 0);
  NONFAILING(*(uint8_t*)0x20002958 = 0);
  NONFAILING(*(uint8_t*)0x20002959 = 0);
  NONFAILING(*(uint16_t*)0x2000295a = 0);
  NONFAILING(*(uint32_t*)0x2000295c = 0);
  NONFAILING(*(uint8_t*)0x20002960 = 0);
  NONFAILING(*(uint8_t*)0x20002961 = 0);
  NONFAILING(*(uint16_t*)0x20002962 = 0);
  NONFAILING(*(uint32_t*)0x20002964 = 0);
  NONFAILING(*(uint8_t*)0x20002968 = 0);
  NONFAILING(*(uint8_t*)0x20002969 = 0);
  NONFAILING(*(uint16_t*)0x2000296a = 0);
  NONFAILING(*(uint32_t*)0x2000296c = 0);
  NONFAILING(*(uint8_t*)0x20002970 = 0);
  NONFAILING(*(uint8_t*)0x20002971 = 0);
  NONFAILING(*(uint16_t*)0x20002972 = 0);
  NONFAILING(*(uint32_t*)0x20002974 = 0);
  NONFAILING(*(uint8_t*)0x20002978 = 0);
  NONFAILING(*(uint8_t*)0x20002979 = 0);
  NONFAILING(*(uint16_t*)0x2000297a = 0);
  NONFAILING(*(uint32_t*)0x2000297c = 0);
  NONFAILING(*(uint8_t*)0x20002980 = 0);
  NONFAILING(*(uint8_t*)0x20002981 = 0);
  NONFAILING(*(uint16_t*)0x20002982 = 0);
  NONFAILING(*(uint32_t*)0x20002984 = 0);
  NONFAILING(*(uint8_t*)0x20002988 = 0);
  NONFAILING(*(uint8_t*)0x20002989 = 0);
  NONFAILING(*(uint16_t*)0x2000298a = 0);
  NONFAILING(*(uint32_t*)0x2000298c = 0);
  NONFAILING(*(uint8_t*)0x20002990 = 0);
  NONFAILING(*(uint8_t*)0x20002991 = 0);
  NONFAILING(*(uint16_t*)0x20002992 = 0);
  NONFAILING(*(uint32_t*)0x20002994 = 0);
  NONFAILING(*(uint8_t*)0x20002998 = 0);
  NONFAILING(*(uint8_t*)0x20002999 = 0);
  NONFAILING(*(uint16_t*)0x2000299a = 0);
  NONFAILING(*(uint32_t*)0x2000299c = 0);
  NONFAILING(*(uint8_t*)0x200029a0 = 0);
  NONFAILING(*(uint8_t*)0x200029a1 = 0);
  NONFAILING(*(uint16_t*)0x200029a2 = 0);
  NONFAILING(*(uint32_t*)0x200029a4 = 0);
  NONFAILING(*(uint8_t*)0x200029a8 = 0);
  NONFAILING(*(uint8_t*)0x200029a9 = 0);
  NONFAILING(*(uint16_t*)0x200029aa = 0);
  NONFAILING(*(uint32_t*)0x200029ac = 0);
  NONFAILING(*(uint8_t*)0x200029b0 = 0);
  NONFAILING(*(uint8_t*)0x200029b1 = 0);
  NONFAILING(*(uint16_t*)0x200029b2 = 0);
  NONFAILING(*(uint32_t*)0x200029b4 = 0);
  NONFAILING(*(uint8_t*)0x200029b8 = 0);
  NONFAILING(*(uint8_t*)0x200029b9 = 0);
  NONFAILING(*(uint16_t*)0x200029ba = 0);
  NONFAILING(*(uint32_t*)0x200029bc = 0);
  NONFAILING(*(uint8_t*)0x200029c0 = 0);
  NONFAILING(*(uint8_t*)0x200029c1 = 0);
  NONFAILING(*(uint16_t*)0x200029c2 = 0);
  NONFAILING(*(uint32_t*)0x200029c4 = 0);
  NONFAILING(*(uint8_t*)0x200029c8 = 0);
  NONFAILING(*(uint8_t*)0x200029c9 = 0);
  NONFAILING(*(uint16_t*)0x200029ca = 0);
  NONFAILING(*(uint32_t*)0x200029cc = 0);
  NONFAILING(*(uint8_t*)0x200029d0 = 0);
  NONFAILING(*(uint8_t*)0x200029d1 = 0);
  NONFAILING(*(uint16_t*)0x200029d2 = 0);
  NONFAILING(*(uint32_t*)0x200029d4 = 0);
  NONFAILING(*(uint8_t*)0x200029d8 = 0);
  NONFAILING(*(uint8_t*)0x200029d9 = 0);
  NONFAILING(*(uint16_t*)0x200029da = 0);
  NONFAILING(*(uint32_t*)0x200029dc = 0);
  NONFAILING(*(uint8_t*)0x200029e0 = 0);
  NONFAILING(*(uint8_t*)0x200029e1 = 0);
  NONFAILING(*(uint16_t*)0x200029e2 = 0);
  NONFAILING(*(uint32_t*)0x200029e4 = 0);
  NONFAILING(*(uint8_t*)0x200029e8 = 0);
  NONFAILING(*(uint8_t*)0x200029e9 = 0);
  NONFAILING(*(uint16_t*)0x200029ea = 0);
  NONFAILING(*(uint32_t*)0x200029ec = 0);
  NONFAILING(*(uint8_t*)0x200029f0 = 0);
  NONFAILING(*(uint8_t*)0x200029f1 = 0);
  NONFAILING(*(uint16_t*)0x200029f2 = 0);
  NONFAILING(*(uint32_t*)0x200029f4 = 0);
  NONFAILING(*(uint8_t*)0x200029f8 = 0);
  NONFAILING(*(uint8_t*)0x200029f9 = 0);
  NONFAILING(*(uint16_t*)0x200029fa = 0);
  NONFAILING(*(uint32_t*)0x200029fc = 0);
  NONFAILING(*(uint8_t*)0x20002a00 = 0);
  NONFAILING(*(uint8_t*)0x20002a01 = 0);
  NONFAILING(*(uint16_t*)0x20002a02 = 0);
  NONFAILING(*(uint32_t*)0x20002a04 = 0);
  NONFAILING(*(uint8_t*)0x20002a08 = 0);
  NONFAILING(*(uint8_t*)0x20002a09 = 0);
  NONFAILING(*(uint16_t*)0x20002a0a = 0);
  NONFAILING(*(uint32_t*)0x20002a0c = 0);
  NONFAILING(*(uint8_t*)0x20002a10 = 0);
  NONFAILING(*(uint8_t*)0x20002a11 = 0);
  NONFAILING(*(uint16_t*)0x20002a12 = 0);
  NONFAILING(*(uint32_t*)0x20002a14 = 0);
  NONFAILING(*(uint8_t*)0x20002a18 = 0);
  NONFAILING(*(uint8_t*)0x20002a19 = 0);
  NONFAILING(*(uint16_t*)0x20002a1a = 0);
  NONFAILING(*(uint32_t*)0x20002a1c = 0);
  NONFAILING(*(uint8_t*)0x20002a20 = 0);
  NONFAILING(*(uint8_t*)0x20002a21 = 0);
  NONFAILING(*(uint16_t*)0x20002a22 = 0);
  NONFAILING(*(uint32_t*)0x20002a24 = 0);
  NONFAILING(*(uint8_t*)0x20002a28 = 0);
  NONFAILING(*(uint8_t*)0x20002a29 = 0);
  NONFAILING(*(uint16_t*)0x20002a2a = 0);
  NONFAILING(*(uint32_t*)0x20002a2c = 0);
  NONFAILING(*(uint8_t*)0x20002a30 = 0);
  NONFAILING(*(uint8_t*)0x20002a31 = 0);
  NONFAILING(*(uint16_t*)0x20002a32 = 0);
  NONFAILING(*(uint32_t*)0x20002a34 = 0);
  NONFAILING(*(uint8_t*)0x20002a38 = 0);
  NONFAILING(*(uint8_t*)0x20002a39 = 0);
  NONFAILING(*(uint16_t*)0x20002a3a = 0);
  NONFAILING(*(uint32_t*)0x20002a3c = 0);
  NONFAILING(*(uint8_t*)0x20002a40 = 0);
  NONFAILING(*(uint8_t*)0x20002a41 = 0);
  NONFAILING(*(uint16_t*)0x20002a42 = 0);
  NONFAILING(*(uint32_t*)0x20002a44 = 0);
  NONFAILING(*(uint8_t*)0x20002a48 = 0);
  NONFAILING(*(uint8_t*)0x20002a49 = 0);
  NONFAILING(*(uint16_t*)0x20002a4a = 0);
  NONFAILING(*(uint32_t*)0x20002a4c = 0);
  NONFAILING(*(uint8_t*)0x20002a50 = 0);
  NONFAILING(*(uint8_t*)0x20002a51 = 0);
  NONFAILING(*(uint16_t*)0x20002a52 = 0);
  NONFAILING(*(uint32_t*)0x20002a54 = 0);
  NONFAILING(*(uint8_t*)0x20002a58 = 0);
  NONFAILING(*(uint8_t*)0x20002a59 = 0);
  NONFAILING(*(uint16_t*)0x20002a5a = 0);
  NONFAILING(*(uint32_t*)0x20002a5c = 0);
  NONFAILING(*(uint8_t*)0x20002a60 = 0);
  NONFAILING(*(uint8_t*)0x20002a61 = 0);
  NONFAILING(*(uint16_t*)0x20002a62 = 0);
  NONFAILING(*(uint32_t*)0x20002a64 = 0);
  NONFAILING(*(uint8_t*)0x20002a68 = 0);
  NONFAILING(*(uint8_t*)0x20002a69 = 0);
  NONFAILING(*(uint16_t*)0x20002a6a = 0);
  NONFAILING(*(uint32_t*)0x20002a6c = 0);
  NONFAILING(*(uint8_t*)0x20002a70 = 0);
  NONFAILING(*(uint8_t*)0x20002a71 = 0);
  NONFAILING(*(uint16_t*)0x20002a72 = 0);
  NONFAILING(*(uint32_t*)0x20002a74 = 0);
  NONFAILING(*(uint8_t*)0x20002a78 = 0);
  NONFAILING(*(uint8_t*)0x20002a79 = 0);
  NONFAILING(*(uint16_t*)0x20002a7a = 0);
  NONFAILING(*(uint32_t*)0x20002a7c = 0);
  syscall(__NR_io_uring_register, /*fd=*/r[0], /*opcode=*/8ul,
          /*arg=*/0x20002900ul, /*nr_args=*/0x2eul);
  syscall(__NR_clock_gettime, /*id=*/0ul, /*tp=*/0ul);
  NONFAILING(
      syz_io_uring_submit(/*ring_ptr=*/r[1], /*sqes_ptr=*/r[2], /*sqe=*/0));
  NONFAILING(*(uint8_t*)0x20001680 = 0x26);
  NONFAILING(*(uint8_t*)0x20001681 = 0x22);
  NONFAILING(*(uint16_t*)0x20001682 = 0);
  NONFAILING(*(uint32_t*)0x20001684 = r[3]);
  NONFAILING(*(uint64_t*)0x20001688 = 0x20000180);
  NONFAILING(memcpy((void*)0x20000180, "./file0\000", 8));
  NONFAILING(*(uint64_t*)0x20001690 = 0x20000380);
  NONFAILING(memcpy((void*)0x20000380, "./file0\000", 8));
  NONFAILING(*(uint32_t*)0x20001698 = 0);
  NONFAILING(*(uint32_t*)0x2000169c = 0);
  NONFAILING(*(uint64_t*)0x200016a0 = 0);
  NONFAILING(*(uint16_t*)0x200016a8 = 0);
  NONFAILING(*(uint16_t*)0x200016aa = 0);
  NONFAILING(memset((void*)0x200016ac, 0, 4));
  NONFAILING(memset((void*)0x200016b0, 0, 16));
  NONFAILING(syz_io_uring_submit(/*ring_ptr=*/r[1], /*sqes_ptr=*/r[2],
                                 /*sqe=*/0x20001680));
  NONFAILING(*(uint8_t*)0x20002a80 = 0xe);
  NONFAILING(*(uint8_t*)0x20002a81 = 0);
  NONFAILING(*(uint16_t*)0x20002a82 = 0);
  NONFAILING(*(uint32_t*)0x20002a84 = 0);
  NONFAILING(*(uint64_t*)0x20002a88 = 0);
  NONFAILING(*(uint64_t*)0x20002a90 = 0);
  NONFAILING(*(uint32_t*)0x20002a98 = 0);
  NONFAILING(*(uint32_t*)0x20002a9c = 4);
  NONFAILING(*(uint64_t*)0x20002aa0 = 1);
  NONFAILING(*(uint16_t*)0x20002aa8 = 0);
  NONFAILING(*(uint16_t*)0x20002aaa = 0);
  NONFAILING(memset((void*)0x20002aac, 0, 4));
  NONFAILING(memset((void*)0x20002ab0, 0, 16));
  NONFAILING(syz_io_uring_submit(/*ring_ptr=*/r[1], /*sqes_ptr=*/r[2],
                                 /*sqe=*/0x20002a80));
  NONFAILING(*(uint8_t*)0x20002ac0 = 0xe);
  NONFAILING(*(uint8_t*)0x20002ac1 = 0);
  NONFAILING(*(uint16_t*)0x20002ac2 = 0);
  NONFAILING(*(uint32_t*)0x20002ac4 = 0);
  NONFAILING(*(uint64_t*)0x20002ac8 = 0);
  NONFAILING(*(uint64_t*)0x20002ad0 = 0);
  NONFAILING(*(uint32_t*)0x20002ad8 = 0);
  NONFAILING(*(uint32_t*)0x20002adc = 0x10);
  NONFAILING(*(uint64_t*)0x20002ae0 = 1);
  NONFAILING(*(uint16_t*)0x20002ae8 = 0);
  NONFAILING(*(uint16_t*)0x20002aea = 0);
  NONFAILING(memset((void*)0x20002aec, 0, 4));
  NONFAILING(memset((void*)0x20002af0, 0, 16));
  NONFAILING(syz_io_uring_submit(/*ring_ptr=*/r[1], /*sqes_ptr=*/r[2],
                                 /*sqe=*/0x20002ac0));
  syscall(__NR_io_uring_enter, /*fd=*/r[0], /*to_submit=*/4, /*min_complete=*/4,
          /*flags=IORING_ENTER_SQ_WAIT|IORING_ENTER_GETEVENTS*/ 5ul,
          /*sigmask=*/0ul, /*size=*/0ul);
  NONFAILING(syz_io_uring_complete(/*ring_ptr=*/r[1], /*result_fd=*/0));
}
int main(void)
{
  syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul,
          /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  install_segv_handler();
  loop();
  return 0;
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [io-uring] WARNING in io_issue_sqe
  2024-06-12 14:29 [io-uring] WARNING in io_issue_sqe chase xd
@ 2024-06-12 15:41 ` Pavel Begunkov
  2024-06-12 15:46   ` chase xd
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Begunkov @ 2024-06-12 15:41 UTC (permalink / raw)
  To: chase xd, Jens Axboe, io-uring, linux-kernel

On 6/12/24 15:29, chase xd wrote:
> Hi,
> 
> Syzkaller hits a new bug in branch 6.10.0-rc1-00004-gff802a9f35cf-dirty #7.
> Note: this is also not a reliable repro, might need to try more times

Do you have a syz repro? It's easier to understand what it's doing,
which request types are used and such.


> 
> ```
> 
> [  153.857557][T21250] apt-get (21250) used greatest stack depth:
> 22240 bytes left
> [  249.711259][T57846] ------------[ cut here ]------------
> [  249.711626][T57846] WARNING: CPU: 1 PID: 57846 at
> io_uring/refs.h:38 io_issue_sqe+0x10dc/0x1720
> [  249.712188][T57846] Modules linked in:
> [  249.712431][T57846] CPU: 1 PID: 57846 Comm: iou-wrk-57845 Not
> tainted 6.10.0-rc1-00004-gff802a9f35cf-dirty #7
> [  249.713020][T57846] Hardware name: QEMU Standard PC (i440FX + PIIX,
> 1996), BIOS 1.15.0-1 04/01/2014
> [  249.713566][T57846] RIP: 0010:io_issue_sqe+0x10dc/0x1720
> [  249.713894][T57846] Code: fc ff df 4c 89 e2 48 c1 ea 03 80 3c 02 00
> 0f 85 c6 05 00 00 49 89 1c 24 49f
> [  249.715023][T57846] RSP: 0018:ffffc9000e84fc00 EFLAGS: 00010293
> [  249.715389][T57846] RAX: 0000000000000000 RBX: 0000000000000000
> RCX: ffffffff84139c3c
> [  249.715855][T57846] RDX: ffff88801eaad640 RSI: ffffffff8413a70b
> RDI: 0000000000000007
> [  249.716300][T57846] RBP: ffffc9000e84fc80 R08: 0000000000000007
> R09: 0000000000000000
> [  249.716676][T57846] R10: 0000000000000000 R11: 0000000000000000
> R12: ffff8880001c3a00
> [  249.717042][T57846] R13: 0000000000000000 R14: ffff888010600040
> R15: ffff8880001c3a48
> [  249.717428][T57846] FS:  00007f58ce931800(0000)
> GS:ffff88807ec00000(0000) knlGS:0000000000000000
> [  249.717837][T57846] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [  249.718135][T57846] CR2: 00007f58ce932128 CR3: 000000001b08a000
> CR4: 00000000000006f0
> [  249.718497][T57846] Call Trace:
> [  249.718668][T57846]  <TASK>
> [  249.718810][T57846]  ? __warn+0xc7/0x2f0
> [  249.719003][T57846]  ? io_issue_sqe+0x10dc/0x1720
> [  249.719233][T57846]  ? report_bug+0x347/0x410
> [  249.719451][T57846]  ? handle_bug+0x3d/0x80
> [  249.719654][T57846]  ? exc_invalid_op+0x18/0x50
> [  249.719872][T57846]  ? asm_exc_invalid_op+0x1a/0x20
> [  249.720127][T57846]  ? io_issue_sqe+0x60c/0x1720
> [  249.720420][T57846]  ? io_issue_sqe+0x10db/0x1720
> [  249.720711][T57846]  ? io_issue_sqe+0x10dc/0x1720
> [  249.721012][T57846]  ? __fget_files+0x1bc/0x3d0
> [  249.722194][T57846]  ? io_wq_submit_work+0x264/0xcb0
> [  249.722521][T57846]  io_wq_submit_work+0x264/0xcb0
> [  249.722826][T57846]  io_worker_handle_work+0x97e/0x1790
> [  249.723159][T57846]  io_wq_worker+0x38e/0xe50
> [  249.723435][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> [  249.723687][T57846]  ? ret_from_fork+0x16/0x70
> [  249.723907][T57846]  ? __pfx_lock_release+0x10/0x10
> [  249.724139][T57846]  ? do_raw_spin_lock+0x12c/0x2b0
> [  249.724392][T57846]  ? __pfx_do_raw_spin_lock+0x10/0x10
> [  249.724706][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> [  249.725015][T57846]  ret_from_fork+0x2f/0x70
> [  249.725300][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> [  249.725603][T57846]  ret_from_fork_asm+0x1a/0x30
> [  249.725897][T57846]  </TASK>
> [  249.726083][T57846] Kernel panic - not syncing: kernel: panic_on_warn set ...
> [  249.726521][T57846] CPU: 1 PID: 57846 Comm: iou-wrk-57845 Not
> tainted 6.10.0-rc1-00004-gff802a9f35cf-dirty #7
> [  249.727110][T57846] Hardware name: QEMU Standard PC (i440FX + PIIX,
> 1996), BIOS 1.15.0-1 04/01/2014
> [  249.727647][T57846] Call Trace:
> [  249.727842][T57846]  <TASK>
> [  249.728018][T57846]  panic+0x4fa/0x5a0
> [  249.728252][T57846]  ? __pfx_panic+0x10/0x10
> [  249.728516][T57846]  ? show_trace_log_lvl+0x284/0x390
> [  249.728832][T57846]  ? io_issue_sqe+0x10dc/0x1720
> [  249.729120][T57846]  check_panic_on_warn+0x61/0x80
> [  249.729416][T57846]  __warn+0xd3/0x2f0
> [  249.729650][T57846]  ? io_issue_sqe+0x10dc/0x1720
> [  249.729941][T57846]  report_bug+0x347/0x410
> [  249.730206][T57846]  handle_bug+0x3d/0x80
> [  249.730460][T57846]  exc_invalid_op+0x18/0x50
> [  249.730730][T57846]  asm_exc_invalid_op+0x1a/0x20
> [  249.731031][T57846] RIP: 0010:io_issue_sqe+0x10dc/0x1720
> [  249.731365][T57846] Code: fc ff df 4c 89 e2 48 c1 ea 03 80 3c 02 00
> 0f 85 c6 05 00 00 49 89 1c 24 49f
> [  249.732508][T57846] RSP: 0018:ffffc9000e84fc00 EFLAGS: 00010293
> [  249.732873][T57846] RAX: 0000000000000000 RBX: 0000000000000000
> RCX: ffffffff84139c3c
> [  249.733351][T57846] RDX: ffff88801eaad640 RSI: ffffffff8413a70b
> RDI: 0000000000000007
> [  249.733822][T57846] RBP: ffffc9000e84fc80 R08: 0000000000000007
> R09: 0000000000000000
> [  249.734285][T57846] R10: 0000000000000000 R11: 0000000000000000
> R12: ffff8880001c3a00
> [  249.734757][T57846] R13: 0000000000000000 R14: ffff888010600040
> R15: ffff8880001c3a48
> [  249.735236][T57846]  ? io_issue_sqe+0x60c/0x1720
> [  249.735529][T57846]  ? io_issue_sqe+0x10db/0x1720
> [  249.735825][T57846]  ? __fget_files+0x1bc/0x3d0
> [  249.736116][T57846]  ? io_wq_submit_work+0x264/0xcb0
> [  249.736428][T57846]  io_wq_submit_work+0x264/0xcb0
> [  249.736731][T57846]  io_worker_handle_work+0x97e/0x1790
> [  249.737061][T57846]  io_wq_worker+0x38e/0xe50
> [  249.737353][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> [  249.737646][T57846]  ? ret_from_fork+0x16/0x70
> [  249.737861][T57846]  ? __pfx_lock_release+0x10/0x10
> [  249.738091][T57846]  ? do_raw_spin_lock+0x12c/0x2b0
> [  249.738398][T57846]  ? __pfx_do_raw_spin_lock+0x10/0x10
> [  249.738729][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> [  249.739033][T57846]  ret_from_fork+0x2f/0x70
> [  249.739308][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> [  249.739617][T57846]  ret_from_fork_asm+0x1a/0x30
> [  249.739913][T57846]  </TASK>
> [  249.740236][T57846] Kernel Offset: disabled
> [  249.740518][T57846] Rebooting in 86400 seconds..
> 
> ```
> 
> crepro is in attachments.
> 
> Regards

-- 
Pavel Begunkov

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [io-uring] WARNING in io_issue_sqe
  2024-06-12 15:41 ` Pavel Begunkov
@ 2024-06-12 15:46   ` chase xd
  0 siblings, 0 replies; 3+ messages in thread
From: chase xd @ 2024-06-12 15:46 UTC (permalink / raw)
  To: Pavel Begunkov, Jens Axboe, io-uring, linux-kernel

here you go

```
# {Threaded:false Repeat:true RepeatTimes:0 Procs:1 Slowdown:1
Sandbox: SandboxArg:0 Leak:false NetInjection:false NetDevices:false
NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false
KCSAN:false DevlinkPCI:false NicVF:false USB:false VhciInjection:false
Wifi:false IEEE802154:false Sysctl:false Swap:false UseTmpDir:false
HandleSegv:true Repro:false Trace:false LegacyOptions:{Collide:false
Fault:false FaultCall:0 FaultNth:0}}
r0 = syz_io_uring_setup(0x4d84, &(0x7f0000000000)={0x0, 0x649b, 0x80,
0x0, 0x4315}, &(0x7f0000000080)=<r1=>0x0, &(0x7f00000000c0)=<r2=>0x0)
open(&(0x7f0000000100)='./file0\x00', 0x214400, 0x84)
r3 = open$dir(&(0x7f0000000140)='./file0\x00', 0x0, 0x0)
r4 = socket(0x2a, 0x80800, 0x4)
epoll_create1(0x0)
eventfd2(0xffffffff, 0x100800)
io_uring_register$IORING_UNREGISTER_IOWQ_AFF(r0, 0x12, 0x0, 0x0)
syz_io_uring_submit(r1, r2, &(0x7f00000001c0)=@IORING_OP_ACCEPT={0xd,
0x10, 0x1, @sock=r4, &(0x7f0000000200)=0x80,
&(0x7f0000000240)=@tipc=@name, 0x0, 0x800})
io_uring_enter(r0, 0x1, 0x1, 0x9, 0x0, 0x0)
syz_io_uring_complete(r1, &(0x7f0000000380))
io_uring_register$IORING_REGISTER_PROBE(r0, 0x8,
&(0x7f0000002900)={0x0, 0x0, 0x0, '\x00', [{}, {}, {}, {}, {}, {}, {},
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
{}, {}, {}, {}, {}]}, 0x2e)
clock_gettime(0x0, 0x0)
syz_io_uring_submit(r1, r2, 0x0)
syz_io_uring_submit(r1, r2,
&(0x7f0000001680)=@IORING_OP_SYMLINKAT={0x26, 0x22, 0x0, @fd_dir=r3,
&(0x7f0000000180)='./file0\x00', &(0x7f0000000380)='./file0\x00'})
syz_io_uring_submit(r1, r2,
&(0x7f0000002a80)=@IORING_OP_ASYNC_CANCEL={0xe, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x4, 0x1})
syz_io_uring_submit(r1, r2,
&(0x7f0000002ac0)=@IORING_OP_ASYNC_CANCEL={0xe, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x10, 0x1})
io_uring_enter(r0, 0x4, 0x4, 0x5, 0x0, 0x0)
syz_io_uring_complete(r1, 0x0)
```


On Wed, Jun 12, 2024 at 5:41 PM Pavel Begunkov <[email protected]> wrote:
>
> On 6/12/24 15:29, chase xd wrote:
> > Hi,
> >
> > Syzkaller hits a new bug in branch 6.10.0-rc1-00004-gff802a9f35cf-dirty #7.
> > Note: this is also not a reliable repro, might need to try more times
>
> Do you have a syz repro? It's easier to understand what it's doing,
> which request types are used and such.
>
>
> >
> > ```
> >
> > [  153.857557][T21250] apt-get (21250) used greatest stack depth:
> > 22240 bytes left
> > [  249.711259][T57846] ------------[ cut here ]------------
> > [  249.711626][T57846] WARNING: CPU: 1 PID: 57846 at
> > io_uring/refs.h:38 io_issue_sqe+0x10dc/0x1720
> > [  249.712188][T57846] Modules linked in:
> > [  249.712431][T57846] CPU: 1 PID: 57846 Comm: iou-wrk-57845 Not
> > tainted 6.10.0-rc1-00004-gff802a9f35cf-dirty #7
> > [  249.713020][T57846] Hardware name: QEMU Standard PC (i440FX + PIIX,
> > 1996), BIOS 1.15.0-1 04/01/2014
> > [  249.713566][T57846] RIP: 0010:io_issue_sqe+0x10dc/0x1720
> > [  249.713894][T57846] Code: fc ff df 4c 89 e2 48 c1 ea 03 80 3c 02 00
> > 0f 85 c6 05 00 00 49 89 1c 24 49f
> > [  249.715023][T57846] RSP: 0018:ffffc9000e84fc00 EFLAGS: 00010293
> > [  249.715389][T57846] RAX: 0000000000000000 RBX: 0000000000000000
> > RCX: ffffffff84139c3c
> > [  249.715855][T57846] RDX: ffff88801eaad640 RSI: ffffffff8413a70b
> > RDI: 0000000000000007
> > [  249.716300][T57846] RBP: ffffc9000e84fc80 R08: 0000000000000007
> > R09: 0000000000000000
> > [  249.716676][T57846] R10: 0000000000000000 R11: 0000000000000000
> > R12: ffff8880001c3a00
> > [  249.717042][T57846] R13: 0000000000000000 R14: ffff888010600040
> > R15: ffff8880001c3a48
> > [  249.717428][T57846] FS:  00007f58ce931800(0000)
> > GS:ffff88807ec00000(0000) knlGS:0000000000000000
> > [  249.717837][T57846] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> > [  249.718135][T57846] CR2: 00007f58ce932128 CR3: 000000001b08a000
> > CR4: 00000000000006f0
> > [  249.718497][T57846] Call Trace:
> > [  249.718668][T57846]  <TASK>
> > [  249.718810][T57846]  ? __warn+0xc7/0x2f0
> > [  249.719003][T57846]  ? io_issue_sqe+0x10dc/0x1720
> > [  249.719233][T57846]  ? report_bug+0x347/0x410
> > [  249.719451][T57846]  ? handle_bug+0x3d/0x80
> > [  249.719654][T57846]  ? exc_invalid_op+0x18/0x50
> > [  249.719872][T57846]  ? asm_exc_invalid_op+0x1a/0x20
> > [  249.720127][T57846]  ? io_issue_sqe+0x60c/0x1720
> > [  249.720420][T57846]  ? io_issue_sqe+0x10db/0x1720
> > [  249.720711][T57846]  ? io_issue_sqe+0x10dc/0x1720
> > [  249.721012][T57846]  ? __fget_files+0x1bc/0x3d0
> > [  249.722194][T57846]  ? io_wq_submit_work+0x264/0xcb0
> > [  249.722521][T57846]  io_wq_submit_work+0x264/0xcb0
> > [  249.722826][T57846]  io_worker_handle_work+0x97e/0x1790
> > [  249.723159][T57846]  io_wq_worker+0x38e/0xe50
> > [  249.723435][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> > [  249.723687][T57846]  ? ret_from_fork+0x16/0x70
> > [  249.723907][T57846]  ? __pfx_lock_release+0x10/0x10
> > [  249.724139][T57846]  ? do_raw_spin_lock+0x12c/0x2b0
> > [  249.724392][T57846]  ? __pfx_do_raw_spin_lock+0x10/0x10
> > [  249.724706][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> > [  249.725015][T57846]  ret_from_fork+0x2f/0x70
> > [  249.725300][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> > [  249.725603][T57846]  ret_from_fork_asm+0x1a/0x30
> > [  249.725897][T57846]  </TASK>
> > [  249.726083][T57846] Kernel panic - not syncing: kernel: panic_on_warn set ...
> > [  249.726521][T57846] CPU: 1 PID: 57846 Comm: iou-wrk-57845 Not
> > tainted 6.10.0-rc1-00004-gff802a9f35cf-dirty #7
> > [  249.727110][T57846] Hardware name: QEMU Standard PC (i440FX + PIIX,
> > 1996), BIOS 1.15.0-1 04/01/2014
> > [  249.727647][T57846] Call Trace:
> > [  249.727842][T57846]  <TASK>
> > [  249.728018][T57846]  panic+0x4fa/0x5a0
> > [  249.728252][T57846]  ? __pfx_panic+0x10/0x10
> > [  249.728516][T57846]  ? show_trace_log_lvl+0x284/0x390
> > [  249.728832][T57846]  ? io_issue_sqe+0x10dc/0x1720
> > [  249.729120][T57846]  check_panic_on_warn+0x61/0x80
> > [  249.729416][T57846]  __warn+0xd3/0x2f0
> > [  249.729650][T57846]  ? io_issue_sqe+0x10dc/0x1720
> > [  249.729941][T57846]  report_bug+0x347/0x410
> > [  249.730206][T57846]  handle_bug+0x3d/0x80
> > [  249.730460][T57846]  exc_invalid_op+0x18/0x50
> > [  249.730730][T57846]  asm_exc_invalid_op+0x1a/0x20
> > [  249.731031][T57846] RIP: 0010:io_issue_sqe+0x10dc/0x1720
> > [  249.731365][T57846] Code: fc ff df 4c 89 e2 48 c1 ea 03 80 3c 02 00
> > 0f 85 c6 05 00 00 49 89 1c 24 49f
> > [  249.732508][T57846] RSP: 0018:ffffc9000e84fc00 EFLAGS: 00010293
> > [  249.732873][T57846] RAX: 0000000000000000 RBX: 0000000000000000
> > RCX: ffffffff84139c3c
> > [  249.733351][T57846] RDX: ffff88801eaad640 RSI: ffffffff8413a70b
> > RDI: 0000000000000007
> > [  249.733822][T57846] RBP: ffffc9000e84fc80 R08: 0000000000000007
> > R09: 0000000000000000
> > [  249.734285][T57846] R10: 0000000000000000 R11: 0000000000000000
> > R12: ffff8880001c3a00
> > [  249.734757][T57846] R13: 0000000000000000 R14: ffff888010600040
> > R15: ffff8880001c3a48
> > [  249.735236][T57846]  ? io_issue_sqe+0x60c/0x1720
> > [  249.735529][T57846]  ? io_issue_sqe+0x10db/0x1720
> > [  249.735825][T57846]  ? __fget_files+0x1bc/0x3d0
> > [  249.736116][T57846]  ? io_wq_submit_work+0x264/0xcb0
> > [  249.736428][T57846]  io_wq_submit_work+0x264/0xcb0
> > [  249.736731][T57846]  io_worker_handle_work+0x97e/0x1790
> > [  249.737061][T57846]  io_wq_worker+0x38e/0xe50
> > [  249.737353][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> > [  249.737646][T57846]  ? ret_from_fork+0x16/0x70
> > [  249.737861][T57846]  ? __pfx_lock_release+0x10/0x10
> > [  249.738091][T57846]  ? do_raw_spin_lock+0x12c/0x2b0
> > [  249.738398][T57846]  ? __pfx_do_raw_spin_lock+0x10/0x10
> > [  249.738729][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> > [  249.739033][T57846]  ret_from_fork+0x2f/0x70
> > [  249.739308][T57846]  ? __pfx_io_wq_worker+0x10/0x10
> > [  249.739617][T57846]  ret_from_fork_asm+0x1a/0x30
> > [  249.739913][T57846]  </TASK>
> > [  249.740236][T57846] Kernel Offset: disabled
> > [  249.740518][T57846] Rebooting in 86400 seconds..
> >
> > ```
> >
> > crepro is in attachments.
> >
> > Regards
>
> --
> Pavel Begunkov

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-12 15:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-12 14:29 [io-uring] WARNING in io_issue_sqe chase xd
2024-06-12 15:41 ` Pavel Begunkov
2024-06-12 15:46   ` chase xd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox