Skip to content

Commit

Permalink
NFSv4/pnfs: Ensure pnfs_parse_lgopen() won't try to parse uninitialis…
Browse files Browse the repository at this point in the history
…ed data

We need to ensure that pnfs_parse_lgopen() doesn't try to parse a
struct nfs4_layoutget_res that was not filled by a successful call
to decode_layoutget(). This can happen if we performed a cached open,
or if either the OP_ACCESS or OP_GETATTR operations preceding the
OP_LAYOUTGET in the compound returned an error.

By initialising the 'status' field to NFS4ERR_DELAY, we ensure that
pnfs_parse_lgopen() won't try to interpret the structure.

Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
trondmypd authored and Trond Myklebust committed May 31, 2018
1 parent 30ae241 commit d49e0d5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/nfs/pnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,8 @@ pnfs_alloc_init_layoutget_args(struct inode *ino,
lgp->args.layout.pglen = max_pages * PAGE_SIZE;
lgp->res.layoutp = &lgp->args.layout;


/* Don't confuse uninitialised result and success */
lgp->res.status = -NFS4ERR_DELAY;

lgp->args.minlength = PAGE_SIZE;
if (lgp->args.minlength > range->length)
Expand Down

0 comments on commit d49e0d5

Please sign in to comment.