mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
To: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
	Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>,
	andersson@kernel.org
Cc: srini@kernel.org, konradybcio@kernel.org,
	linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] soc: qcom: apr: Check response packet length by router type
Date: Thu, 21 May 2026 17:19:10 +0000	[thread overview]
Message-ID: <1b56fe76-981f-4193-bd39-ceadb7b551e2@oss.qualcomm.com> (raw)
In-Reply-To: <3381259a-1deb-460c-bbde-a97263914e15@oss.qualcomm.com>



On 5/21/26 9:45 AM, Konrad Dybcio wrote:
> On 5/14/26 5:50 PM, Srinivas Kandagatla wrote:
>> apr_callback() currently validates all received packets against
>> APR_HDR_SIZE before queueing them for the RX worker. This is not correct
>> for GPR packets, which use a different header size.
>>
>> Validate the received packet length against the header size matching the
>> packet router type before copying the packet.
>>
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
>> ---
>>  drivers/soc/qcom/apr.c | 17 ++++++++++++++---
>>  1 file changed, 14 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/soc/qcom/apr.c b/drivers/soc/qcom/apr.c
>> index 127204c195ea..68b357462438 100644
>> --- a/drivers/soc/qcom/apr.c
>> +++ b/drivers/soc/qcom/apr.c
>> @@ -165,9 +165,20 @@ static int apr_callback(struct rpmsg_device *rpdev, void *buf,
>>  	struct apr_rx_buf *abuf;
>>  	unsigned long flags;
>>  
>> -	if (len <= APR_HDR_SIZE) {
>> -		dev_err(apr->dev, "APR: Improper apr pkt received:%p %d\n",
>> -			buf, len);
>> +	switch (apr->type) {
>> +	case PR_TYPE_APR:
>> +		if (len <= APR_HDR_SIZE) {
>> +			dev_err(apr->dev, "APR: Improper apr pkt received:%p %d\n", buf, len);
>> +			return -EINVAL;
>> +		}
>> +		break;
>> +	case PR_TYPE_GPR:
>> +		if (len <= GPR_HDR_SIZE) {
>> +			dev_err(apr->dev, "APR: Improper gpr pkt received:%p %d\n", buf, len);
> 
> It first says "APR:" and then "[ag]pr" later, please at least make the
> case consistent

Ah, seems like an overlook, thanks for spotting it, will fix this in
next spin.


> 
>> +			return -EINVAL;
>> +		}
>> +		break;
> 
> Switch seems a little far-fetched, unless there'll be more packet types
never know...  we have similar checks in the driver, atleast its
consistent with that.



--srini
> 
> Konrad


  reply	other threads:[~2026-05-21 17:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 15:50 [PATCH 0/3] soc: qcom: apr: improve RX processing Srinivas Kandagatla
2026-05-14 15:50 ` [PATCH 1/3] soc: qcom: apr: Remove service from IDR before registration failure Srinivas Kandagatla
2026-05-14 15:50 ` [PATCH 2/3] soc: qcom: apr: Check response packet length by router type Srinivas Kandagatla
2026-05-21  9:45   ` Konrad Dybcio
2026-05-21 17:19     ` Srinivas Kandagatla [this message]
2026-05-14 15:50 ` [PATCH 3/3] soc: qcom: apr: Process RX messages using per-service work items Srinivas Kandagatla
2026-05-21 22:28   ` Bjorn Andersson
2026-05-28 13:50     ` Srinivas Kandagatla
2026-05-26 22:26 ` [PATCH 0/3] soc: qcom: apr: improve RX processing Val Packett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1b56fe76-981f-4193-bd39-ceadb7b551e2@oss.qualcomm.com \
    --to=srinivas.kandagatla@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=srini@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®