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

Commit cef9f8d2 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

Revert "ANDROID: overlayfs: override_creds=off option bypass creator_cred"

This reverts commit 9a2d2a45.

Reason for revert: <INSERT REASONING HERE>

Change-Id: I1b96d1111b993ca23061844dd33573c16d449248
parent 9a2d2a45
Loading
Loading
Loading
Loading
+0 −23
Original line number Diff line number Diff line
@@ -89,29 +89,6 @@ Only the lists of names from directories are merged. Other content
such as metadata and extended attributes are reported for the upper
directory only.  These attributes of the lower directory are hidden.

credentials
-----------

By default, all access to the upper, lower and work directories is the
recorded mounter's MAC and DAC credentials.  The incoming accesses are
checked against the caller's credentials.

In the case where caller MAC or DAC credentials do not overlap, a
use case available in older versions of the driver, the
override_creds mount flag can be turned off and help when the use
pattern has caller with legitimate credentials where the mounter
does not.  Several unintended side effects will occur though.  The
caller without certain key capabilities or lower privilege will not
always be able to delete files or directories, create nodes, or
search some restricted directories.  The ability to search and read
a directory entry is spotty as a result of the cache mechanism not
retesting the credentials because of the assumption, a privileged
caller can fill cache, then a lower privilege can read the directory
cache.  The uneven security model where cache, upperdir and workdir
are opened at privilege, but accessed without creating a form of
privilege escalation, should only be used with strict understanding
of the side effects and of the security policies.

whiteouts and opaque directories
--------------------------------

+1 −1
Original line number Diff line number Diff line
@@ -687,7 +687,7 @@ int ovl_copy_up_flags(struct dentry *dentry, int flags)
		dput(parent);
		dput(next);
	}
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);

	return err;
}
+4 −5
Original line number Diff line number Diff line
@@ -496,8 +496,7 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
		override_cred->fsgid = inode->i_gid;
		if (!hardlink) {
			err = security_dentry_create_files_as(dentry,
					attr->mode, &dentry->d_name,
					old_cred ? old_cred : current_cred(),
					attr->mode, &dentry->d_name, old_cred,
					override_cred);
			if (err) {
				put_cred(override_cred);
@@ -515,7 +514,7 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
							hardlink);
	}
out_revert_creds:
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);
	if (!err) {
		struct inode *realinode = d_inode(ovl_dentry_upper(dentry));

@@ -774,7 +773,7 @@ static int ovl_do_remove(struct dentry *dentry, bool is_dir)
		err = ovl_remove_upper(dentry, is_dir);
	else
		err = ovl_remove_and_whiteout(dentry, is_dir);
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);
	if (!err) {
		if (is_dir)
			clear_nlink(dentry->d_inode);
@@ -1090,7 +1089,7 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
out_unlock:
	unlock_rename(new_upperdir, old_upperdir);
out_revert_creds:
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);
	ovl_nlink_end(new, locked);
out_drop_write:
	ovl_drop_write(old);
+8 −8
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
		inode_lock(upperdentry->d_inode);
		old_cred = ovl_override_creds(dentry->d_sb);
		err = notify_change(upperdentry, attr, NULL);
		ovl_revert_creds(old_cred);
		revert_creds(old_cred);
		if (!err)
			ovl_copyattr(upperdentry->d_inode, dentry->d_inode);
		inode_unlock(upperdentry->d_inode);
@@ -142,7 +142,7 @@ int ovl_getattr(const struct path *path, struct kstat *stat,
		stat->nlink = dentry->d_inode->i_nlink;

out:
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);

	return err;
}
@@ -176,7 +176,7 @@ int ovl_permission(struct inode *inode, int mask)
		mask |= MAY_READ;
	}
	err = inode_permission(realinode, mask);
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);

	return err;
}
@@ -193,7 +193,7 @@ static const char *ovl_get_link(struct dentry *dentry,

	old_cred = ovl_override_creds(dentry->d_sb);
	p = vfs_get_link(ovl_dentry_real(dentry), done);
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);
	return p;
}

@@ -236,7 +236,7 @@ int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char *name,
		WARN_ON(flags != XATTR_REPLACE);
		err = vfs_removexattr(realdentry, name);
	}
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);

out_drop_write:
	ovl_drop_write(dentry);
@@ -254,7 +254,7 @@ int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name,

	old_cred = ovl_override_creds(dentry->d_sb);
	res = vfs_getxattr(realdentry, name, value, size);
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);
	return res;
}

@@ -278,7 +278,7 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)

	old_cred = ovl_override_creds(dentry->d_sb);
	res = vfs_listxattr(realdentry, list, size);
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);
	if (res <= 0 || size == 0)
		return res;

@@ -313,7 +313,7 @@ struct posix_acl *ovl_get_acl(struct inode *inode, int type)

	old_cred = ovl_override_creds(inode->i_sb);
	acl = get_acl(realinode, type);
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);

	return acl;
}
+2 −2
Original line number Diff line number Diff line
@@ -730,7 +730,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
			ovl_set_flag(OVL_INDEX, inode);
	}

	ovl_revert_creds(old_cred);
	revert_creds(old_cred);
	dput(index);
	kfree(stack);
	kfree(d.redirect);
@@ -751,7 +751,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
	kfree(upperredirect);
out:
	kfree(d.redirect);
	ovl_revert_creds(old_cred);
	revert_creds(old_cred);
	return ERR_PTR(err);
}

Loading