@@ -64,36 +64,6 @@ MODULE_PARM_DESC(nfsd4_ssc_umount_timeout,
64
64
"idle msecs before unmount export from source server" );
65
65
#endif
66
66
67
- #ifdef CONFIG_NFSD_V4_SECURITY_LABEL
68
- #include <linux/security.h>
69
-
70
- static inline void
71
- nfsd4_security_inode_setsecctx (struct svc_fh * resfh , struct xdr_netobj * label , u32 * bmval )
72
- {
73
- struct inode * inode = d_inode (resfh -> fh_dentry );
74
- int status ;
75
-
76
- inode_lock (inode );
77
- status = security_inode_setsecctx (resfh -> fh_dentry ,
78
- label -> data , label -> len );
79
- inode_unlock (inode );
80
-
81
- if (status )
82
- /*
83
- * XXX: We should really fail the whole open, but we may
84
- * already have created a new file, so it may be too
85
- * late. For now this seems the least of evils:
86
- */
87
- bmval [2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ;
88
-
89
- return ;
90
- }
91
- #else
92
- static inline void
93
- nfsd4_security_inode_setsecctx (struct svc_fh * resfh , struct xdr_netobj * label , u32 * bmval )
94
- { }
95
- #endif
96
-
97
67
#define NFSDDBG_FACILITY NFSDDBG_PROC
98
68
99
69
static u32 nfsd_attrmask [] = {
@@ -288,6 +258,7 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
288
258
struct iattr * iap = & open -> op_iattr ;
289
259
struct nfsd_attrs attrs = {
290
260
.na_iattr = iap ,
261
+ .na_seclabel = & open -> op_label ,
291
262
};
292
263
struct dentry * parent , * child ;
293
264
__u32 v_mtime , v_atime ;
@@ -409,6 +380,8 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
409
380
set_attr :
410
381
status = nfsd_create_setattr (rqstp , fhp , resfhp , & attrs );
411
382
383
+ if (attrs .na_labelerr )
384
+ open -> op_bmval [2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ;
412
385
out :
413
386
fh_unlock (fhp );
414
387
if (child && !IS_ERR (child ))
@@ -450,9 +423,6 @@ do_open_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, stru
450
423
status = nfsd4_create_file (rqstp , current_fh , * resfh , open );
451
424
current -> fs -> umask = 0 ;
452
425
453
- if (!status && open -> op_label .len )
454
- nfsd4_security_inode_setsecctx (* resfh , & open -> op_label , open -> op_bmval );
455
-
456
426
/*
457
427
* Following rfc 3530 14.2.16, and rfc 5661 18.16.4
458
428
* use the returned bitmask to indicate which attributes
@@ -792,6 +762,7 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
792
762
struct nfsd4_create * create = & u -> create ;
793
763
struct nfsd_attrs attrs = {
794
764
.na_iattr = & create -> cr_iattr ,
765
+ .na_seclabel = & create -> cr_label ,
795
766
};
796
767
struct svc_fh resfh ;
797
768
__be32 status ;
@@ -864,8 +835,8 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
864
835
if (status )
865
836
goto out ;
866
837
867
- if (create -> cr_label . len )
868
- nfsd4_security_inode_setsecctx ( & resfh , & create -> cr_label , create -> cr_bmval ) ;
838
+ if (attrs . na_labelerr )
839
+ create -> cr_bmval [ 2 ] &= ~ FATTR4_WORD2_SECURITY_LABEL ;
869
840
870
841
if (create -> cr_acl != NULL )
871
842
do_set_nfs4_acl (rqstp , & resfh , create -> cr_acl ,
@@ -1150,6 +1121,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
1150
1121
struct nfsd4_setattr * setattr = & u -> setattr ;
1151
1122
struct nfsd_attrs attrs = {
1152
1123
.na_iattr = & setattr -> sa_iattr ,
1124
+ .na_seclabel = & setattr -> sa_label ,
1153
1125
};
1154
1126
__be32 status = nfs_ok ;
1155
1127
int err ;
@@ -1178,13 +1150,10 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
1178
1150
setattr -> sa_acl );
1179
1151
if (status )
1180
1152
goto out ;
1181
- if (setattr -> sa_label .len )
1182
- status = nfsd4_set_nfs4_label (rqstp , & cstate -> current_fh ,
1183
- & setattr -> sa_label );
1184
- if (status )
1185
- goto out ;
1186
1153
status = nfsd_setattr (rqstp , & cstate -> current_fh , & attrs ,
1187
1154
0 , (time64_t )0 );
1155
+ if (!status )
1156
+ status = nfserrno (attrs .na_labelerr );
1188
1157
out :
1189
1158
fh_drop_write (& cstate -> current_fh );
1190
1159
return status ;
0 commit comments