Skip to content

Commit 989b52c

Browse files
azeemshaikh38davem330
authored andcommitted
net: sched: 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 return value of -errno is used to check for truncation instead of sizeof(dest). [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] KSPP#89 Signed-off-by: Azeem Shaikh <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 87355b7 commit 989b52c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/sched/act_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, bool police,
13201320
return ERR_PTR(err);
13211321
}
13221322
} else {
1323-
if (strlcpy(act_name, "police", IFNAMSIZ) >= IFNAMSIZ) {
1323+
if (strscpy(act_name, "police", IFNAMSIZ) < 0) {
13241324
NL_SET_ERR_MSG(extack, "TC action name too long");
13251325
return ERR_PTR(-EINVAL);
13261326
}

0 commit comments

Comments
 (0)