diff mbox

veth: Enforce minimum size of VETH_INFO_PEER

Message ID 1329314986-20320-1-git-send-email-tgraf@suug.ch
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Thomas Graf Feb. 15, 2012, 2:09 p.m. UTC
VETH_INFO_PEER carries struct ifinfomsg plus optional IFLA
attributes. A minimal size of sizeof(struct ifinfomsg) must be
enforced or we may risk accessing that struct beyond the limits
of the netlink message.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
---
 drivers/net/veth.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Comments

David Miller Feb. 15, 2012, 7:59 p.m. UTC | #1
From: Thomas Graf <tgraf@suug.ch>
Date: Wed, 15 Feb 2012 15:09:46 +0100

> VETH_INFO_PEER carries struct ifinfomsg plus optional IFLA
> attributes. A minimal size of sizeof(struct ifinfomsg) must be
> enforced or we may risk accessing that struct beyond the limits
> of the netlink message.
> 
> Signed-off-by: Thomas Graf <tgraf@suug.ch>

Applied and queued up for -stable, thanks Thomas.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 49f4667..4a34028 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -422,7 +422,9 @@  static void veth_dellink(struct net_device *dev, struct list_head *head)
 	unregister_netdevice_queue(peer, head);
 }
 
-static const struct nla_policy veth_policy[VETH_INFO_MAX + 1];
+static const struct nla_policy veth_policy[VETH_INFO_MAX + 1] = {
+	[VETH_INFO_PEER]	= { .len = sizeof(struct ifinfomsg) },
+};
 
 static struct rtnl_link_ops veth_link_ops = {
 	.kind		= DRV_NAME,