diff options
author | Alexander Potapenko <glider@google.com> | 2017-06-06 13:56:54 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-07-05 12:40:13 (GMT) |
commit | d2f459e3feb0f73d2e95ab7892adcf22f21fe9ef (patch) | |
tree | 38a113af0e76f6fa5da1c837c2158c444df21812 /net | |
parent | 98184bbb8daea6af32208d63831e66023db4bb58 (diff) | |
download | linux-d2f459e3feb0f73d2e95ab7892adcf22f21fe9ef.tar.xz |
net: don't call strlen on non-terminated string in dev_set_alias()
[ Upstream commit c28294b941232931fbd714099798eb7aa7e865d7 ]
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/dev.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 2e04fd1..97f8061 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -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; } |