From: Seth Forshee <seth.forshee@canonical.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-kernel@vger.kernel.org, fuse-devel@lists.sourceforge.net,
lxc-devel@lists.linuxcontainers.org,
"Eric W. Biederman" <ebiederm@xmission.com>,
Serge Hallyn <serge.hallyn@ubuntu.com>,
"Michael H. Warfield" <mhw@WittsEnd.com>,
Seth Forshee <seth.forshee@canonical.com>
Subject: [PATCH 1/3] fuse/dev: Fix unbalanced calls to kunmap_atomic() during splice I/O
Date: Mon, 14 Jul 2014 14:18:14 -0500 [thread overview]
Message-ID: <1405365496-58404-2-git-send-email-seth.forshee@canonical.com> (raw)
In-Reply-To: <1405365496-58404-1-git-send-email-seth.forshee@canonical.com>
fuse_copy_finish() assumes that mapaddr in fuse_copy_state refers
to a valid mapping if currbuf is non-NULL, but this isn't always
true when moving pages for splice I/O. This results in an
unbalanced call to kunmap_atomic() and thus an unbalanced
decrement of the preempt count. Avoid this by checking that
mapaddr is non-NULL before calling kunmap_atomic().
This can be reproduced easily with fusexmp_fh:
$ mkdir data mount
$ dd if=/dev/urandom of=data/rand.bin bs=1M count=1
$ fusexmp_fh -omodules=subdir,subdir=$PWD/data,splice_write,splice_move mount
$ cat mount/rand.bin >/dev/null
The bug has existed in its current form since 58bda1da4
"fuse/dev: use atomic maps" and fbb32750a "pipe: kill ->map()
and ->unmap()" converted all unmaps to kunmap_atomic() in 3.15.
The fundamental problem of unmapping a page which hasn't been
mapped goes back farther, probably to ce534fb05 "fuse: allow
splice to move pages," but likely with a different impact.
Cc: <stable@vger.kernel.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
fs/fuse/dev.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 098f97bdcf1b..219d1e685183 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -666,12 +666,10 @@ static void fuse_copy_finish(struct fuse_copy_state *cs)
if (cs->currbuf) {
struct pipe_buffer *buf = cs->currbuf;
- if (!cs->write) {
- kunmap_atomic(cs->mapaddr);
- } else {
+ if (cs->mapaddr)
kunmap_atomic(cs->mapaddr);
+ if (cs->write)
buf->len = PAGE_SIZE - cs->len;
- }
cs->currbuf = NULL;
cs->mapaddr = NULL;
} else if (cs->mapaddr) {
--
1.9.1
next prev parent reply other threads:[~2014-07-14 19:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-14 19:18 [PATCH 0/3] fuse: Allow mounts in containers Seth Forshee
2014-07-14 19:18 ` Seth Forshee [this message]
2014-07-18 15:21 ` [PATCH 1/3] fuse/dev: Fix unbalanced calls to kunmap_atomic() during splice I/O Miklos Szeredi
2014-07-21 12:18 ` Seth Forshee
2014-07-14 19:18 ` [PATCH 2/3] fuse: Translate pid making a request into the server's pid namespace Seth Forshee
2014-07-18 15:29 ` Miklos Szeredi
2014-07-14 19:18 ` [PATCH 3/3] fuse: Allow mounts from user namespaces Seth Forshee
2014-07-18 15:33 ` Miklos Szeredi
2014-07-21 12:47 ` Seth Forshee
2014-07-21 13:09 ` Miklos Szeredi
2014-07-21 14:34 ` Seth Forshee
2014-07-21 18:02 ` Eric W. Biederman
2014-07-22 3:30 ` Seth Forshee
2014-07-25 19:46 ` Seth Forshee
2014-07-26 16:27 ` Miklos Szeredi
2014-08-15 13:15 ` Seth Forshee
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=1405365496-58404-2-git-send-email-seth.forshee@canonical.com \
--to=seth.forshee@canonical.com \
--cc=ebiederm@xmission.com \
--cc=fuse-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lxc-devel@lists.linuxcontainers.org \
--cc=mhw@WittsEnd.com \
--cc=miklos@szeredi.hu \
--cc=serge.hallyn@ubuntu.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
all inboxes | Powered by JetHome®