Skip to contentSkip to conversation

Patch "rtnl: stats - add missing netlink message size checks" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Jan 12, 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

rtnl: stats - add missing netlink message size checks

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:
rtnl-stats-add-missing-netlink-message-size-checks.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 Jan 12 21:37:26 CET 2017

From: Mathias Krause <[email protected]>
Date: Wed, 28 Dec 2016 17:52:15 +0100
Subject: rtnl: stats - add missing netlink message size checks

From: Mathias Krause <[email protected]>

[ Upstream commit 4775cc1f2d5abca894ac32774eefc22c45347d1c ]

We miss to check if the netlink message is actually big enough to contain a struct if_stats_msg.

Add a check to prevent userland from sending us short messages that would make us access memory beyond the end of the message.

Fixes 10c9ead9f3c6 ("rtnetlink: add new RTM_GETSTATS message to dump...")
Cc Roopa Prabhu <[email protected]>
---
 net/core/rtnetlink.c |    6 ++++++
 1 file changed, 6 insertions(+)
net/core/rtnetlink.c +6 -0
@@ -3886,6 +3886,9 @@ static int rtnl_stats_get(struct sk_buff
 	u32 filter_mask;
 	int err;
 
+	if (nlmsg_len(nlh) < sizeof(*ifsm))
+		return -EINVAL;
+
 	ifsm = nlmsg_data(nlh);
 	if (ifsm->ifindex > 0)
 		dev = __dev_get_by_index(net, ifsm->ifindex);
@@ -3935,6 +3938,9 @@ static int rtnl_stats_dump(struct sk_buf
 
 	cb->seq = net->dev_base_seq;
 
+	if (nlmsg_len(cb->nlh) < sizeof(*ifsm))
+		return -EINVAL;
+
 	ifsm = nlmsg_data(cb->nlh);
 	filter_mask = ifsm->filter_mask;
 	if (!filter_mask)

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

queue-4.9/rtnl-stats-add-missing-netlink-message-size-checks.patch