From: Jakub Kicinski <kuba@kernel.org>
To: Gal Pressman <gal@nvidia.com>
Cc: "David S. Miller" <davem@davemloft.net>, <netdev@vger.kernel.org>,
Vlad Buslov <vladbu@nvidia.com>
Subject: Re: [PATCH net] net: Fix undefined behavior in netdev name allocation
Date: Mon, 13 Nov 2023 23:09:02 -0500 [thread overview]
Message-ID: <20231113230902.7f342501@kernel.org> (raw)
In-Reply-To: <20231113083544.1685919-1-gal@nvidia.com>
On Mon, 13 Nov 2023 10:35:44 +0200 Gal Pressman wrote:
> Cited commit removed the strscpy() call and kept the snprintf() only.
>
> When allocating a netdev, 'res' and 'name' pointers are equal, but
> according to POSIX, if copying takes place between objects that overlap
> as a result of a call to sprintf() or snprintf(), the results are
> undefined.
>
> Add back the strscpy() and use 'buf' as an intermediate buffer.
It may be worth mentioning that it is fairly common to put the format
in dev->name before device is registered, IOW this condition takes
place a lot? IIUC once we cross into 3-digit IDs we may crash?
With that and the right fixes tag:
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Thanks!
--
pw-bot: cr
next prev parent reply other threads:[~2023-11-14 4:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-13 8:35 [PATCH net] net: Fix undefined behavior in netdev name allocation Gal Pressman
2023-11-13 9:53 ` Simon Horman
2023-11-13 14:01 ` Gal Pressman
2023-11-15 9:28 ` Simon Horman
2023-11-14 4:09 ` Jakub Kicinski [this message]
2023-11-14 4:12 ` Jakub Kicinski
2023-11-14 7:26 ` Gal Pressman
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=20231113230902.7f342501@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=gal@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=vladbu@nvidia.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.