Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp252605lqp; Tue, 11 Jun 2024 03:36:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWm14svfNYUaZ7OjgpwrAovt7y1l+Umq1OGA9Pwfp95zccHkDOoSGLUcx2MSOZzAY3p/twrEfKKYKXCxjdawfNtTYHpab8Fu2G5WK4Dzg== X-Google-Smtp-Source: AGHT+IFsbHaKU7GhhN8CE8WR4pBgbUxOjKbiG756UQ5BaU/UAgSCNbnGyN5LMVtsJVeQoOQIcXMe X-Received: by 2002:a17:906:d189:b0:a6e:f66a:e0d7 with SMTP id a640c23a62f3a-a6ef66ae1eamr614322366b.15.1718102196539; Tue, 11 Jun 2024 03:36:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718102196; cv=pass; d=google.com; s=arc-20160816; b=R+0hAFtMPGuJa0k6tYPkozvziW+h4n5RRrnb1weH6O0jQbJdn7uL/QNwsytG2cgdkr p+z1H2vDZBBKIuauiwiDSkJCEbuPdsrG+JwUwp6AmVBSu6o8BkL7Bhv2Z80usseC0Lwz DuEtyhHBCjtgqvzZE+O28n/qJk4ixq6PeTwS5xgR0F1CsIoV/Zu0RmXiNe8miBxMragJ YGZCmzfdDKjTpC6rEWVxnpenWHKx2ShzvYzLjlywCIhqVG6SiGysc1Sw36/YX/Zy4eSy dHeZwh2VHj7hD71emLaPG3SYPHCMHfUjBEXCsyAMFhqFVG6oTB5QH3syc6SO1yVMTYnd DcAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xga9InphqIU5F07DXzKaKU5bC87YGm1DVFw4tUuTkng=; fh=diZmGYJcu01zmNbcPcyhEp2Q9qdQcYqGq04YRZeL26M=; b=hJp+XCKPrNKKYttareoBnzggiBHoEz9XVv/4Hli1kNySrR37WY8bTNB717kf0RnAqq H4QllT/uLszIr2ISlmHMBfnYjAYTMuqVlZNa7LGJUHCwBPN9LPlHG8yvwxf16tlZt3cQ ZPBg7dOehbjROK7NAkY2R/f3YPDHXZveY5YkLGq2gmWehLTK+nnr6ZEW2g+2tp5+M4DY FmH4pZatkPLH9yxGfQNNHgc+0uXAXTIIqzXuR57RhU7NFMCdo0pVIbEu39ah9ooYJKfl IhtgtODY55yReHE/W3VD8LxZQjrdFhCK4V0T1qSlaTo+slSGObCRlx1pwnwZ4epxM+AL 0BtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=VxhFOk7N; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-209657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209657-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6ef60fef25si396552866b.714.2024.06.11.03.36.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 03:36:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=VxhFOk7N; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-209657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209657-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4050E1F22D95 for ; Tue, 11 Jun 2024 10:36:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87BDC17BB1D; Tue, 11 Jun 2024 10:35:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="VxhFOk7N" 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 5051117BB02; Tue, 11 Jun 2024 10:35:17 +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=1718102118; cv=none; b=RFOgdWA5LghLzTgVTejwirMkvXrXwmgULx1MZcCpfbQFHqzSCkHsSkWxayX3YXtT0rLxztFpMnh5rBYPt7H5lypurx8KXbGF0trLD6Iy/8v9gtrqH6iqSHuQnNktIBWG0h2itYUDvgJ51cQekKiR7UvlBeqgZadFhsQL8dS1FfM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718102118; c=relaxed/simple; bh=U939Gfmb3mBRjAVfdODo5fX4Bh5668p3KhMUIh4Z590=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LQLAyLrq9SZ0Al9HbkXh2gun8X1MnvKADpEz9OMmK3LjCMg6CyLhYGBUuqEVmCLArPIxumCZwfqUWdQ/39EtKRa+9uiO/F2Ooyc9OQ0LD7imkjlwbThgp38RiI7wFi3PbQdHaP+ujW7612XxQpnt9aNT4ypPCPi1guKiHhibTrw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=VxhFOk7N; 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=quicinc.com Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45B9g8lO018399; Tue, 11 Jun 2024 10:35:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= xga9InphqIU5F07DXzKaKU5bC87YGm1DVFw4tUuTkng=; b=VxhFOk7NLvVS5Fro iM+EB/EhrUHeQwX1qV1Ad2+vyLk25wkmIPVX7hcCQmwxe4Cs0HW3Hj++n9EigU1t /aF42zYKZM41RhypODz3sDP25NcbkHlEH0ez1UTgxepQy1hDzuyESXq7EUKLtTyu 6Y1S/eD3+mhVuEYHgWMetpQsDwaLkhH/bav1XViILo8MzAJgnGb1gtkAVqdU2YSs c1kFwWAxpiWntVgGJhAiGCwDGQ22B9VpD36mLBh3Xs83FbBiUYAb9kB5FX8Kkj78 RbHNX/pcxKGtltmVr/1cfDAX/VX6Wp3wQZZuTUglJVQiqb2h4xoYk+ssXPSeC9J3 C/V7Jw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ypm6b8476-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jun 2024 10:35:12 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 45BAZBnL023208 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jun 2024 10:35:11 GMT Received: from hu-ekangupt-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 11 Jun 2024 03:35:08 -0700 From: Ekansh Gupta To: , CC: , , , , stable Subject: [PATCH v5 6/7] misc: fastrpc: Fix ownership reassignment of remote heap Date: Tue, 11 Jun 2024 16:04:39 +0530 Message-ID: <20240611103442.27198-7-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240611103442.27198-1-quic_ekangupt@quicinc.com> References: <20240611103442.27198-1-quic_ekangupt@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: YmyhnHDrWQLIWHQH_3MDrfxe7uAqzPDr X-Proofpoint-GUID: YmyhnHDrWQLIWHQH_3MDrfxe7uAqzPDr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-11_06,2024-06-11_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406110080 Audio PD daemon will allocate memory for audio PD dynamic loading usage when it is attaching for the first time to audio PD. As part of this, the memory ownership is moved to the VM where audio PD can use it. In case daemon process is killed without any impact to DSP audio PD, the daemon process will retry to attach to audio PD and in this case memory won't be reallocated. If the invoke fails due to any reason, as part of err_invoke, the memory ownership is getting reassigned to HLOS even when the memory was not allocated. At this time the audio PD might still be using the memory and an attemp of ownership reassignment would result in memory issue. Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd") Cc: stable Signed-off-by: Ekansh Gupta --- drivers/misc/fastrpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 1ba85c70e3ff..24dc1cba40e9 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1238,6 +1238,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, struct fastrpc_phy_page pages[1]; char *name; int err; + bool scm_done = false; struct { int pgid; u32 namelen; @@ -1289,6 +1290,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err); goto err_map; } + scm_done = true; } } @@ -1324,7 +1326,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, return 0; err_invoke: - if (fl->cctx->vmcount) { + if (fl->cctx->vmcount && scm_done) { u64 src_perms = 0; struct qcom_scm_vmperm dst_perms; u32 i; -- 2.43.0