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: <dc028fd0-b188-435e-9dc3-f5de53dd9686@gmail.com>
Date:   Thu, 26 Oct 2023 21:07:46 +0530
From:   Abhinav Singh <singhabhinav9051571833@...il.com>
To:     "Michael S. Tsirkin" <mst@...hat.com>,
        Mateusz Guzik <mjguzik@...il.com>
Cc:     akpm@...ux-foundation.org, brauner@...nel.org, surenb@...gle.com,
        michael.christie@...cle.com, mathieu.desnoyers@...icios.com,
        npiggin@...il.com, shakeelb@...gle.com, peterz@...radead.org,
        linux-kernel@...r.kernel.org,
        linux-kernel-mentees@...ts.linuxfoundation.org,
        "Paul E. McKenney" <paulmck@...nel.org>
Subject: Re: [PATCH v2] Fixing directly deferencing a __rcu pointer warning

On 10/26/23 20:47, Michael S. Tsirkin wrote:
> On Thu, Oct 26, 2023 at 04:06:24PM +0200, Mateusz Guzik wrote:
>> On 10/26/23, Michael S. Tsirkin <mst@...hat.com> wrote:
>>> On Thu, Oct 26, 2023 at 05:46:21PM +0530, Abhinav Singh wrote:
>>>> This patch fixes the warning about directly dereferencing a pointer
>>>> tagged with __rcu annotation.
>>>>
>>>> Dereferencing the pointers tagged with __rcu directly should
>>>> always be avoided according to the docs. There is a rcu helper
>>>> functions rcu_dereference(...) to use when dereferencing a __rcu
>>>> pointer. This functions returns the non __rcu tagged pointer which
>>>> can be dereferenced just like a normal pointers.
>>>>
>>>> Signed-off-by: Abhinav Singh <singhabhinav9051571833@...il.com>
>>>
>>> Well yes but these need to be called under rcu_read_lock.
>>> Who does it here?
>>> If no one then maybe you found an actual bug and we need to
>>> fix it not paper over it.
>>>
>>
>> There is no bug here.
>>
>> p is the newly created thread, ->real_cred was initialized just prior
>> to this code and there is nobody to whack the creds from under it.
>>
>> Second bit in the patch changes one real_parent deref, but leaves 2
>> others just above it. Once more no bug since the entire thing happens
>> under tasklist_lock, but the patch should either sort all these cases
>> or none.
Sparse reported 3 similar dereferencing warning this patch contains 2 
fixes for 2, but yeah I should fixed all 3 of them.
>>
>> I think it would help if the submitter had shown warnings they see.
The warning message :- warning: dereference of noderef expression
> 
> Yes, and this must be tested under lockdep, which I think would
> spit out warnings for this patch.
Not sure, but I tested this with sparse (make C=2) and after the above 
changes I dont get the warning.
> 
> What should be used here I'm not sure. IIUC rcu_dereference_protected(p, 1)
> is discouraged now?
> 
Not sure but I read that, rcu_dereference should be prefered when 
reading and rcu_dereference_protected should when writing.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ