From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16C72372B4B; Fri, 4 Sep 2026 05:41:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788500511; cv=none; b=XSJ8C0MhseTV31Mtr3FYbbJ9e1Ak/5s60MIwiC0cim71xTvgYQcDTyJOfz3zu7NVc8l8R7o/WGQEgcLxZ+p2tAuKJEbT8ENxZyyQ+/m8Q4ULUtu2mSj1j9uAp3f4Cre47hm3MNSlJ+wnKGJX6Kj+NXFrEyqBsnGGoDsxugiQSbg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788500511; c=relaxed/simple; bh=UNBnkMiL2wCBlzZZmFtYSV+j757tolle2PaEmVgaCx4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G8jXGXCob0vqmhEiaq3YckzdVPyMq1l+HZYiRiljCmaTJOL5u2Wea7MuySAuMvPI4U3YywcXJb0tpfE0R9H3LWxx7R0CSwq4/CTLWzzHxljbEvdvJKjYRsQLprrLjofhaK4UKr5sxofWskpHLHAUWM0M9ldr5vqf0GZq9A4W11w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LMhYFY/m; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="LMhYFY/m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A1F11F00A3D; Fri, 4 Sep 2026 05:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788500510; bh=i0n9sinADdJ2OnY1FMdkhJD0n5uDyeYJIs6onxKEUw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LMhYFY/m6+ZVZW24UBLhfC02KPFZRfxOTRVzAY2XQMwJNEgzhY53Hl0swET1PQcA/ YE7XNYT9dVgSYxcbrQQY+rq1VCm2tEZJ6aYowg5MxjwqhX+FNTyF2SIEFwNI1kBmAg LibZmZx4RiaA7wG7aSwn73j6UPcn3qcRC9INoUuE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+de553c19cb054f174a35@syzkaller.appspotmail.com, Jeffin Philip Subject: [PATCH 6.18 083/552] usb: gadget: uvc: fix dangling pointers in uvc_function_bind() and uvc_function_unbind() Date: Fri, 4 Sep 2026 06:54:00 +0200 Message-ID: <20260904045749.753766207@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045747.813364717@linuxfoundation.org> References: <20260904045747.813364717@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeffin Philip commit bdab5605259ba5d6ff927c1a85cc83eb3ecfdacc upstream. In uvc_function_bind() error path, we use usb_ep_free_request which uses uvc->control_req but does not set it to NULL afterwards. Thus, uvc->control_req is a dangling pointer causing a UAF. Also we do not set the uvc->control_buf pointer to NULL after freeing it, which is another dangling pointer. Fix it by setting uvc->control_req to NULL after we run usb_ep_free_request() and uvc->control_buf to NULL after kfree. Do the same for uvc_function_unbind(). Reported-by: syzbot+de553c19cb054f174a35@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=de553c19cb054f174a35 Fixes: 0f9df9393855 ("usb: gadget: uvc: fix error path in uvc_function_bind()") Fixes: 6d11ed76c45d ("usb: gadget: f_uvc: convert f_uvc to new function interface") Cc: stable@vger.kernel.org Signed-off-by: Jeffin Philip Link: https://patch.msgid.link/20260813174311.130823-1-jeffinphilip14@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_uvc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -889,9 +889,12 @@ error_unlock: v4l2_error: v4l2_device_unregister(&uvc->v4l2_dev); error: - if (uvc->control_req) + if (uvc->control_req) { usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); + uvc->control_req = NULL; + } kfree(uvc->control_buf); + uvc->control_buf = NULL; usb_free_all_descriptors(f); return ret; @@ -1075,7 +1078,9 @@ static void uvc_function_unbind(struct u uvc->vdev_release_done = NULL; usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); + uvc->control_req = NULL; kfree(uvc->control_buf); + uvc->control_buf = NULL; usb_free_all_descriptors(f); }