Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2022-29582 PoC — Linux kernel 竞争条件问题漏洞

Source
Associated Vulnerability
Title:Linux kernel 竞争条件问题漏洞 (CVE-2022-29582)
Description:Linux kernel是美国Linux基金会的开源操作系统Linux所使用的内核。 Linux kernel5.17.3 之前版本存在竞争条件问题漏洞,该漏洞源于 io_uring 超时中的竞争条件,fs/io_uring.c 具有 use-after-free。
Description
Exploit for CVE-2022-29582 targeting Google's Kernel CTF
Readme
# CVE-2022-29582
This repository contains exploit code for CVE-2022-29582, a Local Privilege Escalation in `io_uring` (of the Linux kernel).

Default configurations are affected and no special privileges should be needed.

You can find the writeup at [https://ruia-ruia.github.io/2022/08/05/CVE-2022-29582-io-uring/](https://ruia-ruia.github.io/2022/08/05/CVE-2022-29582-io-uring/)

## Building
Running

```bash
make
```

should result in a shiny new executable - or just use the pre-commited one :)

## Testing
First, check the writeup for the (micro)arch specs. Then run the given kernel: vmlinuz-5.10.90.
The exploit (particularly now the ROP chain) should work fine with the kCTF setup.
File Snapshot

[4.0K] /data/pocs/ed141ea16962e0bac3fc1b67972f690fd79a93f7 ├── [ 172] affinity.h ├── [4.0K] bin │   └── [1.2M] exp ├── [4.8K] cross_cache.c ├── [ 811] cross_cache.h ├── [ 963] err_state.h ├── [4.0K] liburing │   ├── [1.4K] CHANGELOG │   ├── [ 244] CITATION.cff │   ├── [ 11K] configure │   ├── [ 26K] COPYING │   ├── [ 18K] COPYING.GPL │   ├── [4.0K] debian │   │   ├── [ 803] changelog │   │   ├── [ 2] compat │   │   ├── [1.6K] control │   │   ├── [2.1K] copyright │   │   ├── [ 16] liburing1.install │   │   ├── [1.3K] liburing1.symbols │   │   ├── [ 16] liburing1-udeb.install │   │   ├── [ 67] liburing-dev.install │   │   ├── [ 141] liburing-dev.manpages │   │   ├── [4.0K] patches │   │   │   └── [ 65] series │   │   ├── [ 236] README.Debian │   │   ├── [1.5K] rules │   │   ├── [4.0K] source │   │   │   ├── [ 12] format │   │   │   ├── [ 44] local-options │   │   │   └── [ 88] options │   │   └── [ 186] watch │   ├── [4.0K] examples │   │   ├── [5.2K] io_uring-cp.c │   │   ├── [2.2K] io_uring-test.c │   │   ├── [3.5K] link-cp.c │   │   ├── [ 672] Makefile │   │   └── [5.9K] ucontext-cp.c │   ├── [ 233] liburing.pc.in │   ├── [1.7K] liburing.spec │   ├── [1.0K] LICENSE │   ├── [1.7K] make-debs.sh │   ├── [2.2K] Makefile │   ├── [ 256] Makefile.common │   ├── [ 237] Makefile.quiet │   ├── [4.0K] man │   │   ├── [ 24K] io_uring.7 │   │   ├── [1.5K] io_uring_buf_ring_add.3 │   │   ├── [ 824] io_uring_buf_ring_advance.3 │   │   ├── [1.2K] io_uring_buf_ring_cq_advance.3 │   │   ├── [ 769] io_uring_buf_ring_init.3 │   │   ├── [ 687] io_uring_buf_ring_mask.3 │   │   ├── [1.3K] io_uring_cq_advance.3 │   │   ├── [1.3K] io_uring_cqe_get_data.3 │   │   ├── [ 23] io_uring_cqe_get_data64.3 -> io_uring_cqe_get_data.3 │   │   ├── [1.1K] io_uring_cqe_seen.3 │   │   ├── [ 675] io_uring_cq_ready.3 │   │   ├── [ 40K] io_uring_enter.2 │   │   ├── [ 557] io_uring_free_probe.3 │   │   ├── [ 834] io_uring_get_probe.3 │   │   ├── [1.2K] io_uring_get_sqe.3 │   │   ├── [ 809] io_uring_opcode_supported.3 │   │   ├── [1.0K] io_uring_peek_cqe.3 │   │   ├── [5.9K] io_uring_prep_accept.3 │   │   ├── [ 22] io_uring_prep_accept_direct.3 -> io_uring_prep_accept.3 │   │   ├── [3.2K] io_uring_prep_cancel.3 │   │   ├── [ 22] io_uring_prep_cancel64.3 -> io_uring_prep_cancel.3 │   │   ├── [1.4K] io_uring_prep_close.3 │   │   ├── [ 21] io_uring_prep_close_direct.3 -> io_uring_prep_close.3 │   │   ├── [1.9K] io_uring_prep_connect.3 │   │   ├── [1.4K] io_uring_prep_fadvise.3 │   │   ├── [1.4K] io_uring_prep_fallocate.3 │   │   ├── [2.7K] io_uring_prep_files_update.3 │   │   ├── [1.8K] io_uring_prep_fsync.3 │   │   ├── [ 22] io_uring_prep_link.3 -> io_uring_prep_linkat.3 │   │   ├── [2.6K] io_uring_prep_linkat.3 │   │   ├── [1.3K] io_uring_prep_madvise.3 │   │   ├── [ 23] io_uring_prep_mkdir.3 -> io_uring_prep_mkdirat.3 │   │   ├── [2.3K] io_uring_prep_mkdirat.3 │   │   ├── [1.9K] io_uring_prep_msg_ring.3 │   │   ├── [ 22] io_uring_prep_multishot_accept.3 -> io_uring_prep_accept.3 │   │   ├── [ 22] io_uring_prep_multishot_accept_direct.3 -> io_uring_prep_accept.3 │   │   ├── [3.9K] io_uring_prep_openat2.3 │   │   ├── [ 23] io_uring_prep_openat2_direct.3 -> io_uring_prep_openat2.3 │   │   ├── [3.8K] io_uring_prep_openat.3 │   │   ├── [ 22] io_uring_prep_openat_direct.3 -> io_uring_prep_openat.3 │   │   ├── [2.2K] io_uring_prep_poll_add.3 │   │   ├── [ 24] io_uring_prep_poll_multishot.3 -> io_uring_prep_poll_add.3 │   │   ├── [1.5K] io_uring_prep_poll_remove.3 │   │   ├── [2.7K] io_uring_prep_poll_update.3 │   │   ├── [3.8K] io_uring_prep_provide_buffers.3 │   │   ├── [1.9K] io_uring_prep_read.3 │   │   ├── [1.8K] io_uring_prep_read_fixed.3 │   │   ├── [3.0K] io_uring_prep_readv2.3 │   │   ├── [2.6K] io_uring_prep_readv.3 │   │   ├── [2.3K] io_uring_prep_recv.3 │   │   ├── [2.8K] io_uring_prep_recvmsg.3 │   │   ├── [1.3K] io_uring_prep_remove_buffers.3 │   │   ├── [ 24] io_uring_prep_rename.3 -> io_uring_prep_renameat.3 │   │   ├── [2.7K] io_uring_prep_renameat.3 │   │   ├── [1.3K] io_uring_prep_send.3 │   │   ├── [1.8K] io_uring_prep_sendmsg.3 │   │   ├── [1.2K] io_uring_prep_shutdown.3 │   │   ├── [2.9K] io_uring_prep_socket.3 │   │   ├── [ 22] io_uring_prep_socket_direct.3 -> io_uring_prep_socket.3 │   │   ├── [1.9K] io_uring_prep_splice.3 │   │   ├── [2.1K] io_uring_prep_statx.3 │   │   ├── [ 25] io_uring_prep_symlink.3 -> io_uring_prep_symlinkat.3 │   │   ├── [2.4K] io_uring_prep_symlinkat.3 │   │   ├── [1.5K] io_uring_prep_sync_file_range.3 │   │   ├── [1.7K] io_uring_prep_tee.3 │   │   ├── [2.6K] io_uring_prep_timeout.3 │   │   ├── [ 30] io_uring_prep_timeout_remove.3 -> io_uring_prep_timeout_update.3 │   │   ├── [2.8K] io_uring_prep_timeout_update.3 │   │   ├── [ 24] io_uring_prep_unlink.3 -> io_uring_prep_unlinkat.3 │   │   ├── [2.3K] io_uring_prep_unlinkat.3 │   │   ├── [1.8K] io_uring_prep_write.3 │   │   ├── [1.8K] io_uring_prep_write_fixed.3 │   │   ├── [3.0K] io_uring_prep_writev2.3 │   │   ├── [2.6K] io_uring_prep_writev.3 │   │   ├── [ 764] io_uring_queue_exit.3 │   │   ├── [2.9K] io_uring_queue_init.3 │   │   ├── [ 21] io_uring_queue_init_params.3 -> io_uring_queue_init.3 │   │   ├── [ 18K] io_uring_register.2 │   │   ├── [1.8K] io_uring_register_buffers.3 │   │   ├── [3.3K] io_uring_register_buf_ring.3 │   │   ├── [1.7K] io_uring_register_eventfd.3 │   │   ├── [ 27] io_uring_register_eventfd_async.3 -> io_uring_register_eventfd.3 │   │   ├── [1.3K] io_uring_register_files.3 │   │   ├── [1.6K] io_uring_register_iowq_aff.3 │   │   ├── [2.2K] io_uring_register_iowq_max_workers.3 │   │   ├── [1.7K] io_uring_register_ring_fd.3 │   │   ├── [ 18K] io_uring_setup.2 │   │   ├── [1.2K] io_uring_sqe_set_data.3 │   │   ├── [ 23] io_uring_sqe_set_data64.3 -> io_uring_sqe_set_data.3 │   │   ├── [3.4K] io_uring_sqe_set_flags.3 │   │   ├── [ 893] io_uring_sq_ready.3 │   │   ├── [1015] io_uring_sqring_wait.3 │   │   ├── [ 622] io_uring_sq_space_left.3 │   │   ├── [1.5K] io_uring_submit.3 │   │   ├── [1.0K] io_uring_submit_and_wait.3 │   │   ├── [1.7K] io_uring_submit_and_wait_timeout.3 │   │   ├── [ 692] io_uring_unregister_buffers.3 │   │   ├── [ 794] io_uring_unregister_buf_ring.3 │   │   ├── [ 27] io_uring_unregister_eventfd.3 -> io_uring_register_eventfd.3 │   │   ├── [ 664] io_uring_unregister_files.3 │   │   ├── [ 28] io_uring_unregister_iowq_aff.3 -> io_uring_register_iowq_aff.3 │   │   ├── [ 977] io_uring_unregister_ring_fd.3 │   │   ├── [1.1K] io_uring_wait_cqe.3 │   │   ├── [1.3K] io_uring_wait_cqe_nr.3 │   │   ├── [1.5K] io_uring_wait_cqes.3 │   │   └── [1.5K] io_uring_wait_cqe_timeout.3 │   ├── [2.0K] README │   ├── [ 206] SECURITY.md │   ├── [4.0K] src │   │   ├── [4.0K] arch │   │   │   ├── [4.0K] aarch64 │   │   │   │   └── [2.9K] syscall.h │   │   │   ├── [4.0K] generic │   │   │   │   ├── [ 424] lib.h │   │   │   │   └── [2.1K] syscall.h │   │   │   ├── [1.8K] syscall-defs.h │   │   │   └── [4.0K] x86 │   │   │   ├── [ 312] lib.h │   │   │   └── [7.2K] syscall.h │   │   ├── [4.0K] include │   │   │   ├── [4.0K] liburing │   │   │   │   ├── [2.4K] barrier.h │   │   │   │   └── [ 13K] io_uring.h │   │   │   └── [ 33K] liburing.h │   │   ├── [ 132] int_flags.h │   │   ├── [1.1K] lib.h │   │   ├── [1.3K] liburing.map │   │   ├── [2.5K] Makefile │   │   ├── [ 840] nolibc.c │   │   ├── [ 10K] queue.c │   │   ├── [7.7K] register.c │   │   ├── [8.9K] setup.c │   │   ├── [1.2K] syscall.c │   │   └── [2.4K] syscall.h │   └── [4.0K] test │   ├── [5.9K] 232c93d07b74.c │   ├── [7.0K] 35fa71a030ca.c │   ├── [1.6K] 500f9fbadef8.c │   ├── [1.8K] 7ad0e4b2f83c.c │   ├── [1.6K] 8a9973408177.c │   ├── [1.3K] 917257daa0fe.c │   ├── [1.5K] a0908ae19763.c │   ├── [3.6K] a4c0b3decb33.c │   ├── [ 17K] accept.c │   ├── [4.9K] accept-link.c │   ├── [3.5K] accept-reuse.c │   ├── [1.7K] accept-test.c │   ├── [6.0K] across-fork.c │   ├── [1.3K] b19062a56726.c │   ├── [1.6K] b5837bd5311d.c │   ├── [8.1K] buf-ring.c │   ├── [2.9K] ce593a6c480a.c │   ├── [2.4K] close-opath.c │   ├── [ 326] config │   ├── [7.5K] connect.c │   ├── [1.6K] cq-full.c │   ├── [5.5K] cq-overflow.c │   ├── [1.8K] cq-peek-batch.c │   ├── [1.5K] cq-ready.c │   ├── [1.2K] cq-size.c │   ├── [1.8K] d4ae271dfaae.c │   ├── [1.2K] d77a67ed5f27.c │   ├── [5.6K] defer.c │   ├── [6.2K] double-poll-crash.c │   ├── [1.5K] drop-submit.c │   ├── [1.7K] eeed8b54e0df.c │   ├── [ 888] empty-eownerdead.c │   ├── [2.0K] eventfd.c │   ├── [2.8K] eventfd-disable.c │   ├── [1.5K] eventfd-reg.c │   ├── [1.8K] eventfd-ring.c │   ├── [ 84] exec-target.c │   ├── [2.4K] exit-no-cleanup.c │   ├── [3.6K] fadvise.c │   ├── [4.4K] fallocate.c │   ├── [3.4K] fc2a85cb02ef.c │   ├── [ 18K] file-register.c │   ├── [2.5K] files-exit-hang-poll.c │   ├── [2.6K] files-exit-hang-timeout.c │   ├── [3.4K] file-update.c │   ├── [ 12K] file-verify.c │   ├── [2.3K] fixed-buf-iter.c │   ├── [1.9K] fixed-link.c │   ├── [3.2K] fixed-reuse.c │   ├── [5.3K] fpos.c │   ├── [4.0K] fsync.c │   ├── [2.8K] hardlink.c │   ├── [3.0K] helpers.c │   ├── [1.5K] helpers.h │   ├── [ 11K] io-cancel.c │   ├── [7.5K] iopoll.c │   ├── [6.3K] io_uring_enter.c │   ├── [ 15K] io_uring_register.c │   ├── [4.3K] io_uring_setup.c │   ├── [5.6K] lfs-openat.c │   ├── [2.4K] lfs-openat-write.c │   ├── [8.8K] link.c │   ├── [4.2K] link_drain.c │   ├── [ 21K] link-timeout.c │   ├── [3.6K] madvise.c │   ├── [4.8K] Makefile │   ├── [1.9K] mkdir.c │   ├── [4.2K] msg-ring.c │   ├── [7.8K] multicqes_drain.c │   ├── [1.6K] nop-all-sizes.c │   ├── [2.5K] nop.c │   ├── [6.5K] openat2.c │   ├── [4.8K] open-close.c │   ├── [3.6K] open-direct-link.c │   ├── [3.2K] open-direct-pick.c │   ├── [3.7K] personality.c │   ├── [1.4K] pipe-eof.c │   ├── [2.1K] pipe-reuse.c │   ├── [1.9K] poll.c │   ├── [9.0K] poll-cancel-all.c │   ├── [4.5K] poll-cancel.c │   ├── [2.5K] poll-cancel-ton.c │   ├── [ 10K] pollfree.c │   ├── [4.5K] poll-link.c │   ├── [3.6K] poll-many.c │   ├── [4.9K] poll-mshot-update.c │   ├── [ 924] poll-ring.c │   ├── [6.2K] poll-v-poll.c │   ├── [2.4K] probe.c │   ├── [2.1K] read-before-exit.c │   ├── [ 18K] read-write.c │   ├── [5.1K] recv-msgall.c │   ├── [7.4K] recv-msgall-stream.c │   ├── [ 14K] register-restrictions.c │   ├── [2.2K] rename.c │   ├── [3.3K] ringbuf-read.c │   ├── [5.1K] ring-leak2.c │   ├── [5.3K] ring-leak.c │   ├── [ 10K] rsrc_tags.c │   ├── [ 219] runtests-loop.sh │   ├── [ 197] runtests-quiet.sh │   ├── [3.5K] runtests.sh │   ├── [2.1K] rw_merge_test.c │   ├── [1.7K] self.c │   ├── [4.4K] sendmsg_fs_cve.c │   ├── [5.5K] send_recv.c │   ├── [9.1K] send_recvmsg.c │   ├── [1.5K] shared-wq.c │   ├── [1.3K] short-read.c │   ├── [3.3K] shutdown.c │   ├── [1.3K] sigfd-deadlock.c │   ├── [9.4K] skip-cqe.c │   ├── [8.1K] socket.c │   ├── [2.9K] socket-rw.c │   ├── [3.3K] socket-rw-eagain.c │   ├── [3.2K] socket-rw-offset.c │   ├── [ 10K] splice.c │   ├── [ 711] sq-full.c │   ├── [ 711] sq-full-cpp.cc │   ├── [4.7K] sqpoll-cancel-hang.c │   ├── [5.0K] sqpoll-disable-exit.c │   ├── [3.5K] sq-poll-dup.c │   ├── [1.5K] sqpoll-exit-hang.c │   ├── [3.3K] sq-poll-kthread.c │   ├── [2.4K] sq-poll-share.c │   ├── [1.3K] sqpoll-sleep.c │   ├── [2.8K] sq-space_left.c │   ├── [3.3K] statx.c │   ├── [4.8K] stdout.c │   ├── [3.4K] submit-link-fail.c │   ├── [4.3K] submit-reuse.c │   ├── [2.4K] symlink.c │   ├── [ 833] teardowns.c │   ├── [ 831] test.h │   ├── [2.4K] thread-exit.c │   ├── [ 32K] timeout.c │   ├── [5.5K] timeout-new.c │   ├── [4.1K] timeout-overflow.c │   ├── [1.1K] tty-write-dpoll.c │   ├── [1.9K] unlink.c │   ├── [2.9K] wakeup-hang.c │   └── [ 10K] xattr.c ├── [ 14K] main.c ├── [ 292] Makefile ├── [5.7K] manager.c ├── [2.6K] manager.h ├── [1.5K] msg.c ├── [ 700] msg.h ├── [ 691] README.md ├── [1.5K] ring_helpers.h ├── [3.6K] rop.h ├── [4.2K] tls.c ├── [ 681] tls.h └── [8.4M] vmlinuz-5.10.90 15 directories, 319 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. If the original source is unavailable, please email f.jinxu#gmail.com for a local snapshot (replace # with @).
    3. Shenlong has snapshotted the POC code for you. To support long-term maintenance, please consider donating. Thank you for your support.