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: Will Drewry <wad@chromium.org>, Kees Cook <keescook@chromium.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Luis Henriques <luis.henriques@canonical.com>
Subject: [PATCH 3.11 68/93] futex-prevent-requeue-pi-on-same-futex.patch futex: Forbid uaddr == uaddr2 in futex_requeue(..., requeue_pi=1)
Date: Mon, 23 Jun 2014 14:02:47 +0100	[thread overview]
Message-ID: <1403528592-2163-69-git-send-email-luis.henriques@canonical.com> (raw)
In-Reply-To: <1403528592-2163-1-git-send-email-luis.henriques@canonical.com>

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

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

From: Thomas Gleixner <tglx@linutronix.de>

commit e9c243a5a6de0be8e584c604d353412584b592f8 upstream.

If uaddr == uaddr2, then we have broken the rule of only requeueing from
a non-pi futex to a pi futex with this call.  If we attempt this, then
dangling pointers may be left for rt_waiter resulting in an exploitable
condition.

This change brings futex_requeue() in line with futex_wait_requeue_pi()
which performs the same check as per commit 6f7b0a2a5c0f ("futex: Forbid
uaddr == uaddr2 in futex_wait_requeue_pi()")

[ tglx: Compare the resulting keys as well, as uaddrs might be
  	different depending on the mapping ]

Fixes CVE-2014-3153.

Reported-by: Pinkie Pie
Signed-off-by: Will Drewry <wad@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 kernel/futex.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/kernel/futex.c b/kernel/futex.c
index a62447d335ab..83b44e9c26c3 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1294,6 +1294,13 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags,
 
 	if (requeue_pi) {
 		/*
+		 * Requeue PI only works on two distinct uaddrs. This
+		 * check is only valid for private futexes. See below.
+		 */
+		if (uaddr1 == uaddr2)
+			return -EINVAL;
+
+		/*
 		 * requeue_pi requires a pi_state, try to allocate it now
 		 * without any locks in case it fails.
 		 */
@@ -1331,6 +1338,15 @@ retry:
 	if (unlikely(ret != 0))
 		goto out_put_key1;
 
+	/*
+	 * The check above which compares uaddrs is not sufficient for
+	 * shared futexes. We need to compare the keys:
+	 */
+	if (requeue_pi && match_futex(&key1, &key2)) {
+		ret = -EINVAL;
+		goto out_put_keys;
+	}
+
 	hb1 = hash_futex(&key1);
 	hb2 = hash_futex(&key2);
 
@@ -2361,6 +2377,15 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
 	if (ret)
 		goto out_key2;
 
+	/*
+	 * The check above which compares uaddrs is not sufficient for
+	 * shared futexes. We need to compare the keys:
+	 */
+	if (match_futex(&q.key, &key2)) {
+		ret = -EINVAL;
+		goto out_put_keys;
+	}
+
 	/* Queue the futex_q, drop the hb lock, wait for wakeup. */
 	futex_wait_queue_me(hb, &q, to);
 
-- 
1.9.1


  parent reply	other threads:[~2014-06-23 13:05 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23 13:01 [3.11.y.z extended stable] Linux 3.11.10.12 stable review Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 01/93] cfg80211: free sme on connection failures Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 02/93] sched: Sanitize irq accounting madness Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 03/93] sched: Use CPUPRI_NR_PRIORITIES instead of MAX_RT_PRIO in cpupri check Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 04/93] net: cpsw: fix null dereference at probe Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 05/93] mac80211: fix suspend vs. association race Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 06/93] mac80211: fix on-channel remain-on-channel Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 07/93] af_iucv: wrong mapping of sent and confirmed skbs Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 08/93] net: filter: s390: fix JIT address randomization Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 09/93] perf: Limit perf_event_attr::sample_period to 63 bits Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 10/93] perf: Prevent false warning in perf_swevent_add Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 11/93] drm/gf119-/disp: fix nasty bug which can clobber SOR0's clock setup Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 12/93] drm/radeon: also try GART for CPU accessed buffers Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 13/93] drm/radeon: handle non-VGA class pci devices with ATRM Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 14/93] drm/radeon: fix register typo on si Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 15/93] drm/radeon: avoid segfault on device open when accel is not working Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 16/93] can: peak_pci: prevent use after free at netdev removal Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 17/93] nfsd4: remove lockowner when removing lock stateid Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 18/93] nfsd4: warn on finding lockowner without stateid's Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 19/93] hwpoison, hugetlb: lock_page/unlock_page does not match for handling a free hugepage Luis Henriques
2014-06-23 13:01 ` [PATCH 3.11 20/93] mm/memory-failure.c: fix memory leak by race between poison and unpoison Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 21/93] netfilter: ipv4: defrag: set local_df flag on defragmented skb Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 22/93] ARM: OMAP3: clock: Back-propagate rate change from cam_mclk to dpll4_m5 on all OMAP3 platforms Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 23/93] dma: dw: allow shared interrupts Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 24/93] dmaengine: dw: went back to plain {request,free}_irq() calls Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 25/93] ARM: omap5: hwmod_data: Correct IDLEMODE for McPDM Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 26/93] Input: synaptics - add min/max quirk for the ThinkPad W540 Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 27/93] futex: Add another early deadlock detection check Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 28/93] futex: Prevent attaching to kernel threads Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 29/93] ARM: OMAP4: Fix the boot regression with CPU_IDLE enabled Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 30/93] cpufreq: remove race while accessing cur_policy Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 31/93] cpufreq: cpu0: drop wrong devm usage Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 32/93] ARM: imx: fix error handling in ipu device registration Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 33/93] ALSA: hda - Fix onboard audio on Intel H97/Z97 chipsets Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 34/93] ARM: 8051/1: put_user: fix possible data corruption in put_user Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 35/93] ARM: 8064/1: fix v7-M signal return Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 36/93] Input: synaptics - T540p - unify with other LEN0034 models Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 37/93] drm/i915: Only copy back the modified fields to userspace from execbuffer Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 38/93] dm cache: always split discards on cache block boundaries Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 39/93] powerpc: Fix 64 bit builds with binutils 2.24 Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 40/93] powerpc, kexec: Fix "Processor X is stuck" issue during kexec from ST mode Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 41/93] rtmutex: Fix deadlock detector for real Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 42/93] drm/radeon: don't allow RADEON_GEM_DOMAIN_CPU for command submission Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 43/93] audit: restore order of tty and ses fields in log output Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 44/93] drm/nouveau/pm/fan: drop the fan lock in fan_update() before rescheduling Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 45/93] leds: leds-pwm: properly clean up after probe failure Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 46/93] clk: vexpress: NULL dereference on error path Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 47/93] [SCSI] fix our current target reap infrastructure Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 48/93] [SCSI] dual scan thread bug fix Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 49/93] genirq: Provide irq_force_affinity fallback for non-SMP Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 50/93] i2c: designware: Mask all interrupts during i2c controller enable Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 51/93] crypto: s390 - fix aes,des ctr mode concurrency finding Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 52/93] Staging: speakup: Move pasting into a work item Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 53/93] USB: Avoid runtime suspend loops for HCDs that can't handle suspend/resume Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 54/93] can: only rename enabled led triggers when changing the netdev name Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 55/93] USB: io_ti: fix firmware download on big-endian machines (part 2) Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 56/93] USB: ftdi_sio: add NovaTech OrionLXm product ID Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 57/93] USB: serial: option: add support for Novatel E371 PCIe card Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 58/93] USB: cdc-wdm: properly include types.h Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 59/93] md: always set MD_RECOVERY_INTR when aborting a reshape or other "resync" Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 60/93] xhci: delete endpoints from bandwidth list before freeing whole device Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 61/93] md: always set MD_RECOVERY_INTR when interrupting a reshape thread Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 62/93] ALSA: hda/analog - Fix silent output on ASUS A8JN Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 63/93] ALSA: hda/realtek - Correction of fixup codes for PB V7900 laptop Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 64/93] ALSA: hda/realtek - Fix COEF widget NID for ALC260 replacer fixup Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 65/93] iser-target: Add missing target_put_sess_cmd for ImmedateData failure Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 66/93] iscsi-target: Fix wrong buffer / buffer overrun in iscsi_change_param_value() Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 67/93] percpu-refcount: fix usage of this_cpu_ops Luis Henriques
2014-06-23 13:02 ` Luis Henriques [this message]
2014-06-23 13:02 ` [PATCH 3.11 69/93] futex: Validate atomic acquisition in futex_lock_pi_atomic() Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 70/93] futex: Always cleanup owner tid in unlock_pi Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 71/93] futex: Make lookup_pi_state more robust Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 72/93] target: Fix alua_access_state attribute OOPs for un-configured devices Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 73/93] mm: rmap: fix use-after-free in __put_anon_vma Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 74/93] usb: cdc-wdm: export cdc-wdm uapi header Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 75/93] staging: comedi: ni_daq_700: add mux settling delay Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 76/93] kvm: free resources after canceling async_pf Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 77/93] kvm: remove .done from struct kvm_async_pf Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 78/93] KVM: async_pf: mm->mm_users can not pin apf->mm Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 79/93] mm/page-writeback.c: fix divide by zero in pos_ratio_polynom Luis Henriques
2014-06-23 13:02 ` [PATCH 3.11 80/93] dma: mv_xor: Flush descriptors before activating a channel Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 81/93] skbuff: skb_segment: orphan frags before copying Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 82/93] Target/iscsi,iser: Avoid accepting transport connections during stop stage Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 83/93] iser-target: Fix multi network portal shutdown regression Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 84/93] target: Allow READ_CAPACITY opcode in ALUA Standby access state Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 85/93] mm: compaction: reset cached scanner pfn's before reading them Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 86/93] mm: compaction: detect when scanners meet in isolate_freepages Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 87/93] MIPS: asm: thread_info: Add _TIF_SECCOMP flag Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 88/93] perf: Fix race in removing an event Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 89/93] hwmon: (ntc_thermistor) Fix dependencies Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 90/93] hwmon: (ntc_thermistor) Fix OF device ID mapping Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 91/93] fs,userns: Change inode_capable to capable_wrt_inode_uidgid Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 92/93] auditsc: audit_krule mask accesses need bounds checking Luis Henriques
2014-06-23 13:03 ` [PATCH 3.11 93/93] [SCSI] megaraid: Use resource_size_t for PCI resources, not long 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=1403528592-2163-69-git-send-email-luis.henriques@canonical.com \
    --to=luis.henriques@canonical.com \
    --cc=keescook@chromium.org \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=wad@chromium.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®