[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wjtvUDbbcXw0iqAPn3dmZK+RnqVMFrU9i53HzvPtWx_vw@mail.gmail.com>
Date: Tue, 7 Dec 2021 08:13:38 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Christoph Hellwig <hch@...radead.org>,
Jens Axboe <axboe@...nel.dk>,
"linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,
Kees Cook <keescook@...omium.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] block: switch to atomic_t for request references
On Tue, Dec 7, 2021 at 5:28 AM Peter Zijlstra <peterz@...radead.org> wrote:
>
> +#define refcount_dec_and_test refcount_dec_and_test
> +static inline bool refcount_dec_and_test(refcount_t *r)
> +{
> + asm_volatile_goto (LOCK_PREFIX "decl %[var]\n\t"
> + "jz %l[cc_zero]\n\t"
> + "jl %l[cc_error]"
> + : : [var] "m" (r->refs.counter)
> + : "memory"
> + : cc_zero, cc_error);
> + return false;
> +
> +cc_zero:
> + return true;
> +
> +cc_error:
> + refcount_warn_saturate(r, REFCOUNT_SUB_UAF);
> + return false;
> +}
Please don't add broken arch-specific helpers that are useless for
anything else than the broken refcount_t use.
Make it return three return values, call it atomic_dec_and_test_ref()
or something like that, and now people can use it without having to
use a refcount_t.
Nobody really wants two different error cases anyway. The fact that
refcount_warn_saturate() has different cases is only an annoyance.
Linus
Powered by blists - more mailing lists