From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH net-next 19/20] net: Update netconf dump handlers for strict data checking Date: Sun, 7 Oct 2018 19:38:14 -0600 Message-ID: <6ab6f14a-1cf9-cbe9-0019-6c4818327930@gmail.com> References: <20181004213355.14899-1-dsahern@kernel.org> <20181004213355.14899-20-dsahern@kernel.org> <20181007105323.hibmy6duhzu6h37w@brauner.io> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, davem@davemloft.net, jbenc@redhat.com, stephen@networkplumber.org To: Christian Brauner , David Ahern Return-path: Received: from mail-pl1-f193.google.com ([209.85.214.193]:36013 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725760AbeJHIra (ORCPT ); Mon, 8 Oct 2018 04:47:30 -0400 Received: by mail-pl1-f193.google.com with SMTP id y11-v6so6138210plt.3 for ; Sun, 07 Oct 2018 18:38:16 -0700 (PDT) In-Reply-To: <20181007105323.hibmy6duhzu6h37w@brauner.io> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 10/7/18 4:53 AM, Christian Brauner wrote: >> @@ -2076,6 +2077,21 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb, >> struct in_device *in_dev; >> struct hlist_head *head; >> >> + if (cb->strict_check) { >> + struct netlink_ext_ack *extack = cb->extack; >> + struct netconfmsg *ncm; >> + >> + if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ncm))) { >> + NL_SET_ERR_MSG(extack, "Invalid header"); >> + return -EINVAL; >> + } >> + >> + if (nlh->nlmsg_len != nlmsg_msg_size(sizeof(*ncm))) { >> + NL_SET_ERR_MSG(extack, "Invalid data after header"); >> + return -EINVAL; >> + } > > Hm, I think this could just be one branch with != > But if you've done this to report back a more meaningful error message > to userspace, fine. :) Consistency with other dump handlers and better userspace error messages. If netconf ever gets a filter the length check is removed in favor of nlmsg_parse_strict