netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <aring@mojatatu.com>
To: jhs@mojatatu.com
Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net,
	netdev@vger.kernel.org, kernel@mojatatu.com,
	Alexander Aring <aring@mojatatu.com>
Subject: [PATCHv2 net-next 02/15] lib: nlattr: set extack msg if validate_nla fails
Date: Thu, 14 Dec 2017 13:38:52 -0500	[thread overview]
Message-ID: <20171214183905.23066-3-aring@mojatatu.com> (raw)
In-Reply-To: <20171214183905.23066-1-aring@mojatatu.com>

This patch sets a generic netlink error message if the validation of the
netlink attribute failed. It avoids several different settings of
netlink messages by handle nla_parse_nested on error case.

Suggested-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Alexander Aring <aring@mojatatu.com>
---
 lib/nlattr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/nlattr.c b/lib/nlattr.c
index dfa55c873c13..a2a9506b2fb7 100644
--- a/lib/nlattr.c
+++ b/lib/nlattr.c
@@ -253,8 +253,10 @@ int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
 			if (policy) {
 				err = validate_nla(nla, maxtype, policy);
 				if (err < 0) {
-					if (extack)
+					if (extack) {
+						NL_SET_ERR_MSG(extack, "Failed to validate netlink attribute");
 						extack->bad_attr = nla;
+					}
 					goto errout;
 				}
 			}
-- 
2.11.0

  parent reply	other threads:[~2017-12-14 18:39 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14 18:38 [PATCHv2 net-next 00/15] net: sched: sch: introduce extack support Alexander Aring
2017-12-14 18:38 ` [PATCHv2 net-next 01/15] net: sched: fix coding style issues Alexander Aring
2017-12-14 18:38 ` Alexander Aring [this message]
2017-12-14 19:45   ` [PATCHv2 net-next 02/15] lib: nlattr: set extack msg if validate_nla fails David Ahern
2017-12-14 18:38 ` [PATCHv2 net-next 03/15] net: sched: sch_api: handle generic qdisc errors Alexander Aring
2017-12-14 18:52   ` Alexander Aring
2017-12-14 19:56   ` David Ahern
2017-12-14 18:38 ` [PATCHv2 net-next 04/15] net: sched: sch: add extack for init callback Alexander Aring
2017-12-16 19:08   ` kbuild test robot
2017-12-16 19:37   ` kbuild test robot
2017-12-16 19:55   ` kbuild test robot
2017-12-14 18:38 ` [PATCHv2 net-next 05/15] net: sched: sch: add extack for change qdisc ops Alexander Aring
2017-12-14 18:38 ` [PATCHv2 net-next 06/15] net: sched: sch: add extack to change class Alexander Aring
2017-12-14 18:38 ` [PATCHv2 net-next 07/15] net: sched: sch: add extack for block callback Alexander Aring
2017-12-14 18:38 ` [PATCHv2 net-next 08/15] net: sched: sch: add extack for graft callback Alexander Aring
2017-12-14 18:38 ` [PATCHv2 net-next 09/15] net: sch: api: add extack support in qdisc_get_rtab Alexander Aring
2017-12-14 20:02   ` David Ahern
2017-12-14 18:39 ` [PATCHv2 net-next 10/15] net: sch: api: add extack support in tcf_block_get Alexander Aring
2017-12-14 20:08   ` David Ahern
2017-12-16 18:27   ` kbuild test robot
2017-12-14 18:39 ` [PATCHv2 net-next 11/15] net: sch: api: add extack support in qdisc_alloc Alexander Aring
2017-12-14 18:39 ` [PATCHv2 net-next 12/15] net: sch: api: add extack support in qdisc_create_dflt Alexander Aring
2017-12-16 19:06   ` kbuild test robot
2017-12-14 18:39 ` [PATCHv2 net-next 13/15] net: sch: sch_cbq: add extack support Alexander Aring
2017-12-14 18:39 ` [PATCHv2 net-next 14/15] net: sch: sch_cbs: " Alexander Aring
2017-12-14 20:11   ` David Ahern
2017-12-14 18:39 ` [PATCHv2 net-next 15/15] net: sch: sch_drr: " Alexander Aring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171214183905.23066-3-aring@mojatatu.com \
    --to=aring@mojatatu.com \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kernel@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).