Skip to content

Commit 786e000

Browse files
dsaherndavem330
authored andcommitted
rtnetlink: Update inet6_dump_ifinfo for strict data checking
Update inet6_dump_ifinfo for strict data checking. If the flag is set, the dump request is expected to have an ifinfomsg 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 <[email protected]> Acked-by: Christian Brauner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 841891e commit 786e000

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

net/ipv6/addrconf.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5644,6 +5644,31 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
56445644
return -EMSGSIZE;
56455645
}
56465646

5647+
static int inet6_valid_dump_ifinfo(const struct nlmsghdr *nlh,
5648+
struct netlink_ext_ack *extack)
5649+
{
5650+
struct ifinfomsg *ifm;
5651+
5652+
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
5653+
NL_SET_ERR_MSG_MOD(extack, "Invalid header for link dump request");
5654+
return -EINVAL;
5655+
}
5656+
5657+
if (nlmsg_attrlen(nlh, sizeof(*ifm))) {
5658+
NL_SET_ERR_MSG_MOD(extack, "Invalid data after header");
5659+
return -EINVAL;
5660+
}
5661+
5662+
ifm = nlmsg_data(nlh);
5663+
if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags ||
5664+
ifm->ifi_change || ifm->ifi_index) {
5665+
NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for dump request");
5666+
return -EINVAL;
5667+
}
5668+
5669+
return 0;
5670+
}
5671+
56475672
static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
56485673
{
56495674
struct net *net = sock_net(skb->sk);
@@ -5653,6 +5678,16 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
56535678
struct inet6_dev *idev;
56545679
struct hlist_head *head;
56555680

5681+
/* only requests using strict checking can pass data to
5682+
* influence the dump
5683+
*/
5684+
if (cb->strict_check) {
5685+
int err = inet6_valid_dump_ifinfo(cb->nlh, cb->extack);
5686+
5687+
if (err < 0)
5688+
return err;
5689+
}
5690+
56565691
s_h = cb->args[0];
56575692
s_idx = cb->args[1];
56585693

0 commit comments

Comments
 (0)