Re: Catching use-after-free easily in linux kernel.

From: Al Viro
Date: Mon Mar 10 2025 - 20:36:03 EST


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.