From mboxrd@z Thu Jan 1 00:00:00 1970 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 0E9C63E6DD5 for ; Wed, 17 Jun 2026 10:20:41 +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=1781691649; cv=none; b=lYfeKyjogpRf6D9QTU/tEdXjj80Ql/MrMzb5WvKutvXZ7eht6NuiolHuikdkkQ+U1Cyy0/hQ50loCKRjVeRdxUfZxDKi+jvs3GmipgYiuHhOwcQlQKFZ4L+tabA2LLGjYYyRVKXkwOS7kW8GD3ywzY/Gkbq3QuYoiu8JNFKoR3U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781691649; c=relaxed/simple; bh=WuP5u/ZoxribT8PGwz8TXVGN3HwyXXM3wzG9TYRQ4K8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=U4wZyHeidU3yxncnouTdn+m+PWQCy6mUCqYCGhsa4ZiNsh9M5FQymGqrQY1FGNJEI4qD2FSjZJ384CJSm/fieVhUElrDTfL1+Bl+xJ/ZxI8RtvxY4jZ6IMxNQ7WlrUI2/MhtIl+qWPjR5R8Mbq4/DaAFKmYYIKjWQPlh2BwgCPY= 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=TPfnMdTK; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=QVYGQ/2C; arc=none smtp.client-ip=205.220.180.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="TPfnMdTK"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="QVYGQ/2C" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65H8Usf32025364 for ; Wed, 17 Jun 2026 10:20:40 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= Cg2K5gQ16+6GwG5qTL6Bdl6HDq+V+fzBEDj9yIQ9kPc=; b=TPfnMdTKWtxk6qw0 8RCLsC27+b76QXs4DXMpso2qS/qnEb2OYesHWBGHbticyKFhm+RQOhhUfb3s/6QH z8HmIpsFrNYkPVP353XvME+GemVM7/NC/bZpby7DPNDebKyQdFXIO0Hz8xeKneKt w2pC6bS3Bv2Pw7fbPpOqIQJkrg2ADYUisP6OBxfHKosY5MIoUwOVDQCBPEPQiElS vNHmoltvl160K9UYwhc47RJxlku7VJSWUsqej/ms1mUXlbJTiWDhCQM05RpcbbT+ ib8oScklN/lcu2qUKsYH1XP7aOO1SRS2Oz+CF9wbhwzdkhS7Wh2kUUrH5U+S6+4h ahFddQ== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4euees2mc2-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 17 Jun 2026 10:20:40 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-8421f5d76aaso4021346b3a.2 for ; Wed, 17 Jun 2026 03:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1781691640; x=1782296440; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Cg2K5gQ16+6GwG5qTL6Bdl6HDq+V+fzBEDj9yIQ9kPc=; b=QVYGQ/2ChHpHQygK8YbRjhyfARzrQ6ipbQdFaKEGmU70mW8BjQ+r4zybIFgUZOWQbb /Q6SrPx5NUlz/KUNWZFy0b4q5nhbLehi0C0kw1ypYO3fayu/v4Kb6ulkpxpTZ9SBjp/q XZIucW6lPNteu+4TTdqrTVhZzIAQ37eSqaELtec69o9rySfBWC7oI2/X87/uWXGvZdSV NDR0rbdotcbE5XSk9/Jpfy7sI7tI+QnKnuNqwmQHYfdstBOVnnQEf57mM5bkDOXoLOwG B64dtG0H++0RgJYe1p++M3aRzV1FhZDHk9a26U7H3YrnQ1DIeoISRg2acOhZFWnhbIPs lQZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781691640; x=1782296440; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc: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=Cg2K5gQ16+6GwG5qTL6Bdl6HDq+V+fzBEDj9yIQ9kPc=; b=NqRu/o/lwd27g9aN1ujLYBtNy9qTXbBDnF7NuLDwHH8rPpF55Wr4kUicG2759ZU9j2 R7bdHMsgGwV3F/3KIrACbAuENw7icgy9CcD7QSEqZoMKo8JpdwdMwJql9uXqdL9Acwvn Z33lYRzbG/3I9bpd5a7PwfZiY7+8jrZSTfVlDXwhRrL9yqU+0WBB4RiToSL/+p5Lyn6O ifCYGOEkaDIkSJ7S2Q5ak8Ay7eUoWXw0EzS6E6foJnY7GyAro49RAVEp+icpajoJZGE8 GL4MxrKzapANHzD84vouqBeWzAAbAHMDlu5qwcEFykKo3av+iS+slSXes6xJ1SuVicqu 4amA== X-Forwarded-Encrypted: i=1; AFNElJ+s7NMl6yLRdbFm2CH6066Q+/ci7kMmLR2pwtCnIfJRv5C2YtlDp6Iod5Zk7hrbCYNOG2swpCgsH4+kTRA=@vger.kernel.org X-Gm-Message-State: AOJu0YyHXG5gtbFA7PJ4FZzETsP+qprq5WNUFv+DZmluzeuwQUxrvZ+u 6p4cE83MT87A28F7+6GgGmAT5F1bwchbJnyyMYjJmrLnbg1D4IL1GbQ/de52Y72M3hNQK2olI0O m7W1CSRlF3Vbv61OAWqmU7tkg3t45mIlQZ6+43XrNkcod75Ooe/GUfFmyu3PARkHxp2Y= X-Gm-Gg: Acq92OEoJrqpTpHZp42GcTIm+W/8vc/XoqSXrAPKj/n6Hp/Op9E5aNMCQXLKZ1vt4L2 GdlVh9qTP5RA8QPwUzGcf/S+qlPtMhWf64XR/9jMFtRTniErpCoHuKjbXcafJPA8vuyDDwwMb4Z SFbw/40sB5OSne97bcvUB8FX4vP0sQnCm56lCtJFT18bnobT99wpMajtqN7H7EdmpXfW/vAMhG6 JfcjKqGslzhmZ2c4boG2epxhkBWEfHo/TFZxQV0JOAoqvzTz4JAhe1OQiIQxFASIjPspHtPrRA3 IOCd3Hqw/JucAPPSBTtu4xL5Dst4l0bcgPRiJZA6OL1VHJ7xbhgF3Ad3fnJZm1OVfCf7BHFju/t 7TUHD5TWJH5oAxWa0tbna9cpgE4BFLL003EhBkmuDsCAmmzTVcn7dZzRHHpwMAVolgN4lPGw8Gf Kvy2MbMA== X-Received: by 2002:a05:6a00:1397:b0:842:540d:42ea with SMTP id d2e1a72fcca58-84524495c6emr3011227b3a.19.1781691639638; Wed, 17 Jun 2026 03:20:39 -0700 (PDT) X-Received: by 2002:a05:6a00:1397:b0:842:540d:42ea with SMTP id d2e1a72fcca58-84524495c6emr3011203b3a.19.1781691639167; Wed, 17 Jun 2026 03:20:39 -0700 (PDT) Received: from [10.133.33.84] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84531dbbe7fsm370446b3a.14.2026.06.17.03.20.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Jun 2026 03:20:38 -0700 (PDT) Message-ID: <84686669-ec39-46f3-ba28-b6180e630964@oss.qualcomm.com> Date: Wed, 17 Jun 2026 18:20:35 +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 3/3] rpmsg: glink: smem: Use modulo for FIFO tail wrap-around in rx_advance To: Bjorn Andersson Cc: Mathieu Poirier , linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, tony.truong@oss.qualcomm.com, chris.lew@oss.qualcomm.com References: <20260603-rpmsg-improvements-v1-0-dcfc22ed69f7@oss.qualcomm.com> <20260603-rpmsg-improvements-v1-3-dcfc22ed69f7@oss.qualcomm.com> Content-Language: en-US From: Chunkai Deng In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: yOaMdpmEopLNjJx9oBUIiGSb55bKmbS6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE3MDA5NyBTYWx0ZWRfX8osDCOcYfhov J338cg2lSFOx8BDOFHG1e+m/qlfknoDJ+F64pbeobAvsCGLvozDRi33hLj1q1deWoXJuYTYVc3L Qr26o1GGQEk4lovZjan49sme/V0yuPnHSdANFokxolBtUfycQeSXG5BXmwCGxA1vqOArNln/+VH 2N5v7uU3Ifz320imbTGIf+vBWTmoGaYg782lSHBJraP3EjnQ/nDKIBjKcOCHtZObzWnuMXUdzWE CwtqQq8Pmvb5j8RynLG7Leg3T9YK3MGN8UVRuUfbzkmNAGupBQNz3u3u93TG6E17j4eI+lUvPlD P1Mz09GdyTftEpMV5VhHct0yytlMseqdtiVytsrv0I5jYxM9Aysd8t6gHRzTRGUVpr96SdGbsoN h7GqDmRCzQRLslr9p8tXDsaJPIBWFHxXHrRjbLvuXNDfRYFCFwJ83GEOg04aaRFa92hNorBgQQk nn6BMP1rzJyuHwCrA1w== X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE3MDA5NyBTYWx0ZWRfX6HMMkZcqtJpr jErd7xC7mvlWtBWyqI8G4qzhXIwYdAX3FH34ZnOKiTYJpZJHAjYqbw4ZrUG8rXha7XpAUFkyiO9 pMVZ4ovmX1r2CDCAz2meTaB+nQnNXF0= X-Authority-Analysis: v=2.4 cv=KeTidwYD c=1 sm=1 tr=0 ts=6a3274f8 cx=c_pps a=rEQLjTOiSrHUhVqRoksmgQ==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=bMOh1Y247VvR-8fTSPQA:9 a=QEXdDO2ut3YA:10 a=2VI0MkxyNR6bbpdq8BZq:22 X-Proofpoint-GUID: yOaMdpmEopLNjJx9oBUIiGSb55bKmbS6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_01,2026-06-16_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606170097 On 6/15/2026 6:54 AM, Bjorn Andersson wrote: > On Wed, Jun 03, 2026 at 06:14:30PM +0800, Chunkai Deng wrote: >> glink_smem_rx_advance() wraps the tail index with a single subtraction, >> which only corrects for one full wrap. The advance count is derived from >> remote-supplied packet fields (up to sizeof(glink_msg) + 0xffff bytes); >> if such a count reaches or exceeds pipe->native.length, the tail remains >> outside [0, length) after the subtraction and the next FIFO access uses >> an out-of-bounds offset. >> >> Use modulo so the tail is always normalised back into [0, length), >> keeping it consistent with the index bounds enforced by the WARN_ON_ONCE >> checks added to the FIFO helpers. >> >> Signed-off-by: Chunkai Deng >> --- >> drivers/rpmsg/qcom_glink_smem.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/rpmsg/qcom_glink_smem.c b/drivers/rpmsg/qcom_glink_smem.c >> index 42ad315d7910..4f143921b719 100644 >> --- a/drivers/rpmsg/qcom_glink_smem.c >> +++ b/drivers/rpmsg/qcom_glink_smem.c >> @@ -129,7 +129,7 @@ static void glink_smem_rx_advance(struct qcom_glink_pipe *np, >> >> tail += count; >> if (tail >= pipe->native.length) >> - tail -= pipe->native.length; >> + tail %= pipe->native.length; > It seems unlikely that the "tail" will point to the start of a valid > header after this. How can we make sure this is more robust? > > Regards, > Bjorn Agreed -- modulo only normalises the offset arithmetically; the protocol state is already desynchronised at that point and the tail won't land on a valid header boundary. The patch hides the symptom (OOB access) without addressing the underlying issue (a bogus remote-supplied size). I'll drop this patch in v2 and keep just the WARN_ON_ONCE patch as a defensive backstop. If a proper hardening of the receive path is wanted (e.g. validating chunk_size against rx_pipe->length on header peek, mirroring the existing "tlen >= tx_pipe->length" check on the TX side), I'll send it as a separate patch so it can be discussed on its own. Thanks, Chunkai >> >> *pipe->tail = cpu_to_le32(tail); >> } >> >> -- >> 2.34.1 >>