<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/overlayfs/super.c, branch linux-6.5.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.5.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.5.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2023-11-28T17:15:06Z</updated>
<entry>
<title>ima: detect changes to the backing overlay file</title>
<updated>2023-11-28T17:15:06Z</updated>
<author>
<name>Mimi Zohar</name>
</author>
<published>2023-10-18T18:47:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0d29174959bc829db091f09505ec7981cb8a7717'/>
<id>urn:sha1:0d29174959bc829db091f09505ec7981cb8a7717</id>
<content type='text'>
commit b836c4d29f2744200b2af41e14bf50758dddc818 upstream.

Commit 18b44bc5a672 ("ovl: Always reevaluate the file signature for
IMA") forced signature re-evaulation on every file access.

Instead of always re-evaluating the file's integrity, detect a change
to the backing file, by comparing the cached file metadata with the
backing file's metadata.  Verifying just the i_version has not changed
is insufficient.  In addition save and compare the i_ino and s_dev
as well.

Reviewed-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Tested-by: Eric Snowberg &lt;eric.snowberg@oracle.com&gt;
Tested-by: Raul E Rangel &lt;rrangel@chromium.org&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Mimi Zohar &lt;zohar@linux.ibm.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>ovl: make use of -&gt;layers safe in rcu pathwalk</title>
<updated>2023-10-19T21:11:08Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2023-10-02T11:21:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a8187a9ca2530372da49e5001bcfe2fc83b5dd95'/>
<id>urn:sha1:a8187a9ca2530372da49e5001bcfe2fc83b5dd95</id>
<content type='text'>
[ Upstream commit a535116d80339dbfe50b9b81b2f808c69eefbbc3 ]

ovl_permission() accesses -&gt;layers[...].mnt; we can't have -&gt;layers
freed without an RCU delay on fs shutdown.

Fortunately, kern_unmount_array() that is used to drop those mounts
does include an RCU delay, so freeing is delayed; unfortunately, the
array passed to kern_unmount_array() is formed by mangling -&gt;layers
contents and that happens without any delays.

The -&gt;layers[...].name string entries are used to store the strings to
display in "lowerdir=..." by ovl_show_options().  Those entries are not
accessed in RCU walk.

Move the name strings into a separate array ofs-&gt;config.lowerdirs and
reuse the ofs-&gt;config.lowerdirs array as the temporary mount array to
pass to kern_unmount_array().

Reported-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Link: https://lore.kernel.org/r/20231002023711.GP3389589@ZenIV/
Acked-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Stable-dep-of: 32db51070850 ("ovl: fix regression in showing lowerdir mount option")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>ovl: fetch inode once in ovl_dentry_revalidate_common()</title>
<updated>2023-10-10T20:03:02Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2023-10-02T02:36:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c7f31ffe34797671faf2503b4dee1df4df8eb68d'/>
<id>urn:sha1:c7f31ffe34797671faf2503b4dee1df4df8eb68d</id>
<content type='text'>
[ Upstream commit c54719c92aa3129f330cce81b88cf34f1627f756 ]

d_inode_rcu() is right - we might be in rcu pathwalk;
however, OVL_E() hides plain d_inode() on the same dentry...

Fixes: a6ff2bc0be17 ("ovl: use OVL_E() and OVL_E_FLAGS() accessors")
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>ovl: move freeing ovl_entry past rcu delay</title>
<updated>2023-10-10T20:03:02Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2023-10-02T02:36:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9f5f1de1a6b528bb0d36002fe94f487419bf4d2e'/>
<id>urn:sha1:9f5f1de1a6b528bb0d36002fe94f487419bf4d2e</id>
<content type='text'>
[ Upstream commit d9e8319a6e3538b430f692b5625a76ffa0758adc ]

... into -&gt;free_inode(), that is.

Fixes: 0af950f57fef "ovl: move ovl_entry into ovl_inode"
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>ovl: Always reevaluate the file signature for IMA</title>
<updated>2023-07-25T22:36:22Z</updated>
<author>
<name>Eric Snowberg</name>
</author>
<published>2023-07-25T21:56:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=18b44bc5a67275641fb26f2c54ba7eef80ac5950'/>
<id>urn:sha1:18b44bc5a67275641fb26f2c54ba7eef80ac5950</id>
<content type='text'>
Commit db1d1e8b9867 ("IMA: use vfs_getattr_nosec to get the i_version")
partially closed an IMA integrity issue when directly modifying a file
on the lower filesystem.  If the overlay file is first opened by a user
and later the lower backing file is modified by root, but the extended
attribute is NOT updated, the signature validation succeeds with the old
original signature.

Update the super_block s_iflags to SB_I_IMA_UNVERIFIABLE_SIGNATURE to
force signature reevaluation on every file access until a fine grained
solution can be found.

Signed-off-by: Eric Snowberg &lt;eric.snowberg@oracle.com&gt;
Signed-off-by: Mimi Zohar &lt;zohar@linux.ibm.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>ovl: move all parameter handling into params.{c,h}</title>
<updated>2023-07-03T13:08:17Z</updated>
<author>
<name>Christian Brauner</name>
</author>
<published>2023-06-26T10:23:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7fb7998b599a2e1f3744fbd34a3e7145da841ed1'/>
<id>urn:sha1:7fb7998b599a2e1f3744fbd34a3e7145da841ed1</id>
<content type='text'>
While initially I thought that we couldn't move all new mount api
handling into params.{c,h} it turns out it is possible. So this just
moves a good chunk of code out of super.c and into params.{c,h}.

Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
</content>
</entry>
<entry>
<title>ovl: reserve ability to reconfigure mount options with new mount api</title>
<updated>2023-06-20T15:28:07Z</updated>
<author>
<name>Christian Brauner</name>
</author>
<published>2023-06-20T11:42:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ceecc2d87f007f9fc34e847401282111c0c29786'/>
<id>urn:sha1:ceecc2d87f007f9fc34e847401282111c0c29786</id>
<content type='text'>
Using the old mount api to remount an overlayfs superblock via
mount(MS_REMOUNT) all mount options will be silently ignored. For
example, if you create an overlayfs mount:

        mount -t overlay overlay -o lowerdir=/mnt/a:/mnt/b,upperdir=/mnt/upper,workdir=/mnt/work /mnt/merged

and then issue a remount via:

        # force mount(8) to use mount(2)
        export LIBMOUNT_FORCE_MOUNT2=always
        mount -t overlay overlay -o remount,WOOTWOOT,lowerdir=/DOESNT-EXIST /mnt/merged

with completely nonsensical mount options whatsoever it will succeed
nonetheless. This prevents us from every changing any mount options we
might introduce in the future that could reasonably be changed during a
remount.

We don't need to carry this issue into the new mount api port. Similar
to FUSE we can use the fs_context::oldapi member to figure out that this
is a request coming through the legacy mount api. If we detect it we
continue silently ignoring all mount options.

But for the new mount api we simply report that mount options cannot
currently be changed. This will allow us to potentially alter mount
properties for new or even old properties. It any case, silently
ignoring everything is not something new apis should do.

Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
</content>
</entry>
<entry>
<title>ovl: modify layer parameter parsing</title>
<updated>2023-06-20T11:10:40Z</updated>
<author>
<name>Christian Brauner</name>
</author>
<published>2023-06-16T13:54:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b36a5780cb44a16d4384639740d87e08d4cee627'/>
<id>urn:sha1:b36a5780cb44a16d4384639740d87e08d4cee627</id>
<content type='text'>
We ran into issues where mount(8) passed multiple lower layers as one
big string through fsconfig(). But the fsconfig() FSCONFIG_SET_STRING
option is limited to 256 bytes in strndup_user(). While this would be
fixable by extending the fsconfig() buffer I'd rather encourage users to
append layers via multiple fsconfig() calls as the interface allows
nicely for this. This has also been requested as a feature before.

With this port to the new mount api the following will be possible:

        fsconfig(fs_fd, FSCONFIG_SET_STRING, "lowerdir", "/lower1", 0);

        /* set upper layer */
        fsconfig(fs_fd, FSCONFIG_SET_STRING, "upperdir", "/upper", 0);

        /* append "/lower2", "/lower3", and "/lower4" */
        fsconfig(fs_fd, FSCONFIG_SET_STRING, "lowerdir", ":/lower2:/lower3:/lower4", 0);

        /* turn index feature on */
        fsconfig(fs_fd, FSCONFIG_SET_STRING, "index", "on", 0);

        /* append "/lower5" */
        fsconfig(fs_fd, FSCONFIG_SET_STRING, "lowerdir", ":/lower5", 0);

Specifying ':' would have been rejected so this isn't a regression. And
we can't simply use "lowerdir=/lower" to append on top of existing
layers as "lowerdir=/lower,lowerdir=/other-lower" would make
"/other-lower" the only lower layer so we'd break uapi if we changed
this. So the ':' prefix seems a good compromise.

Users can choose to specify multiple layers at once or individual
layers. A layer is appended if it starts with ":". This requires that
the user has already added at least one layer before. If lowerdir is
specified again without a leading ":" then all previous layers are
dropped and replaced with the new layers. If lowerdir is specified and
empty than all layers are simply dropped.

An additional change is that overlayfs will now parse and resolve layers
right when they are specified in fsconfig() instead of deferring until
super block creation. This allows users to receive early errors.

It also allows users to actually use up to 500 layers something which
was theoretically possible but ended up not working due to the mount
option string passed via mount(2) being too large.

This also allows a more privileged process to set config options for a
lesser privileged process as the creds for fsconfig() and the creds for
fsopen() can differ. We could restrict that they match by enforcing that
the creds of fsopen() and fsconfig() match but I don't see why that
needs to be the case and allows for a good delegation mechanism.

Plus, in the future it means we're able to extend overlayfs mount
options and allow users to specify layers via file descriptors instead
of paths:

        fsconfig(FSCONFIG_SET_PATH{_EMPTY}, "lowerdir", "lower1", dirfd);

        /* append */
        fsconfig(FSCONFIG_SET_PATH{_EMPTY}, "lowerdir", "lower2", dirfd);

        /* append */
        fsconfig(FSCONFIG_SET_PATH{_EMPTY}, "lowerdir", "lower3", dirfd);

        /* clear all layers specified until now */
        fsconfig(FSCONFIG_SET_STRING, "lowerdir", NULL, 0);

This would be especially nice if users create an overlayfs mount on top
of idmapped layers or just in general private mounts created via
open_tree(OPEN_TREE_CLONE). Those mounts would then never have to appear
anywhere in the filesystem. But for now just do the minimal thing.

We should probably aim to move more validation into ovl_fs_parse_param()
so users get errors before fsconfig(FSCONFIG_CMD_CREATE). But that can
be done in additional patches later.

This is now also rebased on top of the lazy lowerdata lookup which
allows the specificatin of data only layers using the new "::" syntax.

The rules are simple. A data only layers cannot be followed by any
regular layers and data layers must be preceeded by at least one regular
layer.

Parsing the lowerdir mount option must change because of this. The
original patchset used the old lowerdir parsing function to split a
lowerdir mount option string such as:

        lowerdir=/lower1:/lower2::/lower3::/lower4

simply replacing each non-escaped ":" by "\0". So sequences of
non-escaped ":" were counted as layers. For example, the previous
lowerdir mount option above would've counted 6 layers instead of 4 and a
lowerdir mount option such as:

        lowerdir="/lower1:/lower2::/lower3::/lower4:::::::::::::::::::::::::::"

would be counted as 33 layers. Other than being ugly this didn't matter
much because kern_path() would reject the first "\0" layer. However,
this overcounting of layers becomes problematic when we base allocations
on it where we very much only want to allocate space for 4 layers
instead of 33.

So the new parsing function rejects non-escaped sequences of colons
other than ":" and "::" immediately instead of relying on kern_path().

Link: https://github.com/util-linux/util-linux/issues/2287
Link: https://github.com/util-linux/util-linux/issues/1992
Link: https://bugs.archlinux.org/task/78702
Link: https://lore.kernel.org/linux-unionfs/20230530-klagen-zudem-32c0908c2108@brauner
Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
</content>
</entry>
<entry>
<title>ovl: port to new mount api</title>
<updated>2023-06-19T11:02:01Z</updated>
<author>
<name>Christian Brauner</name>
</author>
<published>2023-06-16T12:53:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1784fbc2ed9c888ea4e895f30a53207ed7ee8208'/>
<id>urn:sha1:1784fbc2ed9c888ea4e895f30a53207ed7ee8208</id>
<content type='text'>
We recently ported util-linux to the new mount api. Now the mount(8)
tool will by default use the new mount api. While trying hard to fall
back to the old mount api gracefully there are still cases where we run
into issues that are difficult to handle nicely.

Now with mount(8) and libmount supporting the new mount api I expect an
increase in the number of bug reports and issues we're going to see with
filesystems that don't yet support the new mount api. So it's time we
rectify this.

When ovl_fill_super() fails before setting sb-&gt;s_root, we need to cleanup
sb-&gt;s_fs_info.  The logic is a bit convoluted but tl;dr: If sget_fc() has
succeeded fc-&gt;s_fs_info will have been transferred to sb-&gt;s_fs_info.
So by the time -&gt;fill_super()/ovl_fill_super() is called fc-&gt;s_fs_info
is NULL consequently fs_context-&gt;free() won't call ovl_free_fs().

If we fail before sb-&gt;s_root() is set then -&gt;put_super() won't be called
which would call ovl_free_fs(). IOW, if we fail in -&gt;fill_super() before
sb-&gt;s_root we have to clean it up.

Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
</content>
</entry>
<entry>
<title>ovl: factor out ovl_parse_options() helper</title>
<updated>2023-06-19T11:02:01Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2023-06-17T06:05:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ac519625edf2004fd34f6deec3110b154f621780'/>
<id>urn:sha1:ac519625edf2004fd34f6deec3110b154f621780</id>
<content type='text'>
For parsing a single mount option.

Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
</content>
</entry>
</feed>
