Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2119618ybp; Thu, 10 Oct 2019 02:31:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFZjTCSkfmb5gVsPVkb2CON/Ixo08BQr511mezR4YswRVDdMJ7aCAXp1K7+wzX7FbLctI2 X-Received: by 2002:aa7:c595:: with SMTP id g21mr7143776edq.79.1570699898875; Thu, 10 Oct 2019 02:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570699898; cv=none; d=google.com; s=arc-20160816; b=K4c7N9a2D4MZSyvdiN5PWVQOjBB3MRel5F87gq4Y2uEDhBVTjJkak2P56Tn4ZOIiBH hdwpELMvTpa6/iBm7RTl/3aAIZWPMJshFpflJZ68DBGQGRIpM3+8QqaEX1JVBE9iJ+w9 cc7OHToQK9Hc631t4D4ItIP8KgT9Whi5jpk3B9+TSLiqdYSSXmobaQh91l9rYT1fnDMn oWT+RhzAXXHzh2TC3WEl05d34FO0Onl6+6VpuPR0nf7dpphJpUvMbLW9Sz/WfKH+dNMn 48WVW+BB2HHyNVqZ+MGXMkH02AdSs7GBZf213aEAAGX5cNO8nr1OhVZfx+0g7O0QrP++ br7Q== 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:dkim-signature; bh=Xw2OqBpr6JQo/dUUNepFw8saT6FZ2X+9TC5O/M6JiCc=; b=mokA1032DcBLZOia08siWw2Dwcd4ebSwNLcIn6S3Br8B3Su1yXfsmYMbpk+TnbrR4p OGJAXwckWNgei7YdeH06fLtoZsSHZ6N0QaMtW791Xyo6dQCcxGEu+LJ73ZOG8x0EJbqe +GPmahBP7l2e9Y7wOJqZsX5YIthxkGmIkLVYMf7IvHmZ7SmqOzygGDnpQS3NjX9njyov oWPpsSfGZlDyhXe3uonGZ/+wy5ocygQaRa3dJZiBz7HBhCLsI+eYHvybZ04f9Hj1SQkV k10V0EwavGW7IgLYlMMI4y8PajGl84l3yTzs2ZkdBp2H26Igl3z62oZYX9LxiWJXxAiW l9qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=tsPN87qr; 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 n8si2743396ejh.169.2019.10.10.02.31.14; Thu, 10 Oct 2019 02:31:38 -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=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=tsPN87qr; 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 S2387799AbfJJJaT (ORCPT + 99 others); Thu, 10 Oct 2019 05:30:19 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:40786 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727320AbfJJJaS (ORCPT ); Thu, 10 Oct 2019 05:30:18 -0400 Received: by mail-wm1-f68.google.com with SMTP id b24so5977222wmj.5 for ; Thu, 10 Oct 2019 02:30:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Xw2OqBpr6JQo/dUUNepFw8saT6FZ2X+9TC5O/M6JiCc=; b=tsPN87qrb7SnXMfk9DsBmdwnImlZtp14YDyx9V4GNwQKfsd9RH3dVINK16uvjNJ3Mv sKHxsnIGvftheCQvCEixkQkt/nkSmenArp8+At1aENlH/OzLZB4yPcaG7XgGkw0As9QV ode/fKW1AJ0jYEEo5+6dek9GIAqTxV3Y4LI2PaMdK3NALKJcQ/82jWEd16K3YMCh7v5L d/MPAXgbVhIFFZrj6NQhRpABv/5XI9wVyQZlSssH3m+P15AO0k2f5B1tODqSFh+o8q+5 ijQiAb4N9fXk5X6uM828NCHG3JK3mwOnAiDqWdnsHTxaIKQMkHNb5FZlVzYxuFRwDiGe d+xg== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Xw2OqBpr6JQo/dUUNepFw8saT6FZ2X+9TC5O/M6JiCc=; b=PMv5d4cu0OEFk87EAPbCEESs8wu3xIDmvNb9xgfREoL90UPfSKaW488Do0iSVH+jfu VkMA7YmvjSc2b/7tLVEIYuOWbEbNzPBaT6f1HHuxnB0DCf2SeJQ7BZLN6P2W8EU8+nR4 vJRDKM8F6sGzlSMxBpvtOlMkG67XQz7u5Vf0zdcFaQ2awkkrFXVkK4Dch+rbu1Q73gKO OhEzt3nxFSXzbMxJVyG82NpgT7diPbvLTBHztl9KwUcA+poqIgMMBpByCDEe5abhAIn0 3xHhe5G5BG8xQsMtyHSccDVBUkMyCVZtR2nJxWS3mpBYID4WMWb4atbJ/ZODBsYCFMWU FOgA== X-Gm-Message-State: APjAAAUxIojEyTi9hAFOV5eSZr3v7HWyb4U2b3LUUK95ACftdU8WXEoL SOb4w7uEc7I+Hr0wQFKtofw53g== X-Received: by 2002:a7b:c849:: with SMTP id c9mr6921856wml.58.1570699816416; Thu, 10 Oct 2019 02:30:16 -0700 (PDT) Received: from localhost ([85.163.43.78]) by smtp.gmail.com with ESMTPSA id e18sm6975329wrv.63.2019.10.10.02.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 02:30:16 -0700 (PDT) Date: Thu, 10 Oct 2019 11:30:15 +0200 From: Jiri Pirko 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] genetlink: do not parse attributes for families with zero maxattr Message-ID: <20191010093015.GF2223@nanopsycho> References: <20191009164432.AD5D1E3785@unicorn.suse.cz> <20191010083958.GD2223@nanopsycho> <20191010091347.GA22163@unicorn.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191010091347.GA22163@unicorn.suse.cz> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thu, Oct 10, 2019 at 11:13:47AM CEST, mkubecek@suse.cz wrote: >On Thu, Oct 10, 2019 at 10:39:58AM +0200, Jiri Pirko wrote: >> Wed, Oct 09, 2019 at 06:44:32PM CEST, mkubecek@suse.cz 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(). >> >> This is the original code before the changes: >> >> if (ops->doit == NULL) >> return -EOPNOTSUPP; >> >> if (family->maxattr && family->parallel_ops) { >> attrbuf = kmalloc_array(family->maxattr + 1, >> sizeof(struct nlattr *), >> GFP_KERNEL); >> if (attrbuf == NULL) >> return -ENOMEM; >> } else >> attrbuf = family->attrbuf; >> >> if (attrbuf) { >> enum netlink_validation validate = NL_VALIDATE_STRICT; >> >> if (ops->validate & GENL_DONT_VALIDATE_STRICT) >> validate = NL_VALIDATE_LIBERAL; >> >> err = __nlmsg_parse(nlh, hdrlen, attrbuf, family->maxattr, >> family->policy, validate, extack); >> if (err < 0) >> goto out; >> } >> >> Looks like the __nlmsg_parse() is called no matter if maxattr if 0 or >> not. It is only considered for allocation of attrbuf. This is in-sync >> with the current code. > >If family->maxattr is 0, genl_register_family() sets family->attrbuf to >NULL so that attrbuf is also NULL and the whole "if (attrbuf) { ... }" >block is not executed. Ah, I missed that. Thanks! > >Michal