[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250311044231.GO2023217@ZenIV>
Date: Tue, 11 Mar 2025 04:42:31 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Amit <amitchoudhary0523@...il.com>
Cc: linux-kernel@...r.kernel.org
Subject: Re: Catching use-after-free easily in linux kernel.
On Tue, Mar 11, 2025 at 08:46:36AM +0530, Amit wrote:
> On Tue, Mar 11, 2025, 6:05 AM Al Viro <viro@...iv.linux.org.uk> wrote:
>
> > On Mon, Mar 10, 2025 at 01:24:54PM +0530, Amit wrote:
> > > Hi,
> > >
> > > We can catch use-after-free easily if we do the following:
> > >
> > > kfree(x);
> > > (x) = NULL;
> > >
> > > Now, if someone uses 'x' again then the kernel will crash and we will
> > know where
> > > the use-after-free is happening and then we can fix it.
> >
> > That assumes that no pointer is ever stored in more than one place.
> > Which is very clearly false.
> >
>
>
> I will do some experiments and then I will reply if I find something.
>
> I will introduce a global macro and then change all kfree() to this macro
> name using cscope probably.
>
> Then I will compile the kernel and run the new kernel and see if some crash
> is happening or not.
What would that test, exactly? And why would that be any more useful than
adding global variables named wank and magic and replacing every kfree(p) with
((magic = wank++),kfree(p))? That also would not introduce any crashes...
Powered by blists - more mailing lists