Deal with lost delegations and EKEYEXPIRED
Subsystems (2)
cover Deal with lost delegations and EKEYEXPIRED
I've finally discovered that the majority of our lost delegation problems come from EKEYEXPIRED. This seems to work fine in our environment, but I am unsure of the ramifications of this in a broader context, so it's time to get other folks to look at it.
Andrew Elble (4):
nfs/nfsd: Move useful bitfield ops to a commonly accessible place
nfs: machine credential support for additional operations
nfsd: allow mach_creds_match to be used more broadly
nfsd: implement machine credential support for some operations
fs/nfs/nfs4proc.c | 20 +++++++++++++++++ fs/nfsd/export.c | 4 ++++ fs/nfsd/nfs4proc.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/nfs4state.c | 35 ++++++++++++++++++++++++------ fs/nfsd/nfs4xdr.c | 51 ++++++++++++++++++++----------------------- fs/nfsd/nfsd.h | 1 + fs/nfsd/state.h | 1 + fs/nfsd/xdr4.h | 5 +++++ include/linux/nfs4.h | 11 ++++++++++ include/linux/nfs_fs_sb.h | 1 + include/linux/nfs_xdr.h | 11 ---------- 11 files changed, 149 insertions(+), 46 deletions(-)
Signature · 1 line
2.6.3
RFC PATCH 1/4 nfs/nfsd: Move useful bitfield ops to a commonly accessible place
So these may be used in nfsd as well
--- include/linux/nfs4.h | 11 +++++++++++ include/linux/nfs_xdr.h | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-)
include/linux/nfs4.h +11 -0
@@ -592,4 +592,15 @@ enum data_content4 { NFS4_CONTENT_HOLE = 1, }; +#define NFS4_OP_MAP_NUM_LONGS \ + DIV_ROUND_UP(LAST_NFS4_OP, 8 * sizeof(unsigned long)) +#define NFS4_OP_MAP_NUM_WORDS \ + (NFS4_OP_MAP_NUM_LONGS * sizeof(unsigned long) / sizeof(u32)) +struct nfs4_op_map { +union { +unsigned long longs[NFS4_OP_MAP_NUM_LONGS ]; +u32 words[NFS4_OP_MAP_NUM_WORDS ]; + } u; +}; +#endif
include/linux/nfs_xdr.h +0 -11
@@ -1185,17 +1185,6 @@ struct pnfs_ds_commit_info {struct pnfs_commit_bucket *buckets; }; -#define NFS4_OP_MAP_NUM_LONGS \ - DIV_ROUND_UP(LAST_NFS4_OP, 8 * sizeof(unsigned long)) -#define NFS4_OP_MAP_NUM_WORDS \ - (NFS4_OP_MAP_NUM_LONGS * sizeof(unsigned long) / sizeof(u32)) -struct nfs4_op_map { -union { -unsigned long longs[NFS4_OP_MAP_NUM_LONGS ]; -u32 words[NFS4_OP_MAP_NUM_WORDS ]; - } u; -}; -struct nfs41_state_protection {u32 how;struct nfs4_op_map enforce;
Signature · 1 line
2.6.3
RFC PATCH 2/4 nfs: machine credential support for additional operations
In reply to Andrew ElbleAllow LAYOUTRETURN and DELEGRETURN to use machine credentials if the server supports it. Add request for OPEN_DOWNGRADE as the close path also uses that.
--- fs/nfs/nfs4proc.c | 20 ++++++++++++++++++++ include/linux/nfs_fs_sb.h | 1 + 2 files changed, 21 insertions(+)
fs/nfs/nfs4proc.c +20 -0
@@ -5384,6 +5384,11 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, coif (data ==NULL )return -ENOMEM ;nfs4_init_sequence (&data->args.seq_args, &data->res.seq_res,1 ); + +nfs4_state_protect (server->nfs_client, +NFS_SP4_MACH_CRED_CLEANUP , + &task_setup_data.rpc_client, &msg); + data->args.fhandle = &data->fh; data->args.stateid = &data->stateid; data->args.bitmask = server->cache_consistency_bitmask;
@@ -6862,10 +6867,13 @@ static const struct nfs41_state_protection nfs4_sp4_mach_cred_request = { }, .allow.u.words = { [0 ] =1 << (OP_CLOSE ) | +1 << (OP_OPEN_DOWNGRADE ) |1 << (OP_LOCKU ) | +1 << (OP_DELEGRETURN ) | 1 << (OP_COMMIT), [1 ] =1 << (OP_SECINFO -32 ) |1 << (OP_SECINFO_NO_NAME -32 ) | +1 << (OP_LAYOUTRETURN -32 ) |1 << (OP_TEST_STATEID -32 ) |1 << (OP_FREE_STATEID -32 ) |1 << (OP_WRITE -32 )
@@ -6930,11 +6938,19 @@ static int nfs4_sp4_select_mode(struct nfs_client *clp, }if (test_bit (OP_CLOSE , sp->allow.u.longs) && +test_bit (OP_OPEN_DOWNGRADE , sp->allow.u.longs) && +test_bit (OP_DELEGRETURN , sp->allow.u.longs) &&test_bit (OP_LOCKU , sp->allow.u.longs)) {dfprintk (MOUNT ," cleanup mode enabled\n" );set_bit (NFS_SP4_MACH_CRED_CLEANUP , &clp->cl_sp4_flags); } +if (test_bit (OP_LAYOUTRETURN , sp->allow.u.longs)) { +dfprintk (MOUNT ," pnfs cleanup mode enabled\n" ); +set_bit (NFS_SP4_MACH_CRED_PNFS_CLEANUP , + &clp->cl_sp4_flags); + } +if (test_bit (OP_SECINFO , sp->allow.u.longs) &&test_bit (OP_SECINFO_NO_NAME , sp->allow.u.longs)) {dfprintk (MOUNT ," secinfo mode enabled\n" );
@@ -8086,6 +8102,10 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync) };int status =0 ; +nfs4_state_protect (NFS_SERVER (lrp->args.inode)->nfs_client, +NFS_SP4_MACH_CRED_PNFS_CLEANUP , + &task_setup_data.rpc_client, &msg); +dprintk ("--> %s\n" , __func__);if (!sync) { lrp->inode =nfs_igrab_and_active (lrp->args.inode);
include/linux/nfs_fs_sb.h +1 -0
@@ -102,6 +102,7 @@ struct nfs_client {#define NFS_SP4_MACH_CRED_STATEID 4/* TEST_STATEID and FREE_STATEID */ #define NFS_SP4_MACH_CRED_WRITE 5/* WRITE */ #define NFS_SP4_MACH_CRED_COMMIT 6/* COMMIT */ +#define NFS_SP4_MACH_CRED_PNFS_CLEANUP 7/* LAYOUTRETURN */ #endif /* CONFIG_NFS_V4 */ /* Our own IP address, as a null-terminated string.
Signature · 1 line
2.6.3
Re: [PATCH RFC 2/4] nfs: machine credential support for additional operations
Quoted 76 lines · Andrew Elble
Allow LAYOUTRETURN and DELEGRETURN to use machine credentials if the server supports it. Add request for
OPEN_DOWNGRADEas the close path also uses that.Signed-off-by Andrew Elble <[email protected]>--- fs/nfs/nfs4proc.c | 20 ++++++++++++++++++++ include/linux/nfs_fs_sb.h | 1 + 2 files changed, 21 insertions(+)fs/nfs/nfs4proc.c +20
-0@@ -5384,6 +5384,11 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, coif (data ==NULL )return -ENOMEM ;nfs4_init_sequence (&data->args.seq_args, &data->res.seq_res,1 ); + +nfs4_state_protect (server->nfs_client, +NFS_SP4_MACH_CRED_CLEANUP , + &task_setup_data.rpc_client, &msg); + data->args.fhandle = &data->fh; data->args.stateid = &data->stateid; data->args.bitmask = server->cache_consistency_bitmask;@@ -6862,10 +6867,13 @@ static const struct nfs41_state_protection nfs4_sp4_mach_cred_request = { }, .allow.u.words = { [0 ] =1 << (OP_CLOSE ) | +1 << (OP_OPEN_DOWNGRADE ) |1 << (OP_LOCKU ) | +1 << (OP_DELEGRETURN ) | 1 << (OP_COMMIT), [1 ] =1 << (OP_SECINFO -32 ) |1 << (OP_SECINFO_NO_NAME -32 ) | +1 << (OP_LAYOUTRETURN -32 ) |1 << (OP_TEST_STATEID -32 ) |1 << (OP_FREE_STATEID -32 ) |1 << (OP_WRITE -32 )@@ -6930,11 +6938,19 @@ static int nfs4_sp4_select_mode(struct nfs_client *clp, }if (test_bit (OP_CLOSE , sp->allow.u.longs) && +test_bit (OP_OPEN_DOWNGRADE , sp->allow.u.longs) && +test_bit (OP_DELEGRETURN , sp->allow.u.longs) &&test_bit (OP_LOCKU , sp->allow.u.longs)) {dfprintk (MOUNT ," cleanup mode enabled\n" );set_bit (NFS_SP4_MACH_CRED_CLEANUP , &clp->cl_sp4_flags); } +if (test_bit (OP_LAYOUTRETURN , sp->allow.u.longs)) { +dfprintk (MOUNT ," pnfs cleanup mode enabled\n" ); +set_bit (NFS_SP4_MACH_CRED_PNFS_CLEANUP , + &clp->cl_sp4_flags); + } +if (test_bit (OP_SECINFO , sp->allow.u.longs) &&test_bit (OP_SECINFO_NO_NAME , sp->allow.u.longs)) {dfprintk (MOUNT ," secinfo mode enabled\n" );@@ -8086,6 +8102,10 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync) };int status =0 ; +nfs4_state_protect (NFS_SERVER (lrp->args.inode)->nfs_client, +NFS_SP4_MACH_CRED_PNFS_CLEANUP , + &task_setup_data.rpc_client, &msg); +dprintk ("--> %s\n" , __func__);if (!sync) { lrp->inode =nfs_igrab_and_active (lrp->args.inode);include/linux/nfs_fs_sb.h +0
-0
include/linux/nfs_fs_sb.h struct nfs_client { · line 108
Quoted 7 lines
include/linux/nfs_fs_sb.h +1
-0@@ -102,6 +102,7 @@ struct nfs_client {#define NFS_SP4_MACH_CRED_STATEID 4/* TEST_STATEID and FREE_STATEID */ #define NFS_SP4_MACH_CRED_WRITE 5/* WRITE */ #define NFS_SP4_MACH_CRED_COMMIT 6/* COMMIT */ +#define NFS_SP4_MACH_CRED_PNFS_CLEANUP 7/* LAYOUTRETURN */ #endif /* CONFIG_NFS_V4 */ /* Our own IP address, as a null-terminated string.
This patch looks fine, but can we please break it out of the series? There doesn't appear to be any dependency between this and the other patches, so it would be easier if I could just take it directly.
Re: [PATCH RFC 2/4] nfs: machine credential support for additional operations
Quoted 8 lines · Trond Myklebust
Quoted 3 lines · Andrew Elble
Allow LAYOUTRETURN and DELEGRETURN to use machine credentials if the server supports it. Add request for
OPEN_DOWNGRADEas the close path also uses that.This patch looks fine, but can we please break it out of the series? There doesn't appear to be any dependency between this and the other patches, so it would be easier if I could just take it directly.
I'm fine with that - I have to (at least) do v2 on the rest, do you want me to repost it separately?
Thanks,
Andy
Signature · 5 lines
Andrew W. Elble [email protected] Infrastructure Engineer, Communications Technical Lead Rochester Institute of Technology PGP: BFAD 8461 4CCF DC95 DA2C B0EB 965B 082E 863E C912
RFC PATCH 3/4 nfsd: allow mach_creds_match to be used more broadly
In reply to Andrew ElbleRename mach_creds_match() to nfsd4_mach_creds_match() and un-staticify
--- fs/nfsd/nfs4state.c | 14 +++++++------- fs/nfsd/xdr4.h | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-)
fs/nfsd/nfs4state.c +7 -7
@@ -1959,7 +1959,7 @@ static bool svc_rqst_integrity_protected(struct svc_rqst *rqstp) service ==RPC_GSS_SVC_PRIVACY ; } -static bool mach_creds_match (struct nfs4_client *cl,struct svc_rqst *rqstp) +bool nfsd4_mach_creds_match (struct nfs4_client *cl,struct svc_rqst *rqstp) {struct svc_cred *cr = &rqstp->rq_cred;
@@ -2393,7 +2393,7 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, status = nfserr_inval; goto out; } -if (!mach_creds_match (conf, rqstp)) { +if (!nfsd4_mach_creds_match (conf, rqstp)) { status = nfserr_wrong_cred; goto out; }
@@ -2640,7 +2640,7 @@ nfsd4_create_session(struct svc_rqst *rqstp,if (conf) { status = nfserr_wrong_cred; -if (!mach_creds_match (conf, rqstp)) +if (!nfsd4_mach_creds_match (conf, rqstp)) goto out_free_conn; cs_slot = &conf->cl_cs_slot; status =check_slot_seqid (cr_ses->seqid, cs_slot->sl_seqid,0 );
@@ -2656,7 +2656,7 @@ nfsd4_create_session(struct svc_rqst *rqstp, goto out_free_conn; } status = nfserr_wrong_cred; -if (!mach_creds_match (unconf, rqstp)) +if (!nfsd4_mach_creds_match (unconf, rqstp)) goto out_free_conn; cs_slot = &unconf->cl_cs_slot; status =check_slot_seqid (cr_ses->seqid, cs_slot->sl_seqid,0 );
@@ -2766,7 +2766,7 @@ __be32 nfsd4_bind_conn_to_session(struct svc_rqst *rqstp,if (!session) goto out_no_session; status = nfserr_wrong_cred; -if (!mach_creds_match (session->se_client, rqstp)) +if (!nfsd4_mach_creds_match (session->se_client, rqstp)) goto out; status =nfsd4_map_bcts_dir (&bcts->dir);if (status)
@@ -2813,7 +2813,7 @@ nfsd4_destroy_session(struct svc_rqst *r,if (!ses) goto out_client_lock; status = nfserr_wrong_cred; -if (!mach_creds_match (ses->se_client, r)) +if (!nfsd4_mach_creds_match (ses->se_client, r)) goto out_put_session; status =mark_session_dead_locked (ses,1 + ref_held_by_me);if (status)
@@ -3052,7 +3052,7 @@ nfsd4_destroy_clientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *csta status = nfserr_stale_clientid; goto out; } -if (!mach_creds_match (clp, rqstp)) { +if (!nfsd4_mach_creds_match (clp, rqstp)) { clp =NULL ; status = nfserr_wrong_cred; goto out;
fs/nfsd/xdr4.h +2 -0
@@ -644,6 +644,8 @@ set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp) } + +bool nfsd4_mach_creds_match (struct nfs4_client *cl,struct svc_rqst *rqstp);int nfs4svc_encode_voidres (struct svc_rqst *,__be32 *,void *);int nfs4svc_decode_compoundargs (struct svc_rqst *,__be32 *,struct nfsd4_compoundargs *);
Signature · 1 line
2.6.3
RFC PATCH 4/4 nfsd: implement machine credential support for some operations
In reply to Andrew ElbleAdd server support for properly decoding and using spo_must_enforce and spo_must_allow bits. Add support for machine credentials to be used for CLOSE, OPEN_DOWNGRADE, LOCKU, DELEGRETURN, TEST/FREE STATEID, and LAYOUTRETURN.
Implement a check so as to not throw WRONGSEC errors when these operations are used if integrity/privacy isn't turned on.
--- fs/nfsd/export.c | 4 ++++ fs/nfsd/nfs4proc.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/nfs4state.c | 21 ++++++++++++++++++++ fs/nfsd/nfs4xdr.c | 51 ++++++++++++++++++++++--------------------------- fs/nfsd/nfsd.h | 1 + fs/nfsd/state.h | 1 + fs/nfsd/xdr4.h | 3 +++ 7 files changed, 108 insertions(+), 28 deletions(-)
fs/nfsd/export.c +4 -0
@@ -954,6 +954,10 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp) rqstp->rq_cred.cr_flavor == RPC_AUTH_UNIX)return 0 ; } + +if (nfsd4_spo_must_allow (rqstp)) +return 0 ; +return nfserr_wrongsec; }
fs/nfsd/nfs4proc.c +55 -0
61 lines not on this page · raw message
fs/nfsd/nfs4state.c +21 -0
@@ -2367,6 +2367,25 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,switch (exid->spa_how) {case SP4_MACH_CRED : + exid->spo_must_enforce[0 ] =0 ; + exid->spo_must_enforce[1 ] = ( +1 << (OP_BIND_CONN_TO_SESSION -32 ) | +1 << (OP_EXCHANGE_ID -32 ) | +1 << (OP_CREATE_SESSION -32 ) | +1 << (OP_DESTROY_SESSION -32 ) | +1 << (OP_DESTROY_CLIENTID -32 )); + + exid->spo_must_allow[0 ] &= (1 << (OP_CLOSE ) | +1 << (OP_OPEN_DOWNGRADE ) | +1 << (OP_LOCKU ) | +1 << (OP_DELEGRETURN )); + + exid->spo_must_allow[1] &= ( +#ifdef CONFIG_NFSD_PNFS +1 << (OP_LAYOUTRETURN -32 ) | +#endif +1 << (OP_TEST_STATEID -32 ) | + 1 << (OP_FREE_STATEID - 32));if (!svc_rqst_integrity_protected (rqstp))return nfserr_inval;case SP4_NONE :
@@ -2443,6 +2462,8 @@ out_new: } new->cl_minorversion = cstate->minorversion; new->cl_mach_cred = (exid->spa_how ==SP4_MACH_CRED ); + new->cl_spo_must_allow.u.words[0 ] = exid->spo_must_allow[0 ]; + new->cl_spo_must_allow.u.words[1 ] = exid->spo_must_allow[1 ];gen_clid (new, nn);add_to_unconfirmed (new);
fs/nfsd/nfs4xdr.c +23 -28
83 lines not on this page · raw message
fs/nfsd/nfsd.h +1 -0
@@ -124,6 +124,7 @@ void nfs4_state_shutdown_net(struct net *net);void nfs4_reset_lease (time_t leasetime);int nfs4_reset_recoverydir (char *recdir);char *nfs4_recoverydir (void ); +bool nfsd4_spo_must_allow (struct svc_rqst *rqstp);#else static inline int nfsd4_init_slabs (void ) {return 0 ; }static inline void nfsd4_free_slabs (void ) { }
fs/nfsd/state.h +1 -0
@@ -345,6 +345,7 @@ struct nfs4_client {u32 cl_exchange_flags;/* number of rpc's in progress over an associated session: */ atomic_t cl_refcount; +struct nfs4_op_map cl_spo_must_allow;/* for nfs41 callbacks */ /* We currently support a single back channel with a single slot */
fs/nfsd/xdr4.h +3 -0
@@ -59,6 +59,7 @@ struct nfsd4_compound_state {struct nfsd4_session *session;struct nfsd4_slot *slot;int data_offset; +bool spo_must_allowed;size_t iovlen;u32 minorversion;__be32 status;
@@ -403,6 +404,8 @@ struct nfsd4_exchange_id {clientid_t clientid;u32 seqid;int spa_how; +u32 spo_must_enforce[3 ]; +u32 spo_must_allow[3 ]; };struct nfsd4_sequence {
Signature · 1 line
2.6.3
These patches look reasonable to me. I agree with Trond that you should separate the client and server patches.
One part I’m not sure about is in nfsd4_spo_must_allow dealing with putfh like ops vs not putfh-like ops. I’ll have to check the spec and take a deeper look at that when I get some time, but maybe a brief explanation in a comment would help?
To be honest, I've always been hazy on where in the spec the ramifications of SP4_MACH_CRED only covering part of a compound is discussed… I’ll take a look soon.
-dros
Quoted 33 lines · Andrew Elble
I've finally discovered that the majority of our lost delegation problems come from EKEYEXPIRED. This seems to work fine in our environment, but I am unsure of the ramifications of this in a broader context, so it's time to get other folks to look at it.
Andrew Elble (4):
nfs/nfsd: Move useful bitfield ops to a commonly accessible place
nfs: machine credential support for additional operations
nfsd: allowmach_creds_matchto be used more broadly
nfsd: implement machine credential support for some operationsfs/nfs/nfs4proc.c | 20 +++++++++++++++++ fs/nfsd/export.c | 4 ++++ fs/nfsd/nfs4proc.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/nfs4state.c | 35 ++++++++++++++++++++++++------ fs/nfsd/nfs4xdr.c | 51 ++++++++++++++++++++----------------------- fs/nfsd/nfsd.h | 1 + fs/nfsd/state.h | 1 + fs/nfsd/xdr4.h | 5 +++++ include/linux/nfs4.h | 11 ++++++++++ include/linux/nfs_fs_sb.h | 1 + include/linux/nfs_xdr.h | 11 ---------- 11 files changed, 149 insertions(+), 46 deletions(-)Signature · 6 lines
2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines
One part I’m not sure about is in
nfsd4_spo_must_allowdealing with putfh like ops vs not putfh-like ops. I’ll have to check the spec and take a deeper look at that when I get some time, but maybe a brief explanation in a comment would help?
Will put on the list for v2.
RFC5561 2.6.3.1.1.7:
The NFSv4.1 server MUST NOT return NFS4ERR_WRONGSEC to any operation other than a put filehandle operation, LOOKUP, LOOKUPP, and OPEN (by component name).
RFC5561 15.4:
| NFS4ERR_WRONGSEC | LINK, LOOKUP, LOOKUPP, OPEN, | | | PUTFH, PUTPUBFH, PUTROOTFH, | | | RENAME, RESTOREFH
See need_wrongsec_check() (called from nfsd4_proc_compound()).
The implementation problem is that fh_verify() also calls check_nfsd_access(), so these contortions are to avoid sending NFS4ERR_WRONGSEC on things we shouldn't be, while still granting the spo_must_allow operation to succeed. (based on [somthing-putfh-like]->...->[something-spo_must_allow-like]...->[end-or-putfh])
Quoted 3 lines
To be honest, I've always been hazy on where in the spec the ramifications of
SP4_MACH_CREDonly covering part of a compound is discussed… I’ll take a look soon.
I think you mean 2.6.3.1? But it doesn't reference SP4_MACH_CRED specifically, only 'acceptable security tuple'.
This may also be a little bit heavyweight for how the server is set up currently. (i.e. simply changing the export (sec=krb5) to (sec=krb5,krb5i) will eliminate the need for nfsd4_spo_must_allow()).
Thanks,
Andy
Signature · 5 lines
Andrew W. Elble [email protected] Infrastructure Engineer, Communications Technical Lead Rochester Institute of Technology PGP: BFAD 8461 4CCF DC95 DA2C B0EB 965B 082E 863E C912