Re: [PATCH v2] aio: Add support for the POLLFREE
From: Ramji Jiyani <hidden>
Date: 2021-10-06 22:36:30
Also in:
linux-arch, linux-fsdevel, lkml
On Wed, Oct 6, 2021 at 2:16 PM Eric Biggers [off-list ref] wrote:
On Wed, Oct 06, 2021 at 07:50:29PM +0000, Ramji Jiyani wrote:quoted
Commit f5cb779ba163 ("ANDROID: binder: remove waitqueue when thread exits.") fixed the use-after-free in eventpoll but aio still has the same issue because it doesn't honor the POLLFREE flag. Add support for the POLLFREE flag to force complete iocb inline in aio_poll_wake(). A thread may use it to signal it's exit and/or request to cleanup while pending poll request. In this case, aio_poll_wake() needs to make sure it doesn't keep any reference to the queue entry before returning from wake to avoid possible use after free via poll_cancel() path. The POLLFREE flag is no more exclusive to the epoll and is being shared with the aio. Remove comment from poll.h to avoid confusion. This fixes a use after free issue between binder thread and aio interactions in certain sequence of events [1]. [1] https://lore.kernel.org/all/CAKUd0B_TCXRY4h1hTztfwWbNSFQqsudDLn2S_28csgWZmZAG3Q@mail.gmail.com/ (local) Signed-off-by: Ramji Jiyani <redacted> Reviewed-by: Jeff Moyer <redacted>Can you add Fixes and Cc stable tags to ensure that this fix gets backported? Please refer to Documentation/process/submitting-patches.rst. - Eric
Thanks Eric. I'll send v3 with these changes soon. ~ Ramji