From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 804CF3E8320 for ; Mon, 25 May 2026 09:45:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779702308; cv=none; b=S5sO9hAworE1oQezYh/u2/pzS4URajrl2vwnipWdgZYQX1l15KpqQ5k1Wdwt+tcw13vGeuAmWdzQNyDhM3HhaS3ophfFe9bQc6R+ETng2Mu7P697amZxTBrBs3qQ5clyr15Hs9B7Atu29vs5EOnuYYnyQY2OrH5WoINycyC027o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779702308; c=relaxed/simple; bh=A6KUs0v4i/FPr/3/c1pnkAS1TY/OzmqmMW4xhcO9MZc=; h=Message-ID:Date:MIME-Version:Subject:To:References:Cc:From: In-Reply-To:Content-Type; b=IwbaGaGYBWJ54tS8qpnUOOL8EZjZw4a5r1UkG3CklHqWeSnmcwhZv4Xdf+bqsvxLjyI1ROtPDHsMNs2ZXdprUQGxmdCH9lvxpatmKTxu2RSUXsggrXuaLscAuiMI26gyFZVJ9sgHtCvswXyzmyugJsROj24PJrcB3A84pScFU1E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=RuOBLe/Q; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=enVfBEpp; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="RuOBLe/Q"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="enVfBEpp" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64P70ppm609776 for ; Mon, 25 May 2026 09:45:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 7SWc0cc22x9nunFWpQzihkc7nKAG+xaM6B4HBtT1Khs=; b=RuOBLe/Qc+HJi5YJ e47jNH2ZR7MpklJuCHi7VtAqgXSUkuA9HckGwKSfOPaatXdYKFkBCJf8x0DvgDsO tqkGEtB/fzRff+OQnF8LFty8HthYnp0Uoi98IdFD5JW3VC8PmnB8TcKKSUt2e5Nt /qmC+kTOCw6vzSkADMD09PLyWY1bSIu/7ux1kcusBtvel9eZ3f+g/KIc023UDJ7y 9tzQf2RY0/9pkrY+IWP/3C7tsu+3GmA+MngxJZSn4MOR2K7IR/Rx3CDKjBFxcsce UeC8Ut2T0h5At40OW5mmKubHTreCUrH5u4u9vqfpuuyoow7mIUIuNnlHawHOQUX9 Fk1jQg== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4eb5h9nxay-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 25 May 2026 09:45:05 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2bdaf8567f3so67030635ad.1 for ; Mon, 25 May 2026 02:45:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779702305; x=1780307105; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=7SWc0cc22x9nunFWpQzihkc7nKAG+xaM6B4HBtT1Khs=; b=enVfBEppd3ErPIaI5lfyiOsLk4d7Xvb0r6NyjRhIBNtMwwIsCZI6GICfj7n63iR2EM UQDb/dCoRJReObTLm1On/HtAOPa4GGw1A/EajmPfJsk6H2SM7NpvEKPehmitSrv8O8s3 NFKYMl4Ygj3JxKNz48k0XM/KuAGy+4FMyeI4OLNcoq91RlLrCeVg3yLrCCetJR1497jW QMw8yh2p6rtAmmIDrpWEMxMP9JGJQY4yRWk762m/Vf6DbF+WCdtckifOvOr+9BlcJ6yI TE8iR5w0cqu04UfyMrRF8XcBPSBgovXEHyi4S/ZmULpI9dlDZcTDpxHgglHloPOcQELZ MUxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779702305; x=1780307105; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7SWc0cc22x9nunFWpQzihkc7nKAG+xaM6B4HBtT1Khs=; b=hGvfMmjlCpVfAYrFllWuW1Abs49HykCvi5vkEEeSwxzFUGXPZu9u7IbG2dVhBD3ssN xQw1M/0NyTFakIP/G1WwzGW1HVXRYZBjsON8WVNdnkqOsUXbI8zZmU32rtz9/LcN0oY7 t7RVNX7wk5rt5XgdY2XsBM7KDWg7825lcJEc2eJ2rLhthKcpETvt254FOrmks10VPDSa oL47/3i+jhMYee772q8gBFe+P7BiKLM/WvbofeF81oz257+nshxbUVtVkofOzmzHlJ8e WwPuy6leMy0z5iQ728dvjby458SKzmZWWeurYAXMPKct4vdM0WCY4jgIF4oSVMBgak3A oQ0w== X-Forwarded-Encrypted: i=1; AFNElJ9XX/+w53GDaA3sWQcvhHfvZBUKnYVGwbe6lnJi8Z9z65jpdkyZCkUcz4zV7i0c8EHeNQ6DX2awqKJCXgg=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0Dfli8XLwfPV5Qc2C3hkBSAkt4Tjn9867jId9aa/9DMHXcmNO pjit4OBBieKHFG0xhIzY8ftRh8Vx/px54vUfZgL5AeBO9KpjIK2R6A2ywA1XbAxFKUwDEY89l9A z98bRmQVC+JfyvMlJcTqcn/3VOSVSKN2M0VNwQR2R5P0mUA/qPE6ciG7jfF+IYWnEiyI= X-Gm-Gg: Acq92OH6iPncpPBE4k9aR24jiFTt9x97+RFM+Ai63KIHlO6FFDKnlrcwSHx35Qfm2MT 6eRsk5AnsBTuEh0+x39Pv8+52Xk7IhrhF+ByHhKk/N0Mfv+mHBsKZFGEmWG8aTfsu9sqeIG0QtB IF2v4LdWJzT0JBCLWvvHxzsSuOQjAQ6KqENy1PMgeEaCDPoBHPsd51A1yJINWnfbUr2UTBsT/eH QrP/y1sddeW+mqtqSYWPmJNbyw60kmCxhb7uxN6/t/83yswKboQUv9GynBnXWi4YMs91ZKeA+cB LtsNkqzZ9kGB6/qIyBT8mE/TwJgAkYj3oUFltBCmql+9YxUZPYgH71Xgfkyl2Za5BPviJ+Owd/N uWSLWbo/jh5M41nwO7etB+SdYL4mlPM0fp8G7R6YkTzHnmAFJoqW+XjQMTXbnf7vAVbstaBi2a/ 8kjXVg+CGHsJRrpxzy X-Received: by 2002:a17:903:11c9:b0:2b0:506b:e6f8 with SMTP id d9443c01a7336-2bea20a2d54mr159277485ad.5.1779702304974; Mon, 25 May 2026 02:45:04 -0700 (PDT) X-Received: by 2002:a17:903:11c9:b0:2b0:506b:e6f8 with SMTP id d9443c01a7336-2bea20a2d54mr159277205ad.5.1779702304487; Mon, 25 May 2026 02:45:04 -0700 (PDT) Received: from [10.133.33.215] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2beb5695c40sm84634895ad.5.2026.05.25.02.45.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 May 2026 02:45:04 -0700 (PDT) Message-ID: Date: Mon, 25 May 2026 17:44:59 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 4/5] misc: fastrpc: Allocate entire reserved memory for Audio PD in probe To: Dmitry Baryshkov References: <20260515124217.20723-1-jianping.li@oss.qualcomm.com> <20260515124217.20723-5-jianping.li@oss.qualcomm.com> Content-Language: en-US Cc: srini@kernel.org, amahesh@qti.qualcomm.com, arnd@arndb.de, Greg KH , abelvesa@kernel.org, jorge.ramirez-ortiz@linaro.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ekansh Gupta , quic_chennak@quicinc.com From: Jianping Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: pN_3_Eb0nhrUedaB3TAbPvOkrhoUJUjm X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTI1MDA5OSBTYWx0ZWRfX0Ey+rPyda7wW eq94EovWdhvjYNV+w6ppBtAWj+purgeMrxbnksi/B+t/SslpEnHrBU4pgk/088Z+OVIb3Osq37c 8Dyi/6LoCO2WhuBDfkzTqD/FO/gWbo7tkkn5gxlMhrv54SUB2y0YAeFVWmSlN7QxM6dTiBvTE+I b4xXLWNmJn1t+HJElF9d6/aRxgwDmd1XVFdxcaU/rTGgLdPpqCKVsBXPLJw/bfAFyE+93FtSyCK 64oo5nKL/pgsGclK4q2qAg3vPyMpRvtYh5m0czpHnN1jny8rCC2JqbZ4Pwkh82IyJFXQvjV8GaY XOxz0UfedVLbaUHX36guYIvHe5WqLAdjwf9LXSObPDJRMCSD8qgPeRyFt+7WU+05F4BnZA75MJA LqSQ1se9nl6ANST6PG71GmoYywOjITmQM58KlCH1wQ1vqEg9l3wjl2hH8qJeTRuvOKHINdFGVj4 aBhlk551d+Mrrbjd8WA== X-Authority-Analysis: v=2.4 cv=H7jrBeYi c=1 sm=1 tr=0 ts=6a141a21 cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=gttq3t2AYlGpivilpbwA:9 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 X-Proofpoint-GUID: pN_3_Eb0nhrUedaB3TAbPvOkrhoUJUjm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-25_02,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 suspectscore=0 clxscore=1015 bulkscore=0 impostorscore=0 spamscore=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605250099 On 5/25/2026 4:32 PM, Dmitry Baryshkov wrote: > On Fri, May 22, 2026 at 03:47:31PM +0800, Jianping Li wrote: >> On 5/15/2026 9:38 PM, Dmitry Baryshkov wrote: >>> On Fri, May 15, 2026 at 08:42:16PM +0800, Jianping Li wrote: >>>> Allocating and freeing Audio PD memory from userspace is unsafe because >>>> the kernel cannot reliably determine when the DSP has finished using the >>>> memory. Userspace may free buffers while they are still in use by the DSP, >>>> and remote free requests cannot be safely trusted. >>>> >>>> Allocate the entire Audio PD reserved-memory region upfront during rpmsg >>>> probe and tie its lifetime to the rpmsg channel. This avoids userspace- >>>> controlled alloc/free and ensures memory is reclaimed only when the DSP >>>> shuts down. >>> So, is this a bugfix or not? Is it possible to make the kernel misbehave >>> without this patch being applied? >> Yes, this is a bug fix. > The tag, cc:stable, clear description as the bugfix? How would anybody > guess if the patch is to be backported to earlier kernels or not? When userspace repeatedly grows the heap, the kernel does not support shrinking it, leading to unbounded memory usage. This can eventually cause memory leak. I will mention this point in the commit message. Thanks, Jianping. > >> Because currently after the audio PD requests to grow the heap, >> the current kernel does not support shrinking the heap, which will all cause memory leaks. >> >> The current modification is to allocate in advance and release uniformly, which will avoid this error. >> >> Thanks, >> Jianping. >> >>>> Signed-off-by: Jianping Li >>>> --- >>>> drivers/misc/fastrpc.c | 107 +++++++++++++++++++---------------------- >>>> 1 file changed, 49 insertions(+), 58 deletions(-) >>>>