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: <20241031140730.2406181-1-sui.jingfeng@linux.dev>
Date: Thu, 31 Oct 2024 22:07:30 +0800
From: Sui Jingfeng <sui.jingfeng@...ux.dev>
To: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
	Maxime Ripard <mripard@...nel.org>,
	Thomas Zimmermann <tzimmermann@...e.de>
Cc: David Airlie <airlied@...il.com>,
	Simona Vetter <simona@...ll.ch>,
	dri-devel@...ts.freedesktop.org,
	linux-kernel@...r.kernel.org,
	Sui Jingfeng <sui.jingfeng@...ux.dev>
Subject: [PATCH] drm/prime: drm_prime_sg_to_dma_addr_array(): Return -EINVAL on error

'-EINVAL' stands for invalid argument, while '-1' will accidently be
interpreted as '-EPERM' by the potential upper caller. Which does not
describe the error case accurately, since such an error can happens when
the caller pass a smaller number than actually needed size to describe
the array passed-in. Such an error is invalid argument.

Take drm/vmwgfx driver as an example, the function call trace is:

|- ttm_bo_vmap()
|-- ttm_tt_populate()
|--- bdev->funcs->ttm_tt_populate()
|----- vmw_ttm_populate()
|------ drm_prime_sg_to_dma_addr_array()

While ttm_bo_vmap() requires its callees return '-EINVAL' on invalid range,
similier for other users or call path. Let's meet the requirement.

Signed-off-by: Sui Jingfeng <sui.jingfeng@...ux.dev>
---
 drivers/gpu/drm/drm_prime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 0e3f8adf162f..3f1d516a90b6 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -1055,7 +1055,7 @@ int drm_prime_sg_to_dma_addr_array(struct sg_table *sgt, dma_addr_t *addrs,
 
 	for_each_sgtable_dma_page(sgt, &dma_iter, 0) {
 		if (WARN_ON(a - addrs >= max_entries))
-			return -1;
+			return -EINVAL;
 		*a++ = sg_page_iter_dma_address(&dma_iter);
 	}
 	return 0;
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ