Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2647761ybp; Thu, 10 Oct 2019 10:23:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAx2tKT7tOxJOVnqOWtWHyvpWFglb32pImnnXAnG+ynnSsqJ0dcMHJ0VabVAdT93SsCJym X-Received: by 2002:a50:ec96:: with SMTP id e22mr9355571edr.109.1570728226129; Thu, 10 Oct 2019 10:23:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570728226; cv=none; d=google.com; s=arc-20160816; b=wkLO/Xfy+cgFwxBbYVbvs24tCeX+hHdG4pVjbAvyFTu6CD0ThwTU2pfFAIqg4Oy/ZH 8CoGN3mMoH42IrqKMU5WxLwgNNSlzF6HguWoFGtSDJ/Udh81KTaF4+eRuGsYRi+LOBvY pdqrYPD7trtbKOYnwslS5BAKvo9yOJwH0MI+7Ss5ptogp3ndSNEjFwVe9iSAdaLx48bQ KfVGCf34MEtAbVk8Ckbihorv8q28t7A5A0d8PylR+hU7TmVD8XmbXFc8QYbSSJeXsomb v5VbD+F7rakXkljosdj/naZKJYdXXzyvQN/kB1DrMKHTjmikYq0YY6fhjc33k/uKb3vt VYYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=xuvZN0JITodz2dLriQ7w9E3lEap+u/kTKfmALojGiXI=; b=YLj027jlB75ASek8yxAYLfvCoOSAJCmhlD9Ea1uHk5WEZzX2ln73cCeW22Nu8suBjh XPUf+xapKGiDVCJLiC/PtKtgzoMIDZg/tx0NeuYTG2KtkObDf1NGvvTTQud8qWGoXB58 ZOZvrQxkTgm688NM7Yio1DStVmQXv4nTVU9vOzEsSxVzbdV2qezJypHX3MN92e9wmHa0 UhadnqtyVbOAdOSAkzC2eZJ5uO5C+or9A/0wxrZqixP8h6HBbKicCN2io/8QKspagjJv jR1ogH+TLV3uND2fI5ueD7LZ+28ljRY8S/YHWDqfAGTUKXwKIWoR7/sphEeHJT2nIfGp DBCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=pXvR3Wde; 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 g20si4643410edb.149.2019.10.10.10.23.22; Thu, 10 Oct 2019 10:23:46 -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; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=pXvR3Wde; 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 S1726801AbfJJRVV (ORCPT + 99 others); Thu, 10 Oct 2019 13:21:21 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:32811 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbfJJRVV (ORCPT ); Thu, 10 Oct 2019 13:21:21 -0400 Received: by mail-qk1-f196.google.com with SMTP id x134so6352955qkb.0 for ; Thu, 10 Oct 2019 10:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=xuvZN0JITodz2dLriQ7w9E3lEap+u/kTKfmALojGiXI=; b=pXvR3WdevfThpK6cyxcaeOuvjdw4Z2kJd6T4aFcXn2jmKAeJo74f0Tmk2tKwk6EUdN cGCTn5Y/HVU0nmpCGVUM9YI55p/CiuzGU7poiJHq3C5voS1pwmjv2Q18v2uVyPklSrPI 4EYqI0j5pTpGWTNNA2T/yiT7acrkbCZziLGKS1XW0x27hoiPi4YreBLFCje2gjU9q8Qu 26JBHgtgJnf6tMzpN7oW3itWRwLSS2KamPJ5U0ANI431FsCOc/q3TDgj1WH+ezdWQ3eQ rQz3vySzMofV+CV+o0GallARMOJIB1L9mo3EDGU5TPWH7E1+gexllXrLawymH7wXBobO Y0xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=xuvZN0JITodz2dLriQ7w9E3lEap+u/kTKfmALojGiXI=; b=BvT2BKFdpcWxiJrcGImoKswgUBboRcHIM7C8vNgdAUDFwy/l68JiAGDecBC+ULZ/L+ FK0PyDXntfz+bHtHr0kON7c5nKqFoHSpZNpmpBR6kiKNJORtEJQE6lYhFKaycKMXLfRM tZif4W90iQtDPTa+AuIupLPWdyFO+oEZFV00NlqlDxbcbMgrtUfTjSLbDRZhgCdWhC+p 6+dXSZqNxU7mD9kYXPD5qifLMJfuYZIplJVZzDFeM2+4BLnerj7JZQCO/EfneQq7pu4i HsiNI6qjw03Ir8unjnV4cGgY+aF/97boc0YaUVdjmoeStvz9+8tfuB3KsMDzKGRAc44v 1WOw== X-Gm-Message-State: APjAAAVD0pBuZqHlaS9ubxHZSAHTejpeKSWVcE2FTVHXsUX4vnL4lanY LiDKCg/INf+dNnyQKg1nsz0ieA== X-Received: by 2002:a37:6255:: with SMTP id w82mr10872838qkb.305.1570728080205; Thu, 10 Oct 2019 10:21:20 -0700 (PDT) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id q207sm3254120qke.98.2019.10.10.10.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 10:21:19 -0700 (PDT) Date: Thu, 10 Oct 2019 10:21:02 -0700 From: Jakub Kicinski To: Michal Kubecek 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: <20191010102102.3bc8515d@cakuba.netronome.com> In-Reply-To: <20191010103402.36408E378C@unicorn.suse.cz> References: <20191010103402.36408E378C@unicorn.suse.cz> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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? Just wondering, if you guys prefer this version I can apply.. > info.snd_seq = nlh->nlmsg_seq; > info.snd_portid = NETLINK_CB(skb).portid; > info.nlhdr = nlh; > @@ -676,8 +678,7 @@ static int genl_family_rcv_msg_doit(const struct genl_family *family, > family->post_doit(ops, skb, &info); > > out: > - genl_family_rcv_msg_attrs_free(family, attrbuf, > - family->maxattr && family->parallel_ops); > + genl_family_rcv_msg_attrs_free(family, attrbuf, family->parallel_ops); > > return err; > }