From ebc18c564778d0121f23ec3c02ad5867d0d3b9366954be86a6426de85191d0e9 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Sat, 24 May 2014 10:37:00 +0000 Subject: [PATCH] - Fix crash in abnormal condition (bnc#879666, bnc#879489): * u_connection-avoid-crash-when-CloseWellKnownConnections-gets-called-twice.patch Fix a crash when CloseWellKnownConnections() gets called twice. This can happen if FatalError() is called in the shutdown procedure. * u_CloseConsole-Don-t-report-FatalError-when-shutting-down.patch Don't call FatalError() on errors in console ioctls when in shutdown. OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/xorg-x11-server?expand=0&rev=518 --- ...report-FatalError-when-shutting-down.patch | 81 +++++++++++++++++++ ...llKnownConnections-gets-called-twice.patch | 33 ++++++++ xorg-x11-server.changes | 10 +++ xorg-x11-server.spec | 4 + 4 files changed, 128 insertions(+) create mode 100644 u_CloseConsole-Don-t-report-FatalError-when-shutting-down.patch create mode 100644 u_connection-avoid-crash-when-CloseWellKnownConnections-gets-called-twice.patch diff --git a/u_CloseConsole-Don-t-report-FatalError-when-shutting-down.patch b/u_CloseConsole-Don-t-report-FatalError-when-shutting-down.patch new file mode 100644 index 0000000..90b3722 --- /dev/null +++ b/u_CloseConsole-Don-t-report-FatalError-when-shutting-down.patch @@ -0,0 +1,81 @@ +From: Egbert Eich +Date: Sat May 24 02:02:32 2014 +0200 +Subject: [PATCH]CloseConsole: Don't report FatalError() when shutting down +Patch-mainline: to be upstreamed +Git-commit: 4edf1fd15b9d2746f1f83165ab45efbe35af8de8 +Git-repo: +References: bnc#879666, bnc#879489 +Signed-off-by: Egbert Eich + +When encountering a problem while closing the console, don't report this +as a FatalError(). FatalError() will terminate the Xserver - no use calling +it when terminating anyway. Since FatalError() will call CloseConsole() +we would only come here again. + +Signed-off-by: Egbert Eich +--- + hw/xfree86/os-support/linux/lnx_init.c | 25 ++++++++++++++++--------- + 1 file changed, 16 insertions(+), 9 deletions(-) + +diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c +index bcb039f..c46bca9 100644 +--- a/hw/xfree86/os-support/linux/lnx_init.c ++++ b/hw/xfree86/os-support/linux/lnx_init.c +@@ -63,17 +63,24 @@ drain_console(int fd, void *closure) + } + + static void +-switch_to(int vt, const char *from) ++switch_to(int vt, const char *from, Bool fatal) + { + int ret; + + SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt)); +- if (ret < 0) +- FatalError("%s: VT_ACTIVATE failed: %s\n", from, strerror(errno)); +- ++ if (ret < 0) { ++ if (fatal) ++ FatalError("%s: VT_ACTIVATE failed: %s\n", from, strerror(errno)); ++ else ++ xf86Msg(X_WARNING, "%s: VT_ACTIVATE failed: %s\n", from, strerror(errno)); ++ } + SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt)); +- if (ret < 0) +- FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno)); ++ if (ret < 0) { ++ if (fatal) ++ FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno)); ++ else ++ xf86Msg(X_WARNING, "%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno)); ++ } + } + + void +@@ -194,7 +201,7 @@ xf86OpenConsole(void) + /* + * now get the VT. This _must_ succeed, or else fail completely. + */ +- switch_to(xf86Info.vtno, "xf86OpenConsole"); ++ switch_to(xf86Info.vtno, "xf86OpenConsole", TRUE); + + SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT)); + if (ret < 0) +@@ -255,7 +262,7 @@ xf86OpenConsole(void) + else { /* serverGeneration != 1 */ + if (!xf86Info.ShareVTs && xf86Info.autoVTSwitch) { + /* now get the VT */ +- switch_to(xf86Info.vtno, "xf86OpenConsole"); ++ switch_to(xf86Info.vtno, "xf86OpenConsole", TRUE); + } + } + } +@@ -305,7 +312,7 @@ xf86CloseConsole(void) + * Perform a switch back to the active VT when we were started + */ + if (activeVT >= 0) { +- switch_to(activeVT, "xf86CloseConsole"); ++ switch_to(activeVT, "xf86CloseConsole", FALSE); + activeVT = -1; + } + } diff --git a/u_connection-avoid-crash-when-CloseWellKnownConnections-gets-called-twice.patch b/u_connection-avoid-crash-when-CloseWellKnownConnections-gets-called-twice.patch new file mode 100644 index 0000000..f761d28 --- /dev/null +++ b/u_connection-avoid-crash-when-CloseWellKnownConnections-gets-called-twice.patch @@ -0,0 +1,33 @@ +From: Egbert Eich +Date: Fri May 23 20:08:29 2014 +0200 +Subject: [PATCH]connection: avoid crash when CloseWellKnownConnections() gets called twice +Patch-mainline: to be upstreamed +Git-commit: 74472c4e8e4c873014554f321ec2086066126297 +Git-repo: +References: bnc#879666, bnc#879489 +Signed-off-by: Egbert Eich + +CloseWellKnownConnections() closes all connections and deallocates +their data. Thus all entries in ListenTransConns are invalid. +To avoid access to those entries set ListenTransCount to 0. +This avoids crashes when CloseWellKnownConnections() is called twice +for instance when FatalError() is called on Xserver shutdown. + +Signed-off-by: Egbert Eich +--- + os/connection.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/os/connection.c b/os/connection.c +index 162e1d9..3c0b62a 100644 +--- a/os/connection.c ++++ b/os/connection.c +@@ -513,6 +513,8 @@ CloseWellKnownConnections(void) + + for (i = 0; i < ListenTransCount; i++) + _XSERVTransClose(ListenTransConns[i]); ++ ++ ListenTransCount = 0; + } + + static void diff --git a/xorg-x11-server.changes b/xorg-x11-server.changes index 6f241f0..0f7af54 100644 --- a/xorg-x11-server.changes +++ b/xorg-x11-server.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Sat May 24 09:16:08 UTC 2014 - eich@suse.com + +- Fix crash in abnormal condition (bnc#879666, bnc#879489): + * u_connection-avoid-crash-when-CloseWellKnownConnections-gets-called-twice.patch + Fix a crash when CloseWellKnownConnections() gets called twice. + This can happen if FatalError() is called in the shutdown procedure. + * u_CloseConsole-Don-t-report-FatalError-when-shutting-down.patch + Don't call FatalError() on errors in console ioctls when in shutdown. + ------------------------------------------------------------------- Mon May 19 10:52:32 UTC 2014 - sndirsch@suse.com diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index c0c08ae..81d6e04 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -150,6 +150,8 @@ Patch105: ux_xserver_xvfb-randr.patch Patch106: u_exa-only-draw-valid-trapezoids.patch # PATCH-FIX-UPSTREAM u_arch-Fix-image-and-bitmap-byte-order-for-ppc64le.patch -- sent to ML 2014-02-24 Patch107: u_arch-Fix-image-and-bitmap-byte-order-for-ppc64le.patch +Patch110: u_connection-avoid-crash-when-CloseWellKnownConnections-gets-called-twice.patch +Patch111: u_CloseConsole-Don-t-report-FatalError-when-shutting-down.patch Patch162: b_cache-xkbcomp-output-for-fast-start-up.patch Patch211: b_0001-Prevent-XSync-Alarms-from-senslessly-calling-CheckTr.patch @@ -225,6 +227,8 @@ cp %{SOURCE90} . %patch105 -p1 %patch106 -p1 %patch107 -p1 +%patch110 -p1 +%patch111 -p1 ### disabled for now #%patch162 -p1