Skip to content

Commit 2c16db6

Browse files
zenczykowskidavem330
authored andcommitted
net: fix nla_strcmp to handle more then one trailing null character
Android userspace has been using TCA_KIND with a char[IFNAMESIZ] many-null-terminated buffer containing the string 'bpf'. This works on 4.19 and ceases to work on 5.10. I'm not entirely sure what fixes tag to use, but I think the issue was likely introduced in the below mentioned 5.4 commit. Reported-by: Nucca Chen <[email protected]> Cc: Cong Wang <[email protected]> Cc: David Ahern <[email protected]> Cc: David S. Miller <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Jamal Hadi Salim <[email protected]> Cc: Jiri Pirko <[email protected]> Cc: Jiri Pirko <[email protected]> Fixes: 62794fc ("net_sched: add max len check for TCA_KIND") Change-Id: I66dc281f165a2858fc29a44869a270a2d698a82b Signed-off-by: David S. Miller <[email protected]>
1 parent 52bfcdd commit 2c16db6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/nlattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ int nla_strcmp(const struct nlattr *nla, const char *str)
828828
int attrlen = nla_len(nla);
829829
int d;
830830

831-
if (attrlen > 0 && buf[attrlen - 1] == '\0')
831+
while (attrlen > 0 && buf[attrlen - 1] == '\0')
832832
attrlen--;
833833

834834
d = attrlen - len;

0 commit comments

Comments
 (0)