Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp25304ybp; Thu, 10 Oct 2019 13:22:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjfn5w+VMbZB423zcnWge/vOvJkRzRMfayvkWFFDKIuWDHAnWjJ0DxJqw//ysxtWu8hRg1 X-Received: by 2002:a17:906:474d:: with SMTP id j13mr10102091ejs.166.1570738944529; Thu, 10 Oct 2019 13:22:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570738944; cv=none; d=google.com; s=arc-20160816; b=ekPUNWEF0UDkHHJboKwgbgJN14FYk3nMuTwDKl8KbT3wDtY/BFzXYPD5dil6iyP6J+ rMTwyGwRm5zSnuOoRiUQZT5oaC7GNwCz1N6ybniTQDUVeTRkxh3frSKop1FDoxdk4JRw imzFGbLibZqK68aobciJyHros8NqP74S9DmWObzGFcHo0WojFNfCnoIRhJO97lo+/a+P gBB7SEUmVt911CTjhYXzE6Rm+5j+C4C8R+v5ikWrGAixNX3m/wqKYBeMDCSu9Kp4OTII PGZKemyzzdCNlGVpF+OG053rp6v7B6No+iqK7yvt9q6scbyZkWQOzeZ2SOZCn+vsJ3Bx lyXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=eknUeXDlab9RyeoutZJDDowE6eJyVKw1VFCxPPII9hQ=; b=FdjFq0JTRcB/1klmLAc2Qufy1t6ba7xX0OinBGFx/AcH98BjGLEjF+VYvuYhZX0nOp MPzWbGIsIOStYtQYDdEDscL7sE4KVTBmhuAGC78Jfwn8CT9mfHxpWWPpNzh2NlukcJd/ 6m3p/1NE6pjYNenp0pxbD25uNX8M6Q/2d7sq+f3evQL0dCiNntbsSPuhYpuNfmGeaW1j UrQdqLJ4NN8bZKn73q8V19sOMqQvhjQXL6+XKlv3webArqzGHkSC74zkUxbDAs00LWj8 SvjmTo2jTvtcywtyzm2NFNC2yB7Bv74TqGPWfsci8mDMFBxD5VNmwH6282JHl5qPAvqI cwYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c9si3672614eds.211.2019.10.10.13.21.58; Thu, 10 Oct 2019 13:22:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726672AbfJJUVb (ORCPT + 99 others); Thu, 10 Oct 2019 16:21:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:59574 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726533AbfJJUVb (ORCPT ); Thu, 10 Oct 2019 16:21:31 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2CE76AC6E; Thu, 10 Oct 2019 20:21:29 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id CAA94E378C; Thu, 10 Oct 2019 22:21:28 +0200 (CEST) Date: Thu, 10 Oct 2019 22:21:28 +0200 From: Michal Kubecek To: Jakub Kicinski Cc: "David S. Miller" , Jiri Pirko , Johannes Berg , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v2] genetlink: do not parse attributes for families with zero maxattr Message-ID: <20191010202128.GJ22163@unicorn.suse.cz> References: <20191010103402.36408E378C@unicorn.suse.cz> <20191010102102.3bc8515d@cakuba.netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191010102102.3bc8515d@cakuba.netronome.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 10, 2019 at 10:21:02AM -0700, Jakub Kicinski wrote: > On Thu, 10 Oct 2019 12:34:02 +0200 (CEST), Michal Kubecek wrote: > > Commit c10e6cf85e7d ("net: genetlink: push attrbuf allocation and parsing > > to a separate function") moved attribute buffer allocation and attribute > > parsing from genl_family_rcv_msg_doit() into a separate function > > genl_family_rcv_msg_attrs_parse() which, unlike the previous code, calls > > __nlmsg_parse() even if family->maxattr is 0 (i.e. the family does its own > > parsing). The parser error is ignored and does not propagate out of > > genl_family_rcv_msg_attrs_parse() but an error message ("Unknown attribute > > type") is set in extack and if further processing generates no error or > > warning, it stays there and is interpreted as a warning by userspace. > > > > Dumpit requests are not affected as genl_family_rcv_msg_dumpit() bypasses > > the call of genl_family_rcv_msg_doit() if family->maxattr is zero. Do the > > same also in genl_family_rcv_msg_doit(). > > > > Fixes: c10e6cf85e7d ("net: genetlink: push attrbuf allocation and parsing to a separate function") > > Signed-off-by: Michal Kubecek > > --- > > net/netlink/genetlink.c | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c > > index ecc2bd3e73e4..1f14e55ad3ad 100644 > > --- a/net/netlink/genetlink.c > > +++ b/net/netlink/genetlink.c > > @@ -639,21 +639,23 @@ static int genl_family_rcv_msg_doit(const struct genl_family *family, > > const struct genl_ops *ops, > > int hdrlen, struct net *net) > > { > > - struct nlattr **attrbuf; > > + struct nlattr **attrbuf = NULL; > > struct genl_info info; > > int err; > > > > if (!ops->doit) > > return -EOPNOTSUPP; > > > > + if (!family->maxattr) > > + goto no_attrs; > > attrbuf = genl_family_rcv_msg_attrs_parse(family, nlh, extack, > > ops, hdrlen, > > GENL_DONT_VALIDATE_STRICT, > > - family->maxattr && > > family->parallel_ops); > > if (IS_ERR(attrbuf)) > > return PTR_ERR(attrbuf); > > > > +no_attrs: > > The use of a goto statement as a replacement for an if is making me > uncomfortable. I used instead of a simple if because (1) it's what the dumpit code does and (2) the function call arguments are already quite pressed to the 80-character barrier. > Looks like both callers of genl_family_rcv_msg_attrs_parse() jump > around it if !family->maxattr and then check the result with IS_ERR(). > > Would it not make more sense to have genl_family_rcv_msg_attrs_parse() > return NULL if !family->maxattr? This sounds like a good solution. I'll check again in the morning and send v3. Michal