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: <CAHk-=wicxUkovFa7D0YyhSweMVbL47VDimr-nytxr93SbgV9oQ@mail.gmail.com>
Date:   Mon, 13 Dec 2021 10:24:45 -0800
From:   Linus Torvalds <torvalds@...ux-foundation.org>
To:     Marco Elver <elver@...gle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Will Deacon <will@...nel.org>,
        Boqun Feng <boqun.feng@...il.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        "the arch/x86 maintainers" <x86@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Kees Cook <keescook@...omium.org>,
        Christoph Hellwig <hch@...radead.org>,
        Jens Axboe <axboe@...nel.dk>
Subject: Re: [PATCH v2 8/9] atomic,x86: Alternative atomic_*_overflow() scheme

On Mon, Dec 13, 2021 at 10:19 AM Marco Elver <elver@...gle.com> wrote:
>
> I'm still genuinely worried about this:
>
> >       2. Yet another potentially larger issue is if some code
> >          kmalloc()s some structs containing refcount_t, and relies on
> >          GFP_ZERO (kzalloc()) to initialize their data assuming that a
> >          freshly initialized refcount_t contains 0.
>
> Even with everything properly wrapped up in atomic_ref_t, it's not going
> to prevent mis-initialization via kzalloc() and friends.

I agree that it's an issue, but it's not a new issue. We've had the
exact same thing with a lot of other core data structures.

And a ref-count of zero isn't valid _anyway_. When you allocate a
structure, a zero ref-count by definition is wrong. You need to set
the ref-count to the user that allocated it.

So I don't actually think the "implicit zero" is an issue in practice,
because it would be wrong in the first place. Code that relies on
kzmalloc() to initialize a refcount cannot work right.

(And by "cannot" I obviously mean "can, if you do wrong things" - it's
not like it's *impossible* to do an "atomic_inc_ref()" to change a 0
refcount to a 1, but it's both wrong *AND* actively stupid, since an
allocation does not need to set the refcount atomically).

             Linus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ