[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z-7JbPeMlnpspKM_@smile.fi.intel.com>
Date: Thu, 3 Apr 2025 20:46:20 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: Kees Cook <kees@...nel.org>, Vlastimil Babka <vbabka@...e.cz>,
Przemek Kitszel <przemyslaw.kitszel@...el.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
torvalds@...ux-foundation.org, peterz@...radead.org,
Jann Horn <jannh@...gle.com>, intel-wired-lan@...ts.osuosl.org,
netdev@...r.kernel.org, Harry Yoo <harry.yoo@...cle.com>,
Christoph Lameter <cl@...two.org>
Subject: Re: [RFC] slab: introduce auto_kfree macro
On Thu, Apr 03, 2025 at 06:35:39PM +0100, Matthew Wilcox wrote:
> On Thu, Apr 03, 2025 at 09:59:41AM -0700, Kees Cook wrote:
> > On Wed, Apr 02, 2025 at 12:44:50PM +0200, Vlastimil Babka wrote:
> > > Cc Kees and others from his related efforts:
> > >
> > > https://lore.kernel.org/all/20250321202620.work.175-kees@kernel.org/
> >
> > I think, unfortunately, the consensus is that "invisible side-effects"
> > are not going to be tolerated. After I finish with kmalloc_obj(), I'd
> > like to take another run at this for basically providing something like:
> >
> > static inline __must_check
> > void *kfree(void *p) { __kfree(p); return NULL; }
> >
> > And then switch all:
> >
> > kfree(s->ptr);
> >
> > to
> >
> > s->ptr = kfree(s->ptr);
> >
> > Where s->ptr isn't used again.
>
> Umm ... kfree is now going to be __must_check? That's a lot of churn.
>
> I'd just go with making kfree() return NULL and leave off the
> __must_check. It doesn't need the __kfree() indirection either.
> That lets individual functions opt into the new safety.
Maybe something like
void kfree_and_null(void **ptr)
{
__kfree(*ptr);
*ptr = NULL;
}
?
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists