[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZVSaEaNaeRzAm/Jv@nanopsycho>
Date: Wed, 15 Nov 2023 11:14:41 +0100
From: Jiri Pirko <jiri@...nulli.us>
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>,
netdev@...r.kernel.org, Simon Horman <horms@...nel.org>,
Vlad Buslov <vladbu@...dia.com>
Subject: Re: [PATCH net v2] net: Fix undefined behavior in netdev name
allocation
Tue, Nov 14, 2023 at 08:56:18AM CET, gal@...dia.com 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: Jiri Pirko <jiri@...dia.com>
Powered by blists - more mailing lists