NFSv4.1: Label each entry in the session slot tables with its slot number
[linux-2.6-block.git] / fs / nfs / super.c
CommitLineData
f7b422b1
DH
1/*
2 * linux/fs/nfs/super.c
3 *
4 * Copyright (C) 1992 Rick Sladkey
5 *
6 * nfs superblock handling functions
7 *
526719ba 8 * Modularised by Alan Cox <alan@lxorguk.ukuu.org.uk>, while hacking some
f7b422b1
DH
9 * experimental NFS changes. Modularisation taken straight from SYS5 fs.
10 *
11 * Change to nfs_read_super() to permit NFS mounts to multi-homed hosts.
12 * J.S.Peatfield@damtp.cam.ac.uk
13 *
14 * Split from inode.c by David Howells <dhowells@redhat.com>
15 *
54ceac45
DH
16 * - superblocks are indexed on server only - all inodes, dentries, etc. associated with a
17 * particular server are held in the same superblock
18 * - NFS superblocks can have several effective roots to the dentry tree
19 * - directory type roots are spliced into the tree when a path from one root reaches the root
20 * of another (see nfs_lookup())
f7b422b1
DH
21 */
22
f7b422b1
DH
23#include <linux/module.h>
24#include <linux/init.h>
25
26#include <linux/time.h>
27#include <linux/kernel.h>
28#include <linux/mm.h>
29#include <linux/string.h>
30#include <linux/stat.h>
31#include <linux/errno.h>
32#include <linux/unistd.h>
33#include <linux/sunrpc/clnt.h>
34#include <linux/sunrpc/stats.h>
35#include <linux/sunrpc/metrics.h>
0896a725 36#include <linux/sunrpc/xprtsock.h>
2cf7ff7a 37#include <linux/sunrpc/xprtrdma.h>
f7b422b1
DH
38#include <linux/nfs_fs.h>
39#include <linux/nfs_mount.h>
40#include <linux/nfs4_mount.h>
41#include <linux/lockd/bind.h>
f7b422b1
DH
42#include <linux/seq_file.h>
43#include <linux/mount.h>
c02d7adf 44#include <linux/namei.h>
f7b422b1
DH
45#include <linux/nfs_idmap.h>
46#include <linux/vfs.h>
47#include <linux/inet.h>
fd00a8ff 48#include <linux/in6.h>
5a0e3ad6 49#include <linux/slab.h>
fd00a8ff 50#include <net/ipv6.h>
d8e7748a 51#include <linux/netdevice.h>
f7b422b1 52#include <linux/nfs_xdr.h>
b5d5dfbd 53#include <linux/magic.h>
bf0fd768 54#include <linux/parser.h>
e50a7a1a 55#include <linux/nsproxy.h>
2446ab60 56#include <linux/rcupdate.h>
324d003b 57#include <linux/kthread.h>
f7b422b1 58
f7b422b1
DH
59#include <asm/uaccess.h>
60
61#include "nfs4_fs.h"
62#include "callback.h"
63#include "delegation.h"
64#include "iostat.h"
65#include "internal.h"
08734048 66#include "fscache.h"
ae50c0b5 67#include "pnfs.h"
ab7017a3 68#include "nfs.h"
f7b422b1
DH
69
70#define NFSDBG_FACILITY NFSDBG_VFS
b72e4f42 71#define NFS_TEXT_DATA 1
f7b422b1 72
1c606fb7 73#if IS_ENABLED(CONFIG_NFS_V3)
1e657bd5
PZ
74#define NFS_DEFAULT_VERSION 3
75#else
76#define NFS_DEFAULT_VERSION 2
77#endif
78
bf0fd768
CL
79enum {
80 /* Mount options that take no arguments */
81 Opt_soft, Opt_hard,
bf0fd768
CL
82 Opt_posix, Opt_noposix,
83 Opt_cto, Opt_nocto,
84 Opt_ac, Opt_noac,
85 Opt_lock, Opt_nolock,
2cf7ff7a 86 Opt_udp, Opt_tcp, Opt_rdma,
bf0fd768
CL
87 Opt_acl, Opt_noacl,
88 Opt_rdirplus, Opt_nordirplus,
75180df2 89 Opt_sharecache, Opt_nosharecache,
d740351b 90 Opt_resvport, Opt_noresvport,
b797cac7 91 Opt_fscache, Opt_nofscache,
89652617 92 Opt_migration, Opt_nomigration,
bf0fd768
CL
93
94 /* Mount options that take integer arguments */
95 Opt_port,
96 Opt_rsize, Opt_wsize, Opt_bsize,
97 Opt_timeo, Opt_retrans,
98 Opt_acregmin, Opt_acregmax,
99 Opt_acdirmin, Opt_acdirmax,
100 Opt_actimeo,
101 Opt_namelen,
102 Opt_mountport,
e887cbcf 103 Opt_mountvers,
3fd5be9e 104 Opt_minorversion,
bf0fd768
CL
105
106 /* Mount options that take string arguments */
0d71b058 107 Opt_nfsvers,
33832034 108 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
0ac83779 109 Opt_addr, Opt_mountaddr, Opt_clientaddr,
7973c1f1 110 Opt_lookupcache,
b797cac7 111 Opt_fscache_uniq,
5eebde23 112 Opt_local_lock,
bf0fd768 113
f45663ce
CL
114 /* Special mount options */
115 Opt_userspace, Opt_deprecated, Opt_sloppy,
bf0fd768
CL
116
117 Opt_err
118};
119
a447c093 120static const match_table_t nfs_mount_option_tokens = {
bf0fd768
CL
121 { Opt_userspace, "bg" },
122 { Opt_userspace, "fg" },
ecbb3845
CL
123 { Opt_userspace, "retry=%s" },
124
f45663ce
CL
125 { Opt_sloppy, "sloppy" },
126
bf0fd768
CL
127 { Opt_soft, "soft" },
128 { Opt_hard, "hard" },
d33e4dfe
CL
129 { Opt_deprecated, "intr" },
130 { Opt_deprecated, "nointr" },
bf0fd768
CL
131 { Opt_posix, "posix" },
132 { Opt_noposix, "noposix" },
133 { Opt_cto, "cto" },
134 { Opt_nocto, "nocto" },
135 { Opt_ac, "ac" },
136 { Opt_noac, "noac" },
137 { Opt_lock, "lock" },
138 { Opt_nolock, "nolock" },
bf0fd768
CL
139 { Opt_udp, "udp" },
140 { Opt_tcp, "tcp" },
2cf7ff7a 141 { Opt_rdma, "rdma" },
bf0fd768
CL
142 { Opt_acl, "acl" },
143 { Opt_noacl, "noacl" },
144 { Opt_rdirplus, "rdirplus" },
145 { Opt_nordirplus, "nordirplus" },
75180df2
TM
146 { Opt_sharecache, "sharecache" },
147 { Opt_nosharecache, "nosharecache" },
d740351b
CL
148 { Opt_resvport, "resvport" },
149 { Opt_noresvport, "noresvport" },
b797cac7 150 { Opt_fscache, "fsc" },
b797cac7 151 { Opt_nofscache, "nofsc" },
89652617
CL
152 { Opt_migration, "migration" },
153 { Opt_nomigration, "nomigration" },
bf0fd768 154
a5a16bae
CL
155 { Opt_port, "port=%s" },
156 { Opt_rsize, "rsize=%s" },
157 { Opt_wsize, "wsize=%s" },
158 { Opt_bsize, "bsize=%s" },
159 { Opt_timeo, "timeo=%s" },
160 { Opt_retrans, "retrans=%s" },
161 { Opt_acregmin, "acregmin=%s" },
162 { Opt_acregmax, "acregmax=%s" },
163 { Opt_acdirmin, "acdirmin=%s" },
164 { Opt_acdirmax, "acdirmax=%s" },
165 { Opt_actimeo, "actimeo=%s" },
166 { Opt_namelen, "namlen=%s" },
167 { Opt_mountport, "mountport=%s" },
168 { Opt_mountvers, "mountvers=%s" },
0d71b058
TM
169 { Opt_minorversion, "minorversion=%s" },
170
a5a16bae
CL
171 { Opt_nfsvers, "nfsvers=%s" },
172 { Opt_nfsvers, "vers=%s" },
bf0fd768
CL
173
174 { Opt_sec, "sec=%s" },
175 { Opt_proto, "proto=%s" },
176 { Opt_mountproto, "mountproto=%s" },
177 { Opt_addr, "addr=%s" },
178 { Opt_clientaddr, "clientaddr=%s" },
33832034 179 { Opt_mounthost, "mounthost=%s" },
0ac83779 180 { Opt_mountaddr, "mountaddr=%s" },
bf0fd768 181
7973c1f1 182 { Opt_lookupcache, "lookupcache=%s" },
a6d5ff64 183 { Opt_fscache_uniq, "fsc=%s" },
5eebde23 184 { Opt_local_lock, "local_lock=%s" },
7973c1f1 185
3862279a
TM
186 /* The following needs to be listed after all other options */
187 { Opt_nfsvers, "v%s" },
188
bf0fd768
CL
189 { Opt_err, NULL }
190};
191
192enum {
ee671b01 193 Opt_xprt_udp, Opt_xprt_udp6, Opt_xprt_tcp, Opt_xprt_tcp6, Opt_xprt_rdma,
bf0fd768
CL
194
195 Opt_xprt_err
196};
197
a447c093 198static const match_table_t nfs_xprt_protocol_tokens = {
bf0fd768 199 { Opt_xprt_udp, "udp" },
ee671b01 200 { Opt_xprt_udp6, "udp6" },
bf0fd768 201 { Opt_xprt_tcp, "tcp" },
ee671b01 202 { Opt_xprt_tcp6, "tcp6" },
2cf7ff7a 203 { Opt_xprt_rdma, "rdma" },
bf0fd768
CL
204
205 { Opt_xprt_err, NULL }
206};
207
208enum {
209 Opt_sec_none, Opt_sec_sys,
210 Opt_sec_krb5, Opt_sec_krb5i, Opt_sec_krb5p,
211 Opt_sec_lkey, Opt_sec_lkeyi, Opt_sec_lkeyp,
212 Opt_sec_spkm, Opt_sec_spkmi, Opt_sec_spkmp,
213
214 Opt_sec_err
215};
216
a447c093 217static const match_table_t nfs_secflavor_tokens = {
bf0fd768
CL
218 { Opt_sec_none, "none" },
219 { Opt_sec_none, "null" },
220 { Opt_sec_sys, "sys" },
221
222 { Opt_sec_krb5, "krb5" },
223 { Opt_sec_krb5i, "krb5i" },
224 { Opt_sec_krb5p, "krb5p" },
225
226 { Opt_sec_lkey, "lkey" },
227 { Opt_sec_lkeyi, "lkeyi" },
228 { Opt_sec_lkeyp, "lkeyp" },
229
8d042218
OK
230 { Opt_sec_spkm, "spkm3" },
231 { Opt_sec_spkmi, "spkm3i" },
232 { Opt_sec_spkmp, "spkm3p" },
233
bf0fd768
CL
234 { Opt_sec_err, NULL }
235};
236
7973c1f1
TM
237enum {
238 Opt_lookupcache_all, Opt_lookupcache_positive,
239 Opt_lookupcache_none,
240
241 Opt_lookupcache_err
242};
243
244static match_table_t nfs_lookupcache_tokens = {
245 { Opt_lookupcache_all, "all" },
246 { Opt_lookupcache_positive, "pos" },
247 { Opt_lookupcache_positive, "positive" },
248 { Opt_lookupcache_none, "none" },
249
250 { Opt_lookupcache_err, NULL }
251};
252
5eebde23
SJ
253enum {
254 Opt_local_lock_all, Opt_local_lock_flock, Opt_local_lock_posix,
255 Opt_local_lock_none,
256
257 Opt_local_lock_err
258};
259
260static match_table_t nfs_local_lock_tokens = {
261 { Opt_local_lock_all, "all" },
262 { Opt_local_lock_flock, "flock" },
263 { Opt_local_lock_posix, "posix" },
264 { Opt_local_lock_none, "none" },
265
266 { Opt_local_lock_err, NULL }
267};
268
0d71b058
TM
269enum {
270 Opt_vers_2, Opt_vers_3, Opt_vers_4, Opt_vers_4_0,
271 Opt_vers_4_1,
272
273 Opt_vers_err
274};
275
276static match_table_t nfs_vers_tokens = {
277 { Opt_vers_2, "2" },
278 { Opt_vers_3, "3" },
279 { Opt_vers_4, "4" },
280 { Opt_vers_4_0, "4.0" },
281 { Opt_vers_4_1, "4.1" },
282
283 { Opt_vers_err, NULL }
284};
bf0fd768 285
31f43471
AV
286static struct dentry *nfs_xdev_mount(struct file_system_type *fs_type,
287 int flags, const char *dev_name, void *raw_data);
f7b422b1 288
ab7017a3 289struct file_system_type nfs_fs_type = {
f7b422b1
DH
290 .owner = THIS_MODULE,
291 .name = "nfs",
01194981 292 .mount = nfs_fs_mount,
f7b422b1 293 .kill_sb = nfs_kill_super,
349457cc 294 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
f7b422b1 295};
ddda8e0a 296EXPORT_SYMBOL_GPL(nfs_fs_type);
f7b422b1 297
54ceac45 298struct file_system_type nfs_xdev_fs_type = {
f7b422b1
DH
299 .owner = THIS_MODULE,
300 .name = "nfs",
31f43471 301 .mount = nfs_xdev_mount,
f7b422b1 302 .kill_sb = nfs_kill_super,
349457cc 303 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
f7b422b1
DH
304};
305
6a74490d 306const struct super_operations nfs_sops = {
f7b422b1
DH
307 .alloc_inode = nfs_alloc_inode,
308 .destroy_inode = nfs_destroy_inode,
309 .write_inode = nfs_write_inode,
387c149b 310 .put_super = nfs_put_super,
f7b422b1 311 .statfs = nfs_statfs,
b57922d9 312 .evict_inode = nfs_evict_inode,
f7b422b1
DH
313 .umount_begin = nfs_umount_begin,
314 .show_options = nfs_show_options,
c7f404b4
AV
315 .show_devname = nfs_show_devname,
316 .show_path = nfs_show_path,
f7b422b1 317 .show_stats = nfs_show_stats,
48b605f8 318 .remount_fs = nfs_remount,
f7b422b1 319};
ddda8e0a 320EXPORT_SYMBOL_GPL(nfs_sops);
f7b422b1 321
89d77c8f 322#if IS_ENABLED(CONFIG_NFS_V4)
b72e4f42 323static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data *);
d72c727c
BS
324static int nfs4_validate_mount_data(void *options,
325 struct nfs_parsed_mount_data *args, const char *dev_name);
1ae811ee 326
327struct file_system_type nfs4_fs_type = {
328 .owner = THIS_MODULE,
329 .name = "nfs4",
330 .mount = nfs_fs_mount,
331 .kill_sb = nfs_kill_super,
332 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
333};
334EXPORT_SYMBOL_GPL(nfs4_fs_type);
335
336static int __init register_nfs4_fs(void)
337{
338 return register_filesystem(&nfs4_fs_type);
339}
340
341static void unregister_nfs4_fs(void)
342{
343 unregister_filesystem(&nfs4_fs_type);
344}
345#else
346static int __init register_nfs4_fs(void)
347{
348 return 0;
349}
350
351static void unregister_nfs4_fs(void)
352{
353}
f7b422b1
DH
354#endif
355
8e1f936b
RR
356static struct shrinker acl_shrinker = {
357 .shrink = nfs_access_cache_shrinker,
358 .seeks = DEFAULT_SEEKS,
359};
979df72e 360
f7b422b1
DH
361/*
362 * Register the NFS filesystems
363 */
364int __init register_nfs_fs(void)
365{
366 int ret;
367
368 ret = register_filesystem(&nfs_fs_type);
369 if (ret < 0)
370 goto error_0;
371
1ae811ee 372 ret = register_nfs4_fs();
f7b422b1
DH
373 if (ret < 0)
374 goto error_1;
1ae811ee 375
376 ret = nfs_register_sysctl();
377 if (ret < 0)
378 goto error_2;
8e1f936b 379 register_shrinker(&acl_shrinker);
f7b422b1
DH
380 return 0;
381
1ae811ee 382error_2:
383 unregister_nfs4_fs();
f7b422b1
DH
384error_1:
385 unregister_filesystem(&nfs_fs_type);
f7b422b1
DH
386error_0:
387 return ret;
388}
389
390/*
391 * Unregister the NFS filesystems
392 */
393void __exit unregister_nfs_fs(void)
394{
8e1f936b 395 unregister_shrinker(&acl_shrinker);
49af7ee1 396 nfs_unregister_sysctl();
1ae811ee 397 unregister_nfs4_fs();
f7b422b1
DH
398 unregister_filesystem(&nfs_fs_type);
399}
400
1daef0a8 401void nfs_sb_active(struct super_block *sb)
ef818a28 402{
1daef0a8 403 struct nfs_server *server = NFS_SB(sb);
ef818a28 404
1daef0a8
TM
405 if (atomic_inc_return(&server->active) == 1)
406 atomic_inc(&sb->s_active);
ef818a28 407}
89d77c8f 408EXPORT_SYMBOL_GPL(nfs_sb_active);
ef818a28 409
1daef0a8 410void nfs_sb_deactive(struct super_block *sb)
ef818a28
SD
411{
412 struct nfs_server *server = NFS_SB(sb);
1daef0a8
TM
413
414 if (atomic_dec_and_test(&server->active))
415 deactivate_super(sb);
ef818a28 416}
89d77c8f 417EXPORT_SYMBOL_GPL(nfs_sb_deactive);
ef818a28 418
324d003b
WAA
419static int nfs_deactivate_super_async_work(void *ptr)
420{
421 struct super_block *sb = ptr;
422
423 deactivate_super(sb);
424 module_put_and_exit(0);
425 return 0;
426}
427
428/*
429 * same effect as deactivate_super, but will do final unmount in kthread
430 * context
431 */
432static void nfs_deactivate_super_async(struct super_block *sb)
433{
434 struct task_struct *task;
435 char buf[INET6_ADDRSTRLEN + 1];
436 struct nfs_server *server = NFS_SB(sb);
437 struct nfs_client *clp = server->nfs_client;
438
439 if (!atomic_add_unless(&sb->s_active, -1, 1)) {
440 rcu_read_lock();
441 snprintf(buf, sizeof(buf),
442 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
443 rcu_read_unlock();
444
445 __module_get(THIS_MODULE);
446 task = kthread_run(nfs_deactivate_super_async_work, sb,
447 "%s-deactivate-super", buf);
448 if (IS_ERR(task)) {
449 pr_err("%s: kthread_run: %ld\n",
450 __func__, PTR_ERR(task));
451 /* make synchronous call and hope for the best */
452 deactivate_super(sb);
453 module_put(THIS_MODULE);
454 }
455 }
456}
457
458void nfs_sb_deactive_async(struct super_block *sb)
459{
460 struct nfs_server *server = NFS_SB(sb);
461
462 if (atomic_dec_and_test(&server->active))
463 nfs_deactivate_super_async(sb);
464}
465EXPORT_SYMBOL_GPL(nfs_sb_deactive_async);
466
f7b422b1
DH
467/*
468 * Deliver file system statistics to userspace
469 */
fbdefd64 470int nfs_statfs(struct dentry *dentry, struct kstatfs *buf)
f7b422b1 471{
0c7d90cf 472 struct nfs_server *server = NFS_SB(dentry->d_sb);
f7b422b1
DH
473 unsigned char blockbits;
474 unsigned long blockres;
0c7d90cf 475 struct nfs_fh *fh = NFS_FH(dentry->d_inode);
ca7e9a0d
TM
476 struct nfs_fsstat res;
477 int error = -ENOMEM;
478
479 res.fattr = nfs_alloc_fattr();
480 if (res.fattr == NULL)
481 goto out_err;
f7b422b1 482
8fa5c000 483 error = server->nfs_client->rpc_ops->statfs(server, fh, &res);
fbf3fdd2
MZ
484 if (unlikely(error == -ESTALE)) {
485 struct dentry *pd_dentry;
486
487 pd_dentry = dget_parent(dentry);
488 if (pd_dentry != NULL) {
489 nfs_zap_caches(pd_dentry->d_inode);
490 dput(pd_dentry);
491 }
492 }
ca7e9a0d 493 nfs_free_fattr(res.fattr);
f7b422b1
DH
494 if (error < 0)
495 goto out_err;
ca7e9a0d 496
1a0ba9ae 497 buf->f_type = NFS_SUPER_MAGIC;
f7b422b1
DH
498
499 /*
500 * Current versions of glibc do not correctly handle the
501 * case where f_frsize != f_bsize. Eventually we want to
502 * report the value of wtmult in this field.
503 */
0c7d90cf 504 buf->f_frsize = dentry->d_sb->s_blocksize;
f7b422b1
DH
505
506 /*
507 * On most *nix systems, f_blocks, f_bfree, and f_bavail
508 * are reported in units of f_frsize. Linux hasn't had
509 * an f_frsize field in its statfs struct until recently,
510 * thus historically Linux's sys_statfs reports these
511 * fields in units of f_bsize.
512 */
0c7d90cf
DH
513 buf->f_bsize = dentry->d_sb->s_blocksize;
514 blockbits = dentry->d_sb->s_blocksize_bits;
f7b422b1
DH
515 blockres = (1 << blockbits) - 1;
516 buf->f_blocks = (res.tbytes + blockres) >> blockbits;
517 buf->f_bfree = (res.fbytes + blockres) >> blockbits;
518 buf->f_bavail = (res.abytes + blockres) >> blockbits;
519
520 buf->f_files = res.tfiles;
521 buf->f_ffree = res.afiles;
522
523 buf->f_namelen = server->namelen;
1a0ba9ae 524
f7b422b1
DH
525 return 0;
526
527 out_err:
3110ff80 528 dprintk("%s: statfs error = %d\n", __func__, -error);
1a0ba9ae 529 return error;
f7b422b1 530}
89d77c8f 531EXPORT_SYMBOL_GPL(nfs_statfs);
f7b422b1 532
7d4e2747
DH
533/*
534 * Map the security flavour number to a name
535 */
81039f1f
TM
536static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour)
537{
7d4e2747 538 static const struct {
81039f1f
TM
539 rpc_authflavor_t flavour;
540 const char *str;
541 } sec_flavours[] = {
542 { RPC_AUTH_NULL, "null" },
543 { RPC_AUTH_UNIX, "sys" },
544 { RPC_AUTH_GSS_KRB5, "krb5" },
545 { RPC_AUTH_GSS_KRB5I, "krb5i" },
546 { RPC_AUTH_GSS_KRB5P, "krb5p" },
547 { RPC_AUTH_GSS_LKEY, "lkey" },
548 { RPC_AUTH_GSS_LKEYI, "lkeyi" },
549 { RPC_AUTH_GSS_LKEYP, "lkeyp" },
550 { RPC_AUTH_GSS_SPKM, "spkm" },
551 { RPC_AUTH_GSS_SPKMI, "spkmi" },
552 { RPC_AUTH_GSS_SPKMP, "spkmp" },
4d81cd16 553 { UINT_MAX, "unknown" }
81039f1f
TM
554 };
555 int i;
556
4d81cd16 557 for (i = 0; sec_flavours[i].flavour != UINT_MAX; i++) {
81039f1f
TM
558 if (sec_flavours[i].flavour == flavour)
559 break;
560 }
561 return sec_flavours[i].str;
562}
563
ee671b01
JL
564static void nfs_show_mountd_netid(struct seq_file *m, struct nfs_server *nfss,
565 int showdefaults)
566{
567 struct sockaddr *sap = (struct sockaddr *) &nfss->mountd_address;
568
569 seq_printf(m, ",mountproto=");
570 switch (sap->sa_family) {
571 case AF_INET:
572 switch (nfss->mountd_protocol) {
573 case IPPROTO_UDP:
574 seq_printf(m, RPCBIND_NETID_UDP);
575 break;
576 case IPPROTO_TCP:
577 seq_printf(m, RPCBIND_NETID_TCP);
578 break;
579 default:
580 if (showdefaults)
581 seq_printf(m, "auto");
582 }
583 break;
584 case AF_INET6:
585 switch (nfss->mountd_protocol) {
586 case IPPROTO_UDP:
587 seq_printf(m, RPCBIND_NETID_UDP6);
588 break;
589 case IPPROTO_TCP:
590 seq_printf(m, RPCBIND_NETID_TCP6);
591 break;
592 default:
593 if (showdefaults)
594 seq_printf(m, "auto");
595 }
596 break;
597 default:
598 if (showdefaults)
599 seq_printf(m, "auto");
600 }
601}
602
82d101d5
CL
603static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
604 int showdefaults)
605{
606 struct sockaddr *sap = (struct sockaddr *)&nfss->mountd_address;
607
d5eff1a3
BS
608 if (nfss->flags & NFS_MOUNT_LEGACY_INTERFACE)
609 return;
610
82d101d5
CL
611 switch (sap->sa_family) {
612 case AF_INET: {
613 struct sockaddr_in *sin = (struct sockaddr_in *)sap;
be859405 614 seq_printf(m, ",mountaddr=%pI4", &sin->sin_addr.s_addr);
82d101d5
CL
615 break;
616 }
617 case AF_INET6: {
618 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
d250e190 619 seq_printf(m, ",mountaddr=%pI6c", &sin6->sin6_addr);
82d101d5
CL
620 break;
621 }
622 default:
623 if (showdefaults)
624 seq_printf(m, ",mountaddr=unspecified");
625 }
626
627 if (nfss->mountd_version || showdefaults)
628 seq_printf(m, ",mountvers=%u", nfss->mountd_version);
aa699473
SK
629 if ((nfss->mountd_port &&
630 nfss->mountd_port != (unsigned short)NFS_UNSPEC_PORT) ||
631 showdefaults)
82d101d5
CL
632 seq_printf(m, ",mountport=%u", nfss->mountd_port);
633
ee671b01 634 nfs_show_mountd_netid(m, nfss, showdefaults);
82d101d5
CL
635}
636
89d77c8f 637#if IS_ENABLED(CONFIG_NFS_V4)
0be8189f
TM
638static void nfs_show_nfsv4_options(struct seq_file *m, struct nfs_server *nfss,
639 int showdefaults)
640{
641 struct nfs_client *clp = nfss->nfs_client;
642
643 seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr);
0be8189f
TM
644}
645#else
646static void nfs_show_nfsv4_options(struct seq_file *m, struct nfs_server *nfss,
647 int showdefaults)
648{
649}
650#endif
651
7bbceb6f
TM
652static void nfs_show_nfs_version(struct seq_file *m,
653 unsigned int version,
654 unsigned int minorversion)
655{
656 seq_printf(m, ",vers=%u", version);
657 if (version == 4)
658 seq_printf(m, ".%u", minorversion);
659}
660
f7b422b1
DH
661/*
662 * Describe the mount options in force on this server representation
663 */
82d101d5
CL
664static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
665 int showdefaults)
f7b422b1 666{
509de811 667 static const struct proc_nfs_info {
f7b422b1 668 int flag;
509de811
DH
669 const char *str;
670 const char *nostr;
f7b422b1
DH
671 } nfs_info[] = {
672 { NFS_MOUNT_SOFT, ",soft", ",hard" },
82d101d5 673 { NFS_MOUNT_POSIX, ",posix", "" },
f7b422b1
DH
674 { NFS_MOUNT_NOCTO, ",nocto", "" },
675 { NFS_MOUNT_NOAC, ",noac", "" },
676 { NFS_MOUNT_NONLM, ",nolock", "" },
677 { NFS_MOUNT_NOACL, ",noacl", "" },
74dd34e6 678 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
d740351b
CL
679 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
680 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
f7b422b1
DH
681 { 0, NULL, NULL }
682 };
509de811 683 const struct proc_nfs_info *nfs_infop;
8fa5c000 684 struct nfs_client *clp = nfss->nfs_client;
82d101d5 685 u32 version = clp->rpc_ops->version;
7c563cc9 686 int local_flock, local_fcntl;
f7b422b1 687
7bbceb6f 688 nfs_show_nfs_version(m, version, clp->cl_minorversion);
2d767432
CL
689 seq_printf(m, ",rsize=%u", nfss->rsize);
690 seq_printf(m, ",wsize=%u", nfss->wsize);
82d101d5
CL
691 if (nfss->bsize != 0)
692 seq_printf(m, ",bsize=%u", nfss->bsize);
693 seq_printf(m, ",namlen=%u", nfss->namelen);
0e0cab74 694 if (nfss->acregmin != NFS_DEF_ACREGMIN*HZ || showdefaults)
2d767432 695 seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ);
0e0cab74 696 if (nfss->acregmax != NFS_DEF_ACREGMAX*HZ || showdefaults)
2d767432 697 seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ);
0e0cab74 698 if (nfss->acdirmin != NFS_DEF_ACDIRMIN*HZ || showdefaults)
2d767432 699 seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ);
0e0cab74 700 if (nfss->acdirmax != NFS_DEF_ACDIRMAX*HZ || showdefaults)
2d767432 701 seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ);
f7b422b1
DH
702 for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) {
703 if (nfss->flags & nfs_infop->flag)
704 seq_puts(m, nfs_infop->str);
705 else
706 seq_puts(m, nfs_infop->nostr);
707 }
2446ab60 708 rcu_read_lock();
56928edd 709 seq_printf(m, ",proto=%s",
ee671b01 710 rpc_peeraddr2str(nfss->client, RPC_DISPLAY_NETID));
2446ab60 711 rcu_read_unlock();
82d101d5
CL
712 if (version == 4) {
713 if (nfss->port != NFS_PORT)
714 seq_printf(m, ",port=%u", nfss->port);
715 } else
716 if (nfss->port)
717 seq_printf(m, ",port=%u", nfss->port);
718
33170233
TM
719 seq_printf(m, ",timeo=%lu", 10U * nfss->client->cl_timeout->to_initval / HZ);
720 seq_printf(m, ",retrans=%u", nfss->client->cl_timeout->to_retries);
81039f1f 721 seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor));
82d101d5
CL
722
723 if (version != 4)
724 nfs_show_mountd_options(m, nfss, showdefaults);
0be8189f
TM
725 else
726 nfs_show_nfsv4_options(m, nfss, showdefaults);
82d101d5 727
b797cac7
DH
728 if (nfss->options & NFS_OPTION_FSCACHE)
729 seq_printf(m, ",fsc");
9b00c643 730
89652617
CL
731 if (nfss->options & NFS_OPTION_MIGRATION)
732 seq_printf(m, ",migration");
733
9b00c643
PL
734 if (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG) {
735 if (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONE)
736 seq_printf(m, ",lookupcache=none");
737 else
738 seq_printf(m, ",lookupcache=pos");
739 }
7c563cc9
SJ
740
741 local_flock = nfss->flags & NFS_MOUNT_LOCAL_FLOCK;
742 local_fcntl = nfss->flags & NFS_MOUNT_LOCAL_FCNTL;
743
744 if (!local_flock && !local_fcntl)
745 seq_printf(m, ",local_lock=none");
746 else if (local_flock && local_fcntl)
747 seq_printf(m, ",local_lock=all");
748 else if (local_flock)
749 seq_printf(m, ",local_lock=flock");
750 else
751 seq_printf(m, ",local_lock=posix");
f7b422b1
DH
752}
753
754/*
755 * Describe the mount options on this VFS mountpoint
756 */
fbdefd64 757int nfs_show_options(struct seq_file *m, struct dentry *root)
f7b422b1 758{
34c80b1d 759 struct nfs_server *nfss = NFS_SB(root->d_sb);
f7b422b1
DH
760
761 nfs_show_mount_options(m, nfss, 0);
762
2446ab60 763 rcu_read_lock();
5d8515ca
CL
764 seq_printf(m, ",addr=%s",
765 rpc_peeraddr2str(nfss->nfs_client->cl_rpcclient,
766 RPC_DISPLAY_ADDR));
2446ab60 767 rcu_read_unlock();
f7b422b1
DH
768
769 return 0;
770}
89d77c8f 771EXPORT_SYMBOL_GPL(nfs_show_options);
45402c38 772
89d77c8f 773#if IS_ENABLED(CONFIG_NFS_V4)
ae50c0b5 774#ifdef CONFIG_NFS_V4_1
45402c38 775static void show_sessions(struct seq_file *m, struct nfs_server *server)
ae50c0b5
BF
776{
777 if (nfs4_has_session(server->nfs_client))
778 seq_printf(m, ",sessions");
779}
780#else
45402c38
HS
781static void show_sessions(struct seq_file *m, struct nfs_server *server) {}
782#endif
ae50c0b5
BF
783#endif
784
785#ifdef CONFIG_NFS_V4_1
45402c38 786static void show_pnfs(struct seq_file *m, struct nfs_server *server)
ae50c0b5
BF
787{
788 seq_printf(m, ",pnfs=");
789 if (server->pnfs_curr_ld)
790 seq_printf(m, "%s", server->pnfs_curr_ld->name);
791 else
792 seq_printf(m, "not configured");
793}
7e03b7cc
TM
794
795static void show_implementation_id(struct seq_file *m, struct nfs_server *nfss)
796{
59155546
CL
797 if (nfss->nfs_client && nfss->nfs_client->cl_implid) {
798 struct nfs41_impl_id *impl_id = nfss->nfs_client->cl_implid;
7e03b7cc
TM
799 seq_printf(m, "\n\timpl_id:\tname='%s',domain='%s',"
800 "date='%llu,%u'",
801 impl_id->name, impl_id->domain,
802 impl_id->date.seconds, impl_id->date.nseconds);
803 }
804}
45402c38 805#else
89d77c8f 806#if IS_ENABLED(CONFIG_NFS_V4)
7e03b7cc
TM
807static void show_pnfs(struct seq_file *m, struct nfs_server *server)
808{
809}
45402c38 810#endif
7e03b7cc
TM
811static void show_implementation_id(struct seq_file *m, struct nfs_server *nfss)
812{
813}
45402c38 814#endif
f7b422b1 815
fbdefd64 816int nfs_show_devname(struct seq_file *m, struct dentry *root)
c7f404b4
AV
817{
818 char *page = (char *) __get_free_page(GFP_KERNEL);
819 char *devname, *dummy;
820 int err = 0;
821 if (!page)
822 return -ENOMEM;
97a54868 823 devname = nfs_path(&dummy, root, page, PAGE_SIZE, 0);
c7f404b4
AV
824 if (IS_ERR(devname))
825 err = PTR_ERR(devname);
826 else
827 seq_escape(m, devname, " \t\n\\");
828 free_page((unsigned long)page);
829 return err;
830}
89d77c8f 831EXPORT_SYMBOL_GPL(nfs_show_devname);
c7f404b4 832
fbdefd64 833int nfs_show_path(struct seq_file *m, struct dentry *dentry)
c7f404b4
AV
834{
835 seq_puts(m, "/");
836 return 0;
837}
89d77c8f 838EXPORT_SYMBOL_GPL(nfs_show_path);
c7f404b4 839
f7b422b1
DH
840/*
841 * Present statistical information for this VFS mountpoint
842 */
fbdefd64 843int nfs_show_stats(struct seq_file *m, struct dentry *root)
f7b422b1
DH
844{
845 int i, cpu;
64132379 846 struct nfs_server *nfss = NFS_SB(root->d_sb);
f7b422b1
DH
847 struct rpc_auth *auth = nfss->client->cl_auth;
848 struct nfs_iostats totals = { };
849
850 seq_printf(m, "statvers=%s", NFS_IOSTAT_VERS);
851
852 /*
853 * Display all mount option settings
854 */
855 seq_printf(m, "\n\topts:\t");
64132379
AV
856 seq_puts(m, root->d_sb->s_flags & MS_RDONLY ? "ro" : "rw");
857 seq_puts(m, root->d_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : "");
858 seq_puts(m, root->d_sb->s_flags & MS_NOATIME ? ",noatime" : "");
859 seq_puts(m, root->d_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : "");
f7b422b1
DH
860 nfs_show_mount_options(m, nfss, 1);
861
862 seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ);
863
7e03b7cc 864 show_implementation_id(m, nfss);
7d2ed9ac 865
f7b422b1
DH
866 seq_printf(m, "\n\tcaps:\t");
867 seq_printf(m, "caps=0x%x", nfss->caps);
2d767432
CL
868 seq_printf(m, ",wtmult=%u", nfss->wtmult);
869 seq_printf(m, ",dtsize=%u", nfss->dtsize);
870 seq_printf(m, ",bsize=%u", nfss->bsize);
871 seq_printf(m, ",namlen=%u", nfss->namelen);
f7b422b1 872
89d77c8f 873#if IS_ENABLED(CONFIG_NFS_V4)
40c55319 874 if (nfss->nfs_client->rpc_ops->version == 4) {
f7b422b1
DH
875 seq_printf(m, "\n\tnfsv4:\t");
876 seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]);
877 seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]);
878 seq_printf(m, ",acl=0x%x", nfss->acl_bitmask);
ae50c0b5
BF
879 show_sessions(m, nfss);
880 show_pnfs(m, nfss);
f7b422b1
DH
881 }
882#endif
883
884 /*
885 * Display security flavor in effect for this mount
886 */
2d767432 887 seq_printf(m, "\n\tsec:\tflavor=%u", auth->au_ops->au_flavor);
f7b422b1 888 if (auth->au_flavor)
2d767432 889 seq_printf(m, ",pseudoflavor=%u", auth->au_flavor);
f7b422b1
DH
890
891 /*
892 * Display superblock I/O counters
893 */
894 for_each_possible_cpu(cpu) {
895 struct nfs_iostats *stats;
896
897 preempt_disable();
898 stats = per_cpu_ptr(nfss->io_stats, cpu);
899
900 for (i = 0; i < __NFSIOS_COUNTSMAX; i++)
901 totals.events[i] += stats->events[i];
902 for (i = 0; i < __NFSIOS_BYTESMAX; i++)
903 totals.bytes[i] += stats->bytes[i];
6a51091d
DH
904#ifdef CONFIG_NFS_FSCACHE
905 for (i = 0; i < __NFSIOS_FSCACHEMAX; i++)
906 totals.fscache[i] += stats->fscache[i];
907#endif
f7b422b1
DH
908
909 preempt_enable();
910 }
911
912 seq_printf(m, "\n\tevents:\t");
913 for (i = 0; i < __NFSIOS_COUNTSMAX; i++)
914 seq_printf(m, "%lu ", totals.events[i]);
915 seq_printf(m, "\n\tbytes:\t");
916 for (i = 0; i < __NFSIOS_BYTESMAX; i++)
917 seq_printf(m, "%Lu ", totals.bytes[i]);
6a51091d
DH
918#ifdef CONFIG_NFS_FSCACHE
919 if (nfss->options & NFS_OPTION_FSCACHE) {
920 seq_printf(m, "\n\tfsc:\t");
921 for (i = 0; i < __NFSIOS_FSCACHEMAX; i++)
922 seq_printf(m, "%Lu ", totals.bytes[i]);
923 }
924#endif
f7b422b1
DH
925 seq_printf(m, "\n");
926
927 rpc_print_iostats(m, nfss->client);
928
929 return 0;
930}
89d77c8f 931EXPORT_SYMBOL_GPL(nfs_show_stats);
f7b422b1
DH
932
933/*
934 * Begin unmount by attempting to remove all automounted mountpoints we added
54ceac45 935 * in response to xdev traversals and referrals
f7b422b1 936 */
fbdefd64 937void nfs_umount_begin(struct super_block *sb)
f7b422b1 938{
67e55205 939 struct nfs_server *server;
fc6ae3cf
TM
940 struct rpc_clnt *rpc;
941
67e55205 942 server = NFS_SB(sb);
fc6ae3cf
TM
943 /* -EIO all pending I/O */
944 rpc = server->client_acl;
945 if (!IS_ERR(rpc))
946 rpc_killall_tasks(rpc);
947 rpc = server->client;
948 if (!IS_ERR(rpc))
949 rpc_killall_tasks(rpc);
f7b422b1 950}
89d77c8f 951EXPORT_SYMBOL_GPL(nfs_umount_begin);
f7b422b1 952
db833351 953static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(void)
9423a08a
CL
954{
955 struct nfs_parsed_mount_data *data;
956
957 data = kzalloc(sizeof(*data), GFP_KERNEL);
958 if (data) {
9423a08a
CL
959 data->acregmin = NFS_DEF_ACREGMIN;
960 data->acregmax = NFS_DEF_ACREGMAX;
961 data->acdirmin = NFS_DEF_ACDIRMIN;
962 data->acdirmax = NFS_DEF_ACDIRMAX;
c5811dbd 963 data->mount_server.port = NFS_UNSPEC_PORT;
9423a08a 964 data->nfs_server.port = NFS_UNSPEC_PORT;
c5811dbd 965 data->nfs_server.protocol = XPRT_TRANSPORT_TCP;
9423a08a
CL
966 data->auth_flavors[0] = RPC_AUTH_UNIX;
967 data->auth_flavor_len = 1;
968 data->minorversion = 0;
b72e4f42 969 data->need_mount = true;
9937347a 970 data->net = current->nsproxy->net_ns;
8a0d551a 971 security_init_mnt_opts(&data->lsm_opts);
9423a08a
CL
972 }
973 return data;
974}
975
8a0d551a
JL
976static void nfs_free_parsed_mount_data(struct nfs_parsed_mount_data *data)
977{
978 if (data) {
979 kfree(data->client_address);
980 kfree(data->mount_server.hostname);
981 kfree(data->nfs_server.export_path);
982 kfree(data->nfs_server.hostname);
983 kfree(data->fscache_uniq);
984 security_free_mnt_opts(&data->lsm_opts);
985 kfree(data);
986 }
987}
988
fc50d58f 989/*
cdcd7f9a
CL
990 * Sanity-check a server address provided by the mount command.
991 *
992 * Address family must be initialized, and address must not be
993 * the ANY address for that family.
fc50d58f
CL
994 */
995static int nfs_verify_server_address(struct sockaddr *addr)
996{
997 switch (addr->sa_family) {
998 case AF_INET: {
cdcd7f9a 999 struct sockaddr_in *sa = (struct sockaddr_in *)addr;
e6f1cebf 1000 return sa->sin_addr.s_addr != htonl(INADDR_ANY);
cdcd7f9a
CL
1001 }
1002 case AF_INET6: {
1003 struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr;
1004 return !ipv6_addr_any(sa);
fc50d58f
CL
1005 }
1006 }
1007
53a0b9c4 1008 dfprintk(MOUNT, "NFS: Invalid IP address specified\n");
fc50d58f
CL
1009 return 0;
1010}
1011
4cfd74fc
CL
1012/*
1013 * Select between a default port value and a user-specified port value.
1014 * If a zero value is set, then autobind will be used.
1015 */
f5855fec 1016static void nfs_set_port(struct sockaddr *sap, int *port,
4cfd74fc
CL
1017 const unsigned short default_port)
1018{
f5855fec
TM
1019 if (*port == NFS_UNSPEC_PORT)
1020 *port = default_port;
4cfd74fc 1021
f5855fec 1022 rpc_set_port(sap, *port);
4cfd74fc
CL
1023}
1024
259875ef
TM
1025/*
1026 * Sanity check the NFS transport protocol.
1027 *
1028 */
1029static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt)
1030{
1031 switch (mnt->nfs_server.protocol) {
1032 case XPRT_TRANSPORT_UDP:
1033 case XPRT_TRANSPORT_TCP:
1034 case XPRT_TRANSPORT_RDMA:
1035 break;
1036 default:
1037 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1038 }
1039}
1040
1041/*
1042 * For text based NFSv2/v3 mounts, the mount protocol transport default
1043 * settings should depend upon the specified NFS transport.
1044 */
1045static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt)
1046{
1047 nfs_validate_transport_protocol(mnt);
1048
1049 if (mnt->mount_server.protocol == XPRT_TRANSPORT_UDP ||
1050 mnt->mount_server.protocol == XPRT_TRANSPORT_TCP)
1051 return;
1052 switch (mnt->nfs_server.protocol) {
1053 case XPRT_TRANSPORT_UDP:
1054 mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
1055 break;
1056 case XPRT_TRANSPORT_TCP:
1057 case XPRT_TRANSPORT_RDMA:
1058 mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
1059 }
1060}
1061
01060c89
CL
1062/*
1063 * Parse the value of the 'sec=' option.
01060c89
CL
1064 */
1065static int nfs_parse_security_flavors(char *value,
1066 struct nfs_parsed_mount_data *mnt)
1067{
1068 substring_t args[MAX_OPT_ARGS];
1069
1070 dfprintk(MOUNT, "NFS: parsing sec=%s option\n", value);
1071
1072 switch (match_token(value, nfs_secflavor_tokens, args)) {
1073 case Opt_sec_none:
01060c89
CL
1074 mnt->auth_flavors[0] = RPC_AUTH_NULL;
1075 break;
1076 case Opt_sec_sys:
01060c89
CL
1077 mnt->auth_flavors[0] = RPC_AUTH_UNIX;
1078 break;
1079 case Opt_sec_krb5:
01060c89
CL
1080 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5;
1081 break;
1082 case Opt_sec_krb5i:
01060c89
CL
1083 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I;
1084 break;
1085 case Opt_sec_krb5p:
01060c89
CL
1086 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P;
1087 break;
1088 case Opt_sec_lkey:
01060c89
CL
1089 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY;
1090 break;
1091 case Opt_sec_lkeyi:
01060c89
CL
1092 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI;
1093 break;
1094 case Opt_sec_lkeyp:
01060c89
CL
1095 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP;
1096 break;
1097 case Opt_sec_spkm:
01060c89
CL
1098 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM;
1099 break;
1100 case Opt_sec_spkmi:
01060c89
CL
1101 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI;
1102 break;
1103 case Opt_sec_spkmp:
01060c89
CL
1104 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP;
1105 break;
1106 default:
1107 return 0;
1108 }
1109
9b7160c5 1110 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
059f90b3 1111 mnt->auth_flavor_len = 1;
01060c89
CL
1112 return 1;
1113}
1114
0d71b058
TM
1115static int nfs_parse_version_string(char *string,
1116 struct nfs_parsed_mount_data *mnt,
1117 substring_t *args)
1118{
1119 mnt->flags &= ~NFS_MOUNT_VER3;
1120 switch (match_token(string, nfs_vers_tokens, args)) {
1121 case Opt_vers_2:
1122 mnt->version = 2;
1123 break;
1124 case Opt_vers_3:
1125 mnt->flags |= NFS_MOUNT_VER3;
1126 mnt->version = 3;
1127 break;
1128 case Opt_vers_4:
1129 /* Backward compatibility option. In future,
1130 * the mount program should always supply
1131 * a NFSv4 minor version number.
1132 */
1133 mnt->version = 4;
1134 break;
1135 case Opt_vers_4_0:
1136 mnt->version = 4;
1137 mnt->minorversion = 0;
1138 break;
1139 case Opt_vers_4_1:
1140 mnt->version = 4;
1141 mnt->minorversion = 1;
1142 break;
1143 default:
1144 return 0;
1145 }
1146 return 1;
1147}
1148
c5cb09b6
RL
1149static int nfs_get_option_str(substring_t args[], char **option)
1150{
1151 kfree(*option);
1152 *option = match_strdup(args);
1153 return !option;
1154}
1155
1156static int nfs_get_option_ul(substring_t args[], unsigned long *option)
1157{
1158 int rc;
1159 char *string;
1160
1161 string = match_strdup(args);
1162 if (string == NULL)
1163 return -ENOMEM;
7297cb68 1164 rc = kstrtoul(string, 10, option);
c5cb09b6
RL
1165 kfree(string);
1166
1167 return rc;
1168}
1169
bf0fd768
CL
1170/*
1171 * Error-check and convert a string of mount options from user space into
f45663ce
CL
1172 * a data structure. The whole mount string is processed; bad options are
1173 * skipped as they are encountered. If there were no errors, return 1;
1174 * otherwise return 0 (zero).
bf0fd768
CL
1175 */
1176static int nfs_parse_mount_options(char *raw,
1177 struct nfs_parsed_mount_data *mnt)
1178{
f9c3a380 1179 char *p, *string, *secdata;
d23c45fd 1180 int rc, sloppy = 0, invalid_option = 0;
ee671b01
JL
1181 unsigned short protofamily = AF_UNSPEC;
1182 unsigned short mountfamily = AF_UNSPEC;
bf0fd768
CL
1183
1184 if (!raw) {
1185 dfprintk(MOUNT, "NFS: mount options string was NULL.\n");
1186 return 1;
1187 }
1188 dfprintk(MOUNT, "NFS: nfs mount opts='%s'\n", raw);
1189
f9c3a380
EP
1190 secdata = alloc_secdata();
1191 if (!secdata)
1192 goto out_nomem;
1193
1194 rc = security_sb_copy_data(raw, secdata);
1195 if (rc)
1196 goto out_security_failure;
1197
1198 rc = security_sb_parse_opts_str(secdata, &mnt->lsm_opts);
1199 if (rc)
1200 goto out_security_failure;
1201
1202 free_secdata(secdata);
1203
bf0fd768
CL
1204 while ((p = strsep(&raw, ",")) != NULL) {
1205 substring_t args[MAX_OPT_ARGS];
a5a16bae
CL
1206 unsigned long option;
1207 int token;
bf0fd768
CL
1208
1209 if (!*p)
1210 continue;
1211
1212 dfprintk(MOUNT, "NFS: parsing nfs mount option '%s'\n", p);
1213
1214 token = match_token(p, nfs_mount_option_tokens, args);
1215 switch (token) {
f45663ce
CL
1216
1217 /*
1218 * boolean options: foo/nofoo
1219 */
bf0fd768
CL
1220 case Opt_soft:
1221 mnt->flags |= NFS_MOUNT_SOFT;
1222 break;
1223 case Opt_hard:
1224 mnt->flags &= ~NFS_MOUNT_SOFT;
1225 break;
bf0fd768
CL
1226 case Opt_posix:
1227 mnt->flags |= NFS_MOUNT_POSIX;
1228 break;
1229 case Opt_noposix:
1230 mnt->flags &= ~NFS_MOUNT_POSIX;
1231 break;
1232 case Opt_cto:
1233 mnt->flags &= ~NFS_MOUNT_NOCTO;
1234 break;
1235 case Opt_nocto:
1236 mnt->flags |= NFS_MOUNT_NOCTO;
1237 break;
1238 case Opt_ac:
1239 mnt->flags &= ~NFS_MOUNT_NOAC;
1240 break;
1241 case Opt_noac:
1242 mnt->flags |= NFS_MOUNT_NOAC;
1243 break;
1244 case Opt_lock:
1245 mnt->flags &= ~NFS_MOUNT_NONLM;
5eebde23
SJ
1246 mnt->flags &= ~(NFS_MOUNT_LOCAL_FLOCK |
1247 NFS_MOUNT_LOCAL_FCNTL);
bf0fd768
CL
1248 break;
1249 case Opt_nolock:
1250 mnt->flags |= NFS_MOUNT_NONLM;
5eebde23
SJ
1251 mnt->flags |= (NFS_MOUNT_LOCAL_FLOCK |
1252 NFS_MOUNT_LOCAL_FCNTL);
bf0fd768 1253 break;
bf0fd768
CL
1254 case Opt_udp:
1255 mnt->flags &= ~NFS_MOUNT_TCP;
0896a725 1256 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
bf0fd768
CL
1257 break;
1258 case Opt_tcp:
1259 mnt->flags |= NFS_MOUNT_TCP;
0896a725 1260 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
bf0fd768 1261 break;
2cf7ff7a
TT
1262 case Opt_rdma:
1263 mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */
1264 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
a67d18f8 1265 xprt_load_transport(p);
2cf7ff7a 1266 break;
bf0fd768
CL
1267 case Opt_acl:
1268 mnt->flags &= ~NFS_MOUNT_NOACL;
1269 break;
1270 case Opt_noacl:
1271 mnt->flags |= NFS_MOUNT_NOACL;
1272 break;
1273 case Opt_rdirplus:
1274 mnt->flags &= ~NFS_MOUNT_NORDIRPLUS;
1275 break;
1276 case Opt_nordirplus:
1277 mnt->flags |= NFS_MOUNT_NORDIRPLUS;
1278 break;
75180df2
TM
1279 case Opt_sharecache:
1280 mnt->flags &= ~NFS_MOUNT_UNSHARED;
1281 break;
1282 case Opt_nosharecache:
1283 mnt->flags |= NFS_MOUNT_UNSHARED;
1284 break;
d740351b
CL
1285 case Opt_resvport:
1286 mnt->flags &= ~NFS_MOUNT_NORESVPORT;
1287 break;
1288 case Opt_noresvport:
1289 mnt->flags |= NFS_MOUNT_NORESVPORT;
1290 break;
b797cac7
DH
1291 case Opt_fscache:
1292 mnt->options |= NFS_OPTION_FSCACHE;
1293 kfree(mnt->fscache_uniq);
1294 mnt->fscache_uniq = NULL;
1295 break;
1296 case Opt_nofscache:
1297 mnt->options &= ~NFS_OPTION_FSCACHE;
1298 kfree(mnt->fscache_uniq);
1299 mnt->fscache_uniq = NULL;
1300 break;
89652617
CL
1301 case Opt_migration:
1302 mnt->options |= NFS_OPTION_MIGRATION;
1303 break;
1304 case Opt_nomigration:
1305 mnt->options &= NFS_OPTION_MIGRATION;
1306 break;
bf0fd768 1307
f45663ce
CL
1308 /*
1309 * options that take numeric values
1310 */
bf0fd768 1311 case Opt_port:
c5cb09b6
RL
1312 if (nfs_get_option_ul(args, &option) ||
1313 option > USHRT_MAX)
d23c45fd
CL
1314 goto out_invalid_value;
1315 mnt->nfs_server.port = option;
bf0fd768
CL
1316 break;
1317 case Opt_rsize:
c5cb09b6 1318 if (nfs_get_option_ul(args, &option))
d23c45fd
CL
1319 goto out_invalid_value;
1320 mnt->rsize = option;
bf0fd768
CL
1321 break;
1322 case Opt_wsize:
c5cb09b6 1323 if (nfs_get_option_ul(args, &option))
d23c45fd
CL
1324 goto out_invalid_value;
1325 mnt->wsize = option;
bf0fd768
CL
1326 break;
1327 case Opt_bsize:
c5cb09b6 1328 if (nfs_get_option_ul(args, &option))
d23c45fd
CL
1329 goto out_invalid_value;
1330 mnt->bsize = option;
bf0fd768
CL
1331 break;
1332 case Opt_timeo:
c5cb09b6 1333 if (nfs_get_option_ul(args, &option) || option == 0)
d23c45fd
CL
1334 goto out_invalid_value;
1335 mnt->timeo = option;
bf0fd768
CL
1336 break;
1337 case Opt_retrans:
c5cb09b6 1338 if (nfs_get_option_ul(args, &option) || option == 0)
d23c45fd
CL
1339 goto out_invalid_value;
1340 mnt->retrans = option;
bf0fd768
CL
1341 break;
1342 case Opt_acregmin:
c5cb09b6 1343 if (nfs_get_option_ul(args, &option))
d23c45fd
CL
1344 goto out_invalid_value;
1345 mnt->acregmin = option;
bf0fd768
CL
1346 break;
1347 case Opt_acregmax:
c5cb09b6 1348 if (nfs_get_option_ul(args, &option))
d23c45fd
CL
1349 goto out_invalid_value;
1350 mnt->acregmax = option;
bf0fd768
CL
1351 break;
1352 case Opt_acdirmin:
c5cb09b6 1353 if (nfs_get_option_ul(args, &option))
d23c45fd
CL
1354 goto out_invalid_value;
1355 mnt->acdirmin = option;
bf0fd768
CL
1356 break;
1357 case Opt_acdirmax:
c5cb09b6 1358 if (nfs_get_option_ul(args, &option))
d23c45fd
CL
1359 goto out_invalid_value;
1360 mnt->acdirmax = option;
bf0fd768
CL
1361 break;
1362 case Opt_actimeo:
c5cb09b6 1363 if (nfs_get_option_ul(args, &option))
d23c45fd
CL
1364 goto out_invalid_value;
1365 mnt->acregmin = mnt->acregmax =
1366 mnt->acdirmin = mnt->acdirmax = option;
bf0fd768
CL
1367 break;
1368 case Opt_namelen:
c5cb09b6 1369 if (nfs_get_option_ul(args, &option))
d23c45fd
CL
1370 goto out_invalid_value;
1371 mnt->namlen = option;
bf0fd768
CL
1372 break;
1373 case Opt_mountport:
c5cb09b6
RL
1374 if (nfs_get_option_ul(args, &option) ||
1375 option > USHRT_MAX)
d23c45fd
CL
1376 goto out_invalid_value;
1377 mnt->mount_server.port = option;
bf0fd768 1378 break;
bf0fd768 1379 case Opt_mountvers:
c5cb09b6 1380 if (nfs_get_option_ul(args, &option) ||
f45663ce 1381 option < NFS_MNT_VERSION ||
d23c45fd
CL
1382 option > NFS_MNT3_VERSION)
1383 goto out_invalid_value;
1384 mnt->mount_server.version = option;
bf0fd768 1385 break;
3fd5be9e 1386 case Opt_minorversion:
c5cb09b6 1387 if (nfs_get_option_ul(args, &option))
f3f4f4ed
CL
1388 goto out_invalid_value;
1389 if (option > NFS4_MAX_MINOR_VERSION)
1390 goto out_invalid_value;
1391 mnt->minorversion = option;
3fd5be9e 1392 break;
bf0fd768 1393
f45663ce
CL
1394 /*
1395 * options that take text values
1396 */
0d71b058
TM
1397 case Opt_nfsvers:
1398 string = match_strdup(args);
1399 if (string == NULL)
1400 goto out_nomem;
1401 rc = nfs_parse_version_string(string, mnt, args);
1402 kfree(string);
1403 if (!rc)
1404 goto out_invalid_value;
1405 break;
bf0fd768
CL
1406 case Opt_sec:
1407 string = match_strdup(args);
1408 if (string == NULL)
1409 goto out_nomem;
01060c89 1410 rc = nfs_parse_security_flavors(string, mnt);
bf0fd768 1411 kfree(string);
f45663ce 1412 if (!rc) {
f45663ce
CL
1413 dfprintk(MOUNT, "NFS: unrecognized "
1414 "security flavor\n");
d23c45fd 1415 return 0;
f45663ce 1416 }
bf0fd768
CL
1417 break;
1418 case Opt_proto:
1419 string = match_strdup(args);
1420 if (string == NULL)
1421 goto out_nomem;
1422 token = match_token(string,
1423 nfs_xprt_protocol_tokens, args);
bf0fd768 1424
ee671b01 1425 protofamily = AF_INET;
bf0fd768 1426 switch (token) {
ee671b01
JL
1427 case Opt_xprt_udp6:
1428 protofamily = AF_INET6;
fdb66ff4 1429 case Opt_xprt_udp:
bf0fd768 1430 mnt->flags &= ~NFS_MOUNT_TCP;
0896a725 1431 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
bf0fd768 1432 break;
ee671b01
JL
1433 case Opt_xprt_tcp6:
1434 protofamily = AF_INET6;
fdb66ff4 1435 case Opt_xprt_tcp:
bf0fd768 1436 mnt->flags |= NFS_MOUNT_TCP;
0896a725 1437 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
bf0fd768 1438 break;
2cf7ff7a
TT
1439 case Opt_xprt_rdma:
1440 /* vector side protocols to TCP */
1441 mnt->flags |= NFS_MOUNT_TCP;
1442 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
a67d18f8 1443 xprt_load_transport(string);
2cf7ff7a 1444 break;
bf0fd768 1445 default:
f45663ce
CL
1446 dfprintk(MOUNT, "NFS: unrecognized "
1447 "transport protocol\n");
4223a4a1 1448 kfree(string);
d23c45fd 1449 return 0;
bf0fd768 1450 }
c5cb09b6 1451 kfree(string);
bf0fd768
CL
1452 break;
1453 case Opt_mountproto:
1454 string = match_strdup(args);
1455 if (string == NULL)
1456 goto out_nomem;
1457 token = match_token(string,
1458 nfs_xprt_protocol_tokens, args);
d508afb4 1459 kfree(string);
bf0fd768 1460
ee671b01 1461 mountfamily = AF_INET;
bf0fd768 1462 switch (token) {
ee671b01
JL
1463 case Opt_xprt_udp6:
1464 mountfamily = AF_INET6;
fdb66ff4 1465 case Opt_xprt_udp:
0896a725 1466 mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
bf0fd768 1467 break;
ee671b01
JL
1468 case Opt_xprt_tcp6:
1469 mountfamily = AF_INET6;
fdb66ff4 1470 case Opt_xprt_tcp:
0896a725 1471 mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
bf0fd768 1472 break;
2cf7ff7a 1473 case Opt_xprt_rdma: /* not used for side protocols */
bf0fd768 1474 default:
f45663ce
CL
1475 dfprintk(MOUNT, "NFS: unrecognized "
1476 "transport protocol\n");
d23c45fd 1477 return 0;
bf0fd768
CL
1478 }
1479 break;
1480 case Opt_addr:
1481 string = match_strdup(args);
1482 if (string == NULL)
1483 goto out_nomem;
53a0b9c4 1484 mnt->nfs_server.addrlen =
b48e1278 1485 rpc_pton(mnt->net, string, strlen(string),
53a0b9c4
CL
1486 (struct sockaddr *)
1487 &mnt->nfs_server.address,
1488 sizeof(mnt->nfs_server.address));
bf0fd768 1489 kfree(string);
53a0b9c4
CL
1490 if (mnt->nfs_server.addrlen == 0)
1491 goto out_invalid_address;
bf0fd768
CL
1492 break;
1493 case Opt_clientaddr:
c5cb09b6 1494 if (nfs_get_option_str(args, &mnt->client_address))
bf0fd768 1495 goto out_nomem;
bf0fd768 1496 break;
33832034 1497 case Opt_mounthost:
c5cb09b6
RL
1498 if (nfs_get_option_str(args,
1499 &mnt->mount_server.hostname))
33832034 1500 goto out_nomem;
33832034 1501 break;
0ac83779 1502 case Opt_mountaddr:
bf0fd768
CL
1503 string = match_strdup(args);
1504 if (string == NULL)
1505 goto out_nomem;
53a0b9c4 1506 mnt->mount_server.addrlen =
b48e1278 1507 rpc_pton(mnt->net, string, strlen(string),
53a0b9c4
CL
1508 (struct sockaddr *)
1509 &mnt->mount_server.address,
1510 sizeof(mnt->mount_server.address));
bf0fd768 1511 kfree(string);
53a0b9c4
CL
1512 if (mnt->mount_server.addrlen == 0)
1513 goto out_invalid_address;
bf0fd768 1514 break;
7973c1f1
TM
1515 case Opt_lookupcache:
1516 string = match_strdup(args);
1517 if (string == NULL)
1518 goto out_nomem;
1519 token = match_token(string,
1520 nfs_lookupcache_tokens, args);
1521 kfree(string);
1522 switch (token) {
1523 case Opt_lookupcache_all:
1524 mnt->flags &= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE);
1525 break;
1526 case Opt_lookupcache_positive:
1527 mnt->flags &= ~NFS_MOUNT_LOOKUP_CACHE_NONE;
1528 mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG;
1529 break;
1530 case Opt_lookupcache_none:
1531 mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE;
1532 break;
1533 default:
7973c1f1
TM
1534 dfprintk(MOUNT, "NFS: invalid "
1535 "lookupcache argument\n");
d23c45fd 1536 return 0;
7973c1f1
TM
1537 };
1538 break;
a6d5ff64 1539 case Opt_fscache_uniq:
c5cb09b6 1540 if (nfs_get_option_str(args, &mnt->fscache_uniq))
a6d5ff64 1541 goto out_nomem;
a6d5ff64
CL
1542 mnt->options |= NFS_OPTION_FSCACHE;
1543 break;
5eebde23
SJ
1544 case Opt_local_lock:
1545 string = match_strdup(args);
1546 if (string == NULL)
1547 goto out_nomem;
1548 token = match_token(string, nfs_local_lock_tokens,
1549 args);
1550 kfree(string);
1551 switch (token) {
1552 case Opt_local_lock_all:
1553 mnt->flags |= (NFS_MOUNT_LOCAL_FLOCK |
1554 NFS_MOUNT_LOCAL_FCNTL);
1555 break;
1556 case Opt_local_lock_flock:
1557 mnt->flags |= NFS_MOUNT_LOCAL_FLOCK;
1558 break;
1559 case Opt_local_lock_posix:
1560 mnt->flags |= NFS_MOUNT_LOCAL_FCNTL;
1561 break;
1562 case Opt_local_lock_none:
1563 mnt->flags &= ~(NFS_MOUNT_LOCAL_FLOCK |
1564 NFS_MOUNT_LOCAL_FCNTL);
1565 break;
1566 default:
1567 dfprintk(MOUNT, "NFS: invalid "
1568 "local_lock argument\n");
1569 return 0;
1570 };
1571 break;
bf0fd768 1572
f45663ce
CL
1573 /*
1574 * Special options
1575 */
1576 case Opt_sloppy:
1577 sloppy = 1;
1578 dfprintk(MOUNT, "NFS: relaxing parsing rules\n");
1579 break;
bf0fd768
CL
1580 case Opt_userspace:
1581 case Opt_deprecated:
d33e4dfe
CL
1582 dfprintk(MOUNT, "NFS: ignoring mount option "
1583 "'%s'\n", p);
bf0fd768
CL
1584 break;
1585
1586 default:
d23c45fd 1587 invalid_option = 1;
f45663ce
CL
1588 dfprintk(MOUNT, "NFS: unrecognized mount option "
1589 "'%s'\n", p);
bf0fd768
CL
1590 }
1591 }
1592
d23c45fd
CL
1593 if (!sloppy && invalid_option)
1594 return 0;
1595
571b7554
WAA
1596 if (mnt->minorversion && mnt->version != 4)
1597 goto out_minorversion_mismatch;
1598
89652617
CL
1599 if (mnt->options & NFS_OPTION_MIGRATION &&
1600 mnt->version != 4 && mnt->minorversion != 0)
1601 goto out_migration_misuse;
1602
ee671b01
JL
1603 /*
1604 * verify that any proto=/mountproto= options match the address
1856b225 1605 * families in the addr=/mountaddr= options.
ee671b01
JL
1606 */
1607 if (protofamily != AF_UNSPEC &&
1608 protofamily != mnt->nfs_server.address.ss_family)
1609 goto out_proto_mismatch;
1610
1611 if (mountfamily != AF_UNSPEC) {
1612 if (mnt->mount_server.addrlen) {
1613 if (mountfamily != mnt->mount_server.address.ss_family)
1614 goto out_mountproto_mismatch;
1615 } else {
1616 if (mountfamily != mnt->nfs_server.address.ss_family)
1617 goto out_mountproto_mismatch;
1618 }
1619 }
1620
bf0fd768
CL
1621 return 1;
1622
ee671b01
JL
1623out_mountproto_mismatch:
1624 printk(KERN_INFO "NFS: mount server address does not match mountproto= "
1625 "option\n");
1626 return 0;
1627out_proto_mismatch:
1628 printk(KERN_INFO "NFS: server address does not match proto= option\n");
1629 return 0;
53a0b9c4
CL
1630out_invalid_address:
1631 printk(KERN_INFO "NFS: bad IP address specified: %s\n", p);
1632 return 0;
d23c45fd 1633out_invalid_value:
53a0b9c4 1634 printk(KERN_INFO "NFS: bad mount option value specified: %s\n", p);
d23c45fd 1635 return 0;
571b7554
WAA
1636out_minorversion_mismatch:
1637 printk(KERN_INFO "NFS: mount option vers=%u does not support "
1638 "minorversion=%u\n", mnt->version, mnt->minorversion);
1639 return 0;
89652617
CL
1640out_migration_misuse:
1641 printk(KERN_INFO
1642 "NFS: 'migration' not supported for this NFS version\n");
1643 return 0;
bf0fd768
CL
1644out_nomem:
1645 printk(KERN_INFO "NFS: not enough memory to parse option\n");
1646 return 0;
f9c3a380
EP
1647out_security_failure:
1648 free_secdata(secdata);
1649 printk(KERN_INFO "NFS: security options invalid: %d\n", rc);
1650 return 0;
bf0fd768
CL
1651}
1652
ec88f28d
CL
1653/*
1654 * Match the requested auth flavors with the list returned by
1655 * the server. Returns zero and sets the mount's authentication
1656 * flavor on success; returns -EACCES if server does not support
1657 * the requested flavor.
1658 */
1659static int nfs_walk_authlist(struct nfs_parsed_mount_data *args,
1660 struct nfs_mount_request *request)
1661{
1662 unsigned int i, j, server_authlist_len = *(request->auth_flav_len);
1663
5eecfde6
CL
1664 /*
1665 * Certain releases of Linux's mountd return an empty
1666 * flavor list. To prevent behavioral regression with
1667 * these servers (ie. rejecting mounts that used to
1668 * succeed), revert to pre-2.6.32 behavior (no checking)
1669 * if the returned flavor list is empty.
1670 */
1671 if (server_authlist_len == 0)
1672 return 0;
1673
ec88f28d
CL
1674 /*
1675 * We avoid sophisticated negotiating here, as there are
1676 * plenty of cases where we can get it wrong, providing
1677 * either too little or too much security.
1678 *
1679 * RFC 2623, section 2.7 suggests we SHOULD prefer the
1680 * flavor listed first. However, some servers list
1681 * AUTH_NULL first. Our caller plants AUTH_SYS, the
1682 * preferred default, in args->auth_flavors[0] if user
1683 * didn't specify sec= mount option.
1684 */
1685 for (i = 0; i < args->auth_flavor_len; i++)
1686 for (j = 0; j < server_authlist_len; j++)
1687 if (args->auth_flavors[i] == request->auth_flavs[j]) {
1688 dfprintk(MOUNT, "NFS: using auth flavor %d\n",
1689 request->auth_flavs[j]);
1690 args->auth_flavors[0] = request->auth_flavs[j];
1691 return 0;
1692 }
1693
1694 dfprintk(MOUNT, "NFS: server does not support requested auth flavor\n");
1695 nfs_umount(request);
1696 return -EACCES;
1697}
1698
0076d7b7
CL
1699/*
1700 * Use the remote server's MOUNT service to request the NFS file handle
1701 * corresponding to the provided path.
1702 */
486aa699
BS
1703static int nfs_request_mount(struct nfs_parsed_mount_data *args,
1704 struct nfs_fh *root_fh)
0076d7b7 1705{
ec88f28d
CL
1706 rpc_authflavor_t server_authlist[NFS_MAX_SECFLAVORS];
1707 unsigned int server_authlist_len = ARRAY_SIZE(server_authlist);
c5d120f8
CL
1708 struct nfs_mount_request request = {
1709 .sap = (struct sockaddr *)
1710 &args->mount_server.address,
1711 .dirpath = args->nfs_server.export_path,
1712 .protocol = args->mount_server.protocol,
1713 .fh = root_fh,
50a737f8 1714 .noresvport = args->flags & NFS_MOUNT_NORESVPORT,
ec88f28d
CL
1715 .auth_flav_len = &server_authlist_len,
1716 .auth_flavs = server_authlist,
6d59b8d5 1717 .net = args->net,
c5d120f8 1718 };
4c568017 1719 int status;
0076d7b7
CL
1720
1721 if (args->mount_server.version == 0) {
8a6e5deb
TM
1722 switch (args->version) {
1723 default:
1724 args->mount_server.version = NFS_MNT3_VERSION;
1725 break;
1726 case 2:
1727 args->mount_server.version = NFS_MNT_VERSION;
1728 }
0076d7b7 1729 }
c5d120f8 1730 request.version = args->mount_server.version;
0076d7b7 1731
33832034 1732 if (args->mount_server.hostname)
c5d120f8 1733 request.hostname = args->mount_server.hostname;
33832034 1734 else
c5d120f8 1735 request.hostname = args->nfs_server.hostname;
33832034 1736
0076d7b7
CL
1737 /*
1738 * Construct the mount server's address.
1739 */
4c568017 1740 if (args->mount_server.address.ss_family == AF_UNSPEC) {
c5d120f8 1741 memcpy(request.sap, &args->nfs_server.address,
4c568017
CL
1742 args->nfs_server.addrlen);
1743 args->mount_server.addrlen = args->nfs_server.addrlen;
1744 }
c5d120f8 1745 request.salen = args->mount_server.addrlen;
f5855fec 1746 nfs_set_port(request.sap, &args->mount_server.port, 0);
0076d7b7
CL
1747
1748 /*
1749 * Now ask the mount server to map our export path
1750 * to a file handle.
1751 */
c5d120f8 1752 status = nfs_mount(&request);
ec88f28d
CL
1753 if (status != 0) {
1754 dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n",
1755 request.hostname, status);
1756 return status;
1757 }
0076d7b7 1758
ec88f28d
CL
1759 /*
1760 * MNTv1 (NFSv2) does not support auth flavor negotiation.
1761 */
1762 if (args->mount_server.version != NFS_MNT3_VERSION)
1763 return 0;
1764 return nfs_walk_authlist(args, &request);
0076d7b7
CL
1765}
1766
ff9099f2
BS
1767struct dentry *nfs_try_mount(int flags, const char *dev_name,
1768 struct nfs_mount_info *mount_info,
1769 struct nfs_subversion *nfs_mod)
486aa699
BS
1770{
1771 int status;
1772 struct nfs_server *server;
1773
b72e4f42 1774 if (mount_info->parsed->need_mount) {
87c7083d 1775 status = nfs_request_mount(mount_info->parsed, mount_info->mntfh);
b72e4f42
BS
1776 if (status)
1777 return ERR_PTR(status);
1778 }
486aa699
BS
1779
1780 /* Get a volume representation */
1179acc6 1781 server = nfs_mod->rpc_ops->create_server(mount_info, nfs_mod);
486aa699
BS
1782 if (IS_ERR(server))
1783 return ERR_CAST(server);
1784
ab7017a3 1785 return nfs_fs_mount_common(server, flags, dev_name, mount_info, nfs_mod);
486aa699 1786}
ddda8e0a 1787EXPORT_SYMBOL_GPL(nfs_try_mount);
486aa699 1788
c12bacec
RL
1789/*
1790 * Split "dev_name" into "hostname:export_path".
1791 *
1792 * The leftmost colon demarks the split between the server's hostname
1793 * and the export path. If the hostname starts with a left square
1794 * bracket, then it may contain colons.
1795 *
1796 * Note: caller frees hostname and export path, even on error.
1797 */
1798static int nfs_parse_devname(const char *dev_name,
1799 char **hostname, size_t maxnamlen,
1800 char **export_path, size_t maxpathlen)
dc045898
CL
1801{
1802 size_t len;
c12bacec 1803 char *end;
dc045898 1804
c12bacec
RL
1805 /* Is the host name protected with square brakcets? */
1806 if (*dev_name == '[') {
1807 end = strchr(++dev_name, ']');
1808 if (end == NULL || end[1] != ':')
dc045898 1809 goto out_bad_devname;
dc045898 1810
c12bacec
RL
1811 len = end - dev_name;
1812 end++;
1813 } else {
1814 char *comma;
dc045898 1815
c12bacec
RL
1816 end = strchr(dev_name, ':');
1817 if (end == NULL)
1818 goto out_bad_devname;
1819 len = end - dev_name;
d1aa0825 1820
c12bacec
RL
1821 /* kill possible hostname list: not supported */
1822 comma = strchr(dev_name, ',');
1823 if (comma != NULL && comma < end)
1824 *comma = 0;
1825 }
d1aa0825 1826
d1aa0825
CL
1827 if (len > maxnamlen)
1828 goto out_hostname;
1829
1830 /* N.B. caller will free nfs_server.hostname in all cases */
c12bacec 1831 *hostname = kstrndup(dev_name, len, GFP_KERNEL);
d1aa0825
CL
1832 if (*hostname == NULL)
1833 goto out_nomem;
c12bacec 1834 len = strlen(++end);
d1aa0825
CL
1835 if (len > maxpathlen)
1836 goto out_path;
1837 *export_path = kstrndup(end, len, GFP_KERNEL);
1838 if (!*export_path)
1839 goto out_nomem;
1840
c12bacec 1841 dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", *export_path);
d1aa0825
CL
1842 return 0;
1843
1844out_bad_devname:
1845 dfprintk(MOUNT, "NFS: device name not in host:path format\n");
1846 return -EINVAL;
1847
1848out_nomem:
1849 dfprintk(MOUNT, "NFS: not enough memory to parse device name\n");
1850 return -ENOMEM;
1851
1852out_hostname:
1853 dfprintk(MOUNT, "NFS: server hostname too long\n");
1854 return -ENAMETOOLONG;
1855
1856out_path:
1857 dfprintk(MOUNT, "NFS: export pathname too long\n");
1858 return -ENAMETOOLONG;
1859}
1860
f7b422b1 1861/*
54ceac45
DH
1862 * Validate the NFS2/NFS3 mount data
1863 * - fills in the mount root filehandle
136d558c
CL
1864 *
1865 * For option strings, user space handles the following behaviors:
1866 *
1867 * + DNS: mapping server host name to IP address ("addr=" option)
1868 *
1869 * + failure mode: how to behave if a mount request can't be handled
1870 * immediately ("fg/bg" option)
1871 *
1872 * + retry: how often to retry a mount request ("retry=" option)
1873 *
1874 * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
1875 * mountproto=tcp after mountproto=udp, and so on
f7b422b1 1876 */
d72c727c
BS
1877static int nfs23_validate_mount_data(void *options,
1878 struct nfs_parsed_mount_data *args,
1879 struct nfs_fh *mntfh,
1880 const char *dev_name)
f7b422b1 1881{
2283f8d6 1882 struct nfs_mount_data *data = (struct nfs_mount_data *)options;
4cfd74fc 1883 struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address;
136d558c 1884
5df36e78
CL
1885 if (data == NULL)
1886 goto out_no_data;
f7b422b1 1887
c5afc8da 1888 args->version = NFS_DEFAULT_VERSION;
54ceac45 1889 switch (data->version) {
5df36e78
CL
1890 case 1:
1891 data->namlen = 0;
1892 case 2:
1893 data->bsize = 0;
1894 case 3:
1895 if (data->flags & NFS_MOUNT_VER3)
1896 goto out_no_v3;
1897 data->root.size = NFS2_FHSIZE;
1898 memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE);
1899 case 4:
1900 if (data->flags & NFS_MOUNT_SECFLAVOUR)
1901 goto out_no_sec;
1902 case 5:
1903 memset(data->context, 0, sizeof(data->context));
1904 case 6:
b7e24457
TM
1905 if (data->flags & NFS_MOUNT_VER3) {
1906 if (data->root.size > NFS3_FHSIZE || data->root.size == 0)
1907 goto out_invalid_fh;
5df36e78 1908 mntfh->size = data->root.size;
764302cc
CL
1909 args->version = 3;
1910 } else {
5df36e78 1911 mntfh->size = NFS2_FHSIZE;
764302cc
CL
1912 args->version = 2;
1913 }
5df36e78 1914
5df36e78
CL
1915
1916 memcpy(mntfh->data, data->root.data, mntfh->size);
1917 if (mntfh->size < sizeof(mntfh->data))
1918 memset(mntfh->data + mntfh->size, 0,
1919 sizeof(mntfh->data) - mntfh->size);
6e88e061 1920
2283f8d6
TT
1921 /*
1922 * Translate to nfs_parsed_mount_data, which nfs_fill_super
1923 * can deal with.
1924 */
ff3525a5 1925 args->flags = data->flags & NFS_MOUNT_FLAGMASK;
d5eff1a3 1926 args->flags |= NFS_MOUNT_LEGACY_INTERFACE;
2283f8d6
TT
1927 args->rsize = data->rsize;
1928 args->wsize = data->wsize;
2283f8d6
TT
1929 args->timeo = data->timeo;
1930 args->retrans = data->retrans;
1931 args->acregmin = data->acregmin;
1932 args->acregmax = data->acregmax;
1933 args->acdirmin = data->acdirmin;
1934 args->acdirmax = data->acdirmax;
b72e4f42 1935 args->need_mount = false;
4c568017 1936
4cfd74fc 1937 memcpy(sap, &data->addr, sizeof(data->addr));
4c568017 1938 args->nfs_server.addrlen = sizeof(data->addr);
872ece86 1939 args->nfs_server.port = ntohs(data->addr.sin_port);
4cfd74fc 1940 if (!nfs_verify_server_address(sap))
4c568017
CL
1941 goto out_no_address;
1942
2283f8d6 1943 if (!(data->flags & NFS_MOUNT_TCP))
0896a725 1944 args->nfs_server.protocol = XPRT_TRANSPORT_UDP;
2283f8d6
TT
1945 /* N.B. caller will free nfs_server.hostname in all cases */
1946 args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL);
1947 args->namlen = data->namlen;
1948 args->bsize = data->bsize;
dd07c947
CL
1949
1950 if (data->flags & NFS_MOUNT_SECFLAVOUR)
1951 args->auth_flavors[0] = data->pseudoflavor;
63649bd7
CG
1952 if (!args->nfs_server.hostname)
1953 goto out_nomem;
f9c3a380 1954
5eebde23
SJ
1955 if (!(data->flags & NFS_MOUNT_NONLM))
1956 args->flags &= ~(NFS_MOUNT_LOCAL_FLOCK|
1957 NFS_MOUNT_LOCAL_FCNTL);
1958 else
1959 args->flags |= (NFS_MOUNT_LOCAL_FLOCK|
1960 NFS_MOUNT_LOCAL_FCNTL);
f9c3a380
EP
1961 /*
1962 * The legacy version 6 binary mount data from userspace has a
1963 * field used only to transport selinux information into the
1964 * the kernel. To continue to support that functionality we
1965 * have a touch of selinux knowledge here in the NFS code. The
1966 * userspace code converted context=blah to just blah so we are
1967 * converting back to the full string selinux understands.
1968 */
1969 if (data->context[0]){
1970#ifdef CONFIG_SECURITY_SELINUX
1971 int rc;
1972 char *opts_str = kmalloc(sizeof(data->context) + 8, GFP_KERNEL);
1973 if (!opts_str)
1974 return -ENOMEM;
1975 strcpy(opts_str, "context=");
1976 data->context[NFS_MAX_CONTEXT_LEN] = '\0';
1977 strcat(opts_str, &data->context[0]);
1978 rc = security_sb_parse_opts_str(opts_str, &args->lsm_opts);
1979 kfree(opts_str);
1980 if (rc)
1981 return rc;
1982#else
1983 return -EINVAL;
1984#endif
1985 }
1986
5df36e78 1987 break;
b72e4f42
BS
1988 default:
1989 return NFS_TEXT_DATA;
f7b422b1 1990 }
54ceac45 1991
1c606fb7 1992#if !IS_ENABLED(CONFIG_NFS_V3)
8a6e5deb 1993 if (args->version == 3)
5df36e78
CL
1994 goto out_v3_not_compiled;
1995#endif /* !CONFIG_NFS_V3 */
f7b422b1 1996
5df36e78 1997 return 0;
f7b422b1 1998
5df36e78
CL
1999out_no_data:
2000 dfprintk(MOUNT, "NFS: mount program didn't pass any mount data\n");
2001 return -EINVAL;
54ceac45 2002
5df36e78
CL
2003out_no_v3:
2004 dfprintk(MOUNT, "NFS: nfs_mount_data version %d does not support v3\n",
2005 data->version);
2006 return -EINVAL;
f7b422b1 2007
5df36e78
CL
2008out_no_sec:
2009 dfprintk(MOUNT, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
2010 return -EINVAL;
2011
1c606fb7 2012#if !IS_ENABLED(CONFIG_NFS_V3)
5df36e78
CL
2013out_v3_not_compiled:
2014 dfprintk(MOUNT, "NFS: NFSv3 is not compiled into kernel\n");
2015 return -EPROTONOSUPPORT;
2016#endif /* !CONFIG_NFS_V3 */
2017
63649bd7
CG
2018out_nomem:
2019 dfprintk(MOUNT, "NFS: not enough memory to handle mount options\n");
2020 return -ENOMEM;
2021
5df36e78
CL
2022out_no_address:
2023 dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n");
2024 return -EINVAL;
2025
2026out_invalid_fh:
2027 dfprintk(MOUNT, "NFS: invalid root filehandle\n");
2028 return -EINVAL;
f7b422b1
DH
2029}
2030
89d77c8f 2031#if IS_ENABLED(CONFIG_NFS_V4)
d72c727c
BS
2032static int nfs_validate_mount_data(struct file_system_type *fs_type,
2033 void *options,
2034 struct nfs_parsed_mount_data *args,
2035 struct nfs_fh *mntfh,
2036 const char *dev_name)
2037{
2038 if (fs_type == &nfs_fs_type)
2039 return nfs23_validate_mount_data(options, args, mntfh, dev_name);
2040 return nfs4_validate_mount_data(options, args, dev_name);
2041}
2042#else
2043static int nfs_validate_mount_data(struct file_system_type *fs_type,
2044 void *options,
2045 struct nfs_parsed_mount_data *args,
2046 struct nfs_fh *mntfh,
2047 const char *dev_name)
2048{
2049 return nfs23_validate_mount_data(options, args, mntfh, dev_name);
2050}
2051#endif
2052
b72e4f42
BS
2053static int nfs_validate_text_mount_data(void *options,
2054 struct nfs_parsed_mount_data *args,
2055 const char *dev_name)
2056{
2057 int port = 0;
2058 int max_namelen = PAGE_SIZE;
2059 int max_pathlen = NFS_MAXPATHLEN;
2060 struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address;
2061
2062 if (nfs_parse_mount_options((char *)options, args) == 0)
2063 return -EINVAL;
2064
2065 if (!nfs_verify_server_address(sap))
2066 goto out_no_address;
2067
2068 if (args->version == 4) {
89d77c8f 2069#if IS_ENABLED(CONFIG_NFS_V4)
b72e4f42
BS
2070 port = NFS_PORT;
2071 max_namelen = NFS4_MAXNAMLEN;
2072 max_pathlen = NFS4_MAXPATHLEN;
2073 nfs_validate_transport_protocol(args);
2074 nfs4_validate_mount_flags(args);
2075#else
2076 goto out_v4_not_compiled;
2077#endif /* CONFIG_NFS_V4 */
2078 } else
2079 nfs_set_mount_transport_protocol(args);
2080
2081 nfs_set_port(sap, &args->nfs_server.port, port);
2082
2083 if (args->auth_flavor_len > 1)
2084 goto out_bad_auth;
2085
2086 return nfs_parse_devname(dev_name,
2087 &args->nfs_server.hostname,
2088 max_namelen,
2089 &args->nfs_server.export_path,
2090 max_pathlen);
2091
89d77c8f 2092#if !IS_ENABLED(CONFIG_NFS_V4)
b72e4f42
BS
2093out_v4_not_compiled:
2094 dfprintk(MOUNT, "NFS: NFSv4 is not compiled into kernel\n");
2095 return -EPROTONOSUPPORT;
2096#endif /* !CONFIG_NFS_V4 */
2097
2098out_no_address:
2099 dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n");
2100 return -EINVAL;
2101
2102out_bad_auth:
2103 dfprintk(MOUNT, "NFS: Too many RPC auth flavours specified\n");
2104 return -EINVAL;
2105}
2106
48b605f8
JL
2107static int
2108nfs_compare_remount_data(struct nfs_server *nfss,
2109 struct nfs_parsed_mount_data *data)
2110{
2111 if (data->flags != nfss->flags ||
2112 data->rsize != nfss->rsize ||
2113 data->wsize != nfss->wsize ||
2114 data->retrans != nfss->client->cl_timeout->to_retries ||
2115 data->auth_flavors[0] != nfss->client->cl_auth->au_flavor ||
2116 data->acregmin != nfss->acregmin / HZ ||
2117 data->acregmax != nfss->acregmax / HZ ||
2118 data->acdirmin != nfss->acdirmin / HZ ||
2119 data->acdirmax != nfss->acdirmax / HZ ||
2120 data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) ||
bcd2ea17 2121 data->nfs_server.port != nfss->port ||
48b605f8 2122 data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen ||
a1be9eee
SR
2123 !rpc_cmp_addr((struct sockaddr *)&data->nfs_server.address,
2124 (struct sockaddr *)&nfss->nfs_client->cl_addr))
48b605f8
JL
2125 return -EINVAL;
2126
2127 return 0;
2128}
2129
fbdefd64 2130int
48b605f8
JL
2131nfs_remount(struct super_block *sb, int *flags, char *raw_data)
2132{
2133 int error;
2134 struct nfs_server *nfss = sb->s_fs_info;
2135 struct nfs_parsed_mount_data *data;
2136 struct nfs_mount_data *options = (struct nfs_mount_data *)raw_data;
2137 struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data;
cd100725 2138 u32 nfsvers = nfss->nfs_client->rpc_ops->version;
48b605f8
JL
2139
2140 /*
2141 * Userspace mount programs that send binary options generally send
2142 * them populated with default values. We have no way to know which
2143 * ones were explicitly specified. Fall back to legacy behavior and
2144 * just return success.
2145 */
31c94469
MZ
2146 if ((nfsvers == 4 && (!options4 || options4->version == 1)) ||
2147 (nfsvers <= 3 && (!options || (options->version >= 1 &&
2148 options->version <= 6))))
48b605f8
JL
2149 return 0;
2150
2151 data = kzalloc(sizeof(*data), GFP_KERNEL);
2152 if (data == NULL)
2153 return -ENOMEM;
2154
2155 /* fill out struct with values from existing mount */
2156 data->flags = nfss->flags;
2157 data->rsize = nfss->rsize;
2158 data->wsize = nfss->wsize;
2159 data->retrans = nfss->client->cl_timeout->to_retries;
2160 data->auth_flavors[0] = nfss->client->cl_auth->au_flavor;
2161 data->acregmin = nfss->acregmin / HZ;
2162 data->acregmax = nfss->acregmax / HZ;
2163 data->acdirmin = nfss->acdirmin / HZ;
2164 data->acdirmax = nfss->acdirmax / HZ;
2165 data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ;
bcd2ea17 2166 data->nfs_server.port = nfss->port;
48b605f8
JL
2167 data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen;
2168 memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr,
2169 data->nfs_server.addrlen);
2170
2171 /* overwrite those values with any that were specified */
2172 error = nfs_parse_mount_options((char *)options, data);
2173 if (error < 0)
2174 goto out;
2175
26c4c170
JL
2176 /*
2177 * noac is a special case. It implies -o sync, but that's not
2178 * necessarily reflected in the mtab options. do_remount_sb
2179 * will clear MS_SYNCHRONOUS if -o sync wasn't specified in the
2180 * remount options, so we have to explicitly reset it.
2181 */
2182 if (data->flags & NFS_MOUNT_NOAC)
2183 *flags |= MS_SYNCHRONOUS;
2184
48b605f8
JL
2185 /* compare new mount options with old ones */
2186 error = nfs_compare_remount_data(nfss, data);
2187out:
2188 kfree(data);
2189 return error;
2190}
89d77c8f 2191EXPORT_SYMBOL_GPL(nfs_remount);
48b605f8 2192
f7b422b1 2193/*
54ceac45 2194 * Initialise the common bits of the superblock
f7b422b1 2195 */
fbdefd64 2196inline void nfs_initialise_sb(struct super_block *sb)
f7b422b1 2197{
54ceac45 2198 struct nfs_server *server = NFS_SB(sb);
5006a76c 2199
54ceac45 2200 sb->s_magic = NFS_SUPER_MAGIC;
f7b422b1 2201
54ceac45
DH
2202 /* We probably want something more informative here */
2203 snprintf(sb->s_id, sizeof(sb->s_id),
5a7c9eec 2204 "%u:%u", MAJOR(sb->s_dev), MINOR(sb->s_dev));
5006a76c 2205
54ceac45
DH
2206 if (sb->s_blocksize == 0)
2207 sb->s_blocksize = nfs_block_bits(server->wsize,
2208 &sb->s_blocksize_bits);
f7b422b1 2209
32a88aa1
JA
2210 sb->s_bdi = &server->backing_dev_info;
2211
54ceac45 2212 nfs_super_set_maxbytes(sb, server->maxfilesize);
f7b422b1
DH
2213}
2214
2215/*
54ceac45 2216 * Finish setting up an NFS2/3 superblock
f7b422b1 2217 */
fbdefd64 2218void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info)
f7b422b1 2219{
c40f8d1d 2220 struct nfs_parsed_mount_data *data = mount_info->parsed;
f7b422b1 2221 struct nfs_server *server = NFS_SB(sb);
5006a76c 2222
54ceac45
DH
2223 sb->s_blocksize_bits = 0;
2224 sb->s_blocksize = 0;
6a74490d
BS
2225 sb->s_xattr = server->nfs_client->cl_nfs_mod->xattr;
2226 sb->s_op = server->nfs_client->cl_nfs_mod->sops;
2227 if (data && data->bsize)
54ceac45 2228 sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits);
f7b422b1 2229
6a74490d 2230 if (server->nfs_client->rpc_ops->version != 2) {
54ceac45
DH
2231 /* The VFS shouldn't apply the umask to mode bits. We will do
2232 * so ourselves when necessary.
2233 */
2234 sb->s_flags |= MS_POSIXACL;
2235 sb->s_time_gran = 1;
816724e6 2236 }
54ceac45 2237
54ceac45 2238 nfs_initialise_sb(sb);
f7b422b1 2239}
89d77c8f 2240EXPORT_SYMBOL_GPL(nfs_fill_super);
f7b422b1
DH
2241
2242/*
3cadf4b8 2243 * Finish setting up a cloned NFS2/3/4 superblock
f7b422b1 2244 */
fbdefd64 2245void nfs_clone_super(struct super_block *sb, struct nfs_mount_info *mount_info)
f7b422b1 2246{
8c958e0c 2247 const struct super_block *old_sb = mount_info->cloned->sb;
54ceac45
DH
2248 struct nfs_server *server = NFS_SB(sb);
2249
2250 sb->s_blocksize_bits = old_sb->s_blocksize_bits;
2251 sb->s_blocksize = old_sb->s_blocksize;
2252 sb->s_maxbytes = old_sb->s_maxbytes;
3cadf4b8
BS
2253 sb->s_xattr = old_sb->s_xattr;
2254 sb->s_op = old_sb->s_op;
2255 sb->s_time_gran = 1;
f7b422b1 2256
3cadf4b8 2257 if (server->nfs_client->rpc_ops->version != 2) {
54ceac45
DH
2258 /* The VFS shouldn't apply the umask to mode bits. We will do
2259 * so ourselves when necessary.
f7b422b1
DH
2260 */
2261 sb->s_flags |= MS_POSIXACL;
f7b422b1
DH
2262 }
2263
54ceac45 2264 nfs_initialise_sb(sb);
f7b422b1
DH
2265}
2266
275a5d24
TM
2267static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
2268{
2269 const struct nfs_server *a = s->s_fs_info;
2270 const struct rpc_clnt *clnt_a = a->client;
2271 const struct rpc_clnt *clnt_b = b->client;
2272
2273 if ((s->s_flags & NFS_MS_MASK) != (flags & NFS_MS_MASK))
2274 goto Ebusy;
2275 if (a->nfs_client != b->nfs_client)
2276 goto Ebusy;
2277 if (a->flags != b->flags)
2278 goto Ebusy;
2279 if (a->wsize != b->wsize)
2280 goto Ebusy;
2281 if (a->rsize != b->rsize)
2282 goto Ebusy;
2283 if (a->acregmin != b->acregmin)
2284 goto Ebusy;
2285 if (a->acregmax != b->acregmax)
2286 goto Ebusy;
2287 if (a->acdirmin != b->acdirmin)
2288 goto Ebusy;
2289 if (a->acdirmax != b->acdirmax)
2290 goto Ebusy;
2291 if (clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor)
2292 goto Ebusy;
e89a5a43 2293 return 1;
275a5d24 2294Ebusy:
e89a5a43
TM
2295 return 0;
2296}
2297
2298struct nfs_sb_mountdata {
2299 struct nfs_server *server;
2300 int mntflags;
2301};
2302
2303static int nfs_set_super(struct super_block *s, void *data)
2304{
2305 struct nfs_sb_mountdata *sb_mntdata = data;
2306 struct nfs_server *server = sb_mntdata->server;
2307 int ret;
2308
2309 s->s_flags = sb_mntdata->mntflags;
2310 s->s_fs_info = server;
8b244ff2 2311 s->s_d_op = server->nfs_client->rpc_ops->dentry_ops;
e89a5a43
TM
2312 ret = set_anon_super(s, server);
2313 if (ret == 0)
2314 server->s_dev = s->s_dev;
2315 return ret;
2316}
2317
fd00a8ff
CL
2318static int nfs_compare_super_address(struct nfs_server *server1,
2319 struct nfs_server *server2)
2320{
2321 struct sockaddr *sap1, *sap2;
2322
2323 sap1 = (struct sockaddr *)&server1->nfs_client->cl_addr;
2324 sap2 = (struct sockaddr *)&server2->nfs_client->cl_addr;
2325
2326 if (sap1->sa_family != sap2->sa_family)
2327 return 0;
2328
2329 switch (sap1->sa_family) {
2330 case AF_INET: {
2331 struct sockaddr_in *sin1 = (struct sockaddr_in *)sap1;
2332 struct sockaddr_in *sin2 = (struct sockaddr_in *)sap2;
2333 if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr)
2334 return 0;
2335 if (sin1->sin_port != sin2->sin_port)
2336 return 0;
2337 break;
2338 }
2339 case AF_INET6: {
2340 struct sockaddr_in6 *sin1 = (struct sockaddr_in6 *)sap1;
2341 struct sockaddr_in6 *sin2 = (struct sockaddr_in6 *)sap2;
2342 if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
2343 return 0;
2344 if (sin1->sin6_port != sin2->sin6_port)
2345 return 0;
2346 break;
2347 }
2348 default:
2349 return 0;
2350 }
2351
2352 return 1;
2353}
2354
e89a5a43
TM
2355static int nfs_compare_super(struct super_block *sb, void *data)
2356{
2357 struct nfs_sb_mountdata *sb_mntdata = data;
2358 struct nfs_server *server = sb_mntdata->server, *old = NFS_SB(sb);
2359 int mntflags = sb_mntdata->mntflags;
2360
fd00a8ff 2361 if (!nfs_compare_super_address(old, server))
e89a5a43
TM
2362 return 0;
2363 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
2364 if (old->flags & NFS_MOUNT_UNSHARED)
2365 return 0;
2366 if (memcmp(&old->fsid, &server->fsid, sizeof(old->fsid)) != 0)
2367 return 0;
2368 return nfs_compare_mount_options(sb, server, mntflags);
275a5d24
TM
2369}
2370
39ffb921 2371#ifdef CONFIG_NFS_FSCACHE
2311b943
BS
2372static void nfs_get_cache_cookie(struct super_block *sb,
2373 struct nfs_parsed_mount_data *parsed,
2374 struct nfs_clone_mount *cloned)
2375{
2376 char *uniq = NULL;
2377 int ulen = 0;
2378
2379 if (parsed && parsed->fscache_uniq) {
2380 uniq = parsed->fscache_uniq;
2381 ulen = strlen(parsed->fscache_uniq);
2382 } else if (cloned) {
2383 struct nfs_server *mnt_s = NFS_SB(cloned->sb);
2384 if (mnt_s->fscache_key) {
2385 uniq = mnt_s->fscache_key->key.uniquifier;
2386 ulen = mnt_s->fscache_key->key.uniq_len;
2387 };
2388 }
2389
2390 nfs_fscache_get_super_cookie(sb, uniq, ulen);
2391}
39ffb921
TM
2392#else
2393static void nfs_get_cache_cookie(struct super_block *sb,
2394 struct nfs_parsed_mount_data *parsed,
2395 struct nfs_clone_mount *cloned)
2396{
2397}
2398#endif
2311b943 2399
fa799759
MS
2400static int nfs_bdi_register(struct nfs_server *server)
2401{
2402 return bdi_register_dev(&server->backing_dev_info, server->s_dev);
2403}
2404
fbdefd64
BS
2405int nfs_set_sb_security(struct super_block *s, struct dentry *mntroot,
2406 struct nfs_mount_info *mount_info)
3d176e3f
BS
2407{
2408 return security_sb_set_mnt_opts(s, &mount_info->parsed->lsm_opts);
2409}
89d77c8f 2410EXPORT_SYMBOL_GPL(nfs_set_sb_security);
3d176e3f 2411
fbdefd64
BS
2412int nfs_clone_sb_security(struct super_block *s, struct dentry *mntroot,
2413 struct nfs_mount_info *mount_info)
3d176e3f
BS
2414{
2415 /* clone any lsm security options from the parent to the new sb */
2416 security_sb_clone_mnt_opts(mount_info->cloned->sb, s);
2417 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops)
2418 return -ESTALE;
2419 return 0;
2420}
89d77c8f 2421EXPORT_SYMBOL_GPL(nfs_clone_sb_security);
3d176e3f 2422
ab7017a3 2423struct dentry *nfs_fs_mount_common(struct nfs_server *server,
fbdefd64 2424 int flags, const char *dev_name,
ab7017a3
BS
2425 struct nfs_mount_info *mount_info,
2426 struct nfs_subversion *nfs_mod)
f7b422b1 2427{
f7b422b1 2428 struct super_block *s;
01194981 2429 struct dentry *mntroot = ERR_PTR(-ENOMEM);
75180df2 2430 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
e89a5a43
TM
2431 struct nfs_sb_mountdata sb_mntdata = {
2432 .mntflags = flags,
c40f8d1d 2433 .server = server,
e89a5a43 2434 };
01194981 2435 int error;
33852a1f 2436
75180df2
TM
2437 if (server->flags & NFS_MOUNT_UNSHARED)
2438 compare_super = NULL;
2439
fb2088cc
SP
2440 /* -o noac implies -o sync */
2441 if (server->flags & NFS_MOUNT_NOAC)
2442 sb_mntdata.mntflags |= MS_SYNCHRONOUS;
2443
54ceac45 2444 /* Get a superblock - note that we may end up sharing one that already exists */
ab7017a3 2445 s = sget(nfs_mod->nfs_fs, compare_super, nfs_set_super, flags, &sb_mntdata);
816724e6 2446 if (IS_ERR(s)) {
01194981 2447 mntroot = ERR_CAST(s);
54ceac45 2448 goto out_err_nosb;
816724e6
TM
2449 }
2450
54ceac45
DH
2451 if (s->s_fs_info != server) {
2452 nfs_free_server(server);
2453 server = NULL;
fa799759
MS
2454 } else {
2455 error = nfs_bdi_register(server);
01194981
AV
2456 if (error) {
2457 mntroot = ERR_PTR(error);
cfbc0683 2458 goto error_splat_bdi;
01194981 2459 }
54ceac45 2460 }
f7b422b1 2461
54ceac45
DH
2462 if (!s->s_root) {
2463 /* initial superblock/root creation */
c40f8d1d 2464 mount_info->fill_super(s, mount_info);
3d176e3f 2465 nfs_get_cache_cookie(s, mount_info->parsed, mount_info->cloned);
54ceac45 2466 }
f7b422b1 2467
87c7083d 2468 mntroot = nfs_get_root(s, mount_info->mntfh, dev_name);
01194981 2469 if (IS_ERR(mntroot))
54ceac45 2470 goto error_splat_super;
816724e6 2471
3d176e3f 2472 error = mount_info->set_security(s, mntroot, mount_info);
f9c3a380
EP
2473 if (error)
2474 goto error_splat_root;
2475
54ceac45 2476 s->s_flags |= MS_ACTIVE;
0655960f
CL
2477
2478out:
01194981 2479 return mntroot;
816724e6 2480
54ceac45
DH
2481out_err_nosb:
2482 nfs_free_server(server);
0655960f 2483 goto out;
54ceac45 2484
f9c3a380
EP
2485error_splat_root:
2486 dput(mntroot);
01194981 2487 mntroot = ERR_PTR(error);
54ceac45 2488error_splat_super:
cfbc0683
N
2489 if (server && !s->s_root)
2490 bdi_unregister(&server->backing_dev_info);
2491error_splat_bdi:
6f5bbff9 2492 deactivate_locked_super(s);
0655960f 2493 goto out;
f7b422b1 2494}
89d77c8f 2495EXPORT_SYMBOL_GPL(nfs_fs_mount_common);
f7b422b1 2496
fbdefd64 2497struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
c40f8d1d
BS
2498 int flags, const char *dev_name, void *raw_data)
2499{
c40f8d1d
BS
2500 struct nfs_mount_info mount_info = {
2501 .fill_super = nfs_fill_super,
3d176e3f 2502 .set_security = nfs_set_sb_security,
c40f8d1d 2503 };
c40f8d1d 2504 struct dentry *mntroot = ERR_PTR(-ENOMEM);
ab7017a3 2505 struct nfs_subversion *nfs_mod;
c40f8d1d
BS
2506 int error;
2507
46058d46 2508 mount_info.parsed = nfs_alloc_parsed_mount_data();
87c7083d
BS
2509 mount_info.mntfh = nfs_alloc_fhandle();
2510 if (mount_info.parsed == NULL || mount_info.mntfh == NULL)
c40f8d1d
BS
2511 goto out;
2512
2513 /* Validate the mount data */
87c7083d 2514 error = nfs_validate_mount_data(fs_type, raw_data, mount_info.parsed, mount_info.mntfh, dev_name);
b72e4f42 2515 if (error == NFS_TEXT_DATA)
46058d46 2516 error = nfs_validate_text_mount_data(raw_data, mount_info.parsed, dev_name);
c40f8d1d
BS
2517 if (error < 0) {
2518 mntroot = ERR_PTR(error);
2519 goto out;
2520 }
c40f8d1d 2521
ab7017a3
BS
2522 nfs_mod = get_nfs_version(mount_info.parsed->version);
2523 if (IS_ERR(nfs_mod)) {
2524 mntroot = ERR_CAST(nfs_mod);
2525 goto out;
2526 }
2527
ff9099f2 2528 mntroot = nfs_mod->rpc_ops->try_mount(flags, dev_name, &mount_info, nfs_mod);
ab7017a3
BS
2529
2530 put_nfs_version(nfs_mod);
c40f8d1d 2531out:
46058d46 2532 nfs_free_parsed_mount_data(mount_info.parsed);
87c7083d 2533 nfs_free_fhandle(mount_info.mntfh);
c40f8d1d
BS
2534 return mntroot;
2535}
89d77c8f 2536EXPORT_SYMBOL_GPL(nfs_fs_mount);
c40f8d1d 2537
387c149b
TM
2538/*
2539 * Ensure that we unregister the bdi before kill_anon_super
2540 * releases the device name
2541 */
fbdefd64 2542void nfs_put_super(struct super_block *s)
387c149b
TM
2543{
2544 struct nfs_server *server = NFS_SB(s);
2545
2546 bdi_unregister(&server->backing_dev_info);
2547}
89d77c8f 2548EXPORT_SYMBOL_GPL(nfs_put_super);
387c149b 2549
54ceac45
DH
2550/*
2551 * Destroy an NFS2/3 superblock
2552 */
fbdefd64 2553void nfs_kill_super(struct super_block *s)
f7b422b1
DH
2554{
2555 struct nfs_server *server = NFS_SB(s);
2556
2557 kill_anon_super(s);
08734048 2558 nfs_fscache_release_super_cookie(s);
54ceac45 2559 nfs_free_server(server);
f7b422b1 2560}
89d77c8f 2561EXPORT_SYMBOL_GPL(nfs_kill_super);
f7b422b1 2562
54ceac45 2563/*
8c958e0c 2564 * Clone an NFS2/3/4 server record on xdev traversal (FSID-change)
54ceac45 2565 */
3dd4f8ef 2566static struct dentry *
e8f25e6d
BS
2567nfs_xdev_mount(struct file_system_type *fs_type, int flags,
2568 const char *dev_name, void *raw_data)
f7b422b1 2569{
e8f25e6d
BS
2570 struct nfs_clone_mount *data = raw_data;
2571 struct nfs_mount_info mount_info = {
2572 .fill_super = nfs_clone_super,
2573 .set_security = nfs_clone_sb_security,
2574 .cloned = data,
2575 };
54ceac45 2576 struct nfs_server *server;
3d176e3f 2577 struct dentry *mntroot = ERR_PTR(-ENOMEM);
ab7017a3 2578 struct nfs_subversion *nfs_mod = NFS_SB(data->sb)->nfs_client->cl_nfs_mod;
54ceac45 2579 int error;
f7b422b1 2580
8c958e0c 2581 dprintk("--> nfs_xdev_mount_common()\n");
f7b422b1 2582
e8f25e6d 2583 mount_info.mntfh = mount_info.cloned->fh;
87c7083d 2584
54ceac45 2585 /* create a new volume representation */
1179acc6 2586 server = nfs_mod->rpc_ops->clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor);
54ceac45
DH
2587 if (IS_ERR(server)) {
2588 error = PTR_ERR(server);
3d176e3f 2589 goto out_err;
4c1fe2f7 2590 }
f7b422b1 2591
e8f25e6d 2592 mntroot = nfs_fs_mount_common(server, flags, dev_name, &mount_info, nfs_mod);
8c958e0c 2593 dprintk("<-- nfs_xdev_mount_common() = 0\n");
3d176e3f 2594out:
31f43471 2595 return mntroot;
24c8dbbb 2596
3d176e3f 2597out_err:
8c958e0c 2598 dprintk("<-- nfs_xdev_mount_common() = %d [error]\n", error);
3d176e3f 2599 goto out;
f7b422b1
DH
2600}
2601
89d77c8f 2602#if IS_ENABLED(CONFIG_NFS_V4)
54ceac45 2603
01c3f052
TM
2604static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data *args)
2605{
5eebde23
SJ
2606 args->flags &= ~(NFS_MOUNT_NONLM|NFS_MOUNT_NOACL|NFS_MOUNT_VER3|
2607 NFS_MOUNT_LOCAL_FLOCK|NFS_MOUNT_LOCAL_FCNTL);
01c3f052
TM
2608}
2609
f0768ebd
CL
2610/*
2611 * Validate NFSv4 mount options
2612 */
91ea40b9
TT
2613static int nfs4_validate_mount_data(void *options,
2614 struct nfs_parsed_mount_data *args,
2615 const char *dev_name)
f0768ebd 2616{
4cfd74fc 2617 struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address;
91ea40b9 2618 struct nfs4_mount_data *data = (struct nfs4_mount_data *)options;
f0768ebd
CL
2619 char *c;
2620
2621 if (data == NULL)
2622 goto out_no_data;
2623
cdf66442
BS
2624 args->version = 4;
2625
f0768ebd
CL
2626 switch (data->version) {
2627 case 1:
4c568017
CL
2628 if (data->host_addrlen > sizeof(args->nfs_server.address))
2629 goto out_no_address;
2630 if (data->host_addrlen == 0)
f0768ebd 2631 goto out_no_address;
4c568017 2632 args->nfs_server.addrlen = data->host_addrlen;
4cfd74fc 2633 if (copy_from_user(sap, data->host_addr, data->host_addrlen))
f0768ebd 2634 return -EFAULT;
4cfd74fc 2635 if (!nfs_verify_server_address(sap))
f0768ebd 2636 goto out_no_address;
872ece86 2637 args->nfs_server.port = ntohs(((struct sockaddr_in *)sap)->sin_port);
f0768ebd 2638
6738b251
CL
2639 if (data->auth_flavourlen) {
2640 if (data->auth_flavourlen > 1)
2641 goto out_inval_auth;
20c71f5e 2642 if (copy_from_user(&args->auth_flavors[0],
91ea40b9 2643 data->auth_flavours,
20c71f5e 2644 sizeof(args->auth_flavors[0])))
f0768ebd 2645 return -EFAULT;
f0768ebd
CL
2646 }
2647
2648 c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN);
2649 if (IS_ERR(c))
2650 return PTR_ERR(c);
91ea40b9 2651 args->nfs_server.hostname = c;
f0768ebd
CL
2652
2653 c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN);
2654 if (IS_ERR(c))
2655 return PTR_ERR(c);
91ea40b9
TT
2656 args->nfs_server.export_path = c;
2657 dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c);
f0768ebd
CL
2658
2659 c = strndup_user(data->client_addr.data, 16);
2660 if (IS_ERR(c))
2661 return PTR_ERR(c);
91ea40b9
TT
2662 args->client_address = c;
2663
2664 /*
2665 * Translate to nfs_parsed_mount_data, which nfs4_fill_super
2666 * can deal with.
2667 */
2668
2669 args->flags = data->flags & NFS4_MOUNT_FLAGMASK;
2670 args->rsize = data->rsize;
2671 args->wsize = data->wsize;
2672 args->timeo = data->timeo;
2673 args->retrans = data->retrans;
2674 args->acregmin = data->acregmin;
2675 args->acregmax = data->acregmax;
2676 args->acdirmin = data->acdirmin;
2677 args->acdirmax = data->acdirmax;
2678 args->nfs_server.protocol = data->proto;
259875ef 2679 nfs_validate_transport_protocol(args);
f0768ebd
CL
2680
2681 break;
7630c852 2682 default:
b72e4f42 2683 return NFS_TEXT_DATA;
f0768ebd
CL
2684 }
2685
2686 return 0;
2687
2688out_no_data:
2689 dfprintk(MOUNT, "NFS4: mount program didn't pass any mount data\n");
2690 return -EINVAL;
2691
2692out_inval_auth:
2693 dfprintk(MOUNT, "NFS4: Invalid number of RPC auth flavours %d\n",
2694 data->auth_flavourlen);
2695 return -EINVAL;
2696
2697out_no_address:
2698 dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n");
2699 return -EINVAL;
f0768ebd
CL
2700}
2701
fac1e8e4
BS
2702/*
2703 * NFS v4 module parameters need to stay in the
2704 * NFS client for backwards compatibility
2705 */
2706unsigned int nfs_callback_set_tcpport;
2707unsigned short nfs_callback_tcpport;
2708/* Default cache timeout is 10 minutes */
2709unsigned int nfs_idmap_cache_timeout = 600;
2710/* Turn off NFSv4 uid/gid mapping when using AUTH_SYS */
2711bool nfs4_disable_idmapping = true;
2712unsigned short max_session_slots = NFS4_DEF_SLOT_TABLE_SIZE;
2713unsigned short send_implementation_id = 1;
6f2ea7f2 2714char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN] = "";
fac1e8e4 2715
89d77c8f
BS
2716EXPORT_SYMBOL_GPL(nfs_callback_set_tcpport);
2717EXPORT_SYMBOL_GPL(nfs_callback_tcpport);
2718EXPORT_SYMBOL_GPL(nfs_idmap_cache_timeout);
2719EXPORT_SYMBOL_GPL(nfs4_disable_idmapping);
2720EXPORT_SYMBOL_GPL(max_session_slots);
2721EXPORT_SYMBOL_GPL(send_implementation_id);
6f2ea7f2 2722EXPORT_SYMBOL_GPL(nfs4_client_id_uniquifier);
89d77c8f 2723
fac1e8e4
BS
2724#define NFS_CALLBACK_MAXPORTNR (65535U)
2725
2726static int param_set_portnr(const char *val, const struct kernel_param *kp)
2727{
2728 unsigned long num;
2729 int ret;
2730
2731 if (!val)
2732 return -EINVAL;
7297cb68 2733 ret = kstrtoul(val, 0, &num);
fac1e8e4
BS
2734 if (ret == -EINVAL || num > NFS_CALLBACK_MAXPORTNR)
2735 return -EINVAL;
2736 *((unsigned int *)kp->arg) = num;
2737 return 0;
2738}
2739static struct kernel_param_ops param_ops_portnr = {
2740 .set = param_set_portnr,
2741 .get = param_get_uint,
2742};
2743#define param_check_portnr(name, p) __param_check(name, p, unsigned int);
2744
2745module_param_named(callback_tcpport, nfs_callback_set_tcpport, portnr, 0644);
2746module_param(nfs_idmap_cache_timeout, int, 0644);
2747module_param(nfs4_disable_idmapping, bool, 0644);
6f2ea7f2
CL
2748module_param_string(nfs4_unique_id, nfs4_client_id_uniquifier,
2749 NFS4_CLIENT_ID_UNIQ_LEN, 0600);
fac1e8e4
BS
2750MODULE_PARM_DESC(nfs4_disable_idmapping,
2751 "Turn off NFSv4 idmapping when using 'sec=sys'");
2752module_param(max_session_slots, ushort, 0644);
2753MODULE_PARM_DESC(max_session_slots, "Maximum number of outstanding NFSv4.1 "
2754 "requests the client will negotiate");
2755module_param(send_implementation_id, ushort, 0644);
2756MODULE_PARM_DESC(send_implementation_id,
2757 "Send implementation ID with NFSv4.1 exchange_id");
6f2ea7f2 2758MODULE_PARM_DESC(nfs4_unique_id, "nfs_client_id4 uniquifier string");
425e776d 2759MODULE_ALIAS("nfs4");
2760
54ceac45 2761#endif /* CONFIG_NFS_V4 */