Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d4ef4e1 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull overlayfs fixes from Miklos Szeredi:
 "Fix a regression in 4.14 and one in 4.13. The latter is a case when
  Docker is doing something it really shouldn't and gets away with it.
  We now print a warning instead of erroring out.

  There are also fixes to several error paths"

* 'overlayfs-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs:
  ovl: fix regression caused by exclusive upper/work dir protection
  ovl: fix missing unlock_rename() in ovl_do_copy_up()
  ovl: fix dentry leak in ovl_indexdir_cleanup()
  ovl: fix dput() of ERR_PTR in ovl_cleanup_index()
  ovl: fix error value printed in ovl_lookup_index()
  ovl: fix may_write_real() for overlayfs directories
parents 1249b571 85fdee1e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -210,8 +210,11 @@ path as another overlay mount and it may use a lower layer path that is
beneath or above the path of another overlay lower layer path.

Using an upper layer path and/or a workdir path that are already used by
another overlay mount is not allowed and will fail with EBUSY.  Using
another overlay mount is not allowed and may fail with EBUSY.  Using
partially overlapping paths is not allowed but will not fail with EBUSY.
If files are accessed from two overlayfs mounts which share or overlap the
upper layer and/or workdir path the behavior of the overlay is undefined,
though it will not result in a crash or deadlock.

Mounting an overlay using an upper layer path, where the upper layer path
was previously used by another mounted overlay in combination with a
+3 −1
Original line number Diff line number Diff line
@@ -468,7 +468,9 @@ static inline int may_write_real(struct file *file)

	/* File refers to upper, writable layer? */
	upperdentry = d_real(dentry, NULL, 0, D_REAL_UPPER);
	if (upperdentry && file_inode(file) == d_inode(upperdentry))
	if (upperdentry &&
	    (file_inode(file) == d_inode(upperdentry) ||
	     file_inode(file) == d_inode(dentry)))
		return 0;

	/* Lower layer: can't write to real file, sorry... */
+2 −4
Original line number Diff line number Diff line
@@ -561,10 +561,8 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
		c->tmpfile = true;
		err = ovl_copy_up_locked(c);
	} else {
		err = -EIO;
		if (lock_rename(c->workdir, c->destdir) != NULL) {
			pr_err("overlayfs: failed to lock workdir+upperdir\n");
		} else {
		err = ovl_lock_rename_workdir(c->workdir, c->destdir);
		if (!err) {
			err = ovl_copy_up_locked(c);
			unlock_rename(c->workdir, c->destdir);
		}
+0 −20
Original line number Diff line number Diff line
@@ -216,26 +216,6 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
	return err;
}

static int ovl_lock_rename_workdir(struct dentry *workdir,
				   struct dentry *upperdir)
{
	/* Workdir should not be the same as upperdir */
	if (workdir == upperdir)
		goto err;

	/* Workdir should not be subdir of upperdir and vice versa */
	if (lock_rename(workdir, upperdir) != NULL)
		goto err_unlock;

	return 0;

err_unlock:
	unlock_rename(workdir, upperdir);
err:
	pr_err("overlayfs: failed to lock workdir+upperdir\n");
	return -EIO;
}

static struct dentry *ovl_clear_empty(struct dentry *dentry,
				      struct list_head *list)
{
+1 −0
Original line number Diff line number Diff line
@@ -506,6 +506,7 @@ static struct dentry *ovl_lookup_index(struct dentry *dentry,

	index = lookup_one_len_unlocked(name.name, ofs->indexdir, name.len);
	if (IS_ERR(index)) {
		err = PTR_ERR(index);
		pr_warn_ratelimited("overlayfs: failed inode index lookup (ino=%lu, key=%*s, err=%i);\n"
				    "overlayfs: mount with '-o index=off' to disable inodes index.\n",
				    d_inode(origin)->i_ino, name.len, name.name,
Loading