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 A59313242A9; Sun, 7 Jun 2026 10:22:57 +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=1780827779; cv=none; b=ZTWRTL27U9B5PLwkv26OrdX5I4rVN6w+hUtfW77JKGeDmHZDKLMXSrYOY6hfmsaz77i2Q2SKYAP4dNEq7D4qvnPvg7f0iMkGz/jB578dvzI1lTVwD7Cw6ZWlCU20McCzZL7kXTitI1ujEHhz8RnNjaoleeVcaDhMdFQ70aQZRK8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780827779; c=relaxed/simple; bh=MSuCzoAGGF6MG7K185ZZ7pccKNbfYX9IZGgst1sVXow=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B57nrPBnHu4ncSb3R5+lDPBktB+dcgIqgJE+r1b3BpKWl61rsNYYw+cSL0rxXP0wsSkNXW+MlF+JnB429CIqtuY+ZR6rzoHYxxF+SyYJ9M+iJsNF8G4hR5PviLN2PsyyEbh9jO9VDk7UWl1PZLj98HCHmEqNcsHv9Jb6JKjzAiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YDeZU4kr; 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="YDeZU4kr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE1921F00893; Sun, 7 Jun 2026 10:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780827777; bh=IaPWyOck4hRgNcEuM4gtZ9Cd3kXvFpKCDxLyAd1OBj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YDeZU4krpUxW7S8ukI9GbH3dwr7xcsVUQsx1cpA2cNBsDgYQIb+/VcRoZQeAk9DGn T9QtNB5Er2N2utxzgB842a6Xe87cyFeuVru+0V4cOCfOhHe7iRfrIdg9obVsaRHIdO HzsBxGCA5TmJDTZ4Cmv7XiI2Msfw2d4Q7K+zn9sY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Heikki Krogerus Subject: [PATCH 7.0 121/332] usb: typec: ucsi: ccg: reject firmware images without a : record header Date: Sun, 7 Jun 2026 11:58:10 +0200 Message-ID: <20260607095732.554662922@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095728.031258202@linuxfoundation.org> References: <20260607095728.031258202@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 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Greg Kroah-Hartman commit d7486952bf74e546ee3748fb14b2d07881fa6273 upstream. do_flash() locates the first .cyacd record with p = strnchr(fw->data, fw->size, ':'); while (p < eof) { s = strnchr(p + 1, eof - p - 1, ':'); ... } If the firmware image contains no ':' byte, strnchr() returns NULL. NULL compares less than the valid kernel pointer eof, so the loop body runs and strnchr() is called with p + 1 == (void *)1 and a length of roughly (unsigned long)eof, causing a wonderful crash. The not_signed_fw fallthrough earlier in do_flash() and the chip-state branches in ccg_fw_update_needed() allow an unsigned blob to reach this loop, so a root user who can place a crafted file under /lib/firmware and write the do_flash sysfs attribute can trigger the oops. Bail out with -EINVAL when the initial strnchr() returns NULL. Assisted-by: gkh_clanker_t1000 Cc: stable Cc: Heikki Krogerus Reviewed-by: Heikki Krogerus Signed-off-by: Greg Kroah-Hartman Link: https://patch.msgid.link/2026051405-posture-shrill-7884@gregkh Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/ucsi/ucsi_ccg.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/usb/typec/ucsi/ucsi_ccg.c +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c @@ -1243,6 +1243,11 @@ not_signed_fw: *****************************************************************/ p = strnchr(fw->data, fw->size, ':'); + if (!p) { + dev_err(dev, "Bad FW format: no ':' record header found\n"); + err = -EINVAL; + goto release_mem; + } while (p < eof) { s = strnchr(p + 1, eof - p - 1, ':');