From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A416C3BB116; Tue, 12 May 2026 17:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778608440; cv=none; b=GC9yzvIdHUqyDjtFxZVR4PkWy0YfhESapsvwwMfIkWx31zBI/l82SRWxHUeLIT6RPWRklTATMbruRkwCKU6/x+cH4FvpXTfgAsusVukdrWRqXMPUVbzZrCrUKn5MCq07fm8VPiCEgV8EemC3WOom1KRdxqyeHAAQ1v6RfkR3sEU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778608440; c=relaxed/simple; bh=MxC8x13U3dH87bRB2WtPs8fD5AjFpRqZBYQcYImEUYQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q+AfzNR4apEn0/7R0CweyjI89FpL2naLk3WY+bCVu2gsVn7UaP4lcfdwdBFteVLTLUuIDqE3q+5Stnlo8ZyZvXexSvwGzQVJ4pI57ej4CRKZY4AFFA6k/zsnyMe5ESLjh+Fq4pVw8JMzsWvZLjsGjhnrlor5QwKCaRDmZVO8SxQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=N5Ke00Kg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="N5Ke00Kg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13D11C2BCB0; Tue, 12 May 2026 17:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778608440; bh=MxC8x13U3dH87bRB2WtPs8fD5AjFpRqZBYQcYImEUYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N5Ke00KgBn/zGwW2KLG/3F0aDc+UCywp82yXnxka3ltKqvKip6Z19g2tGVSbhGrUJ 5jxU+ajdm1dEEDZFCv5INmFsZFwaNlokaWC2JE5tvpZP1Y4n3Led1dkXKlmtXXkV1G w2fFhqYIGMQ3zbb5Gb13pyxjCCrPrYq/wU1VE4B4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pete Zaitcev , stable Subject: [PATCH 6.18 038/270] usb: usblp: fix heap leak in IEEE 1284 device ID via short response Date: Tue, 12 May 2026 19:37:19 +0200 Message-ID: <20260512173939.258655705@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260512173938.452574370@linuxfoundation.org> References: <20260512173938.452574370@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: Greg Kroah-Hartman commit 7a400c6fe3617e31e690e3f7ca37bb335e0498f3 upstream. usblp_ctrl_msg() collapses the usb_control_msg() return value to 0/-errno, discarding the actual number of bytes transferred. A broken printer can complete the GET_DEVICE_ID control transfer short and the driver has no way to know. usblp_cache_device_id_string() reads the 2-byte big-endian length prefix from the response and trusts it (clamped only to the buffer bounds). The buffer is kmalloc(1024) at probe time. A device that sends exactly two bytes (e.g. 0x03 0xFF, claiming a 1023-byte ID) leaves device_id_string[2..1022] holding stale kmalloc heap. That stale data is then exposed: - via the ieee1284_id sysfs attribute (sprintf("%s", buf+2), truncated at the first NUL in the stale heap), and - via the IOCNR_GET_DEVICE_ID ioctl, which copy_to_user()s the full claimed length regardless of NULs, up to 1021 bytes of uninitialized heap, with the leak size chosen by the device. Fix this up by just zapping the buffer with zeros before each request sent to the device. Cc: Pete Zaitcev Assisted-by: gkh_clanker_t1000 Cc: stable Link: https://patch.msgid.link/2026042002-unicorn-greedily-3c63@gregkh Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/usblp.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -1377,6 +1377,7 @@ static int usblp_cache_device_id_string( { int err, length; + memset(usblp->device_id_string, 0, USBLP_DEVICE_ID_SIZE); err = usblp_get_id(usblp, 0, usblp->device_id_string, USBLP_DEVICE_ID_SIZE - 1); if (err < 0) { dev_dbg(&usblp->intf->dev,