Add support for OpenBSD
PATCH 1/3 Add support for OpenBSD
Hi!
I made the xen kernel buildable on OpenBSD.
The first patch touches the buildsystem.
xen/arch/x86/Rules.mk +2 -2
@@ -34,7 +34,7 @@ endif endif ifeq ($(XEN_TARGET_ARCH),x86_32) -LDFLAGS += -m elf_i386 +LDFLAGS += -m $(ELFFMT_X86_32) x86_32 := y x86_64 := n endif
@@ -45,7 +45,7 @@ CFLAGS += -fno-asynchronous-unwind-tabl # -fvisibility=hidden reduces -fpic cost, if it's available CFLAGS += $(shell $(CC) -v --help 2>&1 | grep " -fvisibility=" | \ grep -q hidden && echo "-DGCC_HAS_VISIBILITY_ATTRIBUTE") -LDFLAGS += -m elf_x86_64 +LDFLAGS += -m $(ELFFMT_X86_64) x86_32 := n x86_64 := y endif
config/Linux.mk +3 -0
@@ -31,6 +31,9 @@ CFLAGS ?= -O1 -fno-omit-frame-pointer CFLAGS ?= -O1 -fno-omit-frame-pointer endif +ELFFMT_X86_32 = elf_i386 +ELFFMT_X86_64 = elf_x86_64 + # You may use wildcards, e.g. KERNELS=*2.6* KERNELS ?= linux-2.6-xen
config/SunOS.mk +3 -0
@@ -34,3 +34,6 @@ endif endif CFLAGS += -Wa,--divide + +ELFFMT_X86_32 = elf_i386 +ELFFMT_X86_64 = elf_x86_64
config/OpenBSD.mk new file +35 -0
@@ -0,0 +1,35 @@ +# -*- mode: Makefile; -*- + +AS = $(CROSS_COMPILE)as +LD = $(CROSS_COMPILE)ld +CC = $(CROSS_COMPILE)gcc +CPP = $(CROSS_COMPILE)gcc -E +AR = $(CROSS_COMPILE)ar +RANLIB = $(CROSS_COMPILE)ranlib +NM = $(CROSS_COMPILE)nm +STRIP = $(CROSS_COMPILE)strip +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump + +INSTALL = install +INSTALL_DIR = $(INSTALL) -d -m0755 +INSTALL_DATA = $(INSTALL) -m0644 +INSTALL_PROG = $(INSTALL) -m0755 + +LIB64DIR = lib64 + +SOCKET_LIBS = +CURSES_LIBS = -lncurses +SONAME_LDFLAG = -soname +SHLIB_CFLAGS = -shared + +ifneq ($(debug),y) +# Optimisation flags are overridable +CFLAGS ?= -O2 -fomit-frame-pointer +else +# Less than -O1 produces bad code and large stack frames +CFLAGS ?= -O1 -fno-omit-frame-pointer +endif + +ELFFMT_X86_32 = elf_i386_obsd +ELFFMT_X86_64 = elf_x86_64_obsd
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 2 lines · Christoph Egger
I made the xen kernel buildable on OpenBSD.
The first patch touches the buildsystem.
Why is elf_{i386,x86_64}_obsd needed? Is OpenBSD so very special it needs its own linkage target architecture?
-- Keir
Quoted 6 lines · Keir Fraser
Quoted 2 lines · Christoph Egger
I made the xen kernel buildable on OpenBSD.
The first patch touches the buildsystem.Why is elf_{i386,x86_64}_obsd needed? Is OpenBSD so very special it needs its own linkage target architecture?
ld on OpenBSD complains that elf_i386 and elf_x86_64 are not supported. It expects elf_i386_obsd or elf_x86_64_obsd respectively.
Quoted 8 lines · Christoph Egger
Quoted 5 lines
Quoted 2 lines
I made the xen kernel buildable on OpenBSD.
The first patch touches the buildsystem.Why is elf_{i386,x86_64}_obsd needed? Is OpenBSD so very special it needs its own linkage target architecture?
ld on OpenBSD complains that
elf_i386andelf_x86_64are not supported. It expectself_i386_obsdorelf_x86_64_obsdrespectively.
Okay. I applied a modified form of your patch which puts common definitions in config/StdGNU.mk.
I applied your second patch, but not the third (SSP/ProPolice) one as I don't understand why it's needed. If there's some extra magic in OpenBSD's gcc, I hope there is a flag we can specify to turn it off for the hypervisor itself.
-- Keir
Quoted 11 lines · Keir Fraser
Quoted 8 lines · Christoph Egger
Quoted 5 lines
Quoted 2 lines
I made the xen kernel buildable on OpenBSD.
The first patch touches the buildsystem.Why is elf_{i386,x86_64}_obsd needed? Is OpenBSD so very special it needs its own linkage target architecture?
ld on OpenBSD complains that
elf_i386andelf_x86_64are not supported. It expectself_i386_obsdorelf_x86_64_obsdrespectively.
Quoted 7 lines
Okay. I applied a modified form of your patch which puts common definitions in
config/StdGNU.mk.I applied your second patch, but not the third (SSP/ProPolice) one as I don't understand why it's needed. If there's some extra magic in OpenBSD's gcc, I hope there is a flag we can specify to turn it off for the hypervisor itself.
It's enabled by default in OpenBSD's modified gcc-3.3.5, turn it off with CFLAGS+= -fno-stack-protector
-anil
Quoted 10 lines · Anil Madhavapeddy
Quoted 7 lines
I applied your second patch, but not the third (SSP/ProPolice) one as I
don't understand why it's needed. If there's some extra magic in OpenBSD's
gcc, I hope there is a flag we can specify to turn it off for the hypervisor
itself.It's enabled by default in OpenBSD's modified gcc-3.3.5, turn it off with CFLAGS+= -fno-stack-protector
We have that already in arch/x86/Rules.mk. If that was working, I doubt Christoph would have gone to the trouble of hacking up the SSP goop.
-- Keir
Quoted 9 lines · Keir Fraser
Quoted 8 lines · Anil Madhavapeddy
Quoted 7 lines
I applied your second patch, but not the third (SSP/ProPolice) one as I
don't understand why it's needed. If there's some extra magic in OpenBSD's
gcc, I hope there is a flag we can specify to turn it off for the hypervisor
itself.
Quoted 5 lines
Quoted 2 lines
It's enabled by default in OpenBSD's modified gcc-3.3.5, turn it off with CFLAGS+= -fno-stack-protector
We have that already in
arch/x86/Rules.mk. If that was working, I doubt Christoph would have gone to the trouble of hacking up the SSP goop.
I did this work in August. There wasn't anything SSP-related there. So without SSP support, I got into linking errors.
Now that the work is done, why shouldn't it go in?
Quoted 6 lines · Christoph Egger
Quoted 2 lines
We have that already in
arch/x86/Rules.mk. If that was working, I doubt Christoph would have gone to the trouble of hacking up the SSP goop.I did this work in August. There wasn't anything SSP-related there. So without SSP support, I got into linking errors.
Now that the work is done, why shouldn't it go in?
Uncertainty about new compiler-assisted stuff that I don't believe will catch any bugs in Xen. Linux guys have clearly reached the same conclusion. Given we even turn off frame pointers in non-debug builds, is it likely we'll take this? :-)
-- Keir
Quoted 4 lines · Keir Fraser
Quoted 3 lines · Christoph Egger
Quoted 2 lines
We have that already in
arch/x86/Rules.mk. If that was working, I doubt Christoph would have gone to the trouble of hacking up the SSP goop.
Quoted 8 lines
Quoted 3 lines
I did this work in August. There wasn't anything SSP-related there. So without SSP support, I got into linking errors.
Now that the work is done, why shouldn't it go in?Uncertainty about new compiler-assisted stuff that I don't believe will catch any bugs in Xen. Linux guys have clearly reached the same conclusion. Given we even turn off frame pointers in non-debug builds, is it likely we'll take this? :-)
Linux guys also came to the conclusion, kernel debuggers are useless to catch any bugs. On the other side, how many use the kgdb patch? So, even if my SSP patch won't go in, how many will use it? Hmm... now I feel, this ends up in a debate on principles. :-)
Quoted 14 lines · Christoph Egger
Quoted 4 lines · Keir Fraser
Quoted 3 lines · Christoph Egger
Quoted 2 lines
We have that already in
arch/x86/Rules.mk. If that was working, I doubt Christoph would have gone to the trouble of hacking up the SSP goop.Quoted 8 lines
Quoted 3 lines
I did this work in August. There wasn't anything SSP-related there. So without SSP support, I got into linking errors.
Now that the work is done, why shouldn't it go in?Uncertainty about new compiler-assisted stuff that I don't believe will catch any bugs in Xen. Linux guys have clearly reached the same conclusion. Given we even turn off frame pointers in non-debug builds, is it likely we'll take this? :-)
Quoted 4 lines
Linux guys also came to the conclusion, kernel debuggers are useless to catch any bugs. On the other side, how many use the kgdb patch? So, even if my SSP patch won't go in, how many will use it? Hmm... now I feel, this ends up in a debate on principles. :-)
I'll admit I don't really have any time for kernel debuggers either. :-)
We simply don't have arrays on the stack all that often, and particularly not filled from untrusted sources with untrusted limits.
-- Keir
Quoted 14 lines · Christoph Egger
Quoted 4 lines · Keir Fraser
Quoted 3 lines · Christoph Egger
Quoted 2 lines
We have that already in
arch/x86/Rules.mk. If that was working, I doubt Christoph would have gone to the trouble of hacking up the SSP goop.Quoted 8 lines
Quoted 3 lines
I did this work in August. There wasn't anything SSP-related there. So without SSP support, I got into linking errors.
Now that the work is done, why shouldn't it go in?Uncertainty about new compiler-assisted stuff that I don't believe will catch any bugs in Xen. Linux guys have clearly reached the same conclusion. Given we even turn off frame pointers in non-debug builds, is it likely we'll take this? :-)
Quoted 5 lines
Linux guys also came to the conclusion, kernel debuggers are useless to catch any bugs. On the other side, how many use the kgdb patch? So, even if my SSP patch won't go in, how many will use it? Hmm... now I feel, this ends up in a debate on principles. :-)
There is also the small matter of filling up the init_guard with random values, and not hard-coded ones ... in its current state it doesn't actually add any security in Xen with regards to malicious activity (although it would catch some accidental stack overflows, but as Keir says the use of the stack in this way is fairly rare in Xen itself).
-anil
Quoted 10 lines · Keir Fraser
Quoted 8 lines · Anil Madhavapeddy
Quoted 7 lines
I applied your second patch, but not the third (SSP/ProPolice) one as I
don't understand why it's needed. If there's some extra magic in OpenBSD's
gcc, I hope there is a flag we can specify to turn it off for the hypervisor
itself.
Quoted 6 lines
Quoted 2 lines
It's enabled by default in OpenBSD's modified gcc-3.3.5, turn it off with CFLAGS+= -fno-stack-protector
We have that already in
arch/x86/Rules.mk. If that was working, I doubt Christoph would have gone to the trouble of hacking up the SSP goop.
That flag definitely works.
I think Christoph wanted to get stack protection working, as all the other OpenBSD bits (kernel/userland) use it. There isn't much to it beyond adding the stack smash handler, and the stack frame format changes a bit...
-anil
Quoted 11 lines · Anil Madhavapeddy
Quoted 4 lines
We have that already in
arch/x86/Rules.mk. If that was working, I doubt
Christoph would have gone to the trouble of hacking up the SSP goop.That flag definitely works.
I think Christoph wanted to get stack protection working, as all the other OpenBSD bits (kernel/userland) use it. There isn't much to it beyond adding the stack smash handler, and the stack frame format changes a bit...
I don't think stack-smashing attacks are a worrying vulnerability for Xen. We don't do much variable-sized buffer manipulation, strcpy, and so on. I'd much rather see someone put some effort into something more likely to be useful (albeit undoubtedly more work!) like randomised attacks on the hypercall interfaces.
-- Keir
Quoted 14 lines · Keir Fraser
Quoted 11 lines · Anil Madhavapeddy
Quoted 4 lines
We have that already in
arch/x86/Rules.mk. If that was working, I doubt
Christoph would have gone to the trouble of hacking up the SSP goop.That flag definitely works.
I think Christoph wanted to get stack protection working, as all the other OpenBSD bits (kernel/userland) use it. There isn't much to it beyond adding the stack smash handler, and the stack frame format changes a bit...
Quoted 5 lines
I don't think stack-smashing attacks are a worrying vulnerability for Xen. We don't do much variable-sized buffer manipulation, strcpy, and so on. I'd much rather see someone put some effort into something more likely to be useful (albeit undoubtedly more work!) like randomised attacks on the hypercall interfaces.
I built something to do that for a course project a few months ago - basically a kernel module to pass along completely unchecked hypercalls, generated by a python script with a few hooks to filter out those that it knew Xen would catch anyway. It even managed to crash xen periodically, but I never quite finished the piece that was supposed to reproduce crashes after they happened. I guess I should clean it up and post it somewhere...
Quoted 1 line
Quoted 1 line
I don't think stack-smashing attacks are a worrying vulnerability
for
Quoted 2 lines
Xen.
Quoted 1 line
We don't do much variable-sized buffer manipulation, strcpy, and so
on.
Quoted 2 lines
I'd
Quoted 1 line
much rather see someone put some effort into something more likely
to be
Quoted 1 line
Quoted 1 line
useful (albeit undoubtedly more work!) like randomised attacks on
the
Quoted 9 lines
Quoted 1 line
hypercall interfaces.
I built something to do that for a course project a few months ago - basically a kernel module to pass along completely unchecked hypercalls, generated by a python script with a few hooks to filter out those that it knew Xen would catch anyway. It even managed to crash xen periodically, but I never quite finished the piece that was supposed to reproduce crashes after they happened. I guess I should clean it up and post it somewhere...
That would certainly be helpful -- thanks!
I suspect you could get the most mileage with this by saving the domain, then having a loop that restores it and kicks off the test with a different seed. This should enable much faster cycling than having to boot the VM every time Xen decides to terminate it for misbehaving.
Many of the more complex situations come about by having complex pagetable structures etc that are almost valid but have subtle bugs. Generating these scenarios by hand is going to be tough. I think that possibly fault injection is the best way of handling these, perhaps having a special guest kernel module that runs off the ticker and tries to do interesting corruptions to pagetables. We could also arrange to corrupt hypercall arguments one time in a thousand or something.
It would be *great* if someone could work at this sort of testing. It may not sexy as some of the other security work that's going on, but would be incredibly valuable to the project. Please could someone step forward!
Thanks,
Ian
Quoted 20 lines · Ian Pratt
Quoted 1 line
Quoted 1 line
I don't think stack-smashing attacks are a worrying vulnerability
for
Quoted 2 lines
Xen.
Quoted 1 line
We don't do much variable-sized buffer manipulation, strcpy, and so
on.
Quoted 2 lines
I'd
Quoted 1 line
much rather see someone put some effort into something more likely
to be
Quoted 1 line
Quoted 1 line
useful (albeit undoubtedly more work!) like randomised attacks on
the
Quoted 9 lines
Quoted 1 line
hypercall interfaces.
I built something to do that for a course project a few months ago - basically a kernel module to pass along completely unchecked hypercalls, generated by a python script with a few hooks to filter out those that it knew Xen would catch anyway. It even managed to crash xen periodically, but I never quite finished the piece that was supposed to reproduce crashes after they happened. I guess I should clean it up and post it somewhere...
Quoted 5 lines
That would certainly be helpful -- thanks!
I suspect you could get the most mileage with this by saving the domain, then having a loop that restores it and kicks off the test with a different seed. This should enable much faster cycling than having to boot the VM every time Xen decides to terminate it for misbehaving.
That's exactly what it did.
Quoted 7 lines
Many of the more complex situations come about by having complex pagetable structures etc that are almost valid but have subtle bugs. Generating these scenarios by hand is going to be tough. I think that possibly fault injection is the best way of handling these, perhaps having a special guest kernel module that runs off the ticker and tries to do interesting corruptions to pagetables. We could also arrange to corrupt hypercall arguments one time in a thousand or something.
Yes, 'almost correct' is the hard part, and page table manipulation from userspace needs a bit more help than I ever put into my module. But I don't think it would be that much work to export them, let userspace fiddle with them a bit, and reload them.
Quoted 4 lines
It would be *great* if someone could work at this sort of testing. It may not sexy as some of the other security work that's going on, but would be incredibly valuable to the project. Please could someone step forward!
I don't know if I've got the time for it in the near term, but if anyone's interested, the code I wrote (such as it is) is available at
http://hg.kublai.com/monkey
Quoted 10 lines · Keir Fraser
Quoted 3 lines · Anil Madhavapeddy
It's enabled by default in OpenBSD's modified gcc-3.3.5, turn it off with CFLAGS+= -fno-stack-protector
We have that already in
arch/x86/Rules.mk. If that was working, I doubt Christoph would have gone to the trouble of hacking up the SSP goop.-- Keir
I can tell you for a fact that that check doesn't work on Ubuntu edgy.
'test-gcc-flag' greps the gcc --help output, which doesn't do the right thing, at least on Ubuntu. I believe the linux kernel equivalent tries to actually use the option and checks the gcc return code.
I was in the midst of tracking this down a few weeks ago when I discovered other HVM bugs that apparently only show up with gcc v4 (bad EFER values), so I moved back to compiling with gcc-3.4 and dropped it. I'll see if I can finish it up and submit a patch unless someone beats me to it.
john.c
Signature · 1 line
John Clemens Revive Systems, www.revivesystems.com
Quoted 11 lines · John Clemens
I can tell you for a fact that that check doesn't work on Ubuntu edgy.
'test-gcc-flag' greps the gcc --help output, which doesn't do the right thing, at least on Ubuntu. I believe the linux kernel equivalent tries to actually use the option and checks the gcc return code.
I was in the midst of tracking this down a few weeks ago when I discovered other HVM bugs that apparently only show up with gcc v4 (bad EFER values), so I moved back to compiling with gcc-3.4 and dropped it. I'll see if I can finish it up and submit a patch unless someone beats me to it.
Okay, I checked in something like the Linux cc-option function as xen-unstable changeset 11820:b2e71d574045. Actually I changed it because Linux allows through options which aren't really recognised (and cause a warning to be printed) but which do not cause gcc to return an error code. Instead I look for any output on stdout/stderr. It should be more robust than grepping the output of gcc long help!
By the way, the EFER bug was fixed weeks ago.
-- Keir
Quoted 8 lines · Keir Fraser
Quoted 2 lines · Christoph Egger
I made the xen kernel buildable on OpenBSD.
The first patch touches the buildsystem.Why is elf_{i386,x86_64}_obsd needed? Is OpenBSD so very special it needs its own linkage target architecture?
If I remember, these emulations are for W^X support on OpenBSD when we switched to elf from a.out a couple of years ago; it links sections in different address areas so that segment registers (on i386 32-bit anyway) can be used to ensure that no pages are simultaneously writable and executable.
- http://www.openbsd.org/papers/ven05-deraadt/index.html
-anil