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]
Date:   Mon, 15 Nov 2021 11:59:03 -0800
From:   Shakeel Butt <shakeelb@...gle.com>
To:     Mina Almasry <almasrymina@...gle.com>,
        Marco Elver <elver@...gle.com>, paulmck@...nel.org
Cc:     Mike Kravetz <mike.kravetz@...cle.com>,
        Muchun Song <songmuchun@...edance.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Shuah Khan <shuah@...nel.org>,
        Miaohe Lin <linmiaohe@...wei.com>,
        Oscar Salvador <osalvador@...e.de>,
        Michal Hocko <mhocko@...e.com>,
        David Rientjes <rientjes@...gle.com>,
        Jue Wang <juew@...gle.com>, Yang Yao <ygyao@...gle.com>,
        Joanna Li <joannali@...gle.com>,
        Cannon Matthews <cannonmatthews@...gle.com>,
        Linux Memory Management List <linux-mm@...ck.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v6] hugetlb: Add hugetlb.*.numa_stat file

)

On Mon, Nov 15, 2021 at 10:55 AM Mina Almasry <almasrymina@...gle.com> wrote:
>
> On Mon, Nov 15, 2021 at 10:22 AM Mike Kravetz <mike.kravetz@...cle.com> wrote:
> >
> > Subject:   Re: [PATCH v6] hugetlb: Add hugetlb.*.numa_stat file
> >
> > To:        Muchun Song <songmuchun@...edance.com>, Shakeel Butt <shakeelb@...gle.com>, Mina Almasry <almasrymina@...gle.com>
> >
> > Cc:        Andrew Morton <akpm@...ux-foundation.org>, Shuah Khan <shuah@...nel.org>, Miaohe Lin <linmiaohe@...wei.com>, Oscar Salvador <osalvador@...e.de>, Michal Hocko <mhocko@...e.com>, David Rientjes <rientjes@...gle.com>, Jue Wang <juew@...gle.com>, Yang Yao <ygyao@...gle.com>, Joanna Li <joannali@...gle.com>, Cannon Matthews <cannonmatthews@...gle.com>, Linux Memory Management List <linux-mm@...ck.org>, LKML <linux-kernel@...r.kernel.org>
> >
> > Bcc:
> >
> > -=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-
> >
> > On 11/14/21 5:43 AM, Muchun Song wrote:
> >
> > > On Sun, Nov 14, 2021 at 3:15 AM Shakeel Butt <shakeelb@...gle.com> wrote:
> >
> > >> On Sat, Nov 13, 2021 at 6:48 AM Mina Almasry <almasrymina@...gle.com> wrote:
> >
> > >>> On Fri, Nov 12, 2021 at 6:45 PM Muchun Song <songmuchun@...edance.com> wrote:
> >
> > >>>> On Sat, Nov 13, 2021 at 7:36 AM Mike Kravetz <mike.kravetz@...cle.com> wrote:
> >
> > >> We have following options:
> >
> > >>
> >
> > >> 1) Use atomic type for usage.
> >
> > >> 2) Use "unsigned long" for usage along with WRITE_ONCE/READ_ONCE.
> >
> > >> 3) Use hugetlb_lock for hugetlb_cgroup_read_numa_stat as well.
> >
> > >>
> >
> > >> All options are valid but we would like to avoid (3).
> >
> > >>
> >
> > >> What if we use "unsigned long" type but without READ_ONCE/WRITE_ONCE.
> >
> > >> The potential issues with that are KCSAN will report this as race and
> >
> > >> possible garbage value on archs which do not support atomic writes to
> >
> > >> unsigned long.
> >
> > >
> >
> > > At least I totally agree with you. Thanks for your detailed explanation.
> >
> > >
> >
> >
> >
> > Thanks everyone.  This makes sense.
> >
> >
> >
> > However, I should note that this same situation (updates to unsigned
> >
> > long variables under lock and reads of the the same variable without
> >
> > lock or READ/WRITE_ONCE) exists in hugetlb sysfs files today.  Not
> >
> > suggesting that this makes it OK to ignore the potential issue.  Just
> >
> > wanted to point this out.
> >
>
> Sorry I'm still a bit confused. READ_ONCE/WRITE_ONCE isn't documented
> to provide atomicity to the write or read, just prevents the compiler
> from re-ordering them. Is there something I'm missing, or is the
> suggestion to add READ_ONCE/WRITE_ONCE simply to supress the KCSAN
> warnings?
>

+Paul & Marco

Let's ask the experts.

We have a "unsigned long usage" variable that is updated within a lock
(hugetlb_lock) but is read without the lock.

Q1) I think KCSAN will complain about it and READ_ONCE() in the
unlocked read path should be good enough to silent KCSAN. So, the
question is should we still use WRITE_ONCE() as well for usage within
hugetlb_lock?

Q2) Second question is more about 64 bit archs breaking a 64 bit write
into two 32 bit writes. Is this a real issue? If yes, then the
combination of READ_ONCE()/WRITE_ONCE() are good enough for the given
use-case?

thanks,
Shakeel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ