Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D60732C182 for ; Wed, 28 Feb 2024 08:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709108200; cv=none; b=RzFmp7t+Molags3G9aj/KEbl/fNFrklXtuey7eBwZ6hZXUvbIaHzx3GP27EvkpmywFeH4NJICIHyDuZS93AYyVNluzJT3LVzilkxQ+3o7KpA+M9UpcOW0CfaJl1Itd7u6mB4/liwDhQVZU3S0MUOBPN2coPA7ggXtgv9qB+dP8s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709108200; c=relaxed/simple; bh=3FUPwBXgUqIOxOGm6m3+KLF4jSzckGZ/2MTwuExgGPU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=k6jjAQIAISGDdISf+DsBJlhUkz+AyyjfqRlUqERCpX8Ive5o+84JiyQ9OvlTsUlZORzS6d5O/WnMZZX2fdVwLKkAPzpbMboslmgkTyNlB1+4Ze0WFjgRiaKEUApATNR8+naUuHNDcQGKW5CA+ZxIK49OIU2RukYHneyCqCbq7g8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Bb80sW9a; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Bb80sW9a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 646DCC433F1; Wed, 28 Feb 2024 08:16:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709108200; bh=3FUPwBXgUqIOxOGm6m3+KLF4jSzckGZ/2MTwuExgGPU=; h=From:To:Cc:Subject:Date:Reply-to:From; b=Bb80sW9aZUHDBAe/zHMx1qTINzDDDegELY1o9ra1yuTv8WKT7QEmP0AuUVBRUAro8 NTstc7433xxiwwdzC+AYP2BL0i1GzgCzQ15JcZqL+6gRKxNCzBEPHD63ooFs6KRw62 NeLc88zXVTb3FvgC7Y4blfi2zyH2JZZxjhbjZSjk= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: gregkh@kernel.org Subject: CVE-2021-46980: usb: typec: ucsi: Retrieve all the PDOs instead of just the first 4 Date: Wed, 28 Feb 2024 09:14:30 +0100 Message-ID: <2024022823-CVE-2021-46980-adda@gregkh> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3890; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=HIGwNy3pL5VpaMsADIHr5DtKtkGHy7OEzb//+7e2Wsg=; b=owGbwMvMwCRo6H6F97bub03G02pJDKn3XsczSoufvVW78uyj85O7cjYYPrjUN03t7+uX4dc/r np2cU9obUcsC4MgE4OsmCLLl208R/dXHFL0MrQ9DTOHlQlkCAMXpwBMhG8lwzz1L/eq3prNDypR t0t6fXrNRTUPCy+GucKbveeePjl7Wfv3/DlcRtF74nj2mQMA X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: gregkh@kernel.org Description =========== In the Linux kernel, the following vulnerability has been resolved: usb: typec: ucsi: Retrieve all the PDOs instead of just the first 4 commit 4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") introduced retrieval of the PDOs when connected to a PD-capable source. But only the first 4 PDOs are received since that is the maximum number that can be fetched at a time given the MESSAGE_IN length limitation (16 bytes). However, as per the PD spec a connected source may advertise up to a maximum of 7 PDOs. If such a source is connected it's possible the PPM could have negotiated a power contract with one of the PDOs at index greater than 4, and would be reflected in the request data object's (RDO) object position field. This would result in an out-of-bounds access when the rdo_index() is used to index into the src_pdos array in ucsi_psy_get_voltage_now(). With the help of the UBSAN -fsanitize=array-bounds checker enabled this exact issue is revealed when connecting to a PD source adapter that advertise 5 PDOs and the PPM enters a contract having selected the 5th one. [ 151.545106][ T70] Unexpected kernel BRK exception at EL1 [ 151.545112][ T70] Internal error: BRK handler: f2005512 [#1] PREEMPT SMP ... [ 151.545499][ T70] pc : ucsi_psy_get_prop+0x208/0x20c [ 151.545507][ T70] lr : power_supply_show_property+0xc0/0x328 ... [ 151.545542][ T70] Call trace: [ 151.545544][ T70] ucsi_psy_get_prop+0x208/0x20c [ 151.545546][ T70] power_supply_uevent+0x1a4/0x2f0 [ 151.545550][ T70] dev_uevent+0x200/0x384 [ 151.545555][ T70] kobject_uevent_env+0x1d4/0x7e8 [ 151.545557][ T70] power_supply_changed_work+0x174/0x31c [ 151.545562][ T70] process_one_work+0x244/0x6f0 [ 151.545564][ T70] worker_thread+0x3e0/0xa64 We can resolve this by instead retrieving and storing up to the maximum of 7 PDOs in the con->src_pdos array. This would involve two calls to the GET_PDOS command. The Linux kernel CVE team has assigned CVE-2021-46980 to this issue. Affected and fixed versions =========================== Issue introduced in 5.8 with commit 4dbc6a4ef06d and fixed in 5.10.38 with commit e5366bea0277 Issue introduced in 5.8 with commit 4dbc6a4ef06d and fixed in 5.11.22 with commit a453bfd7ef15 Issue introduced in 5.8 with commit 4dbc6a4ef06d and fixed in 5.12.5 with commit 5e9c6f58b01e Issue introduced in 5.8 with commit 4dbc6a4ef06d and fixed in 5.13 with commit 1f4642b72be7 Please see https://www.kernel.org or a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2021-46980 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: drivers/usb/typec/ucsi/ucsi.c drivers/usb/typec/ucsi/ucsi.h Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/e5366bea0277425e1868ba20eeb27c879d5a6e2d https://git.kernel.org/stable/c/a453bfd7ef15fd9d524004d3ca7b05353a302911 https://git.kernel.org/stable/c/5e9c6f58b01e6fdfbc740390c01f542a35c97e57 https://git.kernel.org/stable/c/1f4642b72be79757f050924a9b9673b6a02034bc