mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Guard against NULL driver_data in i915_pci_probe()
@ 2026-08-09  9:04 Deepanshu Kartikey
  2026-08-11  6:28 ` Krzysztof Karas
  0 siblings, 1 reply; 4+ messages in thread
From: Deepanshu Kartikey @ 2026-08-09  9:04 UTC (permalink / raw)
  To: jani.nikula, joonas.lahtinen, rodrigo.vivi, tursulin, airlied, simona
  Cc: chris, intel-gfx, dri-devel, linux-kernel, Deepanshu Kartikey,
	syzbot+db96c5ff032f4292a8dc

pci_match_device() can return the dummy pci_device_id_any entry
when a device is force-bound via sysfs driver_override, in which
case ->driver_data is unset (NULL). i915_pci_probe() casts it to
struct intel_device_info * unconditionally and dereferences
intel_info->require_force_probe, causing a NULL-ptr-deref.

Reported-by: syzbot+db96c5ff032f4292a8dc@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=db96c5ff032f4292a8dc
Tested-by: syzbot+db96c5ff032f4292a8dc@syzkaller.appspotmail.com
Fixes: 42f5551d2769 ("drm/i915: Split out the PCI driver interface to i915_pci.c")
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 drivers/gpu/drm/i915/i915_pci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
index 82415af47d54..2f03f95945f1 100644
--- a/drivers/gpu/drm/i915/i915_pci.c
+++ b/drivers/gpu/drm/i915/i915_pci.c
@@ -958,6 +958,9 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		(struct intel_device_info *) ent->driver_data;
 	int err;
 
+	if (!intel_info)
+		return -ENODEV;
+
 	if (intel_info->require_force_probe && !id_forced(pdev->device)) {
 		dev_info(&pdev->dev,
 			 "Your graphics device %04x is not properly supported by i915 in this\n"
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915: Guard against NULL driver_data in i915_pci_probe()
  2026-08-09  9:04 [PATCH] drm/i915: Guard against NULL driver_data in i915_pci_probe() Deepanshu Kartikey
@ 2026-08-11  6:28 ` Krzysztof Karas
  2026-08-11  9:31   ` Jani Nikula
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Karas @ 2026-08-11  6:28 UTC (permalink / raw)
  To: Deepanshu Kartikey
  Cc: jani.nikula, joonas.lahtinen, rodrigo.vivi, tursulin, airlied,
	simona, chris, intel-gfx, dri-devel, linux-kernel,
	syzbot+db96c5ff032f4292a8dc

Hi Deepanshu,

On 2026-08-09 at 14:34:30 +0530, Deepanshu Kartikey wrote:
> pci_match_device() can return the dummy pci_device_id_any entry
> when a device is force-bound via sysfs driver_override, in which
> case ->driver_data is unset (NULL). i915_pci_probe() casts it to
> struct intel_device_info * unconditionally and dereferences
> intel_info->require_force_probe, causing a NULL-ptr-deref.
> 
> Reported-by: syzbot+db96c5ff032f4292a8dc@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=db96c5ff032f4292a8dc
> Tested-by: syzbot+db96c5ff032f4292a8dc@syzkaller.appspotmail.com
> Fixes: 42f5551d2769 ("drm/i915: Split out the PCI driver interface to i915_pci.c")
This "Fixes" tag should point to the commit that breaks stuff,
I believe, so what you are looking for is
7ef5ef5cdead ("drm/i915: add force_probe module parameter to replace alpha_support")
since this patch introduced that unconditional dereference.

> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> ---
>  drivers/gpu/drm/i915/i915_pci.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
> index 82415af47d54..2f03f95945f1 100644
> --- a/drivers/gpu/drm/i915/i915_pci.c
> +++ b/drivers/gpu/drm/i915/i915_pci.c
> @@ -958,6 +958,9 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		(struct intel_device_info *) ent->driver_data;
>  	int err;
>  
> +	if (!intel_info)
> +		return -ENODEV;
> +
>  	if (intel_info->require_force_probe && !id_forced(pdev->device)) {
>  		dev_info(&pdev->dev,
>  			 "Your graphics device %04x is not properly supported by i915 in this\n"
> -- 
> 2.43.0
> 

-- 
Best Regards,
Krzysztof

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915: Guard against NULL driver_data in i915_pci_probe()
  2026-08-11  6:28 ` Krzysztof Karas
@ 2026-08-11  9:31   ` Jani Nikula
  2026-08-13  6:49     ` Deepanshu Kartikey
  0 siblings, 1 reply; 4+ messages in thread
From: Jani Nikula @ 2026-08-11  9:31 UTC (permalink / raw)
  To: Krzysztof Karas, Deepanshu Kartikey
  Cc: joonas.lahtinen, rodrigo.vivi, tursulin, airlied, simona, chris,
	intel-gfx, dri-devel, linux-kernel, syzbot+db96c5ff032f4292a8dc

On Tue, 11 Aug 2026, Krzysztof Karas <krzysztof.karas@intel.com> wrote:
> Hi Deepanshu,
>
> On 2026-08-09 at 14:34:30 +0530, Deepanshu Kartikey wrote:
>> pci_match_device() can return the dummy pci_device_id_any entry
>> when a device is force-bound via sysfs driver_override, in which
>> case ->driver_data is unset (NULL). i915_pci_probe() casts it to
>> struct intel_device_info * unconditionally and dereferences
>> intel_info->require_force_probe, causing a NULL-ptr-deref.
>> 
>> Reported-by: syzbot+db96c5ff032f4292a8dc@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?extid=db96c5ff032f4292a8dc
>> Tested-by: syzbot+db96c5ff032f4292a8dc@syzkaller.appspotmail.com
>> Fixes: 42f5551d2769 ("drm/i915: Split out the PCI driver interface to i915_pci.c")
> This "Fixes" tag should point to the commit that breaks stuff,

In general, agreed...

> I believe, so what you are looking for is
> 7ef5ef5cdead ("drm/i915: add force_probe module parameter to replace alpha_support")
> since this patch introduced that unconditional dereference.

...but that didn't introduce the unconditional reference. I think it was
always there. We've always expected .driver_data to point at whatever we
have specified in MODULE_DEVICE_TABLE().

I'd just slap a Cc: stable on it without Fixes.


BR,
Jani.

>
>> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
>> ---
>>  drivers/gpu/drm/i915/i915_pci.c | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
>> index 82415af47d54..2f03f95945f1 100644
>> --- a/drivers/gpu/drm/i915/i915_pci.c
>> +++ b/drivers/gpu/drm/i915/i915_pci.c
>> @@ -958,6 +958,9 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>>  		(struct intel_device_info *) ent->driver_data;
>>  	int err;
>>  
>> +	if (!intel_info)
>> +		return -ENODEV;
>> +
>>  	if (intel_info->require_force_probe && !id_forced(pdev->device)) {
>>  		dev_info(&pdev->dev,
>>  			 "Your graphics device %04x is not properly supported by i915 in this\n"
>> -- 
>> 2.43.0
>> 

-- 
Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915: Guard against NULL driver_data in i915_pci_probe()
  2026-08-11  9:31   ` Jani Nikula
@ 2026-08-13  6:49     ` Deepanshu Kartikey
  0 siblings, 0 replies; 4+ messages in thread
From: Deepanshu Kartikey @ 2026-08-13  6:49 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Krzysztof Karas, joonas.lahtinen, rodrigo.vivi, tursulin,
	airlied, simona, chris, intel-gfx, dri-devel, linux-kernel,
	syzbot+db96c5ff032f4292a8dc

On Tue, Aug 11, 2026 at 3:01 PM Jani Nikula <jani.nikula@linux.intel.com> wrote:
>
> On Tue, 11 Aug 2026, Krzysztof Karas <krzysztof.karas@intel.com> wrote:
> > Hi Deepanshu,
> >
> > On 2026-08-09 at 14:34:30 +0530, Deepanshu Kartikey wrote:
> >> pci_match_device() can return the dummy pci_device_id_any entry
> >> when a device is force-bound via sysfs driver_override, in which
> >> case ->driver_data is unset (NULL). i915_pci_probe() casts it to
> >> struct intel_device_info * unconditionally and dereferences
> >> intel_info->require_force_probe, causing a NULL-ptr-deref.
> >>
> >> Reported-by: syzbot+db96c5ff032f4292a8dc@syzkaller.appspotmail.com
> >> Closes: https://syzkaller.appspot.com/bug?extid=db96c5ff032f4292a8dc
> >> Tested-by: syzbot+db96c5ff032f4292a8dc@syzkaller.appspotmail.com
> >> Fixes: 42f5551d2769 ("drm/i915: Split out the PCI driver interface to i915_pci.c")
> > This "Fixes" tag should point to the commit that breaks stuff,
>
> In general, agreed...
>
> > I believe, so what you are looking for is
> > 7ef5ef5cdead ("drm/i915: add force_probe module parameter to replace alpha_support")
> > since this patch introduced that unconditional dereference.
>
> ...but that didn't introduce the unconditional reference. I think it was
> always there. We've always expected .driver_data to point at whatever we
> have specified in MODULE_DEVICE_TABLE().
>
> I'd just slap a Cc: stable on it without Fixes.
>
>
> BR,
> Jani.
>
> >
> >> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> >> ---
> >>  drivers/gpu/drm/i915/i915_pci.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
> >> index 82415af47d54..2f03f95945f1 100644
> >> --- a/drivers/gpu/drm/i915/i915_pci.c
> >> +++ b/drivers/gpu/drm/i915/i915_pci.c
> >> @@ -958,6 +958,9 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >>              (struct intel_device_info *) ent->driver_data;
> >>      int err;
> >>
> >> +    if (!intel_info)
> >> +            return -ENODEV;
> >> +
> >>      if (intel_info->require_force_probe && !id_forced(pdev->device)) {
> >>              dev_info(&pdev->dev,
> >>                       "Your graphics device %04x is not properly supported by i915 in this\n"
> >> --
> >> 2.43.0
> >>
>
> --
> Jani Nikula, Intel

Thanks for the review. I have sent patch v2.

Deepanshu

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-13  6:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-09  9:04 [PATCH] drm/i915: Guard against NULL driver_data in i915_pci_probe() Deepanshu Kartikey
2026-08-11  6:28 ` Krzysztof Karas
2026-08-11  9:31   ` Jani Nikula
2026-08-13  6:49     ` Deepanshu Kartikey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®