* [PATCH] rtnetlink: Fix message size calculation for link messages
@ 2010-11-12 1:47 Thomas Graf
2010-11-12 7:43 ` Patrick McHardy
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Graf @ 2010-11-12 1:47 UTC (permalink / raw)
To: davem; +Cc: Patrick McHardy, netdev
nlmsg_total_size() calculates the length of a netlink message
including header and alignment. nla_total_size() calculates the
space an individual attribute consumes which was meant to be used
in this context.
Also, ensure to account for the attribute header for the
IFLA_INFO_XSTATS attribute as implementations of get_xstats_size()
seem to assume that we do so.
The addition of two message headers minus the missing attribute
header resulted in a calculated message size that was larger than
required. Therefore we never risked running out of skb tailroom.
Signed-off-by: Thomas Graf <tgraf@infradead.org>
Cc: Patrick McHardy <kaber@trash.net>
Index: net-2.6/net/core/rtnetlink.c
===================================================================
--- net-2.6.orig/net/core/rtnetlink.c
+++ net-2.6/net/core/rtnetlink.c
@@ -347,16 +347,17 @@ static size_t rtnl_link_get_size(const s
if (!ops)
return 0;
- size = nlmsg_total_size(sizeof(struct nlattr)) + /* IFLA_LINKINFO */
- nlmsg_total_size(strlen(ops->kind) + 1); /* IFLA_INFO_KIND */
+ size = nla_total_size(sizeof(struct nlattr)) + /* IFLA_LINKINFO */
+ nla_total_size(strlen(ops->kind) + 1); /* IFLA_INFO_KIND */
if (ops->get_size)
/* IFLA_INFO_DATA + nested data */
- size += nlmsg_total_size(sizeof(struct nlattr)) +
+ size += nla_total_size(sizeof(struct nlattr)) +
ops->get_size(dev);
if (ops->get_xstats_size)
- size += ops->get_xstats_size(dev); /* IFLA_INFO_XSTATS */
+ /* IFLA_INFO_XSTATS */
+ size += nla_total_size(ops->get_xstats_size(dev));
return size;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rtnetlink: Fix message size calculation for link messages
2010-11-12 1:47 [PATCH] rtnetlink: Fix message size calculation for link messages Thomas Graf
@ 2010-11-12 7:43 ` Patrick McHardy
2010-11-12 18:53 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Patrick McHardy @ 2010-11-12 7:43 UTC (permalink / raw)
To: davem, netdev
On 12.11.2010 02:47, Thomas Graf wrote:
> nlmsg_total_size() calculates the length of a netlink message
> including header and alignment. nla_total_size() calculates the
> space an individual attribute consumes which was meant to be used
> in this context.
>
> Also, ensure to account for the attribute header for the
> IFLA_INFO_XSTATS attribute as implementations of get_xstats_size()
> seem to assume that we do so.
>
> The addition of two message headers minus the missing attribute
> header resulted in a calculated message size that was larger than
> required. Therefore we never risked running out of skb tailroom.
>
> Signed-off-by: Thomas Graf <tgraf@infradead.org>
> Cc: Patrick McHardy <kaber@trash.net>
Looks good to me, thanks Thomas.
Acked-by: Patrick McHardy <kaber@trash.net>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rtnetlink: Fix message size calculation for link messages
2010-11-12 7:43 ` Patrick McHardy
@ 2010-11-12 18:53 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2010-11-12 18:53 UTC (permalink / raw)
To: kaber; +Cc: netdev
From: Patrick McHardy <kaber@trash.net>
Date: Fri, 12 Nov 2010 08:43:46 +0100
> On 12.11.2010 02:47, Thomas Graf wrote:
>> nlmsg_total_size() calculates the length of a netlink message
>> including header and alignment. nla_total_size() calculates the
>> space an individual attribute consumes which was meant to be used
>> in this context.
>>
>> Also, ensure to account for the attribute header for the
>> IFLA_INFO_XSTATS attribute as implementations of get_xstats_size()
>> seem to assume that we do so.
>>
>> The addition of two message headers minus the missing attribute
>> header resulted in a calculated message size that was larger than
>> required. Therefore we never risked running out of skb tailroom.
>>
>> Signed-off-by: Thomas Graf <tgraf@infradead.org>
>> Cc: Patrick McHardy <kaber@trash.net>
>
> Looks good to me, thanks Thomas.
>
> Acked-by: Patrick McHardy <kaber@trash.net>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-12 18:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-12 1:47 [PATCH] rtnetlink: Fix message size calculation for link messages Thomas Graf
2010-11-12 7:43 ` Patrick McHardy
2010-11-12 18:53 ` 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).