From: Zheng Wang <zyytlz.wz@163.com>
To: mchehab@kernel.org
Cc: laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
alex000young@gmail.com, hackerzheng666@gmail.com,
security@kernel.org, hdanton@sina.com,
Zheng Wang <zyytlz.wz@163.com>
Subject: [PATCH v2] media: bttv: fix use after free error due to btv->timeout timer
Date: Thu, 2 Mar 2023 18:04:00 +0800 [thread overview]
Message-ID: <20230302100400.821270-1-zyytlz.wz@163.com> (raw)
There may be some a race condition between timer function
bttv_irq_timeout and bttv_remove. The timer is setup in
probe and there is no timer_delete operation in remove
function. When it hit kfree btv, the function might still be
invoked, which will cause use after free bug.
This bug is found by static analysis, it may be false positive.
Fix it by adding del_timer_sync invoking to the remove function.
cpu0 cpu1
bttv_probe
->timer_setup
->bttv_set_dma
->mod_timer;
bttv_remove
->kfree(btv);
->bttv_irq_timeout
->USE btv
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
---
v2:
- stop replacing del_timer with del_timer_sync suggested by Hillf Danton
---
drivers/media/pci/bt8xx/bttv-driver.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index d40b537f4e98..24ba5729969d 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -4248,6 +4248,7 @@ static void bttv_remove(struct pci_dev *pci_dev)
/* free resources */
free_irq(btv->c.pci->irq,btv);
+ del_timer_sync(&btv->timeout);
iounmap(btv->bt848_mmio);
release_mem_region(pci_resource_start(btv->c.pci,0),
pci_resource_len(btv->c.pci,0));
--
2.25.1
reply other threads:[~2023-03-02 10:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230302100400.821270-1-zyytlz.wz@163.com \
--to=zyytlz.wz@163.com \
--cc=alex000young@gmail.com \
--cc=hackerzheng666@gmail.com \
--cc=hdanton@sina.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=security@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 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.