netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: xemul@openvz.org
Cc: netdev@vger.kernel.org, devel@openvz.org
Subject: Re: [PATCH 0/4] Fix race between sk_filter reassign and sk_clone()
Date: Wed, 17 Oct 2007 21:23:02 -0700 (PDT)	[thread overview]
Message-ID: <20071017.212302.68039057.davem@davemloft.net> (raw)
In-Reply-To: <4715D9D2.8070102@openvz.org>

From: Pavel Emelyanov <xemul@openvz.org>
Date: Wed, 17 Oct 2007 13:45:54 +0400

> The race can result in that some sock will get an sk_filter
> pointer set to kfree-d memory. Look
> 
> CPU1:                            CPU2:
> sk_clone():                      sk_attach_filter():
>   new_sk = sk_alloc(...);
>   sock_copy(new_sk, sk); 
>   /* copies the filter ptr */
>   ...
>   filter = new_sk->sk_filter;
>   if (filter)
>                                      old_fp = sk->sk_filter;
>                                      ...
>                                      sk_filter_release(old_fp);
>                                        if (atomic_dec_and_test(&old_fp->refcnt))
>      atomic_inc(&filter->refcnt);
>                                           /* true */
>                                           call_rcu(&fp->rcu, kfree);
> 
> that's it - after a quiescent state pass the new_sk will have 
> a pointer on kfree-d filter.
> 
> The same problem exists for detaching filter (SO_DETACH_FILTER).
> 
> The proposed fix consists of 3 preparation patches and the fix itself.
> 
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

Looks good, applied.

Thanks for fixing this bug Pavel!

  parent reply	other threads:[~2007-10-18  4:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-17  9:45 [PATCH 0/4] Fix race between sk_filter reassign and sk_clone() Pavel Emelyanov
2007-10-17  9:47 ` [PATCH 1/4] Introduce the sk_detach_filter() call Pavel Emelyanov
2007-10-17  9:49 ` [PATCH 2/4] Move the filter releasing into a separate call Pavel Emelyanov
2007-10-17  9:51 ` [PATCH 3/4] Cleanup the error path in sk_attach_filter Pavel Emelyanov
2007-10-17  9:53 ` [PATCH 4/4] Fix the race between sk_filter_(de|at)tach and sk_clone() Pavel Emelyanov
2007-10-18  4:23 ` David Miller [this message]
2007-10-19  2:29   ` [PATCH 0/4] Fix race between sk_filter reassign " Olof Johansson
2007-10-19  4:55     ` David Miller
2007-10-19  7:37       ` Pavel Emelyanov
2007-10-19  7:52         ` 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=20071017.212302.68039057.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=devel@openvz.org \
    --cc=netdev@vger.kernel.org \
    --cc=xemul@openvz.org \
    /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).