Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4228465pxy; Mon, 26 Apr 2021 23:07:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkUl/VYsmnDfAh4BRDSDdXQ32N+Gelwbx8+RplppI4rioZ7LL3o+gknTfgV0CfzNIEFcbi X-Received: by 2002:a17:907:7629:: with SMTP id jy9mr4837733ejc.34.1619503636126; Mon, 26 Apr 2021 23:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619503636; cv=none; d=google.com; s=arc-20160816; b=FT0b3N5XWXQxJ/NB6OETs1XdNWYL4UrXYOPt3R2GCxC4JywGqCZ4Lk4g62NsT324dI dQmmUfs3BDTlF3AS4K3hMfeo89CKlDziWp+LCzcXDzmfLYO+MlRtjG1HmZbdXsA2Nf3J FDqwOxmTYhp+Qt70xOlFhvvpUaPkYSvGAnalpq9q4oye+L9heQvRScPEDJl/2t0eKKNJ HEQxFqPcl3sJoGom5TEOvILpsdX3KNBnLQRSb2TnuShjsn2ILyiT/XEFC9QIw06A/hMd 07kkazQmJw4Ol7m/Tsg0X5tYCZrB9q4rSiLPRYmxCrxf7cMA0hYp0sqlGMABLLDFgmf8 EBBA== 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=v7OI+JeiSLNOWCbMsyFE1LhROWob97JvYTX1veuCAAU=; b=hH/AXe914dOQs22rjigWC9WA2+EJgxn0AP6acXPnsHpVOpV4v5BRzUbcZBcBnayZJW l9kW+Vi1iDRPHCjVmSdqUeEfvFpIRWKmfXqT2dkDjADFgkyfYkzA939z57vEYUxdLKOG 7DZSo3ve4abo7c2gtLs/D1asoC+q7PDi2FA1hfX4U4iH77U2jsoJU8w9Pn8ldwp7pEX5 lQZ8jmX936/RPeFXFxJlPGGdwRgZN+s+xxPmUM5J5BPezG4ig83OdNfArIKt5XvJsQSV dlYuy1bVUQLqa7kFEPnXWoCxEPjeVw5745hbkRawHossVatkUWZfAQpKrmAGySfVc7M6 EsMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=ZWfrAn0f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z18si1673168edb.55.2021.04.26.23.06.52; Mon, 26 Apr 2021 23:07:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=ZWfrAn0f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231475AbhD0GDx (ORCPT + 99 others); Tue, 27 Apr 2021 02:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbhD0GDw (ORCPT ); Tue, 27 Apr 2021 02:03:52 -0400 Received: from ustc.edu.cn (email6.ustc.edu.cn [IPv6:2001:da8:d800::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ADB6AC061574; Mon, 26 Apr 2021 23:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ustc.edu.cn; s=dkim; h=Received:From:To:Cc:Subject:Date: Message-Id:MIME-Version:Content-Transfer-Encoding; bh=v7OI+JeiSL NOWCbMsyFE1LhROWob97JvYTX1veuCAAU=; b=ZWfrAn0f2Fhph6gtaTWDkhOFOM ySQ67mX//jP5+bixOfxos2EB/JBehAvPUrRuyAWGRt2RqpqDGaSpsFFBA3/KJuUW EbzF1JBtKyxpLO9aPjYXVGPDTMpSp2Er7gBNHVFfWK0SNieQefIa/N5nxQNEZjRW SN74mnNbxUzG5ngqY= Received: from ubuntu.localdomain (unknown [202.38.69.14]) by newmailweb.ustc.edu.cn (Coremail) with SMTP id LkAmygDHz68RqYdgrVNQAA--.2285S4; Tue, 27 Apr 2021 14:02:57 +0800 (CST) From: Lv Yunlong To: s.nawrocki@samsung.com, mchehab@kernel.org, krzk@kernel.org Cc: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Lv Yunlong Subject: [PATCH v2] media:exynos4-is: Fix a use after free in isp_video_release Date: Mon, 26 Apr 2021 23:02:55 -0700 Message-Id: <20210427060255.3318-1-lyl2019@mail.ustc.edu.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: LkAmygDHz68RqYdgrVNQAA--.2285S4 X-Coremail-Antispam: 1UD129KBjvdXoW7Gw1UXFWfZF4rtF13tr4ktFb_yoWkurX_Z3 48KFn7Xry5tr4jy3WqyFn5ZrW0yrZ8Xa93CanagFW2y3yUAFWxtF4qkrWfu3ZrGa17GFZ8 Jrs8XF4UCr93CjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbsAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_ Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI 64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8Jw Am72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAG YxC7MxkIecxEwVAFwVW8AwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8Jw C20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAF wI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjx v20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2 z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnU UI43ZEXa7VUjylk7UUUUU== X-CM-SenderInfo: ho1ojiyrz6zt1loo32lwfovvfxof0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In isp_video_release, file->private_data is freed via _vb2_fop_release()->v4l2_fh_release(). But the freed file->private_data is still used in v4l2_fh_is_singular_file() ->v4l2_fh_is_singular(file->private_data), which is a use after free bug. My patch set file->private_data to NULL after _vb2_fop_release() to avoid the use after free. Fixes: 34947b8aebe3f ("[media] exynos4-is: Add the FIMC-IS ISP capture DMA driver") Signed-off-by: Lv Yunlong --- drivers/media/platform/exynos4-is/fimc-isp-video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c index 612b9872afc8..2e04589068b4 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c @@ -315,7 +315,8 @@ static int isp_video_release(struct file *file) } _vb2_fop_release(file, NULL); - + file->private_data = NULL; + if (v4l2_fh_is_singular_file(file)) { fimc_pipeline_call(&ivc->ve, close); -- 2.25.1