From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796355407; b=LbgtTAnZqjG1rE8q76xVzaJeu4wTfitEh0VJ1f0ei/acGGIbzd9r/su937rswRHZa22g pp1mjzhec77lk1qxtwf8AFeBb3G14BRVDFODnVB3OfzhnSJV4uVIdUSGMpgkaxzUB2eHE F1xm0eSQg7yiT47c8vW0Zn4aK6DeoKDMia34L2N6WFV8cMq2nB2ikL/rqixe9cYpZKp8M nBSyct/ZM8nbu8PlVx0YixxKWhoaEuNGzrvYbDnvVFQTuOPXsssoJW9Orvv/H6xrwBvMU 7V54kEIfVWkmQp8NrtVrnlHbZcv0JI9hlAsplVo4vwxUFOYHjLPwZ5VDjAPdJ1rzLAQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796355407; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=ky1oPijr3MnhheKXMEO7YdyT1o+eyqrXQmeHwlOATEw=; b=4JjzFvviXU9TcCC2p9rmkf85GcP5WycIzhlDfyVNo1HGhms9ce+PWvJxDKJZ2po7npj8 vkH0qAobYLidGwaaJMvYcysWeRD4ljUJPFTl4onmMAfKNJ3CVgCbZSd4ByHPFVD7g6OsF HvkLhEEZ6BZJ5KFpefCugB+K9c2nWAYwd1kzrHLxXCaGLXET7STCAslI11+K/vY5IVtpc cLDJ/7uZD2h91VmaNH2aPiz/Eyly5AlwrewiY1B/E0NdSafen9FvdgU61o6ZsuRDsD3uV R0Zvw2sDinnOAaGK0K5q2ijtJwF7KKoEIuWfIeQEwNjO0SHwVJBLmXgY90hsZQWUcQw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=kXfCnOVk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D888E606A33F; Fri, 4 Dec 2026 03:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=kXfCnOVk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1ABB31F00933; Fri, 4 Dec 2026 03:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796355407; bh=ky1oPijr3MnhheKXMEO7YdyT1o+eyqrXQmeHwlOATEw=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=kXfCnOVkgVnzUXHB3APz7zPMlhIaepUpglUB3Shsm+CGCl5vPeUs6jiF+WBsEtitQ zt7/Nm8eCj5sHjumx2x5rd820Vy0lzCRJhiUHq4TipzIiCMfVNE32LtQFNrhCXhpcr Q8qp0bhc6uPJHwZkEKJJiWzWQAWv75F3SfRCOiRo= Date: Thu, 3 Dec 2026 22:41:05 +0100 From: Greg KH To: Kyle Tso Cc: badhri@google.com, heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v1] usb: typec: tcpm: Fix out-of-bounds read of the pds and pd_list arrays Message-ID: <2026120344-remission-sixth-d367@gregkh> References: <20261013081549.2375441-1-kyletso@google.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261013081549.2375441-1-kyletso@google.com> On Tue, Oct 13, 2026 at 08:15:49AM +0000, Kyle Tso wrote: > select_usb_power_delivery_show() iterates through port->pds (via the > pd_get() callback) and tcpm_find_pd_data() iterates through > port->pd_list until they find a NULL entry. However, tcpm_fw_get_caps() > allocates only port->pd_count entries for each array, and > tcpm_port_register_pd() fills all of them. Without a NULL terminator, > both loops read and dereference one entry past the end: > > Unable to handle kernel paging request at virtual address > adacafaea9a8ac1a > Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP > pc : select_usb_power_delivery_show+0xa4/0x110 > lr : select_usb_power_delivery_show+0x90/0x110 > Call trace: > select_usb_power_delivery_show+0xa4/0x110 > dev_attr_show+0x38/0x74 > sysfs_kf_seq_show+0xb4/0x130 > kernfs_seq_show+0x44/0x54 > seq_read_iter+0x158/0x4ec > kernfs_fop_read_iter+0x68/0x1bc > vfs_read+0x230/0x2c0 > ksys_read+0x78/0xe8 > __arm64_sys_read+0x1c/0x2c > invoke_syscall+0x58/0x118 > el0_svc_common+0xb4/0xf4 > do_el0_svc+0x24/0x80 > el0_svc+0x2c/0x90 > el0t_64_sync_handler+0x68/0xb4 > el0t_64_sync+0x1a4/0x1a8 > > Allocate one extra, zeroed entry for both arrays so that they are > always NULL-terminated. > > Fixes: cd099cde4ed2 ("usb: typec: tcpm: Support multiple capabilities") > Cc: stable@kernel.org > Reviewed-by: Badhri Jagan Sridharan > Signed-off-by: Kyle Tso > Acked-by: Heikki Krogerus > --- > drivers/usb/typec/tcpm/tcpm.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > index d721baef5210..8f4e10ec6d66 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -8376,14 +8376,21 @@ static int tcpm_fw_get_caps(struct tcpm_port *port, struct fwnode_handle *fwnode > } > } > > - port->pds = devm_kcalloc(port->dev, port->pd_count, sizeof(struct usb_power_delivery *), > + /* > + * Allocate one extra entry for each array to keep them NULL-terminated. > + * select_usb_power_delivery_show() iterates through port->pds (via the > + * pd_get callback) until it finds a NULL entry. Similarly, > + * tcpm_find_pd_data() iterates through port->pd_list until it finds a > + * NULL entry. > + */ > + port->pds = devm_kcalloc(port->dev, port->pd_count + 1, sizeof(struct usb_power_delivery *), > GFP_KERNEL); > if (!port->pds) { > ret = -ENOMEM; > goto put_capabilities; > } > > - port->pd_list = devm_kcalloc(port->dev, port->pd_count, sizeof(struct pd_data *), > + port->pd_list = devm_kcalloc(port->dev, port->pd_count + 1, sizeof(struct pd_data *), > GFP_KERNEL); > if (!port->pd_list) { > ret = -ENOMEM; > -- > 2.56.0.385.gd3acb90ef8-goog > Does not apply to my usb-testing branch, can you rebase and resend and keep the reviewed-by lines? thanks, greg k-h