Re: [PATCH v4 2/4] mm,page_owner: Fix refcount imbalance

Oscar Salvador
2024-05-06T15:41:39Z

On Mon, May 06, 2024 at 07:59:11AM -0700, Kees Cook wrote:
> Does this also fix this?
> https://lore.kernel.org/all/202405061514.23fedba1-oliver.sang@intel.com/

Hi Kess,

yes, it does.

>
> This is a report of the backtrace changing, but the warning was
> pre-existing.
>
> > [...]
> > -static void dec_stack_record_count(depot_stack_handle_t handle)
> > +static void dec_stack_record_count(depot_stack_handle_t handle,
> > + int nr_base_pages)
> > {
> > struct stack_record *stack_record = __stack_depot_get_stack_record(handle);
> >
> > - if (stack_record)
> > - refcount_dec(&stack_record->count);
> > + if (!stack_record)
> > + return;
> > +
> > + if (refcount_sub_and_test(nr_base_pages, &stack_record->count))
> > + pr_warn("%s: refcount went to 0 for %u handle\n", __func__,
> > + handle);
>
> This pr_warn() isn't needed: refcount will very loudly say the same
> thing. :)

Yes, but I wanted to get the handle so I can match it with the
backtrace.

Thanks

--
Oscar Salvador
SUSE Labs