[PATCH OLK-6.6 0/2] Fix CVE-2026-31729
Fix CVE-2026-31729. Nathan Rebello (2): usb: typec: ucsi: validate connector number in ucsi_notify_common() usb: typec: ucsi: skip connector validation before init drivers/usb/typec/ucsi/ucsi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.34.1
From: Nathan Rebello <nathan.c.rebello@gmail.com> mainline inclusion from mainline-v7.0-rc7 commit d2d8c17ac01a1b1f638ea5d340a884ccc5015186 category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/14479 CVE: CVE-2026-31729 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- The connector number extracted from CCI via UCSI_CCI_CONNECTOR() is a 7-bit field (0-127) that is used to index into the connector array in ucsi_connector_change(). However, the array is only allocated for the number of connectors reported by the device (typically 2-4 entries). A malicious or malfunctioning device could report an out-of-range connector number in the CCI, causing an out-of-bounds array access in ucsi_connector_change(). Add a bounds check in ucsi_notify_common(), the central point where CCI is parsed after arriving from hardware, so that bogus connector numbers are rejected before they propagate further. Fixes: bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") Cc: stable <stable@kernel.org> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Nathan Rebello <nathan.c.rebello@gmail.com> Link: https://patch.msgid.link/20260313222453.123-1-nathan.c.rebello@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Conflicts: drivers/usb/typec/ucsi/ucsi.c [lhb: context conflicts, due to 584e8df58942 ("usb: typec: ucsi: extract common code for command handling") reconstruct the code which has some dependencies so we choose to adapt the original code.] Signed-off-by: Hongbo Li <lihongbo22@huawei.com> --- drivers/usb/typec/ucsi/ucsi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index b88f4e179a7a..3ad2a4e883d6 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -960,7 +960,14 @@ static void ucsi_handle_connector_change(struct work_struct *work) */ void ucsi_connector_change(struct ucsi *ucsi, u8 num) { - struct ucsi_connector *con = &ucsi->connector[num - 1]; + struct ucsi_connector *con; + + if (num > ucsi->cap.num_connectors) { + dev_err(ucsi->dev, "bogus connector number in CCI: %u\n", + num); + return; + } + con = &ucsi->connector[num - 1]; if (!(ucsi->ntfy & UCSI_ENABLE_NTFY_CONNECTOR_CHANGE)) { dev_dbg(ucsi->dev, "Early connector change event\n"); -- 2.34.1
From: Nathan Rebello <nathan.c.rebello@gmail.com> mainline inclusion from mainline-v7.0 commit 5a1140404cbf7ba40137dfb1fb96893aa9a67d68 category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/14479 CVE: CVE-2026-31729 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- Notifications can arrive before ucsi_init() has populated ucsi->cap.num_connectors via GET_CAPABILITY. At that point num_connectors is still 0, causing all valid connector numbers to be incorrectly rejected as bogus. Skip the bounds check when num_connectors is 0 (not yet initialized). Pre-init notifications are already handled safely by the early-event guard in ucsi_connector_change(). Reported-by: Takashi Iwai <tiwai@suse.de> Fixes: d2d8c17ac01a ("usb: typec: ucsi: validate connector number in ucsi_notify_common()") Cc: stable@vger.kernel.org Signed-off-by: Nathan Rebello <nathan.c.rebello@gmail.com> Tested-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20260407063958.863-1-nathan.c.rebello@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Conflicts: drivers/usb/typec/ucsi/ucsi.c [lhb: Context conflicts] Signed-off-by: Hongbo Li <lihongbo22@huawei.com> --- drivers/usb/typec/ucsi/ucsi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 3ad2a4e883d6..4f5a72a1fbd8 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -962,17 +962,17 @@ void ucsi_connector_change(struct ucsi *ucsi, u8 num) { struct ucsi_connector *con; - if (num > ucsi->cap.num_connectors) { - dev_err(ucsi->dev, "bogus connector number in CCI: %u\n", - num); + if (!(ucsi->ntfy & UCSI_ENABLE_NTFY_CONNECTOR_CHANGE)) { + dev_dbg(ucsi->dev, "Early connector change event\n"); return; } - con = &ucsi->connector[num - 1]; - if (!(ucsi->ntfy & UCSI_ENABLE_NTFY_CONNECTOR_CHANGE)) { - dev_dbg(ucsi->dev, "Early connector change event\n"); + if (ucsi->cap.num_connectors && num > ucsi->cap.num_connectors) { + dev_err(ucsi->dev, "bogus connector number in CCI: %u\n", + num); return; } + con = &ucsi->connector[num - 1]; if (!test_and_set_bit(EVENT_PENDING, &ucsi->flags)) schedule_work(&con->work); -- 2.34.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/22244 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/U62... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/22244 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/U62...
participants (2)
-
Hongbo Li -
patchwork bot