Skip to content

Commit cd91250

Browse files
azeemshaikh38Stefan-Schmidt
authored andcommitted
ieee802154: 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 the return values from the helper macros are ignored by the callers. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] KSPP#89 Signed-off-by: Azeem Shaikh <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stefan Schmidt <[email protected]>
1 parent bd4e3d8 commit cd91250

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

net/ieee802154/trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#define MAXNAME 32
1515
#define WPAN_PHY_ENTRY __array(char, wpan_phy_name, MAXNAME)
16-
#define WPAN_PHY_ASSIGN strlcpy(__entry->wpan_phy_name, \
16+
#define WPAN_PHY_ASSIGN strscpy(__entry->wpan_phy_name, \
1717
wpan_phy_name(wpan_phy), \
1818
MAXNAME)
1919
#define WPAN_PHY_PR_FMT "%s"

net/mac802154/trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#define MAXNAME 32
1616
#define LOCAL_ENTRY __array(char, wpan_phy_name, MAXNAME)
17-
#define LOCAL_ASSIGN strlcpy(__entry->wpan_phy_name, \
17+
#define LOCAL_ASSIGN strscpy(__entry->wpan_phy_name, \
1818
wpan_phy_name(local->hw.phy), MAXNAME)
1919
#define LOCAL_PR_FMT "%s"
2020
#define LOCAL_PR_ARG __entry->wpan_phy_name

0 commit comments

Comments
 (0)