From patchwork Tue Mar 21 10:21:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ekansh Gupta X-Patchwork-Id: 72791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1694592wrt; Tue, 21 Mar 2023 03:26:07 -0700 (PDT) X-Google-Smtp-Source: AK7set9yvdG7NvL1MMD/wa/bydpk+sM7JjWm2iHnjO2v5+a9ZWp2xMGMjj+a7rjavpPYltDvx3OB X-Received: by 2002:a05:6a20:1b21:b0:d9:f539:728a with SMTP id ch33-20020a056a201b2100b000d9f539728amr1370941pzb.25.1679394366772; Tue, 21 Mar 2023 03:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679394366; cv=none; d=google.com; s=arc-20160816; b=ogej7YrViiqw7mcR8xcMfHbTZZiNwOs6beNP8V2hnmdjp1hNA0to29wwrJH/QGWFj3 BP0bLIfcAkAGfaRkprc2us4CC/wZ0ZQvmyDmhaHfPJkCs2QGSnfoUCKUDTZL/A4S77KB b2lloVb44REG6Gp8jit4vKUpvTV6cYCLEw3u2if13IoJL7yvWNT3uDVrctHCLEmJaEgh Je2QULAwQVjjEXlI90eOQ7/kETGtTnZ7re2SwqfRdaMAZ5djCzB7Jx4Q8eYR06HCm4i/ bpXKqDbr+mPT/73Oc1ysSWSMFIXTCVPBWnQTVEevEf11DQMsn0kGvOA/h1eCaWE615Rw OJUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=K+XQnICK4w06YswGKZJZo7fmlVOCaCrIH6hlqTXENxw=; b=tSn15sxXuSK/EaBrYhmu31qdbc+bA0tmONgeP/YBejgKSue7GBOtAG/+l7m1qVeOyX r7ORhTRBTqUkLq+tuu/MX97lZ5kzTsVX0XrVDr9fW1ymyYjbzeGhlICEDGxW0OlB2xZq /zW0vJ3Q/EvaxTPwUf0XbvxFMVbrD+kho/IDpIOhdp6dWckJ6Jd+WKvJ5Rbf9+lN5C/Y p2AFrMsdAXKa6k7ySAMEx0iGo7xlteR12BeurzLYnmWG4H6BzHPookwnzENiNo+n9ASy ux79Ed+fTwVuIHE7YellxZYp/Kuli9gFTRjZRsD0q4LRDYC587MfAgdG/XXW28vFOIai jJ7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=kdKzuxpa; 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=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v3-20020a63d543000000b00502ffff6533si12792959pgi.88.2023.03.21.03.25.53; Tue, 21 Mar 2023 03:26:06 -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=@quicinc.com header.s=qcppdkim1 header.b=kdKzuxpa; 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=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230047AbjCUKWG (ORCPT + 99 others); Tue, 21 Mar 2023 06:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbjCUKWF (ORCPT ); Tue, 21 Mar 2023 06:22:05 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E1549FD; Tue, 21 Mar 2023 03:21:59 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32KMiGYT005985; Tue, 21 Mar 2023 10:21:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=K+XQnICK4w06YswGKZJZo7fmlVOCaCrIH6hlqTXENxw=; b=kdKzuxpaGE/IIV8jqSMrx5xx8wSYa1fxDmYBdyyKOoaQ2rtN0Mh09huOf1PmZ3fLud20 cK/YnvfXIcjkhx9MyCJoe6OQTkz62Kc70GMtIuvmz/Y8XO7xCVYKyWeLYr+UaLsqG8+a 6Y5nv4WDIM5eTFPDfiw/Xpij+DzcgGV+9KeDy8EvCcJcD0/RUh8MRimYcRuFb7FU6Uk+ ZgO2X72gKRCAxVAYc92F9BHPAXLZ6MBn6/OzgTL8KvaPAXWqvmDm85zT1XYO2/DboxKW ZJVJslKKHytM/kaU1WySu7rL2p1n6Q3qIu4j3TwJgiO8S8N5bchg4cFAZOhUvSjcJ5GY bw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pen6huau0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Mar 2023 10:21:54 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32LALr9S002730 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Mar 2023 10:21:53 GMT Received: from ekangupt-linux.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.986.41; Tue, 21 Mar 2023 03:21:50 -0700 From: Ekansh Gupta To: , CC: Ekansh Gupta , , , , , , stable Subject: [PATCH v1] misc: fastrpc: Reassign memory ownership only for remote heap Date: Tue, 21 Mar 2023 15:51:40 +0530 Message-ID: <1679394100-27119-1-git-send-email-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) 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: Vlyqw66tOpxkGXOfifmhCS_fh_E7BJkA X-Proofpoint-GUID: Vlyqw66tOpxkGXOfifmhCS_fh_E7BJkA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-21_07,2023-03-21_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 malwarescore=0 priorityscore=1501 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 impostorscore=0 phishscore=0 clxscore=1011 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303210079 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760972627217375093?= X-GMAIL-MSGID: =?utf-8?q?1760972627217375093?= The userspace map request for remote heap allocates CMA memory. The ownership of this memory needs to be reassigned to proper owners to allow access from the protection domain running on DSP. This reassigning of ownership is not correct if done for any other supported flags. When any other flag is requested from userspace, fastrpc is trying to reassign the ownership of memory and this reassignment is getting skipped for remote heap request which is incorrect. Add proper flag check to reassign the memory only if remote heap is requested. Fixes: 532ad70c6d44 ("misc: fastrpc: Add mmap request assigning for static PD pool") Cc: stable Tested-by: Ekansh Gupta Signed-off-by: Ekansh Gupta Reviewed-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index a701132..9b88132 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1892,7 +1892,7 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) req.vaddrout = rsp_msg.vaddr; /* Add memory to static PD pool, protection thru hypervisor */ - if (req.flags != ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { + if (req.flags == ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { struct qcom_scm_vmperm perm; perm.vmid = QCOM_SCM_VMID_HLOS;