Message ID | 20230313151909.3658925-1-zyytlz.wz@163.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1248328wrd; Mon, 13 Mar 2023 08:24:40 -0700 (PDT) X-Google-Smtp-Source: AK7set9OYjK/pJ9bfx7g21x6uP8rANfeIiZu/wUoxzD7WlXJ1fKJsfnlWm1ZTkuhoi1XQ2M/6vsj X-Received: by 2002:a62:7bc5:0:b0:623:1aeb:e4e with SMTP id w188-20020a627bc5000000b006231aeb0e4emr5177606pfc.3.1678721079795; Mon, 13 Mar 2023 08:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678721079; cv=none; d=google.com; s=arc-20160816; b=r/LQfocFBRk/o+MAUK6mEOwJPgteHGxrrrkv6orG5T1G7X2hgfy8KZauUQWvoXTKf9 CQI5HzCaCbXcy2syO491SUEgQfGFr0MCC3BIdekPmLMJee5+CHRthbNdnVukKeQAh9NY 4H1FlnVYlHai4FAyGTQCTp5yDT36IJBGTlDCMx0rDMsZF3jrb/yRNqk/JvwcNRXVeh4f QExaj+M+FRGc+4Gtr5dwiJpo6c0iMK6Lg+p9Rmv/z4nXlvB3bJTZqcvTMZ++AC1FZihQ yVn1CBmnsNt/kP8iKMPl8Ie4+eRrR+cmyw5oEs9SbH65c8vfUbSlMgBjDKjynNaGeBaE Skqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=jjdVon27HVaeWyXFa+2Rsj/EZI2JFX24oQ2Zjq7vPjQ=; b=IzZ8SJIxCZTZo5YOKAeDEAjeobbAHSGLhbo95tOYlXeSGkV4f+ERn8aH1UHMIiryRr UFLjNRiKSDCQ7hpbRvY6Nz26zpcztVF71JQFbWLBLklktTZRUUnV8+ZWbFoYfzHan+jq ZEI3s3LAs1s+//OnL7UmHx4LHBQX3at+tTQ9p8k6oLqcqW5usOZhEZKcjMYs5DmLzTSA RFI2Dj8INH84tK1g+Ox5Wg/s9p2LdnMp3ufiRx308L+1ptn8Vv70/2+ENvgU8hMMW0P8 xOp74ZVI0SHrS9DgsCr1GwsoNPpOD+LBQL9po+U09zc2ACbFwGtqLstMQByIvUEv9AeO 5Qmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=eP3bEBdN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j25-20020a635519000000b0050239e94bf5si6710465pgb.52.2023.03.13.08.24.24; Mon, 13 Mar 2023 08:24:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=eP3bEBdN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbjCMPUw (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Mon, 13 Mar 2023 11:20:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbjCMPUu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 13 Mar 2023 11:20:50 -0400 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B4A996A9CB; Mon, 13 Mar 2023 08:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=jjdVo n27HVaeWyXFa+2Rsj/EZI2JFX24oQ2Zjq7vPjQ=; b=eP3bEBdNCsNCFPY0XLrSk IHGlJn6GKeRmGFcPM1H1IcOmUYhCT5qoNUeBX0DuNRsESKyAGmG/v1cY3w/lwVBv BMN/e0tRqW0l3V+QbLmmgMK+J4OfUgih+VyadGKl4X99Dpw1ExZCIp4O019Op48U gn8aocpBtm2Sk8umT0bhIs= Received: from leanderwang-LC2.localdomain (unknown [111.206.145.21]) by zwqz-smtp-mta-g4-2 (Coremail) with SMTP id _____wBnXnLvPg9kF8INAA--.4430S2; Mon, 13 Mar 2023 23:19:12 +0800 (CST) From: Zheng Wang <zyytlz.wz@163.com> To: ezequiel@vanguardiasur.com.ar Cc: p.zabel@pengutronix.de, mchehab@kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, hackerzheng666@gmail.com, 1395428693sheep@gmail.com, alex000young@gmail.com, hverkuil@xs4all.nl, Zheng Wang <zyytlz.wz@163.com> Subject: [PATCH v2] media: hantro: fix use after free bug in hantro_remove due to race condition Date: Mon, 13 Mar 2023 23:19:09 +0800 Message-Id: <20230313151909.3658925-1-zyytlz.wz@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wBnXnLvPg9kF8INAA--.4430S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7uFy5uFWUJrWktw17XrWkWFg_yoW8GrWDpF W7KFWakrWjqF47KFn7J3y09ayrCa42gF4xWrZruw13ZF9xtr9rWry0y3WUAas8JrZavFW3 ZF48Jr4rXay2vFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zi-eOJUUUUU= X-Originating-IP: [111.206.145.21] X-CM-SenderInfo: h2113zf2oz6qqrwthudrp/1tbiGhQxU1aEEjcWiQAAsE X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760266634601043015?= X-GMAIL-MSGID: =?utf-8?q?1760266634601043015?= |
Series |
[v2] media: hantro: fix use after free bug in hantro_remove due to race condition
|
|
Commit Message
Zheng Wang
March 13, 2023, 3:19 p.m. UTC
In hantro_probe, vpu->watchdog_work is bound with
hantro_watchdog. Then hantro_end_prepare_run may
be called to start the work.
If we remove the module which will call hantro_remove
to make cleanup, there may be an unfinished work.
The possible sequence is as follows, which will
cause a typical UAF bug.
Fix it by canceling the work before cleanup in hantro_remove.
CPU0 CPU1
|hantro_watchdog
hantro_remove |
v4l2_m2m_release |
kfree(m2m_dev); |
|
| v4l2_m2m_get_curr_priv
| m2m_dev->curr_ctx //use
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
---
v2:
- move the cancel-work-related code to hantro_remove suggested by Hans Verkuil
---
drivers/media/platform/verisilicon/hantro_drv.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index b0aeedae7b65..496024b21b51 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -1099,6 +1099,7 @@ static int hantro_remove(struct platform_device *pdev) v4l2_info(&vpu->v4l2_dev, "Removing %s\n", pdev->name); + cancel_delayed_work_sync(&vpu->watchdog_work); media_device_unregister(&vpu->mdev); hantro_remove_dec_func(vpu); hantro_remove_enc_func(vpu);