From: sashiko-bot@kernel.org
To: "Jaegyun Lee" <dreams200260@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH 1/2] usb: gadget: configfs: free ext_prop data on property removal
Date: Sun, 29 Nov 2026 13:30:48 +0000 [thread overview]
Message-ID: <sashiko-outbox-239629@kernel.org> (raw)
In-Reply-To: <20261129132508.387095-1-dreams200260@gmail.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] usb: gadget: configfs: use-after-free in
ext_prop_data_show() [1]
--
commit 4b938ed211f8916b71340a189fb4330f05c1c4fc
Author: Jaegyun Lee <dreams200260@gmail.com>
usb: gadget: configfs: free ext_prop data on property removal
This commit frees ext_prop->data in ext_prop_drop() when an OS descriptor
extended property is removed from configfs.
> diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
> index 5439c367df794..5202c3e0c2568 100644
> --- a/drivers/usb/gadget/configfs.c
> +++ b/drivers/usb/gadget/configfs.c
> @@ -1449,6 +1449,7 @@ static void ext_prop_drop(struct config_group *group, struct config_item *item)
> list_del(&ext_prop->entry);
> --desc->ext_prop_count;
> kfree(ext_prop->name);
> + kfree(ext_prop->data);
> desc->ext_prop_len -= (ext_prop->name_len + ext_prop->data_len + 14);
> if (desc->opts_mutex)
> mutex_unlock(desc->opts_mutex);
[Severity: Critical]
This problem wasn't introduced by this patch, but can ext_prop_data_show()
race with ext_prop_data_store() and cause a use-after-free or out-of-bounds
read on ext_prop->data [1]?
ext_prop_data_store() updates ext_prop->data and ext_prop->data_len under
desc->opts_mutex, while ext_prop_data_show() reads them without taking
desc->opts_mutex:
drivers/usb/gadget/configfs.c:ext_prop_data_show() {
struct usb_os_desc_ext_prop *ext_prop = to_usb_os_desc_ext_prop(item);
int len = ext_prop->data_len;
if (ext_prop->type == USB_EXT_PROP_UNICODE ||
ext_prop->type == USB_EXT_PROP_UNICODE_ENV ||
ext_prop->type == USB_EXT_PROP_UNICODE_LINK)
len >>= 1;
memcpy(page, ext_prop->data, len);
return len;
}
Because configfs only serializes accesses per open file description, two
processes opening the same data attribute can read and write concurrently:
CPU0 CPU1
ext_prop_data_show() ext_prop_data_store()
len = ext_prop->data_len;
mutex_lock(desc->opts_mutex);
kfree(ext_prop->data);
ext_prop->data = new_data;
ext_prop->data_len = len;
mutex_unlock(desc->opts_mutex);
memcpy(page, ext_prop->data, len); <-- use-after-free or OOB read
Acquiring desc->opts_mutex around the read and memcpy() in
ext_prop_data_show() would prevent the race.
[1] https://sashiko.dev/#/bug/linux-1af10ba3-e011-43af-a87a-dcd65bad0bc8
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129132508.387095-1-dreams200260@gmail.com?part=1
next prev parent reply other threads:[~2026-11-29 13:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 13:25 [PATCH 1/2] usb: gadget: configfs: free ext_prop data on property removal Jaegyun Lee
2026-11-29 13:25 ` [PATCH 2/2] usb: gadget: configfs: fix ext_prop race with composite_setup() Jaegyun Lee
2026-11-29 13:30 ` sashiko-bot [this message]
2026-11-29 13:34 ` [PATCH 1/2] usb: gadget: configfs: free ext_prop data on property removal sashiko-bot
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=sashiko-outbox-239629@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dreams200260@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.