lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1449676635-23490-1-git-send-email-colin.king@canonical.com>
Date:	Wed,  9 Dec 2015 15:57:15 +0000
From:	Colin King <colin.king@...onical.com>
To:	Dave Airlie <airlied@...hat.com>,
	Frediano Ziglio <fziglio@...hat.com>,
	dri-devel@...ts.freedesktop.org
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] drm/qxl: add locking to prevent race on garbage collection

From: Colin Ian King <colin.king@...onical.com>

I've seen the driver break a few times in qxl_garbage_collect
and I believe this is a race condition on qxl_release_free.
Adding extra locking around the release free addresses the
breakage.

Signed-off-by: Colin Ian King <colin.king@...onical.com>
---
 drivers/gpu/drm/qxl/qxl_cmd.c     | 3 +++
 drivers/gpu/drm/qxl/qxl_release.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
index fdc1833..9474622 100644
--- a/drivers/gpu/drm/qxl/qxl_cmd.c
+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
@@ -243,7 +243,10 @@ int qxl_garbage_collect(struct qxl_device *qdev)
 			}
 			id = next_id;
 
+			mutex_lock(&qdev->release_mutex);
 			qxl_release_free(qdev, release);
+			mutex_unlock(&qdev->release_mutex);
+
 			++i;
 		}
 	}
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
index 4efa8e2..2713f6d 100644
--- a/drivers/gpu/drm/qxl/qxl_release.c
+++ b/drivers/gpu/drm/qxl/qxl_release.c
@@ -360,8 +360,8 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
 	if (!qdev->current_release_bo[cur_idx]) {
 		ret = qxl_release_bo_alloc(qdev, &qdev->current_release_bo[cur_idx]);
 		if (ret) {
-			mutex_unlock(&qdev->release_mutex);
 			qxl_release_free(qdev, *release);
+			mutex_unlock(&qdev->release_mutex);
 			return ret;
 		}
 	}
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ