On Mon, Mar 1, 2021 at 8:10 AM Lukas Bulwahn <lukas.bulwahn@xxxxxxxxx> wrote: > > Hi, > > On Mon, Mar 1, 2021 at 7:58 AM <xiaofeng08519@xxxxxxxx> wrote: > > > > This is the first time for me to report something, so maybe the format is not right. Please correct me if I'm wrong. Thank you ~ > > When using Syzkaller to fuzz Linux kernel 5.11.0, it reported one null-ptr-def bug in file.c. The information is as follows: > > > > The kernel's commit: c03c21ba6 > > The syzkaller commit: 52e3731913ab2677be27c29ed8142b04e8f28521 > > > > This looks like a valid kernel issue found with syzkaller. > > Given that it is reproducible, I suggest you continue with the following steps: > > 1. Check if it reproduces on v5.12-rc1. If not, there is already a fix > in v5.12-rc1. Try to identify the specific fix by bisection. > > 2. Check since when this issue occurs, e.g., does it appear on v5.10, v5.9 etc. > > 3. Bisect it to a specific commit. > > 4. Report back the results of your bisections. Hi, For syzkaller bugs it's also a good idea to check if it was already reported by syzbot or not. This one seems to be already reported: https://syzkaller.appspot.com/bug?id=e9579dc4fc313abec952e5811bf48a26fb8d74b4 https://lore.kernel.org/lkml/000000000000ff83de05bc628d3c@xxxxxxxxxx/ > > The report: > > Syzkaller hit 'KASAN: null-ptr-deref Read in __fget_light' bug. > > > > ================================================================== > > audit: type=1400 audit(1614571961.594:8): avc: denied { execmem } for pid=294 comm="syz-executor894" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=1 > > BUG: KASAN: null-ptr-deref in instrument_atomic_read include/linux/instrumented.h:71 [inline] > > BUG: KASAN: null-ptr-deref in atomic_read include/asm-generic/atomic-instrumented.h:27 [inline] > > BUG: KASAN: null-ptr-deref in __fget_light+0x4f/0x250 fs/file.c:930 > > Read of size 4 at addr 0000000000000000 by task io_wqe_worker-0/296 > > > > CPU: 1 PID: 296 Comm: io_wqe_worker-0 Not tainted 5.11.0+ #5 > > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 > > Call Trace: > > __dump_stack lib/dump_stack.c:79 [inline] > > dump_stack+0xaf/0xf2 lib/dump_stack.c:120 > > __kasan_report mm/kasan/report.c:400 [inline] > > kasan_report.cold.9+0x10c/0x10e mm/kasan/report.c:413 > > check_memory_region_inline mm/kasan/generic.c:179 [inline] > > check_memory_region+0x198/0x200 mm/kasan/generic.c:185 > > instrument_atomic_read include/linux/instrumented.h:71 [inline] > > atomic_read include/asm-generic/atomic-instrumented.h:27 [inline] > > __fget_light+0x4f/0x250 fs/file.c:930 > > fdget_raw include/linux/file.h:70 [inline] > > path_init+0x940/0x1290 fs/namei.c:2354 > > path_lookupat.isra.65+0x2c/0x4e0 fs/namei.c:2410 > > filename_lookup.part.80+0x17a/0x370 fs/namei.c:2453 > > filename_lookup fs/namei.c:2446 [inline] > > user_path_at_empty+0x4b/0x80 fs/namei.c:2733 > > user_path_at include/linux/namei.h:60 [inline] > > vfs_statx+0x108/0x310 fs/stat.c:195 > > do_statx+0xa9/0x120 fs/stat.c:590 > > io_statx fs/io_uring.c:4525 [inline] > > io_issue_sqe+0x1c31/0x4a50 fs/io_uring.c:6343 > > io_wq_submit_work+0x2f7/0x8e0 fs/io_uring.c:6418 > > io_worker_handle_work+0xcdd/0x1900 fs/io-wq.c:561 > > io_wqe_worker+0xa15/0xeb0 fs/io-wq.c:603 > > kthread+0x32a/0x3f0 kernel/kthread.c:292 > > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 > > ================================================================== > > > > > > Syzkaller reproducer: > > # {Threaded:false Collide:false Repeat:false RepeatTimes:0 Procs:1 Slowdown:1 Sandbox: Fault:false FaultCall:-1 FaultNth:0 Leak:false NetInjection:false NetDevices:false NetReset:false Cgroups:false BinfmtMisc:false CloseFDs:false KCSAN:false DevlinkPCI:false USB:false VhciInjection:false Wifi:false Sysctl:false UseTmpDir:false HandleSegv:false Repro:false Trace:false} > > r0 = syz_io_uring_setup(0x1, &(0x7f0000000080)={0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, &(0x7f00000a0000)=nil, &(0x7f00000b0000)=nil, &(0x7f0000000100)=<r1=>0x0, &(0x7f0000000140)=<r2=>0x0) > > syz_io_uring_submit(r1, r2, &(0x7f00000008c0)=@IORING_OP_STATX={0x15, 0x0, 0x0, 0xffffffffffffffff, 0x0, &(0x7f00000003c0)='./file1\x00', 0x20, 0x1000}, 0x3) > > io_uring_enter(r0, 0x1, 0x1, 0x1, 0x0, 0x0) > > > > > > C reproducer: > > // autogenerated by syzkaller (https://github.com/google/syzkaller) > > > > #define _GNU_SOURCE > > > > #include <endian.h> > > #include <stdint.h> > > #include <stdio.h> > > #include <stdlib.h> > > #include <string.h> > > #include <sys/mman.h> > > #include <sys/syscall.h> > > #include <sys/types.h> > > #include <unistd.h> > > > > #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 > > > > 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 sys_io_uring_setup 425 > > static long syz_io_uring_setup(volatile long a0, volatile long a1, volatile long a2, volatile long a3, volatile long a4, volatile long a5) > > { > > uint32_t entries = (uint32_t)a0; > > struct io_uring_params* setup_params = (struct io_uring_params*)a1; > > void* vma1 = (void*)a2; > > void* vma2 = (void*)a3; > > void** ring_ptr_out = (void**)a4; > > void** sqes_ptr_out = (void**)a5; > > uint32_t fd_io_uring = syscall(sys_io_uring_setup, entries, setup_params); > > 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; > > uint32_t ring_sz = sq_ring_sz > cq_ring_sz ? sq_ring_sz : cq_ring_sz; > > *ring_ptr_out = mmap(vma1, ring_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE | MAP_FIXED, fd_io_uring, IORING_OFF_SQ_RING); > > uint32_t sqes_sz = setup_params->sq_entries * SIZEOF_IO_URING_SQE; > > *sqes_ptr_out = mmap(vma2, sqes_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE | MAP_FIXED, 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, volatile long a3) > > { > > char* ring_ptr = (char*)a0; > > char* sqes_ptr = (char*)a1; > > char* sqe = (char*)a2; > > uint32_t sqes_index = (uint32_t)a3; > > uint32_t sq_ring_entries = *(uint32_t*)(ring_ptr + SQ_RING_ENTRIES_OFFSET); > > uint32_t cq_ring_entries = *(uint32_t*)(ring_ptr + CQ_RING_ENTRIES_OFFSET); > > uint32_t sq_array_off = (CQ_CQES_OFFSET + cq_ring_entries * SIZEOF_IO_URING_CQE + 63) & ~63; > > if (sq_ring_entries) > > sqes_index %= sq_ring_entries; > > char* sqe_dest = sqes_ptr + sqes_index * SIZEOF_IO_URING_SQE; > > memcpy(sqe_dest, sqe, SIZEOF_IO_URING_SQE); > > uint32_t sq_ring_mask = *(uint32_t*)(ring_ptr + SQ_RING_MASK_OFFSET); > > uint32_t* sq_tail_ptr = (uint32_t*)(ring_ptr + SQ_TAIL_OFFSET); > > uint32_t sq_tail = *sq_tail_ptr & sq_ring_mask; > > uint32_t sq_tail_next = *sq_tail_ptr + 1; > > uint32_t* sq_array = (uint32_t*)(ring_ptr + sq_array_off); > > *(sq_array + sq_tail) = sqes_index; > > __atomic_store_n(sq_tail_ptr, sq_tail_next, __ATOMIC_RELEASE); > > return 0; > > } > > > > #ifndef __NR_io_uring_enter > > #define __NR_io_uring_enter 426 > > #endif > > > > uint64_t r[3] = {0xffffffffffffffff, 0x0, 0x0}; > > > > int main(void) > > { > > syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); > > syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); > > syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); > > intptr_t res = 0; > > *(uint32_t*)0x20000084 = 0; > > *(uint32_t*)0x20000088 = 0; > > *(uint32_t*)0x2000008c = 0; > > *(uint32_t*)0x20000090 = 0; > > *(uint32_t*)0x20000098 = 0; > > *(uint32_t*)0x2000009c = 0; > > *(uint32_t*)0x200000a0 = 0; > > *(uint32_t*)0x200000a4 = 0; > > res = -1; > > res = syz_io_uring_setup(1, 0x20000080, 0x200a0000, 0x200b0000, 0x20000100, 0x20000140); > > if (res != -1) { > > r[0] = res; > > r[1] = *(uint64_t*)0x20000100; > > r[2] = *(uint64_t*)0x20000140; > > } > > *(uint8_t*)0x200008c0 = 0x15; > > *(uint8_t*)0x200008c1 = 0; > > *(uint16_t*)0x200008c2 = 0; > > *(uint32_t*)0x200008c4 = -1; > > *(uint64_t*)0x200008c8 = 0; > > *(uint64_t*)0x200008d0 = 0x200003c0; > > memcpy((void*)0x200003c0, "./file1\000", 8); > > *(uint32_t*)0x200008d8 = 0x20; > > *(uint32_t*)0x200008dc = 0x1000; > > *(uint64_t*)0x200008e0 = 0; > > *(uint16_t*)0x200008e8 = 0; > > *(uint16_t*)0x200008ea = 0; > > *(uint8_t*)0x200008ec = 0; > > *(uint8_t*)0x200008ed = 0; > > *(uint8_t*)0x200008ee = 0; > > *(uint8_t*)0x200008ef = 0; > > *(uint8_t*)0x200008f0 = 0; > > *(uint8_t*)0x200008f1 = 0; > > *(uint8_t*)0x200008f2 = 0; > > *(uint8_t*)0x200008f3 = 0; > > *(uint8_t*)0x200008f4 = 0; > > *(uint8_t*)0x200008f5 = 0; > > *(uint8_t*)0x200008f6 = 0; > > *(uint8_t*)0x200008f7 = 0; > > *(uint8_t*)0x200008f8 = 0; > > *(uint8_t*)0x200008f9 = 0; > > *(uint8_t*)0x200008fa = 0; > > *(uint8_t*)0x200008fb = 0; > > *(uint8_t*)0x200008fc = 0; > > *(uint8_t*)0x200008fd = 0; > > *(uint8_t*)0x200008fe = 0; > > *(uint8_t*)0x200008ff = 0; > > syz_io_uring_submit(r[1], r[2], 0x200008c0, 3); > > syscall(__NR_io_uring_enter, r[0], 1, 1, 1ul, 0ul, 0ul); > > return 0; > > } > > > > -- > > You received this message because you are subscribed to the Google Groups "syzkaller" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller+unsubscribe@xxxxxxxxxxxxxxxx. > > To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller/20210301065837.0AB115D005DA%40webmail.sinamail.sina.com.cn. > > -- > You received this message because you are subscribed to the Google Groups "syzkaller" group. > To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller+unsubscribe@xxxxxxxxxxxxxxxx. > To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller/CAKXUXMz1CqLAz8ZT4202%2Bh9pNzJU%3DYTN7PExAbaAgpOfqzWXgg%40mail.gmail.com.