diff options
author | Alexander Potapenko <glider@google.com> | 2017-06-06 09:56:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-07 12:58:45 -0400 |
commit | c28294b941232931fbd714099798eb7aa7e865d7 (patch) | |
tree | 34ebac6259d426d260ad707793f17cc3ae8df66b | |
parent | b29794ec95c6856b316c2295904208bf11ffddd9 (diff) |
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 <glider@google.com>
Signed-off-by: David S. Miller <davem@davemloft.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 fca407b4a6ea..84e1e86a4bce 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -1253,8 +1253,9 @@ int dev_set_alias(struct net_device *dev, const char *alias, size_t len) | |||
1253 | if (!new_ifalias) | 1253 | if (!new_ifalias) |
1254 | return -ENOMEM; | 1254 | return -ENOMEM; |
1255 | dev->ifalias = new_ifalias; | 1255 | dev->ifalias = new_ifalias; |
1256 | memcpy(dev->ifalias, alias, len); | ||
1257 | dev->ifalias[len] = 0; | ||
1256 | 1258 | ||
1257 | strlcpy(dev->ifalias, alias, len+1); | ||
1258 | return len; | 1259 | return len; |
1259 | } | 1260 | } |
1260 | 1261 | ||