All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Yao <ryao@gentoo.org>
To: Kernel development list <linux-kernel@vger.kernel.org>
Cc: linux-fsdevel@vger.kernel.org,
	"v9fs-developer@lists.sourceforge.net"
	<v9fs-developer@lists.sourceforge.net>,
	"kernel@gentoo.org" <kernel@gentoo.org>,
	Eric Van Hensbergen <ericvh@gmail.com>,
	Ron Minnich <rminnich@sandia.gov>,
	Latchesar Ionkov <lucho@ionkov.net>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: v9fs does not honor open file handles on anonymous files
Date: Tue, 31 Dec 2013 14:21:11 -0500	[thread overview]
Message-ID: <52C31927.40304@gentoo.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1573 bytes --]

I have a small shell script:

#!/bin/bash
cat <<-EOF
EOF

Running this causes bash to fork via clone(), set fd=0 to point to an
empty file in /tmp, unlink it and then execve cat. Specifically,
something like this;

[pid  3699] open("/tmp/sh-thd-1388524249",
O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0600) = 3
[pid  3699] open("/tmp/sh-thd-1388524249", O_RDONLY) = 4
[pid  3699] close(3)                    = 0
[pid  3699] unlink("/tmp/sh-thd-1388524249") = 0
[pid  3699] dup2(4, 0)                  = 0
[pid  3699] close(4)                    = 0
[pid  3699] execve("/bin/cat", ["cat"], [/* 22 vars */]) = 0

One of the first things that cat does is fstat fd=0. This informs cat
that the file is empty and it will quit. If /tmp is on other
filesystems, cat will fstat fd=0, receive a return code of 0 from fstat,
print nothing and then quit normally. If /tmp is on 9pfs, cat will fstat
fd=0, receive ENOENT from fstat, print `cat: -: No such file or
directory` to stderr and die.

It seems that v9fs_vfs_unlink() is killing the file while we still have
open file handles. I have confirmed that this behavior occurs on Linux
3.13.0-rc6. This breaks several things when Gentoo is on a 9p rootfs
(e.g. gcc-config, any emerge command that involves a C compiler,
etcetera) inside QEMU. I have placed /tmp and /var/tmp/portage on a
tmpfs as a hack-fix, but it would be better to get this fixed.

I doubt that I will write a patch to fix this. I am sending the details
to the list so the 9p maintainers or any other interested individual can
fix it.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 901 bytes --]

             reply	other threads:[~2013-12-31 19:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-31 19:21 Richard Yao [this message]
2013-12-31 19:41 ` v9fs does not honor open file handles on anonymous files Dominique Martinet
2013-12-31 19:53   ` Richard Yao

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=52C31927.40304@gentoo.org \
    --to=ryao@gentoo.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=ericvh@gmail.com \
    --cc=kernel@gentoo.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=rminnich@sandia.gov \
    --cc=v9fs-developer@lists.sourceforge.net \
    /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.