From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Zwane Mwaikambo <zwanem@gmail.com>
Cc: Randy Dunlap <rdunlap@infradead.org>,
Greg KH <gregkh@linuxfoundation.org>,
Zwane Mwaikambo <zwane@yosper.io>,
linux-usb@vger.kernel.org
Subject: Re: [PATCH v4 2/2] usb/typec: fix array overruns in ucsi.c partner_altmode[]
Date: Fri, 28 Aug 2020 15:41:10 +0300 [thread overview]
Message-ID: <20200828124110.GG174928@kuha.fi.intel.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2008271135000.37762@montezuma.home>
On Thu, Aug 27, 2020 at 11:35:53AM -0700, Zwane Mwaikambo wrote:
> This fixes the second array overrun occurrence (similar failure mode to
> the first), this time in ucsi_unregister_altmodes.
>
> [ 4373.153246] BUG: kernel NULL pointer dereference, address:
> 00000000000002f2
> [ 4373.153267] #PF: supervisor read access in kernel mode
> [ 4373.153271] #PF: error_code(0x0000) - not-present page
> [ 4373.153275] PGD 0 P4D 0
> [ 4373.153284] Oops: 0000 [#2] PREEMPT SMP NOPTI
> [ 4373.153292] CPU: 0 PID: 13242 Comm: kworker/0:0 Tainted: G D
> 5.8.0-rc6+ #1
> [ 4373.153296] Hardware name: LENOVO 20RD002VUS/20RD002VUS, BIOS R16ET25W
> (1.11 ) 04/21/2020
> [ 4373.153308] Workqueue: events ucsi_handle_connector_change [typec_ucsi]
> [ 4373.153320] RIP: 0010:ucsi_unregister_altmodes+0x5f/0xa0 [typec_ucsi]
> [ 4373.153326] Code: 54 48 8b 3b 41 83 c4 01 e8 9e f9 0c 00 49 63 c4 48 c7
> 03 00 00 00 00 49 8d 5c c5 00 48 8b 3b 48 85 ff 74 31 41 80 fe 01 75 d7
> <0f> b7 87 f0 02 00 00 66 3d 01 ff 74 0f 66 3d 55 09 75 c4 83 bf f8
> [ 4373.153332] RSP: 0018:ffffb2ef036b3dc8 EFLAGS: 00010246
> [ 4373.153338] RAX: 000000000000001e RBX: ffff94268b006a60 RCX:
> 0000000080800067
> [ 4373.153342] RDX: 0000000080800068 RSI: 0000000000000001 RDI:
> 0000000000000002
> [ 4373.153347] RBP: ffffb2ef036b3de8 R08: 0000000000000000 R09:
> ffffffff8dc65400
> [ 4373.153351] R10: ffff9426678d7200 R11: 0000000000000001 R12:
> 000000000000001e
> [ 4373.153355] R13: ffff94268b006970 R14: 0000000000000001 R15:
> ffff94268b006800
> [ 4373.153361] FS: 0000000000000000(0000) GS:ffff942691400000(0000)
> knlGS:0000000000000000
> [ 4373.153366] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 4373.153371] CR2: 00000000000002f2 CR3: 00000004445a6005 CR4:
> 00000000003606f0
> [ 4373.153375] Call Trace:
> [ 4373.153389] ucsi_unregister_partner.part.0+0x17/0x30 [typec_ucsi]
> [ 4373.153400] ucsi_handle_connector_change+0x25c/0x320 [typec_ucsi]
> [ 4373.153418] process_one_work+0x1df/0x3d0
> [ 4373.153428] worker_thread+0x4a/0x3d0
> [ 4373.153436] ? process_one_work+0x3d0/0x3d0
> [ 4373.153444] kthread+0x127/0x170
> [ 4373.153451] ? kthread_park+0x90/0x90
> [ 4373.153461] ret_from_fork+0x1f/0x30
> [ 4373.153661] CR2: 00000000000002f2
>
> Signed-off-by: Zwane Mwaikambo <zwane@yosper.io>
This is also fixing something.
Fixes: ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes")
Cc: stable@vger.kernel.org
Signed-off-by: Zwane Mwaikambo <zwane@yosper.io>
> ---
>
> This v4 addresses patch formatting and submission issues with the
> previous versions.
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index d0c63afaf..79061705e 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -479,7 +480,10 @@ static void ucsi_unregister_altmodes(struct ucsi_connector *con, u8 recipient)
> return;
> }
>
> - while (adev[i]) {
> + for (i = 0; i < UCSI_MAX_ALTMODES; i++) {
> + if (!adev[i])
> + break;
> +
> if (recipient == UCSI_RECIPIENT_SOP &&
> (adev[i]->svid == USB_TYPEC_DP_SID ||
> (adev[i]->svid == USB_TYPEC_NVIDIA_VLINK_SID &&
> @@ -488,7 +492,7 @@ static void ucsi_unregister_altmodes(struct ucsi_connector *con, u8 recipient)
> ucsi_displayport_remove_partner((void *)pdev);
> }
> typec_unregister_altmode(adev[i]);
> - adev[i++] = NULL;
> + adev[i] = NULL;
> }
> }
>
--
heikki
next prev parent reply other threads:[~2020-08-28 12:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-27 17:49 [PATCH v3 1/2] usb/typec: fix array overruns in ucsi.c partner_altmode[] Zwane Mwaikambo
2020-08-27 17:52 ` [PATCH v3 2/2] " Zwane Mwaikambo
2020-08-27 17:54 ` [PATCH v3 1/2] " Randy Dunlap
2020-08-27 18:29 ` Zwane Mwaikambo
2020-08-27 18:34 ` [PATCH v4 " Zwane Mwaikambo
2020-08-27 18:35 ` [PATCH v4 2/2] " Zwane Mwaikambo
2020-08-28 12:41 ` Heikki Krogerus [this message]
2020-08-28 12:33 ` [PATCH v4 1/2] " Heikki Krogerus
2020-08-30 9:26 ` [PATCH v5 " Zwane Mwaikambo
2020-08-30 9:28 ` [PATCH v5 2/2] " Zwane Mwaikambo
2020-09-09 12:33 ` Heikki Krogerus
2020-09-09 15:07 ` Randy Dunlap
2020-09-10 7:49 ` Zwane Mwaikambo
2020-09-03 11:10 ` [PATCH v5 1/2] " Heikki Krogerus
2020-09-04 17:33 ` Zwane Mwaikambo
2020-09-09 13:10 ` Heikki Krogerus
2020-09-10 7:52 ` Zwane Mwaikambo
2020-09-10 12:50 ` Heikki Krogerus
2020-09-11 2:13 ` Zwane Mwaikambo
[not found] ` <20200911135618.GA4168153@kuha.fi.intel.com>
2020-09-14 13:49 ` Heikki Krogerus
2020-09-14 17:56 ` Zwane Mwaikambo
2020-09-16 7:59 ` Heikki Krogerus
2020-09-17 20:55 ` Zwane Mwaikambo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200828124110.GG174928@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=zwane@yosper.io \
--cc=zwanem@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).