Skip to content

Commit 14fc5bb

Browse files
dsaherndavem330
authored andcommitted
rtnetlink: Update ipmr_rtm_dumplink for strict data checking
Update ipmr_rtm_dumplink 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 786e000 commit 14fc5bb

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

net/ipv4/ipmr.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,31 @@ static bool ipmr_fill_vif(struct mr_table *mrt, u32 vifid, struct sk_buff *skb)
27102710
return true;
27112711
}
27122712

2713+
static int ipmr_valid_dumplink(const struct nlmsghdr *nlh,
2714+
struct netlink_ext_ack *extack)
2715+
{
2716+
struct ifinfomsg *ifm;
2717+
2718+
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
2719+
NL_SET_ERR_MSG(extack, "ipv4: Invalid header for ipmr link dump");
2720+
return -EINVAL;
2721+
}
2722+
2723+
if (nlmsg_attrlen(nlh, sizeof(*ifm))) {
2724+
NL_SET_ERR_MSG(extack, "Invalid data after header in ipmr link dump");
2725+
return -EINVAL;
2726+
}
2727+
2728+
ifm = nlmsg_data(nlh);
2729+
if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags ||
2730+
ifm->ifi_change || ifm->ifi_index) {
2731+
NL_SET_ERR_MSG(extack, "Invalid values in header for ipmr link dump request");
2732+
return -EINVAL;
2733+
}
2734+
2735+
return 0;
2736+
}
2737+
27132738
static int ipmr_rtm_dumplink(struct sk_buff *skb, struct netlink_callback *cb)
27142739
{
27152740
struct net *net = sock_net(skb->sk);
@@ -2718,6 +2743,13 @@ static int ipmr_rtm_dumplink(struct sk_buff *skb, struct netlink_callback *cb)
27182743
unsigned int e = 0, s_e;
27192744
struct mr_table *mrt;
27202745

2746+
if (cb->strict_check) {
2747+
int err = ipmr_valid_dumplink(cb->nlh, cb->extack);
2748+
2749+
if (err < 0)
2750+
return err;
2751+
}
2752+
27212753
s_t = cb->args[0];
27222754
s_e = cb->args[1];
27232755

0 commit comments

Comments
 (0)