wifi: mt76: Replace strlcpy() with strscpy()
authorAzeem Shaikh <azeemshaikh38@gmail.com>
Mon, 3 Jul 2023 18:12:56 +0000 (18:12 +0000)
committerKalle Valo <kvalo@kernel.org>
Wed, 2 Aug 2023 10:09:41 +0000 (13:09 +0300)
commitd6b484b5cb2a7d509b36a220911509ddd8b777c4
treeedd1eb24d6af2f791dffd67c38793acaa765ee4f
parent111d5c4797c0f0314de8ef68b50259798ef3a127
wifi: mt76: Replace strlcpy() with strscpy()

strlcpy() reads the entire source buffer first.
This read may exceed the destination size limit.
This is both inefficient and can lead to linear read
overflows if a source string is not NUL-terminated [1].
In an effort to remove strlcpy() completely [2], replace
strlcpy() here with strscpy().

Direct replacement is safe here since DEV_ASSIGN is only used by
TRACE macros and the return values are ignored.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89

Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230703181256.3712079-1-azeemshaikh38@gmail.com
drivers/net/wireless/mediatek/mt76/mt7615/mt7615_trace.h
drivers/net/wireless/mediatek/mt76/mt76x02_trace.h
drivers/net/wireless/mediatek/mt76/trace.h
drivers/net/wireless/mediatek/mt76/usb_trace.h