[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] mini-os: Avoid segfaults in tc{g,s}etattr
On Mon, Apr 27, 2020 at 3:54 AM Samuel Thibault <samuel.thibault@xxxxxxxxxxxx> wrote: > > Jason Andryuk, le dim. 26 avril 2020 23:40:19 -0400, a ecrit: > > Commit c96c22f1d94 "mini-os: minimal implementations of some termios > > functions" introduced implementations of tcgetattr and tcsetattr. > > However, they do not check if files[fildes].cons.dev is non-NULL before > > dereferencing. This is not a problem for FDs allocated through > > alloc_fd, but the files array pre-allocates FDs 0-2 for stdio. Those > > entries have a NULL .dev, so tc{g,s}etattr on them segfault. > > > > ioemu-stubdom segfaults when term_init() calls tcgetattr on FD 0. > > > > Restore tcgetattr and tcsetattr behavior when .dev is NULL equivalent to > > unsupported_function as it was before c96c22f1d94. > > > > Signed-off-by: Jason Andryuk <jandryuk@xxxxxxxxx> > > Reviewed-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx> > > Thanks! Thank you! > > --- > > I can't get ioemu-stubdom to start without this. With this, the guest > > just reboots immediately, but it does that with a non-stubdom > > device_model_version="qemu-xen-traditional" . The same guest disk image > > (cirros 0.5.1) boots with a linux stubdom or non-stubdom Ubuntu > > qemu-system-x86_64. Ubuntu gcc-9 adds -fcf-protection by default. Somehow that flag caused rombios (I think) to restart. Setting -fcf-protection=none like below (probably just the EMBEDDED_EXTRA_CFLAGS part) lets rombios start properly. The hypervisor needs it as well via EXTRA_CFLAGS_XEN_CORE=-fcf-protection=none and maybe also added to xen/arch/x86/boot/build32.mk . diff --git a/Config.mk b/Config.mk index 0f303c79b2..efb3d42bc4 100644 --- a/Config.mk +++ b/Config.mk @@ -205,6 +205,7 @@ APPEND_CFLAGS += $(foreach i, $(APPEND_INCLUDES), -I$(i)) EMBEDDED_EXTRA_CFLAGS := -nopie -fno-stack-protector -fno-stack-protector-all EMBEDDED_EXTRA_CFLAGS += -fno-exceptions +EMBEDDED_EXTRA_CFLAGS += -fcf-protection=none XEN_EXTFILES_URL ?= http://xenbits.xen.org/xen-extfiles # All the files at that location were downloaded from elsewhere on diff --git a/tools/firmware/Rules.mk b/tools/firmware/Rules.mk index 26bbddccd4..0d33514d53 100644 --- a/tools/firmware/Rules.mk +++ b/tools/firmware/Rules.mk @@ -17,3 +17,4 @@ $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) # Extra CFLAGS suitable for an embedded type of environment. CFLAGS += -fno-builtin -msoft-float +CFLAGS += -fcf-protection=none
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |