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

Commit 3767e255 authored by Al Viro's avatar Al Viro
Browse files

switch ->setxattr() to passing dentry and inode separately



smack ->d_instantiate() uses ->setxattr(), so to be able to call it before
we'd hashed the new dentry and attached it to inode, we need ->setxattr()
instances getting the inode as an explicit argument rather than obtaining
it from dentry.

Similar change for ->getxattr() had been done in commit ce23e640.  Unlike
->getxattr() (which is used by both selinux and smack instances of
->d_instantiate()) ->setxattr() is used only by smack one and unfortunately
it got missed back then.

Reported-by: default avatarSeung-Woo Kim <sw0312.kim@samsung.com>
Tested-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 59301226
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -578,3 +578,10 @@ in your dentry operations instead.
--
[mandatory]
	->atomic_open() calls without O_CREAT may happen in parallel.
--
[mandatory]
	->setxattr() and xattr_handler.set() get dentry and inode passed separately.
	dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
	in the instances.  Rationale: !@#!@# security_d_instantiate() needs to be
	called before we attach dentry to inode and !@#!@##!@$!$#!@#$!@$!@$ smack
	->d_instantiate() uses not just ->getxattr() but ->setxattr() as well.
+2 −2
Original line number Diff line number Diff line
@@ -976,8 +976,8 @@ static inline __u64 ll_file_maxbytes(struct inode *inode)
}

/* llite/xattr.c */
int ll_setxattr(struct dentry *dentry, const char *name,
		const void *value, size_t size, int flags);
int ll_setxattr(struct dentry *dentry, struct inode *inode,
		const char *name, const void *value, size_t size, int flags);
ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode,
		    const char *name, void *buffer, size_t size);
ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size);
+2 −4
Original line number Diff line number Diff line
@@ -211,11 +211,9 @@ int ll_setxattr_common(struct inode *inode, const char *name,
	return 0;
}

int ll_setxattr(struct dentry *dentry, const char *name,
		const void *value, size_t size, int flags)
int ll_setxattr(struct dentry *dentry, struct inode *inode,
		const char *name, const void *value, size_t size, int flags)
{
	struct inode *inode = d_inode(dentry);

	LASSERT(inode);
	LASSERT(name);

+2 −2
Original line number Diff line number Diff line
@@ -100,8 +100,8 @@ static int bad_inode_setattr(struct dentry *direntry, struct iattr *attrs)
	return -EIO;
}

static int bad_inode_setxattr(struct dentry *dentry, const char *name,
		const void *value, size_t size, int flags)
static int bad_inode_setxattr(struct dentry *dentry, struct inode *inode,
		const char *name, const void *value, size_t size, int flags)
{
	return -EIO;
}
+5 −4
Original line number Diff line number Diff line
@@ -1141,12 +1141,13 @@ ecryptfs_write_metadata_to_contents(struct inode *ecryptfs_inode,

static int
ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry,
				 struct inode *ecryptfs_inode,
				 char *page_virt, size_t size)
{
	int rc;

	rc = ecryptfs_setxattr(ecryptfs_dentry, ECRYPTFS_XATTR_NAME, page_virt,
			       size, 0);
	rc = ecryptfs_setxattr(ecryptfs_dentry, ecryptfs_inode,
			       ECRYPTFS_XATTR_NAME, page_virt, size, 0);
	return rc;
}

@@ -1215,8 +1216,8 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry,
		goto out_free;
	}
	if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR)
		rc = ecryptfs_write_metadata_to_xattr(ecryptfs_dentry, virt,
						      size);
		rc = ecryptfs_write_metadata_to_xattr(ecryptfs_dentry, ecryptfs_inode,
						      virt, size);
	else
		rc = ecryptfs_write_metadata_to_contents(ecryptfs_inode, virt,
							 virt_len);
Loading