Gal Pressman 674e318089 net: Fix undefined behavior in netdev name allocation
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@kernel.org>
Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2023-11-15 11:05:08 +00:00
..
2023-10-23 08:45:25 +01:00
2023-10-01 19:09:54 +01:00
2023-05-31 13:06:57 +02:00
2023-08-29 17:39:15 -07:00
2023-10-26 20:27:58 -07:00
2023-06-24 15:41:46 -07:00
2023-11-08 18:15:00 -08:00
2023-10-01 19:09:54 +01:00
2023-11-08 13:39:16 -08:00
2023-10-26 20:27:58 -07:00
2023-10-01 19:09:54 +01:00
2023-10-11 10:39:01 +01:00