mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luis Henriques <luis.henriques@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: PaX Team <pageexec@freemail.hu>,
	"H. Peter Anvin" <hpa@linux.intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Luis Henriques <luis.henriques@canonical.com>
Subject: [PATCH 3.5 74/88] x86, x32: Correct invalid use of user timespec in the kernel
Date: Fri,  7 Feb 2014 11:23:11 +0000	[thread overview]
Message-ID: <1391772205-22239-75-git-send-email-luis.henriques@canonical.com> (raw)
In-Reply-To: <1391772205-22239-1-git-send-email-luis.henriques@canonical.com>

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

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

From: PaX Team <pageexec@freemail.hu>

commit 2def2ef2ae5f3990aabdbe8a755911902707d268 upstream.

The x32 case for the recvmsg() timout handling is broken:

  asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
                                      unsigned int vlen, unsigned int flags,
                                      struct compat_timespec __user *timeout)
  {
          int datagrams;
          struct timespec ktspec;

          if (flags & MSG_CMSG_COMPAT)
                  return -EINVAL;

          if (COMPAT_USE_64BIT_TIME)
                  return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
                                        flags | MSG_CMSG_COMPAT,
                                        (struct timespec *) timeout);
          ...

The timeout pointer parameter is provided by userland (hence the __user
annotation) but for x32 syscalls it's simply cast to a kernel pointer
and is passed to __sys_recvmmsg which will eventually directly
dereference it for both reading and writing.  Other callers to
__sys_recvmmsg properly copy from userland to the kernel first.

The bug was introduced by commit ee4fa23c4bfc ("compat: Use
COMPAT_USE_64BIT_TIME in net/compat.c") and should affect all kernels
since 3.4 (and perhaps vendor kernels if they backported x32 support
along with this code).

Note that CONFIG_X86_X32_ABI gets enabled at build time and only if
CONFIG_X86_X32 is enabled and ld can build x32 executables.

Other uses of COMPAT_USE_64BIT_TIME seem fine.

This addresses CVE-2014-0038.

Signed-off-by: PaX Team <pageexec@freemail.hu>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 net/compat.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/net/compat.c b/net/compat.c
index 1d223d5..9c0fca1 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -781,21 +781,16 @@ asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
 	if (flags & MSG_CMSG_COMPAT)
 		return -EINVAL;
 
-	if (COMPAT_USE_64BIT_TIME)
-		return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
-				      flags | MSG_CMSG_COMPAT,
-				      (struct timespec *) timeout);
-
 	if (timeout == NULL)
 		return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
 				      flags | MSG_CMSG_COMPAT, NULL);
 
-	if (get_compat_timespec(&ktspec, timeout))
+	if (compat_get_timespec(&ktspec, timeout))
 		return -EFAULT;
 
 	datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
 				   flags | MSG_CMSG_COMPAT, &ktspec);
-	if (datagrams > 0 && put_compat_timespec(&ktspec, timeout))
+	if (datagrams > 0 && compat_put_timespec(&ktspec, timeout))
 		datagrams = -EFAULT;
 
 	return datagrams;
-- 
1.8.3.2


  parent reply	other threads:[~2014-02-07 11:30 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07 11:21 [3.5.y.z extended stable] Linux 3.5.7.30 stable review Luis Henriques
2014-02-07 11:21 ` [PATCH 3.5 01/88] ext4: fix deadlock when writing in ENOSPC conditions Luis Henriques
2014-02-07 11:21 ` [PATCH 3.5 02/88] writeback: Fix data corruption on NFS Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 03/88] md/raid5: Fix possible confusion when multiple write errors occur Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 04/88] md/raid10: fix two bugs in handling of known-bad-blocks Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 05/88] md/raid10: fix bug when raid10 recovery fails to recover a block Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 06/88] hwmon: (coretemp) Fix truncated name of alarm attributes Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 07/88] nilfs2: fix segctor bug that causes file system corruption Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 08/88] mm: fix crash when using XFS on loopback Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 09/88] vfs: In d_path don't call d_dname on a mount point Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 10/88] perf/x86/amd/ibs: Fix waking up from S3 for AMD family 10h Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 11/88] staging: comedi: 8255_pci: fix for newer PCI-DIO48H Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 12/88] mm/memory-failure.c: recheck PageHuge() after hugetlb page migrate successfully Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 13/88] serial: amba-pl011: use port lock to guard control register access Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 14/88] rtlwifi: rtl8192cu: Fix W=1 build warning Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 15/88] rtlwifi: rtl8192cu: Add new firmware Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 16/88] rtlwifi: Set the link state Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 17/88] rtlwifi: rtl8192c: Add new definitions in the dm_common header Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 18/88] rtlwifi: rtl8192cu: Fix some code in RF handling Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 19/88] NFSv4: OPEN must handle the NFS4ERR_IO return code correctly Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 20/88] parport: parport_pc: remove double PCI ID for NetMos Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 21/88] staging: vt6656: [BUG] BBvUpdatePreEDThreshold Always set sensitivity on bScanning Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 22/88] [SCSI] bfa: Chinook quad port 16G FC HBA claim issue Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 23/88] usb: option: add new zte 3g modem pids to option driver Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 24/88] [media] dib8000: make 32 bits read atomic Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 25/88] serial: add support for 200 v3 series Titan card Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 26/88] usb: xhci: Check for XHCI_PLAT in xhci_cleanup_msix() Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 27/88] x86/efi: Fix off-by-one bug in EFI Boot Services reservation Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 28/88] perf kvm: Fix kvm report without guestmount Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 29/88] mtd: mxc_nand: remove duplicated ecc_stats counting Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 30/88] xen/pvhvm: If xen_platform_pci=0 is set don't blow up (v4) Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 31/88] USB: serial: add support for iBall 3.5G connect usb modem Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 32/88] USB: Nokia 502 is an unusual device Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 33/88] USB: cypress_m8: fix ring-indicator detection and reporting Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 34/88] ALSA: rme9652: fix a missing comma in channel_map_9636_ds[] Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 35/88] sunrpc: Fix infinite loop in RPC state machine Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 36/88] spidev: fix hang when transfer_one_message fails Luis Henriques
2014-02-07 18:17   ` Daniel Santos
2014-02-07 18:37     ` Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 37/88] dm thin: initialize dm_thin_new_mapping returned by get_next_mapping Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 38/88] SELinux: Fix memory leak upon loading policy Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 39/88] drm/radeon: warn users when hw_i2c is enabled (v2) Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 40/88] USB: ftdi_sio: added CS5 quirk for broken smartcard readers Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 41/88] serial: 8250: enable UART_BUG_NOMSR for Tegra Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 42/88] dm: wait until embedded kobject is released before destroying a device Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 43/88] dm space map common: make sure new space is used during extend Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 44/88] ASoC: adau1701: Fix ADAU1701_SEROCTL_WORD_LEN_16 constant Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 45/88] radeon/pm: Guard access to rdev->pm.power_state array Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 46/88] drm/radeon: skip colorbuffer checking if COLOR_INFO.FORMAT is set to INVALID Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 47/88] staging: r8712u: Set device type to wlan Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 48/88] ALSA: Enable CONFIG_ZONE_DMA for smaller PCI DMA masks Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 49/88] mmc: atmel-mci: fix timeout errors in SDIO mode when using DMA Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 50/88] rtlwifi: rtl8192cu: Add new device ID Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 51/88] mwifiex: add missing endian conversion for fw_tsf Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 52/88] b43: Fix lockdep splat Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 53/88] b43: Fix unload oops if firmware is not available Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 54/88] b43legacy: " Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 55/88] nfs4.1: properly handle ENOTSUP in SECINFO_NO_NAME Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 56/88] audit: correct a type mismatch in audit_syscall_exit() Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 57/88] md/raid5: fix long-standing problem with bitmap handling on write failure Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 58/88] drm/radeon: set the full cache bit for fences on r7xx+ Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 59/88] hp_accel: Add a new PnP ID HPQ6007 for new HP laptops Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 60/88] intel-iommu: fix off-by-one in pagetable freeing Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 61/88] fuse: fix pipe_buf_operations Luis Henriques
2014-02-07 11:22 ` [PATCH 3.5 62/88] drm/cirrus: correct register values for 16bpp Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 63/88] IB/qib: Fix QP check when looping back to/from QP1 Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 64/88] ore: Fix wrong math in allocation of per device BIO Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 65/88] b43: fix the wrong assignment of status.freq in b43_rx() Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 66/88] KVM: PPC: e500: Fix bad address type in deliver_tlb_misss() Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 67/88] Btrfs: handle EAGAIN case properly in btrfs_drop_snapshot() Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 68/88] ACPI / init: Flag use of ACPI and ACPI idioms for power supplies to regulator API Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 69/88] powerpc: Make sure "cache" directory is removed when offlining cpu Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 70/88] drm/radeon/DCE4+: clear bios scratch dpms bit (v2) Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 71/88] mm/page-writeback.c: fix dirty_balance_reserve subtraction from dirtyable memory Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 72/88] target/iscsi: Fix network portal creation race Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 73/88] mm, oom: base root bonus on current usage Luis Henriques
2014-02-07 11:23 ` Luis Henriques [this message]
2014-02-07 11:23 ` [PATCH 3.5 75/88] alpha: fix broken network checksum Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 76/88] ARM: at91: smc: bug fix in sam9_smc_cs_read() Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 77/88] KVM: s390: fix diagnose code extraction Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 78/88] e752x_edac: Fix pci_dev usage count Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 79/88] lib/decompressors: fix "no limit" output buffer length Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 80/88] bnx2x: fix DMA unmapping of TSO split BDs Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 81/88] inet_diag: fix inet_diag_dump_icsk() timewait socket state logic Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 82/88] net: avoid reference counter overflows on fib_rules in multicast forwarding Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 83/88] net,via-rhine: Fix tx_timeout handling Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 84/88] mm: hugetlbfs: fix hugetlbfs optimization Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 85/88] usb: core: get config and string descriptors for unauthorized devices Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 86/88] tty/serial: at91: Handle shutdown more safely Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 87/88] slub: Fix calculation of cpu slabs Luis Henriques
2014-02-07 11:23 ` [PATCH 3.5 88/88] turbostat: Use GCC's CPUID functions to support PIC Luis Henriques

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391772205-22239-75-git-send-email-luis.henriques@canonical.com \
    --to=luis.henriques@canonical.com \
    --cc=hpa@linux.intel.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pageexec@freemail.hu \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®