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: <CALYGNiP15BLtxMmMnpEu94jZBtce7tCtJnavrguqFr1d2XxH_A@mail.gmail.com>
Date:	Tue, 24 Mar 2015 21:15:32 +0300
From:	Konstantin Khlebnikov <koct9i@...il.com>
To:	Oleg Nesterov <oleg@...hat.com>
Cc:	Konstantin Khlebnikov <khlebnikov@...dex-team.ru>,
	Davidlohr Bueso <dave@...olabs.net>,
	"linux-mm@...ck.org" <linux-mm@...ck.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mm: fix lockdep build in rcu-protected get_mm_exe_file()

On Tue, Mar 24, 2015 at 9:10 PM, Oleg Nesterov <oleg@...hat.com> wrote:
> On 03/24, Konstantin Khlebnikov wrote:
>>
>> On 23.03.2015 22:10, Oleg Nesterov wrote:
>>> On 03/23, Davidlohr Bueso wrote:
>>>>
>>>>   void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file)
>>>>   {
>>>>     struct file *old_exe_file = rcu_dereference_protected(mm->exe_file,
>>>> -                   !atomic_read(&mm->mm_users) || current->in_execve ||
>>>> -                   lock_is_held(&mm->mmap_sem));
>>>> +                   !atomic_read(&mm->mm_users) || current->in_execve);
>>>
>>> Thanks, looks correct at first glance...
>>>
>>> But can't we remove the ->in_execve check above? and check
>>>
>>>                      atomic_read(&mm->mm_users) <= 1
>>>
>>> instead. OK, this is subjective, I won't insist. Just current->in_execve
>>> looks a bit confusing, it means "I swear, the caller is flush_old_exec()
>>> and this mm is actualy bprm->mm".
>>>
>>> "atomic_read(&mm->mm_users) <= 1" looks a bit more "safe". But again,
>>> I won't insist.
>>
>> Not so safe: this will race with get_task_mm().
>
> How?

I mean rcu/lockdep debug migh race with get_task_mm() and generate
false-positive warning about non-protected rcu_dereference.

>
> If set_mm_exe_file() can race with get_task_mm() then we have a bug.
> And it will be reported ;)
>
>> A lot of proc files grab temporary reference to task mm.
>> But this just a debug -- we can place here "true".
>
> Yeees, probably rcu_dereference_raw() would be even better. set_mm_exe_file()
> must be called only if nobody but us can access this mm.

Yep.

>
> Oleg.
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@...ck.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@...ck.org"> email@...ck.org </a>
--
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