Commit 70b589a3 authored by Eric Sandeen's avatar Eric Sandeen Committed by Darrick J. Wong

xfs: add selinux labels to whiteout inodes

We got a report that "renameat2() with flags=RENAME_WHITEOUT doesn't
apply an SELinux label on xfs" as it does on other filesystems
(for example, ext4 and tmpfs.)  While I'm not quite sure how labels
may interact w/ whiteout files, leaving them as unlabeled seems
inconsistent at best. Now that xfs_init_security is not static,
rename it to xfs_inode_init_security per dchinner's suggestion.
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent fddb564f
...@@ -3032,10 +3032,12 @@ xfs_cross_rename( ...@@ -3032,10 +3032,12 @@ xfs_cross_rename(
static int static int
xfs_rename_alloc_whiteout( xfs_rename_alloc_whiteout(
struct user_namespace *mnt_userns, struct user_namespace *mnt_userns,
struct xfs_name *src_name,
struct xfs_inode *dp, struct xfs_inode *dp,
struct xfs_inode **wip) struct xfs_inode **wip)
{ {
struct xfs_inode *tmpfile; struct xfs_inode *tmpfile;
struct qstr name;
int error; int error;
error = xfs_create_tmpfile(mnt_userns, dp, S_IFCHR | WHITEOUT_MODE, error = xfs_create_tmpfile(mnt_userns, dp, S_IFCHR | WHITEOUT_MODE,
...@@ -3043,6 +3045,15 @@ xfs_rename_alloc_whiteout( ...@@ -3043,6 +3045,15 @@ xfs_rename_alloc_whiteout(
if (error) if (error)
return error; return error;
name.name = src_name->name;
name.len = src_name->len;
error = xfs_inode_init_security(VFS_I(tmpfile), VFS_I(dp), &name);
if (error) {
xfs_finish_inode_setup(tmpfile);
xfs_irele(tmpfile);
return error;
}
/* /*
* Prepare the tmpfile inode as if it were created through the VFS. * Prepare the tmpfile inode as if it were created through the VFS.
* Complete the inode setup and flag it as linkable. nlink is already * Complete the inode setup and flag it as linkable. nlink is already
...@@ -3093,7 +3104,8 @@ xfs_rename( ...@@ -3093,7 +3104,8 @@ xfs_rename(
* appropriately. * appropriately.
*/ */
if (flags & RENAME_WHITEOUT) { if (flags & RENAME_WHITEOUT) {
error = xfs_rename_alloc_whiteout(mnt_userns, target_dp, &wip); error = xfs_rename_alloc_whiteout(mnt_userns, src_name,
target_dp, &wip);
if (error) if (error)
return error; return error;
......
...@@ -75,9 +75,8 @@ xfs_initxattrs( ...@@ -75,9 +75,8 @@ xfs_initxattrs(
* these attrs can be journalled at inode creation time (along with the * these attrs can be journalled at inode creation time (along with the
* inode, of course, such that log replay can't cause these to be lost). * inode, of course, such that log replay can't cause these to be lost).
*/ */
int
STATIC int xfs_inode_init_security(
xfs_init_security(
struct inode *inode, struct inode *inode,
struct inode *dir, struct inode *dir,
const struct qstr *qstr) const struct qstr *qstr)
...@@ -122,7 +121,7 @@ xfs_cleanup_inode( ...@@ -122,7 +121,7 @@ xfs_cleanup_inode(
/* Oh, the horror. /* Oh, the horror.
* If we can't add the ACL or we fail in * If we can't add the ACL or we fail in
* xfs_init_security we must back out. * xfs_inode_init_security we must back out.
* ENOSPC can hit here, among other things. * ENOSPC can hit here, among other things.
*/ */
xfs_dentry_to_name(&teardown, dentry); xfs_dentry_to_name(&teardown, dentry);
...@@ -208,7 +207,7 @@ xfs_generic_create( ...@@ -208,7 +207,7 @@ xfs_generic_create(
inode = VFS_I(ip); inode = VFS_I(ip);
error = xfs_init_security(inode, dir, &dentry->d_name); error = xfs_inode_init_security(inode, dir, &dentry->d_name);
if (unlikely(error)) if (unlikely(error))
goto out_cleanup_inode; goto out_cleanup_inode;
...@@ -424,7 +423,7 @@ xfs_vn_symlink( ...@@ -424,7 +423,7 @@ xfs_vn_symlink(
inode = VFS_I(cip); inode = VFS_I(cip);
error = xfs_init_security(inode, dir, &dentry->d_name); error = xfs_inode_init_security(inode, dir, &dentry->d_name);
if (unlikely(error)) if (unlikely(error))
goto out_cleanup_inode; goto out_cleanup_inode;
......
...@@ -17,4 +17,7 @@ extern void xfs_setattr_time(struct xfs_inode *ip, struct iattr *iattr); ...@@ -17,4 +17,7 @@ extern void xfs_setattr_time(struct xfs_inode *ip, struct iattr *iattr);
int xfs_vn_setattr_size(struct user_namespace *mnt_userns, int xfs_vn_setattr_size(struct user_namespace *mnt_userns,
struct dentry *dentry, struct iattr *vap); struct dentry *dentry, struct iattr *vap);
int xfs_inode_init_security(struct inode *inode, struct inode *dir,
const struct qstr *qstr);
#endif /* __XFS_IOPS_H__ */ #endif /* __XFS_IOPS_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment