3 ms·
This seems a bit too self-congratulatory to be technically meaningful. What feature did they not use? From the thread history, it sounds like they provided no
by geofft 9y ago
This seems a bit too self-congratulatory to be technically meaningful. What feature did they not use?
From the thread history, it sounds like they provided no way for a userspace debugger to (ask the kernel to) set a hardware breakpoint on a section of memory. That means that when you use gdb and set a single breakpoint on some instruction, gdb must instead fall back on single-stepping the entire program until it gets there, incurring at least four context switches per instruction (program being debugged -> exception to kernel -> switch to gdb -> "nope, not there yet" -> kernel resumes the program for one more instruction). It does avoid the bug by not letting the CPU defer a debug exception until after a syscall (because the only mode you get for debug exceptions is the one that unconditionally delivers it after every instruction), but it also makes breakpoints basically unusable for large software.
First, this isn't an obscure, recent, or Intel-only feature. It's not like avoiding RDRAND or anything. Hardware breakpoints are common on basically all CPUs for exactly this reason.
Second, does anyone actually debug large programs using gdb on OpenBSD? It is hard for me to read this as saying "We're not vulnerable because we have so few production users that we can just not have standard development tools that work reasonably." I know OpenBSD is not the most popular OS, but I didn't think it was that unpopular....
- ianai 9y agoQuicker google leads me to believe they suggest using ddb instead of gdb. I’ve seen variations on the following thread a few times. I,don’t,know,whether this answers your question or not. http://openbsd-archive.7691.n7.nabble.com/on-line-kernel-debugging-td335833.html http://openbsd-archive.7691.n7.nabble.com/on-line-kernel-deb...
- notaplumber 9y agoThat is the kernel debugger that is entered when the system panics. Userland debugger is still gdb.
- amluto 9y ago> gdb must instead fall back on single-stepping the entire program until it gets there I don’t think it’s that bad. gdb can (and hopefully does) just replace the target instruction with INT3. IMO the worse implication is that gdb can’t use efficient data breakpoints.
- geofft 9y agoOh, right, yes. Inefficient data breakpoints still seems like a dealbraker for an OS aiming to be as popular as Windows or Linux, but I can see how OpenBSD can avoid it and still have a good number of users.
- 0x0 9y agoI think the hardware breakpoint support is for breaking on memory accesses to a particular address. Setting a breakpoint on the execution of a particular opcode at a particular address is easier and can be done by just swapping in an "INT 3" instruction at the particular point with no overhead.
- burfog 9y agoHardware breakpoint support is also for execution and, oddly, the x86 IO port space reachable by the "in" and "out" instructions. Using an int3 has some problems. It can be seen by the code, which may change behavior. For example, a self-checksum would fail. The int3 will affect all threads, while the hardware breakpoint can be made to affect just one thread.
- notaplumber 9y agoOpenBSD just chose not to implement x86 debug register access from userspace. FYI, Joyent SmartOS/illumos is also similarly not vulnerable, at least by default. https://kb.cert.org/vuls/id/631579 https://kb.cert.org/vuls/id/631579
- ajross 9y agoWhich is to say, no hardware support for watchpoints in gdb[1]? That seems like not such a great "feature"... This is Theo being Theo. No one sane believes that if someone had come to OpenBSD with an implementation of this (very useful!) feature that they wouldn't have committed it. They just didn't get around to it. [1] In which the fallback is, IIRC, to turn off access to the location at the mapping level and take a SIGSEGV on every access to the 4k region containing the address.
- bionsystem 9y agoIt's crazy that DragonFlyBSD took so little time to fix it. I can understand from Microsoft/Xen/Ubuntu to take only 1 day since they have so much people working/depending on it, but it shows great competence and dedication for such a "small" project as DF to solve it in 1 day. Respect.
- tptacek 9y agoAm I misreading this or are you saying that without hardware breakpoints you have to single step all the way through the program to the breakpoint location? If so: that's a surprising and weird thing to say. Without hardware breakpoints, userspace debuggers work by overwriting the instruction at the target with an interrupting instruction, and then restoring it before resuming. I'm trying to imagine how gdb breakpoints in OpenBSD would even work if they required single-stepping whole programs.