public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pasha Tatashin <pasha.tatashin@soleen.com>
To: David Matlack <dmatlack@google.com>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>,
	 linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	 Mike Rapoport <rppt@kernel.org>,
	Pratyush Yadav <pratyush@kernel.org>,
	 Samiullah Khawaja <skhawaja@google.com>
Subject: Re: [PATCH 1/2] liveupdate: Use refcount_t for FLB reference counts
Date: Thu, 23 Apr 2026 19:40:34 +0000	[thread overview]
Message-ID: <aep1XW47lQArwhv9@plex> (raw)
In-Reply-To: <CALzav=dnCp7OoHf5qS+yfzfdmZZpbvD8S2yQeXpFVWT7geR15w@mail.gmail.com>

On 04-23 11:49, David Matlack wrote:
> On Thu, Apr 23, 2026 at 11:11 AM Pasha Tatashin
> <pasha.tatashin@soleen.com> wrote:
> > On 04-23 17:40, David Matlack wrote:
> 
> > > @@ -126,8 +126,10 @@ static int luo_flb_file_preserve_one(struct liveupdate_flb *flb)
> > >                       }
> > >                       private->outgoing.data = args.data;
> > >                       private->outgoing.obj = args.obj;
> > > +                     refcount_set(&private->outgoing.count, 1);
> > > +             } else {
> > > +                     refcount_inc(&private->outgoing.count);
> > >               }
> > > -             private->outgoing.count++;
> >
> > It should be: refcount_inc(&private->outgoing.count); for both
> > cases, as it was before.
> 
> Calling refcount_inc() when the refcount is 0 triggers the
> REFCOUNT_ADD_UAF warning.

Oh you are right, sigh, in this case what you have is OK.

> 
> > Additionally, please add refcount_set(&private->outgoing.count, 0) to
> > luo_flb_get_private, where the rest of the private fields are
> > initialized.
> 
> Will do.

No need to do this...

> 
> > In general, I prefer to avoid refcount_set() because it breaks
> > continuity and makes debugging hard. It should only be used only during
> > initialization, so moving it to where the other fields are initialized
> > is the correct approach.

Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com> 

  reply	other threads:[~2026-04-23 19:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23 17:40 [PATCH 0/2] liveupdate: FLB refcounting improvements David Matlack
2026-04-23 17:40 ` [PATCH 1/2] liveupdate: Use refcount_t for FLB reference counts David Matlack
2026-04-23 18:11   ` Pasha Tatashin
2026-04-23 18:49     ` David Matlack
2026-04-23 19:40       ` Pasha Tatashin [this message]
2026-04-23 19:58   ` Samiullah Khawaja
2026-04-23 17:40 ` [PATCH 2/2] liveupdate: Reference count incoming FLB data David Matlack
2026-04-23 18:21   ` Pasha Tatashin
2026-04-23 19:46   ` Samiullah Khawaja
2026-04-23 18:13 ` [PATCH 0/2] liveupdate: FLB refcounting improvements Pasha Tatashin
2026-04-23 18:40   ` David Matlack

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=aep1XW47lQArwhv9@plex \
    --to=pasha.tatashin@soleen.com \
    --cc=akpm@linux-foundation.org \
    --cc=dmatlack@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pratyush@kernel.org \
    --cc=rppt@kernel.org \
    --cc=skhawaja@google.com \
    /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