netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netlink: don't copy over empty attribute data
@ 2014-10-21 20:51 Sasha Levin
  2014-10-22  1:39 ` David Miller
  2014-10-22  8:55 ` David Laight
  0 siblings, 2 replies; 9+ messages in thread
From: Sasha Levin @ 2014-10-21 20:51 UTC (permalink / raw)
  To: davem
  Cc: a.ryabinin, pablo, mschmidt, akpm, linux-kernel, netdev, Sasha Levin

netlink uses empty data to seperate different levels. However, we still
try to copy that data from a NULL ptr using memcpy, which is an undefined
behaviour.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 lib/nlattr.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/nlattr.c b/lib/nlattr.c
index 9c3e85f..6512b43 100644
--- a/lib/nlattr.c
+++ b/lib/nlattr.c
@@ -430,7 +430,8 @@ void __nla_put(struct sk_buff *skb, int attrtype, int attrlen,
 	struct nlattr *nla;
 
 	nla = __nla_reserve(skb, attrtype, attrlen);
-	memcpy(nla_data(nla), data, attrlen);
+	if (data)
+		memcpy(nla_data(nla), data, attrlen);
 }
 EXPORT_SYMBOL(__nla_put);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-10-27 16:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-21 20:51 [PATCH] netlink: don't copy over empty attribute data Sasha Levin
2014-10-22  1:39 ` David Miller
2014-10-22  2:19   ` Sasha Levin
2014-10-22  6:15     ` David Miller
2014-10-26 23:32       ` Sasha Levin
2014-10-27  2:03         ` David Miller
2014-10-27 14:42           ` Sasha Levin
2014-10-27 16:46             ` Andrey Ryabinin
2014-10-22  8:55 ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).