[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231115095659.GM74656@kernel.org>
Date: Wed, 15 Nov 2023 09:56:59 +0000
From: Simon Horman <horms@...nel.org>
To: Gal Pressman <gal@...dia.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
Jiri Pirko <jiri@...nulli.us>, netdev@...r.kernel.org,
Vlad Buslov <vladbu@...dia.com>
Subject: Re: [PATCH net v2] net: Fix undefined behavior in netdev name
allocation
On Tue, Nov 14, 2023 at 09:56:18AM +0200, Gal Pressman wrote:
> Cited commit removed the strscpy() call and kept the snprintf() only.
>
> It is common to use 'dev->name' as the format string before a netdev is
> registered, this results in 'res' and 'name' pointers being equal.
> 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.
>
> Fixes: 7ad17b04dc7b ("net: trust the bitmap in __dev_alloc_name()")
> Cc: Jakub Kicinski <kuba@...nel.org>
> Reviewed-by: Vlad Buslov <vladbu@...dia.com>
> Signed-off-by: Gal Pressman <gal@...dia.com>
> Reviewed-by: Jakub Kicinski <kuba@...nel.org>
Reviewed-by: Simon Horman <horms@...nel.org>
Powered by blists - more mailing lists