net/mediatek: strlcpy withreturn
Subsystems (2)
PATCH 1/1 net/mediatek: strlcpy withreturn
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
--- drivers/net/wireless/mediatek/mt7601u/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt7601u/trace.h +1 -1
@@ -16,7 +16,7 @@#define MAXNAME 32#define DEV_ENTRY __array(char, wiphy_name, 32) -#define DEV_ASSIGN strlcpy(__entry->wiphy_name, \ +#define DEV_ASSIGN strscpy(__entry->wiphy_name, \ wiphy_name(dev->hw->wiphy), MAXNAME)#define DEV_PR_FMT "%s "#define DEV_PR_ARG __entry->wiphy_name
Signature · 1 line
2.41.0.162.gfafddb0af9-goog
Quoted 7 lines · Azeem Shaikh
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 removestrlcpy()completely [2], replacestrlcpy()here withstrscpy().
Quoted 7 lines
Direct replacement is safe here since
DEV_ASSIGNis 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/89Signed-off-by Azeem Shaikh <[email protected]>
The title should be:
wifi: mt7601u: replace strlcpy() with strscpy()
I can fix that, no need to resend because of this.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 16 lines · Kalle Valo
Quoted 13 lines · Azeem Shaikh
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 removestrlcpy()completely [2], replacestrlcpy()here withstrscpy().Direct replacement is safe here since
DEV_ASSIGNis 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
Quoted 8 lines
Quoted 1 line
Signed-off-by Azeem Shaikh <[email protected]>The title should be:
wifi: mt7601u: replace
strlcpy()withstrscpy()I can fix that, no need to resend because of this.
Thanks Kalle!
Quoted 5 lines
--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 7 lines · Azeem Shaikh
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 removestrlcpy()completely [2], replacestrlcpy()here withstrscpy().
Quoted 7 lines
Direct replacement is safe here since
DEV_ASSIGNis 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/89Signed-off-by Azeem Shaikh <[email protected]>
Yup double-checked the users of the macros. Looks good to me.
Signature · 1 line
Kees Cook
Re: wifi: mt7601u: replace strlcpy() with strscpy()
In reply to Azeem ShaikhQuoted 7 lines · Azeem Shaikh
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 removestrlcpy()completely [2], replacestrlcpy()here withstrscpy().
Quoted 8 lines
Direct replacement is safe here since
DEV_ASSIGNis 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/89Signed-off-by Azeem Shaikh <[email protected]>Reviewed-by Kees Cook <[email protected]>
Patch applied to wireless-next.git, thanks.
7edbd53a58a8 wifi: mt7601u: replace strlcpy() with strscpy()
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches