From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: linux-xfs@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] iomap: Fix overflow in iomap_page_mkwrite
Date: Wed, 6 Nov 2019 11:16:56 -0800 [thread overview]
Message-ID: <20191106191656.GC15212@magnolia> (raw)
In-Reply-To: <20191106190400.20969-1-agruenba@redhat.com>
On Wed, Nov 06, 2019 at 08:04:00PM +0100, Andreas Gruenbacher wrote:
> On architectures where ssize_t is wider than pgoff_t, the expression
ssize_t? But you're changing @offset, which is loff_t. I'm confused.
Also, which architectures are you talking about here?
--D
> ((page->index + 1) << PAGE_SHIFT) can overflow. Rewrite to use the page
> offset, which we already compute here anyway.
>
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
> fs/iomap/buffered-io.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index e25901ae3ff4..a30ea7ecb790 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -1040,20 +1040,19 @@ vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops)
>
> lock_page(page);
> size = i_size_read(inode);
> - if ((page->mapping != inode->i_mapping) ||
> - (page_offset(page) > size)) {
> + offset = page_offset(page);
> + if (page->mapping != inode->i_mapping || offset > size) {
> /* We overload EFAULT to mean page got truncated */
> ret = -EFAULT;
> goto out_unlock;
> }
>
> /* page is wholly or partially inside EOF */
> - if (((page->index + 1) << PAGE_SHIFT) > size)
> + if (offset > size - PAGE_SIZE)
> length = offset_in_page(size);
> else
> length = PAGE_SIZE;
>
> - offset = page_offset(page);
> while (length > 0) {
> ret = iomap_apply(inode, offset, length,
> IOMAP_WRITE | IOMAP_FAULT, ops, page,
> --
> 2.20.1
>
next prev parent reply other threads:[~2019-11-06 19:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-06 19:04 [PATCH] iomap: Fix overflow in iomap_page_mkwrite Andreas Gruenbacher
2019-11-06 19:16 ` Darrick J. Wong [this message]
2019-11-06 19:34 ` Andreas Gruenbacher
2019-11-07 15:37 ` Darrick J. Wong
2019-11-07 17:54 ` Andreas Gruenbacher
2019-11-07 8:44 ` Christoph Hellwig
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=20191106191656.GC15212@magnolia \
--to=darrick.wong@oracle.com \
--cc=agruenba@redhat.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.