Skip to content

Commit 4edaa30

Browse files
chuckleverTrond Myklebust
authored andcommitted
NFS: Use "krb5i" to establish NFSv4 state whenever possible
Currently our client uses AUTH_UNIX for state management on Kerberos NFS mounts in some cases. For example, if the first mount of a server specifies "sec=sys," the SETCLIENTID operation is performed with AUTH_UNIX. Subsequent mounts using stronger security flavors can not change the flavor used for lease establishment. This might be less security than an administrator was expecting. Dave Noveck's migration issues draft recommends the use of an integrity-protecting security flavor for the SETCLIENTID operation. Let's ignore the mount's sec= setting and use krb5i as the default security flavor for SETCLIENTID. If our client can't establish a GSS context (eg. because it doesn't have a keytab or the server doesn't support Kerberos) we fall back to using AUTH_NULL. For an operation that requires a machine credential (which never represents a particular user) AUTH_NULL is as secure as AUTH_UNIX. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent c4eafe1 commit 4edaa30

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

fs/nfs/nfs4client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp,
199199
clp->rpc_ops = &nfs_v4_clientops;
200200

201201
__set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
202-
error = nfs_create_rpc_client(clp, timeparms, authflavour);
202+
error = nfs_create_rpc_client(clp, timeparms, RPC_AUTH_GSS_KRB5I);
203203
if (error < 0)
204204
goto error;
205205

fs/nfs/nfs4state.c

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,26 +1866,13 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
18661866
{
18671867
const struct nfs4_state_recovery_ops *ops =
18681868
clp->cl_mvops->reboot_recovery_ops;
1869-
rpc_authflavor_t *flavors, flav, save;
18701869
struct rpc_clnt *clnt;
18711870
struct rpc_cred *cred;
1872-
int i, len, status;
1871+
int i, status;
18731872

18741873
dprintk("NFS: %s: testing '%s'\n", __func__, clp->cl_hostname);
18751874

1876-
len = NFS_MAX_SECFLAVORS;
1877-
flavors = kcalloc(len, sizeof(*flavors), GFP_KERNEL);
1878-
if (flavors == NULL) {
1879-
status = -ENOMEM;
1880-
goto out;
1881-
}
1882-
len = rpcauth_list_flavors(flavors, len);
1883-
if (len < 0) {
1884-
status = len;
1885-
goto out_free;
1886-
}
18871875
clnt = clp->cl_rpcclient;
1888-
save = clnt->cl_auth->au_flavor;
18891876
i = 0;
18901877

18911878
mutex_lock(&nfs_clid_init_mutex);
@@ -1900,12 +1887,6 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
19001887
switch (status) {
19011888
case 0:
19021889
break;
1903-
1904-
case -EACCES:
1905-
if (clp->cl_machine_cred == NULL)
1906-
break;
1907-
/* Handle case where the user hasn't set up machine creds */
1908-
nfs4_clear_machine_cred(clp);
19091890
case -NFS4ERR_DELAY:
19101891
case -ETIMEDOUT:
19111892
case -EAGAIN:
@@ -1914,17 +1895,12 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
19141895
dprintk("NFS: %s after status %d, retrying\n",
19151896
__func__, status);
19161897
goto again;
1917-
1898+
case -EACCES:
1899+
if (i++)
1900+
break;
19181901
case -NFS4ERR_CLID_INUSE:
19191902
case -NFS4ERR_WRONGSEC:
1920-
status = -EPERM;
1921-
if (i >= len)
1922-
break;
1923-
1924-
flav = flavors[i++];
1925-
if (flav == save)
1926-
flav = flavors[i++];
1927-
clnt = rpc_clone_client_set_auth(clnt, flav);
1903+
clnt = rpc_clone_client_set_auth(clnt, RPC_AUTH_NULL);
19281904
if (IS_ERR(clnt)) {
19291905
status = PTR_ERR(clnt);
19301906
break;
@@ -1944,9 +1920,6 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
19441920

19451921
out_unlock:
19461922
mutex_unlock(&nfs_clid_init_mutex);
1947-
out_free:
1948-
kfree(flavors);
1949-
out:
19501923
dprintk("NFS: %s: status = %d\n", __func__, status);
19511924
return status;
19521925
}

0 commit comments

Comments
 (0)