Skip to content

Commit b5e40f5

Browse files
committed
zpl_inode.c: Fix SMACK interoperability
closes: #11646 ref: #11646 (comment) ref: cschaufler/smack-next#1 SMACK needs to have the ZFS dentry security field setup before SMACK's d_instantiate() hook is called as it requires functioning '__vfs_getxattr()' calls to properly set the labels. Fixes: 1) file instantiation properly setting the object label to the subject's label 2) proper file labelling in a transmutable directory Functions Updated: 1) zpl_create() 2) zpl_mknod() 3) zpl_mkdir() 4) zpl_symlink() Signed-off-by: TerraTech <[email protected]>
1 parent ec58022 commit b5e40f5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

module/os/linux/zfs/zpl_inode.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,14 @@ zpl_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool flag)
149149
error = -zfs_create(ITOZ(dir), dname(dentry), vap, 0,
150150
mode, &zp, cr, 0, NULL);
151151
if (error == 0) {
152-
d_instantiate(dentry, ZTOI(zp));
153-
154152
error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
155153
if (error == 0)
156154
error = zpl_init_acl(ZTOI(zp), dir);
157155

158156
if (error)
159157
(void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
158+
else
159+
d_instantiate(dentry, ZTOI(zp));
160160
}
161161

162162
spl_fstrans_unmark(cookie);
@@ -198,14 +198,14 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
198198
error = -zfs_create(ITOZ(dir), dname(dentry), vap, 0,
199199
mode, &zp, cr, 0, NULL);
200200
if (error == 0) {
201-
d_instantiate(dentry, ZTOI(zp));
202-
203201
error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
204202
if (error == 0)
205203
error = zpl_init_acl(ZTOI(zp), dir);
206204

207205
if (error)
208206
(void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
207+
else
208+
d_instantiate(dentry, ZTOI(zp));
209209
}
210210

211211
spl_fstrans_unmark(cookie);
@@ -308,14 +308,14 @@ zpl_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
308308
cookie = spl_fstrans_mark();
309309
error = -zfs_mkdir(ITOZ(dir), dname(dentry), vap, &zp, cr, 0, NULL);
310310
if (error == 0) {
311-
d_instantiate(dentry, ZTOI(zp));
312-
313311
error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
314312
if (error == 0)
315313
error = zpl_init_acl(ZTOI(zp), dir);
316314

317315
if (error)
318316
(void) zfs_rmdir(ITOZ(dir), dname(dentry), NULL, cr, 0);
317+
else
318+
d_instantiate(dentry, ZTOI(zp));
319319
}
320320

321321
spl_fstrans_unmark(cookie);
@@ -488,11 +488,11 @@ zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
488488
error = -zfs_symlink(ITOZ(dir), dname(dentry), vap,
489489
(char *)name, &zp, cr, 0);
490490
if (error == 0) {
491-
d_instantiate(dentry, ZTOI(zp));
492-
493491
error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
494492
if (error)
495493
(void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
494+
else
495+
d_instantiate(dentry, ZTOI(zp));
496496
}
497497

498498
spl_fstrans_unmark(cookie);

0 commit comments

Comments
 (0)