wifi: mt76: Replace strlcpy with strscpy
Subsystems (2)
PATCH 1/1 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
--- drivers/net/wireless/mediatek/mt76/mt7615/mt7615_trace.h | 2 +- drivers/net/wireless/mediatek/mt76/mt76x02_trace.h | 2 +- drivers/net/wireless/mediatek/mt76/mt7921/mt7921_trace.h | 2 +- drivers/net/wireless/mediatek/mt76/trace.h | 2 +- drivers/net/wireless/mediatek/mt76/usb_trace.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mt7615_trace.h +1 -1
@@ -14,7 +14,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(mt76_hw(dev)->wiphy), MAXNAME)#define DEV_PR_FMT "%s"#define DEV_PR_ARG __entry->wiphy_name
drivers/net/wireless/mediatek/mt76/mt76x02_trace.h +1 -1
@@ -14,7 +14,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(mt76_hw(dev)->wiphy), MAXNAME)#define DEV_PR_FMT "%s"#define DEV_PR_ARG __entry->wiphy_name
drivers/net/wireless/mediatek/mt76/mt7921/mt7921_trace.h +1 -1
@@ -14,7 +14,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(mt76_hw(dev)->wiphy), MAXNAME)#define DEV_PR_FMT "%s"#define DEV_PR_ARG __entry->wiphy_name
drivers/net/wireless/mediatek/mt76/trace.h +1 -1
@@ -14,7 +14,7 @@#define MAXNAME 32#define DEV_ENTRY __array(char, wiphy_name, 32) -#define DEVICE_ASSIGN strlcpy(__entry->wiphy_name, \ +#define DEVICE_ASSIGN strscpy(__entry->wiphy_name, \ wiphy_name(dev->hw->wiphy), MAXNAME)#define DEV_PR_FMT "%s"#define DEV_PR_ARG __entry->wiphy_name
drivers/net/wireless/mediatek/mt76/usb_trace.h +1 -1
@@ -14,7 +14,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.255.g8b1d071c50-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]>
Looks good -- thing is using return values from the macros.
Signature · 1 line
Kees Cook
Quoted 12 lines · Kees Cook
Quoted 10 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.
Quoted 6 lines
Quoted 4 lines
[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]>Looks good -- thing is using return values from the macros.
Just to confirm, you mean *not* using return values from the macros?
Quoted 13 lines · Azeem Shaikh
Quoted 12 lines · Kees Cook
Quoted 10 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.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
[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]>Looks good -- thing is using return values from the macros.
Just to confirm, you mean *not* using return values from the macros?
I thought I'd replied to this, but I see it didn't happen: yes, I meant "not using return values". Sorry for the confusion!
Signature · 1 line
Kees Cook
Kees Cook
AppliedQuoted 8 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().[...]
Applied, thanks!
[1/1] wifi: mt76: Replace strlcpy with strscpy
https://git.kernel.org/kees/c/535c78cbc0c4
Best regards,
Signature · 1 line
Kees Cook
Quoted 8 lines · Kees Cook
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 6 lines
Quoted 1 line
[...]
Applied, thanks!
[1/1] wifi: mt76: Replace strlcpy with strscpy
https://git.kernel.org/kees/c/535c78cbc0c4
Why did you take this? mt76 is in active development so risk of conflicts is high.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 12 lines · Kalle Valo
Quoted 10 lines · Kees Cook
Quoted 8 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
Quoted 4 lines
Applied, thanks!
[1/1] wifi: mt76: Replace strlcpy with strscpy
https://git.kernel.org/kees/c/535c78cbc0c4Why did you take this? mt76 is in active development so risk of conflicts is high.
There didn't seem to be any further activity for 3 weeks, and it was a relatively mechanical change. I can drop it from my tree. What's needed for it to be picked up through wireless?
-Kees
Signature · 1 line
Kees Cook
Quoted 15 lines · Kees Cook
Quoted 14 lines · Kalle Valo
Quoted 12 lines · Kees Cook
Quoted 8 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().[...]
Applied, thanks!
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
[1/1] wifi: mt76: Replace strlcpy with strscpy
https://git.kernel.org/kees/c/535c78cbc0c4Why did you take this? mt76 is in active development so risk of conflicts is high.
There didn't seem to be any further activity for 3 weeks, and it was a relatively mechanical change.
That's because the wireless trees were on a summer break:
https://lore.kernel.org/all/[email protected]/
Quoted 1 line
I can drop it from my tree.
Yes, please drop this. And in the future don't take any wireless patches unless acked by Johannes or me, I want to minimize the risk of conflicts between the trees. If a patch is missed for whatever reason please let me know, do not take it to your tree.
Quoted 1 line
What's needed for it to be picked up through wireless?
I don't know why Felix didn't take this patch but now I assigned it to me on patchwork:
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/
It should be in wireless-next this week.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: wifi: mt76: 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.
d6b484b5cb2a wifi: mt76: 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