From: David Laight <david.laight.linux@gmail.com>
To: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Cc: Kees Cook <kees@kernel.org>,
linux-hardening@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org,
Arnd Bergmann <arnd@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>
Subject: Re: [PATCH next] drivers/rpmsg: Fix copy of channel->name into open request
Date: Thu, 18 Jun 2026 15:59:39 +0100 [thread overview]
Message-ID: <20260618155939.6cdbdbac@pumpkin> (raw)
In-Reply-To: <79c1dda2-153e-4b7a-ad18-c72db1cf4a00@oss.qualcomm.com>
On Thu, 18 Jun 2026 15:24:17 +0200
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> wrote:
> On 6/8/26 11:55 AM, david.laight.linux@gmail.com wrote:
> > From: David Laight <david.laight.linux@gmail.com>
> >
> > Nothing obvious ensures that the name is less than GLINK_CMD_OPEN (32)
> ^ GLINK_NAME_SIZE
I was writing a lot of commit messages, most with -m 'text'.
> [...]
>
> > @@ -481,8 +481,7 @@ static int qcom_glink_send_open_req(struct qcom_glink *glink,
> > struct glink_channel *channel)
> > {
> > DEFINE_RAW_FLEX(struct glink_msg, req, data, GLINK_NAME_SIZE);
> > - int name_len = strlen(channel->name) + 1;
> > - int req_len = ALIGN(sizeof(*req) + name_len, 8);
> > + int name_len, req_len;
> > int ret;
> > unsigned long flags;
> >
> > @@ -498,14 +497,20 @@ static int qcom_glink_send_open_req(struct qcom_glink *glink,
> >
> > channel->lcid = ret;
> >
> > + name_len = strscpy_pad(req->data, channel->name, GLINK_NAME_SIZE);
> > + if (name_len < 0)
> > + name_len = GLINK_NAME_SIZE;
> > + else
> > + name_len++;
>
> Should we perhaps do something along the lines of:
>
> WARN_ON(strlen(name) > GLINK_NAME_SIZE)
>
> to prevent silent clipping?
strscpy() tells you whether the copy got truncated.
No point calling strlen() again.
But I'm not really sure it is worth it.
Any length check of user-supplied names should be much earlier,
this is just ensuring this code doesn't overwrite its own stack.
(and ensuring stale stack doesn't get sent as padding).
David
>
> Konrad
prev parent reply other threads:[~2026-06-18 14:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 9:55 [PATCH next] drivers/rpmsg: Fix copy of channel->name into open request david.laight.linux
2026-06-18 13:24 ` Konrad Dybcio
2026-06-18 14:59 ` David Laight [this message]
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=20260618155939.6cdbdbac@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=andersson@kernel.org \
--cc=arnd@kernel.org \
--cc=kees@kernel.org \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.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