Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2180159ybp; Thu, 10 Oct 2019 03:34:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwo2AHpsYHmj2UOR2QPr+UFW/V7i5ylM039TSJOqpbTx2/RDBi4Jf3zHDwJQrnfUAKOnH6i X-Received: by 2002:a05:6402:88d:: with SMTP id e13mr7233588edy.246.1570703687073; Thu, 10 Oct 2019 03:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570703687; cv=none; d=google.com; s=arc-20160816; b=gEI84Gg4kOP+y68/vDKLGfTEk8vaxwThAuzMmaGQfZylQT8ZJrWW0PTIBZt3DmLxcP QR3bOKjkCxubdGPVDb7QLxzQaOrgG/Onl2cD005qxAqY9SQBw6mqXXJvDC23p5osMgBx AswiMkX6Ohb0fCA21N9jH66tzzkNOzrhx8K1RZkQD1YANXgB4mnEkHyZY7DjEVZM0hFT nUUePCd4njQC1MTlxfac4nZ+0pRfLumLeWhWqaKM279OTV6YctOK9SMiHE/8FiH79vny iNowEMrKUIlGzhRwlE+t/L4lEaiD3JiNEJ12MXgIl6gGi8B+ikIucWZ/0VVnrX1Bfxth BmzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:cc:to:subject:from; bh=LtLsaiZmB7wbLvtovrMhdPhYjqZVvNAtcMdjvMn0x9w=; b=jcpWvHIGuq8amV776/d5iKJbhKB0COHEepWccNRQAHL9rsEX4oXaKBGyEUClEpu8n0 Ey/6n6cKc9HOEPp7VVHLiZWeAhF71ydQuPZyMTDMY19q8KbM5puZToaZ1Dm0wZWoGnhO VjBS6yC/NZagZ+OKuCVTwun3s2ejtLa5ngWQ9q8mlxOsTXB70251tQFyOOPM0dQtFBwe 87c5cfBXpXQ9AYmS8gtGGsVOQ9ZE2iK7xe9nBINORexrSRmiMpwyj2sIz8Aq1TnPZk4w cFDf2zVDVV99iT8+ynicsBR/x+PJGgQ4h/0NQ/BFO0gIby5/BVkTDF+hrtA/oJOIwTS5 uDqw== 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 jx7si2946046ejb.84.2019.10.10.03.34.23; Thu, 10 Oct 2019 03:34:47 -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 S1732682AbfJJKeF (ORCPT + 99 others); Thu, 10 Oct 2019 06:34:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:52624 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726298AbfJJKeE (ORCPT ); Thu, 10 Oct 2019 06:34:04 -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 1557CB187; Thu, 10 Oct 2019 10:34:03 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 36408E378C; Thu, 10 Oct 2019 12:34:02 +0200 (CEST) From: Michal Kubecek Subject: [PATCH net-next v2] genetlink: do not parse attributes for families with zero maxattr To: "David S. Miller" Cc: Jiri Pirko , Johannes Berg , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: <20191010103402.36408E378C@unicorn.suse.cz> Date: Thu, 10 Oct 2019 12:34:02 +0200 (CEST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: 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; } -- 2.23.0