DMA Engine development
 help / color / mirror / Atom feed
From: "Li,Rongqing" <lirongqing@baidu.com>
To: "fenghua.yu@intel.com" <fenghua.yu@intel.com>,
	"dave.jiang@intel.com" <dave.jiang@intel.com>,
	"vkoul@kernel.org" <vkoul@kernel.org>,
	"dmaengine@vger.kernel.org" <dmaengine@vger.kernel.org>
Subject: RE: [PATCH][RFC] dmaengine: idxd: Fix possible Use-After-Free in irq_process_work_list
Date: Tue, 28 May 2024 00:37:05 +0000	[thread overview]
Message-ID: <471a0e5718be42ea968085426e9374f4@baidu.com> (raw)
In-Reply-To: <20240527061920.48626-1-lirongqing@baidu.com>


> I think when the description is freed, it maybe used again because of race, then
> it's next maybe pointer a value that should not be freed
> 
> To prevent this, list_for_each_entry_safe should be used.
> 

Rewrite the commit header:

    dmaengine: idxd: Fix possible Use-After-Free in irq_process_work_list

    The description has been freed in idxd_desc_complete(), should not be used
    in iteration, so replace list_for_each_entry with list_for_each_entry_safe
    to prevent the accessing

    Signed-off-by: Li RongQing <lirongqing@baidu.com>


> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
>  drivers/dma/idxd/irq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c index
> 8dc029c..0c7fed7 100644
> --- a/drivers/dma/idxd/irq.c
> +++ b/drivers/dma/idxd/irq.c
> @@ -611,7 +611,7 @@ static void irq_process_work_list(struct idxd_irq_entry
> *irq_entry)
> 
>  	spin_unlock(&irq_entry->list_lock);
> 
> -	list_for_each_entry(desc, &flist, list) {
> +	list_for_each_entry_safe(desc, n, &flist, list) {
>  		/*
>  		 * Check against the original status as ABORT is software defined
>  		 * and 0xff, which DSA_COMP_STATUS_MASK can mask out.
> --
> 2.9.4


  reply	other threads:[~2024-05-28  1:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27  6:19 [PATCH][RFC] dmaengine: idxd: Fix possible Use-After-Free in irq_process_work_list Li RongQing
2024-05-28  0:37 ` Li,Rongqing [this message]
2024-05-28 16:27 ` Dave Jiang
2024-05-29  9:15   ` [External Mail] " Li,Rongqing

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=471a0e5718be42ea968085426e9374f4@baidu.com \
    --to=lirongqing@baidu.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=fenghua.yu@intel.com \
    --cc=vkoul@kernel.org \
    /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