Linux Overlay Filesystem development
 help / color / mirror / Atom feed
From: Vincent Bernat <bernat@luffy.cx>
To: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ron Minnich <rminnich@sandia.gov>,
	Latchesar Ionkov <lucho@ionkov.net>,
	v9fs-developer@lists.sourceforge.net,
	Miklos Szeredi <miklos@szeredi.hu>,
	linux-unionfs@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: 9p/overlayfs: read error when reading an empty file
Date: Sat, 15 Aug 2015 13:57:41 +0200	[thread overview]
Message-ID: <87bne8ix1m.fsf@zoro.exoscale.ch> (raw)
In-Reply-To: <87fv3kiywt.fsf@zoro.exoscale.ch> (Vincent Bernat's message of "Sat, 15 Aug 2015 13:17:22 +0200")

 ❦ 15 août 2015 13:17 +0200, Vincent Bernat <bernat@luffy.cx> :

>> I have found a regression which was introduced after 4.0 in
>> 9p/overlayfs. This regression happens when the lower directory is a 9p
>> mount, the upperdir is an empty tmpfs and we try to read 0 bytes from an
>> empty file (something than gcc is doing when trying to read an include).
>>
>> The following program can be used to trigger the problem:
>>
>> #v+
>> #include <assert.h>
>> #include <sys/types.h>
>> #include <sys/stat.h>
>> #include <fcntl.h>
>> #include <unistd.h>
>>
>> int main(int argc, const char **argv)
>> {
>>     assert(argc == 2);
>>     char buffer[256];
>>     int fd = open(argv[1], O_RDONLY|O_NOCTTY);
>>     assert(fd >= 0);
>>     assert(read(fd, buffer, 0) == 0);
>>     return 0;
>> }
>> #v-
>>
>> read() returns -30720.
>>
>> This works fine with a 4.0 kernel and breaks with a 4.1 kernel.
>
> It took me some time to bissect this one because I also run into an
> infinite loop caused by 070b36 and fixed by 8e3c50. Finally, the culprit
> for the above bug seems to be:
>
> commit e494b6b5e1034db00571c44e089e6fe3845b6e8c
> Author: Al Viro <viro@zeniv.linux.org.uk>
> Date:   Wed Apr 1 23:59:57 2015 -0400
>
>     9p: switch to ->read_iter/->write_iter
>
>     Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
>
>
> This commit + 8e3c50 triggers the bug. This commit~1 + 8e3c50
> doesn't. Unfortunately, it is far too extensive to try to revert it on
> top of 4.1.

After some more testing, I discovered that this bug also happens without
overlayfs (despite what I said in the first post). The fix is in fact
pretty easy (ret should be initialized to 0 in v9fs_file_read_iter). I
am sending a proper patch in a minute.
-- 
ROMEO:		Courage, man; the hurt cannot be much.
MERCUTIO:	No, 'tis not so deep as a well, nor so wide
			as a church-door; but 'tis enough, 'twill serve.

  reply	other threads:[~2015-08-15 11:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-15  7:37 9p/overlayfs: read error when reading an empty file Vincent Bernat
2015-08-15 11:17 ` Vincent Bernat
2015-08-15 11:57   ` Vincent Bernat [this message]
2015-08-15 13:18 ` Vincent Bernat
2015-08-17 14:11   ` [V9fs-developer] " Dominique Martinet
2015-10-03 17:07     ` Vincent Bernat
2015-10-03 19:19       ` Dominique Martinet
2015-10-12 17:14         ` Miklos Szeredi
2015-10-12 17:47           ` [V9fs-developer] 9p/overlayfs: what inodes/dentries are safe to use? Dominique Martinet
2015-10-13  3:33             ` Miklos Szeredi
2015-10-13 13:10               ` Eric Van Hensbergen

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=87bne8ix1m.fsf@zoro.exoscale.ch \
    --to=bernat@luffy.cx \
    --cc=ericvh@gmail.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=miklos@szeredi.hu \
    --cc=rminnich@sandia.gov \
    --cc=v9fs-developer@lists.sourceforge.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox