Re: [PATCHv2] refcount: always allow checked forms

From: Ingo Molnar
Date: Thu Jul 12 2018 - 17:35:04 EST



* Kees Cook <keescook@xxxxxxxxxxxx> wrote:

> On Thu, Jul 12, 2018 at 10:01 AM, Will Deacon <will.deacon@xxxxxxx> wrote:
> > On Wed, Jul 11, 2018 at 10:36:07AM +0100, Mark Rutland wrote:
> >> In many cases, it would be useful to be able to use the full
> >> sanity-checked refcount helpers regardless of CONFIG_REFCOUNT_FULL, as
> >> this would help to avoid duplicate warnings where callers try to
> >> sanity-check refcount manipulation.
> >>
> >> This patch refactors things such that the full refcount helpers were
> >> always built, as refcount_${op}_checked(), such that they can be used
> >> regardless of CONFIG_REFCOUNT_FULL. This will allow code which *always*
> >> wants a checked refcount to opt-in, avoiding the need to duplicate the
> >> logic for warnings.
> >>
> >> There should be no functional change as a result of this patch.
> >>
> >> Signed-off-by: Mark Rutland <mark.rutland@xxxxxxx>
> >> Acked-by: Kees Cook <keescook@xxxxxxxxxxxx>
> >> Reviewed-by: David Sterba <dsterba@xxxxxxxx>
> >> Cc: Boqun Feng <boqun.feng@xxxxxxxxx>
> >> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> >> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> >> Cc: Will Deacon <will.deacon@xxxxxxx>
> >> ---
> >> include/linux/refcount.h | 27 +++++++++++++++++-------
> >> lib/refcount.c | 53 +++++++++++++++++++++++-------------------------
> >> 2 files changed, 45 insertions(+), 35 deletions(-)
> >
> > Looks good to me:
> >
> > Acked-by: Will Deacon <will.deacon@xxxxxxx>
>
> Peter, Ingo, can this go via the atomics tree? That's been the
> traditional location for the refcount patches.

Sure, will have a look tomorrow!

Ingo