From: Chuck Lever <chuck.lever@oracle.com>
To: trond.myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org, Chuck Lever <chuck.lever@oracle.com>
Subject: [PATCH v1 15/15] NFS: Use "krb5i" to establish NFSv4 state whenever possible
Date: Sat, 16 Mar 2013 15:56:20 -0400 [thread overview]
Message-ID: <20130316195620.27329.83818.stgit@seurat.1015granger.net> (raw)
In-Reply-To: <20130316195044.27329.11666.stgit@seurat.1015granger.net>
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>
---
fs/nfs/nfs4client.c | 2 +-
fs/nfs/nfs4state.c | 37 +++++--------------------------------
2 files changed, 6 insertions(+), 33 deletions(-)
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index ac4fc9a..0194cab 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -199,7 +199,7 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp,
clp->rpc_ops = &nfs_v4_clientops;
__set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
- error = nfs_create_rpc_client(clp, timeparms, authflavour);
+ error = nfs_create_rpc_client(clp, timeparms, RPC_AUTH_GSS_KRB5I);
if (error < 0)
goto error;
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 6ace365..3e30e85 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1823,26 +1823,13 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
{
const struct nfs4_state_recovery_ops *ops =
clp->cl_mvops->reboot_recovery_ops;
- rpc_authflavor_t *flavors, flav, save;
struct rpc_clnt *clnt;
struct rpc_cred *cred;
- int i, len, status;
+ int i, status;
dprintk("NFS: %s: testing '%s'\n", __func__, clp->cl_hostname);
- len = NFS_MAX_SECFLAVORS;
- flavors = kcalloc(len, sizeof(*flavors), GFP_KERNEL);
- if (flavors == NULL) {
- status = -ENOMEM;
- goto out;
- }
- len = rpcauth_list_flavors(flavors, len);
- if (len < 0) {
- status = len;
- goto out_free;
- }
clnt = clp->cl_rpcclient;
- save = clnt->cl_auth->au_flavor;
i = 0;
mutex_lock(&nfs_clid_init_mutex);
@@ -1857,12 +1844,6 @@ again:
switch (status) {
case 0:
break;
-
- case -EACCES:
- if (clp->cl_machine_cred == NULL)
- break;
- /* Handle case where the user hasn't set up machine creds */
- nfs4_clear_machine_cred(clp);
case -NFS4ERR_DELAY:
case -ETIMEDOUT:
case -EAGAIN:
@@ -1871,17 +1852,12 @@ again:
dprintk("NFS: %s after status %d, retrying\n",
__func__, status);
goto again;
-
+ case -EACCES:
+ if (i++)
+ break;
case -NFS4ERR_CLID_INUSE:
case -NFS4ERR_WRONGSEC:
- status = -EPERM;
- if (i >= len)
- break;
-
- flav = flavors[i++];
- if (flav == save)
- flav = flavors[i++];
- clnt = rpc_clone_client_set_auth(clnt, flav);
+ clnt = rpc_clone_client_set_auth(clnt, RPC_AUTH_NULL);
if (IS_ERR(clnt)) {
status = PTR_ERR(clnt);
break;
@@ -1901,9 +1877,6 @@ again:
out_unlock:
mutex_unlock(&nfs_clid_init_mutex);
-out_free:
- kfree(flavors);
-out:
dprintk("NFS: %s: status = %d\n", __func__, status);
return status;
}
prev parent reply other threads:[~2013-03-16 19:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-16 19:54 [PATCH v1 00/15] Security flavor negotiation fixes Chuck Lever
2013-03-16 19:54 ` [PATCH v1 01/15] SUNRPC: Missing module alias for auth_rpcgss.ko Chuck Lever
2013-03-16 19:54 ` [PATCH v1 02/15] NFS: Remove unneeded forward declaration Chuck Lever
2013-03-16 19:54 ` [PATCH v1 03/15] SUNRPC: Define rpcsec_gss_info structure Chuck Lever
2013-03-16 19:54 ` [PATCH v1 04/15] SUNRPC: Introduce rpcauth_get_pseudoflavor() Chuck Lever
2013-03-16 19:54 ` [PATCH v1 05/15] SUNRPC: Load GSS kernel module by OID Chuck Lever
2013-03-16 19:55 ` [PATCH v1 06/15] SUNRPC: Consider qop when looking up pseudoflavors Chuck Lever
2013-03-16 19:55 ` [PATCH v1 08/15] SUNRPC: Make gss_mech_get() static Chuck Lever
2013-03-16 19:55 ` [PATCH v1 09/15] SUNRPC: Remove EXPORT_SYMBOL_GPL() from GSS mech switch Chuck Lever
2013-03-16 19:55 ` [PATCH v1 10/15] NFS: Handle missing rpc.gssd when looking up root FH Chuck Lever
2013-03-16 19:55 ` [PATCH v1 11/15] NFS: Clean up nfs4_proc_get_rootfh Chuck Lever
2013-03-16 19:55 ` [PATCH v1 12/15] NFS: Avoid PUTROOTFH when managing leases Chuck Lever
2013-03-16 19:56 ` [PATCH v1 13/15] NFS: Use static list of security flavors during root FH lookup recovery Chuck Lever
2013-03-16 19:56 ` [PATCH v1 14/15] NFS: Try AUTH_UNIX when PUTROOTFH gets NFS4ERR_WRONGSEC Chuck Lever
2013-03-16 19:56 ` Chuck Lever [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130316195620.27329.83818.stgit@seurat.1015granger.net \
--to=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@netapp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).