All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nilawar, Badal" <badal.nilawar@intel.com>
To: <sashiko-reviews@lists.linux.dev>, <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 4/5] drm/xe/i2c: Expose AMC alert reason through sysfs
Date: Tue, 1 Dec 2026 14:43:28 +0530	[thread overview]
Message-ID: <2b52c302-688b-4995-a559-b7fd8d42fb13@intel.com> (raw)
In-Reply-To: <sashiko-outbox-236738@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1952 bytes --]


On 27-11-2026 12:00, sashiko-bot@kernel.org wrote:
>> @@ -202,13 +255,21 @@ int xe_amc_init(struct xe_i2c *i2c)
>>   	i2c->amc = amc;
>>   	amc->i2c = i2c;
>>   
>> -	return 0;
>> +	ret = amc_create_alert_sysfs(i2c);
>> +	if (ret) {
>> +		kfree(i2c->amc);
>> +		i2c->amc = NULL;
>> +	}
>> +
>> +	return ret;
>>   }
>>   
>>   void xe_amc_exit(struct xe_i2c *i2c)
>>   {
>>   	if (i2c->amc) {
>> +		amc_remove_alert_sysfs(i2c);
>>   		cancel_work_sync(&i2c->amc->work);
>>   		kfree(i2c->amc);
>> +		i2c->amc = NULL;
>>   	}
>>   }
> [Severity: Critical]
> This problem wasn't introduced by this patch, but can xe_amc_exit() race
> with an in-flight SMBus alert interrupt and cause a use-after-free in
> xe_amc_handle_alert() [1]?
>
> In xe_i2c_remove(), xe_i2c_irq_reset() disables hardware interrupts and
> immediately calls xe_amc_exit() without waiting for in-flight interrupt
> handlers to finish:
>
> drivers/gpu/drm/xe/xe_i2c.c:xe_i2c_handle_smbus_alert() {
> 	...
> 	if (stat & DW_IC_SMBUS_INTR_ALERT && i2c->amc)
> 		xe_amc_handle_alert(i2c);
> }
>
> CPU0                              CPU1
> xe_i2c_remove()
>    xe_i2c_irq_reset()
>                                    xe_i2c_handle_smbus_alert()
>                                      if (... && i2c->amc)
>    xe_amc_exit()
>      cancel_work_sync(&i2c->amc->work)
>      kfree(i2c->amc)
>      i2c->amc = NULL
>                                        xe_amc_handle_alert()
>                                          queue_work(..., &i2c->amc->work)
>                                            <-- use-after-free
>
> Queuing the freed work_struct corrupts the workqueue lists and crashes the
> kernel.  Synchronizing the IRQ after xe_i2c_irq_reset() before running
> xe_amc_exit() would prevent the handler from racing with teardown.

This is per-existing issue, will handle this in separate patch.

Thanks,
Badal

>
> [1]https://sashiko.dev/#/bug/linux-e2bb2e7e-d158-4981-a226-338921893668

[-- Attachment #2: Type: text/html, Size: 2805 bytes --]

  reply	other threads:[~2026-12-01  9:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  6:13 [PATCH 0/5] Process AMC alert Badal Nilawar
2026-11-27  6:13 ` [PATCH 1/5] drm/xe: Request cold-reset recovery on AMC thermal trip alert Badal Nilawar
2026-11-27 12:14   ` Gupta, Anshuman
2026-11-27  6:13 ` [PATCH 2/5] drm/xe: Request cold-reset recovery on AMC OOB request alert Badal Nilawar
2026-11-27  6:13 ` [PATCH 3/5] drm/xe: Request cold-reset recovery on AMC CATERR alert Badal Nilawar
2026-11-30 13:41   ` Gupta, Anshuman
2026-11-27  6:13 ` [PATCH 4/5] drm/xe/i2c: Expose AMC alert reason through sysfs Badal Nilawar
2026-11-27  6:30   ` sashiko-bot
2026-12-01  9:13     ` Nilawar, Badal [this message]
2026-11-27 12:19   ` Gupta, Anshuman
2026-11-27  6:13 ` [PATCH 5/5] drm/xe: Request vendor recovery for AMC firmware download alert Badal Nilawar
2026-11-27  6:23   ` sashiko-bot
2026-11-27  6:58 ` ✗ CI.checkpatch: warning for Process AMC alert Patchwork
2026-11-27  7:00 ` ✓ CI.KUnit: success " Patchwork
2026-11-27 21:39 ` ✗ Xe.CI.FULL: failure " Patchwork

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=2b52c302-688b-4995-a559-b7fd8d42fb13@intel.com \
    --to=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.