From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: David Laight <david.laight.linux@gmail.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: Mon, 22 Jun 2026 15:37:09 +0200 [thread overview]
Message-ID: <d786b2bb-42da-458e-a952-5d80b97d8a58@oss.qualcomm.com> (raw)
In-Reply-To: <20260618155939.6cdbdbac@pumpkin>
On 6/18/26 4:59 PM, David Laight wrote:
> 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.
Right.
> 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).
Fair. I'll check that out separately.
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Konrad
prev parent reply other threads:[~2026-06-22 13:37 UTC|newest]
Thread overview: 4+ 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
2026-06-22 13:37 ` Konrad Dybcio [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=d786b2bb-42da-458e-a952-5d80b97d8a58@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=arnd@kernel.org \
--cc=david.laight.linux@gmail.com \
--cc=kees@kernel.org \
--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