Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFSD: MKNOD should return NFSERR_BADTYPE instead of NFSERR_INVAL

A late paragraph of RFC 1813 Section 3.3.11 states:

| ... if the server does not support the target type or the
| target type is illegal, the error, NFS3ERR_BADTYPE, should
| be returned. Note that NF3REG, NF3DIR, and NF3LNK are
| illegal types for MKNOD.

The Linux NFS server incorrectly returns NFSERR_INVAL in these
cases.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

authored by

Chuck Lever and committed by
J. Bruce Fields
66d60e3a d321ff58

+1 -5
+1 -5
fs/nfsd/nfs3proc.c
··· 316 316 fh_copy(&resp->dirfh, &argp->fh); 317 317 fh_init(&resp->fh, NFS3_FHSIZE); 318 318 319 - if (argp->ftype == 0 || argp->ftype >= NF3BAD) { 320 - resp->status = nfserr_inval; 321 - goto out; 322 - } 323 319 if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) { 324 320 rdev = MKDEV(argp->major, argp->minor); 325 321 if (MAJOR(rdev) != argp->major || ··· 324 328 goto out; 325 329 } 326 330 } else if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO) { 327 - resp->status = nfserr_inval; 331 + resp->status = nfserr_badtype; 328 332 goto out; 329 333 } 330 334