All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Miklos Szeredi <mszeredi@redhat.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	"J. Bruce Fields" <bfields@fieldses.org>,
	"linux-unionfs@vger.kernel.org" <linux-unionfs@vger.kernel.org>
Subject: Re: [PATCH 07/12] vfs: do get_write_access() on upper layer of overlayfs
Date: Wed, 19 Oct 2016 10:41:23 +0300	[thread overview]
Message-ID: <CAOQ4uxj5QxcGRMGT78qQf0vmjjP2Do8uaOX-B31HYXt-Wz3Fjg@mail.gmail.com> (raw)
In-Reply-To: <CAJfpegu8dfSzKpvA5g+jPdUXxhuQwNd=TDaH6xDR2ZYt_V6QZQ@mail.gmail.com>

On Tue, Oct 18, 2016 at 10:53 PM, Miklos Szeredi <miklos@szeredi.hu> wrote:
> On Tue, Oct 18, 2016 at 9:41 PM, Amir Goldstein <amir73il@gmail.com> wrote:
>> On Fri, Sep 16, 2016 at 3:19 PM, Miklos Szeredi <mszeredi@redhat.com> wrote:
>>> The problem with writecount is: we want consistent handling of it for
>>> underlying filesystems as well as overlayfs.  Making sure i_writecount is
>>> correct on all layers is difficult.  Instead this patch makes sure that
>>> when write access is acquired, it's always done on the underlying writable
>>> layer (called the upper layer).  We must also make sure to look at the
>>> writecount on this layer when checking for conflicting leases.
>>>
>>> Open for write already updates the upper layer's writecount.  Leaving only
>>> truncate.
>>>
>>> For truncate copy up must happen before get_write_access() so that the
>>> writecount is updated on the upper layer.  Problem with this is if
>>> something fails after that, then copy-up was done needlessly.  E.g. if
>>> break_lease() was interrupted.  Probably not a big deal in practice.
>>>
>>> Another interesting case is if there's a denywrite on a lower file that is
>>> then opened for write or truncated.  With this patch these will succeed,
>>> which is somewhat counterintuitive.  But I think it's still acceptable,
>>> considering that the copy-up does actually create a different file, so the
>>> old, denywrite mapping won't be touched.
>>
>> Miklos,
>> I think this breaks xfstest overlay/013 on v4.8, because execve() does
>> deny write on lower inode and then truncate happens on upper inode.
>
> It does break the xfstest, but as explained in the patch it shouldn't
> be a problem in practice.  I think the test should just be fixed.
>

Right. and so I did fix the test, which had a bug anyway and was not
testing exec+truncate from upper at all.

But I noticed a strange behavior:
When you run t_truncate_self from upper you get success for not being
able to truncate.
When you run t_truncate_self from lower you get an error for being
able to truncate
This is ok as you write, but...
When you re-run t_truncate_self file that just got copied-up you get
segmentation fault
and that is not ok.

You get try the patch to xfstest below to reproduce the problem:

diff --git a/tests/overlay/013 b/tests/overlay/013
index 09f3eb1..cd3d0c0 100755
--- a/tests/overlay/013
+++ b/tests/overlay/013
@@ -59,7 +59,7 @@ upperdir=$SCRATCH_DEV/$OVERLAY_UPPER_DIR
 mkdir -p $lowerdir
 mkdir -p $upperdir
 cp $here/src/t_truncate_self $lowerdir/test_lower
-cp $here/src/t_truncate_self $lowerdir/test_upper
+cp $here/src/t_truncate_self $upperdir/test_upper

 _scratch_mount

@@ -67,8 +67,9 @@ _scratch_mount
 # test programs truncate themselfs, all should fail with ETXTBSY
 $SCRATCH_MNT/test_lower
 $SCRATCH_MNT/test_upper
+# run test again after copy-up
+$SCRATCH_MNT/test_lower

 # success, all done
-echo "Silence is golden"
 status=0
 exit
diff --git a/tests/overlay/013.out b/tests/overlay/013.out
index 3e66423..a8ee7cd 100644
--- a/tests/overlay/013.out
+++ b/tests/overlay/013.out
@@ -1,2 +1,2 @@
 QA output created by 013
-Silence is golden
+truncate(argv[0]) should have failed

  reply	other threads:[~2016-10-19  7:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-16 12:19 [PATCH 00/12] misc filesystem patches for 4.9 Miklos Szeredi
2016-09-16 12:19 ` [PATCH 01/12] ima: use file_dentry() Miklos Szeredi
2016-09-16 12:19 ` [PATCH 02/12] vfs: move permission checking into notify_change() for utimes(NULL) Miklos Szeredi
2016-09-16 12:19 ` [PATCH 03/12] vfs: update ovl inode before relatime check Miklos Szeredi
2016-09-16 12:19 ` [PATCH 04/12] fsnotify: support overlayfs Miklos Szeredi
2016-09-16 16:38   ` Jan Kara
2016-09-17  6:20     ` Amir Goldstein
2016-09-16 12:19 ` [PATCH 05/12] locks: fix file locking on overlayfs Miklos Szeredi
2016-09-16 12:19 ` [PATCH 06/12] vfs: make argument of d_real_inode() const Miklos Szeredi
2016-09-16 12:19 ` [PATCH 07/12] vfs: do get_write_access() on upper layer of overlayfs Miklos Szeredi
2016-10-18 19:41   ` Amir Goldstein
2016-10-18 19:53     ` Miklos Szeredi
2016-10-19  7:41       ` Amir Goldstein [this message]
2016-10-19  8:12         ` Miklos Szeredi
2016-10-19  8:30           ` Amir Goldstein
2016-10-19  8:56             ` Amir Goldstein
2016-09-16 12:19 ` [PATCH 08/12] btrfs: use filemap_check_errors() Miklos Szeredi
2016-09-16 12:19 ` [PATCH 09/12] f2fs: " Miklos Szeredi
2016-09-16 12:19 ` [PATCH 10/12] posix_acl: don't ignore return value of posix_acl_create_masq() Miklos Szeredi
2016-09-16 12:45   ` Andreas Grünbacher
2016-09-16 12:19 ` [PATCH 11/12] cifs: don't use ->d_time Miklos Szeredi
2016-09-16 12:19 ` [PATCH 12/12] vfat: " Miklos Szeredi

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=CAOQ4uxj5QxcGRMGT78qQf0vmjjP2Do8uaOX-B31HYXt-Wz3Fjg@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=bfields@fieldses.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=mszeredi@redhat.com \
    --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.