From: Zenghui Yu <yuzenghui@huawei.com>
To: "T.J. Mercier" <tjmercier@google.com>
Cc: <linux-media@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
<linaro-mm-sig@lists.linaro.org>,
<linux-kselftest@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<sumit.semwal@linaro.org>, <benjamin.gaignard@collabora.com>,
<Brian.Starkey@arm.com>, <jstultz@google.com>, <shuah@kernel.org>,
<wanghaibin.wang@huawei.com>
Subject: Re: [PATCH] kselftests: dmabuf-heaps: Ensure the driver name is null-terminated
Date: Tue, 9 Jul 2024 14:43:01 +0800 [thread overview]
Message-ID: <97cdc2d8-75ae-9fa2-6dc0-678867040eea@huawei.com> (raw)
In-Reply-To: <CABdmKX1CXWuw0-gRukZeSoF=SZFi3eRPELe=EU_-q3OVKQHZzw@mail.gmail.com>
On 2024/7/9 1:49, T.J. Mercier wrote:
> On Mon, Jul 8, 2024 at 6:47 AM Zenghui Yu <yuzenghui@huawei.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
prev parent reply other threads:[~2024-07-09 6:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 13:46 [PATCH] kselftests: dmabuf-heaps: Ensure the driver name is null-terminated Zenghui Yu
2024-07-08 17:49 ` T.J. Mercier
2024-07-09 6:43 ` Zenghui Yu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=97cdc2d8-75ae-9fa2-6dc0-678867040eea@huawei.com \
--to=yuzenghui@huawei.com \
--cc=Brian.Starkey@arm.com \
--cc=benjamin.gaignard@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jstultz@google.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tjmercier@google.com \
--cc=wanghaibin.wang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox