From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Brauner Subject: Re: [PATCH v2 net-next 13/23] rtnetlink: Update ipmr_rtm_dumplink for strict data checking Date: Mon, 8 Oct 2018 12:43:12 +0200 Message-ID: <20181008104311.557ffak7zmvcutio@brauner.io> References: <20181008031644.15989-1-dsahern@kernel.org> <20181008031644.15989-14-dsahern@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: netdev@vger.kernel.org, davem@davemloft.net, jbenc@redhat.com, stephen@networkplumber.org, David Ahern To: David Ahern Return-path: Received: from mail-wr1-f68.google.com ([209.85.221.68]:34675 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726330AbeJHRya (ORCPT ); Mon, 8 Oct 2018 13:54:30 -0400 Received: by mail-wr1-f68.google.com with SMTP id z4-v6so20259346wrb.1 for ; Mon, 08 Oct 2018 03:43:24 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20181008031644.15989-14-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org List-ID: On Sun, Oct 07, 2018 at 08:16:34PM -0700, David Ahern wrote: > From: David Ahern > > 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 Acked-by: Christian Brauner > --- > net/ipv4/ipmr.c | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c > index 5660adcf7a04..e7322e407bb4 100644 > --- a/net/ipv4/ipmr.c > +++ b/net/ipv4/ipmr.c > @@ -2710,6 +2710,31 @@ static bool ipmr_fill_vif(struct mr_table *mrt, u32 vifid, struct sk_buff *skb) > return true; > } > > +static int ipmr_valid_dumplink(const struct nlmsghdr *nlh, > + struct netlink_ext_ack *extack) > +{ > + struct ifinfomsg *ifm; > + > + if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) { > + NL_SET_ERR_MSG(extack, "ipv4: Invalid header for ipmr link dump"); > + return -EINVAL; > + } > + > + if (nlmsg_attrlen(nlh, sizeof(*ifm))) { > + NL_SET_ERR_MSG(extack, "Invalid data after header in ipmr link dump"); > + return -EINVAL; > + } > + > + ifm = nlmsg_data(nlh); > + if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags || > + ifm->ifi_change || ifm->ifi_index) { > + NL_SET_ERR_MSG(extack, "Invalid values in header for ipmr link dump request"); > + return -EINVAL; > + } > + > + return 0; > +} > + > static int ipmr_rtm_dumplink(struct sk_buff *skb, struct netlink_callback *cb) > { > struct net *net = sock_net(skb->sk); > @@ -2718,6 +2743,13 @@ static int ipmr_rtm_dumplink(struct sk_buff *skb, struct netlink_callback *cb) > unsigned int e = 0, s_e; > struct mr_table *mrt; > > + if (cb->strict_check) { > + int err = ipmr_valid_dumplink(cb->nlh, cb->extack); > + > + if (err < 0) > + return err; > + } > + > s_t = cb->args[0]; > s_e = cb->args[1]; > > -- > 2.11.0 >