From: Helge Deller <deller@gmx.de>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>,
Bernie Thompson <bernie@plugable.com>
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fbdev: udlfb: validate vendor descriptor items
Date: Sat, 18 Jul 2026 20:26:09 +0200 [thread overview]
Message-ID: <db0698e3-9f45-4123-8b6d-ff59bcdcf25f@gmx.de> (raw)
In-Reply-To: <20260706093038.80131-1-pengpeng@iscas.ac.cn>
On 7/6/26 11:30, Pengpeng Hou wrote:
> dlfb_parse_vendor_descriptor() walks key-length-value items inside the
> DisplayLink vendor descriptor.
>
> Require each item to contain its key, length and declared value bytes
> before reading item-specific fields such as max_area.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> drivers/video/fbdev/udlfb.c | 22 ++++++++++++++++------
> 1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
> index fdbb8671a810..e78d6f95c9c5 100644
> --- a/drivers/video/fbdev/udlfb.c
> +++ b/drivers/video/fbdev/udlfb.c
> @@ -1586,19 +1586,29 @@ static int dlfb_parse_vendor_descriptor(struct dlfb_data *dlfb,
> desc += 5; /* the fixed header we've already parsed */
>
> while (desc < desc_end) {
> + char *value;
> u8 length;
> u16 key;
>
> - key = *desc++;
> - key |= (u16)*desc++ << 8;
> + if (desc_end - desc < sizeof(key) + sizeof(length))
> + goto unrecognized;
> +
> + key = get_unaligned_le16(desc);
Is there a reason why you switch to unconditional little-endian reads?
Is this "vendor descriptor" always little-endian?
If yes, then your patch is probably correct.
If not, I think your patch will most likely break big-endian machines.
Helge
> + desc += sizeof(key);
> length = *desc++;
>
> + if (length > desc_end - desc)
> + goto unrecognized;
> +
> + value = desc;
> switch (key) {
> case 0x0200: { /* max_area */
> - u32 max_area = *desc++;
> - max_area |= (u32)*desc++ << 8;
> - max_area |= (u32)*desc++ << 16;
> - max_area |= (u32)*desc++ << 24;
> + u32 max_area;
> +
> + if (length < sizeof(max_area))
> + goto unrecognized;
> +
> + max_area = get_unaligned_le32(value);
> dev_warn(&intf->dev,
> "DL chip limited to %d pixel modes\n",
> max_area);
next prev parent reply other threads:[~2026-07-18 18:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 9:30 [PATCH] fbdev: udlfb: validate vendor descriptor items Pengpeng Hou
2026-07-18 18:26 ` Helge Deller [this message]
2026-07-18 18:59 ` Helge Deller
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=db0698e3-9f45-4123-8b6d-ff59bcdcf25f@gmx.de \
--to=deller@gmx.de \
--cc=bernie@plugable.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pengpeng@iscas.ac.cn \
/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