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 <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
parent
345c3877d2
commit
f59388a579
1 changed files with 18 additions and 9 deletions
|
@ -2894,6 +2894,10 @@ struct nfsd4_fattr_args {
|
||||||
struct kstatfs statfs;
|
struct kstatfs statfs;
|
||||||
struct nfs4_acl *acl;
|
struct nfs4_acl *acl;
|
||||||
u64 size;
|
u64 size;
|
||||||
|
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
|
||||||
|
void *context;
|
||||||
|
int contextlen;
|
||||||
|
#endif
|
||||||
u32 rdattr_err;
|
u32 rdattr_err;
|
||||||
bool contextsupport;
|
bool contextsupport;
|
||||||
bool ignore_crossmnt;
|
bool ignore_crossmnt;
|
||||||
|
@ -3334,6 +3338,15 @@ static __be32 nfsd4_encode_fattr4_suppattr_exclcreat(struct xdr_stream *xdr,
|
||||||
return nfsd4_encode_bitmap4(xdr, supp[0], supp[1], supp[2]);
|
return nfsd4_encode_bitmap4(xdr, supp[0], supp[1], supp[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
|
||||||
|
static __be32 nfsd4_encode_fattr4_sec_label(struct xdr_stream *xdr,
|
||||||
|
const struct nfsd4_fattr_args *args)
|
||||||
|
{
|
||||||
|
return nfsd4_encode_security_label(xdr, args->rqstp,
|
||||||
|
args->context, args->contextlen);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: @fhp can be NULL; in this case, we might have to compose the filehandle
|
* Note: @fhp can be NULL; in this case, we might have to compose the filehandle
|
||||||
* ourselves.
|
* ourselves.
|
||||||
|
@ -3354,10 +3367,6 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
|
||||||
int attrlen_offset;
|
int attrlen_offset;
|
||||||
__be32 status;
|
__be32 status;
|
||||||
int err;
|
int err;
|
||||||
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
|
|
||||||
void *context = NULL;
|
|
||||||
int contextlen;
|
|
||||||
#endif
|
|
||||||
struct nfsd4_compoundres *resp = rqstp->rq_resp;
|
struct nfsd4_compoundres *resp = rqstp->rq_resp;
|
||||||
u32 minorversion = resp->cstate.minorversion;
|
u32 minorversion = resp->cstate.minorversion;
|
||||||
struct path path = {
|
struct path path = {
|
||||||
|
@ -3436,11 +3445,12 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
|
||||||
args.contextsupport = false;
|
args.contextsupport = false;
|
||||||
|
|
||||||
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
|
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
|
||||||
|
args.context = NULL;
|
||||||
if ((bmval2 & FATTR4_WORD2_SECURITY_LABEL) ||
|
if ((bmval2 & FATTR4_WORD2_SECURITY_LABEL) ||
|
||||||
bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) {
|
bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) {
|
||||||
if (exp->ex_flags & NFSEXP_SECURITY_LABEL)
|
if (exp->ex_flags & NFSEXP_SECURITY_LABEL)
|
||||||
err = security_inode_getsecctx(d_inode(dentry),
|
err = security_inode_getsecctx(d_inode(dentry),
|
||||||
&context, &contextlen);
|
&args.context, &args.contextlen);
|
||||||
else
|
else
|
||||||
err = -EOPNOTSUPP;
|
err = -EOPNOTSUPP;
|
||||||
args.contextsupport = (err == 0);
|
args.contextsupport = (err == 0);
|
||||||
|
@ -3719,8 +3729,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
|
||||||
|
|
||||||
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
|
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
|
||||||
if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) {
|
if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) {
|
||||||
status = nfsd4_encode_security_label(xdr, rqstp, context,
|
status = nfsd4_encode_fattr4_sec_label(xdr, &args);
|
||||||
contextlen);
|
|
||||||
if (status)
|
if (status)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -3739,8 +3748,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
|
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
|
||||||
if (context)
|
if (args.context)
|
||||||
security_release_secctx(context, contextlen);
|
security_release_secctx(args.context, args.contextlen);
|
||||||
#endif /* CONFIG_NFSD_V4_SECURITY_LABEL */
|
#endif /* CONFIG_NFSD_V4_SECURITY_LABEL */
|
||||||
kfree(args.acl);
|
kfree(args.acl);
|
||||||
if (tempfh) {
|
if (tempfh) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue