Skip to content

Commit f59388a

Browse files
committed
NFSD: Add nfsd4_encode_fattr4_sec_label()
Refactor the encoder for FATTR4_SEC_LABEL into a helper. In a subsequent patch, this helper will be called from a bitmask loop. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 345c387 commit f59388a

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

fs/nfsd/nfs4xdr.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2894,6 +2894,10 @@ struct nfsd4_fattr_args {
28942894
struct kstatfs statfs;
28952895
struct nfs4_acl *acl;
28962896
u64 size;
2897+
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
2898+
void *context;
2899+
int contextlen;
2900+
#endif
28972901
u32 rdattr_err;
28982902
bool contextsupport;
28992903
bool ignore_crossmnt;
@@ -3334,6 +3338,15 @@ static __be32 nfsd4_encode_fattr4_suppattr_exclcreat(struct xdr_stream *xdr,
33343338
return nfsd4_encode_bitmap4(xdr, supp[0], supp[1], supp[2]);
33353339
}
33363340

3341+
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
3342+
static __be32 nfsd4_encode_fattr4_sec_label(struct xdr_stream *xdr,
3343+
const struct nfsd4_fattr_args *args)
3344+
{
3345+
return nfsd4_encode_security_label(xdr, args->rqstp,
3346+
args->context, args->contextlen);
3347+
}
3348+
#endif
3349+
33373350
/*
33383351
* Note: @fhp can be NULL; in this case, we might have to compose the filehandle
33393352
* ourselves.
@@ -3354,10 +3367,6 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
33543367
int attrlen_offset;
33553368
__be32 status;
33563369
int err;
3357-
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
3358-
void *context = NULL;
3359-
int contextlen;
3360-
#endif
33613370
struct nfsd4_compoundres *resp = rqstp->rq_resp;
33623371
u32 minorversion = resp->cstate.minorversion;
33633372
struct path path = {
@@ -3436,11 +3445,12 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
34363445
args.contextsupport = false;
34373446

34383447
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
3448+
args.context = NULL;
34393449
if ((bmval2 & FATTR4_WORD2_SECURITY_LABEL) ||
34403450
bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) {
34413451
if (exp->ex_flags & NFSEXP_SECURITY_LABEL)
34423452
err = security_inode_getsecctx(d_inode(dentry),
3443-
&context, &contextlen);
3453+
&args.context, &args.contextlen);
34443454
else
34453455
err = -EOPNOTSUPP;
34463456
args.contextsupport = (err == 0);
@@ -3719,8 +3729,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
37193729

37203730
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
37213731
if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) {
3722-
status = nfsd4_encode_security_label(xdr, rqstp, context,
3723-
contextlen);
3732+
status = nfsd4_encode_fattr4_sec_label(xdr, &args);
37243733
if (status)
37253734
goto out;
37263735
}
@@ -3739,8 +3748,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
37393748

37403749
out:
37413750
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
3742-
if (context)
3743-
security_release_secctx(context, contextlen);
3751+
if (args.context)
3752+
security_release_secctx(args.context, args.contextlen);
37443753
#endif /* CONFIG_NFSD_V4_SECURITY_LABEL */
37453754
kfree(args.acl);
37463755
if (tempfh) {

0 commit comments

Comments
 (0)