~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/nfs/fs_context.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/nfs/fs_context.c (Version linux-6.12-rc7) and /fs/nfs/fs_context.c (Version linux-6.9.12)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*                                                  2 /*
  3  * linux/fs/nfs/fs_context.c                        3  * linux/fs/nfs/fs_context.c
  4  *                                                  4  *
  5  * Copyright (C) 1992 Rick Sladkey                  5  * Copyright (C) 1992 Rick Sladkey
  6  * Conversion to new mount api Copyright (C) D      6  * Conversion to new mount api Copyright (C) David Howells
  7  *                                                  7  *
  8  * NFS mount handling.                              8  * NFS mount handling.
  9  *                                                  9  *
 10  * Split from fs/nfs/super.c by David Howells      10  * Split from fs/nfs/super.c by David Howells <dhowells@redhat.com>
 11  */                                                11  */
 12                                                    12 
 13 #include <linux/compat.h>                          13 #include <linux/compat.h>
 14 #include <linux/module.h>                          14 #include <linux/module.h>
 15 #include <linux/fs.h>                              15 #include <linux/fs.h>
 16 #include <linux/fs_context.h>                      16 #include <linux/fs_context.h>
 17 #include <linux/fs_parser.h>                       17 #include <linux/fs_parser.h>
 18 #include <linux/nfs_fs.h>                          18 #include <linux/nfs_fs.h>
 19 #include <linux/nfs_mount.h>                       19 #include <linux/nfs_mount.h>
 20 #include <linux/nfs4_mount.h>                      20 #include <linux/nfs4_mount.h>
 21                                                    21 
 22 #include <net/handshake.h>                         22 #include <net/handshake.h>
 23                                                    23 
 24 #include "nfs.h"                                   24 #include "nfs.h"
 25 #include "internal.h"                              25 #include "internal.h"
 26                                                    26 
 27 #include "nfstrace.h"                              27 #include "nfstrace.h"
 28                                                    28 
 29 #define NFSDBG_FACILITY         NFSDBG_MOUNT       29 #define NFSDBG_FACILITY         NFSDBG_MOUNT
 30                                                    30 
 31 #if IS_ENABLED(CONFIG_NFS_V3)                      31 #if IS_ENABLED(CONFIG_NFS_V3)
 32 #define NFS_DEFAULT_VERSION 3                      32 #define NFS_DEFAULT_VERSION 3
 33 #else                                              33 #else
 34 #define NFS_DEFAULT_VERSION 2                      34 #define NFS_DEFAULT_VERSION 2
 35 #endif                                             35 #endif
 36                                                    36 
 37 #define NFS_MAX_CONNECTIONS 16                     37 #define NFS_MAX_CONNECTIONS 16
 38                                                    38 
 39 enum nfs_param {                                   39 enum nfs_param {
 40         Opt_ac,                                    40         Opt_ac,
 41         Opt_acdirmax,                              41         Opt_acdirmax,
 42         Opt_acdirmin,                              42         Opt_acdirmin,
 43         Opt_acl,                                   43         Opt_acl,
 44         Opt_acregmax,                              44         Opt_acregmax,
 45         Opt_acregmin,                              45         Opt_acregmin,
 46         Opt_actimeo,                               46         Opt_actimeo,
 47         Opt_addr,                                  47         Opt_addr,
 48         Opt_bg,                                    48         Opt_bg,
 49         Opt_bsize,                                 49         Opt_bsize,
 50         Opt_clientaddr,                            50         Opt_clientaddr,
 51         Opt_cto,                                   51         Opt_cto,
 52         Opt_alignwrite,                        << 
 53         Opt_fg,                                    52         Opt_fg,
 54         Opt_fscache,                               53         Opt_fscache,
 55         Opt_fscache_flag,                          54         Opt_fscache_flag,
 56         Opt_hard,                                  55         Opt_hard,
 57         Opt_intr,                                  56         Opt_intr,
 58         Opt_local_lock,                            57         Opt_local_lock,
 59         Opt_lock,                                  58         Opt_lock,
 60         Opt_lookupcache,                           59         Opt_lookupcache,
 61         Opt_migration,                             60         Opt_migration,
 62         Opt_minorversion,                          61         Opt_minorversion,
 63         Opt_mountaddr,                             62         Opt_mountaddr,
 64         Opt_mounthost,                             63         Opt_mounthost,
 65         Opt_mountport,                             64         Opt_mountport,
 66         Opt_mountproto,                            65         Opt_mountproto,
 67         Opt_mountvers,                             66         Opt_mountvers,
 68         Opt_namelen,                               67         Opt_namelen,
 69         Opt_nconnect,                              68         Opt_nconnect,
 70         Opt_max_connect,                           69         Opt_max_connect,
 71         Opt_port,                                  70         Opt_port,
 72         Opt_posix,                                 71         Opt_posix,
 73         Opt_proto,                                 72         Opt_proto,
 74         Opt_rdirplus,                              73         Opt_rdirplus,
 75         Opt_rdma,                                  74         Opt_rdma,
 76         Opt_resvport,                              75         Opt_resvport,
 77         Opt_retrans,                               76         Opt_retrans,
 78         Opt_retry,                                 77         Opt_retry,
 79         Opt_rsize,                                 78         Opt_rsize,
 80         Opt_sec,                                   79         Opt_sec,
 81         Opt_sharecache,                            80         Opt_sharecache,
 82         Opt_sloppy,                                81         Opt_sloppy,
 83         Opt_soft,                                  82         Opt_soft,
 84         Opt_softerr,                               83         Opt_softerr,
 85         Opt_softreval,                             84         Opt_softreval,
 86         Opt_source,                                85         Opt_source,
 87         Opt_tcp,                                   86         Opt_tcp,
 88         Opt_timeo,                                 87         Opt_timeo,
 89         Opt_trunkdiscovery,                        88         Opt_trunkdiscovery,
 90         Opt_udp,                                   89         Opt_udp,
 91         Opt_v,                                     90         Opt_v,
 92         Opt_vers,                                  91         Opt_vers,
 93         Opt_wsize,                                 92         Opt_wsize,
 94         Opt_write,                                 93         Opt_write,
 95         Opt_xprtsec,                               94         Opt_xprtsec,
 96 };                                                 95 };
 97                                                    96 
 98 enum {                                             97 enum {
 99         Opt_local_lock_all,                        98         Opt_local_lock_all,
100         Opt_local_lock_flock,                      99         Opt_local_lock_flock,
101         Opt_local_lock_none,                      100         Opt_local_lock_none,
102         Opt_local_lock_posix,                     101         Opt_local_lock_posix,
103 };                                                102 };
104                                                   103 
105 static const struct constant_table nfs_param_e    104 static const struct constant_table nfs_param_enums_local_lock[] = {
106         { "all",                Opt_local_lock    105         { "all",                Opt_local_lock_all },
107         { "flock",      Opt_local_lock_flock }    106         { "flock",      Opt_local_lock_flock },
108         { "posix",      Opt_local_lock_posix }    107         { "posix",      Opt_local_lock_posix },
109         { "none",               Opt_local_lock    108         { "none",               Opt_local_lock_none },
110         {}                                        109         {}
111 };                                                110 };
112                                                   111 
113 enum {                                            112 enum {
114         Opt_lookupcache_all,                      113         Opt_lookupcache_all,
115         Opt_lookupcache_none,                     114         Opt_lookupcache_none,
116         Opt_lookupcache_positive,                 115         Opt_lookupcache_positive,
117 };                                                116 };
118                                                   117 
119 static const struct constant_table nfs_param_e    118 static const struct constant_table nfs_param_enums_lookupcache[] = {
120         { "all",                Opt_lookupcach    119         { "all",                Opt_lookupcache_all },
121         { "none",               Opt_lookupcach    120         { "none",               Opt_lookupcache_none },
122         { "pos",                Opt_lookupcach    121         { "pos",                Opt_lookupcache_positive },
123         { "positive",           Opt_lookupcach    122         { "positive",           Opt_lookupcache_positive },
124         {}                                        123         {}
125 };                                                124 };
126                                                   125 
127 enum {                                            126 enum {
128         Opt_write_lazy,                           127         Opt_write_lazy,
129         Opt_write_eager,                          128         Opt_write_eager,
130         Opt_write_wait,                           129         Opt_write_wait,
131 };                                                130 };
132                                                   131 
133 static const struct constant_table nfs_param_e    132 static const struct constant_table nfs_param_enums_write[] = {
134         { "lazy",               Opt_write_lazy    133         { "lazy",               Opt_write_lazy },
135         { "eager",              Opt_write_eage    134         { "eager",              Opt_write_eager },
136         { "wait",               Opt_write_wait    135         { "wait",               Opt_write_wait },
137         {}                                        136         {}
138 };                                                137 };
139                                                   138 
140 static const struct fs_parameter_spec nfs_fs_p    139 static const struct fs_parameter_spec nfs_fs_parameters[] = {
141         fsparam_flag_no("ac",           Opt_ac    140         fsparam_flag_no("ac",           Opt_ac),
142         fsparam_u32   ("acdirmax",      Opt_ac    141         fsparam_u32   ("acdirmax",      Opt_acdirmax),
143         fsparam_u32   ("acdirmin",      Opt_ac    142         fsparam_u32   ("acdirmin",      Opt_acdirmin),
144         fsparam_flag_no("acl",          Opt_ac    143         fsparam_flag_no("acl",          Opt_acl),
145         fsparam_u32   ("acregmax",      Opt_ac    144         fsparam_u32   ("acregmax",      Opt_acregmax),
146         fsparam_u32   ("acregmin",      Opt_ac    145         fsparam_u32   ("acregmin",      Opt_acregmin),
147         fsparam_u32   ("actimeo",       Opt_ac    146         fsparam_u32   ("actimeo",       Opt_actimeo),
148         fsparam_string("addr",          Opt_ad    147         fsparam_string("addr",          Opt_addr),
149         fsparam_flag  ("bg",            Opt_bg    148         fsparam_flag  ("bg",            Opt_bg),
150         fsparam_u32   ("bsize",         Opt_bs    149         fsparam_u32   ("bsize",         Opt_bsize),
151         fsparam_string("clientaddr",    Opt_cl    150         fsparam_string("clientaddr",    Opt_clientaddr),
152         fsparam_flag_no("cto",          Opt_ct    151         fsparam_flag_no("cto",          Opt_cto),
153         fsparam_flag_no("alignwrite",   Opt_al << 
154         fsparam_flag  ("fg",            Opt_fg    152         fsparam_flag  ("fg",            Opt_fg),
155         fsparam_flag_no("fsc",          Opt_fs    153         fsparam_flag_no("fsc",          Opt_fscache_flag),
156         fsparam_string("fsc",           Opt_fs    154         fsparam_string("fsc",           Opt_fscache),
157         fsparam_flag  ("hard",          Opt_ha    155         fsparam_flag  ("hard",          Opt_hard),
158         __fsparam(NULL, "intr",         Opt_in    156         __fsparam(NULL, "intr",         Opt_intr,
159                   fs_param_neg_with_no|fs_para    157                   fs_param_neg_with_no|fs_param_deprecated, NULL),
160         fsparam_enum  ("local_lock",    Opt_lo    158         fsparam_enum  ("local_lock",    Opt_local_lock, nfs_param_enums_local_lock),
161         fsparam_flag_no("lock",         Opt_lo    159         fsparam_flag_no("lock",         Opt_lock),
162         fsparam_enum  ("lookupcache",   Opt_lo    160         fsparam_enum  ("lookupcache",   Opt_lookupcache, nfs_param_enums_lookupcache),
163         fsparam_flag_no("migration",    Opt_mi    161         fsparam_flag_no("migration",    Opt_migration),
164         fsparam_u32   ("minorversion",  Opt_mi    162         fsparam_u32   ("minorversion",  Opt_minorversion),
165         fsparam_string("mountaddr",     Opt_mo    163         fsparam_string("mountaddr",     Opt_mountaddr),
166         fsparam_string("mounthost",     Opt_mo    164         fsparam_string("mounthost",     Opt_mounthost),
167         fsparam_u32   ("mountport",     Opt_mo    165         fsparam_u32   ("mountport",     Opt_mountport),
168         fsparam_string("mountproto",    Opt_mo    166         fsparam_string("mountproto",    Opt_mountproto),
169         fsparam_u32   ("mountvers",     Opt_mo    167         fsparam_u32   ("mountvers",     Opt_mountvers),
170         fsparam_u32   ("namlen",        Opt_na    168         fsparam_u32   ("namlen",        Opt_namelen),
171         fsparam_u32   ("nconnect",      Opt_nc    169         fsparam_u32   ("nconnect",      Opt_nconnect),
172         fsparam_u32   ("max_connect",   Opt_ma    170         fsparam_u32   ("max_connect",   Opt_max_connect),
173         fsparam_string("nfsvers",       Opt_ve    171         fsparam_string("nfsvers",       Opt_vers),
174         fsparam_u32   ("port",          Opt_po    172         fsparam_u32   ("port",          Opt_port),
175         fsparam_flag_no("posix",        Opt_po    173         fsparam_flag_no("posix",        Opt_posix),
176         fsparam_string("proto",         Opt_pr    174         fsparam_string("proto",         Opt_proto),
177         fsparam_flag_no("rdirplus",     Opt_rd    175         fsparam_flag_no("rdirplus",     Opt_rdirplus),
178         fsparam_flag  ("rdma",          Opt_rd    176         fsparam_flag  ("rdma",          Opt_rdma),
179         fsparam_flag_no("resvport",     Opt_re    177         fsparam_flag_no("resvport",     Opt_resvport),
180         fsparam_u32   ("retrans",       Opt_re    178         fsparam_u32   ("retrans",       Opt_retrans),
181         fsparam_string("retry",         Opt_re    179         fsparam_string("retry",         Opt_retry),
182         fsparam_u32   ("rsize",         Opt_rs    180         fsparam_u32   ("rsize",         Opt_rsize),
183         fsparam_string("sec",           Opt_se    181         fsparam_string("sec",           Opt_sec),
184         fsparam_flag_no("sharecache",   Opt_sh    182         fsparam_flag_no("sharecache",   Opt_sharecache),
185         fsparam_flag  ("sloppy",        Opt_sl    183         fsparam_flag  ("sloppy",        Opt_sloppy),
186         fsparam_flag  ("soft",          Opt_so    184         fsparam_flag  ("soft",          Opt_soft),
187         fsparam_flag  ("softerr",       Opt_so    185         fsparam_flag  ("softerr",       Opt_softerr),
188         fsparam_flag  ("softreval",     Opt_so    186         fsparam_flag  ("softreval",     Opt_softreval),
189         fsparam_string("source",        Opt_so    187         fsparam_string("source",        Opt_source),
190         fsparam_flag  ("tcp",           Opt_tc    188         fsparam_flag  ("tcp",           Opt_tcp),
191         fsparam_u32   ("timeo",         Opt_ti    189         fsparam_u32   ("timeo",         Opt_timeo),
192         fsparam_flag_no("trunkdiscovery", Opt_    190         fsparam_flag_no("trunkdiscovery", Opt_trunkdiscovery),
193         fsparam_flag  ("udp",           Opt_ud    191         fsparam_flag  ("udp",           Opt_udp),
194         fsparam_flag  ("v2",            Opt_v)    192         fsparam_flag  ("v2",            Opt_v),
195         fsparam_flag  ("v3",            Opt_v)    193         fsparam_flag  ("v3",            Opt_v),
196         fsparam_flag  ("v4",            Opt_v)    194         fsparam_flag  ("v4",            Opt_v),
197         fsparam_flag  ("v4.0",          Opt_v)    195         fsparam_flag  ("v4.0",          Opt_v),
198         fsparam_flag  ("v4.1",          Opt_v)    196         fsparam_flag  ("v4.1",          Opt_v),
199         fsparam_flag  ("v4.2",          Opt_v)    197         fsparam_flag  ("v4.2",          Opt_v),
200         fsparam_string("vers",          Opt_ve    198         fsparam_string("vers",          Opt_vers),
201         fsparam_enum  ("write",         Opt_wr    199         fsparam_enum  ("write",         Opt_write, nfs_param_enums_write),
202         fsparam_u32   ("wsize",         Opt_ws    200         fsparam_u32   ("wsize",         Opt_wsize),
203         fsparam_string("xprtsec",       Opt_xp    201         fsparam_string("xprtsec",       Opt_xprtsec),
204         {}                                        202         {}
205 };                                                203 };
206                                                   204 
207 enum {                                            205 enum {
208         Opt_vers_2,                               206         Opt_vers_2,
209         Opt_vers_3,                               207         Opt_vers_3,
210         Opt_vers_4,                               208         Opt_vers_4,
211         Opt_vers_4_0,                             209         Opt_vers_4_0,
212         Opt_vers_4_1,                             210         Opt_vers_4_1,
213         Opt_vers_4_2,                             211         Opt_vers_4_2,
214 };                                                212 };
215                                                   213 
216 static const struct constant_table nfs_vers_to    214 static const struct constant_table nfs_vers_tokens[] = {
217         { "2",          Opt_vers_2 },             215         { "2",          Opt_vers_2 },
218         { "3",          Opt_vers_3 },             216         { "3",          Opt_vers_3 },
219         { "4",          Opt_vers_4 },             217         { "4",          Opt_vers_4 },
220         { "4.0",        Opt_vers_4_0 },           218         { "4.0",        Opt_vers_4_0 },
221         { "4.1",        Opt_vers_4_1 },           219         { "4.1",        Opt_vers_4_1 },
222         { "4.2",        Opt_vers_4_2 },           220         { "4.2",        Opt_vers_4_2 },
223         {}                                        221         {}
224 };                                                222 };
225                                                   223 
226 enum {                                            224 enum {
227         Opt_xprt_rdma,                            225         Opt_xprt_rdma,
228         Opt_xprt_rdma6,                           226         Opt_xprt_rdma6,
229         Opt_xprt_tcp,                             227         Opt_xprt_tcp,
230         Opt_xprt_tcp6,                            228         Opt_xprt_tcp6,
231         Opt_xprt_udp,                             229         Opt_xprt_udp,
232         Opt_xprt_udp6,                            230         Opt_xprt_udp6,
233         nr__Opt_xprt                              231         nr__Opt_xprt
234 };                                                232 };
235                                                   233 
236 static const struct constant_table nfs_xprt_pr    234 static const struct constant_table nfs_xprt_protocol_tokens[] = {
237         { "rdma",       Opt_xprt_rdma },          235         { "rdma",       Opt_xprt_rdma },
238         { "rdma6",      Opt_xprt_rdma6 },         236         { "rdma6",      Opt_xprt_rdma6 },
239         { "tcp",        Opt_xprt_tcp },           237         { "tcp",        Opt_xprt_tcp },
240         { "tcp6",       Opt_xprt_tcp6 },          238         { "tcp6",       Opt_xprt_tcp6 },
241         { "udp",        Opt_xprt_udp },           239         { "udp",        Opt_xprt_udp },
242         { "udp6",       Opt_xprt_udp6 },          240         { "udp6",       Opt_xprt_udp6 },
243         {}                                        241         {}
244 };                                                242 };
245                                                   243 
246 enum {                                            244 enum {
247         Opt_sec_krb5,                             245         Opt_sec_krb5,
248         Opt_sec_krb5i,                            246         Opt_sec_krb5i,
249         Opt_sec_krb5p,                            247         Opt_sec_krb5p,
250         Opt_sec_lkey,                             248         Opt_sec_lkey,
251         Opt_sec_lkeyi,                            249         Opt_sec_lkeyi,
252         Opt_sec_lkeyp,                            250         Opt_sec_lkeyp,
253         Opt_sec_none,                             251         Opt_sec_none,
254         Opt_sec_spkm,                             252         Opt_sec_spkm,
255         Opt_sec_spkmi,                            253         Opt_sec_spkmi,
256         Opt_sec_spkmp,                            254         Opt_sec_spkmp,
257         Opt_sec_sys,                              255         Opt_sec_sys,
258         nr__Opt_sec                               256         nr__Opt_sec
259 };                                                257 };
260                                                   258 
261 static const struct constant_table nfs_secflav    259 static const struct constant_table nfs_secflavor_tokens[] = {
262         { "krb5",       Opt_sec_krb5 },           260         { "krb5",       Opt_sec_krb5 },
263         { "krb5i",      Opt_sec_krb5i },          261         { "krb5i",      Opt_sec_krb5i },
264         { "krb5p",      Opt_sec_krb5p },          262         { "krb5p",      Opt_sec_krb5p },
265         { "lkey",       Opt_sec_lkey },           263         { "lkey",       Opt_sec_lkey },
266         { "lkeyi",      Opt_sec_lkeyi },          264         { "lkeyi",      Opt_sec_lkeyi },
267         { "lkeyp",      Opt_sec_lkeyp },          265         { "lkeyp",      Opt_sec_lkeyp },
268         { "none",       Opt_sec_none },           266         { "none",       Opt_sec_none },
269         { "null",       Opt_sec_none },           267         { "null",       Opt_sec_none },
270         { "spkm3",      Opt_sec_spkm },           268         { "spkm3",      Opt_sec_spkm },
271         { "spkm3i",     Opt_sec_spkmi },          269         { "spkm3i",     Opt_sec_spkmi },
272         { "spkm3p",     Opt_sec_spkmp },          270         { "spkm3p",     Opt_sec_spkmp },
273         { "sys",        Opt_sec_sys },            271         { "sys",        Opt_sec_sys },
274         {}                                        272         {}
275 };                                                273 };
276                                                   274 
277 enum {                                            275 enum {
278         Opt_xprtsec_none,                         276         Opt_xprtsec_none,
279         Opt_xprtsec_tls,                          277         Opt_xprtsec_tls,
280         Opt_xprtsec_mtls,                         278         Opt_xprtsec_mtls,
281         nr__Opt_xprtsec                           279         nr__Opt_xprtsec
282 };                                                280 };
283                                                   281 
284 static const struct constant_table nfs_xprtsec    282 static const struct constant_table nfs_xprtsec_policies[] = {
285         { "none",       Opt_xprtsec_none },       283         { "none",       Opt_xprtsec_none },
286         { "tls",        Opt_xprtsec_tls },        284         { "tls",        Opt_xprtsec_tls },
287         { "mtls",       Opt_xprtsec_mtls },       285         { "mtls",       Opt_xprtsec_mtls },
288         {}                                        286         {}
289 };                                                287 };
290                                                   288 
291 /*                                                289 /*
292  * Sanity-check a server address provided by t    290  * Sanity-check a server address provided by the mount command.
293  *                                                291  *
294  * Address family must be initialized, and add    292  * Address family must be initialized, and address must not be
295  * the ANY address for that family.               293  * the ANY address for that family.
296  */                                               294  */
297 static int nfs_verify_server_address(struct so    295 static int nfs_verify_server_address(struct sockaddr_storage *addr)
298 {                                                 296 {
299         switch (addr->ss_family) {                297         switch (addr->ss_family) {
300         case AF_INET: {                           298         case AF_INET: {
301                 struct sockaddr_in *sa = (stru    299                 struct sockaddr_in *sa = (struct sockaddr_in *)addr;
302                 return sa->sin_addr.s_addr !=     300                 return sa->sin_addr.s_addr != htonl(INADDR_ANY);
303         }                                         301         }
304         case AF_INET6: {                          302         case AF_INET6: {
305                 struct in6_addr *sa = &((struc    303                 struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr;
306                 return !ipv6_addr_any(sa);        304                 return !ipv6_addr_any(sa);
307         }                                         305         }
308         }                                         306         }
309                                                   307 
310         return 0;                                 308         return 0;
311 }                                                 309 }
312                                                   310 
313 #ifdef CONFIG_NFS_DISABLE_UDP_SUPPORT             311 #ifdef CONFIG_NFS_DISABLE_UDP_SUPPORT
314 static bool nfs_server_transport_udp_invalid(c    312 static bool nfs_server_transport_udp_invalid(const struct nfs_fs_context *ctx)
315 {                                                 313 {
316         return true;                              314         return true;
317 }                                                 315 }
318 #else                                             316 #else
319 static bool nfs_server_transport_udp_invalid(c    317 static bool nfs_server_transport_udp_invalid(const struct nfs_fs_context *ctx)
320 {                                                 318 {
321         if (ctx->version == 4)                    319         if (ctx->version == 4)
322                 return true;                      320                 return true;
323         return false;                             321         return false;
324 }                                                 322 }
325 #endif                                            323 #endif
326                                                   324 
327 /*                                                325 /*
328  * Sanity check the NFS transport protocol.       326  * Sanity check the NFS transport protocol.
329  */                                               327  */
330 static int nfs_validate_transport_protocol(str    328 static int nfs_validate_transport_protocol(struct fs_context *fc,
331                                            str    329                                            struct nfs_fs_context *ctx)
332 {                                                 330 {
333         switch (ctx->nfs_server.protocol) {       331         switch (ctx->nfs_server.protocol) {
334         case XPRT_TRANSPORT_UDP:                  332         case XPRT_TRANSPORT_UDP:
335                 if (nfs_server_transport_udp_i    333                 if (nfs_server_transport_udp_invalid(ctx))
336                         goto out_invalid_trans    334                         goto out_invalid_transport_udp;
337                 break;                            335                 break;
338         case XPRT_TRANSPORT_TCP:                  336         case XPRT_TRANSPORT_TCP:
339         case XPRT_TRANSPORT_RDMA:                 337         case XPRT_TRANSPORT_RDMA:
340                 break;                            338                 break;
341         default:                                  339         default:
342                 ctx->nfs_server.protocol = XPR    340                 ctx->nfs_server.protocol = XPRT_TRANSPORT_TCP;
343         }                                         341         }
344                                                   342 
345         if (ctx->xprtsec.policy != RPC_XPRTSEC    343         if (ctx->xprtsec.policy != RPC_XPRTSEC_NONE)
346                 switch (ctx->nfs_server.protoc    344                 switch (ctx->nfs_server.protocol) {
347                 case XPRT_TRANSPORT_TCP:          345                 case XPRT_TRANSPORT_TCP:
348                         ctx->nfs_server.protoc    346                         ctx->nfs_server.protocol = XPRT_TRANSPORT_TCP_TLS;
349                         break;                    347                         break;
350                 default:                          348                 default:
351                         goto out_invalid_xprts    349                         goto out_invalid_xprtsec_policy;
352         }                                         350         }
353                                                   351 
354         return 0;                                 352         return 0;
355 out_invalid_transport_udp:                        353 out_invalid_transport_udp:
356         return nfs_invalf(fc, "NFS: Unsupporte    354         return nfs_invalf(fc, "NFS: Unsupported transport protocol udp");
357 out_invalid_xprtsec_policy:                       355 out_invalid_xprtsec_policy:
358         return nfs_invalf(fc, "NFS: Transport     356         return nfs_invalf(fc, "NFS: Transport does not support xprtsec");
359 }                                                 357 }
360                                                   358 
361 /*                                                359 /*
362  * For text based NFSv2/v3 mounts, the mount p    360  * For text based NFSv2/v3 mounts, the mount protocol transport default
363  * settings should depend upon the specified N    361  * settings should depend upon the specified NFS transport.
364  */                                               362  */
365 static void nfs_set_mount_transport_protocol(s    363 static void nfs_set_mount_transport_protocol(struct nfs_fs_context *ctx)
366 {                                                 364 {
367         if (ctx->mount_server.protocol == XPRT    365         if (ctx->mount_server.protocol == XPRT_TRANSPORT_UDP ||
368             ctx->mount_server.protocol == XPRT    366             ctx->mount_server.protocol == XPRT_TRANSPORT_TCP)
369                         return;                   367                         return;
370         switch (ctx->nfs_server.protocol) {       368         switch (ctx->nfs_server.protocol) {
371         case XPRT_TRANSPORT_UDP:                  369         case XPRT_TRANSPORT_UDP:
372                 ctx->mount_server.protocol = X    370                 ctx->mount_server.protocol = XPRT_TRANSPORT_UDP;
373                 break;                            371                 break;
374         case XPRT_TRANSPORT_TCP:                  372         case XPRT_TRANSPORT_TCP:
375         case XPRT_TRANSPORT_RDMA:                 373         case XPRT_TRANSPORT_RDMA:
376                 ctx->mount_server.protocol = X    374                 ctx->mount_server.protocol = XPRT_TRANSPORT_TCP;
377         }                                         375         }
378 }                                                 376 }
379                                                   377 
380 /*                                                378 /*
381  * Add 'flavor' to 'auth_info' if not already     379  * Add 'flavor' to 'auth_info' if not already present.
382  * Returns true if 'flavor' ends up in the lis    380  * Returns true if 'flavor' ends up in the list, false otherwise
383  */                                               381  */
384 static int nfs_auth_info_add(struct fs_context    382 static int nfs_auth_info_add(struct fs_context *fc,
385                              struct nfs_auth_i    383                              struct nfs_auth_info *auth_info,
386                              rpc_authflavor_t     384                              rpc_authflavor_t flavor)
387 {                                                 385 {
388         unsigned int i;                           386         unsigned int i;
389         unsigned int max_flavor_len = ARRAY_SI    387         unsigned int max_flavor_len = ARRAY_SIZE(auth_info->flavors);
390                                                   388 
391         /* make sure this flavor isn't already    389         /* make sure this flavor isn't already in the list */
392         for (i = 0; i < auth_info->flavor_len;    390         for (i = 0; i < auth_info->flavor_len; i++) {
393                 if (flavor == auth_info->flavo    391                 if (flavor == auth_info->flavors[i])
394                         return 0;                 392                         return 0;
395         }                                         393         }
396                                                   394 
397         if (auth_info->flavor_len + 1 >= max_f    395         if (auth_info->flavor_len + 1 >= max_flavor_len)
398                 return nfs_invalf(fc, "NFS: to    396                 return nfs_invalf(fc, "NFS: too many sec= flavors");
399                                                   397 
400         auth_info->flavors[auth_info->flavor_l    398         auth_info->flavors[auth_info->flavor_len++] = flavor;
401         return 0;                                 399         return 0;
402 }                                                 400 }
403                                                   401 
404 /*                                                402 /*
405  * Parse the value of the 'sec=' option.          403  * Parse the value of the 'sec=' option.
406  */                                               404  */
407 static int nfs_parse_security_flavors(struct f    405 static int nfs_parse_security_flavors(struct fs_context *fc,
408                                       struct f    406                                       struct fs_parameter *param)
409 {                                                 407 {
410         struct nfs_fs_context *ctx = nfs_fc2co    408         struct nfs_fs_context *ctx = nfs_fc2context(fc);
411         rpc_authflavor_t pseudoflavor;            409         rpc_authflavor_t pseudoflavor;
412         char *string = param->string, *p;         410         char *string = param->string, *p;
413         int ret;                                  411         int ret;
414                                                   412 
415         trace_nfs_mount_assign(param->key, str    413         trace_nfs_mount_assign(param->key, string);
416                                                   414 
417         while ((p = strsep(&string, ":")) != N    415         while ((p = strsep(&string, ":")) != NULL) {
418                 if (!*p)                          416                 if (!*p)
419                         continue;                 417                         continue;
420                 switch (lookup_constant(nfs_se    418                 switch (lookup_constant(nfs_secflavor_tokens, p, -1)) {
421                 case Opt_sec_none:                419                 case Opt_sec_none:
422                         pseudoflavor = RPC_AUT    420                         pseudoflavor = RPC_AUTH_NULL;
423                         break;                    421                         break;
424                 case Opt_sec_sys:                 422                 case Opt_sec_sys:
425                         pseudoflavor = RPC_AUT    423                         pseudoflavor = RPC_AUTH_UNIX;
426                         break;                    424                         break;
427                 case Opt_sec_krb5:                425                 case Opt_sec_krb5:
428                         pseudoflavor = RPC_AUT    426                         pseudoflavor = RPC_AUTH_GSS_KRB5;
429                         break;                    427                         break;
430                 case Opt_sec_krb5i:               428                 case Opt_sec_krb5i:
431                         pseudoflavor = RPC_AUT    429                         pseudoflavor = RPC_AUTH_GSS_KRB5I;
432                         break;                    430                         break;
433                 case Opt_sec_krb5p:               431                 case Opt_sec_krb5p:
434                         pseudoflavor = RPC_AUT    432                         pseudoflavor = RPC_AUTH_GSS_KRB5P;
435                         break;                    433                         break;
436                 case Opt_sec_lkey:                434                 case Opt_sec_lkey:
437                         pseudoflavor = RPC_AUT    435                         pseudoflavor = RPC_AUTH_GSS_LKEY;
438                         break;                    436                         break;
439                 case Opt_sec_lkeyi:               437                 case Opt_sec_lkeyi:
440                         pseudoflavor = RPC_AUT    438                         pseudoflavor = RPC_AUTH_GSS_LKEYI;
441                         break;                    439                         break;
442                 case Opt_sec_lkeyp:               440                 case Opt_sec_lkeyp:
443                         pseudoflavor = RPC_AUT    441                         pseudoflavor = RPC_AUTH_GSS_LKEYP;
444                         break;                    442                         break;
445                 case Opt_sec_spkm:                443                 case Opt_sec_spkm:
446                         pseudoflavor = RPC_AUT    444                         pseudoflavor = RPC_AUTH_GSS_SPKM;
447                         break;                    445                         break;
448                 case Opt_sec_spkmi:               446                 case Opt_sec_spkmi:
449                         pseudoflavor = RPC_AUT    447                         pseudoflavor = RPC_AUTH_GSS_SPKMI;
450                         break;                    448                         break;
451                 case Opt_sec_spkmp:               449                 case Opt_sec_spkmp:
452                         pseudoflavor = RPC_AUT    450                         pseudoflavor = RPC_AUTH_GSS_SPKMP;
453                         break;                    451                         break;
454                 default:                          452                 default:
455                         return nfs_invalf(fc,     453                         return nfs_invalf(fc, "NFS: sec=%s option not recognized", p);
456                 }                                 454                 }
457                                                   455 
458                 ret = nfs_auth_info_add(fc, &c    456                 ret = nfs_auth_info_add(fc, &ctx->auth_info, pseudoflavor);
459                 if (ret < 0)                      457                 if (ret < 0)
460                         return ret;               458                         return ret;
461         }                                         459         }
462                                                   460 
463         return 0;                                 461         return 0;
464 }                                                 462 }
465                                                   463 
466 static int nfs_parse_xprtsec_policy(struct fs_    464 static int nfs_parse_xprtsec_policy(struct fs_context *fc,
467                                     struct fs_    465                                     struct fs_parameter *param)
468 {                                                 466 {
469         struct nfs_fs_context *ctx = nfs_fc2co    467         struct nfs_fs_context *ctx = nfs_fc2context(fc);
470                                                   468 
471         trace_nfs_mount_assign(param->key, par    469         trace_nfs_mount_assign(param->key, param->string);
472                                                   470 
473         switch (lookup_constant(nfs_xprtsec_po    471         switch (lookup_constant(nfs_xprtsec_policies, param->string, -1)) {
474         case Opt_xprtsec_none:                    472         case Opt_xprtsec_none:
475                 ctx->xprtsec.policy = RPC_XPRT    473                 ctx->xprtsec.policy = RPC_XPRTSEC_NONE;
476                 break;                            474                 break;
477         case Opt_xprtsec_tls:                     475         case Opt_xprtsec_tls:
478                 ctx->xprtsec.policy = RPC_XPRT    476                 ctx->xprtsec.policy = RPC_XPRTSEC_TLS_ANON;
479                 break;                            477                 break;
480         case Opt_xprtsec_mtls:                    478         case Opt_xprtsec_mtls:
481                 ctx->xprtsec.policy = RPC_XPRT    479                 ctx->xprtsec.policy = RPC_XPRTSEC_TLS_X509;
482                 break;                            480                 break;
483         default:                                  481         default:
484                 return nfs_invalf(fc, "NFS: Un    482                 return nfs_invalf(fc, "NFS: Unrecognized transport security policy");
485         }                                         483         }
486         return 0;                                 484         return 0;
487 }                                                 485 }
488                                                   486 
489 static int nfs_parse_version_string(struct fs_    487 static int nfs_parse_version_string(struct fs_context *fc,
490                                     const char    488                                     const char *string)
491 {                                                 489 {
492         struct nfs_fs_context *ctx = nfs_fc2co    490         struct nfs_fs_context *ctx = nfs_fc2context(fc);
493                                                   491 
494         ctx->flags &= ~NFS_MOUNT_VER3;            492         ctx->flags &= ~NFS_MOUNT_VER3;
495         switch (lookup_constant(nfs_vers_token    493         switch (lookup_constant(nfs_vers_tokens, string, -1)) {
496         case Opt_vers_2:                          494         case Opt_vers_2:
497                 ctx->version = 2;                 495                 ctx->version = 2;
498                 break;                            496                 break;
499         case Opt_vers_3:                          497         case Opt_vers_3:
500                 ctx->flags |= NFS_MOUNT_VER3;     498                 ctx->flags |= NFS_MOUNT_VER3;
501                 ctx->version = 3;                 499                 ctx->version = 3;
502                 break;                            500                 break;
503         case Opt_vers_4:                          501         case Opt_vers_4:
504                 /* Backward compatibility opti    502                 /* Backward compatibility option. In future,
505                  * the mount program should al    503                  * the mount program should always supply
506                  * a NFSv4 minor version numbe    504                  * a NFSv4 minor version number.
507                  */                               505                  */
508                 ctx->version = 4;                 506                 ctx->version = 4;
509                 break;                            507                 break;
510         case Opt_vers_4_0:                        508         case Opt_vers_4_0:
511                 ctx->version = 4;                 509                 ctx->version = 4;
512                 ctx->minorversion = 0;            510                 ctx->minorversion = 0;
513                 break;                            511                 break;
514         case Opt_vers_4_1:                        512         case Opt_vers_4_1:
515                 ctx->version = 4;                 513                 ctx->version = 4;
516                 ctx->minorversion = 1;            514                 ctx->minorversion = 1;
517                 break;                            515                 break;
518         case Opt_vers_4_2:                        516         case Opt_vers_4_2:
519                 ctx->version = 4;                 517                 ctx->version = 4;
520                 ctx->minorversion = 2;            518                 ctx->minorversion = 2;
521                 break;                            519                 break;
522         default:                                  520         default:
523                 return nfs_invalf(fc, "NFS: Un    521                 return nfs_invalf(fc, "NFS: Unsupported NFS version");
524         }                                         522         }
525         return 0;                                 523         return 0;
526 }                                                 524 }
527                                                   525 
528 /*                                                526 /*
529  * Parse a single mount parameter.                527  * Parse a single mount parameter.
530  */                                               528  */
531 static int nfs_fs_context_parse_param(struct f    529 static int nfs_fs_context_parse_param(struct fs_context *fc,
532                                       struct f    530                                       struct fs_parameter *param)
533 {                                                 531 {
534         struct fs_parse_result result;            532         struct fs_parse_result result;
535         struct nfs_fs_context *ctx = nfs_fc2co    533         struct nfs_fs_context *ctx = nfs_fc2context(fc);
536         unsigned short protofamily, mountfamil    534         unsigned short protofamily, mountfamily;
537         unsigned int len;                         535         unsigned int len;
538         int ret, opt;                             536         int ret, opt;
539                                                   537 
540         trace_nfs_mount_option(param);            538         trace_nfs_mount_option(param);
541                                                   539 
542         opt = fs_parse(fc, nfs_fs_parameters,     540         opt = fs_parse(fc, nfs_fs_parameters, param, &result);
543         if (opt < 0)                              541         if (opt < 0)
544                 return (opt == -ENOPARAM && ct    542                 return (opt == -ENOPARAM && ctx->sloppy) ? 1 : opt;
545                                                   543 
546         if (fc->security)                         544         if (fc->security)
547                 ctx->has_sec_mnt_opts = 1;        545                 ctx->has_sec_mnt_opts = 1;
548                                                   546 
549         switch (opt) {                            547         switch (opt) {
550         case Opt_source:                          548         case Opt_source:
551                 if (fc->source)                   549                 if (fc->source)
552                         return nfs_invalf(fc,     550                         return nfs_invalf(fc, "NFS: Multiple sources not supported");
553                 fc->source = param->string;       551                 fc->source = param->string;
554                 param->string = NULL;             552                 param->string = NULL;
555                 break;                            553                 break;
556                                                   554 
557                 /*                                555                 /*
558                  * boolean options:  foo/nofoo    556                  * boolean options:  foo/nofoo
559                  */                               557                  */
560         case Opt_soft:                            558         case Opt_soft:
561                 ctx->flags |= NFS_MOUNT_SOFT;     559                 ctx->flags |= NFS_MOUNT_SOFT;
562                 ctx->flags &= ~NFS_MOUNT_SOFTE    560                 ctx->flags &= ~NFS_MOUNT_SOFTERR;
563                 break;                            561                 break;
564         case Opt_softerr:                         562         case Opt_softerr:
565                 ctx->flags |= NFS_MOUNT_SOFTER    563                 ctx->flags |= NFS_MOUNT_SOFTERR | NFS_MOUNT_SOFTREVAL;
566                 ctx->flags &= ~NFS_MOUNT_SOFT;    564                 ctx->flags &= ~NFS_MOUNT_SOFT;
567                 break;                            565                 break;
568         case Opt_hard:                            566         case Opt_hard:
569                 ctx->flags &= ~(NFS_MOUNT_SOFT    567                 ctx->flags &= ~(NFS_MOUNT_SOFT |
570                                 NFS_MOUNT_SOFT    568                                 NFS_MOUNT_SOFTERR |
571                                 NFS_MOUNT_SOFT    569                                 NFS_MOUNT_SOFTREVAL);
572                 break;                            570                 break;
573         case Opt_softreval:                       571         case Opt_softreval:
574                 if (result.negated)               572                 if (result.negated)
575                         ctx->flags &= ~NFS_MOU    573                         ctx->flags &= ~NFS_MOUNT_SOFTREVAL;
576                 else                              574                 else
577                         ctx->flags |= NFS_MOUN    575                         ctx->flags |= NFS_MOUNT_SOFTREVAL;
578                 break;                            576                 break;
579         case Opt_posix:                           577         case Opt_posix:
580                 if (result.negated)               578                 if (result.negated)
581                         ctx->flags &= ~NFS_MOU    579                         ctx->flags &= ~NFS_MOUNT_POSIX;
582                 else                              580                 else
583                         ctx->flags |= NFS_MOUN    581                         ctx->flags |= NFS_MOUNT_POSIX;
584                 break;                            582                 break;
585         case Opt_cto:                             583         case Opt_cto:
586                 if (result.negated)               584                 if (result.negated)
587                         ctx->flags |= NFS_MOUN    585                         ctx->flags |= NFS_MOUNT_NOCTO;
588                 else                              586                 else
589                         ctx->flags &= ~NFS_MOU    587                         ctx->flags &= ~NFS_MOUNT_NOCTO;
590                 break;                            588                 break;
591         case Opt_trunkdiscovery:                  589         case Opt_trunkdiscovery:
592                 if (result.negated)               590                 if (result.negated)
593                         ctx->flags &= ~NFS_MOU    591                         ctx->flags &= ~NFS_MOUNT_TRUNK_DISCOVERY;
594                 else                              592                 else
595                         ctx->flags |= NFS_MOUN    593                         ctx->flags |= NFS_MOUNT_TRUNK_DISCOVERY;
596                 break;                            594                 break;
597         case Opt_alignwrite:                   << 
598                 if (result.negated)            << 
599                         ctx->flags |= NFS_MOUN << 
600                 else                           << 
601                         ctx->flags &= ~NFS_MOU << 
602                 break;                         << 
603         case Opt_ac:                              595         case Opt_ac:
604                 if (result.negated)               596                 if (result.negated)
605                         ctx->flags |= NFS_MOUN    597                         ctx->flags |= NFS_MOUNT_NOAC;
606                 else                              598                 else
607                         ctx->flags &= ~NFS_MOU    599                         ctx->flags &= ~NFS_MOUNT_NOAC;
608                 break;                            600                 break;
609         case Opt_lock:                            601         case Opt_lock:
610                 if (result.negated) {             602                 if (result.negated) {
611                         ctx->lock_status = NFS << 
612                         ctx->flags |= NFS_MOUN    603                         ctx->flags |= NFS_MOUNT_NONLM;
613                         ctx->flags |= (NFS_MOU    604                         ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL);
614                 } else {                          605                 } else {
615                         ctx->lock_status = NFS << 
616                         ctx->flags &= ~NFS_MOU    606                         ctx->flags &= ~NFS_MOUNT_NONLM;
617                         ctx->flags &= ~(NFS_MO    607                         ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL);
618                 }                                 608                 }
619                 break;                            609                 break;
620         case Opt_udp:                             610         case Opt_udp:
621                 ctx->flags &= ~NFS_MOUNT_TCP;     611                 ctx->flags &= ~NFS_MOUNT_TCP;
622                 ctx->nfs_server.protocol = XPR    612                 ctx->nfs_server.protocol = XPRT_TRANSPORT_UDP;
623                 break;                            613                 break;
624         case Opt_tcp:                             614         case Opt_tcp:
625         case Opt_rdma:                            615         case Opt_rdma:
626                 ctx->flags |= NFS_MOUNT_TCP; /    616                 ctx->flags |= NFS_MOUNT_TCP; /* for side protocols */
627                 ret = xprt_find_transport_iden    617                 ret = xprt_find_transport_ident(param->key);
628                 if (ret < 0)                      618                 if (ret < 0)
629                         goto out_bad_transport    619                         goto out_bad_transport;
630                 ctx->nfs_server.protocol = ret    620                 ctx->nfs_server.protocol = ret;
631                 break;                            621                 break;
632         case Opt_acl:                             622         case Opt_acl:
633                 if (result.negated)               623                 if (result.negated)
634                         ctx->flags |= NFS_MOUN    624                         ctx->flags |= NFS_MOUNT_NOACL;
635                 else                              625                 else
636                         ctx->flags &= ~NFS_MOU    626                         ctx->flags &= ~NFS_MOUNT_NOACL;
637                 break;                            627                 break;
638         case Opt_rdirplus:                        628         case Opt_rdirplus:
639                 if (result.negated)               629                 if (result.negated)
640                         ctx->flags |= NFS_MOUN    630                         ctx->flags |= NFS_MOUNT_NORDIRPLUS;
641                 else                              631                 else
642                         ctx->flags &= ~NFS_MOU    632                         ctx->flags &= ~NFS_MOUNT_NORDIRPLUS;
643                 break;                            633                 break;
644         case Opt_sharecache:                      634         case Opt_sharecache:
645                 if (result.negated)               635                 if (result.negated)
646                         ctx->flags |= NFS_MOUN    636                         ctx->flags |= NFS_MOUNT_UNSHARED;
647                 else                              637                 else
648                         ctx->flags &= ~NFS_MOU    638                         ctx->flags &= ~NFS_MOUNT_UNSHARED;
649                 break;                            639                 break;
650         case Opt_resvport:                        640         case Opt_resvport:
651                 if (result.negated)               641                 if (result.negated)
652                         ctx->flags |= NFS_MOUN    642                         ctx->flags |= NFS_MOUNT_NORESVPORT;
653                 else                              643                 else
654                         ctx->flags &= ~NFS_MOU    644                         ctx->flags &= ~NFS_MOUNT_NORESVPORT;
655                 break;                            645                 break;
656         case Opt_fscache_flag:                    646         case Opt_fscache_flag:
657                 if (result.negated)               647                 if (result.negated)
658                         ctx->options &= ~NFS_O    648                         ctx->options &= ~NFS_OPTION_FSCACHE;
659                 else                              649                 else
660                         ctx->options |= NFS_OP    650                         ctx->options |= NFS_OPTION_FSCACHE;
661                 kfree(ctx->fscache_uniq);         651                 kfree(ctx->fscache_uniq);
662                 ctx->fscache_uniq = NULL;         652                 ctx->fscache_uniq = NULL;
663                 break;                            653                 break;
664         case Opt_fscache:                         654         case Opt_fscache:
665                 trace_nfs_mount_assign(param->    655                 trace_nfs_mount_assign(param->key, param->string);
666                 ctx->options |= NFS_OPTION_FSC    656                 ctx->options |= NFS_OPTION_FSCACHE;
667                 kfree(ctx->fscache_uniq);         657                 kfree(ctx->fscache_uniq);
668                 ctx->fscache_uniq = param->str    658                 ctx->fscache_uniq = param->string;
669                 param->string = NULL;             659                 param->string = NULL;
670                 break;                            660                 break;
671         case Opt_migration:                       661         case Opt_migration:
672                 if (result.negated)               662                 if (result.negated)
673                         ctx->options &= ~NFS_O    663                         ctx->options &= ~NFS_OPTION_MIGRATION;
674                 else                              664                 else
675                         ctx->options |= NFS_OP    665                         ctx->options |= NFS_OPTION_MIGRATION;
676                 break;                            666                 break;
677                                                   667 
678                 /*                                668                 /*
679                  * options that take numeric v    669                  * options that take numeric values
680                  */                               670                  */
681         case Opt_port:                            671         case Opt_port:
682                 if (result.uint_32 > USHRT_MAX    672                 if (result.uint_32 > USHRT_MAX)
683                         goto out_of_bounds;       673                         goto out_of_bounds;
684                 ctx->nfs_server.port = result.    674                 ctx->nfs_server.port = result.uint_32;
685                 break;                            675                 break;
686         case Opt_rsize:                           676         case Opt_rsize:
687                 ctx->rsize = result.uint_32;      677                 ctx->rsize = result.uint_32;
688                 break;                            678                 break;
689         case Opt_wsize:                           679         case Opt_wsize:
690                 ctx->wsize = result.uint_32;      680                 ctx->wsize = result.uint_32;
691                 break;                            681                 break;
692         case Opt_bsize:                           682         case Opt_bsize:
693                 ctx->bsize = result.uint_32;      683                 ctx->bsize = result.uint_32;
694                 break;                            684                 break;
695         case Opt_timeo:                           685         case Opt_timeo:
696                 if (result.uint_32 < 1 || resu    686                 if (result.uint_32 < 1 || result.uint_32 > INT_MAX)
697                         goto out_of_bounds;       687                         goto out_of_bounds;
698                 ctx->timeo = result.uint_32;      688                 ctx->timeo = result.uint_32;
699                 break;                            689                 break;
700         case Opt_retrans:                         690         case Opt_retrans:
701                 if (result.uint_32 > INT_MAX)     691                 if (result.uint_32 > INT_MAX)
702                         goto out_of_bounds;       692                         goto out_of_bounds;
703                 ctx->retrans = result.uint_32;    693                 ctx->retrans = result.uint_32;
704                 break;                            694                 break;
705         case Opt_acregmin:                        695         case Opt_acregmin:
706                 ctx->acregmin = result.uint_32    696                 ctx->acregmin = result.uint_32;
707                 break;                            697                 break;
708         case Opt_acregmax:                        698         case Opt_acregmax:
709                 ctx->acregmax = result.uint_32    699                 ctx->acregmax = result.uint_32;
710                 break;                            700                 break;
711         case Opt_acdirmin:                        701         case Opt_acdirmin:
712                 ctx->acdirmin = result.uint_32    702                 ctx->acdirmin = result.uint_32;
713                 break;                            703                 break;
714         case Opt_acdirmax:                        704         case Opt_acdirmax:
715                 ctx->acdirmax = result.uint_32    705                 ctx->acdirmax = result.uint_32;
716                 break;                            706                 break;
717         case Opt_actimeo:                         707         case Opt_actimeo:
718                 ctx->acregmin = result.uint_32    708                 ctx->acregmin = result.uint_32;
719                 ctx->acregmax = result.uint_32    709                 ctx->acregmax = result.uint_32;
720                 ctx->acdirmin = result.uint_32    710                 ctx->acdirmin = result.uint_32;
721                 ctx->acdirmax = result.uint_32    711                 ctx->acdirmax = result.uint_32;
722                 break;                            712                 break;
723         case Opt_namelen:                         713         case Opt_namelen:
724                 ctx->namlen = result.uint_32;     714                 ctx->namlen = result.uint_32;
725                 break;                            715                 break;
726         case Opt_mountport:                       716         case Opt_mountport:
727                 if (result.uint_32 > USHRT_MAX    717                 if (result.uint_32 > USHRT_MAX)
728                         goto out_of_bounds;       718                         goto out_of_bounds;
729                 ctx->mount_server.port = resul    719                 ctx->mount_server.port = result.uint_32;
730                 break;                            720                 break;
731         case Opt_mountvers:                       721         case Opt_mountvers:
732                 if (result.uint_32 < NFS_MNT_V    722                 if (result.uint_32 < NFS_MNT_VERSION ||
733                     result.uint_32 > NFS_MNT3_    723                     result.uint_32 > NFS_MNT3_VERSION)
734                         goto out_of_bounds;       724                         goto out_of_bounds;
735                 ctx->mount_server.version = re    725                 ctx->mount_server.version = result.uint_32;
736                 break;                            726                 break;
737         case Opt_minorversion:                    727         case Opt_minorversion:
738                 if (result.uint_32 > NFS4_MAX_    728                 if (result.uint_32 > NFS4_MAX_MINOR_VERSION)
739                         goto out_of_bounds;       729                         goto out_of_bounds;
740                 ctx->minorversion = result.uin    730                 ctx->minorversion = result.uint_32;
741                 break;                            731                 break;
742                                                   732 
743                 /*                                733                 /*
744                  * options that take text valu    734                  * options that take text values
745                  */                               735                  */
746         case Opt_v:                               736         case Opt_v:
747                 ret = nfs_parse_version_string    737                 ret = nfs_parse_version_string(fc, param->key + 1);
748                 if (ret < 0)                      738                 if (ret < 0)
749                         return ret;               739                         return ret;
750                 break;                            740                 break;
751         case Opt_vers:                            741         case Opt_vers:
752                 if (!param->string)               742                 if (!param->string)
753                         goto out_invalid_value    743                         goto out_invalid_value;
754                 trace_nfs_mount_assign(param->    744                 trace_nfs_mount_assign(param->key, param->string);
755                 ret = nfs_parse_version_string    745                 ret = nfs_parse_version_string(fc, param->string);
756                 if (ret < 0)                      746                 if (ret < 0)
757                         return ret;               747                         return ret;
758                 break;                            748                 break;
759         case Opt_sec:                             749         case Opt_sec:
760                 ret = nfs_parse_security_flavo    750                 ret = nfs_parse_security_flavors(fc, param);
761                 if (ret < 0)                      751                 if (ret < 0)
762                         return ret;               752                         return ret;
763                 break;                            753                 break;
764         case Opt_xprtsec:                         754         case Opt_xprtsec:
765                 ret = nfs_parse_xprtsec_policy    755                 ret = nfs_parse_xprtsec_policy(fc, param);
766                 if (ret < 0)                      756                 if (ret < 0)
767                         return ret;               757                         return ret;
768                 break;                            758                 break;
769                                                   759 
770         case Opt_proto:                           760         case Opt_proto:
771                 if (!param->string)               761                 if (!param->string)
772                         goto out_invalid_value    762                         goto out_invalid_value;
773                 trace_nfs_mount_assign(param->    763                 trace_nfs_mount_assign(param->key, param->string);
774                 protofamily = AF_INET;            764                 protofamily = AF_INET;
775                 switch (lookup_constant(nfs_xp    765                 switch (lookup_constant(nfs_xprt_protocol_tokens, param->string, -1)) {
776                 case Opt_xprt_udp6:               766                 case Opt_xprt_udp6:
777                         protofamily = AF_INET6    767                         protofamily = AF_INET6;
778                         fallthrough;              768                         fallthrough;
779                 case Opt_xprt_udp:                769                 case Opt_xprt_udp:
780                         ctx->flags &= ~NFS_MOU    770                         ctx->flags &= ~NFS_MOUNT_TCP;
781                         ctx->nfs_server.protoc    771                         ctx->nfs_server.protocol = XPRT_TRANSPORT_UDP;
782                         break;                    772                         break;
783                 case Opt_xprt_tcp6:               773                 case Opt_xprt_tcp6:
784                         protofamily = AF_INET6    774                         protofamily = AF_INET6;
785                         fallthrough;              775                         fallthrough;
786                 case Opt_xprt_tcp:                776                 case Opt_xprt_tcp:
787                         ctx->flags |= NFS_MOUN    777                         ctx->flags |= NFS_MOUNT_TCP;
788                         ctx->nfs_server.protoc    778                         ctx->nfs_server.protocol = XPRT_TRANSPORT_TCP;
789                         break;                    779                         break;
790                 case Opt_xprt_rdma6:              780                 case Opt_xprt_rdma6:
791                         protofamily = AF_INET6    781                         protofamily = AF_INET6;
792                         fallthrough;              782                         fallthrough;
793                 case Opt_xprt_rdma:               783                 case Opt_xprt_rdma:
794                         /* vector side protoco    784                         /* vector side protocols to TCP */
795                         ctx->flags |= NFS_MOUN    785                         ctx->flags |= NFS_MOUNT_TCP;
796                         ret = xprt_find_transp    786                         ret = xprt_find_transport_ident(param->string);
797                         if (ret < 0)              787                         if (ret < 0)
798                                 goto out_bad_t    788                                 goto out_bad_transport;
799                         ctx->nfs_server.protoc    789                         ctx->nfs_server.protocol = ret;
800                         break;                    790                         break;
801                 default:                          791                 default:
802                         goto out_bad_transport    792                         goto out_bad_transport;
803                 }                                 793                 }
804                                                   794 
805                 ctx->protofamily = protofamily    795                 ctx->protofamily = protofamily;
806                 break;                            796                 break;
807                                                   797 
808         case Opt_mountproto:                      798         case Opt_mountproto:
809                 if (!param->string)               799                 if (!param->string)
810                         goto out_invalid_value    800                         goto out_invalid_value;
811                 trace_nfs_mount_assign(param->    801                 trace_nfs_mount_assign(param->key, param->string);
812                 mountfamily = AF_INET;            802                 mountfamily = AF_INET;
813                 switch (lookup_constant(nfs_xp    803                 switch (lookup_constant(nfs_xprt_protocol_tokens, param->string, -1)) {
814                 case Opt_xprt_udp6:               804                 case Opt_xprt_udp6:
815                         mountfamily = AF_INET6    805                         mountfamily = AF_INET6;
816                         fallthrough;              806                         fallthrough;
817                 case Opt_xprt_udp:                807                 case Opt_xprt_udp:
818                         ctx->mount_server.prot    808                         ctx->mount_server.protocol = XPRT_TRANSPORT_UDP;
819                         break;                    809                         break;
820                 case Opt_xprt_tcp6:               810                 case Opt_xprt_tcp6:
821                         mountfamily = AF_INET6    811                         mountfamily = AF_INET6;
822                         fallthrough;              812                         fallthrough;
823                 case Opt_xprt_tcp:                813                 case Opt_xprt_tcp:
824                         ctx->mount_server.prot    814                         ctx->mount_server.protocol = XPRT_TRANSPORT_TCP;
825                         break;                    815                         break;
826                 case Opt_xprt_rdma: /* not use    816                 case Opt_xprt_rdma: /* not used for side protocols */
827                 default:                          817                 default:
828                         goto out_bad_transport    818                         goto out_bad_transport;
829                 }                                 819                 }
830                 ctx->mountfamily = mountfamily    820                 ctx->mountfamily = mountfamily;
831                 break;                            821                 break;
832                                                   822 
833         case Opt_addr:                            823         case Opt_addr:
834                 trace_nfs_mount_assign(param->    824                 trace_nfs_mount_assign(param->key, param->string);
835                 len = rpc_pton(fc->net_ns, par    825                 len = rpc_pton(fc->net_ns, param->string, param->size,
836                                &ctx->nfs_serve    826                                &ctx->nfs_server.address,
837                                sizeof(ctx->nfs    827                                sizeof(ctx->nfs_server._address));
838                 if (len == 0)                     828                 if (len == 0)
839                         goto out_invalid_addre    829                         goto out_invalid_address;
840                 ctx->nfs_server.addrlen = len;    830                 ctx->nfs_server.addrlen = len;
841                 break;                            831                 break;
842         case Opt_clientaddr:                      832         case Opt_clientaddr:
843                 trace_nfs_mount_assign(param->    833                 trace_nfs_mount_assign(param->key, param->string);
844                 kfree(ctx->client_address);       834                 kfree(ctx->client_address);
845                 ctx->client_address = param->s    835                 ctx->client_address = param->string;
846                 param->string = NULL;             836                 param->string = NULL;
847                 break;                            837                 break;
848         case Opt_mounthost:                       838         case Opt_mounthost:
849                 trace_nfs_mount_assign(param->    839                 trace_nfs_mount_assign(param->key, param->string);
850                 kfree(ctx->mount_server.hostna    840                 kfree(ctx->mount_server.hostname);
851                 ctx->mount_server.hostname = p    841                 ctx->mount_server.hostname = param->string;
852                 param->string = NULL;             842                 param->string = NULL;
853                 break;                            843                 break;
854         case Opt_mountaddr:                       844         case Opt_mountaddr:
855                 trace_nfs_mount_assign(param->    845                 trace_nfs_mount_assign(param->key, param->string);
856                 len = rpc_pton(fc->net_ns, par    846                 len = rpc_pton(fc->net_ns, param->string, param->size,
857                                &ctx->mount_ser    847                                &ctx->mount_server.address,
858                                sizeof(ctx->mou    848                                sizeof(ctx->mount_server._address));
859                 if (len == 0)                     849                 if (len == 0)
860                         goto out_invalid_addre    850                         goto out_invalid_address;
861                 ctx->mount_server.addrlen = le    851                 ctx->mount_server.addrlen = len;
862                 break;                            852                 break;
863         case Opt_nconnect:                        853         case Opt_nconnect:
864                 trace_nfs_mount_assign(param->    854                 trace_nfs_mount_assign(param->key, param->string);
865                 if (result.uint_32 < 1 || resu    855                 if (result.uint_32 < 1 || result.uint_32 > NFS_MAX_CONNECTIONS)
866                         goto out_of_bounds;       856                         goto out_of_bounds;
867                 ctx->nfs_server.nconnect = res    857                 ctx->nfs_server.nconnect = result.uint_32;
868                 break;                            858                 break;
869         case Opt_max_connect:                     859         case Opt_max_connect:
870                 trace_nfs_mount_assign(param->    860                 trace_nfs_mount_assign(param->key, param->string);
871                 if (result.uint_32 < 1 || resu    861                 if (result.uint_32 < 1 || result.uint_32 > NFS_MAX_TRANSPORTS)
872                         goto out_of_bounds;       862                         goto out_of_bounds;
873                 ctx->nfs_server.max_connect =     863                 ctx->nfs_server.max_connect = result.uint_32;
874                 break;                            864                 break;
875         case Opt_lookupcache:                     865         case Opt_lookupcache:
876                 trace_nfs_mount_assign(param->    866                 trace_nfs_mount_assign(param->key, param->string);
877                 switch (result.uint_32) {         867                 switch (result.uint_32) {
878                 case Opt_lookupcache_all:         868                 case Opt_lookupcache_all:
879                         ctx->flags &= ~(NFS_MO    869                         ctx->flags &= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE);
880                         break;                    870                         break;
881                 case Opt_lookupcache_positive:    871                 case Opt_lookupcache_positive:
882                         ctx->flags &= ~NFS_MOU    872                         ctx->flags &= ~NFS_MOUNT_LOOKUP_CACHE_NONE;
883                         ctx->flags |= NFS_MOUN    873                         ctx->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG;
884                         break;                    874                         break;
885                 case Opt_lookupcache_none:        875                 case Opt_lookupcache_none:
886                         ctx->flags |= NFS_MOUN    876                         ctx->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE;
887                         break;                    877                         break;
888                 default:                          878                 default:
889                         goto out_invalid_value    879                         goto out_invalid_value;
890                 }                                 880                 }
891                 break;                            881                 break;
892         case Opt_local_lock:                      882         case Opt_local_lock:
893                 trace_nfs_mount_assign(param->    883                 trace_nfs_mount_assign(param->key, param->string);
894                 switch (result.uint_32) {         884                 switch (result.uint_32) {
895                 case Opt_local_lock_all:          885                 case Opt_local_lock_all:
896                         ctx->flags |= (NFS_MOU    886                         ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK |
897                                        NFS_MOU    887                                        NFS_MOUNT_LOCAL_FCNTL);
898                         break;                    888                         break;
899                 case Opt_local_lock_flock:        889                 case Opt_local_lock_flock:
900                         ctx->flags |= NFS_MOUN    890                         ctx->flags |= NFS_MOUNT_LOCAL_FLOCK;
901                         break;                    891                         break;
902                 case Opt_local_lock_posix:        892                 case Opt_local_lock_posix:
903                         ctx->flags |= NFS_MOUN    893                         ctx->flags |= NFS_MOUNT_LOCAL_FCNTL;
904                         break;                    894                         break;
905                 case Opt_local_lock_none:         895                 case Opt_local_lock_none:
906                         ctx->flags &= ~(NFS_MO    896                         ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK |
907                                         NFS_MO    897                                         NFS_MOUNT_LOCAL_FCNTL);
908                         break;                    898                         break;
909                 default:                          899                 default:
910                         goto out_invalid_value    900                         goto out_invalid_value;
911                 }                                 901                 }
912                 break;                            902                 break;
913         case Opt_write:                           903         case Opt_write:
914                 trace_nfs_mount_assign(param->    904                 trace_nfs_mount_assign(param->key, param->string);
915                 switch (result.uint_32) {         905                 switch (result.uint_32) {
916                 case Opt_write_lazy:              906                 case Opt_write_lazy:
917                         ctx->flags &=             907                         ctx->flags &=
918                                 ~(NFS_MOUNT_WR    908                                 ~(NFS_MOUNT_WRITE_EAGER | NFS_MOUNT_WRITE_WAIT);
919                         break;                    909                         break;
920                 case Opt_write_eager:             910                 case Opt_write_eager:
921                         ctx->flags |= NFS_MOUN    911                         ctx->flags |= NFS_MOUNT_WRITE_EAGER;
922                         ctx->flags &= ~NFS_MOU    912                         ctx->flags &= ~NFS_MOUNT_WRITE_WAIT;
923                         break;                    913                         break;
924                 case Opt_write_wait:              914                 case Opt_write_wait:
925                         ctx->flags |=             915                         ctx->flags |=
926                                 NFS_MOUNT_WRIT    916                                 NFS_MOUNT_WRITE_EAGER | NFS_MOUNT_WRITE_WAIT;
927                         break;                    917                         break;
928                 default:                          918                 default:
929                         goto out_invalid_value    919                         goto out_invalid_value;
930                 }                                 920                 }
931                 break;                            921                 break;
932                                                   922 
933                 /*                                923                 /*
934                  * Special options                924                  * Special options
935                  */                               925                  */
936         case Opt_sloppy:                          926         case Opt_sloppy:
937                 ctx->sloppy = true;               927                 ctx->sloppy = true;
938                 break;                            928                 break;
939         }                                         929         }
940                                                   930 
941         return 0;                                 931         return 0;
942                                                   932 
943 out_invalid_value:                                933 out_invalid_value:
944         return nfs_invalf(fc, "NFS: Bad mount     934         return nfs_invalf(fc, "NFS: Bad mount option value specified");
945 out_invalid_address:                              935 out_invalid_address:
946         return nfs_invalf(fc, "NFS: Bad IP add    936         return nfs_invalf(fc, "NFS: Bad IP address specified");
947 out_of_bounds:                                    937 out_of_bounds:
948         return nfs_invalf(fc, "NFS: Value for     938         return nfs_invalf(fc, "NFS: Value for '%s' out of range", param->key);
949 out_bad_transport:                                939 out_bad_transport:
950         return nfs_invalf(fc, "NFS: Unrecogniz    940         return nfs_invalf(fc, "NFS: Unrecognized transport protocol");
951 }                                                 941 }
952                                                   942 
953 /*                                                943 /*
954  * Split fc->source into "hostname:export_path    944  * Split fc->source into "hostname:export_path".
955  *                                                945  *
956  * The leftmost colon demarks the split betwee    946  * The leftmost colon demarks the split between the server's hostname
957  * and the export path.  If the hostname start    947  * and the export path.  If the hostname starts with a left square
958  * bracket, then it may contain colons.           948  * bracket, then it may contain colons.
959  *                                                949  *
960  * Note: caller frees hostname and export path    950  * Note: caller frees hostname and export path, even on error.
961  */                                               951  */
962 static int nfs_parse_source(struct fs_context     952 static int nfs_parse_source(struct fs_context *fc,
963                             size_t maxnamlen,     953                             size_t maxnamlen, size_t maxpathlen)
964 {                                                 954 {
965         struct nfs_fs_context *ctx = nfs_fc2co    955         struct nfs_fs_context *ctx = nfs_fc2context(fc);
966         const char *dev_name = fc->source;        956         const char *dev_name = fc->source;
967         size_t len;                               957         size_t len;
968         const char *end;                          958         const char *end;
969                                                   959 
970         if (unlikely(!dev_name || !*dev_name))    960         if (unlikely(!dev_name || !*dev_name))
971                 return -EINVAL;                   961                 return -EINVAL;
972                                                   962 
973         /* Is the host name protected with squ    963         /* Is the host name protected with square brakcets? */
974         if (*dev_name == '[') {                   964         if (*dev_name == '[') {
975                 end = strchr(++dev_name, ']');    965                 end = strchr(++dev_name, ']');
976                 if (end == NULL || end[1] != '    966                 if (end == NULL || end[1] != ':')
977                         goto out_bad_devname;     967                         goto out_bad_devname;
978                                                   968 
979                 len = end - dev_name;             969                 len = end - dev_name;
980                 end++;                            970                 end++;
981         } else {                                  971         } else {
982                 const char *comma;                972                 const char *comma;
983                                                   973 
984                 end = strchr(dev_name, ':');      974                 end = strchr(dev_name, ':');
985                 if (end == NULL)                  975                 if (end == NULL)
986                         goto out_bad_devname;     976                         goto out_bad_devname;
987                 len = end - dev_name;             977                 len = end - dev_name;
988                                                   978 
989                 /* kill possible hostname list    979                 /* kill possible hostname list: not supported */
990                 comma = memchr(dev_name, ',',     980                 comma = memchr(dev_name, ',', len);
991                 if (comma)                        981                 if (comma)
992                         len = comma - dev_name    982                         len = comma - dev_name;
993         }                                         983         }
994                                                   984 
995         if (len > maxnamlen)                      985         if (len > maxnamlen)
996                 goto out_hostname;                986                 goto out_hostname;
997                                                   987 
998         kfree(ctx->nfs_server.hostname);          988         kfree(ctx->nfs_server.hostname);
999                                                   989 
1000         /* N.B. caller will free nfs_server.h    990         /* N.B. caller will free nfs_server.hostname in all cases */
1001         ctx->nfs_server.hostname = kmemdup_nu    991         ctx->nfs_server.hostname = kmemdup_nul(dev_name, len, GFP_KERNEL);
1002         if (!ctx->nfs_server.hostname)           992         if (!ctx->nfs_server.hostname)
1003                 goto out_nomem;                  993                 goto out_nomem;
1004         len = strlen(++end);                     994         len = strlen(++end);
1005         if (len > maxpathlen)                    995         if (len > maxpathlen)
1006                 goto out_path;                   996                 goto out_path;
1007         ctx->nfs_server.export_path = kmemdup    997         ctx->nfs_server.export_path = kmemdup_nul(end, len, GFP_KERNEL);
1008         if (!ctx->nfs_server.export_path)        998         if (!ctx->nfs_server.export_path)
1009                 goto out_nomem;                  999                 goto out_nomem;
1010                                                  1000 
1011         trace_nfs_mount_path(ctx->nfs_server.    1001         trace_nfs_mount_path(ctx->nfs_server.export_path);
1012         return 0;                                1002         return 0;
1013                                                  1003 
1014 out_bad_devname:                                 1004 out_bad_devname:
1015         return nfs_invalf(fc, "NFS: device na    1005         return nfs_invalf(fc, "NFS: device name not in host:path format");
1016 out_nomem:                                       1006 out_nomem:
1017         nfs_errorf(fc, "NFS: not enough memor    1007         nfs_errorf(fc, "NFS: not enough memory to parse device name");
1018         return -ENOMEM;                          1008         return -ENOMEM;
1019 out_hostname:                                    1009 out_hostname:
1020         nfs_errorf(fc, "NFS: server hostname     1010         nfs_errorf(fc, "NFS: server hostname too long");
1021         return -ENAMETOOLONG;                    1011         return -ENAMETOOLONG;
1022 out_path:                                        1012 out_path:
1023         nfs_errorf(fc, "NFS: export pathname     1013         nfs_errorf(fc, "NFS: export pathname too long");
1024         return -ENAMETOOLONG;                    1014         return -ENAMETOOLONG;
1025 }                                                1015 }
1026                                                  1016 
1027 static inline bool is_remount_fc(struct fs_co    1017 static inline bool is_remount_fc(struct fs_context *fc)
1028 {                                                1018 {
1029         return fc->root != NULL;                 1019         return fc->root != NULL;
1030 }                                                1020 }
1031                                                  1021 
1032 /*                                               1022 /*
1033  * Parse monolithic NFS2/NFS3 mount data         1023  * Parse monolithic NFS2/NFS3 mount data
1034  * - fills in the mount root filehandle          1024  * - fills in the mount root filehandle
1035  *                                               1025  *
1036  * For option strings, user space handles the    1026  * For option strings, user space handles the following behaviors:
1037  *                                               1027  *
1038  * + DNS: mapping server host name to IP addr    1028  * + DNS: mapping server host name to IP address ("addr=" option)
1039  *                                               1029  *
1040  * + failure mode: how to behave if a mount r    1030  * + failure mode: how to behave if a mount request can't be handled
1041  *   immediately ("fg/bg" option)                1031  *   immediately ("fg/bg" option)
1042  *                                               1032  *
1043  * + retry: how often to retry a mount reques    1033  * + retry: how often to retry a mount request ("retry=" option)
1044  *                                               1034  *
1045  * + breaking back: trying proto=udp after pr    1035  * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
1046  *   mountproto=tcp after mountproto=udp, and    1036  *   mountproto=tcp after mountproto=udp, and so on
1047  */                                              1037  */
1048 static int nfs23_parse_monolithic(struct fs_c    1038 static int nfs23_parse_monolithic(struct fs_context *fc,
1049                                   struct nfs_    1039                                   struct nfs_mount_data *data)
1050 {                                                1040 {
1051         struct nfs_fs_context *ctx = nfs_fc2c    1041         struct nfs_fs_context *ctx = nfs_fc2context(fc);
1052         struct nfs_fh *mntfh = ctx->mntfh;       1042         struct nfs_fh *mntfh = ctx->mntfh;
1053         struct sockaddr_storage *sap = &ctx->    1043         struct sockaddr_storage *sap = &ctx->nfs_server._address;
1054         int extra_flags = NFS_MOUNT_LEGACY_IN    1044         int extra_flags = NFS_MOUNT_LEGACY_INTERFACE;
1055         int ret;                                 1045         int ret;
1056                                                  1046 
1057         if (data == NULL)                        1047         if (data == NULL)
1058                 goto out_no_data;                1048                 goto out_no_data;
1059                                                  1049 
1060         ctx->version = NFS_DEFAULT_VERSION;      1050         ctx->version = NFS_DEFAULT_VERSION;
1061         switch (data->version) {                 1051         switch (data->version) {
1062         case 1:                                  1052         case 1:
1063                 data->namlen = 0;                1053                 data->namlen = 0;
1064                 fallthrough;                     1054                 fallthrough;
1065         case 2:                                  1055         case 2:
1066                 data->bsize = 0;                 1056                 data->bsize = 0;
1067                 fallthrough;                     1057                 fallthrough;
1068         case 3:                                  1058         case 3:
1069                 if (data->flags & NFS_MOUNT_V    1059                 if (data->flags & NFS_MOUNT_VER3)
1070                         goto out_no_v3;          1060                         goto out_no_v3;
1071                 data->root.size = NFS2_FHSIZE    1061                 data->root.size = NFS2_FHSIZE;
1072                 memcpy(data->root.data, data-    1062                 memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE);
1073                 /* Turn off security negotiat    1063                 /* Turn off security negotiation */
1074                 extra_flags |= NFS_MOUNT_SECF    1064                 extra_flags |= NFS_MOUNT_SECFLAVOUR;
1075                 fallthrough;                     1065                 fallthrough;
1076         case 4:                                  1066         case 4:
1077                 if (data->flags & NFS_MOUNT_S    1067                 if (data->flags & NFS_MOUNT_SECFLAVOUR)
1078                         goto out_no_sec;         1068                         goto out_no_sec;
1079                 fallthrough;                     1069                 fallthrough;
1080         case 5:                                  1070         case 5:
1081                 memset(data->context, 0, size    1071                 memset(data->context, 0, sizeof(data->context));
1082                 fallthrough;                     1072                 fallthrough;
1083         case 6:                                  1073         case 6:
1084                 if (data->flags & NFS_MOUNT_V    1074                 if (data->flags & NFS_MOUNT_VER3) {
1085                         if (data->root.size >    1075                         if (data->root.size > NFS3_FHSIZE || data->root.size == 0)
1086                                 goto out_inva    1076                                 goto out_invalid_fh;
1087                         mntfh->size = data->r    1077                         mntfh->size = data->root.size;
1088                         ctx->version = 3;        1078                         ctx->version = 3;
1089                 } else {                         1079                 } else {
1090                         mntfh->size = NFS2_FH    1080                         mntfh->size = NFS2_FHSIZE;
1091                         ctx->version = 2;        1081                         ctx->version = 2;
1092                 }                                1082                 }
1093                                                  1083 
1094                                                  1084 
1095                 memcpy(mntfh->data, data->roo    1085                 memcpy(mntfh->data, data->root.data, mntfh->size);
1096                 if (mntfh->size < sizeof(mntf    1086                 if (mntfh->size < sizeof(mntfh->data))
1097                         memset(mntfh->data +     1087                         memset(mntfh->data + mntfh->size, 0,
1098                                sizeof(mntfh->    1088                                sizeof(mntfh->data) - mntfh->size);
1099                                                  1089 
1100                 /*                               1090                 /*
1101                  * for proto == XPRT_TRANSPOR    1091                  * for proto == XPRT_TRANSPORT_UDP, which is what uses
1102                  * to_exponential, implying s    1092                  * to_exponential, implying shift: limit the shift value
1103                  * to BITS_PER_LONG (majortim    1093                  * to BITS_PER_LONG (majortimeo is unsigned long)
1104                  */                              1094                  */
1105                 if (!(data->flags & NFS_MOUNT    1095                 if (!(data->flags & NFS_MOUNT_TCP)) /* this will be UDP */
1106                         if (data->retrans >=     1096                         if (data->retrans >= 64) /* shift value is too large */
1107                                 goto out_inva    1097                                 goto out_invalid_data;
1108                                                  1098 
1109                 /*                               1099                 /*
1110                  * Translate to nfs_fs_contex    1100                  * Translate to nfs_fs_context, which nfs_fill_super
1111                  * can deal with.                1101                  * can deal with.
1112                  */                              1102                  */
1113                 ctx->flags      = data->flags    1103                 ctx->flags      = data->flags & NFS_MOUNT_FLAGMASK;
1114                 ctx->flags      |= extra_flag    1104                 ctx->flags      |= extra_flags;
1115                 ctx->rsize      = data->rsize    1105                 ctx->rsize      = data->rsize;
1116                 ctx->wsize      = data->wsize    1106                 ctx->wsize      = data->wsize;
1117                 ctx->timeo      = data->timeo    1107                 ctx->timeo      = data->timeo;
1118                 ctx->retrans    = data->retra    1108                 ctx->retrans    = data->retrans;
1119                 ctx->acregmin   = data->acreg    1109                 ctx->acregmin   = data->acregmin;
1120                 ctx->acregmax   = data->acreg    1110                 ctx->acregmax   = data->acregmax;
1121                 ctx->acdirmin   = data->acdir    1111                 ctx->acdirmin   = data->acdirmin;
1122                 ctx->acdirmax   = data->acdir    1112                 ctx->acdirmax   = data->acdirmax;
1123                 ctx->need_mount = false;         1113                 ctx->need_mount = false;
1124                                                  1114 
1125                 if (!is_remount_fc(fc)) {        1115                 if (!is_remount_fc(fc)) {
1126                         memcpy(sap, &data->ad    1116                         memcpy(sap, &data->addr, sizeof(data->addr));
1127                         ctx->nfs_server.addrl    1117                         ctx->nfs_server.addrlen = sizeof(data->addr);
1128                         ctx->nfs_server.port     1118                         ctx->nfs_server.port = ntohs(data->addr.sin_port);
1129                 }                                1119                 }
1130                                                  1120 
1131                 if (sap->ss_family != AF_INET    1121                 if (sap->ss_family != AF_INET ||
1132                     !nfs_verify_server_addres    1122                     !nfs_verify_server_address(sap))
1133                         goto out_no_address;     1123                         goto out_no_address;
1134                                                  1124 
1135                 if (!(data->flags & NFS_MOUNT    1125                 if (!(data->flags & NFS_MOUNT_TCP))
1136                         ctx->nfs_server.proto    1126                         ctx->nfs_server.protocol = XPRT_TRANSPORT_UDP;
1137                 /* N.B. caller will free nfs_    1127                 /* N.B. caller will free nfs_server.hostname in all cases */
1138                 ctx->nfs_server.hostname = ks    1128                 ctx->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL);
1139                 if (!ctx->nfs_server.hostname    1129                 if (!ctx->nfs_server.hostname)
1140                         goto out_nomem;          1130                         goto out_nomem;
1141                                                  1131 
1142                 ctx->namlen             = dat    1132                 ctx->namlen             = data->namlen;
1143                 ctx->bsize              = dat    1133                 ctx->bsize              = data->bsize;
1144                                                  1134 
1145                 if (data->flags & NFS_MOUNT_S    1135                 if (data->flags & NFS_MOUNT_SECFLAVOUR)
1146                         ctx->selected_flavor     1136                         ctx->selected_flavor = data->pseudoflavor;
1147                 else                             1137                 else
1148                         ctx->selected_flavor     1138                         ctx->selected_flavor = RPC_AUTH_UNIX;
1149                                                  1139 
1150                 if (!(data->flags & NFS_MOUNT    1140                 if (!(data->flags & NFS_MOUNT_NONLM))
1151                         ctx->flags &= ~(NFS_M    1141                         ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK|
1152                                          NFS_    1142                                          NFS_MOUNT_LOCAL_FCNTL);
1153                 else                             1143                 else
1154                         ctx->flags |= (NFS_MO    1144                         ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK|
1155                                         NFS_M    1145                                         NFS_MOUNT_LOCAL_FCNTL);
1156                                                  1146 
1157                 /*                               1147                 /*
1158                  * The legacy version 6 binar    1148                  * The legacy version 6 binary mount data from userspace has a
1159                  * field used only to transpo    1149                  * field used only to transport selinux information into the
1160                  * kernel.  To continue to su    1150                  * kernel.  To continue to support that functionality we
1161                  * have a touch of selinux kn    1151                  * have a touch of selinux knowledge here in the NFS code. The
1162                  * userspace code converted c    1152                  * userspace code converted context=blah to just blah so we are
1163                  * converting back to the ful    1153                  * converting back to the full string selinux understands.
1164                  */                              1154                  */
1165                 if (data->context[0]){           1155                 if (data->context[0]){
1166 #ifdef CONFIG_SECURITY_SELINUX                   1156 #ifdef CONFIG_SECURITY_SELINUX
1167                         int ret;                 1157                         int ret;
1168                                                  1158 
1169                         data->context[NFS_MAX    1159                         data->context[NFS_MAX_CONTEXT_LEN] = '\0';
1170                         ret = vfs_parse_fs_st    1160                         ret = vfs_parse_fs_string(fc, "context",
1171                                                  1161                                                   data->context, strlen(data->context));
1172                         if (ret < 0)             1162                         if (ret < 0)
1173                                 return ret;      1163                                 return ret;
1174 #else                                            1164 #else
1175                         return -EINVAL;          1165                         return -EINVAL;
1176 #endif                                           1166 #endif
1177                 }                                1167                 }
1178                                                  1168 
1179                 break;                           1169                 break;
1180         default:                                 1170         default:
1181                 goto generic;                    1171                 goto generic;
1182         }                                        1172         }
1183                                                  1173 
1184         ret = nfs_validate_transport_protocol    1174         ret = nfs_validate_transport_protocol(fc, ctx);
1185         if (ret)                                 1175         if (ret)
1186                 return ret;                      1176                 return ret;
1187                                                  1177 
1188         ctx->skip_reconfig_option_check = tru    1178         ctx->skip_reconfig_option_check = true;
1189         return 0;                                1179         return 0;
1190                                                  1180 
1191 generic:                                         1181 generic:
1192         return generic_parse_monolithic(fc, d    1182         return generic_parse_monolithic(fc, data);
1193                                                  1183 
1194 out_no_data:                                     1184 out_no_data:
1195         if (is_remount_fc(fc)) {                 1185         if (is_remount_fc(fc)) {
1196                 ctx->skip_reconfig_option_che    1186                 ctx->skip_reconfig_option_check = true;
1197                 return 0;                        1187                 return 0;
1198         }                                        1188         }
1199         return nfs_invalf(fc, "NFS: mount pro    1189         return nfs_invalf(fc, "NFS: mount program didn't pass any mount data");
1200                                                  1190 
1201 out_no_v3:                                       1191 out_no_v3:
1202         return nfs_invalf(fc, "NFS: nfs_mount    1192         return nfs_invalf(fc, "NFS: nfs_mount_data version does not support v3");
1203                                                  1193 
1204 out_no_sec:                                      1194 out_no_sec:
1205         return nfs_invalf(fc, "NFS: nfs_mount    1195         return nfs_invalf(fc, "NFS: nfs_mount_data version supports only AUTH_SYS");
1206                                                  1196 
1207 out_nomem:                                       1197 out_nomem:
1208         return -ENOMEM;                          1198         return -ENOMEM;
1209                                                  1199 
1210 out_no_address:                                  1200 out_no_address:
1211         return nfs_invalf(fc, "NFS: mount pro    1201         return nfs_invalf(fc, "NFS: mount program didn't pass remote address");
1212                                                  1202 
1213 out_invalid_fh:                                  1203 out_invalid_fh:
1214         return nfs_invalf(fc, "NFS: invalid r    1204         return nfs_invalf(fc, "NFS: invalid root filehandle");
1215                                                  1205 
1216 out_invalid_data:                                1206 out_invalid_data:
1217         return nfs_invalf(fc, "NFS: invalid b    1207         return nfs_invalf(fc, "NFS: invalid binary mount data");
1218 }                                                1208 }
1219                                                  1209 
1220 #if IS_ENABLED(CONFIG_NFS_V4)                    1210 #if IS_ENABLED(CONFIG_NFS_V4)
1221 struct compat_nfs_string {                       1211 struct compat_nfs_string {
1222         compat_uint_t len;                       1212         compat_uint_t len;
1223         compat_uptr_t data;                      1213         compat_uptr_t data;
1224 };                                               1214 };
1225                                                  1215 
1226 static inline void compat_nfs_string(struct n    1216 static inline void compat_nfs_string(struct nfs_string *dst,
1227                                      struct c    1217                                      struct compat_nfs_string *src)
1228 {                                                1218 {
1229         dst->data = compat_ptr(src->data);       1219         dst->data = compat_ptr(src->data);
1230         dst->len = src->len;                     1220         dst->len = src->len;
1231 }                                                1221 }
1232                                                  1222 
1233 struct compat_nfs4_mount_data_v1 {               1223 struct compat_nfs4_mount_data_v1 {
1234         compat_int_t version;                    1224         compat_int_t version;
1235         compat_int_t flags;                      1225         compat_int_t flags;
1236         compat_int_t rsize;                      1226         compat_int_t rsize;
1237         compat_int_t wsize;                      1227         compat_int_t wsize;
1238         compat_int_t timeo;                      1228         compat_int_t timeo;
1239         compat_int_t retrans;                    1229         compat_int_t retrans;
1240         compat_int_t acregmin;                   1230         compat_int_t acregmin;
1241         compat_int_t acregmax;                   1231         compat_int_t acregmax;
1242         compat_int_t acdirmin;                   1232         compat_int_t acdirmin;
1243         compat_int_t acdirmax;                   1233         compat_int_t acdirmax;
1244         struct compat_nfs_string client_addr;    1234         struct compat_nfs_string client_addr;
1245         struct compat_nfs_string mnt_path;       1235         struct compat_nfs_string mnt_path;
1246         struct compat_nfs_string hostname;       1236         struct compat_nfs_string hostname;
1247         compat_uint_t host_addrlen;              1237         compat_uint_t host_addrlen;
1248         compat_uptr_t host_addr;                 1238         compat_uptr_t host_addr;
1249         compat_int_t proto;                      1239         compat_int_t proto;
1250         compat_int_t auth_flavourlen;            1240         compat_int_t auth_flavourlen;
1251         compat_uptr_t auth_flavours;             1241         compat_uptr_t auth_flavours;
1252 };                                               1242 };
1253                                                  1243 
1254 static void nfs4_compat_mount_data_conv(struc    1244 static void nfs4_compat_mount_data_conv(struct nfs4_mount_data *data)
1255 {                                                1245 {
1256         struct compat_nfs4_mount_data_v1 *com    1246         struct compat_nfs4_mount_data_v1 *compat =
1257                         (struct compat_nfs4_m    1247                         (struct compat_nfs4_mount_data_v1 *)data;
1258                                                  1248 
1259         /* copy the fields backwards */          1249         /* copy the fields backwards */
1260         data->auth_flavours = compat_ptr(comp    1250         data->auth_flavours = compat_ptr(compat->auth_flavours);
1261         data->auth_flavourlen = compat->auth_    1251         data->auth_flavourlen = compat->auth_flavourlen;
1262         data->proto = compat->proto;             1252         data->proto = compat->proto;
1263         data->host_addr = compat_ptr(compat->    1253         data->host_addr = compat_ptr(compat->host_addr);
1264         data->host_addrlen = compat->host_add    1254         data->host_addrlen = compat->host_addrlen;
1265         compat_nfs_string(&data->hostname, &c    1255         compat_nfs_string(&data->hostname, &compat->hostname);
1266         compat_nfs_string(&data->mnt_path, &c    1256         compat_nfs_string(&data->mnt_path, &compat->mnt_path);
1267         compat_nfs_string(&data->client_addr,    1257         compat_nfs_string(&data->client_addr, &compat->client_addr);
1268         data->acdirmax = compat->acdirmax;       1258         data->acdirmax = compat->acdirmax;
1269         data->acdirmin = compat->acdirmin;       1259         data->acdirmin = compat->acdirmin;
1270         data->acregmax = compat->acregmax;       1260         data->acregmax = compat->acregmax;
1271         data->acregmin = compat->acregmin;       1261         data->acregmin = compat->acregmin;
1272         data->retrans = compat->retrans;         1262         data->retrans = compat->retrans;
1273         data->timeo = compat->timeo;             1263         data->timeo = compat->timeo;
1274         data->wsize = compat->wsize;             1264         data->wsize = compat->wsize;
1275         data->rsize = compat->rsize;             1265         data->rsize = compat->rsize;
1276         data->flags = compat->flags;             1266         data->flags = compat->flags;
1277         data->version = compat->version;         1267         data->version = compat->version;
1278 }                                                1268 }
1279                                                  1269 
1280 /*                                               1270 /*
1281  * Validate NFSv4 mount options                  1271  * Validate NFSv4 mount options
1282  */                                              1272  */
1283 static int nfs4_parse_monolithic(struct fs_co    1273 static int nfs4_parse_monolithic(struct fs_context *fc,
1284                                  struct nfs4_    1274                                  struct nfs4_mount_data *data)
1285 {                                                1275 {
1286         struct nfs_fs_context *ctx = nfs_fc2c    1276         struct nfs_fs_context *ctx = nfs_fc2context(fc);
1287         struct sockaddr_storage *sap = &ctx->    1277         struct sockaddr_storage *sap = &ctx->nfs_server._address;
1288         int ret;                                 1278         int ret;
1289         char *c;                                 1279         char *c;
1290                                                  1280 
1291         if (!data) {                             1281         if (!data) {
1292                 if (is_remount_fc(fc))           1282                 if (is_remount_fc(fc))
1293                         goto done;               1283                         goto done;
1294                 return nfs_invalf(fc,            1284                 return nfs_invalf(fc,
1295                         "NFS4: mount program     1285                         "NFS4: mount program didn't pass any mount data");
1296         }                                        1286         }
1297                                                  1287 
1298         ctx->version = 4;                        1288         ctx->version = 4;
1299                                                  1289 
1300         if (data->version != 1)                  1290         if (data->version != 1)
1301                 return generic_parse_monolith    1291                 return generic_parse_monolithic(fc, data);
1302                                                  1292 
1303         if (in_compat_syscall())                 1293         if (in_compat_syscall())
1304                 nfs4_compat_mount_data_conv(d    1294                 nfs4_compat_mount_data_conv(data);
1305                                                  1295 
1306         if (data->host_addrlen > sizeof(ctx->    1296         if (data->host_addrlen > sizeof(ctx->nfs_server.address))
1307                 goto out_no_address;             1297                 goto out_no_address;
1308         if (data->host_addrlen == 0)             1298         if (data->host_addrlen == 0)
1309                 goto out_no_address;             1299                 goto out_no_address;
1310         ctx->nfs_server.addrlen = data->host_    1300         ctx->nfs_server.addrlen = data->host_addrlen;
1311         if (copy_from_user(sap, data->host_ad    1301         if (copy_from_user(sap, data->host_addr, data->host_addrlen))
1312                 return -EFAULT;                  1302                 return -EFAULT;
1313         if (!nfs_verify_server_address(sap))     1303         if (!nfs_verify_server_address(sap))
1314                 goto out_no_address;             1304                 goto out_no_address;
1315         ctx->nfs_server.port = ntohs(((struct    1305         ctx->nfs_server.port = ntohs(((struct sockaddr_in *)sap)->sin_port);
1316                                                  1306 
1317         if (data->auth_flavourlen) {             1307         if (data->auth_flavourlen) {
1318                 rpc_authflavor_t pseudoflavor    1308                 rpc_authflavor_t pseudoflavor;
1319                                                  1309 
1320                 if (data->auth_flavourlen > 1    1310                 if (data->auth_flavourlen > 1)
1321                         goto out_inval_auth;     1311                         goto out_inval_auth;
1322                 if (copy_from_user(&pseudofla    1312                 if (copy_from_user(&pseudoflavor, data->auth_flavours,
1323                                    sizeof(pse    1313                                    sizeof(pseudoflavor)))
1324                         return -EFAULT;          1314                         return -EFAULT;
1325                 ctx->selected_flavor = pseudo    1315                 ctx->selected_flavor = pseudoflavor;
1326         } else {                                 1316         } else {
1327                 ctx->selected_flavor = RPC_AU    1317                 ctx->selected_flavor = RPC_AUTH_UNIX;
1328         }                                        1318         }
1329                                                  1319 
1330         c = strndup_user(data->hostname.data,    1320         c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN);
1331         if (IS_ERR(c))                           1321         if (IS_ERR(c))
1332                 return PTR_ERR(c);               1322                 return PTR_ERR(c);
1333         ctx->nfs_server.hostname = c;            1323         ctx->nfs_server.hostname = c;
1334                                                  1324 
1335         c = strndup_user(data->mnt_path.data,    1325         c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN);
1336         if (IS_ERR(c))                           1326         if (IS_ERR(c))
1337                 return PTR_ERR(c);               1327                 return PTR_ERR(c);
1338         ctx->nfs_server.export_path = c;         1328         ctx->nfs_server.export_path = c;
1339         trace_nfs_mount_path(c);                 1329         trace_nfs_mount_path(c);
1340                                                  1330 
1341         c = strndup_user(data->client_addr.da    1331         c = strndup_user(data->client_addr.data, 16);
1342         if (IS_ERR(c))                           1332         if (IS_ERR(c))
1343                 return PTR_ERR(c);               1333                 return PTR_ERR(c);
1344         ctx->client_address = c;                 1334         ctx->client_address = c;
1345                                                  1335 
1346         /*                                       1336         /*
1347          * Translate to nfs_fs_context, which    1337          * Translate to nfs_fs_context, which nfs_fill_super
1348          * can deal with.                        1338          * can deal with.
1349          */                                      1339          */
1350                                                  1340 
1351         ctx->flags      = data->flags & NFS4_    1341         ctx->flags      = data->flags & NFS4_MOUNT_FLAGMASK;
1352         ctx->rsize      = data->rsize;           1342         ctx->rsize      = data->rsize;
1353         ctx->wsize      = data->wsize;           1343         ctx->wsize      = data->wsize;
1354         ctx->timeo      = data->timeo;           1344         ctx->timeo      = data->timeo;
1355         ctx->retrans    = data->retrans;         1345         ctx->retrans    = data->retrans;
1356         ctx->acregmin   = data->acregmin;        1346         ctx->acregmin   = data->acregmin;
1357         ctx->acregmax   = data->acregmax;        1347         ctx->acregmax   = data->acregmax;
1358         ctx->acdirmin   = data->acdirmin;        1348         ctx->acdirmin   = data->acdirmin;
1359         ctx->acdirmax   = data->acdirmax;        1349         ctx->acdirmax   = data->acdirmax;
1360         ctx->nfs_server.protocol = data->prot    1350         ctx->nfs_server.protocol = data->proto;
1361         ret = nfs_validate_transport_protocol    1351         ret = nfs_validate_transport_protocol(fc, ctx);
1362         if (ret)                                 1352         if (ret)
1363                 return ret;                      1353                 return ret;
1364 done:                                            1354 done:
1365         ctx->skip_reconfig_option_check = tru    1355         ctx->skip_reconfig_option_check = true;
1366         return 0;                                1356         return 0;
1367                                                  1357 
1368 out_inval_auth:                                  1358 out_inval_auth:
1369         return nfs_invalf(fc, "NFS4: Invalid     1359         return nfs_invalf(fc, "NFS4: Invalid number of RPC auth flavours %d",
1370                       data->auth_flavourlen);    1360                       data->auth_flavourlen);
1371                                                  1361 
1372 out_no_address:                                  1362 out_no_address:
1373         return nfs_invalf(fc, "NFS4: mount pr    1363         return nfs_invalf(fc, "NFS4: mount program didn't pass remote address");
1374 }                                                1364 }
1375 #endif                                           1365 #endif
1376                                                  1366 
1377 /*                                               1367 /*
1378  * Parse a monolithic block of data from sys_    1368  * Parse a monolithic block of data from sys_mount().
1379  */                                              1369  */
1380 static int nfs_fs_context_parse_monolithic(st    1370 static int nfs_fs_context_parse_monolithic(struct fs_context *fc,
1381                                            vo    1371                                            void *data)
1382 {                                                1372 {
1383         if (fc->fs_type == &nfs_fs_type)         1373         if (fc->fs_type == &nfs_fs_type)
1384                 return nfs23_parse_monolithic    1374                 return nfs23_parse_monolithic(fc, data);
1385                                                  1375 
1386 #if IS_ENABLED(CONFIG_NFS_V4)                    1376 #if IS_ENABLED(CONFIG_NFS_V4)
1387         if (fc->fs_type == &nfs4_fs_type)        1377         if (fc->fs_type == &nfs4_fs_type)
1388                 return nfs4_parse_monolithic(    1378                 return nfs4_parse_monolithic(fc, data);
1389 #endif                                           1379 #endif
1390                                                  1380 
1391         return nfs_invalf(fc, "NFS: Unsupport    1381         return nfs_invalf(fc, "NFS: Unsupported monolithic data version");
1392 }                                                1382 }
1393                                                  1383 
1394 /*                                               1384 /*
1395  * Validate the preparsed information in the     1385  * Validate the preparsed information in the config.
1396  */                                              1386  */
1397 static int nfs_fs_context_validate(struct fs_    1387 static int nfs_fs_context_validate(struct fs_context *fc)
1398 {                                                1388 {
1399         struct nfs_fs_context *ctx = nfs_fc2c    1389         struct nfs_fs_context *ctx = nfs_fc2context(fc);
1400         struct nfs_subversion *nfs_mod;          1390         struct nfs_subversion *nfs_mod;
1401         struct sockaddr_storage *sap = &ctx->    1391         struct sockaddr_storage *sap = &ctx->nfs_server._address;
1402         int max_namelen = PAGE_SIZE;             1392         int max_namelen = PAGE_SIZE;
1403         int max_pathlen = NFS_MAXPATHLEN;        1393         int max_pathlen = NFS_MAXPATHLEN;
1404         int port = 0;                            1394         int port = 0;
1405         int ret;                                 1395         int ret;
1406                                                  1396 
1407         if (!fc->source)                         1397         if (!fc->source)
1408                 goto out_no_device_name;         1398                 goto out_no_device_name;
1409                                                  1399 
1410         /* Check for sanity first. */            1400         /* Check for sanity first. */
1411         if (ctx->minorversion && ctx->version    1401         if (ctx->minorversion && ctx->version != 4)
1412                 goto out_minorversion_mismatc    1402                 goto out_minorversion_mismatch;
1413                                                  1403 
1414         if (ctx->options & NFS_OPTION_MIGRATI    1404         if (ctx->options & NFS_OPTION_MIGRATION &&
1415             (ctx->version != 4 || ctx->minorv    1405             (ctx->version != 4 || ctx->minorversion != 0))
1416                 goto out_migration_misuse;       1406                 goto out_migration_misuse;
1417                                                  1407 
1418         /* Verify that any proto=/mountproto=    1408         /* Verify that any proto=/mountproto= options match the address
1419          * families in the addr=/mountaddr= o    1409          * families in the addr=/mountaddr= options.
1420          */                                      1410          */
1421         if (ctx->protofamily != AF_UNSPEC &&     1411         if (ctx->protofamily != AF_UNSPEC &&
1422             ctx->protofamily != ctx->nfs_serv    1412             ctx->protofamily != ctx->nfs_server.address.sa_family)
1423                 goto out_proto_mismatch;         1413                 goto out_proto_mismatch;
1424                                                  1414 
1425         if (ctx->mountfamily != AF_UNSPEC) {     1415         if (ctx->mountfamily != AF_UNSPEC) {
1426                 if (ctx->mount_server.addrlen    1416                 if (ctx->mount_server.addrlen) {
1427                         if (ctx->mountfamily     1417                         if (ctx->mountfamily != ctx->mount_server.address.sa_family)
1428                                 goto out_moun    1418                                 goto out_mountproto_mismatch;
1429                 } else {                         1419                 } else {
1430                         if (ctx->mountfamily     1420                         if (ctx->mountfamily != ctx->nfs_server.address.sa_family)
1431                                 goto out_moun    1421                                 goto out_mountproto_mismatch;
1432                 }                                1422                 }
1433         }                                        1423         }
1434                                                  1424 
1435         if (!nfs_verify_server_address(sap))     1425         if (!nfs_verify_server_address(sap))
1436                 goto out_no_address;             1426                 goto out_no_address;
1437                                                  1427 
1438         ret = nfs_validate_transport_protocol    1428         ret = nfs_validate_transport_protocol(fc, ctx);
1439         if (ret)                                 1429         if (ret)
1440                 return ret;                      1430                 return ret;
1441                                                  1431 
1442         if (ctx->version == 4) {                 1432         if (ctx->version == 4) {
1443                 if (IS_ENABLED(CONFIG_NFS_V4)    1433                 if (IS_ENABLED(CONFIG_NFS_V4)) {
1444                         if (ctx->nfs_server.p    1434                         if (ctx->nfs_server.protocol == XPRT_TRANSPORT_RDMA)
1445                                 port = NFS_RD    1435                                 port = NFS_RDMA_PORT;
1446                         else                     1436                         else
1447                                 port = NFS_PO    1437                                 port = NFS_PORT;
1448                         max_namelen = NFS4_MA    1438                         max_namelen = NFS4_MAXNAMLEN;
1449                         max_pathlen = NFS4_MA    1439                         max_pathlen = NFS4_MAXPATHLEN;
1450                         ctx->flags &= ~(NFS_M    1440                         ctx->flags &= ~(NFS_MOUNT_NONLM | NFS_MOUNT_NOACL |
1451                                         NFS_M    1441                                         NFS_MOUNT_VER3 | NFS_MOUNT_LOCAL_FLOCK |
1452                                         NFS_M    1442                                         NFS_MOUNT_LOCAL_FCNTL);
1453                 } else {                         1443                 } else {
1454                         goto out_v4_not_compi    1444                         goto out_v4_not_compiled;
1455                 }                                1445                 }
1456         } else {                                 1446         } else {
1457                 nfs_set_mount_transport_proto    1447                 nfs_set_mount_transport_protocol(ctx);
1458                 if (ctx->nfs_server.protocol     1448                 if (ctx->nfs_server.protocol == XPRT_TRANSPORT_RDMA)
1459                         port = NFS_RDMA_PORT;    1449                         port = NFS_RDMA_PORT;
1460         }                                        1450         }
1461                                                  1451 
1462         nfs_set_port(sap, &ctx->nfs_server.po    1452         nfs_set_port(sap, &ctx->nfs_server.port, port);
1463                                                  1453 
1464         ret = nfs_parse_source(fc, max_namele    1454         ret = nfs_parse_source(fc, max_namelen, max_pathlen);
1465         if (ret < 0)                             1455         if (ret < 0)
1466                 return ret;                      1456                 return ret;
1467                                                  1457 
1468         /* Load the NFS protocol module if we    1458         /* Load the NFS protocol module if we haven't done so yet */
1469         if (!ctx->nfs_mod) {                     1459         if (!ctx->nfs_mod) {
1470                 nfs_mod = get_nfs_version(ctx    1460                 nfs_mod = get_nfs_version(ctx->version);
1471                 if (IS_ERR(nfs_mod)) {           1461                 if (IS_ERR(nfs_mod)) {
1472                         ret = PTR_ERR(nfs_mod    1462                         ret = PTR_ERR(nfs_mod);
1473                         goto out_version_unav    1463                         goto out_version_unavailable;
1474                 }                                1464                 }
1475                 ctx->nfs_mod = nfs_mod;          1465                 ctx->nfs_mod = nfs_mod;
1476         }                                        1466         }
1477                                                  1467 
1478         /* Ensure the filesystem context has     1468         /* Ensure the filesystem context has the correct fs_type */
1479         if (fc->fs_type != ctx->nfs_mod->nfs_    1469         if (fc->fs_type != ctx->nfs_mod->nfs_fs) {
1480                 module_put(fc->fs_type->owner    1470                 module_put(fc->fs_type->owner);
1481                 __module_get(ctx->nfs_mod->nf    1471                 __module_get(ctx->nfs_mod->nfs_fs->owner);
1482                 fc->fs_type = ctx->nfs_mod->n    1472                 fc->fs_type = ctx->nfs_mod->nfs_fs;
1483         }                                        1473         }
1484         return 0;                                1474         return 0;
1485                                                  1475 
1486 out_no_device_name:                              1476 out_no_device_name:
1487         return nfs_invalf(fc, "NFS: Device na    1477         return nfs_invalf(fc, "NFS: Device name not specified");
1488 out_v4_not_compiled:                             1478 out_v4_not_compiled:
1489         nfs_errorf(fc, "NFS: NFSv4 is not com    1479         nfs_errorf(fc, "NFS: NFSv4 is not compiled into kernel");
1490         return -EPROTONOSUPPORT;                 1480         return -EPROTONOSUPPORT;
1491 out_no_address:                                  1481 out_no_address:
1492         return nfs_invalf(fc, "NFS: mount pro    1482         return nfs_invalf(fc, "NFS: mount program didn't pass remote address");
1493 out_mountproto_mismatch:                         1483 out_mountproto_mismatch:
1494         return nfs_invalf(fc, "NFS: Mount ser    1484         return nfs_invalf(fc, "NFS: Mount server address does not match mountproto= option");
1495 out_proto_mismatch:                              1485 out_proto_mismatch:
1496         return nfs_invalf(fc, "NFS: Server ad    1486         return nfs_invalf(fc, "NFS: Server address does not match proto= option");
1497 out_minorversion_mismatch:                       1487 out_minorversion_mismatch:
1498         return nfs_invalf(fc, "NFS: Mount opt    1488         return nfs_invalf(fc, "NFS: Mount option vers=%u does not support minorversion=%u",
1499                           ctx->version, ctx->    1489                           ctx->version, ctx->minorversion);
1500 out_migration_misuse:                            1490 out_migration_misuse:
1501         return nfs_invalf(fc, "NFS: 'Migratio    1491         return nfs_invalf(fc, "NFS: 'Migration' not supported for this NFS version");
1502 out_version_unavailable:                         1492 out_version_unavailable:
1503         nfs_errorf(fc, "NFS: Version unavaila    1493         nfs_errorf(fc, "NFS: Version unavailable");
1504         return ret;                              1494         return ret;
1505 }                                                1495 }
1506                                                  1496 
1507 /*                                               1497 /*
1508  * Create an NFS superblock by the appropriat    1498  * Create an NFS superblock by the appropriate method.
1509  */                                              1499  */
1510 static int nfs_get_tree(struct fs_context *fc    1500 static int nfs_get_tree(struct fs_context *fc)
1511 {                                                1501 {
1512         struct nfs_fs_context *ctx = nfs_fc2c    1502         struct nfs_fs_context *ctx = nfs_fc2context(fc);
1513         int err = nfs_fs_context_validate(fc)    1503         int err = nfs_fs_context_validate(fc);
1514                                                  1504 
1515         if (err)                                 1505         if (err)
1516                 return err;                      1506                 return err;
1517         if (!ctx->internal)                      1507         if (!ctx->internal)
1518                 return ctx->nfs_mod->rpc_ops-    1508                 return ctx->nfs_mod->rpc_ops->try_get_tree(fc);
1519         else                                     1509         else
1520                 return nfs_get_tree_common(fc    1510                 return nfs_get_tree_common(fc);
1521 }                                                1511 }
1522                                                  1512 
1523 /*                                               1513 /*
1524  * Handle duplication of a configuration.  Th    1514  * Handle duplication of a configuration.  The caller copied *src into *sc, but
1525  * it can't deal with resource pointers in th    1515  * it can't deal with resource pointers in the filesystem context, so we have
1526  * to do that.  We need to clear pointers, co    1516  * to do that.  We need to clear pointers, copy data or get extra refs as
1527  * appropriate.                                  1517  * appropriate.
1528  */                                              1518  */
1529 static int nfs_fs_context_dup(struct fs_conte    1519 static int nfs_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc)
1530 {                                                1520 {
1531         struct nfs_fs_context *src = nfs_fc2c    1521         struct nfs_fs_context *src = nfs_fc2context(src_fc), *ctx;
1532                                                  1522 
1533         ctx = kmemdup(src, sizeof(struct nfs_    1523         ctx = kmemdup(src, sizeof(struct nfs_fs_context), GFP_KERNEL);
1534         if (!ctx)                                1524         if (!ctx)
1535                 return -ENOMEM;                  1525                 return -ENOMEM;
1536                                                  1526 
1537         ctx->mntfh = nfs_alloc_fhandle();        1527         ctx->mntfh = nfs_alloc_fhandle();
1538         if (!ctx->mntfh) {                       1528         if (!ctx->mntfh) {
1539                 kfree(ctx);                      1529                 kfree(ctx);
1540                 return -ENOMEM;                  1530                 return -ENOMEM;
1541         }                                        1531         }
1542         nfs_copy_fh(ctx->mntfh, src->mntfh);     1532         nfs_copy_fh(ctx->mntfh, src->mntfh);
1543                                                  1533 
1544         __module_get(ctx->nfs_mod->owner);       1534         __module_get(ctx->nfs_mod->owner);
1545         ctx->client_address             = NUL    1535         ctx->client_address             = NULL;
1546         ctx->mount_server.hostname      = NUL    1536         ctx->mount_server.hostname      = NULL;
1547         ctx->nfs_server.export_path     = NUL    1537         ctx->nfs_server.export_path     = NULL;
1548         ctx->nfs_server.hostname        = NUL    1538         ctx->nfs_server.hostname        = NULL;
1549         ctx->fscache_uniq               = NUL    1539         ctx->fscache_uniq               = NULL;
1550         ctx->clone_data.fattr           = NUL    1540         ctx->clone_data.fattr           = NULL;
1551         fc->fs_private = ctx;                    1541         fc->fs_private = ctx;
1552         return 0;                                1542         return 0;
1553 }                                                1543 }
1554                                                  1544 
1555 static void nfs_fs_context_free(struct fs_con    1545 static void nfs_fs_context_free(struct fs_context *fc)
1556 {                                                1546 {
1557         struct nfs_fs_context *ctx = nfs_fc2c    1547         struct nfs_fs_context *ctx = nfs_fc2context(fc);
1558                                                  1548 
1559         if (ctx) {                               1549         if (ctx) {
1560                 if (ctx->server)                 1550                 if (ctx->server)
1561                         nfs_free_server(ctx->    1551                         nfs_free_server(ctx->server);
1562                 if (ctx->nfs_mod)                1552                 if (ctx->nfs_mod)
1563                         put_nfs_version(ctx->    1553                         put_nfs_version(ctx->nfs_mod);
1564                 kfree(ctx->client_address);      1554                 kfree(ctx->client_address);
1565                 kfree(ctx->mount_server.hostn    1555                 kfree(ctx->mount_server.hostname);
1566                 kfree(ctx->nfs_server.export_    1556                 kfree(ctx->nfs_server.export_path);
1567                 kfree(ctx->nfs_server.hostnam    1557                 kfree(ctx->nfs_server.hostname);
1568                 kfree(ctx->fscache_uniq);        1558                 kfree(ctx->fscache_uniq);
1569                 nfs_free_fhandle(ctx->mntfh);    1559                 nfs_free_fhandle(ctx->mntfh);
1570                 nfs_free_fattr(ctx->clone_dat    1560                 nfs_free_fattr(ctx->clone_data.fattr);
1571                 kfree(ctx);                      1561                 kfree(ctx);
1572         }                                        1562         }
1573 }                                                1563 }
1574                                                  1564 
1575 static const struct fs_context_operations nfs    1565 static const struct fs_context_operations nfs_fs_context_ops = {
1576         .free                   = nfs_fs_cont    1566         .free                   = nfs_fs_context_free,
1577         .dup                    = nfs_fs_cont    1567         .dup                    = nfs_fs_context_dup,
1578         .parse_param            = nfs_fs_cont    1568         .parse_param            = nfs_fs_context_parse_param,
1579         .parse_monolithic       = nfs_fs_cont    1569         .parse_monolithic       = nfs_fs_context_parse_monolithic,
1580         .get_tree               = nfs_get_tre    1570         .get_tree               = nfs_get_tree,
1581         .reconfigure            = nfs_reconfi    1571         .reconfigure            = nfs_reconfigure,
1582 };                                               1572 };
1583                                                  1573 
1584 /*                                               1574 /*
1585  * Prepare superblock configuration.  We use     1575  * Prepare superblock configuration.  We use the namespaces attached to the
1586  * context.  This may be the current process'    1576  * context.  This may be the current process's namespaces, or it may be a
1587  * container's namespaces.                       1577  * container's namespaces.
1588  */                                              1578  */
1589 static int nfs_init_fs_context(struct fs_cont    1579 static int nfs_init_fs_context(struct fs_context *fc)
1590 {                                                1580 {
1591         struct nfs_fs_context *ctx;              1581         struct nfs_fs_context *ctx;
1592                                                  1582 
1593         ctx = kzalloc(sizeof(struct nfs_fs_co    1583         ctx = kzalloc(sizeof(struct nfs_fs_context), GFP_KERNEL);
1594         if (unlikely(!ctx))                      1584         if (unlikely(!ctx))
1595                 return -ENOMEM;                  1585                 return -ENOMEM;
1596                                                  1586 
1597         ctx->mntfh = nfs_alloc_fhandle();        1587         ctx->mntfh = nfs_alloc_fhandle();
1598         if (unlikely(!ctx->mntfh)) {             1588         if (unlikely(!ctx->mntfh)) {
1599                 kfree(ctx);                      1589                 kfree(ctx);
1600                 return -ENOMEM;                  1590                 return -ENOMEM;
1601         }                                        1591         }
1602                                                  1592 
1603         ctx->protofamily        = AF_UNSPEC;     1593         ctx->protofamily        = AF_UNSPEC;
1604         ctx->mountfamily        = AF_UNSPEC;     1594         ctx->mountfamily        = AF_UNSPEC;
1605         ctx->mount_server.port  = NFS_UNSPEC_    1595         ctx->mount_server.port  = NFS_UNSPEC_PORT;
1606                                                  1596 
1607         if (fc->root) {                          1597         if (fc->root) {
1608                 /* reconfigure, start with th    1598                 /* reconfigure, start with the current config */
1609                 struct nfs_server *nfss = fc-    1599                 struct nfs_server *nfss = fc->root->d_sb->s_fs_info;
1610                 struct net *net = nfss->nfs_c    1600                 struct net *net = nfss->nfs_client->cl_net;
1611                                                  1601 
1612                 ctx->flags              = nfs    1602                 ctx->flags              = nfss->flags;
1613                 ctx->rsize              = nfs    1603                 ctx->rsize              = nfss->rsize;
1614                 ctx->wsize              = nfs    1604                 ctx->wsize              = nfss->wsize;
1615                 ctx->retrans            = nfs    1605                 ctx->retrans            = nfss->client->cl_timeout->to_retries;
1616                 ctx->selected_flavor    = nfs    1606                 ctx->selected_flavor    = nfss->client->cl_auth->au_flavor;
1617                 ctx->acregmin           = nfs    1607                 ctx->acregmin           = nfss->acregmin / HZ;
1618                 ctx->acregmax           = nfs    1608                 ctx->acregmax           = nfss->acregmax / HZ;
1619                 ctx->acdirmin           = nfs    1609                 ctx->acdirmin           = nfss->acdirmin / HZ;
1620                 ctx->acdirmax           = nfs    1610                 ctx->acdirmax           = nfss->acdirmax / HZ;
1621                 ctx->timeo              = 10U    1611                 ctx->timeo              = 10U * nfss->client->cl_timeout->to_initval / HZ;
1622                 ctx->nfs_server.port    = nfs    1612                 ctx->nfs_server.port    = nfss->port;
1623                 ctx->nfs_server.addrlen = nfs    1613                 ctx->nfs_server.addrlen = nfss->nfs_client->cl_addrlen;
1624                 ctx->version            = nfs    1614                 ctx->version            = nfss->nfs_client->rpc_ops->version;
1625                 ctx->minorversion       = nfs    1615                 ctx->minorversion       = nfss->nfs_client->cl_minorversion;
1626                                                  1616 
1627                 memcpy(&ctx->nfs_server._addr    1617                 memcpy(&ctx->nfs_server._address, &nfss->nfs_client->cl_addr,
1628                         ctx->nfs_server.addrl    1618                         ctx->nfs_server.addrlen);
1629                                                  1619 
1630                 if (fc->net_ns != net) {         1620                 if (fc->net_ns != net) {
1631                         put_net(fc->net_ns);     1621                         put_net(fc->net_ns);
1632                         fc->net_ns = get_net(    1622                         fc->net_ns = get_net(net);
1633                 }                                1623                 }
1634                                                  1624 
1635                 ctx->nfs_mod = nfss->nfs_clie    1625                 ctx->nfs_mod = nfss->nfs_client->cl_nfs_mod;
1636                 __module_get(ctx->nfs_mod->ow    1626                 __module_get(ctx->nfs_mod->owner);
1637         } else {                                 1627         } else {
1638                 /* defaults */                   1628                 /* defaults */
1639                 ctx->timeo              = NFS    1629                 ctx->timeo              = NFS_UNSPEC_TIMEO;
1640                 ctx->retrans            = NFS    1630                 ctx->retrans            = NFS_UNSPEC_RETRANS;
1641                 ctx->acregmin           = NFS    1631                 ctx->acregmin           = NFS_DEF_ACREGMIN;
1642                 ctx->acregmax           = NFS    1632                 ctx->acregmax           = NFS_DEF_ACREGMAX;
1643                 ctx->acdirmin           = NFS    1633                 ctx->acdirmin           = NFS_DEF_ACDIRMIN;
1644                 ctx->acdirmax           = NFS    1634                 ctx->acdirmax           = NFS_DEF_ACDIRMAX;
1645                 ctx->nfs_server.port    = NFS    1635                 ctx->nfs_server.port    = NFS_UNSPEC_PORT;
1646                 ctx->nfs_server.protocol = XP    1636                 ctx->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1647                 ctx->selected_flavor    = RPC    1637                 ctx->selected_flavor    = RPC_AUTH_MAXFLAVOR;
1648                 ctx->minorversion       = 0;     1638                 ctx->minorversion       = 0;
1649                 ctx->need_mount         = tru    1639                 ctx->need_mount         = true;
1650                 ctx->xprtsec.policy     = RPC    1640                 ctx->xprtsec.policy     = RPC_XPRTSEC_NONE;
1651                 ctx->xprtsec.cert_serial         1641                 ctx->xprtsec.cert_serial        = TLS_NO_CERT;
1652                 ctx->xprtsec.privkey_serial      1642                 ctx->xprtsec.privkey_serial     = TLS_NO_PRIVKEY;
1653                                                  1643 
1654                 fc->s_iflags            |= SB    1644                 fc->s_iflags            |= SB_I_STABLE_WRITES;
1655         }                                        1645         }
1656         fc->fs_private = ctx;                    1646         fc->fs_private = ctx;
1657         fc->ops = &nfs_fs_context_ops;           1647         fc->ops = &nfs_fs_context_ops;
1658         return 0;                                1648         return 0;
1659 }                                                1649 }
1660                                                  1650 
1661 struct file_system_type nfs_fs_type = {          1651 struct file_system_type nfs_fs_type = {
1662         .owner                  = THIS_MODULE    1652         .owner                  = THIS_MODULE,
1663         .name                   = "nfs",         1653         .name                   = "nfs",
1664         .init_fs_context        = nfs_init_fs    1654         .init_fs_context        = nfs_init_fs_context,
1665         .parameters             = nfs_fs_para    1655         .parameters             = nfs_fs_parameters,
1666         .kill_sb                = nfs_kill_su    1656         .kill_sb                = nfs_kill_super,
1667         .fs_flags               = FS_RENAME_D    1657         .fs_flags               = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
1668 };                                               1658 };
1669 MODULE_ALIAS_FS("nfs");                          1659 MODULE_ALIAS_FS("nfs");
1670 EXPORT_SYMBOL_GPL(nfs_fs_type);                  1660 EXPORT_SYMBOL_GPL(nfs_fs_type);
1671                                                  1661 
1672 #if IS_ENABLED(CONFIG_NFS_V4)                    1662 #if IS_ENABLED(CONFIG_NFS_V4)
1673 struct file_system_type nfs4_fs_type = {         1663 struct file_system_type nfs4_fs_type = {
1674         .owner                  = THIS_MODULE    1664         .owner                  = THIS_MODULE,
1675         .name                   = "nfs4",        1665         .name                   = "nfs4",
1676         .init_fs_context        = nfs_init_fs    1666         .init_fs_context        = nfs_init_fs_context,
1677         .parameters             = nfs_fs_para    1667         .parameters             = nfs_fs_parameters,
1678         .kill_sb                = nfs_kill_su    1668         .kill_sb                = nfs_kill_super,
1679         .fs_flags               = FS_RENAME_D    1669         .fs_flags               = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
1680 };                                               1670 };
1681 MODULE_ALIAS_FS("nfs4");                         1671 MODULE_ALIAS_FS("nfs4");
1682 MODULE_ALIAS("nfs4");                            1672 MODULE_ALIAS("nfs4");
1683 EXPORT_SYMBOL_GPL(nfs4_fs_type);                 1673 EXPORT_SYMBOL_GPL(nfs4_fs_type);
1684 #endif /* CONFIG_NFS_V4 */                       1674 #endif /* CONFIG_NFS_V4 */
1685                                                  1675 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php