summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2017-06-06 15:56:54 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-07-05 14:35:12 +0200
commit0d487bc50728828ce0f6d817f2c4f8203568c1c8 (patch)
tree88839198e5fd954cb1fac94ca54d129f53e52bf4 /net/core
parentdc818ce51c50ecc3f2157172c5aa1f9e43d9b691 (diff)
downloadlinux-stable-0d487bc50728828ce0f6d817f2c4f8203568c1c8.tar.gz
linux-stable-0d487bc50728828ce0f6d817f2c4f8203568c1c8.tar.bz2
linux-stable-0d487bc50728828ce0f6d817f2c4f8203568c1c8.zip
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/core')
-rw-r--r--net/core/dev.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 86bdf6d813f6..f8df88b202c6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1194,8 +1194,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;
}