Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2826063pxv; Mon, 12 Jul 2021 02:54:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6RE7gCgGQ1maD88SBH3r1uvNQEN1s4dscoeWYg17wzuAKk+thvRTRrYrWcz/dSi0HsjKx X-Received: by 2002:a92:905:: with SMTP id y5mr20174126ilg.222.1626083646860; Mon, 12 Jul 2021 02:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083646; cv=none; d=google.com; s=arc-20160816; b=Y5hGRzi94yi8LAYcNpyexVt1HvJbFR20vU4BkC44hvK5fzDQYZNQVoDgDa5NDi6TPo vurR1A/Fn2J9Tx3zoRj3ZU1l5HhrwCioqR2E2bwq8gofH0qPTIKgdCxMdQrU5rgHNLYL QOChuiadpO0+fEJkDgoVlf21M5bw/vmNYTVSEUuf36DU+j3m64Ot9cCdBWnD/xhJPs+R OlnomMiCKrUzOVsUVxXGLCd80SLgrbFeE/Fx6FV8EXDt/WU2IJeyjEAi2g8cRxTG7ZQ0 /4aCe+ft1t3w3I+wP5sewA2UL2PLtQZrBRgaiR2Mq7spyEQK2eJ3GlY6C+NmF3vlle59 /mgg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2/yNn+GpBEIm7gdkmi2e/f+3amogiIiv9ZkpXCT2b0I=; b=C/CfKH80L1D3zFcLsE0P7O8MM1BOjXbuOCKZ9zg0bIfaoTcpfc5XgiKUWS3PPO2HYI 0aBwO/z1uU/+GGptVLVgzSHnP7IXt/e6rEAMeZx+nFHiOCZu+Y5nQFbMv701EVPT87P7 DErjEXTl64kksqxuct1VDk8Pr+/c1PlnEu62BAXc1Rdi+LdinYuIpAD7tU0lZvAsV5Pk IP2R0f/58Zrl17ruKbFSq7K0ByAWb1sM4UBTXlADFh3Z6LeK64vsOn3TyOhWVkoMVBh7 0OCPLncuP2oGVuUorJ3Xi3OiPtFwQcO/auTrwsrT+5Db+sJdY6stf3bleT2HYpASVvei 2+8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aAYebhG2; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si18279063jav.18.2021.07.12.02.53.55; Mon, 12 Jul 2021 02:54:06 -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=@linuxfoundation.org header.s=korg header.b=aAYebhG2; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240699AbhGLGwB (ORCPT + 99 others); Mon, 12 Jul 2021 02:52:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:34338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238371AbhGLGkJ (ORCPT ); Mon, 12 Jul 2021 02:40:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C130860FD8; Mon, 12 Jul 2021 06:37:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071821; bh=E5BnYOzIC2rS0Shxh1oJ1QRMJjd/fLnsEcaEPllvfao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aAYebhG2xBI2zPDtYySHXjItBbmF6JDH1H6z+v7lYgBRK7uHv5ebWLQ5n9fpo15hw jaZhLKVG4dWzmoQw7gs/dY3Z8DnAOxrKXW8wq1ZnmhqazFUTSQkCfAJtVaLSuhQI52 NhaoyXWxRyURjc8hZPDkY18mAcncqrryxGXj8eAI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lv Yunlong , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 233/593] media: exynos4-is: Fix a use after free in isp_video_release Date: Mon, 12 Jul 2021 08:06:33 +0200 Message-Id: <20210712060908.540696907@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lv Yunlong [ Upstream commit 01fe904c9afd26e79c1f73aa0ca2e3d785e5e319 ] 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 uses a variable 'is_singular_file' to avoid the uaf. v3: https://lore.kernel.org/patchwork/patch/1419058/ Fixes: 34947b8aebe3f ("[media] exynos4-is: Add the FIMC-IS ISP capture DMA driver") Signed-off-by: Lv Yunlong Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/exynos4-is/fimc-isp-video.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c index 8d9dc597deaa..83688a7982f7 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c @@ -305,17 +305,20 @@ static int isp_video_release(struct file *file) struct fimc_is_video *ivc = &isp->video_capture; struct media_entity *entity = &ivc->ve.vdev.entity; struct media_device *mdev = entity->graph_obj.mdev; + bool is_singular_file; mutex_lock(&isp->video_lock); - if (v4l2_fh_is_singular_file(file) && ivc->streaming) { + is_singular_file = v4l2_fh_is_singular_file(file); + + if (is_singular_file && ivc->streaming) { media_pipeline_stop(entity); ivc->streaming = 0; } _vb2_fop_release(file, NULL); - if (v4l2_fh_is_singular_file(file)) { + if (is_singular_file) { fimc_pipeline_call(&ivc->ve, close); mutex_lock(&mdev->graph_mutex); -- 2.30.2