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>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <97cdc2d8-75ae-9fa2-6dc0-678867040eea@huawei.com>
Date: Tue, 9 Jul 2024 14:43:01 +0800
From: Zenghui Yu <yuzenghui@...wei.com>
To: "T.J. Mercier" <tjmercier@...gle.com>
CC: <linux-media@...r.kernel.org>, <dri-devel@...ts.freedesktop.org>,
	<linaro-mm-sig@...ts.linaro.org>, <linux-kselftest@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, <sumit.semwal@...aro.org>,
	<benjamin.gaignard@...labora.com>, <Brian.Starkey@....com>,
	<jstultz@...gle.com>, <shuah@...nel.org>, <wanghaibin.wang@...wei.com>
Subject: Re: [PATCH] kselftests: dmabuf-heaps: Ensure the driver name is
 null-terminated

On 2024/7/9 1:49, T.J. Mercier wrote:
> On Mon, Jul 8, 2024 at 6:47 AM Zenghui Yu <yuzenghui@...wei.com> wrote:
> >
> > Even if a vgem device is configured in, we will skip the import_vgem_fd()
> > test almost every time.
> >
> >   TAP version 13
> >   1..11
> >   # Testing heap: system
> >   # =======================================
> >   # Testing allocation and importing:
> >   ok 1 # SKIP Could not open vgem -1
> >
> > The problem is that we use the DRM_IOCTL_VERSION ioctl to query the driver
> > version information but leave the name field a non-null-terminated string.
> > Terminate it properly to actually test against the vgem device.
> 
> Hm yeah. Looks like drm_copy_field resets version.name to the actual
> size of the name in the case of truncation, so maybe worth checking
> that too in case there is a name like "vgemfoo" that gets converted to
> "vgem\0" by this?

Given that drm_copy_field() would set version.name_len to the exact
length of the driver name, this can be addressed by

diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c 
b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
index 2fcc74998fa9..5d0a809dc2df 100644
--- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
+++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
@@ -29,7 +29,7 @@ static int check_vgem(int fd)
  	version.name = name;

  	ret = ioctl(fd, DRM_IOCTL_VERSION, &version);
-	if (ret)
+	if (ret || version.name_len != 4)
  		return 0;

  	name[4] = '\0';

on top of this patch. What do you think?

Thanks,
Zenghui

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ