From: Linus Torvalds <[email protected]>
To: Kees Cook <[email protected]>
Cc: Alexey Gladkov <[email protected]>,
LKML <[email protected]>,
io-uring <[email protected]>,
Kernel Hardening <[email protected]>,
Linux Containers <[email protected]>,
Linux-MM <[email protected]>, Alexey Gladkov <[email protected]>,
Andrew Morton <[email protected]>,
Christian Brauner <[email protected]>,
"Eric W . Biederman" <[email protected]>,
Jann Horn <[email protected]>, Jens Axboe <[email protected]>,
Oleg Nesterov <[email protected]>
Subject: Re: [PATCH v8 3/8] Use atomic_t for ucounts reference counting
Date: Mon, 15 Mar 2021 15:19:17 -0700 [thread overview]
Message-ID: <CAHk-=wjYOCgM+mKzwTZwkDDg12DdYjFFkmoFKYLim7NFmR9HBg@mail.gmail.com> (raw)
In-Reply-To: <202103151426.ED27141@keescook>
On Mon, Mar 15, 2021 at 3:03 PM Kees Cook <[email protected]> wrote:
>
> On Wed, Mar 10, 2021 at 01:01:28PM +0100, Alexey Gladkov wrote:
> > The current implementation of the ucounts reference counter requires the
> > use of spin_lock. We're going to use get_ucounts() in more performance
> > critical areas like a handling of RLIMIT_SIGPENDING.
>
> This really looks like it should be refcount_t.
No.
refcount_t didn't have the capabilities required.
It just saturates, and doesn't have the "don't do this" case, which
the ucounts case *DOES* have.
In other words, refcount_t is entirely misdesigned for this - because
it's literally designed for "people can't handle overflow, so we warn
and saturate".
ucounts can never saturate, because they replace saturation with
"don't do that then".
In other words, ucounts work like the page counts do (which also don't
saturate, they just say "ok, you can't get a reference".
I know you are attached to refcounts, but really: they are not only
more expensive, THEY LITERALLY DO THE WRONG THING.
Linus
next prev parent reply other threads:[~2021-03-15 22:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-10 12:01 [PATCH v8 0/8] Count rlimits in each user namespace Alexey Gladkov
2021-03-10 12:01 ` [PATCH v8 1/8] Increase size of ucounts to atomic_long_t Alexey Gladkov
2021-03-10 12:01 ` [PATCH v8 2/8] Add a reference to ucounts for each cred Alexey Gladkov
2021-03-10 12:01 ` [PATCH v8 3/8] Use atomic_t for ucounts reference counting Alexey Gladkov
2021-03-10 21:14 ` Linus Torvalds
2021-03-15 22:02 ` Kees Cook
2021-03-15 22:19 ` Linus Torvalds [this message]
2021-03-16 18:49 ` Kees Cook
2021-03-16 19:26 ` Linus Torvalds
2021-03-16 19:32 ` Kees Cook
2021-03-10 12:01 ` [PATCH v8 4/8] Reimplement RLIMIT_NPROC on top of ucounts Alexey Gladkov
2021-03-10 12:01 ` [PATCH v8 5/8] Reimplement RLIMIT_MSGQUEUE " Alexey Gladkov
2021-03-10 12:01 ` [PATCH v8 6/8] Reimplement RLIMIT_SIGPENDING " Alexey Gladkov
2021-03-10 12:01 ` [PATCH v8 7/8] Reimplement RLIMIT_MEMLOCK " Alexey Gladkov
2021-03-10 12:01 ` [PATCH v8 8/8] kselftests: Add test to check for rlimit changes in different user namespaces Alexey Gladkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHk-=wjYOCgM+mKzwTZwkDDg12DdYjFFkmoFKYLim7NFmR9HBg@mail.gmail.com' \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox