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 ADB2D478E3E; Tue, 16 Jun 2026 16:49:02 +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=1781628543; cv=none; b=qi0VX+Oj0IukVhJo7nbXB/VX+dWnYC94dN5fGhNI/pSZ2U6sffMWdOvyWF+MgU2OAXuICbgdlakM/+wCXp82Fwe+5I5ECIfjGGt9edW0YZFaFXIH54VSwLvhBCtSPazgDox/yPy8ZtG7jEszg/yL2RpQFyF1zmOgKyVCdj9P4bM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781628543; c=relaxed/simple; bh=bJobjdXOYgO543rrAZ8m47+4HOsYNm+q4GXc0RE48wg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pZc5Nm30gioh4MslPx1IbjLPdLBaLtcekkVTZI4WLhZHnlMC7GzxXK/JCBEIc1l6cIzFpAIuq0x/56eXkSc4MesTtu+l0PJ52LAZi3Wji9aWmWOirV2bFFd+EbZOnJCiK8MM0secs+sD9jaWb4HSzc/S7XZEuOqiGzuwcMp+Q+0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=V0d7zKri; 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="V0d7zKri" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 693371F000E9; Tue, 16 Jun 2026 16:49:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781628542; bh=cEB5tn3aGjTaEqK9qJLdhvGVGJNK5FFLb1a8ro+QzPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V0d7zKri5v3r9QwePH7eIxCk9ZFoQPRQe5pnOeLuEu7jlwf3CKpH9UP9Wy9X+a7Ef Qgxm/f3zU1Za7SusNq4xkWUWwRwvCsyd+0IC785oYoMmpyz3mCPFC+0TcEI+2obvuc TURtrs5h6NcpjkfX1FVGzdItH7cViJgP5iZTNrl4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Heikki Krogerus Subject: [PATCH 6.6 083/452] usb: typec: ucsi: ccg: reject firmware images without a : record header Date: Tue, 16 Jun 2026 20:25:10 +0530 Message-ID: <20260616145122.227932026@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145117.796205997@linuxfoundation.org> References: <20260616145117.796205997@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.6-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, ':');