From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796326368; b=PT/tqVuGx/oFbmwVGFqIpDvj4bRzI57hhauUCY44aWannk6zHIv+eJIuPEPe1LSU/Mig g2se2RAY36wyf0x1K4mSYFXsxw7uU3PLHwzbs5nN/0jVW/5gs+o6tlXn/wI4AEaBH8j/F Sdv+E/JOVPGiEzfsx7D4V62wnPVvVbxuzZuRdf7mOGWe0LB4cFOQvA4moZ4CbNHdgi/wX 9vLrOI3p+xWt8bFKByPUuGpJeziE2I4I0+0iTc1Q5MpzxuQxrmySZt0Ed/3fr2/spUpdM OiCr2Iov3OM6KDlV9uJX+wzDct8mFaZ/sxgNXEdpQovP4FIa90f9mE5cJEapsjbVGSw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796326368; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=Eb+mUeBQlB9F/eAcxhGs9mY2EIWx4QnfDxnojeOCmdY=; b=wTP06f13knt3LafKfFcvXSHU3hl5W3CD0OBhP2dpcODv1gA1+Ichz0VrD9ybPXanR9Rk c7lNSGx11pod/FAbVlEGb0jnVbuAgS0aubRb8apEOMrs+20HxcmyMb7HUw3UWIeQeXwG4 BtydB4darlxVu6Jr70UN6PtuoYkRWKrTlgwDbYwqaG21YbzskaK6gl3X/l3Rbz+pfU0fh Lk47b4xPCNBPudf6lGcKMAV6E5Pi4KVuUFp7hYnT9t/nxhw+0SsjpXKxiOAXe+X5ueqXJ g0OTKk+z2BuL+sKdyc0BalmEB1qW/9pKxejg2Pdn0W28Y2vYrJ0uXhqK1Dk+lSiVClA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=vzh7ozRD; arc=none smtp.remote-ip=74.125.82.182 Received: from mail-dy1-f182.google.com (mail-dy1-f182.google.com [74.125.82.182]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C67CE606A32C for ; Thu, 3 Dec 2026 19:32:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C67CE606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=vzh7ozRD Received: by mail-dy1-f182.google.com with SMTP id 5a478bee46e88-3874cf36e63so138512eec.0 for ; Thu, 03 Dec 2026 11:32:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796326367; x=1796931167; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Eb+mUeBQlB9F/eAcxhGs9mY2EIWx4QnfDxnojeOCmdY=; b=vzh7ozRDiEixkr8NW0hhe7cR/dN4+iG5pBd/aVnMetMdNw7xBAvGIEHrT7/OSApoo3 wbt/MW8VCpK22v/12blc4QVzLhotw4udpgpnGFA2XhQB7faTqrdYOHwrS62FyQo0KJMc VWgej+UCF+CRXRy4EWRuF6NZLQSlL5v78f0B/Kh516vbigcVfav7HgbI//RER6L2hTGo 5mVlV+s14kYVq1C1OeHbvk7aIbznYNxYOrsV7FladrkJqRM3lTgym+A8NWHRbweYreIQ +w82u+/SMabSV2X14chLM6/dOuo6ARRF5xR3nQz2YwQvp+IVn0mk2JRnbX8hI4Vf9C2b lwTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796326367; x=1796931167; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Eb+mUeBQlB9F/eAcxhGs9mY2EIWx4QnfDxnojeOCmdY=; b=2ct2Sb3SiiZMfxp4XN0jRFKTYTBFiIPeenrL7bji3Zc34BDvhODT11xHouS2xvpBxX NXa98jZwuAEgixFcu09jLwLSvNHY4YJCb1LGd9qIsHJ1tkc9x5v0kv7cR/MKinS5DE63 uc1oWXS2+OQtDCZE+8yxjl2C7tEI1YPe0D7BpKY/jcUNsdMtIMAp48jSfZW71zAV5/ov v+2sj2pQ6YmmA39fZRhH1gFWAsAuHCt8GDzdyeI7yFyR1CGgp3VWf4kaY9G2phQ0eGH+ PyXLRmde9kSMLWOz2tmLLWFnWQToLo5JsKUsRz1ZLxGyDVv3gB5TYiEx9z5rq5Xajh2f mO2g== X-Forwarded-Encrypted: i=1; AL+hErF+/fPomDx8fUzPCnDHfyTaYJxMY70VUeO0ClliC/z0UX4CBLg2SuTQAOXP9ZtUvNvbgQBiaBz9KiE=@vger.kernel.org X-Gm-Message-State: APuU4Z8vg1k/ufV7Ml4vK+aor06pJbvah64g5FaCRePFg5OtYkkPBLEI rAf0ilra63Wy2WYc8M7K/JH0efi/tvIHrcDjXJHW6tNV6WAoM1T95DbK X-Gm-Gg: AZFdTZdJgfWpVOZQkyR5TcBsJV8QipZk1EbENG9prHrpvbmHmaDakkK1lun7fHXn8il OV2mJKXBd3vIeGJCdkDlWn/MQYTF9hZ+fFtCvBwlnl7iU0/N5T408smXT2POHqy1uKu0+4g+ck/ 2UqXdEWbvjzd6eq6K04DIQFw7Yuvy8SHuMdUmZ669lYkGCEY8TLt1YEQ7YuH0bg0ds5h7O9r3t6 a/K2QXB4S96Z+OeCTFEd9jYCDBEtjqFyrhUD+t6YFbJP5txWqTiCdbMn/vNcSEEPfi9qW/hbgpQ SFa8jj0E5cPJi3x87uFDQWAjKJp0oqBFZ+HMsiikDldHdl26eo25SP7z7pnEc1d5g7B8Mtvy+I8 J5XPABRaR721X/AL/ptYw9PkBRcii7Z3H5CkB2fYi3RGPs8/bOyQgqWL3/P6K1KaMuJNe/1YG5p fYBFd0ZYy/J/H5qn0UIHBl/NXNV69J9DCNKbr2G+Y5X3GOsZWV5EQX3Ml4e38mGKV+b3A2nSOKV fuTsjah7onuXPVmcCjPnuHtk1PViQ9+WEZtJCBsbFe9i5m6HVKQRUv9ad06BJBFwRwinQrQc8/d peCE6M1YkEyJ98myQJmWYltXgV0BgzjswXp/+9vo X-Received: by 2002:a05:7301:d183:b0:386:a728:6c11 with SMTP id 5a478bee46e88-386a72872d3mr38137195eec.17.1796326366546; Thu, 03 Dec 2026 11:32:46 -0800 (PST) Received: from vineet-kernel.. ([106.51.245.14]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385672ce402sm124002972eec.16.2026.12.03.11.32.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 11:32:46 -0800 (PST) From: Vineet Thakran To: Greg Kroah-Hartman , Neill Kapron Cc: Ruslan Bilovol , Pavel Hofman , linux-usb@vger.kernel.org, Vineet Thakran Subject: [PATCH 0/4] usb: gadget: f_uac1/f_uac2: fix descriptor leaks and NULL deref with multiple instances Date: Thu, 3 Dec 2026 19:32:13 +0000 Message-ID: <20261203193217.465889-1-vineet789thakran@gmail.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit f_uac1 and f_uac2 keep the dynamically allocated feature unit (and, in f_uac1, AC header) descriptors in file-scope pointers shared by all instances. With more than one instance this leaks descriptors on every bind (reported by syzbot for f_uac2), and once one instance unbinds, a feature unit control request to any other bound instance dereferences a NULL pointer. Patches 1 and 3 make the control request handlers use the unit IDs already stored per instance. Patches 2 and 4 then free the descriptors at the end of bind, as usb_assign_descriptors() has copied them by then. Testing (next-20261127, arm64 QEMU, usbip-vudc as UDC, kmemleak on): - syzbot's C reproducer: reports the build_fu_desc leak before the series; runs for 180 s without any leak after it. - Two uac2 and two uac1 instances in one config, bound/unbound for 3 and 8 cycles: kmemleak reports leaked FU descriptors before the series (10 objects after 3 cycles, 27 after 8) and none after. Counting allocations and frees with temporary instrumentation also confirms the uac1 AC header leak, which kmemleak does not report: 3 of 6 freed before, 6 of 6 after. - Two gadgets on two vudc instances, unbinding the first and attaching the second to vhci-hcd: both drivers oops on the first feature unit control request before the series. After it, snd-usb-audio enumerates the device and creates all volume/mute controls. Both drivers still keep their other descriptors in static variables; this series only addresses the dynamically allocated ones. Vineet Thakran (4): usb: gadget: f_uac2: use per-instance feature unit IDs in control requests usb: gadget: f_uac2: fix feature unit descriptor leak usb: gadget: f_uac1: use per-instance feature unit IDs in control requests usb: gadget: f_uac1: fix feature unit and AC header descriptor leak drivers/usb/gadget/function/f_uac1.c | 83 +++++++++++++--------------- drivers/usb/gadget/function/f_uac2.c | 83 ++++++++++++++-------------- 2 files changed, 78 insertions(+), 88 deletions(-) base-commit: e5aad2bdbbee783611d32599f89cea3f12f9593d -- 2.43.0