summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.3/0011-drm-Fix-authentication-kernel-crash.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.3/0011-drm-Fix-authentication-kernel-crash.patch')
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.3/0011-drm-Fix-authentication-kernel-crash.patch91
1 files changed, 91 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.3/0011-drm-Fix-authentication-kernel-crash.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.3/0011-drm-Fix-authentication-kernel-crash.patch
new file mode 100644
index 00000000..85f719ef
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.3/0011-drm-Fix-authentication-kernel-crash.patch
@@ -0,0 +1,91 @@
1From eb46186bf6a5226ef40a011986bd206874a940b6 Mon Sep 17 00:00:00 2001
2From: Thomas Hellstrom <thellstrom@vmware.com>
3Date: Tue, 24 Jan 2012 18:54:21 +0100
4Subject: [PATCH 11/90] drm: Fix authentication kernel crash
5
6commit 598781d71119827b454fd75d46f84755bca6f0c6 upstream.
7
8If the master tries to authenticate a client using drm_authmagic and
9that client has already closed its drm file descriptor,
10either wilfully or because it was terminated, the
11call to drm_authmagic will dereference a stale pointer into kmalloc'ed memory
12and corrupt it.
13
14Typically this results in a hard system hang.
15
16This patch fixes that problem by removing any authentication tokens
17(struct drm_magic_entry) open for a file descriptor when that file
18descriptor is closed.
19
20Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
21Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
22Signed-off-by: Dave Airlie <airlied@redhat.com>
23Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24---
25 drivers/gpu/drm/drm_auth.c | 6 +++++-
26 drivers/gpu/drm/drm_fops.c | 5 +++++
27 include/drm/drmP.h | 1 +
28 3 files changed, 11 insertions(+), 1 deletions(-)
29
30diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
31index 3f46772..ba23790 100644
32--- a/drivers/gpu/drm/drm_auth.c
33+++ b/drivers/gpu/drm/drm_auth.c
34@@ -101,7 +101,7 @@ static int drm_add_magic(struct drm_master *master, struct drm_file *priv,
35 * Searches and unlinks the entry in drm_device::magiclist with the magic
36 * number hash key, while holding the drm_device::struct_mutex lock.
37 */
38-static int drm_remove_magic(struct drm_master *master, drm_magic_t magic)
39+int drm_remove_magic(struct drm_master *master, drm_magic_t magic)
40 {
41 struct drm_magic_entry *pt;
42 struct drm_hash_item *hash;
43@@ -136,6 +136,8 @@ static int drm_remove_magic(struct drm_master *master, drm_magic_t magic)
44 * If there is a magic number in drm_file::magic then use it, otherwise
45 * searches an unique non-zero magic number and add it associating it with \p
46 * file_priv.
47+ * This ioctl needs protection by the drm_global_mutex, which protects
48+ * struct drm_file::magic and struct drm_magic_entry::priv.
49 */
50 int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
51 {
52@@ -173,6 +175,8 @@ int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
53 * \return zero if authentication successed, or a negative number otherwise.
54 *
55 * Checks if \p file_priv is associated with the magic number passed in \arg.
56+ * This ioctl needs protection by the drm_global_mutex, which protects
57+ * struct drm_file::magic and struct drm_magic_entry::priv.
58 */
59 int drm_authmagic(struct drm_device *dev, void *data,
60 struct drm_file *file_priv)
61diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
62index 4911e1d..828bf65 100644
63--- a/drivers/gpu/drm/drm_fops.c
64+++ b/drivers/gpu/drm/drm_fops.c
65@@ -487,6 +487,11 @@ int drm_release(struct inode *inode, struct file *filp)
66 (long)old_encode_dev(file_priv->minor->device),
67 dev->open_count);
68
69+ /* Release any auth tokens that might point to this file_priv,
70+ (do that under the drm_global_mutex) */
71+ if (file_priv->magic)
72+ (void) drm_remove_magic(file_priv->master, file_priv->magic);
73+
74 /* if the master has gone away we can't do anything with the lock */
75 if (file_priv->minor->master)
76 drm_master_release(dev, filp);
77diff --git a/include/drm/drmP.h b/include/drm/drmP.h
78index 1f9e951..bf4b2dc 100644
79--- a/include/drm/drmP.h
80+++ b/include/drm/drmP.h
81@@ -1328,6 +1328,7 @@ extern int drm_getmagic(struct drm_device *dev, void *data,
82 struct drm_file *file_priv);
83 extern int drm_authmagic(struct drm_device *dev, void *data,
84 struct drm_file *file_priv);
85+extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic);
86
87 /* Cache management (drm_cache.c) */
88 void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
89--
901.7.7.4
91