cregit-Linux how code gets into the kernel

Release 4.10 fs/nfsd/nfs4proc.c

Directory: fs/nfsd
/*
 *  Server-side procedures for NFSv4.
 *
 *  Copyright (c) 2002 The Regents of the University of Michigan.
 *  All rights reserved.
 *
 *  Kendrick Smith <kmsmith@umich.edu>
 *  Andy Adamson   <andros@umich.edu>
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *  3. Neither the name of the University nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
 *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 *  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#include <linux/file.h>
#include <linux/falloc.h>
#include <linux/slab.h>

#include "idmap.h"
#include "cache.h"
#include "xdr4.h"
#include "vfs.h"
#include "current_stateid.h"
#include "netns.h"
#include "acl.h"
#include "pnfs.h"
#include "trace.h"

#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
#include <linux/security.h>


static inline void nfsd4_security_inode_setsecctx(struct svc_fh *resfh, struct xdr_netobj *label, u32 *bmval) { struct inode *inode = d_inode(resfh->fh_dentry); int status; inode_lock(inode); status = security_inode_setsecctx(resfh->fh_dentry, label->data, label->len); inode_unlock(inode); if (status) /* * XXX: We should really fail the whole open, but we may * already have created a new file, so it may be too * late. For now this seems the least of evils: */ bmval[2] &= ~FATTR4_WORD2_SECURITY_LABEL; return; }

Contributors

PersonTokensPropCommitsCommitProp
david quigleydavid quigley7293.51%133.33%
david howellsdavid howells33.90%133.33%
al viroal viro22.60%133.33%
Total77100.00%3100.00%

#else
static inline void nfsd4_security_inode_setsecctx(struct svc_fh *resfh, struct xdr_netobj *label, u32 *bmval) { }

Contributors

PersonTokensPropCommitsCommitProp
david quigleydavid quigley20100.00%1100.00%
Total20100.00%1100.00%

#endif #define NFSDDBG_FACILITY NFSDDBG_PROC static u32 nfsd_attrmask[] = { NFSD_WRITEABLE_ATTRS_WORD0, NFSD_WRITEABLE_ATTRS_WORD1, NFSD_WRITEABLE_ATTRS_WORD2 }; static u32 nfsd41_ex_attrmask[] = { NFSD_SUPPATTR_EXCLCREAT_WORD0, NFSD_SUPPATTR_EXCLCREAT_WORD1, NFSD_SUPPATTR_EXCLCREAT_WORD2 };
static __be32 check_attr_support(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, u32 *bmval, u32 *writable) { struct dentry *dentry = cstate->current_fh.fh_dentry; if (!nfsd_attrs_supported(cstate->minorversion, bmval)) return nfserr_attrnotsupp; if ((bmval[0] & FATTR4_WORD0_ACL) && !IS_POSIXACL(d_inode(dentry))) return nfserr_attrnotsupp; if (writable && !bmval_is_subset(bmval, writable)) return nfserr_inval; if (writable && (bmval[2] & FATTR4_WORD2_MODE_UMASK) && (bmval[1] & FATTR4_WORD1_MODE)) return nfserr_inval; return nfs_ok; }

Contributors

PersonTokensPropCommitsCommitProp
yu zhiguoyu zhiguo7665.52%125.00%
andreas gruenbacherandreas gruenbacher2521.55%125.00%
j. bruce fieldsj. bruce fields1210.34%125.00%
david howellsdavid howells32.59%125.00%
Total116100.00%4100.00%


static __be32 nfsd4_check_open_attributes(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_open *open) { __be32 status = nfs_ok; if (open->op_create == NFS4_OPEN_CREATE) { if (open->op_createmode == NFS4_CREATE_UNCHECKED || open->op_createmode == NFS4_CREATE_GUARDED) status = check_attr_support(rqstp, cstate, open->op_bmval, nfsd_attrmask); else if (open->op_createmode == NFS4_CREATE_EXCLUSIVE4_1) status = check_attr_support(rqstp, cstate, open->op_bmval, nfsd41_ex_attrmask); } return status; }

Contributors

PersonTokensPropCommitsCommitProp
yu zhiguoyu zhiguo92100.00%1100.00%
Total92100.00%1100.00%


static int is_create_with_attrs(struct nfsd4_open *open) { return open->op_create == NFS4_OPEN_CREATE && (open->op_createmode == NFS4_CREATE_UNCHECKED || open->op_createmode == NFS4_CREATE_GUARDED || open->op_createmode == NFS4_CREATE_EXCLUSIVE4_1); }

Contributors

PersonTokensPropCommitsCommitProp
yu zhiguoyu zhiguo3797.37%150.00%
neil brownneil brown12.63%150.00%
Total38100.00%2100.00%

/* * if error occurs when setting the acl, just clear the acl bit * in the returned attr bitmap. */
static void do_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfs4_acl *acl, u32 *bmval) { __be32 status; status = nfsd4_set_nfs4_acl(rqstp, fhp, acl); if (status) /* * We should probably fail the whole open at this point, * but we've already created the file, so it's too late; * So this seems the least of evils: */ bmval[0] &= ~FATTR4_WORD0_ACL; }

Contributors

PersonTokensPropCommitsCommitProp
yu zhiguoyu zhiguo52100.00%1100.00%
Total52100.00%1100.00%


static inline void fh_dup2(struct svc_fh *dst, struct svc_fh *src) { fh_put(dst); dget(src->fh_dentry); if (src->fh_export) exp_get(src->fh_export); *dst = *src; }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton4695.83%133.33%
yu zhiguoyu zhiguo12.08%133.33%
kinglong meekinglong mee12.08%133.33%
Total48100.00%3100.00%


static __be32 do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open, int accmode) { __be32 status; if (open->op_truncate && !(open->op_share_access & NFS4_SHARE_ACCESS_WRITE)) return nfserr_inval; accmode |= NFSD_MAY_READ_IF_EXEC; if (open->op_share_access & NFS4_SHARE_ACCESS_READ) accmode |= NFSD_MAY_READ; if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) accmode |= (NFSD_MAY_WRITE | NFSD_MAY_TRUNC); if (open->op_share_deny & NFS4_SHARE_DENY_READ) accmode |= NFSD_MAY_WRITE; status = fh_verify(rqstp, current_fh, S_IFREG, accmode); return status; }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton7975.24%225.00%
j. bruce fieldsj. bruce fields2019.05%450.00%
miklos szeredimiklos szeredi43.81%112.50%
al viroal viro21.90%112.50%
Total105100.00%8100.00%


static __be32 nfsd_check_obj_isreg(struct svc_fh *fh) { umode_t mode = d_inode(fh->fh_dentry)->i_mode; if (S_ISREG(mode)) return nfs_ok; if (S_ISDIR(mode)) return nfserr_isdir; /* * Using err_symlink as our catch-all case may look odd; but * there's no other obvious error for this case in 4.0, and we * happen to know that it will cause the linux v4 client to do * the right thing on attempts to open something other than a * regular file. */ return nfserr_symlink; }

Contributors

PersonTokensPropCommitsCommitProp
j. bruce fieldsj. bruce fields4493.62%150.00%
david howellsdavid howells36.38%150.00%
Total47100.00%2100.00%


static void nfsd4_set_open_owner_reply_cache(struct nfsd4_compound_state *cstate, struct nfsd4_open *open, struct svc_fh *resfh) { if (nfsd4_has_session(cstate)) return; fh_copy_shallow(&open->op_openowner->oo_owner.so_replay.rp_openfh, &resfh->fh_handle); }

Contributors

PersonTokensPropCommitsCommitProp
j. bruce fieldsj. bruce fields48100.00%1100.00%
Total48100.00%1100.00%


static __be32 do_open_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_open *open, struct svc_fh **resfh) { struct svc_fh *current_fh = &cstate->current_fh; int accmode; __be32 status; *resfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL); if (!*resfh) return nfserr_jukebox; fh_init(*resfh, NFS4_FHSIZE); open->op_truncate = 0; if (open->op_create) { /* FIXME: check session persistence and pnfs flags. * The nfsv4.1 spec requires the following semantics: * * Persistent | pNFS | Server REQUIRED | Client Allowed * Reply Cache | server | | * -------------+--------+-----------------+-------------------- * no | no | EXCLUSIVE4_1 | EXCLUSIVE4_1 * | | | (SHOULD) * | | and EXCLUSIVE4 | or EXCLUSIVE4 * | | | (SHOULD NOT) * no | yes | EXCLUSIVE4_1 | EXCLUSIVE4_1 * yes | no | GUARDED4 | GUARDED4 * yes | yes | GUARDED4 | GUARDED4 */ /* * Note: create modes (UNCHECKED,GUARDED...) are the same * in NFSv4 as in v3 except EXCLUSIVE4_1. */ status = do_nfsd_create(rqstp, current_fh, open->op_fname.data, open->op_fname.len, &open->op_iattr, *resfh, open->op_createmode, (u32 *)open->op_verf.data, &open->op_truncate, &open->op_created); if (!status && open->op_label.len) nfsd4_security_inode_setsecctx(*resfh, &open->op_label, open->op_bmval); /* * Following rfc 3530 14.2.16, and rfc 5661 18.16.4 * use the returned bitmask to indicate which attributes * we used to store the verifier: */ if (nfsd_create_is_exclusive(open->op_createmode) && status == 0) open->op_bmval[1] |= (FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_MODIFY); } else /* * Note this may exit with the parent still locked. * We will hold the lock until nfsd4_open's final * lookup, to prevent renames or unlinks until we've had * a chance to an acquire a delegation if appropriate. */ status = nfsd_lookup(rqstp, current_fh, open->op_fname.data, open->op_fname.len, *resfh); if (status) goto out; status = nfsd_check_obj_isreg(*resfh); if (status) goto out; if (is_create_with_attrs(open) && open->op_acl != NULL) do_set_nfs4_acl(rqstp, *resfh, open->op_acl, open->op_bmval); nfsd4_set_open_owner_reply_cache(cstate, open, *resfh); accmode = NFSD_MAY_NOP; if (open->op_created || open->op_claim_type == NFS4_OPEN_CLAIM_DELEGATE_CUR) accmode |= NFSD_MAY_OWNER_OVERRIDE; status = do_open_permission(rqstp, *resfh, open, accmode); set_change_info(&open->op_cinfo, current_fh); out: return status; }

Contributors

PersonTokensPropCommitsCommitProp
neil brownneil brown12738.25%312.50%
j. bruce fieldsj. bruce fields9929.82%1145.83%
yu zhiguoyu zhiguo288.43%14.17%
david quigleydavid quigley257.53%14.17%
jeff laytonjeff layton226.63%14.17%
andrew mortonandrew morton195.72%28.33%
kinglong meekinglong mee51.51%14.17%
al viroal viro20.60%14.17%
trond myklebusttrond myklebust20.60%14.17%
mi jinlongmi jinlong20.60%14.17%
benny halevybenny halevy10.30%14.17%
Total332100.00%24100.00%


static __be32 do_open_fhandle(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_open *open) { struct svc_fh *current_fh = &cstate->current_fh; __be32 status; int accmode = 0; /* We don't know the target directory, and therefore can not * set the change info */ memset(&open->op_cinfo, 0, sizeof(struct nfsd4_change_info)); nfsd4_set_open_owner_reply_cache(cstate, open, current_fh); open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && (open->op_iattr.ia_size == 0); /* * In the delegation case, the client is telling us about an * open that it *already* performed locally, some time ago. We * should let it succeed now if possible. * * In the case of a CLAIM_FH open, on the other hand, the client * may be counting on us to enforce permissions (the Linux 4.1 * client uses this for normal opens, for example). */ if (open->op_claim_type == NFS4_OPEN_CLAIM_DELEG_CUR_FH) accmode = NFSD_MAY_OWNER_OVERRIDE; status = do_open_permission(rqstp, current_fh, open, accmode); return status; }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton5849.15%222.22%
j. bruce fieldsj. bruce fields3529.66%333.33%
neil brownneil brown2319.49%333.33%
al viroal viro21.69%111.11%
Total118100.00%9100.00%


static void copy_clientid(clientid_t *clid, struct nfsd4_session *session) { struct nfsd4_sessionid *sid = (struct nfsd4_sessionid *)session->se_sessionid.data; clid->cl_boot = sid->clientid.cl_boot; clid->cl_id = sid->clientid.cl_id; }

Contributors

PersonTokensPropCommitsCommitProp
andy adamsonandy adamson5098.04%150.00%
neil brownneil brown11.96%150.00%
Total51100.00%2100.00%


static __be32 nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_open *open) { __be32 status; struct svc_fh *resfh = NULL; struct net *net = SVC_NET(rqstp); struct nfsd_net *nn = net_generic(net, nfsd_net_id); dprintk("NFSD: nfsd4_open filename %.*s op_openowner %p\n", (int)open->op_fname.len, open->op_fname.data, open->op_openowner); /* This check required by spec. */ if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL) return nfserr_inval; open->op_created = 0; /* * RFC5661 18.51.3 * Before RECLAIM_COMPLETE done, server should deny new lock */ if (nfsd4_has_session(cstate) && !test_bit(NFSD4_CLIENT_RECLAIM_COMPLETE, &cstate->session->se_client->cl_flags) && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) return nfserr_grace; if (nfsd4_has_session(cstate)) copy_clientid(&open->op_clientid, cstate->session); /* check seqid for replay. set nfs4_owner */ status = nfsd4_process_open1(cstate, open, nn); if (status == nfserr_replay_me) { struct nfs4_replay *rp = &open->op_openowner->oo_owner.so_replay; fh_put(&cstate->current_fh); fh_copy_shallow(&cstate->current_fh.fh_handle, &rp->rp_openfh); status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); if (status) dprintk("nfsd4_open: replay failed" " restoring previous filehandle\n"); else status = nfserr_replay_me; } if (status) goto out; if (open->op_xdr_error) { status = open->op_xdr_error; goto out; } status = nfsd4_check_open_attributes(rqstp, cstate, open); if (status) goto out; /* Openowner is now set, so sequence id will get bumped. Now we need * these checks before we do any creates: */ status = nfserr_grace; if (opens_in_grace(net) && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) goto out; status = nfserr_no_grace; if (!opens_in_grace(net) && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) goto out; switch (open->op_claim_type) { case NFS4_OPEN_CLAIM_DELEGATE_CUR: case NFS4_OPEN_CLAIM_NULL: status = do_open_lookup(rqstp, cstate, open, &resfh); if (status) goto out; break; case NFS4_OPEN_CLAIM_PREVIOUS: status = nfs4_check_open_reclaim(&open->op_clientid, cstate, nn); if (status) goto out; open->op_openowner->oo_flags |= NFS4_OO_CONFIRMED; case NFS4_OPEN_CLAIM_FH: case NFS4_OPEN_CLAIM_DELEG_CUR_FH: status = do_open_fhandle(rqstp, cstate, open); if (status) goto out; resfh = &cstate->current_fh; break; case NFS4_OPEN_CLAIM_DELEG_PREV_FH: case NFS4_OPEN_CLAIM_DELEGATE_PREV: dprintk("NFSD: unsupported OPEN claim type %d\n", open->op_claim_type); status = nfserr_notsupp; goto out; default: dprintk("NFSD: Invalid OPEN claim type %d\n", open->op_claim_type); status = nfserr_inval; goto out; } /* * nfsd4_process_open2() does the actual opening of the file. If * successful, it (1) truncates the file if open->op_truncate was * set, (2) sets open->op_stateid, (3) sets open->op_delegation. */ status = nfsd4_process_open2(rqstp, resfh, open); WARN(status && open->op_created, "nfsd4_process_open2 failed to open newly-created file! status=%u\n", be32_to_cpu(status)); out: if (resfh && resfh != &cstate->current_fh) { fh_dup2(&cstate->current_fh, resfh); fh_put(resfh); kfree(resfh); } nfsd4_cleanup_open_state(cstate, open); nfsd4_bump_seqid(cstate, status); return status; }

Contributors

PersonTokensPropCommitsCommitProp
j. bruce fieldsj. bruce fields16330.13%1437.84%
neil brownneil brown14326.43%513.51%
andrew mortonandrew morton9116.82%410.81%
mi jinlongmi jinlong427.76%25.41%
stanislav kinsburskystanislav kinsbursky315.73%25.41%
jeff laytonjeff layton254.62%410.81%
andy adamsonandy adamson234.25%25.41%
yu zhiguoyu zhiguo183.33%12.70%
al viroal viro40.74%25.41%
miklos szeredimiklos szeredi10.18%12.70%
Total541100.00%37100.00%

/* * OPEN is the only seqid-mutating operation whose decoding can fail * with a seqid-mutating error (specifically, decoding of user names in * the attributes). Therefore we have to do some processing to look up * the stateowner so that we can bump the seqid. */
static __be32 nfsd4_open_omfg(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_op *op) { struct nfsd4_open *open = (struct nfsd4_open *)&op->u; if (!seqid_mutating_err(ntohl(op->status))) return op->status; if (nfsd4_has_session(cstate)) return op->status; open->op_xdr_error = op->status; return nfsd4_open(rqstp, cstate, open); }

Contributors

PersonTokensPropCommitsCommitProp
j. bruce fieldsj. bruce fields84100.00%1100.00%
Total84100.00%1100.00%

/* * filehandle-manipulating ops. */
static __be32 nfsd4_getfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct svc_fh **getfh) { if (!cstate->current_fh.fh_dentry) return nfserr_nofilehandle; *getfh = &cstate->current_fh; return nfs_ok; }

Contributors

PersonTokensPropCommitsCommitProp
neil brownneil brown3168.89%125.00%
j. bruce fieldsj. bruce fields1328.89%250.00%
al viroal viro12.22%125.00%
Total45100.00%4100.00%


static __be32 nfsd4_putfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_putfh *putfh) { fh_put(&cstate->current_fh); cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen; memcpy(&cstate->current_fh.fh_handle.fh_base, putfh->pf_fhval, putfh->pf_fhlen); return fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_BYPASS_GSS); }

Contributors

PersonTokensPropCommitsCommitProp
neil brownneil brown6078.95%125.00%
j. bruce fieldsj. bruce fields1519.74%250.00%
al viroal viro11.32%125.00%
Total76100.00%4100.00%


static __be32 nfsd4_putrootfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, void *arg) { __be32 status; fh_put(&cstate->current_fh); status = exp_pseudoroot(rqstp, &cstate->current_fh); return status; }

Contributors

PersonTokensPropCommitsCommitProp
neil brownneil brown2554.35%120.00%
j. bruce fieldsj. bruce fields1226.09%240.00%
andrew mortonandrew morton715.22%120.00%
al viroal viro24.35%120.00%
Total46100.00%5100.00%


static __be32 nfsd4_restorefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, void *arg) { if (!cstate->save_fh.fh_dentry) return nfserr_restorefh; fh_dup2(&cstate->current_fh, &cstate->save_fh); if (HAS_STATE_ID(cstate, SAVED_STATE_ID_FLAG)) { memcpy(&cstate->current_stateid, &cstate->save_stateid, sizeof(stateid_t)); SET_STATE_ID(cstate, CURRENT_STATE_ID_FLAG); } return nfs_ok; }

Contributors

PersonTokensPropCommitsCommitProp
tigran mkrtchyantigran mkrtchyan3642.86%228.57%
neil brownneil brown2630.95%114.29%
j. bruce fieldsj. bruce fields2023.81%228.57%
andrew mortonandrew morton11.19%114.29%
al viroal viro11.19%114.29%
Total84100.00%7100.00%


static __be32 nfsd4_savefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, void *arg) { if (!cstate->current_fh.fh_dentry) return nfserr_nofilehandle; fh_dup2(&cstate->save_fh, &cstate->current_fh); if (HAS_STATE_ID(cstate, CURRENT_STATE_ID_FLAG)) { memcpy(&cstate->save_stateid, &cstate->current_stateid, sizeof(stateid_t)); SET_STATE_ID(cstate, SAVED_STATE_ID_FLAG); } return nfs_ok; }

Contributors

PersonTokensPropCommitsCommitProp
tigran mkrtchyantigran mkrtchyan3642.86%233.33%
neil brownneil brown2732.14%116.67%
j. bruce fieldsj. bruce fields2023.81%233.33%
al viroal viro11.19%116.67%
Total84100.00%6100.00%

/* * misc nfsv4 ops */
static __be32 nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_access *access) { if (access->ac_req_access & ~NFS3_ACCESS_FULL) return nfserr_inval; access->ac_resp_access = access->ac_req_access; return nfsd_access(rqstp, &cstate->current_fh, &access->ac_resp_access, &access->ac_supported); }

Contributors

PersonTokensPropCommitsCommitProp
neil brownneil brown5690.32%133.33%
j. bruce fieldsj. bruce fields58.06%133.33%
al viroal viro11.61%133.33%
Total62100.00%3100.00%


static void gen_boot_verifier(nfs4_verifier *verifier, struct net *net) { __be32 verf[2]; struct nfsd_net *nn = net_generic(net, nfsd_net_id); /* * This is opaque to client, so no need to byte-swap. Use * __force to keep sparse happy */ verf[0] = (__force __be32)nn->nfssvc_boot.tv_sec; verf[1] = (__force __be32)nn->nfssvc_boot.tv_usec; memcpy(verifier->data, verf, sizeof(verifier->data)); }

Contributors

PersonTokensPropCommitsCommitProp
chuck leverchuck lever5670.00%133.33%
stanislav kinsburskystanislav kinsbursky2126.25%133.33%
jeff laytonjeff layton33.75%133.33%
Total80100.00%3100.00%


static __be32 nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_commit *commit) { gen_boot_verifier(&commit->co_verf, SVC_NET(rqstp)); return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset, commit->co_count); }

Contributors

PersonTokensPropCommitsCommitProp
neil brownneil brown3769.81%116.67%
j. bruce fieldsj. bruce fields611.32%233.33%
stanislav kinsburskystanislav kinsbursky59.43%116.67%
chuck leverchuck lever47.55%116.67%
al viroal viro11.89%116.67%
Total53100.00%6100.00%


static __be32 nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_create *create) { struct svc_fh resfh; __be32 status; dev_t rdev; fh_init(&resfh, NFS4_FHSIZE); status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_NOP); if (status) return status; status = check_attr_support(rqstp, cstate, create->cr_bmval, nfsd_attrmask); if (status) return status; switch (create->cr_type) { case NF4LNK: status = nfsd_symlink(rqstp, &cstate->current_fh, create->cr_name, create->cr_namelen, create->cr_data, &resfh); break; case NF4BLK: rdev = MKDEV(create->cr_specdata1, create->cr_specdata2); if (MAJOR(rdev) != create->cr_specdata1 || MINOR(rdev) != create->cr_specdata2) return nfserr_inval; status = nfsd_create(rqstp, &cstate->current_fh, create->cr_name, create->cr_namelen, &create->cr_iattr, S_IFBLK, rdev, &resfh); break; case NF4CHR: rdev = MKDEV(create->cr_specdata1, create->cr_specdata2); if (MAJOR(rdev) != create->cr_specdata1 || MINOR(rdev) != create->cr_specdata2) return nfserr_inval; status = nfsd_create(rqstp, &cstate->current_fh, create->cr_name, create->cr_namelen, &create->cr_iattr,S_IFCHR, rdev, &resfh); break; case NF4SOCK: status = nfsd_create(rqstp, &cstate->current_fh, create->cr_name, create->cr_namelen, &create->cr_iattr, S_IFSOCK, 0, &resfh); break; case NF4FIFO: status = nfsd_create(rqstp, &cstate->current_fh, create->cr_name, create->cr_namelen, &create->cr_iattr, S_IFIFO, 0, &resfh); break; case NF4DIR: create->cr_iattr.ia_valid &= ~ATTR_SIZE; status = nfsd_create(rqstp, &cstate->current_fh, create->cr_name, create->cr_namelen, &create->cr_iattr, S_IFDIR, 0, &resfh); break; default: status = nfserr_badtype; } if (status) goto out; if (create->cr_label.len) nfsd4_security_inode_setsecctx(&resfh, &create->cr_label, create->cr_bmval); if (create->cr_acl != NULL) do_set_nfs4_acl(rqstp, &resfh,