mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
net: don't call strlen on non-terminated string in dev_set_alias()
[ Upstream commit c28294b941 ]
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 <glider@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
98184bbb8d
commit
d2f459e3fe
@@ -1250,8 +1250,9 @@ int dev_set_alias(struct net_device *dev, const char *alias, size_t len)
|
||||
if (!new_ifalias)
|
||||
return -ENOMEM;
|
||||
dev->ifalias = new_ifalias;
|
||||
memcpy(dev->ifalias, alias, len);
|
||||
dev->ifalias[len] = 0;
|
||||
|
||||
strlcpy(dev->ifalias, alias, len+1);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user