1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-11 09:50:12 +00:00

Copy all bits of a file handle in case there is padding in the structure.

At least on x86, fhandle_t is a packed structure, so I believe an
assignment will copy all the bits. However, for some current/future
architectures, there might be padding in the structure that doesn't get
copied via an assignment.
Since NFS assumes a file handle is an opaque blob of bits that can be
compared via memcmp()/bcmp(), all the bits including any padding must be
copied.
This patch replaces the assignments with a call to a byte copy function.
Spotted during code inspection.
This commit is contained in:
Rick Macklem 2018-08-05 19:21:50 +00:00
parent 8750586c61
commit 25705dd5d0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=337357
2 changed files with 5 additions and 5 deletions

View File

@ -3954,7 +3954,7 @@ nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap, struct ucred *cred,
tdsc->p = p;
tdsc->pf = tpf;
tdsc->createva = *vap;
tdsc->fh = fh;
NFSBCOPY(&fh, &tdsc->fh, sizeof(fh));
tdsc->va = va;
tdsc->dvp = dvp[i];
tdsc->done = 0;
@ -5014,7 +5014,7 @@ nfsrv_writedsrpc(fhandle_t *fhp, off_t off, int len, struct ucred *cred,
error = 0;
for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) {
tdrpc->done = 0;
tdrpc->fh = *fhp;
NFSBCOPY(fhp, &tdrpc->fh, sizeof(*fhp));
tdrpc->off = off;
tdrpc->len = len;
tdrpc->nmp = *nmpp;
@ -5200,7 +5200,7 @@ nfsrv_setattrdsrpc(fhandle_t *fhp, struct ucred *cred, NFSPROC_T *p,
for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) {
tdrpc->done = 0;
tdrpc->inprog = 0;
tdrpc->fh = *fhp;
NFSBCOPY(fhp, &tdrpc->fh, sizeof(*fhp));
tdrpc->nmp = *nmpp;
tdrpc->vp = vp;
tdrpc->cred = cred;
@ -5348,7 +5348,7 @@ nfsrv_setacldsrpc(fhandle_t *fhp, struct ucred *cred, NFSPROC_T *p,
for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) {
tdrpc->done = 0;
tdrpc->inprog = 0;
tdrpc->fh = *fhp;
NFSBCOPY(fhp, &tdrpc->fh, sizeof(*fhp));
tdrpc->nmp = *nmpp;
tdrpc->vp = vp;
tdrpc->cred = cred;

View File

@ -6907,7 +6907,7 @@ nfsrv_recalloldlayout(NFSPROC_T *p)
lyp->lay_stateid.seqid = 1;
clientid = lyp->lay_clientid;
stateid = lyp->lay_stateid;
fh = lyp->lay_fh;
NFSBCOPY(&lyp->lay_fh, &fh, sizeof(fh));
laytype = lyp->lay_type;
break;
}