Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6316841rwp; Mon, 17 Jul 2023 20:24:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlHNTH/QbWz70ZFRyFmAOStGgYm45EEI/OQb1+cz8UV+paOyeVLj0CgxTo0MXOjSaUSO7G// X-Received: by 2002:a17:902:f809:b0:1b7:db37:fada with SMTP id ix9-20020a170902f80900b001b7db37fadamr11353031plb.58.1689650662401; Mon, 17 Jul 2023 20:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689650662; cv=none; d=google.com; s=arc-20160816; b=YyJixfzbKBgifC8zo6dALte94ayInCzY/Urh6xkSKuCcCyOM19hDW5d5cQZG1F1sQs UgF3cuAkQqf8kjqBOEL4+SAaoxlsJJBQ2b1fJF3skiH5pr9NO2aosHI7kQTkRtvwwi7I KrxcSSyDeSGUKQAT3R0iGUynRaKP4/qavroS8UOSLKoyTY8SFGyJ+YUsJFd4ggrpHaHs Wbj1FH19tbLVMTXK29n2QULXlL6F8i10Z602PBtLchGlUrDdqr+XGs1V5RZ0A07Ogrwf e3ZVHam3OgyHGUmUC1oSVz2R8B+K1S3o7NErBLcNqN3o4pPaTh00I7BBQqqbLRjWNl8+ IGTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ZR7e5E+WmOjH4SVZ3PNZKQQ2pHiOOZ9mhP0U68A34Cw=; fh=iLsyqu1Pu0Q8hTAhBdNXKxsAPeWFtFmikKrLzCiI7pM=; b=YyI7nq9iCbC0H2IXIG4WJMbSn2fptnaAi0yWq1/Q4df8+AdNQPxgGcE/CoEEgqzggk OqqKOvUb3GzGbMgVJ8yXiHoj/bWKOcg9qgf4mWBTr9r94IBA1dK0AE0VX94v/vcjFxZn So7/rk9vtEtAlmPH1qcwoUM11tTpdpxooibRuY26p8jKs2ec9xaZmaBEnhXA9rj1FGWp jZRveDQZ0E8/CjumDEnN9fpS+S5US/HVPX4QvRQp9TcdX0fEcKVyP9ekcNH3Sf9X5ZNw dVtVahDkycuECjLbHTCq4jKMCXtggGC2OhkgpNI+p4/Plg1TKl4F8oBepjGeSbqaDG0G 65Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=HUHR94cp; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e15-20020a170902cf4f00b001adc5bc4d8asi849891plg.572.2023.07.17.20.24.09; Mon, 17 Jul 2023 20:24:22 -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=@gmail.com header.s=20221208 header.b=HUHR94cp; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230049AbjGRDHQ (ORCPT + 99 others); Mon, 17 Jul 2023 23:07:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbjGRDHN (ORCPT ); Mon, 17 Jul 2023 23:07:13 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32110E56; Mon, 17 Jul 2023 20:07:13 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-55fcc15e109so2223025a12.3; Mon, 17 Jul 2023 20:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689649632; x=1692241632; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ZR7e5E+WmOjH4SVZ3PNZKQQ2pHiOOZ9mhP0U68A34Cw=; b=HUHR94cp0/UyIKqtiyeZR237f5pSW8N8ZgQeHBP69YoNqbDBpIRRspMez7/dR1nSbA D5qJU15tV4LQDuoPeHx89HfUhOvGAvlGJvcEcI929f/Hf7zgzkNWNFGMJzI29PCKoWFZ Q+Q+KjcYKiZkXEef/XVx+m7w17eXuuo5Im6eQtys0XDz671hCNxckfAIvKtd6bREZzaX Vg647wlCoZixVN3W6uwFW4cQrqIaj69+VKx37sM9j6spDuWw3n53TOCC4UA9YYQJFCwe i3LRzJd25ksEZlUmDvDuAD5KJBQn6mWePTI/l+yd0/W8dWubcXYiqlxiqDSzu7zEnaUw Hk7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689649632; x=1692241632; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZR7e5E+WmOjH4SVZ3PNZKQQ2pHiOOZ9mhP0U68A34Cw=; b=fRGdGDCAjFf1oOz8zyFTkfPsgmkcdi4kRB+UHEBz06odEtGssK/yt42MwtzKrwSgYp qE7m2om9nb7uWn1sjGV7Ok71XRqMINp0kmpT0eYO4ee6i4OYox9bmPTt5KdgvOnz5+Ac gZ00/p8zyR2C6uj0Tk498KdapnzbV6n39NCtMGGDpz3oi8A+Ql6T8z6arDdBB4wQPPYw adsXNh3GJRVqws0+AOooB9KWxQJyv/A2cAHr+NZqUNmyhL6mFQC7bsywqBp+diORTo+f b9gc+1rlcz21YcBcppoLXq3Q6j0ShudKkYYjsFE5h0qle1Rd/kia+3Tr1uELpdiVm8fp P4IQ== X-Gm-Message-State: ABy/qLYYU7NTv7KqEuMqfc4YNzQPe0U+ap0nZhvnfh5p/V/8fN3mVEMu nZjtQnTZy8eXjME1+pFwsGkBeaU7eva1buz20So= X-Received: by 2002:a17:90a:fb83:b0:263:f3ad:64af with SMTP id cp3-20020a17090afb8300b00263f3ad64afmr10685369pjb.45.1689649632428; Mon, 17 Jul 2023 20:07:12 -0700 (PDT) MIME-Version: 1.0 References: <20230707092414.866760-1-zyytlz.wz@163.com> <538096d2-7b24-e1c7-706d-4d4f952d35eb@baylibre.com> In-Reply-To: From: Zheng Hacker Date: Tue, 18 Jul 2023 11:07:01 +0800 Message-ID: Subject: Re: [RESEND PATCH v2] media: mtk-jpeg: Fix use after free bug due to uncanceled work To: Alexandre Mergnat Cc: Zheng Wang , Kyrie.Wu@mediatek.com, bin.liu@mediatek.com, mchehab@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Irui.Wang@mediatek.com, security@kernel.org, 1395428693sheep@gmail.com, alex000young@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org Friendly ping Zheng Hacker =E4=BA=8E2023=E5=B9=B47=E6=9C=8816= =E6=97=A5=E5=91=A8=E6=97=A5 00:08=E5=86=99=E9=81=93=EF=BC=9A > > Hi, > > This issue has not been resolved for a long time. Is there anyone who can= help? > > Best regards, > Zheng > > Alexandre Mergnat =E4=BA=8E2023=E5=B9=B47=E6=9C= =887=E6=97=A5=E5=91=A8=E4=BA=94 22:11=E5=86=99=E9=81=93=EF=BC=9A > > > > > > > > On 07/07/2023 11:24, Zheng Wang wrote: > > > In mtk_jpeg_probe, &jpeg->job_timeout_work is bound with > > > mtk_jpeg_job_timeout_work. Then mtk_jpeg_dec_device_run > > > and mtk_jpeg_enc_device_run may be called to start the > > > work. > > > If we remove the module which will call mtk_jpeg_remove > > > to make cleanup, there may be a unfinished work. The > > > possible sequence is as follows, which will cause a > > > typical UAF bug. > > > > > > Fix it by canceling the work before cleanup in the mtk_jpeg_remove > > > > > > CPU0 CPU1 > > > > > > |mtk_jpeg_job_timeout_work > > > mtk_jpeg_remove | > > > v4l2_m2m_release | > > > kfree(m2m_dev); | > > > | > > > | v4l2_m2m_get_curr_priv > > > | m2m_dev->curr_ctx //use > > > > Reviewed-by: Alexandre Mergnat > > > > -- > > Regards, > > Alexandre