* netlink: allow empty nested attributes
@ 2008-11-27 12:57 Patrick McHardy
2008-11-28 11:05 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Patrick McHardy @ 2008-11-27 12:57 UTC (permalink / raw)
To: David S. Miller; +Cc: Thomas Graf, Johannes Berg, Linux Netdev List
[-- 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;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: netlink: allow empty nested attributes
2008-11-27 12:57 netlink: allow empty nested attributes Patrick McHardy
@ 2008-11-28 11:05 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2008-11-28 11:05 UTC (permalink / raw)
To: kaber; +Cc: tgraf, johannes, netdev
From: Patrick McHardy <kaber@trash.net>
Date: Thu, 27 Nov 2008 13:57:19 +0100
> 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>
Applied, thanks Patrick.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-11-28 11:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-27 12:57 netlink: allow empty nested attributes Patrick McHardy
2008-11-28 11:05 ` David Miller
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).