Skip to content

Commit

Permalink
net/bridge: Update br_mdb_dump for strict data checking
Browse files Browse the repository at this point in the history
Update br_mdb_dump for strict data checking. If the flag is set,
the dump request is expected to have a br_port_msg struct as the
header. All elements of the struct are expected to be 0 and no
attributes can be appended.

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Christian Brauner <christian@brauner.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David Ahern authored and David S. Miller committed Oct 8, 2018
1 parent addd383 commit c77b936
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions net/bridge/br_mdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,43 @@ static int br_mdb_fill_info(struct sk_buff *skb, struct netlink_callback *cb,
return err;
}

static int br_mdb_valid_dump_req(const struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{
struct br_port_msg *bpm;

if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*bpm))) {
NL_SET_ERR_MSG_MOD(extack, "Invalid header for mdb dump request");
return -EINVAL;
}

bpm = nlmsg_data(nlh);
if (bpm->ifindex) {
NL_SET_ERR_MSG_MOD(extack, "Filtering by device index is not supported for mdb dump request");
return -EINVAL;
}
if (nlmsg_attrlen(nlh, sizeof(*bpm))) {
NL_SET_ERR_MSG(extack, "Invalid data after header in mdb dump request");
return -EINVAL;
}

return 0;
}

static int br_mdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
{
struct net_device *dev;
struct net *net = sock_net(skb->sk);
struct nlmsghdr *nlh = NULL;
int idx = 0, s_idx;

if (cb->strict_check) {
int err = br_mdb_valid_dump_req(cb->nlh, cb->extack);

if (err < 0)
return err;
}

s_idx = cb->args[0];

rcu_read_lock();
Expand Down

0 comments on commit c77b936

Please sign in to comment.