From: Nick Piggin <npiggin@suse.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org, cmm@us.ibm.com,
Badari Pulavarty <pbadari@gmail.com>,
Dmitriy Monakhov <dmonakhov@sw.ru>,
mark.fasheh@oracle.com
Subject: [patch 2/8] 2.6.22-rc4-mm2 buffered write fixes
Date: Thu, 14 Jun 2007 04:35:43 +0200 [thread overview]
Message-ID: <20070614023543.GB30943@wotan.suse.de> (raw)
In-Reply-To: <20070614023444.GA30943@wotan.suse.de>
Dmitriy noticed that iov_iter_fault_in_readable could go past the end
of the first iov in a multi-iov situation, and that could be considered
an EFAULT by the caller. Fix and comment.
Fixes: fs-introduce-write_begin-write_end-and-perform_write-aops.patch
Signed-off-by: Nick Piggin <npiggin@suse.de>
Index: linux-2.6/mm/filemap.c
===================================================================
--- linux-2.6.orig/mm/filemap.c
+++ linux-2.6/mm/filemap.c
@@ -1794,9 +1794,19 @@ void iov_iter_advance(struct iov_iter *i
i->count -= bytes;
}
+/*
+ * Fault in the first iovec of the given iov_iter, to a maximum length
+ * of bytes. Returns 0 on success, or non-zero if the memory could not be
+ * accessed (ie. because it is an invalid address).
+ *
+ * writev-intensive code may want this to prefault several iovecs -- that
+ * would be possible (callers must not rely on the fact that _only_ the
+ * first iovec will be faulted with the current implementation).
+ */
int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes)
{
char __user *buf = i->iov->iov_base + i->iov_offset;
+ bytes = min(bytes, i->iov->iov_len - i->iov_offset);
return fault_in_pages_readable(buf, bytes);
}
next prev parent reply other threads:[~2007-06-14 2:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-14 2:34 [patch 1/8] 2.6.22-rc4-mm2 buffered write fixes Nick Piggin
2007-06-14 2:35 ` Nick Piggin [this message]
2007-06-14 2:36 ` [patch 3/8] " Nick Piggin
2007-06-14 2:37 ` [patch 4/8] " Nick Piggin
2007-06-14 2:39 ` [patch 4/8] minix: convert to new aops fix Nick Piggin
2007-06-14 2:40 ` [patch 6/8] sysv: " Nick Piggin
2007-06-14 2:41 ` [patch 7/8] ufs: " Nick Piggin
2007-06-14 2:42 ` [patch 8/8] reiser4: fix for new aops patches Nick Piggin
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=20070614023543.GB30943@wotan.suse.de \
--to=npiggin@suse.de \
--cc=akpm@linux-foundation.org \
--cc=cmm@us.ibm.com \
--cc=dmonakhov@sw.ru \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mark.fasheh@oracle.com \
--cc=pbadari@gmail.com \
/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).