lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTimuCgn4aHzUJRmQfsXjG_UF-3W8fAWb0Y-sSPsM@mail.gmail.com>
Date:	Sat, 15 Jan 2011 02:00:25 +1100
From:	Nick Piggin <npiggin@...il.com>
To:	Jeff Moyer <jmoyer@...hat.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-fsdevel <linux-fsdevel@...r.kernel.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [patch] fs: aio fix rcu lookup

On Sat, Jan 15, 2011 at 1:52 AM, Jeff Moyer <jmoyer@...hat.com> wrote:
> Nick Piggin <npiggin@...il.com> writes:
>
>> Hi,
>>
>> While hunting down a bug in NFS's AIO, I believe I found this
>> buggy code...
>>
>> fs: aio fix rcu ioctx lookup
>>
>> aio-dio-invalidate-failure GPFs in aio_put_req from io_submit.
>>
>> lookup_ioctx doesn't implement the rcu lookup pattern properly.
>> rcu_read_lock does not prevent refcount going to zero, so we
>> might take a refcount on a zero count ioctx.
>
> So, does this patch fix the problem?  You didn't actually say....

No, it seemd to be an NFS AIO problem, although it was a
slightly older kernel so I'll re test after -rc1 if I haven't heard
back about it.

Do you agree with the theoretical problem? I didn't try to
write a racer to break it yet. Inserting a delay before the
get_ioctx might do the trick.


>> Signed-off-by: Nick Piggin <npiggin@...nel.dk>
>>
>> Index: linux-2.6/fs/aio.c
>> ===================================================================
>> --- linux-2.6.orig/fs/aio.c   2011-01-14 00:29:00.000000000 +1100
>> +++ linux-2.6/fs/aio.c        2011-01-14 11:31:47.000000000 +1100
>> @@ -239,15 +239,23 @@ static void __put_ioctx(struct kioctx *c
>>       call_rcu(&ctx->rcu_head, ctx_rcu_free);
>>  }
>>
>> -#define get_ioctx(kioctx) do {                                               \
>> -     BUG_ON(atomic_read(&(kioctx)->users) <= 0);                     \
>> -     atomic_inc(&(kioctx)->users);                                   \
>> -} while (0)
>> -#define put_ioctx(kioctx) do {                                               \
>> -     BUG_ON(atomic_read(&(kioctx)->users) <= 0);                     \
>> -     if (unlikely(atomic_dec_and_test(&(kioctx)->users)))            \
>> -             __put_ioctx(kioctx);                                    \
>> -} while (0)
>> +static inline void get_ioctx(struct kioctx *kioctx)
>> +{
>> +     BUG_ON(atomic_read(&kioctx->users) <= 0);
>> +     atomic_inc(&kioctx->users);
>> +}
>> +
>> +static inline int try_get_ioctx(struct kioctx *kioctx)
>> +{
>> +     return atomic_inc_not_zero(&kioctx->users);
>> +}
>> +
>> +static inline void put_ioctx(struct kioctx *kioctx)
>> +{
>> +     BUG_ON(atomic_read(&kioctx->users) <= 0);
>> +     if (unlikely(atomic_dec_and_test(&kioctx->users)))
>> +             __put_ioctx(kioctx);
>> +}
>
> Why did you switch from macros?  Personal preference?  Can you at least
> mention it in the changelog?

Yeah, I couldn't bring myself to add another macro :) I can mention
it, sure.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ