]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.32/drm-reorder-set_property_atomic-to-avoid-returning-with-an-active-ww_ctx.patch
Linux 4.14.109
[thirdparty/kernel/stable-queue.git] / releases / 4.19.32 / drm-reorder-set_property_atomic-to-avoid-returning-with-an-active-ww_ctx.patch
1 From 227ad6d957898a88b1746e30234ece64d305f066 Mon Sep 17 00:00:00 2001
2 From: Chris Wilson <chris@chris-wilson.co.uk>
3 Date: Sun, 30 Dec 2018 12:28:42 +0000
4 Subject: drm: Reorder set_property_atomic to avoid returning with an active ww_ctx
5
6 From: Chris Wilson <chris@chris-wilson.co.uk>
7
8 commit 227ad6d957898a88b1746e30234ece64d305f066 upstream.
9
10 Delay the drm_modeset_acquire_init() until after we check for an
11 allocation failure so that we can return immediately upon error without
12 having to unwind.
13
14 WARNING: lock held when returning to user space!
15 4.20.0+ #174 Not tainted
16 ------------------------------------------------
17 syz-executor556/8153 is leaving the kernel with locks still held!
18 1 lock held by syz-executor556/8153:
19 #0: 000000005100c85c (crtc_ww_class_acquire){+.+.}, at:
20 set_property_atomic+0xb3/0x330 drivers/gpu/drm/drm_mode_object.c:462
21
22 Reported-by: syzbot+6ea337c427f5083ebdf2@syzkaller.appspotmail.com
23 Fixes: 144a7999d633 ("drm: Handle properties in the core for atomic drivers")
24 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
25 Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
26 Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
27 Cc: Sean Paul <sean@poorly.run>
28 Cc: David Airlie <airlied@linux.ie>
29 Cc: <stable@vger.kernel.org> # v4.14+
30 Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
31 Link: https://patchwork.freedesktop.org/patch/msgid/20181230122842.21917-1-chris@chris-wilson.co.uk
32 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
33
34 ---
35 drivers/gpu/drm/drm_mode_object.c | 5 +++--
36 1 file changed, 3 insertions(+), 2 deletions(-)
37
38 --- a/drivers/gpu/drm/drm_mode_object.c
39 +++ b/drivers/gpu/drm/drm_mode_object.c
40 @@ -458,12 +458,13 @@ static int set_property_atomic(struct dr
41 struct drm_modeset_acquire_ctx ctx;
42 int ret;
43
44 - drm_modeset_acquire_init(&ctx, 0);
45 -
46 state = drm_atomic_state_alloc(dev);
47 if (!state)
48 return -ENOMEM;
49 +
50 + drm_modeset_acquire_init(&ctx, 0);
51 state->acquire_ctx = &ctx;
52 +
53 retry:
54 if (prop == state->dev->mode_config.dpms_property) {
55 if (obj->type != DRM_MODE_OBJECT_CONNECTOR) {