News for hackers. Stuff that matters.
Re:Put an io_uring on it – Exploiting the Linux Kernel by Sarkie on Friday June 16, 2023 @07:26AM (#36354762)
Chompie is fantastic at making things readable.
Re:Put an io_uring on it – Exploiting the Linux Kernel by gaze on Friday June 16, 2023 @10:19AM (#36356965)
yeah, chompie rules
Re:Put an io_uring on it – Exploiting the Linux Kernel by alberth on Friday June 16, 2023 @08:51AM (#36355731)
Does FreeBSD have anything similar to io_uring?

My understanding is kqueue isn’t the proper comparison.

Re:Put an io_uring on it – Exploiting the Linux Kernel by loeg on Friday June 16, 2023 @12:02PM (#36358925)
> Does FreeBSD have anything similar to io_uring?

No. (Not for security reasons, but for lack of an army of motivated and talented developers like Jens Axboe et al.)

> My understanding is its incorrect to compare to kqueue.

Right. kqueue is more like an extended version of epoll.

Re:Put an io_uring on it – Exploiting the Linux Kernel by hedora on Friday June 16, 2023 @05:25PM (#36364123)
Well, it does, in that most modern hardware devices communicate over PCIe via SQ/CQ pairs, and I'm pretty sure that include virtualization device interfaces.

A lot of people are coming to the conclusion that io_uring's userspace interface is fundamentally insecure. That couldn't be farther from the truth. I've read the spec (which is only a few pages). I could implement + security validate both sides in a day or two (and have done similar in the past).

Re:Put an io_uring on it – Exploiting the Linux Kernel by drewg123 on Friday June 16, 2023 @12:21PM (#36359241)
kqueue is most comparable to epoll.

In a way, async sendfile is like iouring in that a web / file server does not have to supply a blocking thread context to wait for io -- once data arrives from the storage driver, its pushed through the TCP stack in the storage driver's ithread context. But its just that single sequence.

Re:Put an io_uring on it – Exploiting the Linux Kernel by alberth on Friday June 16, 2023 @01:22PM (#36360379)
Drew, beyond async sendfile which you’ve already done - does Netflix have any plans to bring more general purpose iouring-like functionality to FreeBSD?

(Thank you & the team for all you do)

Re:Put an io_uring on it – Exploiting the Linux Kernel by drewg123 on Sunday June 18, 2023 @08:09PM (#36385838)
Not that I'm aware of. The sendfile path is our hottest path, and that's already improved immensely by async sendfile.
Re:Put an io_uring on it – Exploiting the Linux Kernel by twunde on Friday June 16, 2023 @09:36AM (#36356364)
Previous discussion on hnnews when this was originally submitted as a Graph Security piece: https://news.ycombinator.com/item?id=30605356

This is now mirrored since Grapl shut down (RIP)

Re:Put an io_uring on it – Exploiting the Linux Kernel by TechieKid on Friday June 16, 2023 @12:09PM (#36359027)
Also relevant news that Google has disabled io_uring for apps on Android and disabled it entirely on Chrome OS and production Google servers since 60% of the exploits (~$1M worth) submitted to the Google Vulnerability Rewards Program have been for io_uring: https://security.googleblog.com/2023/06/learnings-from-kctf-...
Re:Put an io_uring on it – Exploiting the Linux Kernel by loeg on Friday June 16, 2023 @12:54PM (#36359901)
Re:Put an io_uring on it – Exploiting the Linux Kernel by dang on Friday June 16, 2023 @02:12PM (#36361144)
Thanks to you both! I've macroexpanded these links at the toplevel: https://news.ycombinator.com/item?id=36361124
Re:Put an io_uring on it – Exploiting the Linux Kernel by refulgentis on Friday June 16, 2023 @12:38PM (#36359557)
> If the operation can be done without blocking, it will be completed synchronously in the context of the calling thread.

My careers been in mobile, I thought “blocking” and “synchronous” were synonymous.

Does blocking in this context mean “needs to make a system call?”

Re:Put an io_uring on it – Exploiting the Linux Kernel by skulk on Friday June 16, 2023 @12:40PM (#36359609)
I think it means "entering a state where the thread has nothing to do but wait." An "add" instruction is synchronous but I wouldn't say it "blocks".
Re:Put an io_uring on it – Exploiting the Linux Kernel by Arnavion on Friday June 16, 2023 @12:56PM (#36359929)
>I think it means "entering a state where the thread has nothing to do but wait."

No. Neither thread involved here (the userspace thread or the kernel thread) will "wait" in either scenario. The userspace thread will either work on the syscall (because it was ready to be performed immediately) or it will be released to go do something else. The kernel thread will either not be involved (because the syscall was performed by the userspace thread already) or it will start working on the syscall.

Re:Put an io_uring on it – Exploiting the Linux Kernel by formerly_proven on Friday June 16, 2023 @12:41PM (#36359618)
In Linux, file systems are comparatively uninvolved in I/O (or can choose to be so), so for example the kernel can figure out (in common cases) that e.g. a read of a file can be served entirely out of the page cache without going into file system code at all, then it can just do that right on the spot.
Re:Put an io_uring on it – Exploiting the Linux Kernel by Arnavion on Friday June 16, 2023 @12:52PM (#36359842)
"Blocking" == "can be completed immediately" in this context, ie whether the equivalent syscall would complete immediately or if it would return EAGAIN. So if the operation can be completed immediately, it will be completed in the context of the calling thread without involving the kernel work queue. Otherwise it cannot be completed immediately, so the kernel work queue will take it and start working on it.
Re:Put an io_uring on it – Exploiting the Linux Kernel by ithkuil on Friday June 16, 2023 @12:56PM (#36359928)
"Blocking (on IO)" in OS jargon means that the thread can yield the CPU to other threads because it's otherwise waiting for some external event (e.g. some IO operation to complete).

When the IO operation is ready the thread is then marked to be awakened and the scheduler will context switch back to it whenever it sees fit (given other considerations like thread priority, etc).

From the POV of the thread that blocks nothing really happens while it's waiting. Once it awakens it has the result of the operation (or an error) and it can observe that more time has passed by inspecting the timer. For all intents and purposes the operation was "synchronous" from the POV of the thread.

Re:Put an io_uring on it – Exploiting the Linux Kernel by refulgentis on Sunday June 18, 2023 @06:04PM (#36385002)
Ty for this, Flutters been unreasonably effective for me, with an absurdly simple concurrency system, and I never quite understood why. Now I see why the simple idea of never-blocking is so effective. This comment probably sounds silly, I’m groping for words to describe my old vs. new understanding, but anyways, thanks :)
Re:Put an io_uring on it – Exploiting the Linux Kernel by shp0ngle on Friday June 16, 2023 @02:00PM (#36360957)
(2022)
Re:Put an io_uring on it – Exploiting the Linux Kernel by dang on Friday June 16, 2023 @02:11PM (#36361137)
Added. Thanks!
Re:Put an io_uring on it – Exploiting the Linux Kernel by dang on Friday June 16, 2023 @02:10PM (#36361124)
Recent and related:

Learnings from kCTF VRP's 42 Linux kernel exploits submissions - https://news.ycombinator.com/item?id=36350693 - June 2023 (87 comments)

Past discussion of current article:

Put an io_uring on it: Exploiting the Linux kernel - https://news.ycombinator.com/item?id=30605356 - March 2022 (22 comments)

Re:Put an io_uring on it – Exploiting the Linux Kernel by a1369209993 on Friday June 16, 2023 @03:18PM (#36362321)
Submitted URL doesn't load because of Javascript. Content appears to be available at [0] (previously (non-archive.org) submitted as [1]). Is that actually the same article?

0: http://web.archive.org/web/20221130215710/https://www.grapls...

1: https://news.ycombinator.com/item?id=30605356

Re:Put an io_uring on it – Exploiting the Linux Kernel by hedora on Friday June 16, 2023 @05:35PM (#36364244)
So, going through the 2023 CVE's for io_uring, this is the only one that impacts the 6.x kernel line. The rest were targeting 5.10 (except one for 5.19).

https://www.openwall.com/lists/oss-security/2023/05/08/3

https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=io_uring

That tells me that io_uring stabilized a lot during 2021.

Google yanking support for it seems like a bad decision. Instead, they should upgrade their 3-year-old kernels, which certainly contain other fixed-but-not-backported security vulnerabilites.