Skip to contentSkip to conversation

usb: host: xhci_debugfs: Fix a null pointer dereference in xhci_debugfs_create_endpoint()

PATCH In review Jia-Ju Bai 3 participants 4 messages May 4, 2019 – May 6, 2019

Subsystems (2)
lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH 1/1 usb: host: xhci_debugfs: Fix a null pointer dereference in xhci_debugfs_create_endpoint()

In xhci_debugfs_create_slot(), kzalloc() can fail and dev->debugfs_private will be NULL.
In xhci_debugfs_create_endpoint(), dev->debugfs_private is used without any null-pointer check, and can cause a null pointer dereference.

To fix this bug, a null-pointer check is added in
xhci_debugfs_create_endpoint().

This bug is found by a runtime fuzzing tool named FIZZER written by us.

---
 drivers/usb/host/xhci-debugfs.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/host/xhci-debugfs.c +3 -0
index cadc01336bf8..7ba6afc7ef23 100644
@@ -440,6 +440,9 @@ void xhci_debugfs_create_endpoint(struct xhci_hcd *xhci,
 	struct xhci_ep_priv	*epriv;
 	struct xhci_slot_priv	*spriv = dev->debugfs_private;
 
+	if (!spriv)
+		return;
+
 	if (spriv->eps[ep_index])
 		return;
 
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Jia-Ju Bai

In xhci_debugfs_create_slot(), kzalloc() can fail and dev->debugfs_private will be NULL.
In xhci_debugfs_create_endpoint(), dev->debugfs_private is used without any null-pointer check, and can cause a null pointer dereference.

To fix this bug, a null-pointer check is added in
xhci_debugfs_create_endpoint().

This bug is found by a runtime fuzzing tool named FIZZER written by us.

Very rare case, but nice fix. You should put "potential" in your subject line as this is something that no one should ever hit :)

Anyway:

author
#2 lore raw
Quoted 6 lines · Greg KH
Quoted 5 lines · Jia-Ju Bai

In xhci_debugfs_create_slot(), kzalloc() can fail and dev->debugfs_private will be NULL.
In xhci_debugfs_create_endpoint(), dev->debugfs_private is used without any null-pointer check, and can cause a null pointer dereference.

Quoted 8 lines
Quoted 6 lines

To fix this bug, a null-pointer check is added in
xhci_debugfs_create_endpoint().

This bug is found by a runtime fuzzing tool named FIZZER written by us.

Very rare case, but nice fix. You should put "potential" in your subject line as this is something that no one should ever hit :)

Okay, Greg, thanks for this advice :)

Best wishes,
Jia-Ju Bai

#3 lore raw
Quoted 12 lines · Jia-Ju Bai
Quoted 9 lines · Greg KH
Quoted 8 lines · Jia-Ju Bai

In xhci_debugfs_create_slot(), kzalloc() can fail and dev->debugfs_private will be NULL.
In xhci_debugfs_create_endpoint(), dev->debugfs_private is used without any null-pointer check, and can cause a null pointer dereference.

To fix this bug, a null-pointer check is added in
xhci_debugfs_create_endpoint().

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

This bug is found by a runtime fuzzing tool named FIZZER written by us.

Very rare case, but nice fix.  You should put "potential" in your subject line as this is something that no one should ever hit :)

Okay, Greg, thanks for this advice :)

Adding patch to queue, and added "potential" to subject line.

-Mathias