Skip to content

Commit c28294b

Browse files
ramosian-gliderdavem330
authored andcommitted
net: don't call strlen on non-terminated string in dev_set_alias()
KMSAN reported a use of uninitialized memory in dev_set_alias(), which was caused by calling strlcpy() (which in turn called strlen()) on the user-supplied non-terminated string. Signed-off-by: Alexander Potapenko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b29794e commit c28294b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/core/dev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,8 +1253,9 @@ int dev_set_alias(struct net_device *dev, const char *alias, size_t len)
12531253
if (!new_ifalias)
12541254
return -ENOMEM;
12551255
dev->ifalias = new_ifalias;
1256+
memcpy(dev->ifalias, alias, len);
1257+
dev->ifalias[len] = 0;
12561258

1257-
strlcpy(dev->ifalias, alias, len+1);
12581259
return len;
12591260
}
12601261

0 commit comments

Comments
 (0)