Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1414252

[PATCH 3.14 11/23] pipe: Fix buffer offset after partially failed read

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 3.14 11/23] pipe: Fix buffer offset after partially failed read
Date 2016-06-05 23:50 +0200
Message-ID <rGO5K-3HY-91@gated-at.bofh.it> (permalink)
References <rGO5H-3HY-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


3.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ben Hutchings <ben@decadent.org.uk>

commit feae3ca2e5e1a8f44aa6290255d3d9709985d0b2 upstream.

Quoting the RHEL advisory:

> It was found that the fix for CVE-2015-1805 incorrectly kept buffer
> offset and buffer length in sync on a failed atomic read, potentially
> resulting in a pipe buffer state corruption. A local, unprivileged user
> could use this flaw to crash the system or leak kernel memory to user
> space. (CVE-2016-0774, Moderate)

The same flawed fix was applied to stable branches from 2.6.32.y to
3.14.y inclusive, and I was able to reproduce the issue on 3.2.y.
We need to give pipe_iov_copy_to_user() a separate offset variable
and only update the buffer offset if it succeeds.

References: https://rhn.redhat.com/errata/RHSA-2016-0103.html
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/pipe.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -401,6 +401,7 @@ pipe_read(struct kiocb *iocb, const stru
 			void *addr;
 			size_t chars = buf->len, remaining;
 			int error, atomic;
+			int offset;
 
 			if (chars > total_len)
 				chars = total_len;
@@ -414,9 +415,10 @@ pipe_read(struct kiocb *iocb, const stru
 
 			atomic = !iov_fault_in_pages_write(iov, chars);
 			remaining = chars;
+			offset = buf->offset;
 redo:
 			addr = ops->map(pipe, buf, atomic);
-			error = pipe_iov_copy_to_user(iov, addr, &buf->offset,
+			error = pipe_iov_copy_to_user(iov, addr, &offset,
 						      &remaining, atomic);
 			ops->unmap(pipe, buf, addr);
 			if (unlikely(error)) {
@@ -432,6 +434,7 @@ redo:
 				break;
 			}
 			ret += chars;
+			buf->offset += chars;
 			buf->len -= chars;
 
 			/* Was it a packet buffer? Clean up and exit */

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3.14 00/23] 3.14.72-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-05 23:50 +0200
  [PATCH 3.14 07/23] aacraid: Fix for aac_command_thread hang Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-05 23:50 +0200
  [PATCH 3.14 11/23] pipe: Fix buffer offset after partially failed read Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-05 23:50 +0200
    Re: [PATCH 3.14 11/23] pipe: Fix buffer offset after partially failed  read Jiri Slaby <jslaby@suse.cz> - 2016-06-07 16:00 +0200
      Re: [PATCH 3.14 11/23] pipe: Fix buffer offset after partially  failed read Ben Hutchings <ben@decadent.org.uk> - 2016-06-07 16:50 +0200
  [PATCH 3.14 08/23] cpuidle: Indicate when a device has been unregistered Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-05 23:50 +0200
  [PATCH 3.14 03/23] MIPS: ath79: make bootconsole wait for both THRE and TEMT Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  [PATCH 3.14 05/23] ath5k: Change led pin configuration for compaq c700 laptop Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  [PATCH 3.14 19/23] ext4: silence UBSAN in ext4_mb_init() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  [PATCH 3.14 04/23] Input: uinput - handle compat ioctl for UI_SET_PHYS Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  [PATCH 3.14 13/23] xen/events: Dont move disabled irqs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  [PATCH 3.14 10/23] rtlwifi: Fix logic error in enter/exit power-save mode Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  [PATCH 3.14 01/23] MIPS: math-emu: Fix jalr emulation when rd == $0 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  [PATCH 3.14 06/23] aacraid: Relinquish CPU during timeout wait Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  [PATCH 3.14 17/23] ext4: fix hang when processing corrupted orphaned inode list Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  [PATCH 3.14 02/23] MIPS: Fix siginfo.h to use strict posix types Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  [PATCH 3.14 18/23] ext4: address UBSAN warning in mb_find_order_for_block() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  [PATCH 3.14 15/23] drm/gma500: Fix possible out of bounds read Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-06 01:10 +0200
  Re: [PATCH 3.14 00/23] 3.14.72-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2016-06-06 19:30 +0200
    Re: [PATCH 3.14 00/23] 3.14.72-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-06-08 02:30 +0200
  Re: [PATCH 3.14 00/23] 3.14.72-stable review Guenter Roeck <linux@roeck-us.net> - 2016-06-07 05:50 +0200

csiph-web