[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231113230902.7f342501@kernel.org>
Date: Mon, 13 Nov 2023 23:09:02 -0500
From: Jakub Kicinski <kuba@...nel.org>
To: Gal Pressman <gal@...dia.com>
Cc: "David S. Miller" <davem@...emloft.net>, <netdev@...r.kernel.org>, Vlad
Buslov <vladbu@...dia.com>
Subject: Re: [PATCH net] net: Fix undefined behavior in netdev name
allocation
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@...nel.org>
Thanks!
--
pw-bot: cr
Powered by blists - more mailing lists