mirror of
https://gitdl.cn/https://github.com/chakralinux/core.git
synced 2025-02-19 10:45:47 +08:00
linux: security patch for CVE-2014-0196
This commit is contained in:
parent
ba77fb472c
commit
5bf8440e51
80
linux/CVE-2014-0196.patch
Normal file
80
linux/CVE-2014-0196.patch
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
From 4291086b1f081b869c6d79e5b7441633dc3ace00 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Peter Hurley <peter@hurleysoftware.com>
|
||||||
|
Date: Sat, 3 May 2014 14:04:59 +0200
|
||||||
|
Subject: n_tty: Fix n_tty_write crash when echoing in raw mode
|
||||||
|
|
||||||
|
The tty atomic_write_lock does not provide an exclusion guarantee for
|
||||||
|
the tty driver if the termios settings are LECHO & !OPOST. And since
|
||||||
|
it is unexpected and not allowed to call TTY buffer helpers like
|
||||||
|
tty_insert_flip_string concurrently, this may lead to crashes when
|
||||||
|
concurrect writers call pty_write. In that case the following two
|
||||||
|
writers:
|
||||||
|
* the ECHOing from a workqueue and
|
||||||
|
* pty_write from the process
|
||||||
|
race and can overflow the corresponding TTY buffer like follows.
|
||||||
|
|
||||||
|
If we look into tty_insert_flip_string_fixed_flag, there is:
|
||||||
|
int space = __tty_buffer_request_room(port, goal, flags);
|
||||||
|
struct tty_buffer *tb = port->buf.tail;
|
||||||
|
...
|
||||||
|
memcpy(char_buf_ptr(tb, tb->used), chars, space);
|
||||||
|
...
|
||||||
|
tb->used += space;
|
||||||
|
|
||||||
|
so the race of the two can result in something like this:
|
||||||
|
A B
|
||||||
|
__tty_buffer_request_room
|
||||||
|
__tty_buffer_request_room
|
||||||
|
memcpy(buf(tb->used), ...)
|
||||||
|
tb->used += space;
|
||||||
|
memcpy(buf(tb->used), ...) ->BOOM
|
||||||
|
|
||||||
|
B's memcpy is past the tty_buffer due to the previous A's tb->used
|
||||||
|
increment.
|
||||||
|
|
||||||
|
Since the N_TTY line discipline input processing can output
|
||||||
|
concurrently with a tty write, obtain the N_TTY ldisc output_lock to
|
||||||
|
serialize echo output with normal tty writes. This ensures the tty
|
||||||
|
buffer helper tty_insert_flip_string is not called concurrently and
|
||||||
|
everything is fine.
|
||||||
|
|
||||||
|
Note that this is nicely reproducible by an ordinary user using
|
||||||
|
forkpty and some setup around that (raw termios + ECHO). And it is
|
||||||
|
present in kernels at least after commit
|
||||||
|
d945cb9cce20ac7143c2de8d88b187f62db99bdc (pty: Rework the pty layer to
|
||||||
|
use the normal buffering logic) in 2.6.31-rc3.
|
||||||
|
|
||||||
|
js: add more info to the commit log
|
||||||
|
js: switch to bool
|
||||||
|
js: lock unconditionally
|
||||||
|
js: lock only the tty->ops->write call
|
||||||
|
|
||||||
|
References: CVE-2014-0196
|
||||||
|
Reported-and-tested-by: Jiri Slaby <jslaby@suse.cz>
|
||||||
|
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
|
||||||
|
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
|
||||||
|
Cc: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
|
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
|
||||||
|
Cc: <stable@vger.kernel.org>
|
||||||
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||||
|
|
||||||
|
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
|
||||||
|
index 41fe8a0..fe9d129 100644
|
||||||
|
--- a/drivers/tty/n_tty.c
|
||||||
|
+++ b/drivers/tty/n_tty.c
|
||||||
|
@@ -2353,8 +2353,12 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
|
||||||
|
if (tty->ops->flush_chars)
|
||||||
|
tty->ops->flush_chars(tty);
|
||||||
|
} else {
|
||||||
|
+ struct n_tty_data *ldata = tty->disc_data;
|
||||||
|
+
|
||||||
|
while (nr > 0) {
|
||||||
|
+ mutex_lock(&ldata->output_lock);
|
||||||
|
c = tty->ops->write(tty, b, nr);
|
||||||
|
+ mutex_unlock(&ldata->output_lock);
|
||||||
|
if (c < 0) {
|
||||||
|
retval = c;
|
||||||
|
goto break_out;
|
||||||
|
--
|
||||||
|
cgit v0.10.1
|
||||||
|
|
@ -8,7 +8,7 @@ pkgname=('linux' 'linux-headers' 'linux-docs')
|
|||||||
_kernelname=${pkgname#linux}
|
_kernelname=${pkgname#linux}
|
||||||
_basekernel="3.12.15"
|
_basekernel="3.12.15"
|
||||||
pkgver=3.12.15
|
pkgver=3.12.15
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
url="http://www.kernel.org/"
|
url="http://www.kernel.org/"
|
||||||
license=('GPL2')
|
license=('GPL2')
|
||||||
@ -26,6 +26,8 @@ source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-${_basekernel}.tar.xz
|
|||||||
'aufs3-loopback.patch'
|
'aufs3-loopback.patch'
|
||||||
'aufs3.patch'
|
'aufs3.patch'
|
||||||
'config.aufs'
|
'config.aufs'
|
||||||
|
# cve patches (for tty issue, see patch)
|
||||||
|
CVE-2014-0196.patch
|
||||||
# standard config files for mkinitcpio ramdisk
|
# standard config files for mkinitcpio ramdisk
|
||||||
'linux.preset'
|
'linux.preset'
|
||||||
'change-default-console-loglevel.patch')
|
'change-default-console-loglevel.patch')
|
||||||
@ -80,6 +82,9 @@ prepare() {
|
|||||||
|
|
||||||
cat "${srcdir}/config.aufs" >> ./.config
|
cat "${srcdir}/config.aufs" >> ./.config
|
||||||
|
|
||||||
|
# CVE patch
|
||||||
|
patch -p1 -i ${srcdir}/CVE-2014-0196.patch
|
||||||
|
|
||||||
if [ "${_kernelname}" != "" ]; then
|
if [ "${_kernelname}" != "" ]; then
|
||||||
sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
|
sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
|
||||||
sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config
|
sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config
|
||||||
@ -328,3 +333,16 @@ package_linux-docs() {
|
|||||||
# remove a file already in linux package
|
# remove a file already in linux package
|
||||||
rm -f "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
|
rm -f "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
|
||||||
}
|
}
|
||||||
|
sha256sums=('f6116819985f0402392580704bf4b3b2f0dd6d0ab7f16b36a078c5788b17c423'
|
||||||
|
'6fa9dfea3d3bb41464652f07fd036886336be3fbb73e2c06baabd1005af1d2cf'
|
||||||
|
'316d7b429cac1d0b407eb3a36403ecc55813fd3941f517c58ab6514433a7ddd9'
|
||||||
|
'e9604c6d87ae87830c154c1b12065eb6361e503006025497741f15dbaa9fd3ff'
|
||||||
|
'03ec8d29245b222c21aee0a043ab9a48702d252d8460d44541fa9ea65bcea7ce'
|
||||||
|
'68426d50a9e774526d039be3e48cdff8f85ee8a37a77bd1aa0671885a09060ec'
|
||||||
|
'6c9a05787a392bd86da8f0fb66abd32a72808576aa7c635e5c2ae678134b59dd'
|
||||||
|
'86bf44ad0ea7c2afa4b195f8858f07eb8e35562c73290a8ba0ca723ee2a1932e'
|
||||||
|
'c4bc9e482581b2e58bb69a11e42636b5b75f0fa5bf0eb20a034594ec8f40f2d6'
|
||||||
|
'b1b1cf291bd68270b700eb21f19f7b052116d07dde492761227cd94bb775910c'
|
||||||
|
'00c522829c322004ea87ae3e228ebb73aa4b4160068078f8b46a7033490df21f'
|
||||||
|
'f0d90e756f14533ee67afda280500511a62465b4f76adcc5effa95a40045179c'
|
||||||
|
'faced4eb4c47c4eb1a9ee8a5bf8a7c4b49d6b4d78efbe426e410730e6267d182')
|
||||||
|
Loading…
Reference in New Issue
Block a user