From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60E6838398F; Sat, 12 Sep 2026 18:21:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789237289; cv=none; b=MY4ydqKm8szwHeK5z40Zb7jbpgwHhaoBfa7eiWJWCwrDNyGAoZB1MY5iAf6IZ8vvW6VWFyAmcqgoXswXstuU00WH6ha7bp/Kp1kW/LmEp3PjBoblP7uaAqUB8cQzM76496ZvBCnWOjEcdf3+8zDpwDrVljRQW+rUtN5UVDWKfjA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789237289; c=relaxed/simple; bh=P3OxwaXXKQKFbno/PuMg3UIBwDKSOkSN+K6cx9hQq2A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q+oPmHxy7WiUP4HZ9Hlzim4WthIhpHCWnSpf0HyIpKMSfvVwQdItL1Aqek+YUJAlSkREier6uKn4G654OYPbskR54BHs2f1Li5k97TY1Oay9AiWnUdKmDBurF4VABBryc0s8itT0xqiQ4LX0Zh6495E44fe/IvDP+tZXwizCepM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ct8Gpu8D; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ct8Gpu8D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 355C61F000FF; Sat, 12 Sep 2026 18:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789237288; bh=+JJLhTPXWvdfes4nsbTl2V+RBLQV1makuwllqLubBzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ct8Gpu8DNzPf8OOGC1O0gbQ4Mj0T7DI8NEthBoyxbFLY1Ku7j6ol2e1NkrnLhAoIv V+mUXmKtCMlSVeiUSTKJOsBDs00pu4ZIR+Yj+iRP06mr8WpbRLM6Kk8xvyX2lKqBpp /bEBq9pQPjUTH4cbTFlvyQOxE4DwG5uF5wK/829Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zack Rusin , Ian Forbes , Alexander Martyniuk , Sasha Levin Subject: [PATCH 5.15 229/935] drm/vmwgfx: drop dma_buf reference on foreign-fd prime import Date: Sat, 12 Sep 2026 08:54:19 +0200 Message-ID: <20260912065532.079468615@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065526.833703348@linuxfoundation.org> References: <20260912065526.833703348@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zack Rusin commit f739416dc555fa205a785e5135d73fa39b26f35d upstream. ttm_prime_fd_to_handle() returns -ENOSYS when the imported fd's dma_buf->ops do not match the ttm_object_device's ops, but does so without releasing the reference acquired by dma_buf_get(). Any unprivileged renderD client passing a non-vmwgfx prime fd through the DRM_VMW_GB_SURFACE_REF{,_EXT} path leaks one dma_buf reference per call and indefinitely pins the foreign exporter's GEM resources. Funnel the error path through the existing dma_buf_put() so the reference is always dropped. Fixes: 65981f7681ab ("drm/ttm: Add a minimal prime implementation for ttm base objects") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Zack Rusin Reviewed-by: Ian Forbes Link: https://patch.msgid.link/20260505222728.519626-6-zack.rusin@broadcom.com Signed-off-by: Alexander Martyniuk Signed-off-by: Sasha Levin --- drivers/gpu/drm/vmwgfx/ttm_object.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/ttm_object.c b/drivers/gpu/drm/vmwgfx/ttm_object.c index 123ab2cbec484..40862775916be 100644 --- a/drivers/gpu/drm/vmwgfx/ttm_object.c +++ b/drivers/gpu/drm/vmwgfx/ttm_object.c @@ -658,14 +658,17 @@ int ttm_prime_fd_to_handle(struct ttm_object_file *tfile, if (IS_ERR(dma_buf)) return PTR_ERR(dma_buf); - if (dma_buf->ops != &tdev->ops) - return -ENOSYS; + if (dma_buf->ops != &tdev->ops) { + ret = -ENOSYS; + goto out; + } prime = (struct ttm_prime_object *) dma_buf->priv; base = &prime->base; *handle = base->handle; ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL, false); +out: dma_buf_put(dma_buf); return ret; -- 2.53.0