Skip to contentSkip to conversation

Patch "net: don't call strlen on non-terminated string in dev_set_alias()" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Jun 29, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

net: don't call strlen on non-terminated string in dev_set_alias()

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
net-don-t-call-strlen-on-non-terminated-string-in-dev_set_alias.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Thu Jun 29 18:57:46 CEST 2017

From: Alexander Potapenko <[email protected]>
Date: Tue, 6 Jun 2017 15:56:54 +0200
Subject: net: don't call strlen on non-terminated string in dev_set_alias()

From: Alexander Potapenko <[email protected]>

[ 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.

---
 net/core/dev.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/dev.c +2 -1
@@ -1250,8 +1250,9 @@ int dev_set_alias(struct net_device *dev
 	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;
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/net-don-t-call-strlen-on-non-terminated-string-in-dev_set_alias.patch