[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFf+5zjA8aXGi=6_L9T_uP_2nG9ced80KLeMXtbB1UC4y+4ijA@mail.gmail.com>
Date: Tue, 11 Mar 2025 10:23:26 +0530
From: Amit <amitchoudhary0523@...il.com>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: linux-kernel@...r.kernel.org
Subject: Re: Catching use-after-free easily in linux kernel.
On Tue, 11 Mar 2025 at 10:12, Al Viro <viro@...iv.linux.org.uk> wrote:
>
> 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...
If I don't find any kernel crashes then it's fine. But I will do the
experiment to check whether I am right or wrong. Theoretical
discussion about whether the kernel will crash or not in my experiment
won't be much useful probably.
----
Powered by blists - more mailing lists