From: Alexander Potapenko Date: Tue, 6 Jun 2017 13:56:54 +0000 (+0200) Subject: net: don't call strlen on non-terminated string in dev_set_alias() X-Git-Tag: MMI-PSA29.97-13-9~5432^2~62 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c28294b941232931fbd714099798eb7aa7e865d7;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git 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 Signed-off-by: David S. Miller --- 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) 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; }