<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/overlayfs/readdir.c, branch linux-4.4.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2018-09-15T07:40:41Z</updated>
<entry>
<title>ovl: proper cleanup of workdir</title>
<updated>2018-09-15T07:40:41Z</updated>
<author>
<name>Miklos Szeredi</name>
</author>
<published>2016-09-01T09:11:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=89f15c6e8212ab97dbdcaf561709357cd0b398f5'/>
<id>urn:sha1:89f15c6e8212ab97dbdcaf561709357cd0b398f5</id>
<content type='text'>
commit eea2fb4851e9dcbab6b991aaf47e2e024f1f55a0 upstream.

When mounting overlayfs it needs a clean "work" directory under the
supplied workdir.

Previously the mount code removed this directory if it already existed and
created a new one.  If the removal failed (e.g. directory was not empty)
then it fell back to a read-only mount not using the workdir.

While this has never been reported, it is possible to get a non-empty
"work" dir from a previous mount of overlayfs in case of crash in the
middle of an operation using the work directory.

In this case the left over state should be discarded and the overlay
filesystem will be consistent, guaranteed by the atomicity of operations on
moving to/from the workdir to the upper layer.

This patch implements cleaning out any files left in workdir.  It is
implemented using real recursion for simplicity, but the depth is limited
to 2, because the worst case is that of a directory containing whiteouts
under "work".

Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: SZ Lin (林上智) &lt;sz.lin@moxa.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ovl: override creds with the ones from the superblock mounter</title>
<updated>2018-09-15T07:40:41Z</updated>
<author>
<name>Antonio Murdaca</name>
</author>
<published>2016-04-07T13:48:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=121b09d30d48a59a0ae621b130f3b4e42e724e68'/>
<id>urn:sha1:121b09d30d48a59a0ae621b130f3b4e42e724e68</id>
<content type='text'>
commit 3fe6e52f062643676eb4518d68cee3bc1272091b upstream.

In user namespace the whiteout creation fails with -EPERM because the
current process isn't capable(CAP_SYS_ADMIN) when setting xattr.

A simple reproducer:

$ mkdir upper lower work merged lower/dir
$ sudo mount -t overlay overlay -olowerdir=lower,upperdir=upper,workdir=work merged
$ unshare -m -p -f -U -r bash

Now as root in the user namespace:

\# touch merged/dir/{1,2,3} # this will force a copy up of lower/dir
\# rm -fR merged/*

This ends up failing with -EPERM after the files in dir has been
correctly deleted:

unlinkat(4, "2", 0)                     = 0
unlinkat(4, "1", 0)                     = 0
unlinkat(4, "3", 0)                     = 0
close(4)                                = 0
unlinkat(AT_FDCWD, "merged/dir", AT_REMOVEDIR) = -1 EPERM (Operation not
permitted)

Interestingly, if you don't place files in merged/dir you can remove it,
meaning if upper/dir does not exist, creating the char device file works
properly in that same location.

This patch uses ovl_sb_creator_cred() to get the cred struct from the
superblock mounter and override the old cred with these new ones so that
the whiteout creation is possible because overlay is wrong in assuming that
the creds it will get with prepare_creds will be in the initial user
namespace.  The old cap_raise game is removed in favor of just overriding
the old cred struct.

This patch also drops from ovl_copy_up_one() the following two lines:

override_cred-&gt;fsuid = stat-&gt;uid;
override_cred-&gt;fsgid = stat-&gt;gid;

This is because the correct uid and gid are taken directly with the stat
struct and correctly set with ovl_set_attr().

Signed-off-by: Antonio Murdaca &lt;runcom@redhat.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Signed-off-by: SZ Lin (林上智) &lt;sz.lin@moxa.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ovl: rename is_merge to is_lowest</title>
<updated>2018-09-15T07:40:41Z</updated>
<author>
<name>Miklos Szeredi</name>
</author>
<published>2016-03-21T16:31:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6586f61ab5bb8f216d79c40a9997920c1ed01544'/>
<id>urn:sha1:6586f61ab5bb8f216d79c40a9997920c1ed01544</id>
<content type='text'>
commit 56656e960b555cb98bc414382566dcb59aae99a2 upstream.

The 'is_merge' is an historical naming from when only a single lower layer
could exist.  With the introduction of multiple lower layers the meaning of
this flag was changed to mean only the "lowest layer" (while all lower
layers were being merged).

So now 'is_merge' is inaccurate and hence renaming to 'is_lowest'

Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Signed-off-by: SZ Lin (林上智) &lt;sz.lin@moxa.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ovl: Ensure upper filesystem supports d_type</title>
<updated>2018-08-28T05:23:43Z</updated>
<author>
<name>Vivek Goyal</name>
</author>
<published>2016-02-22T14:28:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d5e678942de33a5d8545a8b7c825eb93b57be1a9'/>
<id>urn:sha1:d5e678942de33a5d8545a8b7c825eb93b57be1a9</id>
<content type='text'>
commit 45aebeaf4f67468f76bedf62923a576a519a9b68 upstream.

In some instances xfs has been created with ftype=0 and there if a file
on lower fs is removed, overlay leaves a whiteout in upper fs but that
whiteout does not get filtered out and is visible to overlayfs users.

And reason it does not get filtered out because upper filesystem does
not report file type of whiteout as DT_CHR during iterate_dir().

So it seems to be a requirement that upper filesystem support d_type for
overlayfs to work properly. Do this check during mount and fail if d_type
is not supported.

Suggested-by: Dave Chinner &lt;dchinner@redhat.com&gt;
Signed-off-by: Vivek Goyal &lt;vgoyal@redhat.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Signed-off-by: SZ Lin (林上智) &lt;sz.lin@moxa.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ovl: fix failure to fsync lower dir</title>
<updated>2018-02-16T19:09:47Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2017-11-08T07:39:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3b0104f9e21a49cd03b91c7794b3e3e6cc0bc277'/>
<id>urn:sha1:3b0104f9e21a49cd03b91c7794b3e3e6cc0bc277</id>
<content type='text'>
commit d796e77f1dd541fe34481af2eee6454688d13982 upstream.

As a writable mount, it is not expected for overlayfs to return
EINVAL/EROFS for fsync, even if dir/file is not changed.

This commit fixes the case of fsync of directory, which is easier to
address, because overlayfs already implements fsync file operation for
directories.

The problem reported by Raphael is that new PostgreSQL 10.0 with a
database in overlayfs where lower layer in squashfs fails to start.
The failure is due to fsync error, when PostgreSQL does fsync on all
existing db directories on startup and a specific directory exists
lower layer with no changes.

Reported-by: Raphael Hertzog &lt;raphael@ouaza.com&gt;
Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Tested-by: Raphaël Hertzog &lt;hertzog@debian.org&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ovl: check dentry positiveness in ovl_cleanup_whiteouts()</title>
<updated>2016-02-25T20:01:24Z</updated>
<author>
<name>Konstantin Khlebnikov</name>
</author>
<published>2015-11-16T15:44:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=367e439dbc238907963ddf2758200b55087cab04'/>
<id>urn:sha1:367e439dbc238907963ddf2758200b55087cab04</id>
<content type='text'>
commit 84889d49335627bc770b32787c1ef9ebad1da232 upstream.

This patch fixes kernel crash at removing directory which contains
whiteouts from lower layers.

Cache of directory content passed as "list" contains entries from all
layers, including whiteouts from lower layers. So, lookup in upper dir
(moved into work at this stage) will return negative entry. Plus this
cache is filled long before and we can race with external removal.

Example:
 mkdir -p lower0/dir lower1/dir upper work overlay
 touch lower0/dir/a lower0/dir/b
 mknod lower1/dir/a c 0 0
 mount -t overlay none overlay -o lowerdir=lower1:lower0,upperdir=upper,workdir=work
 rm -fr overlay/dir

Signed-off-by: Konstantin Khlebnikov &lt;khlebnikov@yandex-team.ru&gt;
Signed-off-by: Miklos Szeredi &lt;miklos@szeredi.hu&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ovl: lookup whiteouts outside iterate_dir()</title>
<updated>2015-06-22T11:53:48Z</updated>
<author>
<name>Miklos Szeredi</name>
</author>
<published>2015-06-22T11:53:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cdb672795876d7bc1870aed9a2d7cb59f43d1d96'/>
<id>urn:sha1:cdb672795876d7bc1870aed9a2d7cb59f43d1d96</id>
<content type='text'>
If jffs2 can deadlock on overlayfs readdir because it takes the same lock
on -&gt;iterate() as in -&gt;lookup().

Fix by moving whiteout checking outside iterate_dir().  Optimized by
collecting potential whiteouts (DT_CHR) in a temporary list and if
non-empty iterating throug these and checking for a 0/0 chardev.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Fixes: 49c21e1cacd7 ("ovl: check whiteout while reading directory")
Reported-by: Roman Yeryomin &lt;leroi.lists@gmail.com&gt; 
</content>
</entry>
<entry>
<title>Merge branch 'overlayfs-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs into for-next</title>
<updated>2015-02-20T09:58:52Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2015-02-20T09:58:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ce7b9facdf43b42fb95bdff9069aefeddb7d0a69'/>
<id>urn:sha1:ce7b9facdf43b42fb95bdff9069aefeddb7d0a69</id>
<content type='text'>
</content>
</entry>
<entry>
<title>ovl: discard independent cursor in readdir()</title>
<updated>2015-01-09T13:55:57Z</updated>
<author>
<name>hujianyang</name>
</author>
<published>2014-12-11T02:30:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4330397e4e8a662f36d101659e2a59ce32e76ff4'/>
<id>urn:sha1:4330397e4e8a662f36d101659e2a59ce32e76ff4</id>
<content type='text'>
Since the ovl_dir_cache is stable during a directory reading, the cursor
of struct ovl_dir_file don't need to be an independent entry in the list
of a merged directory.

This patch changes *cursor* to a pointer which points to the entry in the
ovl_dir_cache. After this, we don't need to check *is_cursor* either.

Signed-off-by: hujianyang &lt;hujianyang@huawei.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
</content>
</entry>
<entry>
<title>ovl: check whiteout on lowest layer as well</title>
<updated>2014-12-12T23:59:45Z</updated>
<author>
<name>Miklos Szeredi</name>
</author>
<published>2014-12-12T23:59:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3e01cee3b980f96463cb6f378ab05303a99903d9'/>
<id>urn:sha1:3e01cee3b980f96463cb6f378ab05303a99903d9</id>
<content type='text'>
Not checking whiteouts on lowest layer was an optimization (there's nothing
to white out there), but it could result in inconsitent behavior when a
layer previously used as upper/middle is later used as lowest. 

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
</content>
</entry>
</feed>
