All of lore.kernel.org
 help / color / mirror / Atom feed
From: Deepak Kumar Singh <quic_deesin@quicinc.com>
To: "Michal Koutný" <mkoutny@suse.com>,
	linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>, <afaerber@suse.com>,
	<ivan.ivanov@suse.com>
Subject: Re: [RFC PATCH] rpmsg: glink: Add bounds check on tx path
Date: Mon, 29 Jan 2024 16:18:36 +0530	[thread overview]
Message-ID: <151f5738-791e-42cb-b8fe-e0cfbf9f7dca@quicinc.com> (raw)
In-Reply-To: <20240113002505.15503-1-mkoutny@suse.com>



On 1/13/2024 5:55 AM, Michal Koutný wrote:
> Add bounds check on values read from shared memory in the tx path. In
> cases where the VM is misbehaving, the transport should exit and print a
> warning when bogus values may cause out of bounds to be read.
> 
> Link: https://git.codelinaro.org/clo/la/kernel/msm-5.10/-/commit/32d9c3a2f2b6a4d1fc48d6871194f3faf3184e8b
> Suggested-by: Chris Lew <quic_clew@quicinc.com>
> Suggested-by: Sarannya S <quic_sarannya@quicinc.com>
> Signed-off-by: Michal Koutný <mkoutny@suse.com>
> ---
>   drivers/rpmsg/qcom_glink_smem.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> Why RFC? The patch is adopted from the link above. It would be good to
> asses whether such conditions can also happen with rpmsg glink.
> (And if so, whether the zeroed values are the best correction.)
> 
Hi Michal,

There is already a patch posted for similar problem -
https://lore.kernel.org/all/20231201110631.669085-1-quic_deesin@quicinc.com/

> diff --git a/drivers/rpmsg/qcom_glink_smem.c b/drivers/rpmsg/qcom_glink_smem.c
> index 7a982c60a8dd..3e786e590c03 100644
> --- a/drivers/rpmsg/qcom_glink_smem.c
> +++ b/drivers/rpmsg/qcom_glink_smem.c
> @@ -146,6 +146,11 @@ static size_t glink_smem_tx_avail(struct qcom_glink_pipe *np)
>   	else
>   		avail -= FIFO_FULL_RESERVE + TX_BLOCKED_CMD_RESERVE;
>   
> +	if (avail > pipe->native.length) {
> +		pr_warn_once("%s: avail clamped\n", __func__);
> +		avail = 0;
> +	}
> +
>   	return avail;
>   }
>   
> @@ -177,6 +182,10 @@ static void glink_smem_tx_write(struct qcom_glink_pipe *glink_pipe,
>   	unsigned int head;
>   
>   	head = le32_to_cpu(*pipe->head);
> +	if (head > pipe->native.length) {
> +		pr_warn_once("%s: head overflow\n", __func__);
> +		return;
> +	}
>   
>   	head = glink_smem_tx_write_one(pipe, head, hdr, hlen);
>   	head = glink_smem_tx_write_one(pipe, head, data, dlen);

  reply	other threads:[~2024-01-29 10:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-13  0:25 [RFC PATCH] rpmsg: glink: Add bounds check on tx path Michal Koutný
2024-01-29 10:48 ` Deepak Kumar Singh [this message]
2024-01-29 16:33   ` Michal Koutný
2024-03-20  6:14     ` Deepak Kumar Singh

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=151f5738-791e-42cb-b8fe-e0cfbf9f7dca@quicinc.com \
    --to=quic_deesin@quicinc.com \
    --cc=afaerber@suse.com \
    --cc=andersson@kernel.org \
    --cc=ivan.ivanov@suse.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mkoutny@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.