Skip to content

Commit 9fc2f99

Browse files
committed
Merge tag 'nfsd-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
Pull nfsd updates from Chuck Lever: "Two significant security enhancements are part of this release: - NFSD's RPC header encoding and decoding, including RPCSEC GSS and gssproxy header parsing, has been overhauled to make it more memory-safe. - Support for Kerberos AES-SHA2-based encryption types has been added for both the NFS client and server. This provides a clean path for deprecating and removing insecure encryption types based on DES and SHA-1. AES-SHA2 is also FIPS-140 compliant, so that NFS with Kerberos may now be used on systems with fips enabled. In addition to these, NFSD is now able to handle crossing into an auto-mounted mount point on an exported NFS mount. A number of fixes have been made to NFSD's server-side copy implementation. RPC metrics have been converted to per-CPU variables. This helps reduce unnecessary cross-CPU and cross-node memory bus traffic, and significantly reduces noise when KCSAN is enabled" * tag 'nfsd-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: (121 commits) NFSD: Clean up nfsd_symlink() NFSD: copy the whole verifier in nfsd_copy_write_verifier nfsd: don't fsync nfsd_files on last close SUNRPC: Fix occasional warning when destroying gss_krb5_enctypes nfsd: fix courtesy client with deny mode handling in nfs4_upgrade_open NFSD: fix problems with cleanup on errors in nfsd4_copy nfsd: fix race to check ls_layouts nfsd: don't hand out delegation on setuid files being opened for write SUNRPC: Remove ->xpo_secure_port() SUNRPC: Clean up the svc_xprt_flags() macro nfsd: remove fs/nfsd/fault_inject.c NFSD: fix leaked reference count of nfsd4_ssc_umount_item nfsd: clean up potential nfsd_file refcount leaks in COPY codepath nfsd: zero out pointers after putting nfsd_files on COPY setup error SUNRPC: Fix whitespace damage in svcauth_unix.c nfsd: eliminate __nfs4_get_fd nfsd: add some kerneldoc comments for stateid preprocessing functions nfsd: eliminate find_deleg_file_locked nfsd: don't take nfsd4_copy ref for OP_OFFLOAD_STATUS SUNRPC: Add encryption self-tests ...
2 parents 25ac8c1 + 4b471a8 commit 9fc2f99

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5218
-2070
lines changed

fs/lockd/svc.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -685,17 +685,16 @@ module_exit(exit_nlm);
685685
/**
686686
* nlmsvc_dispatch - Process an NLM Request
687687
* @rqstp: incoming request
688-
* @statp: pointer to location of accept_stat field in RPC Reply buffer
689688
*
690689
* Return values:
691690
* %0: Processing complete; do not send a Reply
692691
* %1: Processing complete; send Reply in rqstp->rq_res
693692
*/
694-
static int nlmsvc_dispatch(struct svc_rqst *rqstp, __be32 *statp)
693+
static int nlmsvc_dispatch(struct svc_rqst *rqstp)
695694
{
696695
const struct svc_procedure *procp = rqstp->rq_procinfo;
696+
__be32 *statp = rqstp->rq_accept_statp;
697697

698-
svcxdr_init_decode(rqstp);
699698
if (!procp->pc_decode(rqstp, &rqstp->rq_arg_stream))
700699
goto out_decode_err;
701700

@@ -705,7 +704,6 @@ static int nlmsvc_dispatch(struct svc_rqst *rqstp, __be32 *statp)
705704
if (*statp != rpc_success)
706705
return 1;
707706

708-
svcxdr_init_encode(rqstp);
709707
if (!procp->pc_encode(rqstp, &rqstp->rq_res_stream))
710708
goto out_encode_err;
711709

@@ -723,7 +721,7 @@ static int nlmsvc_dispatch(struct svc_rqst *rqstp, __be32 *statp)
723721
/*
724722
* Define NLM program and procedures
725723
*/
726-
static unsigned int nlmsvc_version1_count[17];
724+
static DEFINE_PER_CPU_ALIGNED(unsigned long, nlmsvc_version1_count[17]);
727725
static const struct svc_version nlmsvc_version1 = {
728726
.vs_vers = 1,
729727
.vs_nproc = 17,
@@ -732,26 +730,31 @@ static const struct svc_version nlmsvc_version1 = {
732730
.vs_dispatch = nlmsvc_dispatch,
733731
.vs_xdrsize = NLMSVC_XDRSIZE,
734732
};
735-
static unsigned int nlmsvc_version3_count[24];
733+
734+
static DEFINE_PER_CPU_ALIGNED(unsigned long,
735+
nlmsvc_version3_count[ARRAY_SIZE(nlmsvc_procedures)]);
736736
static const struct svc_version nlmsvc_version3 = {
737737
.vs_vers = 3,
738-
.vs_nproc = 24,
738+
.vs_nproc = ARRAY_SIZE(nlmsvc_procedures),
739739
.vs_proc = nlmsvc_procedures,
740740
.vs_count = nlmsvc_version3_count,
741741
.vs_dispatch = nlmsvc_dispatch,
742742
.vs_xdrsize = NLMSVC_XDRSIZE,
743743
};
744+
744745
#ifdef CONFIG_LOCKD_V4
745-
static unsigned int nlmsvc_version4_count[24];
746+
static DEFINE_PER_CPU_ALIGNED(unsigned long,
747+
nlmsvc_version4_count[ARRAY_SIZE(nlmsvc_procedures4)]);
746748
static const struct svc_version nlmsvc_version4 = {
747749
.vs_vers = 4,
748-
.vs_nproc = 24,
750+
.vs_nproc = ARRAY_SIZE(nlmsvc_procedures4),
749751
.vs_proc = nlmsvc_procedures4,
750752
.vs_count = nlmsvc_version4_count,
751753
.vs_dispatch = nlmsvc_dispatch,
752754
.vs_xdrsize = NLMSVC_XDRSIZE,
753755
};
754756
#endif
757+
755758
static const struct svc_version *nlmsvc_version[] = {
756759
[1] = &nlmsvc_version1,
757760
[3] = &nlmsvc_version3,

fs/namei.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,11 +1459,11 @@ EXPORT_SYMBOL(follow_down_one);
14591459
* point, the filesystem owning that dentry may be queried as to whether the
14601460
* caller is permitted to proceed or not.
14611461
*/
1462-
int follow_down(struct path *path)
1462+
int follow_down(struct path *path, unsigned int flags)
14631463
{
14641464
struct vfsmount *mnt = path->mnt;
14651465
bool jumped;
1466-
int ret = traverse_mounts(path, &jumped, NULL, 0);
1466+
int ret = traverse_mounts(path, &jumped, NULL, flags);
14671467

14681468
if (path->mnt != mnt)
14691469
mntput(mnt);
@@ -2865,7 +2865,7 @@ int path_pts(struct path *path)
28652865

28662866
path->dentry = child;
28672867
dput(parent);
2868-
follow_down(path);
2868+
follow_down(path, 0);
28692869
return 0;
28702870
}
28712871
#endif

fs/nfs/callback_xdr.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -980,14 +980,11 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp)
980980
}
981981

982982
static int
983-
nfs_callback_dispatch(struct svc_rqst *rqstp, __be32 *statp)
983+
nfs_callback_dispatch(struct svc_rqst *rqstp)
984984
{
985985
const struct svc_procedure *procp = rqstp->rq_procinfo;
986986

987-
svcxdr_init_decode(rqstp);
988-
svcxdr_init_encode(rqstp);
989-
990-
*statp = procp->pc_func(rqstp);
987+
*rqstp->rq_accept_statp = procp->pc_func(rqstp);
991988
return 1;
992989
}
993990

@@ -1072,7 +1069,8 @@ static const struct svc_procedure nfs4_callback_procedures1[] = {
10721069
}
10731070
};
10741071

1075-
static unsigned int nfs4_callback_count1[ARRAY_SIZE(nfs4_callback_procedures1)];
1072+
static DEFINE_PER_CPU_ALIGNED(unsigned long,
1073+
nfs4_callback_count1[ARRAY_SIZE(nfs4_callback_procedures1)]);
10761074
const struct svc_version nfs4_callback_version1 = {
10771075
.vs_vers = 1,
10781076
.vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1),
@@ -1084,7 +1082,8 @@ const struct svc_version nfs4_callback_version1 = {
10841082
.vs_need_cong_ctrl = true,
10851083
};
10861084

1087-
static unsigned int nfs4_callback_count4[ARRAY_SIZE(nfs4_callback_procedures1)];
1085+
static DEFINE_PER_CPU_ALIGNED(unsigned long,
1086+
nfs4_callback_count4[ARRAY_SIZE(nfs4_callback_procedures1)]);
10881087
const struct svc_version nfs4_callback_version4 = {
10891088
.vs_vers = 4,
10901089
.vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1),

fs/nfs/export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ nfs_encode_fh(struct inode *inode, __u32 *p, int *max_len, struct inode *parent)
4242
dprintk("%s: max fh len %d inode %p parent %p",
4343
__func__, *max_len, inode, parent);
4444

45-
if (*max_len < len || IS_AUTOMOUNT(inode)) {
45+
if (*max_len < len) {
4646
dprintk("%s: fh len %d too small, required %d\n",
4747
__func__, *max_len, len);
4848
*max_len = len;

fs/nfsd/fault_inject.c

Lines changed: 0 additions & 142 deletions
This file was deleted.

fs/nfsd/filecache.c

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -331,37 +331,27 @@ nfsd_file_alloc(struct nfsd_file_lookup_key *key, unsigned int may)
331331
return nf;
332332
}
333333

334+
/**
335+
* nfsd_file_check_write_error - check for writeback errors on a file
336+
* @nf: nfsd_file to check for writeback errors
337+
*
338+
* Check whether a nfsd_file has an unseen error. Reset the write
339+
* verifier if so.
340+
*/
334341
static void
335-
nfsd_file_fsync(struct nfsd_file *nf)
336-
{
337-
struct file *file = nf->nf_file;
338-
int ret;
339-
340-
if (!file || !(file->f_mode & FMODE_WRITE))
341-
return;
342-
ret = vfs_fsync(file, 1);
343-
trace_nfsd_file_fsync(nf, ret);
344-
if (ret)
345-
nfsd_reset_write_verifier(net_generic(nf->nf_net, nfsd_net_id));
346-
}
347-
348-
static int
349342
nfsd_file_check_write_error(struct nfsd_file *nf)
350343
{
351344
struct file *file = nf->nf_file;
352345

353-
if (!file || !(file->f_mode & FMODE_WRITE))
354-
return 0;
355-
return filemap_check_wb_err(file->f_mapping, READ_ONCE(file->f_wb_err));
346+
if ((file->f_mode & FMODE_WRITE) &&
347+
filemap_check_wb_err(file->f_mapping, READ_ONCE(file->f_wb_err)))
348+
nfsd_reset_write_verifier(net_generic(nf->nf_net, nfsd_net_id));
356349
}
357350

358351
static void
359352
nfsd_file_hash_remove(struct nfsd_file *nf)
360353
{
361354
trace_nfsd_file_unhash(nf);
362-
363-
if (nfsd_file_check_write_error(nf))
364-
nfsd_reset_write_verifier(net_generic(nf->nf_net, nfsd_net_id));
365355
rhashtable_remove_fast(&nfsd_file_rhash_tbl, &nf->nf_rhash,
366356
nfsd_file_rhash_params);
367357
}
@@ -387,23 +377,12 @@ nfsd_file_free(struct nfsd_file *nf)
387377
this_cpu_add(nfsd_file_total_age, age);
388378

389379
nfsd_file_unhash(nf);
390-
391-
/*
392-
* We call fsync here in order to catch writeback errors. It's not
393-
* strictly required by the protocol, but an nfsd_file could get
394-
* evicted from the cache before a COMMIT comes in. If another
395-
* task were to open that file in the interim and scrape the error,
396-
* then the client may never see it. By calling fsync here, we ensure
397-
* that writeback happens before the entry is freed, and that any
398-
* errors reported result in the write verifier changing.
399-
*/
400-
nfsd_file_fsync(nf);
401-
402380
if (nf->nf_mark)
403381
nfsd_file_mark_put(nf->nf_mark);
404382
if (nf->nf_file) {
405383
get_file(nf->nf_file);
406384
filp_close(nf->nf_file, NULL);
385+
nfsd_file_check_write_error(nf);
407386
fput(nf->nf_file);
408387
}
409388

@@ -452,7 +431,7 @@ static bool nfsd_file_lru_remove(struct nfsd_file *nf)
452431
struct nfsd_file *
453432
nfsd_file_get(struct nfsd_file *nf)
454433
{
455-
if (likely(refcount_inc_not_zero(&nf->nf_ref)))
434+
if (nf && refcount_inc_not_zero(&nf->nf_ref))
456435
return nf;
457436
return NULL;
458437
}
@@ -1107,8 +1086,7 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
11071086
rcu_read_lock();
11081087
nf = rhashtable_lookup(&nfsd_file_rhash_tbl, &key,
11091088
nfsd_file_rhash_params);
1110-
if (nf)
1111-
nf = nfsd_file_get(nf);
1089+
nf = nfsd_file_get(nf);
11121090
rcu_read_unlock();
11131091

11141092
if (nf) {
@@ -1159,6 +1137,7 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
11591137
out:
11601138
if (status == nfs_ok) {
11611139
this_cpu_inc(nfsd_file_acquisitions);
1140+
nfsd_file_check_write_error(nf);
11621141
*pnf = nf;
11631142
} else {
11641143
if (refcount_dec_and_test(&nf->nf_ref))

fs/nfsd/nfs2acl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,11 @@ static const struct svc_procedure nfsd_acl_procedures2[5] = {
377377
},
378378
};
379379

380-
static unsigned int nfsd_acl_count2[ARRAY_SIZE(nfsd_acl_procedures2)];
380+
static DEFINE_PER_CPU_ALIGNED(unsigned long,
381+
nfsd_acl_count2[ARRAY_SIZE(nfsd_acl_procedures2)]);
381382
const struct svc_version nfsd_acl_version2 = {
382383
.vs_vers = 2,
383-
.vs_nproc = 5,
384+
.vs_nproc = ARRAY_SIZE(nfsd_acl_procedures2),
384385
.vs_proc = nfsd_acl_procedures2,
385386
.vs_count = nfsd_acl_count2,
386387
.vs_dispatch = nfsd_dispatch,

0 commit comments

Comments
 (0)