All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Jann Horn <jannh@google.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 4.18 17/44] drm: fix use-after-free read in drm_mode_create_lease_ioctl()
Date: Thu, 11 Oct 2018 17:39:55 +0200	[thread overview]
Message-ID: <20181011152453.238337437@linuxfoundation.org> (raw)
In-Reply-To: <20181011152452.571669983@linuxfoundation.org>

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

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

From: Jann Horn <jannh@google.com>

commit 12d43deb1ee639d01a2a8d2a7a4cc8ad31224475 upstream.

fd_install() moves the reference given to it into the file descriptor table
of the current process. If the current process is multithreaded, then
immediately after fd_install(), another thread can close() the file
descriptor and cause the file's resources to be cleaned up.

Since the reference to "lessee" is held by the file, we must not access
"lessee" after the fd_install() call.

As far as I can tell, to reach this codepath, the caller must have an open
file descriptor to a DRI device in master mode. I'm not sure what the
requirements for that are.

Signed-off-by: Jann Horn <jannh@google.com>
Fixes: 62884cd386b8 ("drm: Add four ioctls for managing drm mode object leases [v7]")
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20181001153117.216923-1-jannh@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpu/drm/drm_lease.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/gpu/drm/drm_lease.c
+++ b/drivers/gpu/drm/drm_lease.c
@@ -566,14 +566,14 @@ int drm_mode_create_lease_ioctl(struct d
 	lessee_priv->is_master = 1;
 	lessee_priv->authenticated = 1;
 
-	/* Hook up the fd */
-	fd_install(fd, lessee_file);
-
 	/* Pass fd back to userspace */
 	DRM_DEBUG_LEASE("Returning fd %d id %d\n", fd, lessee->lessee_id);
 	cl->fd = fd;
 	cl->lessee_id = lessee->lessee_id;
 
+	/* Hook up the fd */
+	fd_install(fd, lessee_file);
+
 	DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl succeeded\n");
 	return 0;
 



  parent reply	other threads:[~2018-10-11 15:47 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-11 15:39 [PATCH 4.18 00/44] 4.18.14-stable review Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 01/44] perf/core: Add sanity check to deal with pinned event failure Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 02/44] mm: migration: fix migration of huge PMD shared pages Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 03/44] mm, thp: fix mlocking THP page with migration enabled Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 04/44] mm/vmstat.c: skip NR_TLB_REMOTE_FLUSH* properly Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 05/44] KVM: x86: fix L1TFs MMIO GFN calculation Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 06/44] KVM: VMX: check for existence of secondary exec controls before accessing Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 07/44] blk-mq: I/O and timer unplugs are inverted in blktrace Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 08/44] pstore/ram: Fix failure-path memory leak in ramoops_init Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 09/44] clocksource/drivers/timer-atmel-pit: Properly handle error cases Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 10/44] fbdev/omapfb: fix omapfb_memory_read infoleak Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 11/44] xen-netback: fix input validation in xenvif_set_hash_mapping() Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 12/44] mmc: core: Fix debounce time to use microseconds Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 13/44] mmc: slot-gpio: Fix debounce time to use miliseconds again Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 14/44] mac80211: allocate TXQs for active monitor interfaces Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 15/44] drm/amdgpu: Fix vce work queue was not cancelled when suspend Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 16/44] drm/syncobj: Dont leak fences when WAIT_FOR_SUBMIT is set Greg Kroah-Hartman
2018-10-11 15:39 ` Greg Kroah-Hartman [this message]
2018-10-11 15:39 ` [PATCH 4.18 18/44] x86/vdso: Fix asm constraints on vDSO syscall fallbacks Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 19/44] selftests/x86: Add clock_gettime() tests to test_vdso Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 20/44] x86/vdso: Only enable vDSO retpolines when enabled and supported Greg Kroah-Hartman
2018-10-11 15:39 ` [PATCH 4.18 21/44] x86/vdso: Fix vDSO syscall fallback asm constraint regression Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 22/44] PCI: Reprogram bridge prefetch registers on resume Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 23/44] mac80211: fix setting IEEE80211_KEY_FLAG_RX_MGMT for AP mode keys Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 24/44] PM / core: Clear the direct_complete flag on errors Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 25/44] dm mpath: fix attached_handler_name leak and dangling hw_handler_name pointer Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 26/44] dm cache metadata: ignore hints array being too small during resize Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 27/44] dm cache: fix resize crash if user doesnt reload cache table Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 28/44] xhci: Add missing CAS workaround for Intel Sunrise Point xHCI Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 29/44] usb: xhci-mtk: resume USB3 roothub first Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 30/44] USB: serial: simple: add Motorola Tetra MTP6550 id Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 31/44] USB: serial: option: improve Quectel EP06 detection Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 32/44] USB: serial: option: add two-endpoints device-id flag Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 33/44] usb: cdc_acm: Do not leak URB buffers Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 34/44] tty: Drop tty->count on tty_reopen() failure Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 35/44] of: unittest: Disable interrupt node tests for old world MAC systems Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 36/44] powerpc: Avoid code patching freed init sections Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 37/44] powerpc/lib: fix book3s/32 boot failure due to code patching Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 38/44] ARC: clone syscall to setp r25 as thread pointer Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 39/44] f2fs: fix invalid memory access Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 40/44] tipc: call start and done ops directly in __tipc_nl_compat_dumpit() Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 41/44] ucma: fix a use-after-free in ucma_resolve_ip() Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 42/44] ubifs: Check for name being NULL while mounting Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 43/44] rds: rds_ib_recv_alloc_cache() should call alloc_percpu_gfp() instead Greg Kroah-Hartman
2018-10-11 15:40 ` [PATCH 4.18 44/44] ath10k: fix scan crash due to incorrect length calculation Greg Kroah-Hartman
2018-10-11 22:34 ` [PATCH 4.18 00/44] 4.18.14-stable review Shuah Khan
2018-10-12  4:22 ` Naresh Kamboju
2018-10-12 10:24   ` Greg Kroah-Hartman
2018-10-12 15:43 ` Guenter Roeck

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=20181011152453.238337437@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.