Linux Container Development
 help / color / mirror / Atom feed
From: ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman)
To: Andrei Vagin <avagin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	syzkaller <syzkaller-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>,
	Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>,
	JongHwan Kim <zzoru007-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Dmitry Vyukov <dvyukov-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Subject: Re: [REVIEW][PATCH] ucount: Remove the atomicity from ucount->count
Date: Mon, 06 Mar 2017 15:26:09 -0600	[thread overview]
Message-ID: <87fuiq14i6.fsf@xmission.com> (raw)
In-Reply-To: <20170306203919.GA17874-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> (Andrei Vagin's message of "Mon, 6 Mar 2017 12:39:21 -0800")

Andrei Vagin <avagin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> On Sun, Mar 05, 2017 at 03:41:06PM -0600, Eric W. Biederman wrote:
>> 
>> Always increment/decrement ucount->count under the ucounts_lock.  The
>> increments are there already and moving the decrements there means the
>> locking logic of the code is simpler.  This simplification in the
>> locking logic fixes a race between put_ucounts and get_ucounts that
>> could result in a use-after-free because the count could go zero then
>> be found by get_ucounts and then be freed by put_ucounts.
>> 
>> A bug presumably this one was found by a combination of syzkaller and
>> KASAN.  JongWhan Kim reported the syzkaller failure and Dmitry Vyukov
>> spotted the race in the code.
>>
>
> Reviewed-by: Andrei Vagin <avagin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> I think we can rework this in a future so that ucount will be rcu
> protected.

Agreed. Although I would like to see a benchmark that motivated that.
So far my impression is that all of these counts are in the noise.
Which is why I have aimed more at simplicity than the fastest possible
data structures.


Eric

      parent reply	other threads:[~2017-03-06 21:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <C4CB953C-4712-43F3-9E75-1A12C14B8A4B@gmail.com>
     [not found] ` <C4CB953C-4712-43F3-9E75-1A12C14B8A4B-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-03 15:37   ` ucount: use-after-free read in inc_ucount & dec_ucount Nikolay Borisov
     [not found]     ` <180fb7dc-790e-8e82-0cc1-c6e15ddcd20b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-03 16:30       ` Eric W. Biederman
     [not found]         ` <87pohy1fx6.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2017-03-03 16:45           ` Nikolay Borisov
     [not found]             ` <d0a23a9c-65a6-063f-748b-e399bed6dacd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-03 16:46               ` Eric W. Biederman
2017-03-04 10:58           ` Nikolay Borisov
     [not found]             ` <1aafd5e9-d9de-e5d9-a77d-cf245c5a5c6a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-04 11:44               ` Dmitry Vyukov via Containers
     [not found]                 ` <CACT4Y+a043_qFN=2uzvYhDFwF4JS9_p3jnOykpMk=RcpqQfKGQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-04 11:50                   ` Dmitry Vyukov via Containers
     [not found]                     ` <CACT4Y+Yev63VXYm+kZdii5kheV_ACBn2cehFcFdz6LBVam3Q2g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-04 11:57                       ` Dmitry Vyukov via Containers
2017-03-04 12:01                       ` Dmitry Vyukov via Containers
     [not found]                         ` <CACT4Y+b7YXnoOkdYTjp6D6XH-zuYRx063hMayOVMyJVc735dtQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-04 12:10                           ` Nikolay Borisov
     [not found]                             ` <c69f8f03-4324-f934-eed2-643c91d703c0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-04 12:15                               ` Dmitry Vyukov via Containers
     [not found]                                 ` <CACT4Y+avCy8Susvb09DLHkGym0K_15+EeZ8yBH7tcgjvnb3Yhw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-04 12:35                                   ` 쪼르
     [not found]                                     ` <CALRZ7Ut=bAgX+XwS3h8-V-zGqiUFkuSCi_C=j6uN_=OptU-+RQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-05 21:00                                       ` Eric W. Biederman
     [not found]                                         ` <87efybfnh2.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2017-03-06  9:13                                           ` Dmitry Vyukov via Containers
     [not found]                                             ` <CACT4Y+aZmSY3rmV7+iC7i6Ov2Of4N5YTpjz5Tk8XCki-CyAY5w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-06 16:33                                               ` Eric W. Biederman
     [not found]                                                 ` <87a88y4b78.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2017-03-06 18:43                                                   ` Dmitry Vyukov via Containers
2017-03-04 12:38                                   ` Dmitry Vyukov via Containers
     [not found]                                     ` <CACT4Y+YWEq66QXbTMR4yGtgc0ULN+TurAnRzcDASaja1z5XNjA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-04 23:58                                       ` Eric W. Biederman
     [not found]                                         ` <87shmsoar7.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2017-03-05 10:53                                           ` Dmitry Vyukov via Containers
     [not found]                                             ` <CACT4Y+bYAbsxsRWA2o+c7x25f1JPSqZKX-8a8NJq4nab-PyYig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-05 18:41                                               ` Eric W. Biederman
     [not found]                                                 ` <87y3wjlg6r.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2017-03-05 21:41                                                   ` [REVIEW][PATCH] ucount: Remove the atomicity from ucount->count Eric W. Biederman
     [not found]                                                     ` <87tw77csgd.fsf_-_-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2017-03-06 20:39                                                       ` Andrei Vagin
     [not found]                                                         ` <20170306203919.GA17874-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-06 21:26                                                           ` Eric W. Biederman [this message]

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=87fuiq14i6.fsf@xmission.com \
    --to=ebiederm-as9lmozglivwk0htik3j/w@public.gmane.org \
    --cc=avagin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=dvyukov-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=jack-AlSwsSmVLrQ@public.gmane.org \
    --cc=syzkaller-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=zzoru007-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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