Skip to content

Commit

Permalink
bridge: Validate IFLA_BRIDGE_FLAGS attribute length
Browse files Browse the repository at this point in the history
Payload is currently accessed blindly and may exceed valid message
boundaries.

Fixes: 407af32 ("bridge: Add netlink interface to configure vlans on bridge ports")
Cc: Vlad Yasevich <vyasevic@redhat.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Thomas Graf authored and David S. Miller committed Nov 26, 2014
1 parent 571dcfd commit 6e8d1c5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -2798,6 +2798,9 @@ static int rtnl_bridge_setlink(struct sk_buff *skb, struct nlmsghdr *nlh)
if (br_spec) {
nla_for_each_nested(attr, br_spec, rem) {
if (nla_type(attr) == IFLA_BRIDGE_FLAGS) {
if (nla_len(attr) < sizeof(flags))
return -EINVAL;

have_flags = true;
flags = nla_get_u16(attr);
break;
Expand Down Expand Up @@ -2868,6 +2871,9 @@ static int rtnl_bridge_dellink(struct sk_buff *skb, struct nlmsghdr *nlh)
if (br_spec) {
nla_for_each_nested(attr, br_spec, rem) {
if (nla_type(attr) == IFLA_BRIDGE_FLAGS) {
if (nla_len(attr) < sizeof(flags))
return -EINVAL;

have_flags = true;
flags = nla_get_u16(attr);
break;
Expand Down

0 comments on commit 6e8d1c5

Please sign in to comment.