netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Graf <tgraf@suug.ch>,
	Johannes Berg <johannes@sipsolutions.net>,
	Linux Netdev List <netdev@vger.kernel.org>
Subject: netlink: allow empty nested attributes
Date: Thu, 27 Nov 2008 13:57:19 +0100	[thread overview]
Message-ID: <492E992F.7040703@trash.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: 01.diff --]
[-- Type: text/x-patch, Size: 1171 bytes --]

commit 57b0afc97f8249f0b4f665aa285ed89a9178ba42
Author: Patrick McHardy <kaber@trash.net>
Date:   Thu Nov 27 13:40:31 2008 +0100

    netlink: allow empty nested attributes
    
    validate_nla() currently doesn't allow empty nested attributes. This
    makes userspace code unnecessarily complicated when starting and ending
    the nested attribute is done by generic upper level code and the inner
    attributes are dumped by a module.
    
    Add a special case to accept empty nested attributes. When the nested
    attribute is non empty, the same checks as before are performed.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netlink/attr.c b/net/netlink/attr.c
index c83fea7..56c3ce7 100644
--- a/net/netlink/attr.c
+++ b/net/netlink/attr.c
@@ -83,6 +83,12 @@ static int validate_nla(struct nlattr *nla, int maxtype,
 		if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN + nla_len(nla))
 			return -ERANGE;
 		break;
+	case NLA_NESTED:
+		/* a nested attributes is allowed to be empty; if its not,
+		 * it must have a size of at least NLA_HDRLEN.
+		 */
+		if (attrlen == 0)
+			break;
 	default:
 		if (pt->len)
 			minlen = pt->len;

             reply	other threads:[~2008-11-27 12:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-27 12:57 Patrick McHardy [this message]
2008-11-28 11:05 ` netlink: allow empty nested attributes David Miller

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=492E992F.7040703@trash.net \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=johannes@sipsolutions.net \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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).