License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Process version 3 NFS requests.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/ext2_fs.h>
|
2009-01-11 19:13:53 +00:00
|
|
|
#include <linux/magic.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-12-03 18:30:56 +00:00
|
|
|
#include "cache.h"
|
|
|
|
#include "xdr3.h"
|
2009-11-04 23:12:35 +00:00
|
|
|
#include "vfs.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#define NFSDDBG_FACILITY NFSDDBG_PROC
|
|
|
|
|
|
|
|
#define RETURN_STATUS(st) { resp->status = (st); return (st); }
|
|
|
|
|
|
|
|
static int nfs3_ftypes[] = {
|
|
|
|
0, /* NF3NON */
|
|
|
|
S_IFREG, /* NF3REG */
|
|
|
|
S_IFDIR, /* NF3DIR */
|
|
|
|
S_IFBLK, /* NF3BLK */
|
|
|
|
S_IFCHR, /* NF3CHR */
|
|
|
|
S_IFLNK, /* NF3LNK */
|
|
|
|
S_IFSOCK, /* NF3SOCK */
|
|
|
|
S_IFIFO, /* NF3FIFO */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NULL call.
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_null(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
return nfs_ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a file's attributes
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_getattr(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd_fhandle *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_attrstat *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: GETATTR(3) %s\n",
|
2006-01-06 08:19:58 +00:00
|
|
|
SVCFH_fmt(&argp->fh));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
2008-08-07 17:00:20 +00:00
|
|
|
nfserr = fh_verify(rqstp, &resp->fh, 0,
|
|
|
|
NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
|
2006-01-06 08:19:58 +00:00
|
|
|
if (nfserr)
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
|
2013-01-24 07:18:08 +00:00
|
|
|
nfserr = fh_getattr(&resp->fh, &resp->stat);
|
2006-01-06 08:19:58 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set a file's attributes
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_setattr(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_sattrargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_attrstat *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: SETATTR(3) %s\n",
|
|
|
|
SVCFH_fmt(&argp->fh));
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
nfserr = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,
|
|
|
|
argp->check_guard, argp->guardtime);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look up a path name component
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_lookup(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_diropargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: LOOKUP(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
fh_copy(&resp->dirfh, &argp->fh);
|
|
|
|
fh_init(&resp->fh, NFS3_FHSIZE);
|
|
|
|
|
|
|
|
nfserr = nfsd_lookup(rqstp, &resp->dirfh,
|
|
|
|
argp->name,
|
|
|
|
argp->len,
|
|
|
|
&resp->fh);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check file access
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_access(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_accessargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_accessres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: ACCESS(3) %s 0x%x\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->access);
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
resp->access = argp->access;
|
|
|
|
nfserr = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a symlink.
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_readlink(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_readlinkargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_readlinkres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh));
|
|
|
|
|
|
|
|
/* Read the symlink. */
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
resp->len = NFS3_MAXPATHLEN;
|
|
|
|
nfserr = nfsd_readlink(rqstp, &resp->fh, argp->buffer, &resp->len);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a portion of a file.
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_read(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_readargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_readres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2006-10-04 09:15:47 +00:00
|
|
|
u32 max_blocksize = svc_max_payload(rqstp);
|
2016-03-22 14:28:36 +00:00
|
|
|
unsigned long cnt = min(argp->count, max_blocksize);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-11-29 20:28:10 +00:00
|
|
|
dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
(unsigned long) argp->count,
|
2010-11-29 20:28:10 +00:00
|
|
|
(unsigned long long) argp->offset);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Obtain buffer pointer for payload.
|
|
|
|
* 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof)
|
|
|
|
* + 1 (xdr opaque byte count) = 26
|
|
|
|
*/
|
2016-03-22 14:28:36 +00:00
|
|
|
resp->count = cnt;
|
2007-05-09 09:34:50 +00:00
|
|
|
svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
2010-07-30 15:33:32 +00:00
|
|
|
nfserr = nfsd_read(rqstp, &resp->fh,
|
2005-04-16 22:20:36 +00:00
|
|
|
argp->offset,
|
2006-10-04 09:15:47 +00:00
|
|
|
rqstp->rq_vec, argp->vlen,
|
2019-08-26 17:03:11 +00:00
|
|
|
&resp->count,
|
|
|
|
&resp->eof);
|
2005-04-16 22:20:36 +00:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write data to a file
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_write(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_writeargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_writeres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2009-03-06 01:16:14 +00:00
|
|
|
unsigned long cnt = argp->len;
|
2018-03-27 14:54:07 +00:00
|
|
|
unsigned int nvecs;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-11-29 20:28:10 +00:00
|
|
|
dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
2010-11-29 20:28:10 +00:00
|
|
|
(unsigned long long) argp->offset,
|
2005-04-16 22:20:36 +00:00
|
|
|
argp->stable? " stable" : "");
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
resp->committed = argp->stable;
|
2018-07-27 15:19:05 +00:00
|
|
|
nvecs = svc_fill_write_vector(rqstp, rqstp->rq_arg.pages,
|
|
|
|
&argp->first, cnt);
|
2018-03-27 14:54:07 +00:00
|
|
|
if (!nvecs)
|
|
|
|
RETURN_STATUS(nfserr_io);
|
2016-12-31 13:00:13 +00:00
|
|
|
nfserr = nfsd_write(rqstp, &resp->fh, argp->offset,
|
2018-03-27 14:54:07 +00:00
|
|
|
rqstp->rq_vec, nvecs, &cnt,
|
2020-01-06 18:40:37 +00:00
|
|
|
resp->committed, resp->verf);
|
2009-03-06 01:16:14 +00:00
|
|
|
resp->count = cnt;
|
2005-04-16 22:20:36 +00:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* With NFSv3, CREATE processing is a lot easier than with NFSv2.
|
|
|
|
* At least in theory; we'll see how it fares in practice when the
|
|
|
|
* first reports about SunOS compatibility problems start to pour in...
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_create(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_createargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
2005-04-16 22:20:36 +00:00
|
|
|
svc_fh *dirfhp, *newfhp = NULL;
|
|
|
|
struct iattr *attr;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: CREATE(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
dirfhp = fh_copy(&resp->dirfh, &argp->fh);
|
|
|
|
newfhp = fh_init(&resp->fh, NFS3_FHSIZE);
|
|
|
|
attr = &argp->attrs;
|
|
|
|
|
|
|
|
/* Unfudge the mode bits */
|
|
|
|
attr->ia_mode &= ~S_IFMT;
|
|
|
|
if (!(attr->ia_valid & ATTR_MODE)) {
|
|
|
|
attr->ia_valid |= ATTR_MODE;
|
|
|
|
attr->ia_mode = S_IFREG;
|
|
|
|
} else {
|
|
|
|
attr->ia_mode = (attr->ia_mode & ~S_IFMT) | S_IFREG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now create the file and set attributes */
|
2011-04-20 09:06:25 +00:00
|
|
|
nfserr = do_nfsd_create(rqstp, dirfhp, argp->name, argp->len,
|
2005-04-16 22:20:36 +00:00
|
|
|
attr, newfhp,
|
2012-07-27 19:50:11 +00:00
|
|
|
argp->createmode, (u32 *)argp->verf, NULL, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make directory. This operation is not idempotent.
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_mkdir(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_createargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: MKDIR(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
argp->attrs.ia_valid &= ~ATTR_SIZE;
|
|
|
|
fh_copy(&resp->dirfh, &argp->fh);
|
|
|
|
fh_init(&resp->fh, NFS3_FHSIZE);
|
|
|
|
nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
|
|
|
|
&argp->attrs, S_IFDIR, 0, &resp->fh);
|
NFSD: Fill in WCC data for REMOVE, RMDIR, MKNOD, and MKDIR
Some well-known NFSv3 clients drop their directory entry caches when
they receive replies with no WCC data. Without this data, they
employ extra READ, LOOKUP, and GETATTR requests to ensure their
directory entry caches are up to date, causing performance to suffer
needlessly.
In order to return WCC data, our server has to have both the pre-op
and the post-op attribute data on hand when a reply is XDR encoded.
The pre-op data is filled in when the incoming fh is locked, and the
post-op data is filled in when the fh is unlocked.
Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh
is not unlocked until well after the reply has been XDR encoded. This
means that encode_wcc_data() does not have wcc_data for the parent
directory, so none is returned to the client after these operations
complete.
By unlocking the parent directory fh immediately after the internal
operations for each NFS procedure is complete, the post-op data is
filled in before XDR encoding starts, so it can be returned to the
client properly.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
2010-07-06 20:53:34 +00:00
|
|
|
fh_unlock(&resp->dirfh);
|
2005-04-16 22:20:36 +00:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_symlink(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_symlinkargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-03-27 14:54:21 +00:00
|
|
|
if (argp->tlen == 0)
|
|
|
|
RETURN_STATUS(nfserr_inval);
|
|
|
|
if (argp->tlen > NFS3_MAXPATHLEN)
|
|
|
|
RETURN_STATUS(nfserr_nametoolong);
|
|
|
|
|
|
|
|
argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first,
|
2018-07-27 15:19:10 +00:00
|
|
|
page_address(rqstp->rq_arg.pages[0]),
|
2018-03-27 14:54:21 +00:00
|
|
|
argp->tlen);
|
|
|
|
if (IS_ERR(argp->tname))
|
|
|
|
RETURN_STATUS(nfserrno(PTR_ERR(argp->tname)));
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->ffh),
|
|
|
|
argp->flen, argp->fname,
|
|
|
|
argp->tlen, argp->tname);
|
|
|
|
|
|
|
|
fh_copy(&resp->dirfh, &argp->ffh);
|
|
|
|
fh_init(&resp->fh, NFS3_FHSIZE);
|
|
|
|
nfserr = nfsd_symlink(rqstp, &resp->dirfh, argp->fname, argp->flen,
|
2014-07-01 09:48:02 +00:00
|
|
|
argp->tname, &resp->fh);
|
2018-07-27 15:19:10 +00:00
|
|
|
kfree(argp->tname);
|
2005-04-16 22:20:36 +00:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make socket/fifo/device.
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_mknod(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_mknodargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_diropres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
|
|
|
int type;
|
2005-04-16 22:20:36 +00:00
|
|
|
dev_t rdev = 0;
|
|
|
|
|
|
|
|
dprintk("nfsd: MKNOD(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
fh_copy(&resp->dirfh, &argp->fh);
|
|
|
|
fh_init(&resp->fh, NFS3_FHSIZE);
|
|
|
|
|
|
|
|
if (argp->ftype == 0 || argp->ftype >= NF3BAD)
|
|
|
|
RETURN_STATUS(nfserr_inval);
|
|
|
|
if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) {
|
|
|
|
rdev = MKDEV(argp->major, argp->minor);
|
|
|
|
if (MAJOR(rdev) != argp->major ||
|
|
|
|
MINOR(rdev) != argp->minor)
|
|
|
|
RETURN_STATUS(nfserr_inval);
|
|
|
|
} else
|
|
|
|
if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO)
|
|
|
|
RETURN_STATUS(nfserr_inval);
|
|
|
|
|
|
|
|
type = nfs3_ftypes[argp->ftype];
|
|
|
|
nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
|
|
|
|
&argp->attrs, type, rdev, &resp->fh);
|
NFSD: Fill in WCC data for REMOVE, RMDIR, MKNOD, and MKDIR
Some well-known NFSv3 clients drop their directory entry caches when
they receive replies with no WCC data. Without this data, they
employ extra READ, LOOKUP, and GETATTR requests to ensure their
directory entry caches are up to date, causing performance to suffer
needlessly.
In order to return WCC data, our server has to have both the pre-op
and the post-op attribute data on hand when a reply is XDR encoded.
The pre-op data is filled in when the incoming fh is locked, and the
post-op data is filled in when the fh is unlocked.
Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh
is not unlocked until well after the reply has been XDR encoded. This
means that encode_wcc_data() does not have wcc_data for the parent
directory, so none is returned to the client after these operations
complete.
By unlocking the parent directory fh immediately after the internal
operations for each NFS procedure is complete, the post-op data is
filled in before XDR encoding starts, so it can be returned to the
client properly.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
2010-07-06 20:53:34 +00:00
|
|
|
fh_unlock(&resp->dirfh);
|
2005-04-16 22:20:36 +00:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove file/fifo/socket etc.
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_remove(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_diropargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_attrstat *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: REMOVE(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
/* Unlink. -S_IFDIR means file must not be a directory */
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
nfserr = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, argp->name, argp->len);
|
NFSD: Fill in WCC data for REMOVE, RMDIR, MKNOD, and MKDIR
Some well-known NFSv3 clients drop their directory entry caches when
they receive replies with no WCC data. Without this data, they
employ extra READ, LOOKUP, and GETATTR requests to ensure their
directory entry caches are up to date, causing performance to suffer
needlessly.
In order to return WCC data, our server has to have both the pre-op
and the post-op attribute data on hand when a reply is XDR encoded.
The pre-op data is filled in when the incoming fh is locked, and the
post-op data is filled in when the fh is unlocked.
Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh
is not unlocked until well after the reply has been XDR encoded. This
means that encode_wcc_data() does not have wcc_data for the parent
directory, so none is returned to the client after these operations
complete.
By unlocking the parent directory fh immediately after the internal
operations for each NFS procedure is complete, the post-op data is
filled in before XDR encoding starts, so it can be returned to the
client properly.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
2010-07-06 20:53:34 +00:00
|
|
|
fh_unlock(&resp->fh);
|
2005-04-16 22:20:36 +00:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove a directory
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_rmdir(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_diropargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_attrstat *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: RMDIR(3) %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->len,
|
|
|
|
argp->name);
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
nfserr = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, argp->name, argp->len);
|
NFSD: Fill in WCC data for REMOVE, RMDIR, MKNOD, and MKDIR
Some well-known NFSv3 clients drop their directory entry caches when
they receive replies with no WCC data. Without this data, they
employ extra READ, LOOKUP, and GETATTR requests to ensure their
directory entry caches are up to date, causing performance to suffer
needlessly.
In order to return WCC data, our server has to have both the pre-op
and the post-op attribute data on hand when a reply is XDR encoded.
The pre-op data is filled in when the incoming fh is locked, and the
post-op data is filled in when the fh is unlocked.
Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh
is not unlocked until well after the reply has been XDR encoded. This
means that encode_wcc_data() does not have wcc_data for the parent
directory, so none is returned to the client after these operations
complete.
By unlocking the parent directory fh immediately after the internal
operations for each NFS procedure is complete, the post-op data is
filled in before XDR encoding starts, so it can be returned to the
client properly.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
2010-07-06 20:53:34 +00:00
|
|
|
fh_unlock(&resp->fh);
|
2005-04-16 22:20:36 +00:00
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_rename(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_renameargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_renameres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: RENAME(3) %s %.*s ->\n",
|
|
|
|
SVCFH_fmt(&argp->ffh),
|
|
|
|
argp->flen,
|
|
|
|
argp->fname);
|
|
|
|
dprintk("nfsd: -> %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->tfh),
|
|
|
|
argp->tlen,
|
|
|
|
argp->tname);
|
|
|
|
|
|
|
|
fh_copy(&resp->ffh, &argp->ffh);
|
|
|
|
fh_copy(&resp->tfh, &argp->tfh);
|
|
|
|
nfserr = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen,
|
|
|
|
&resp->tfh, argp->tname, argp->tlen);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_link(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_linkargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_linkres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: LINK(3) %s ->\n",
|
|
|
|
SVCFH_fmt(&argp->ffh));
|
|
|
|
dprintk("nfsd: -> %s %.*s\n",
|
|
|
|
SVCFH_fmt(&argp->tfh),
|
|
|
|
argp->tlen,
|
|
|
|
argp->tname);
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->ffh);
|
|
|
|
fh_copy(&resp->tfh, &argp->tfh);
|
|
|
|
nfserr = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen,
|
|
|
|
&resp->fh);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a portion of a directory.
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_readdir(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_readdirargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_readdirres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2019-04-04 06:57:11 +00:00
|
|
|
int count = 0;
|
|
|
|
struct page **p;
|
|
|
|
caddr_t page_addr = NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: READDIR(3) %s %d bytes at %d\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->count, (u32) argp->cookie);
|
|
|
|
|
|
|
|
/* Make sure we've room for the NULL ptr & eof flag, and shrink to
|
|
|
|
* client read size */
|
|
|
|
count = (argp->count >> 2) - 2;
|
|
|
|
|
|
|
|
/* Read directory and encode entries on the fly */
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
|
|
|
|
resp->buflen = count;
|
|
|
|
resp->common.err = nfs_ok;
|
|
|
|
resp->buffer = argp->buffer;
|
|
|
|
resp->rqstp = rqstp;
|
|
|
|
nfserr = nfsd_readdir(rqstp, &resp->fh, (loff_t*) &argp->cookie,
|
|
|
|
&resp->common, nfs3svc_encode_entry);
|
|
|
|
memcpy(resp->verf, argp->verf, 8);
|
2019-04-04 06:57:11 +00:00
|
|
|
count = 0;
|
|
|
|
for (p = rqstp->rq_respages + 1; p < rqstp->rq_next_page; p++) {
|
|
|
|
page_addr = page_address(*p);
|
|
|
|
|
|
|
|
if (((caddr_t)resp->buffer >= page_addr) &&
|
|
|
|
((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) {
|
|
|
|
count += (caddr_t)resp->buffer - page_addr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
count += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
resp->count = count >> 2;
|
nfsd: fix memory corruption caused by readdir
If the result of an NFSv3 readdir{,plus} request results in the
"offset" on one entry having to be split across 2 pages, and is sized
so that the next directory entry doesn't fit in the requested size,
then memory corruption can happen.
When encode_entry() is called after encoding the last entry that fits,
it notices that ->offset and ->offset1 are set, and so stores the
offset value in the two pages as required. It clears ->offset1 but
*does not* clear ->offset.
Normally this omission doesn't matter as encode_entry_baggage() will
be called, and will set ->offset to a suitable value (not on a page
boundary).
But in the case where cd->buflen < elen and nfserr_toosmall is
returned, ->offset is not reset.
This means that nfsd3proc_readdirplus will see ->offset with a value 4
bytes before the end of a page, and ->offset1 set to NULL.
It will try to write 8bytes to ->offset.
If we are lucky, the next page will be read-only, and the system will
BUG: unable to handle kernel paging request at...
If we are unlucky, some innocent page will have the first 4 bytes
corrupted.
nfsd3proc_readdir() doesn't even check for ->offset1, it just blindly
writes 8 bytes to the offset wherever it is.
Fix this by clearing ->offset after it is used, and copying the
->offset handling code from nfsd3_proc_readdirplus into
nfsd3_proc_readdir.
(Note that the commit hash in the Fixes tag is from the 'history'
tree - this bug predates git).
Fixes: 0b1d57cf7654 ("[PATCH] kNFSd: Fix nfs3 dentry encoding")
Fixes-URL: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=0b1d57cf7654
Cc: stable@vger.kernel.org (v2.6.12+)
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2019-03-04 03:08:22 +00:00
|
|
|
if (resp->offset) {
|
|
|
|
loff_t offset = argp->cookie;
|
|
|
|
|
|
|
|
if (unlikely(resp->offset1)) {
|
|
|
|
/* we ended up with offset on a page boundary */
|
|
|
|
*resp->offset = htonl(offset >> 32);
|
|
|
|
*resp->offset1 = htonl(offset & 0xffffffff);
|
|
|
|
resp->offset1 = NULL;
|
|
|
|
} else {
|
|
|
|
xdr_encode_hyper(resp->offset, offset);
|
|
|
|
}
|
|
|
|
resp->offset = NULL;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a portion of a directory, including file handles and attrs.
|
|
|
|
* For now, we choose to ignore the dircount parameter.
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_readdirargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_readdirres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
|
|
|
int count = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
loff_t offset;
|
2012-12-10 23:01:37 +00:00
|
|
|
struct page **p;
|
2005-04-16 22:20:36 +00:00
|
|
|
caddr_t page_addr = NULL;
|
|
|
|
|
|
|
|
dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->count, (u32) argp->cookie);
|
|
|
|
|
|
|
|
/* Convert byte count to number of words (i.e. >> 2),
|
|
|
|
* and reserve room for the NULL ptr & eof flag (-2 words) */
|
|
|
|
resp->count = (argp->count >> 2) - 2;
|
|
|
|
|
|
|
|
/* Read directory and encode entries on the fly */
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
|
|
|
|
|
|
|
resp->common.err = nfs_ok;
|
|
|
|
resp->buffer = argp->buffer;
|
|
|
|
resp->buflen = resp->count;
|
|
|
|
resp->rqstp = rqstp;
|
|
|
|
offset = argp->cookie;
|
nfsd: allow turning off nfsv3 readdir_plus
One of our customer's application only needs file names, not file
attributes. With directories having 10K+ inodes (assuming buffer cache
has directory blocks cached having file names, but inode cache is
limited and hence need eviction of older cached inodes), older inodes
are evicted periodically. So if they keep on doing readdir(2) from NSF
client on multiple directories, some directory's files are periodically
removed from inode cache and hence new readdir(2) on same directory
requires disk access to bring back inodes again to inode cache.
As READDIRPLUS request fetches attributes also, doing getattr on each
file on server, it causes unnecessary disk accesses. If READDIRPLUS on
NFS client is returned with -ENOTSUPP, NFS client uses READDIR request
which just gets the names of the files in a directory, not attributes,
hence avoiding disk accesses on server.
There's already a corresponding client-side mount option, but an export
option reduces the need for configuration across multiple clients.
This flag affects NFSv3 only. If it turns out it's needed for NFSv4 as
well then we may have to figure out how to extend the behavior to NFSv4,
but it's not currently obvious how to do that.
Signed-off-by: Rajesh Ghanekar <rajesh_ghanekar@symantec.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2014-08-02 02:17:30 +00:00
|
|
|
|
|
|
|
nfserr = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP);
|
|
|
|
if (nfserr)
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
|
|
|
|
if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS)
|
|
|
|
RETURN_STATUS(nfserr_notsupp);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
nfserr = nfsd_readdir(rqstp, &resp->fh,
|
|
|
|
&offset,
|
|
|
|
&resp->common,
|
|
|
|
nfs3svc_encode_entry_plus);
|
|
|
|
memcpy(resp->verf, argp->verf, 8);
|
2012-12-10 23:01:37 +00:00
|
|
|
for (p = rqstp->rq_respages + 1; p < rqstp->rq_next_page; p++) {
|
|
|
|
page_addr = page_address(*p);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (((caddr_t)resp->buffer >= page_addr) &&
|
|
|
|
((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) {
|
|
|
|
count += (caddr_t)resp->buffer - page_addr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
count += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
resp->count = count >> 2;
|
|
|
|
if (resp->offset) {
|
|
|
|
if (unlikely(resp->offset1)) {
|
|
|
|
/* we ended up with offset on a page boundary */
|
|
|
|
*resp->offset = htonl(offset >> 32);
|
|
|
|
*resp->offset1 = htonl(offset & 0xffffffff);
|
|
|
|
resp->offset1 = NULL;
|
|
|
|
} else {
|
|
|
|
xdr_encode_hyper(resp->offset, offset);
|
|
|
|
}
|
nfsd: fix memory corruption caused by readdir
If the result of an NFSv3 readdir{,plus} request results in the
"offset" on one entry having to be split across 2 pages, and is sized
so that the next directory entry doesn't fit in the requested size,
then memory corruption can happen.
When encode_entry() is called after encoding the last entry that fits,
it notices that ->offset and ->offset1 are set, and so stores the
offset value in the two pages as required. It clears ->offset1 but
*does not* clear ->offset.
Normally this omission doesn't matter as encode_entry_baggage() will
be called, and will set ->offset to a suitable value (not on a page
boundary).
But in the case where cd->buflen < elen and nfserr_toosmall is
returned, ->offset is not reset.
This means that nfsd3proc_readdirplus will see ->offset with a value 4
bytes before the end of a page, and ->offset1 set to NULL.
It will try to write 8bytes to ->offset.
If we are lucky, the next page will be read-only, and the system will
BUG: unable to handle kernel paging request at...
If we are unlucky, some innocent page will have the first 4 bytes
corrupted.
nfsd3proc_readdir() doesn't even check for ->offset1, it just blindly
writes 8 bytes to the offset wherever it is.
Fix this by clearing ->offset after it is used, and copying the
->offset handling code from nfsd3_proc_readdirplus into
nfsd3_proc_readdir.
(Note that the commit hash in the Fixes tag is from the 'history'
tree - this bug predates git).
Fixes: 0b1d57cf7654 ("[PATCH] kNFSd: Fix nfs3 dentry encoding")
Fixes-URL: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=0b1d57cf7654
Cc: stable@vger.kernel.org (v2.6.12+)
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2019-03-04 03:08:22 +00:00
|
|
|
resp->offset = NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get file system stats
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_fsstat(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd_fhandle *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_fsstatres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: FSSTAT(3) %s\n",
|
|
|
|
SVCFH_fmt(&argp->fh));
|
|
|
|
|
2008-08-07 17:00:20 +00:00
|
|
|
nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
fh_put(&argp->fh);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get file system info
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_fsinfo(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd_fhandle *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_fsinfores *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2006-10-04 09:15:47 +00:00
|
|
|
u32 max_blocksize = svc_max_payload(rqstp);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: FSINFO(3) %s\n",
|
|
|
|
SVCFH_fmt(&argp->fh));
|
|
|
|
|
2006-10-04 09:15:47 +00:00
|
|
|
resp->f_rtmax = max_blocksize;
|
|
|
|
resp->f_rtpref = max_blocksize;
|
2005-04-16 22:20:36 +00:00
|
|
|
resp->f_rtmult = PAGE_SIZE;
|
2006-10-04 09:15:47 +00:00
|
|
|
resp->f_wtmax = max_blocksize;
|
|
|
|
resp->f_wtpref = max_blocksize;
|
2005-04-16 22:20:36 +00:00
|
|
|
resp->f_wtmult = PAGE_SIZE;
|
2019-03-06 22:49:46 +00:00
|
|
|
resp->f_dtpref = max_blocksize;
|
2005-04-16 22:20:36 +00:00
|
|
|
resp->f_maxfilesize = ~(u32) 0;
|
|
|
|
resp->f_properties = NFS3_FSF_DEFAULT;
|
|
|
|
|
2008-08-07 17:00:20 +00:00
|
|
|
nfserr = fh_verify(rqstp, &argp->fh, 0,
|
|
|
|
NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Check special features of the file system. May request
|
|
|
|
* different read/write sizes for file systems known to have
|
|
|
|
* problems with large blocks */
|
|
|
|
if (nfserr == 0) {
|
2016-04-10 05:33:30 +00:00
|
|
|
struct super_block *sb = argp->fh.fh_dentry->d_sb;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Note that we don't care for remote fs's here */
|
2009-01-11 19:13:53 +00:00
|
|
|
if (sb->s_magic == MSDOS_SUPER_MAGIC) {
|
2005-04-16 22:20:36 +00:00
|
|
|
resp->f_properties = NFS3_FSF_BILLYBOY;
|
|
|
|
}
|
|
|
|
resp->f_maxfilesize = sb->s_maxbytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
fh_put(&argp->fh);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get pathconf info for the specified file
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_pathconf(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd_fhandle *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_pathconfres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: PATHCONF(3) %s\n",
|
|
|
|
SVCFH_fmt(&argp->fh));
|
|
|
|
|
|
|
|
/* Set default pathconf */
|
|
|
|
resp->p_link_max = 255; /* at least */
|
|
|
|
resp->p_name_max = 255; /* at least */
|
|
|
|
resp->p_no_trunc = 0;
|
|
|
|
resp->p_chown_restricted = 1;
|
|
|
|
resp->p_case_insensitive = 0;
|
|
|
|
resp->p_case_preserving = 1;
|
|
|
|
|
2008-06-16 11:20:29 +00:00
|
|
|
nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (nfserr == 0) {
|
2016-04-10 05:33:30 +00:00
|
|
|
struct super_block *sb = argp->fh.fh_dentry->d_sb;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Note that we don't care for remote fs's here */
|
|
|
|
switch (sb->s_magic) {
|
|
|
|
case EXT2_SUPER_MAGIC:
|
|
|
|
resp->p_link_max = EXT2_LINK_MAX;
|
|
|
|
resp->p_name_max = EXT2_NAME_LEN;
|
|
|
|
break;
|
2009-01-11 19:13:53 +00:00
|
|
|
case MSDOS_SUPER_MAGIC:
|
2005-04-16 22:20:36 +00:00
|
|
|
resp->p_case_insensitive = 1;
|
|
|
|
resp->p_case_preserving = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fh_put(&argp->fh);
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Commit a file (range) to stable storage.
|
|
|
|
*/
|
2006-10-20 06:28:45 +00:00
|
|
|
static __be32
|
2017-05-08 15:35:49 +00:00
|
|
|
nfsd3_proc_commit(struct svc_rqst *rqstp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-05-08 15:35:49 +00:00
|
|
|
struct nfsd3_commitargs *argp = rqstp->rq_argp;
|
|
|
|
struct nfsd3_commitres *resp = rqstp->rq_resp;
|
2006-10-20 06:29:00 +00:00
|
|
|
__be32 nfserr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dprintk("nfsd: COMMIT(3) %s %u@%Lu\n",
|
|
|
|
SVCFH_fmt(&argp->fh),
|
|
|
|
argp->count,
|
|
|
|
(unsigned long long) argp->offset);
|
|
|
|
|
|
|
|
if (argp->offset > NFS_OFFSET_MAX)
|
|
|
|
RETURN_STATUS(nfserr_inval);
|
|
|
|
|
|
|
|
fh_copy(&resp->fh, &argp->fh);
|
2020-01-06 18:40:36 +00:00
|
|
|
nfserr = nfsd_commit(rqstp, &resp->fh, argp->offset, argp->count,
|
|
|
|
resp->verf);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
RETURN_STATUS(nfserr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NFSv3 Server procedures.
|
|
|
|
* Only the results of non-idempotent operations are cached.
|
|
|
|
*/
|
|
|
|
#define nfs3svc_decode_fhandleargs nfs3svc_decode_fhandle
|
|
|
|
#define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat
|
|
|
|
#define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat
|
|
|
|
#define nfsd3_mkdirargs nfsd3_createargs
|
|
|
|
#define nfsd3_readdirplusargs nfsd3_readdirargs
|
|
|
|
#define nfsd3_fhandleargs nfsd_fhandle
|
|
|
|
#define nfsd3_fhandleres nfsd3_attrstat
|
|
|
|
#define nfsd3_attrstatres nfsd3_attrstat
|
|
|
|
#define nfsd3_wccstatres nfsd3_attrstat
|
|
|
|
#define nfsd3_createres nfsd3_diropres
|
|
|
|
#define nfsd3_voidres nfsd3_voidargs
|
|
|
|
struct nfsd3_voidargs { int dummy; };
|
|
|
|
|
|
|
|
#define ST 1 /* status*/
|
|
|
|
#define FH 17 /* filehandle with length */
|
|
|
|
#define AT 21 /* attributes */
|
|
|
|
#define pAT (1+AT) /* post attributes - conditional */
|
|
|
|
#define WC (7+pAT) /* WCC attributes */
|
|
|
|
|
2017-05-12 14:11:49 +00:00
|
|
|
static const struct svc_procedure nfsd_procedures3[22] = {
|
2009-06-09 09:33:34 +00:00
|
|
|
[NFS3PROC_NULL] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_null,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_voidres,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_voidargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_voidres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST,
|
|
|
|
},
|
|
|
|
[NFS3PROC_GETATTR] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_getattr,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_fhandleargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_attrstatres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_fhandleargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_attrstatres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+AT,
|
|
|
|
},
|
|
|
|
[NFS3PROC_SETATTR] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_setattr,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_sattrargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_wccstatres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_sattrargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_wccstatres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_LOOKUP] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_lookup,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_diropargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_diropres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_diropargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_diropres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+FH+pAT+pAT,
|
|
|
|
},
|
|
|
|
[NFS3PROC_ACCESS] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_access,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_accessargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_accessres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_accessargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_accessres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+1,
|
|
|
|
},
|
|
|
|
[NFS3PROC_READLINK] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_readlink,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_readlinkargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_readlinkres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_readlinkargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_readlinkres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4,
|
|
|
|
},
|
|
|
|
[NFS3PROC_READ] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_read,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_readargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_readres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_readargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_readres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4,
|
|
|
|
},
|
|
|
|
[NFS3PROC_WRITE] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_write,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_writeargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_writeres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_writeargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_writeres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+WC+4,
|
|
|
|
},
|
|
|
|
[NFS3PROC_CREATE] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_create,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_createargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_createres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_createargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_createres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+(1+FH+pAT)+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_MKDIR] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_mkdir,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_mkdirargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_createres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_mkdirargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_createres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+(1+FH+pAT)+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_SYMLINK] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_symlink,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_symlinkargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_createres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_symlinkargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_createres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+(1+FH+pAT)+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_MKNOD] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_mknod,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_mknodargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_createres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_mknodargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_createres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+(1+FH+pAT)+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_REMOVE] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_remove,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_diropargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_wccstatres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_diropargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_wccstatres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_RMDIR] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_rmdir,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_diropargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_wccstatres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_diropargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_wccstatres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_RENAME] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_rename,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_renameargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_renameres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_renameargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_renameres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+WC+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_LINK] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_link,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_linkargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_linkres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle2,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_linkargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_linkres),
|
|
|
|
.pc_cachetype = RC_REPLBUFF,
|
|
|
|
.pc_xdrressize = ST+pAT+WC,
|
|
|
|
},
|
|
|
|
[NFS3PROC_READDIR] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_readdir,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_readdirargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_readdirres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_readdirargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_readdirres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
},
|
|
|
|
[NFS3PROC_READDIRPLUS] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_readdirplus,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_readdirplusargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_readdirres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_readdirplusargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_readdirres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
},
|
|
|
|
[NFS3PROC_FSSTAT] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_fsstat,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_fhandleargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_fsstatres,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_fhandleargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_fsstatres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+2*6+1,
|
|
|
|
},
|
|
|
|
[NFS3PROC_FSINFO] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_fsinfo,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_fhandleargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_fsinfores,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_fhandleargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_fsinfores),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+12,
|
|
|
|
},
|
|
|
|
[NFS3PROC_PATHCONF] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_pathconf,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_fhandleargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_pathconfres,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_fhandleargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_pathconfres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+pAT+6,
|
|
|
|
},
|
|
|
|
[NFS3PROC_COMMIT] = {
|
2017-05-08 15:35:49 +00:00
|
|
|
.pc_func = nfsd3_proc_commit,
|
2017-05-08 17:01:48 +00:00
|
|
|
.pc_decode = nfs3svc_decode_commitargs,
|
2017-05-08 17:42:02 +00:00
|
|
|
.pc_encode = nfs3svc_encode_commitres,
|
2017-05-08 16:48:24 +00:00
|
|
|
.pc_release = nfs3svc_release_fhandle,
|
2009-06-09 09:33:34 +00:00
|
|
|
.pc_argsize = sizeof(struct nfsd3_commitargs),
|
|
|
|
.pc_ressize = sizeof(struct nfsd3_commitres),
|
|
|
|
.pc_cachetype = RC_NOCACHE,
|
|
|
|
.pc_xdrressize = ST+WC+2,
|
|
|
|
},
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2017-05-08 21:40:27 +00:00
|
|
|
static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)];
|
2017-05-12 14:21:37 +00:00
|
|
|
const struct svc_version nfsd_version3 = {
|
|
|
|
.vs_vers = 3,
|
|
|
|
.vs_nproc = 22,
|
|
|
|
.vs_proc = nfsd_procedures3,
|
|
|
|
.vs_dispatch = nfsd_dispatch,
|
|
|
|
.vs_count = nfsd_count3,
|
|
|
|
.vs_xdrsize = NFS3_SVC_XDRSIZE,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|