From: Konstantin Khlebnikov <khlebnikov@yandex-team•ru>
To: Eric Dumazet <eric.dumazet@gmail•com>
Cc: netdev@vger•kernel.org, "David S. Miller" <davem@davemloft•net>,
Eric Dumazet <edumazet@google•com>,
Herbert Xu <herbert@gondor•apana.org.au>
Subject: Re: [PATCH] netlink: enable skb header refcounting before sending first broadcast
Date: Fri, 10 Jul 2015 17:08:32 +0300 [thread overview]
Message-ID: <559FD1E0.40909@yandex-team.ru> (raw)
In-Reply-To: <1436536187.24939.50.camel@edumazet-glaptop2.roam.corp.google.com>
On 10.07.2015 16:49, Eric Dumazet wrote:
> On Fri, 2015-07-10 at 14:51 +0300, Konstantin Khlebnikov wrote:
>> This fixes race between non-atomic updates of adjacent bit-fields:
>> skb->cloned could be lost because netlink broadcast clones skb after
>> sending it to the first listener who sets skb->peeked at the same skb.
>> As a result atomic refcounting of skb header stays disabled and
>> skb_release_data() frees it twice. Race leads to double-free in kmalloc-xxx.
>>
>> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team•ru>
>> Fixes: b19372273164 ("net: reorganize sk_buff for faster __copy_skb_header()")
>> ---
>> net/netlink/af_netlink.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
>> index dea925388a5b..921e0d8dfe3a 100644
>> --- a/net/netlink/af_netlink.c
>> +++ b/net/netlink/af_netlink.c
>> @@ -2028,6 +2028,12 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 portid
>> info.tx_filter = filter;
>> info.tx_data = filter_data;
>>
>> + /* Enable atomic refcounting in skb_release_data() before first send:
>> + * non-atomic set of that bit-field in __skb_clone() could race with
>> + * __skb_recv_datagram() which touches the same set of bit-fields.
>> + */
>> + skb->cloned = 1;
>> +
>> /* While we sleep in clone, do not allow to change socket list */
>>
>> netlink_lock_table();
>
> Wow, this is tricky.
>
> I wonder how you found this bug ????
In some setups race happens quite often: once or twice per hour.
I guess the main trigger was the openvswitch which generates a
lot of netlink traffic. Though debugging was a real pain.
>
> Acked-by: Eric Dumazet <edumazet@google•com>
>
>
>
--
Konstantin
next prev parent reply other threads:[~2015-07-10 14:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-10 11:51 [PATCH] netlink: enable skb header refcounting before sending first broadcast Konstantin Khlebnikov
2015-07-10 13:49 ` Eric Dumazet
2015-07-10 14:08 ` Konstantin Khlebnikov [this message]
2015-07-13 7:23 ` Herbert Xu
2015-07-13 8:04 ` net: Clone skb before setting peeked flag Herbert Xu
2015-07-15 23:13 ` David Miller
2015-07-13 8:05 ` [PATCH] netlink: enable skb header refcounting before sending first broadcast Eric Dumazet
2015-07-13 8:10 ` Herbert Xu
2015-07-13 8:22 ` Eric Dumazet
2015-07-13 8:25 ` Herbert Xu
2015-07-13 8:28 ` Eric Dumazet
2015-07-13 8:31 ` Herbert Xu
2015-07-13 12:01 ` net: Fix skb csum races when peeking Herbert Xu
2015-07-13 14:25 ` Herbert Xu
2015-07-14 6:11 ` Eric Dumazet
2015-07-15 23:14 ` David Miller
2015-07-13 8:54 ` [PATCH] netlink: enable skb header refcounting before sending first broadcast Konstantin Khlebnikov
2015-07-13 9:04 ` Herbert Xu
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=559FD1E0.40909@yandex-team.ru \
--to=khlebnikov@yandex-team$(echo .)ru \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=eric.dumazet@gmail$(echo .)com \
--cc=herbert@gondor$(echo .)apana.org.au \
--cc=netdev@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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