X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=module%2Fzfs%2Fzpl_xattr.c;h=f274407e5930f02e79c09d0e16ab4a9f6078ddd9;hb=5c03efc379693f992ebe39c6a00c7297c4a304ea;hp=7a1ecec8f14bb442cad2f2c7c1a9e3d307bc7aef;hpb=f9637c6c8b9c452c440a366aa937b363f027d95e;p=zfs.git diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c index 7a1ecec..f274407 100644 --- a/module/zfs/zpl_xattr.c +++ b/module/zfs/zpl_xattr.c @@ -110,11 +110,11 @@ zpl_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) struct inode *ip = dentry->d_inode; struct inode *dxip = NULL; loff_t pos = 3; /* skip '.', '..', and '.zfs' entries. */ - cred_t *cr; + cred_t *cr = CRED(); int error; xattr_filldir_t xf = { buffer_size, 0, buffer, ip }; - cr = (cred_t *)get_current_cred(); + crhold(cr); /* Lookup the xattr directory */ error = -zfs_lookup(ip, NULL, &dxip, LOOKUP_XATTR, cr, NULL, NULL); @@ -135,7 +135,7 @@ out: if (dxip) iput(dxip); - put_cred(cr); + crfree(cr); return (error); } @@ -145,10 +145,10 @@ zpl_xattr_get(struct inode *ip, const char *name, void *buf, size_t size) { struct inode *dxip = NULL; struct inode *xip = NULL; - cred_t *cr; + cred_t *cr = CRED(); int error; - cr = (cred_t *)get_current_cred(); + crhold(cr); /* Lookup the xattr directory */ error = -zfs_lookup(ip, NULL, &dxip, LOOKUP_XATTR, cr, NULL, NULL); @@ -173,7 +173,7 @@ out: if (dxip) iput(dxip); - put_cred(cr); + crfree(cr); if (error == -ENOENT) error = -ENODATA; @@ -188,11 +188,12 @@ zpl_xattr_set(struct inode *ip, const char *name, const void *value, struct inode *dxip = NULL; struct inode *xip = NULL; vattr_t *vap = NULL; - cred_t *cr; + cred_t *cr = CRED(); ssize_t wrote; int error; + const int xattr_mode = S_IFREG | 0644; - cr = (cred_t *)get_current_cred(); + crhold(cr); /* Lookup the xattr directory and create it if required. */ error = -zfs_lookup(ip, NULL, &dxip, LOOKUP_XATTR | CREATE_XATTR_DIR, @@ -230,10 +231,10 @@ zpl_xattr_set(struct inode *ip, const char *name, const void *value, /* Lookup failed create a new xattr. */ if (xip == NULL) { vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP); - vap->va_mode = S_IFREG | 0644; + vap->va_mode = xattr_mode; vap->va_mask = ATTR_MODE; - vap->va_uid = current_fsuid(); - vap->va_gid = current_fsgid(); + vap->va_uid = crgetfsuid(cr); + vap->va_gid = crgetfsgid(cr); error = -zfs_create(dxip, (char *)name, vap, 0, 0644, &xip, cr, 0, NULL); @@ -242,6 +243,11 @@ zpl_xattr_set(struct inode *ip, const char *name, const void *value, } ASSERT(xip != NULL); + + error = -zfs_freesp(ITOZ(xip), 0, 0, xattr_mode, TRUE); + if (error) + goto out; + wrote = zpl_write_common(xip, value, size, 0, UIO_SYSSPACE, 0, cr); if (wrote < 0) error = wrote; @@ -256,7 +262,7 @@ out: if (dxip) iput(dxip); - put_cred(cr); + crfree(cr); if (error == -ENOENT) error = -ENODATA; @@ -398,14 +404,16 @@ __zpl_xattr_security_set(struct inode *ip, const char *name, ZPL_XATTR_SET_WRAPPER(zpl_xattr_security_set); int -zpl_xattr_security_init(struct inode *ip, struct inode *dip) +zpl_xattr_security_init(struct inode *ip, struct inode *dip, + const struct qstr *qstr) { int error; size_t len; void *value; char *name; - error = security_inode_init_security(ip, dip, &name, &value, &len); + error = zpl_security_inode_init_security(ip, dip, qstr, + &name, &value, &len); if (error) { if (error == -EOPNOTSUPP) return 0;