TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Put an io_uring on it: Exploiting the Linux kernel

282 点作者 blopeur大约 3 年前

4 条评论

tptacek大约 3 年前
This is one of the all-time great LPE writeups.<p>A summary:<p>1. io_uring includes a feature that asks the kernel to manage groups of buffers for SQEs (the objects userland submits to tell uring what to do). If you enable this feature, the kernel overloads a field normally used to track a userland pointer with a kernel pointer.<p>2. The special-case code that handles I&#x2F;O operations for files-that-are-not-files, like in procfs, missed the check for this &quot;overloaded pointer&quot; hack, and so can be tricked into advancing a kernel pointer arbitrarily, because it thinks it&#x27;s working with a userland pointer.<p>3. The pointer you manipulate thusly is eventually freed, which lets you free kernel objects within a range of possible pointers.<p>4. io_uring allows you to control the CPU affinity of the kernel threads it generates on your behalf, because of course it does, so you can get your userland process and all your related io_uring kthreads onto the same CPU, and thus into the same SLUB cache area, which gives you enough control to target specific kernel objects (of a size bounded I think by the SQE?) reliably.<p>5. There&#x27;s a well-known LPE trick for exploiting UAFs: the setxattr(2) syscall copies arbitrary extended attributes for files from userland to kernel buffers (that&#x27;s its job), and the userfaultfd(2) syscall lets you defer page faults to userland; you can chain setxattr and userfaultfd to allocate and populate a kernel buffer of arbitrary size and contents and then block, keeping the object in memory.<p>6. Since that&#x27;s a popular exploit technique, there&#x27;s a default-yes setting in most distros to require root to use userfaultfd(2) --- but you can do the same thing with FUSE, where deferring I&#x2F;O operations to userland is kind of the whole premise of the interface.<p>7. setxattr&#x2F;userfaultfd can be transformed from a UAF primitive to an arbitrary kernel leak: if you have an arbitrary-free vulnerability (see step 3), you can do the setxattr-then-block thing, then trigger the free from another thread and target the xattr buffer, so setxattr&#x27;s buffer is reclaimed out from under it, then trigger the allocation of a kernel structure you want to leak that is of the same size, which setxattr will copy into (another UAF); now you have a kernel structure that the kernel is treating like a file&#x27;s extended attributes, which you can read back with getxattr. Neat!<p>8. At this point you can go hunting for kernel structures to whack, because you can use the arbitrary leak primitive to leak structs that in turn embed the (secret) addresses of other kernel structures.<p>9. Find a pointer to a socket&#x27;s BPF filter and use the UAF to inject a BPF filter directly, bypassing the verifier, then trigger the BPF filter and do whatever you want, I guess.<p>I&#x27;m sure I got a bunch of this wrong; corrections welcome. Again: really spectacular writeup: a good bug, some neat tricks, and a decent survey of Linux kernel LPE techniques.
评论 #30609337 未加载
egberts1大约 3 年前
Whoa!<p>One frickin’ GIANT driver coherency setting, I&#x2F;O Ring, that is.
junon大约 3 年前
Yes, unfortunately I figured this might happen. People have been warning of some major issues with its design for a while now wrt security. Paired with the fact it&#x27;s not much faster in practice than epoll in a large majority of usecases, I really worry it&#x27;s going to footgun some people.
评论 #30608960 未加载
评论 #30608030 未加载
评论 #30609389 未加载
评论 #30608226 未加载
评论 #30607938 未加载
评论 #30608763 未加载
jwilk大约 3 年前
&gt; <i>most distros sync on stable releases</i><p>[citation needed]