From: Matthew Bobrowski <mbobrowski@mbobrowski.org>
To: David Howells <dhowells@redhat.com>
Cc: jack@suse.cz, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: Is ext4_dio_read_iter() broken?
Date: Thu, 12 Mar 2020 21:20:02 +1100 [thread overview]
Message-ID: <20200312102002.GA6585@athena.bobrowski.net> (raw)
In-Reply-To: <969260.1584004779@warthog.procyon.org.uk>
On Thu, Mar 12, 2020 at 09:19:39AM +0000, David Howells wrote:
> Hi Matthew,
>
> Is ext4_dio_read_iter() broken? It calls:
>
> file_accessed(iocb->ki_filp);
>
> at the end of the function - but surely iocb should be expected to have been
> freed when iocb->ki_complete() was called?
>
> In my cachefiles rewrite, I'm seeing the attached kasan dump. The offending
> RIP, ext4_file_read_iter+0x12b is at the above line, where it is trying to
> read iocb->ki_filp.
>
> Here's an excerpt of the relevant bits from my code:
>
> static void cachefiles_read_complete(struct kiocb *iocb, long ret, long ret2)
> {
> struct cachefiles_kiocb *ki =
> container_of(iocb, struct cachefiles_kiocb, iocb);
> struct fscache_io_request *req = ki->req;
> ...
> fput(ki->iocb.ki_filp);
> kfree(ki);
> fscache_end_io_operation(req->cookie);
> ...
> }
I'm not exactly sure what you're rewriting, although from this excerpt
the way that this is implemented would sure cause the UAF in
ext4_dio_read_iter().
I don't forsee any issues with calling file_accessed(iocb->ki_filp);
prior to calling into the iomap infrastructure, unless I'm totally
missing something obvious...
/M
next prev parent reply other threads:[~2020-03-12 10:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-12 9:19 Is ext4_dio_read_iter() broken? David Howells
2020-03-12 10:07 ` Is ext4_dio_read_iter() broken? - and xfs_file_dio_aio_read() David Howells
2020-03-12 10:42 ` Christoph Hellwig
2020-03-12 10:49 ` David Howells
2020-03-12 10:53 ` Christoph Hellwig
2020-03-12 10:20 ` Matthew Bobrowski [this message]
2020-03-12 10:26 ` btrfs may be broken too - Re: Is ext4_dio_read_iter() broken? David Howells
2020-03-12 23:23 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200312102002.GA6585@athena.bobrowski.net \
--to=mbobrowski@mbobrowski.org \
--cc=dhowells@redhat.com \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).