From patchwork Fri Apr 5 15:51:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dikshita Agarwal X-Patchwork-Id: 786632 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0654416C45E; Fri, 5 Apr 2024 15:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712332350; cv=none; b=bIk3vO2N3Fu8YTX6v9/Sk+XdF94m1TDAj+eO+4qxQd3bq7DaL3bp66CxSzMiwKJHo7YRA8k4Pypbgisd/WLXDy3xsVS+TcNSNGsKQvcs8iYMH70lSJJxaKQSBEXcAaAuZvZtFtD52u02gDpk/wGkuOogfTrOzddOGN3dqXgGX1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712332350; c=relaxed/simple; bh=0DLwPXtz3s/pnpDyHKeyGJUx5h2MKJ57J8vOGPMiy/c=; h=From:To:Cc:Subject:Date:Message-Id; b=BESQYpEplEZtaQgMljUlYXB0Mvoyjc2AuyQpNzWwsR2wapg2pm98W+Uppzppb5Qw1Cq1Z/OGq/vuuYwk//jwMbs+VOaqc0p8Vpkuk0p2epfRxHeSM3hRs6fIrDatEY77ZjOptfGYtGp7jf0fED/F8Ga7br+m7GB1n6NsuudzTjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=FDOCrt2C; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="FDOCrt2C" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 435CUeX8010410; Fri, 5 Apr 2024 15:52:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id; s=qcppdkim1; bh=sG1XfZTCDkK5 lGZiblJPHTJdQCUMcIt2vLP9MBa3y/g=; b=FDOCrt2CyWpUzvcOXWQuIEh/Y945 r3i+y8KDvr4qLAJhiaDr2i2jrR/v6pAxOpkvwLlmQo+V3HwwMlA5eJ7xZtthlfep +lhiurRhzpOLhLUSK+M5jZwYk86cx7vadtjKyQU+5Ys+8ws+91Zc9NKBbVNUIrBH awqWyCNlouQmIhB3JoXHKr28oNt7fdTBGbP8hH0xhLQZ2llH/IkxBlpwCXAr01Rn UCJJRt55330h2yAUP0mTvwyu2112A/HffggRShhzSjgF6Nb4ZA2euvgmCrygzbp4 t9JGFQWeaLxhN9vvvP2/jj6Nol514+al+oaplY1hx3uxG8W0ZwqDqFA6Tg== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xahb10fyn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Apr 2024 15:52:24 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 435FqLQP014489; Fri, 5 Apr 2024 15:52:21 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3x6btmhjcb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 05 Apr 2024 15:52:21 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 435FqLno014468; Fri, 5 Apr 2024 15:52:21 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-dikshita-hyd.qualcomm.com [10.213.110.13]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 435FqKlb014465; Fri, 05 Apr 2024 15:52:21 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 347544) id 85BA42F4D; Fri, 5 Apr 2024 21:22:19 +0530 (+0530) From: Dikshita Agarwal To: Stanimir Varbanov , Vikash Garodia , Bjorn Andersson , Konrad Dybcio , Mauro Carvalho Chehab Cc: "Bryan O'Donoghue" , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Dikshita Agarwal Subject: [PATCH] media: venus: fix use after free in vdec_close Date: Fri, 5 Apr 2024 21:21:59 +0530 Message-Id: <1712332319-11767-1-git-send-email-quic_dikshita@quicinc.com> X-Mailer: git-send-email 2.7.4 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: r8h5ePs04KIbg_F1SCrB67TU-uymLv6c X-Proofpoint-GUID: r8h5ePs04KIbg_F1SCrB67TU-uymLv6c X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-05_17,2024-04-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 spamscore=0 malwarescore=0 impostorscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404050112 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: There appears to be a possible use after free with vdec_close(). The firmware will add buffer release work to the work queue through HFI callbacks as a normal part of decoding. Randomly closing the decoder device from userspace during normal decoding can incur a read after free for inst. Fix it by cancelling the delayed work in vdec_close. Signed-off-by: Dikshita Agarwal --- drivers/media/platform/qcom/venus/vdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 29130a9..8dda46a 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1747,6 +1747,7 @@ static int vdec_close(struct file *file) vdec_pm_get(inst); + cancel_delayed_work_sync(&inst->delayed_process_work); v4l2_m2m_ctx_release(inst->m2m_ctx); v4l2_m2m_release(inst->m2m_dev); vdec_ctrl_deinit(inst);