Re: [PATCH] fs/aio: fix uaf in sys_io_cancel

From: Benjamin LaHaise
Date: Mon Mar 04 2024 - 13:02:32 EST


On Mon, Mar 04, 2024 at 09:58:37AM -0800, Bart Van Assche wrote:
> On 3/4/24 09:47, Benjamin LaHaise wrote:
> >On Mon, Mar 04, 2024 at 09:40:35AM -0800, Bart Van Assche wrote:
> >>On 3/4/24 09:31, Benjamin LaHaise wrote:
> >>>A revert is justified when a series of patches is buggy and had
> >>>insufficient review prior to merging.
> >>
> >>That's not how Linux kernel development works. If a bug can get fixed
> >>easily, a fix is preferred instead of reverting + reapplying a patch.
> >
> >Your original "fix" is not right, and it wasn't properly tested. Commit
> >54cbc058d86beca3515c994039b5c0f0a34f53dd needs to be reverted.
>
> As I explained before, the above reply is not sufficiently detailed to
> motivate a revert.

You have introduced a use-after-free. You have not corrected the
underlying cause of that use-after-free.

Once you call ->ki_cancel(), you can't touch the kiocb. The call into
->ki_cancel() can result in a subsequent aio_complete() happening on that
kiocb. Your change is wrong, your "fix" is wrong, and you are refusing to
understand *why* your change was wrong in the first place.

You haven't even given me a test case justifying your change. You need to
justify your change to the maintainer, not the other way around.

Revert 54cbc058d86beca3515c994039b5c0f0a34f53dd and the problem goes away.

-ben

> Bart.
>

--
"Thought is the essence of where you are now."