From: Thomas Zimmermann <tzimmermann@suse.de>
To: Hui Peng <benquike@gmail.com>,
jani.nikula@linux.intel.com, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v3 1/2] drm/udl: reject short USB control transfers in udl_read_edid_block()
Date: Thu, 24 Sep 2026 14:24:20 +0200 [thread overview]
Message-ID: <bb1176c6-a1d5-4c89-9524-caeedd9282c4@suse.de> (raw)
In-Reply-To: <20260924073012.2742968-2-benquike@gmail.com>
Hi
Am 24.09.26 um 09:30 schrieb Hui Peng:
> In udl_read_edid_block(), usb_control_msg() requests 2 bytes into
> read_buff for each EDID byte, and read_buff[1] is stored into buf[i].
> Currently the short-transfer check tests ret < 1 instead of ret < 2, so
> if a short USB control transfer returns 1 byte, read_buff[1] is not
> written by usb_control_msg() and retains the previous iteration's byte (or
> uninitialized kmalloc(2) memory on the first iteration), which is then
> copied into buf[i].
>
> Change the check from ret < 1 to ret < 2 so any short USB control
> transfer fails with -EIO.
>
> Tested in QEMU against Linux 7.3.0-rc3 using dummy_hcd and raw-gadget
> emulating a DisplayLink UDL USB device: on the unfixed kernel, when
> usb_control_msg() returned 1 byte for an EDID read (short transfer),
> udl_read_edid_block() accepted ret = 1 and stored stale read_buff[1]
> data into the EDID buffer; whereas with this fix applied, ret < 2
> correctly fails with -EIO and prevents EDID buffer corruption.
>
> Fixes: 5320918b9a87 ("drm/udl: initial UDL driver (v4)")
> Cc: stable@vger.kernel.org
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> Assisted-by: LLM
> Signed-off-by: Hui Peng <benquike@gmail.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Thanks for the fix.
Best regards
Thomas
> ---
> Changes in v3:
> - Change (ret != 2) to (ret < 2) in udl_read_edid_block(), as requested
> by Thomas Zimmermann.
>
> Changes in v2:
> - Split out as patch 1/2 as requested by Jani Nikula.
> - Added testing details in QEMU on short USB EDID control transfers.
>
> drivers/gpu/drm/udl/udl_edid.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/udl/udl_edid.c b/drivers/gpu/drm/udl/udl_edid.c
> index af4cff2a7c51..2120e363b6eb 100644
> --- a/drivers/gpu/drm/udl/udl_edid.c
> +++ b/drivers/gpu/drm/udl/udl_edid.c
> @@ -36,7 +36,7 @@ static int udl_read_edid_block(void *data, u8 *buf, unsigned int block, size_t l
> if (ret < 0) {
> drm_err(dev, "Read EDID byte %zu failed err %x\n", i, ret);
> goto err_drm_dev_exit;
> - } else if (ret < 1) {
> + } else if (ret < 2) {
> ret = -EIO;
> drm_err(dev, "Read EDID byte %zu failed\n", i);
> goto err_drm_dev_exit;
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
next prev parent reply other threads:[~2026-09-24 12:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 22:35 [PATCH] drm/udl: reject short USB EDID control transfers and fix URB init cleanup Hui Peng
2026-09-21 10:43 ` Jani Nikula
2026-09-24 6:44 ` [PATCH v2 0/2] drm/udl: fix EDID short transfer check and probe USB cleanup Hui Peng
2026-09-24 6:44 ` [PATCH v2 1/2] drm/udl: reject short USB control transfers in udl_read_edid_block() Hui Peng
2026-09-24 7:14 ` Thomas Zimmermann
2026-09-24 7:30 ` [PATCH v3 " Hui Peng
2026-09-24 12:24 ` Thomas Zimmermann [this message]
2026-09-24 6:44 ` [PATCH v2 2/2] drm/udl: clean up USB resources if drm_dev_register() fails Hui Peng
2026-09-24 7:12 ` Thomas Zimmermann
2026-09-24 7:30 ` [PATCH v3 " Hui Peng
2026-09-24 7:30 ` [PATCH v3 0/2] drm/udl: fix EDID short transfer check and probe USB cleanup Hui Peng
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=bb1176c6-a1d5-4c89-9524-caeedd9282c4@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=benquike@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®