Skip to content

Commit fe4f454

Browse files
TerraTechRageLtMan
authored andcommitted
zpl_inode.c: Fix SMACK interoperability
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. Fxes: 1) file instantiation properly setting the object label to the subject's label 2) proper file labeling in a transmutable directory Functions Updated: 1) zpl_create() 2) zpl_mknod() 3) zpl_mkdir() 4) zpl_symlink() External-issue: cschaufler/smack-next#1 Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: TerraTech <[email protected]> Closes openzfs#11646 Closes openzfs#11839
1 parent e01565e commit fe4f454

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

module/os/linux/zfs/zpl_inode.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,17 @@ 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

158-
if (error)
156+
if (error) {
159157
(void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
158+
remove_inode_hash(ZTOI(zp));
159+
iput(ZTOI(zp));
160+
} else {
161+
d_instantiate(dentry, ZTOI(zp));
162+
}
160163
}
161164

162165
spl_fstrans_unmark(cookie);
@@ -198,14 +201,17 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
198201
error = -zfs_create(ITOZ(dir), dname(dentry), vap, 0,
199202
mode, &zp, cr, 0, NULL);
200203
if (error == 0) {
201-
d_instantiate(dentry, ZTOI(zp));
202-
203204
error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
204205
if (error == 0)
205206
error = zpl_init_acl(ZTOI(zp), dir);
206207

207-
if (error)
208+
if (error) {
208209
(void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
210+
remove_inode_hash(ZTOI(zp));
211+
iput(ZTOI(zp));
212+
} else {
213+
d_instantiate(dentry, ZTOI(zp));
214+
}
209215
}
210216

211217
spl_fstrans_unmark(cookie);
@@ -308,14 +314,17 @@ zpl_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
308314
cookie = spl_fstrans_mark();
309315
error = -zfs_mkdir(ITOZ(dir), dname(dentry), vap, &zp, cr, 0, NULL);
310316
if (error == 0) {
311-
d_instantiate(dentry, ZTOI(zp));
312-
313317
error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
314318
if (error == 0)
315319
error = zpl_init_acl(ZTOI(zp), dir);
316320

317-
if (error)
321+
if (error) {
318322
(void) zfs_rmdir(ITOZ(dir), dname(dentry), NULL, cr, 0);
323+
remove_inode_hash(ZTOI(zp));
324+
iput(ZTOI(zp));
325+
} else {
326+
d_instantiate(dentry, ZTOI(zp));
327+
}
319328
}
320329

321330
spl_fstrans_unmark(cookie);
@@ -488,11 +497,14 @@ zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
488497
error = -zfs_symlink(ITOZ(dir), dname(dentry), vap,
489498
(char *)name, &zp, cr, 0);
490499
if (error == 0) {
491-
d_instantiate(dentry, ZTOI(zp));
492-
493500
error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
494-
if (error)
501+
if (error) {
495502
(void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
503+
remove_inode_hash(ZTOI(zp));
504+
iput(ZTOI(zp));
505+
} else {
506+
d_instantiate(dentry, ZTOI(zp));
507+
}
496508
}
497509

498510
spl_fstrans_unmark(cookie);

0 commit comments

Comments
 (0)