Skip to content

Commit

Permalink
media: imon: fix access to invalid resource for the second interface
Browse files Browse the repository at this point in the history
imon driver probes two USB interfaces, and at the probe of the second
interface, the driver assumes blindly that the first interface got
bound with the same imon driver.  It's usually true, but it's still
possible that the first interface is bound with another driver via a
malformed descriptor.  Then it may lead to a memory corruption, as
spotted by syzkaller; imon driver accesses the data from drvdata as
struct imon_context object although it's a completely different one
that was assigned by another driver.

This patch adds a sanity check -- whether the first interface is
really bound with the imon driver or not -- for avoiding the problem
above at the probe time.

Reported-by: [email protected]
Closes: https://lore.kernel.org/all/[email protected]/
Tested-by: Ricardo B. Marliere <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
Signed-off-by: Sean Young <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
  • Loading branch information
tiwai authored and Hans Verkuil committed Oct 7, 2023
1 parent 462e108 commit a1766a4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/media/rc/imon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,12 @@ static int imon_probe(struct usb_interface *interface,
goto fail;
}

if (first_if->dev.driver != interface->dev.driver) {
dev_err(&interface->dev, "inconsistent driver matching\n");
ret = -EINVAL;
goto fail;
}

if (ifnum == 0) {
ictx = imon_init_intf0(interface, id);
if (!ictx) {
Expand Down

0 comments on commit a1766a4

Please sign in to comment.