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 6985F47A0B0; Tue, 16 Jun 2026 17:25:20 +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=1781630721; cv=none; b=pCSQUaCRlyWDnn+AQaS2vLufO9/9t8DkvrIlyot12S5sIYDVYI1TDpbe+xHblQiTG18t6JNBRxJ5N7fBYnsv/dyRymCH4P1dt7P3mOzxwK1hb/qsyLucRwF0zScixWmBLhanhhnxhZqT3A6tiP4bpTs2O/rgVgqns7aApNfJQxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781630721; c=relaxed/simple; bh=G2xBhVdLjn1lTU+4u6EppP4Gy98CaaHI5P/UgohJJOg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GWsVvU8IiKbL2TC1oytcbr9CLFiFtvKgLiVljK4NI4N70hwi7uTF5OAdVhfjcpU7yh3aLcDSwjTRPVwa1iA9zjIq/3//HigOojBQC2HUSV/p3zjnSr3ERxMNsXlzeYwl64cwss+ohuhM7wWfn8N1QAVSncgiIuaKHS1RSQ3NFHY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZySpsF7t; 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="ZySpsF7t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 789931F000E9; Tue, 16 Jun 2026 17:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781630720; bh=MTY/2mLGtaWwzERKBSe5t/I3Ax+ra7KGETftBWW0/Hk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZySpsF7tPUBXd3ZwsEl+MRx2h5l4h84j9l8z+Osq7sqGsZunHFpRLC3LHIL5Rkf4Z Yhy34ymUkH+pcQw/HIQ4CjYS8EfUYZ4H7CNEvB5pdv1dqB72brMAB2SNhEJSKGsiSY OUZ90klsgae28nrzQDlBs9XdMuzTB5tKQRz6yWK8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Heikki Krogerus Subject: [PATCH 6.1 083/522] usb: typec: ucsi: ccg: reject firmware images without a : record header Date: Tue, 16 Jun 2026 20:23:50 +0530 Message-ID: <20260616145129.751629241@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145125.307082728@linuxfoundation.org> References: <20260616145125.307082728@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.1-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 @@ -1178,6 +1178,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, ':');