Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1166943ybp; Wed, 9 Oct 2019 09:45:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAez8U3t9rXjbh0WEignDZFLiarhd1koBqz1zZ8EkVR/kmnmC1xuwxjotNX6sIy7F6EQWV X-Received: by 2002:aa7:da4a:: with SMTP id w10mr3759745eds.209.1570639518761; Wed, 09 Oct 2019 09:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570639518; cv=none; d=google.com; s=arc-20160816; b=fDbSCrfVGa+/wb3zX1Bey5Progw6q4T90aqkKscsR9L8At6CrTUhHgqCAHsZGKSkUA uiFRI+C5ejIKfqSrRAJzSiyrVKRx+PcBSGuev8Phh7oZkiSytddnMgkTCy8FCJ+nIPH0 VGC+QYceWEhTYlt2TTtxS7BQ+fjOSP5+rfFbqG/dbB5g6qISG47yaU40mjx+CLk4sm5O /3jRM+nZXShidU+NEvW+dUTDQhvNbJirWKgpckUpgp2nHwPaveZZMzfJ5LJM6q40qEcN mvdbwYKKF8Id/EIJIMrMa9thgvOg9XaUEjxsEtp+mkDK0li0KnSpYQ8XFFNA5ij6P+35 No8w== 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=znW5vQvvlkC0mlhQFKe8OqRau69BrK2OAnJh3G10Rmc=; b=TBp/LLiAYbR03XiWTBhETc9vovT4a0382SEkIxtSG+D0dUmwZZPzDA8foYWLttRjrF BvX9Ql008vdqq4Z8029UGxj8NrAVm6xAFcRPJuNPAmVDblVVsj7cm4y7cjy63g4jFrab XPnWgWwtoRuPlA9Gnq1ISwAtzhf3vxO0TxZ+MAd9xsmE14yygig9/jMmIc6fO4FlVFqo mmF3Kcu/wP1eW0bZAT8qI4hkEMPXcgQU5ZlNg8KNLxUeuqDSSx6nnBD8gH0sZqFcxH8r HF7OSqpyLn0XDUGmjnyDtImcOAbk71vOvdacAYXtIKZ2deoVPF4Rd5lNcDGfwgvH13cN B4dQ== 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 f11si1524101ejw.116.2019.10.09.09.44.54; Wed, 09 Oct 2019 09:45:18 -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 S1731790AbfJIQof (ORCPT + 99 others); Wed, 9 Oct 2019 12:44:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:56018 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729644AbfJIQof (ORCPT ); Wed, 9 Oct 2019 12:44:35 -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 57B1DAC7D; Wed, 9 Oct 2019 16:44:33 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id AD5D1E3785; Wed, 9 Oct 2019 18:44:32 +0200 (CEST) From: Michal Kubecek Subject: [PATCH net-next] 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: <20191009164432.AD5D1E3785@unicorn.suse.cz> Date: Wed, 9 Oct 2019 18:44:32 +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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index ecc2bd3e73e4..c4bf8830eedf 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; -- 2.23.0