Skip to content

Commit a57e0c6

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 a57e0c6

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

module/os/linux/zfs/zpl_inode.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,16 @@ 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+
(void) zpl_inode_destroy(ZTOI(zp));
159+
} else {
160+
d_instantiate(dentry, ZTOI(zp));
161+
}
160162
}
161163

162164
spl_fstrans_unmark(cookie);
@@ -198,14 +200,16 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
198200
error = -zfs_create(ITOZ(dir), dname(dentry), vap, 0,
199201
mode, &zp, cr, 0, NULL);
200202
if (error == 0) {
201-
d_instantiate(dentry, ZTOI(zp));
202-
203203
error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
204204
if (error == 0)
205205
error = zpl_init_acl(ZTOI(zp), dir);
206206

207-
if (error)
207+
if (error) {
208208
(void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
209+
(void) zpl_inode_destroy(ZTOI(zp));
210+
} else {
211+
d_instantiate(dentry, ZTOI(zp));
212+
}
209213
}
210214

211215
spl_fstrans_unmark(cookie);
@@ -308,14 +312,16 @@ zpl_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
308312
cookie = spl_fstrans_mark();
309313
error = -zfs_mkdir(ITOZ(dir), dname(dentry), vap, &zp, cr, 0, NULL);
310314
if (error == 0) {
311-
d_instantiate(dentry, ZTOI(zp));
312-
313315
error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
314316
if (error == 0)
315317
error = zpl_init_acl(ZTOI(zp), dir);
316318

317-
if (error)
319+
if (error) {
318320
(void) zfs_rmdir(ITOZ(dir), dname(dentry), NULL, cr, 0);
321+
(void) zpl_inode_destroy(ZTOI(zp));
322+
} else {
323+
d_instantiate(dentry, ZTOI(zp));
324+
}
319325
}
320326

321327
spl_fstrans_unmark(cookie);
@@ -488,11 +494,13 @@ zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
488494
error = -zfs_symlink(ITOZ(dir), dname(dentry), vap,
489495
(char *)name, &zp, cr, 0);
490496
if (error == 0) {
491-
d_instantiate(dentry, ZTOI(zp));
492-
493497
error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name);
494-
if (error)
498+
if (error) {
495499
(void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0);
500+
(void) zpl_inode_destroy(ZTOI(zp));
501+
} else {
502+
d_instantiate(dentry, ZTOI(zp));
503+
}
496504
}
497505

498506
spl_fstrans_unmark(cookie);

0 commit comments

Comments
 (0)