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 BB3D238C437; Tue, 16 Jun 2026 18:43:44 +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=1781635425; cv=none; b=aMzaftfdR8T1qFM9DreNrrHiGLJJSWKL3D6vTMGu8IezXKU6SEQrDzXm5gmJsUTb0s27QW4ifJgk/Hw/TeN1TfGP93wfESFVI4SJ9MnKCBTHk+INsbK8XdnFIMsohiuEORS14h4Q1OSSoVsUMM8FMbsboRDDwqccvDhvDi2ehos= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781635425; c=relaxed/simple; bh=XzHrFc+8LOVByT2s/yHfzINsHiN3zkn5V91LK/IZKfA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tGlJxG46PDi+8w79oZsRBsAi965TpIUHkwKFKGXt+8DKvEwq74nuJ7TpHFyr+65c+/pDk3QujxrWq+U60sEDUsmexXICKFHiNtSYOCGLHc+mzBNelUqbUozi/LtCpHACzYCqpv8D3VPOyVlDsULdgk15SM3sHVAeuPN1uosjG9Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kJNaCRyV; 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="kJNaCRyV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9336B1F000E9; Tue, 16 Jun 2026 18:43:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781635424; bh=xIGB0chUp0eMl9kAVFkyKZOqvK4HdQ2oFTRR/6MOGdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kJNaCRyVhENkiD//HBIu1i7yulP2BMPakJ9DbxhahjN2+3WulVU/LplBV4ZVpHuqd ZJ1HmS2Mm4/LKQconTk3RD0kIo7eQtLrVq8IQ7nOhFQkbPQdwh+WnJTuZ4EcNGRP+8 jmYS3WeJ2UkhAw9ATlK3OoCU4eQZQDLHO4RXL+Fg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Heikki Krogerus Subject: [PATCH 5.10 045/342] usb: typec: ucsi: ccg: reject firmware images without a : record header Date: Tue, 16 Jun 2026 20:25:41 +0530 Message-ID: <20260616145050.361269856@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145048.348037099@linuxfoundation.org> References: <20260616145048.348037099@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 5.10-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 @@ -1156,6 +1156,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, ':');