From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795959049; b=LM2nwh34zRD2jzmfXjvsb+PLcW+fMjb7xK1MHV4wwuucfdYX2aDlB6h17wurX0YgSnvo ZTYNX08z+LvKk6QG+YhOfr4MqF9vppOlEjK/CVGLa9bQ3k8TsPj6t5908vUZLOkJn/JLV 3H1ENiPyR5MoH3wPiPyWIuI4JpAxBlz+59UbdItnZeLukv2lcBrT6qmuV1gu0APlyNz7z zagqQpp26M9zOo0VSDbFrR3ARENH2b+4MH+lGM9Bs1P75+3/96uz8gcTLnCPais3BbbXq RmAAQfaMiTMZvbAxbx46xbGn/5yyS8rnT7/WhxGHy9r1I7eFA2H2y3R5NrUekBasttw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795959049; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=rOvlPLW+ZCkGqbUDV3HXiTQUHAGELxdtH/gkr2n1tXs=; b=sTRWuZmV+gTJzJTvtUi5363VKrZvw6B+3+tykxkm5eODA3EoBJ9W5nDM5P5gYWshuAPJ mgm4LAWLIrcZKsg7/R6rdMGmeaD8XthQl4sjSeEO91+o7uW41eIcbP5CxCNjcNZotwweB b5UrGc+bjYh2KwsVtO6NTG+rkEMMlpu+vfaQVZ/m3/CDNgpUOvvTSh21+LRpJeha75Qd2 pdCF/0wjGR17HfjLwpRcYN4VESFjTNtyYb9PeCGN2N1E0B1zeMf0zwC+FVCBiXqUhFJcY b6fz8l8c4jxU4cBv51NLp7T+XLMJDDnCLFRklMkrBSQBrr+nyKSZs/2dvSyZqaDAqHw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JerG5e5p; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2B78606A31C for ; Sun, 29 Nov 2026 13:30:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JerG5e5p Received: by smtp.kernel.org (Postfix) with ESMTPSA id 835931F00896; Sun, 29 Nov 2026 13:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795959048; bh=rOvlPLW+ZCkGqbUDV3HXiTQUHAGELxdtH/gkr2n1tXs=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JerG5e5pv05lRuIENe6dEwU3M6park5sDkFqjMaEGOeovKQr3wSx+j9pJVhT+MtrR +CYiaOmXgT/IE8hpssi28UDwG1Ln+t0f0kMyFAmnEghIzHF6lOhYKIR05P6hM7ay5m xF/L0Fq6gw7XPJJaAKaZiG2tfiOxYsJsHKZCBfHCxbrCGCsXg4Sf5c3CQVLwvzyKRT 8HMD2sKQ6rJeAE+fZbrl5Mvjqy5jwO3KxYGckmlnT5GupELbErBS33dYMrFixPdltS LML81dqSMyjA+ahRQYqRYAVtDBip6t9+HLHYSambBkRbuaOqNCETceJv+eart5q4jb DdGj80qRlrIJg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 1/2] usb: gadget: configfs: free ext_prop data on property removal Reply-To: sashiko-reviews@lists.linux.dev To: "Jaegyun Lee" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261129132508.387095-1-dreams200260@gmail.com> References: <20261129132508.387095-1-dreams200260@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 13:30:48 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 *grou= p, 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 -=3D (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 =3D to_usb_os_desc_ext_prop(item); int len =3D ext_prop->data_len; if (ext_prop->type =3D=3D USB_EXT_PROP_UNICODE || ext_prop->type =3D=3D USB_EXT_PROP_UNICODE_ENV || ext_prop->type =3D=3D USB_EXT_PROP_UNICODE_LINK) len >>=3D 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 =3D ext_prop->data_len; mutex_lock(desc->opts_mutex); kfree(ext_prop->data); ext_prop->data =3D new_data; ext_prop->data_len =3D 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 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129132508.3870= 95-1-dreams200260@gmail.com?part=3D1