@@ -134,33 +134,6 @@ nfs4_callback_up(struct svc_serv *serv)
134134}
135135
136136#if defined(CONFIG_NFS_V4_1 )
137- /*
138- * * CB_SEQUENCE operations will fail until the callback sessionid is set.
139- * */
140- int nfs4_set_callback_sessionid (struct nfs_client * clp )
141- {
142- struct svc_serv * serv = clp -> cl_rpcclient -> cl_xprt -> bc_serv ;
143- struct nfs4_sessionid * bc_sid ;
144-
145- if (!serv -> sv_bc_xprt )
146- return - EINVAL ;
147-
148- /* on success freed in xprt_free */
149- bc_sid = kmalloc (sizeof (struct nfs4_sessionid ), GFP_KERNEL );
150- if (!bc_sid )
151- return - ENOMEM ;
152- memcpy (bc_sid -> data , & clp -> cl_session -> sess_id .data ,
153- NFS4_MAX_SESSIONID_LEN );
154- spin_lock_bh (& serv -> sv_cb_lock );
155- serv -> sv_bc_xprt -> xpt_bc_sid = bc_sid ;
156- spin_unlock_bh (& serv -> sv_cb_lock );
157- dprintk ("%s set xpt_bc_sid=%u:%u:%u:%u for sv_bc_xprt %p\n" , __func__ ,
158- ((u32 * )bc_sid -> data )[0 ], ((u32 * )bc_sid -> data )[1 ],
159- ((u32 * )bc_sid -> data )[2 ], ((u32 * )bc_sid -> data )[3 ],
160- serv -> sv_bc_xprt );
161- return 0 ;
162- }
163-
164137/*
165138 * The callback service for NFSv4.1 callbacks
166139 */
@@ -266,10 +239,6 @@ static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt,
266239 struct nfs_callback_data * cb_info )
267240{
268241}
269- int nfs4_set_callback_sessionid (struct nfs_client * clp )
270- {
271- return 0 ;
272- }
273242#endif /* CONFIG_NFS_V4_1 */
274243
275244/*
@@ -359,78 +328,58 @@ void nfs_callback_down(int minorversion)
359328 mutex_unlock (& nfs_callback_mutex );
360329}
361330
362- static int check_gss_callback_principal (struct nfs_client * clp ,
363- struct svc_rqst * rqstp )
331+ /* Boolean check of RPC_AUTH_GSS principal */
332+ int
333+ check_gss_callback_principal (struct nfs_client * clp , struct svc_rqst * rqstp )
364334{
365335 struct rpc_clnt * r = clp -> cl_rpcclient ;
366336 char * p = svc_gss_principal (rqstp );
367337
338+ if (rqstp -> rq_authop -> flavour != RPC_AUTH_GSS )
339+ return 1 ;
340+
368341 /* No RPC_AUTH_GSS on NFSv4.1 back channel yet */
369342 if (clp -> cl_minorversion != 0 )
370- return SVC_DROP ;
343+ return 0 ;
371344 /*
372345 * It might just be a normal user principal, in which case
373346 * userspace won't bother to tell us the name at all.
374347 */
375348 if (p == NULL )
376- return SVC_DENIED ;
349+ return 0 ;
377350
378351 /* Expect a GSS_C_NT_HOSTBASED_NAME like "nfs@serverhostname" */
379352
380353 if (memcmp (p , "nfs@" , 4 ) != 0 )
381- return SVC_DENIED ;
354+ return 0 ;
382355 p += 4 ;
383356 if (strcmp (p , r -> cl_server ) != 0 )
384- return SVC_DENIED ;
385- return SVC_OK ;
357+ return 0 ;
358+ return 1 ;
386359}
387360
388- /* pg_authenticate method helper */
389- static struct nfs_client * nfs_cb_find_client (struct svc_rqst * rqstp )
390- {
391- struct nfs4_sessionid * sessionid = bc_xprt_sid (rqstp );
392- int is_cb_compound = rqstp -> rq_proc == CB_COMPOUND ? 1 : 0 ;
393-
394- dprintk ("--> %s rq_proc %d\n" , __func__ , rqstp -> rq_proc );
395- if (svc_is_backchannel (rqstp ))
396- /* Sessionid (usually) set after CB_NULL ping */
397- return nfs4_find_client_sessionid (svc_addr (rqstp ), sessionid ,
398- is_cb_compound );
399- else
400- /* No callback identifier in pg_authenticate */
401- return nfs4_find_client_no_ident (svc_addr (rqstp ));
402- }
403-
404- /* pg_authenticate method for nfsv4 callback threads. */
361+ /*
362+ * pg_authenticate method for nfsv4 callback threads.
363+ *
364+ * The authflavor has been negotiated, so an incorrect flavor is a server
365+ * bug. Drop packets with incorrect authflavor.
366+ *
367+ * All other checking done after NFS decoding where the nfs_client can be
368+ * found in nfs4_callback_compound
369+ */
405370static int nfs_callback_authenticate (struct svc_rqst * rqstp )
406371{
407- struct nfs_client * clp ;
408- RPC_IFDEBUG (char buf [RPC_MAX_ADDRBUFLEN ]);
409- int ret = SVC_OK ;
410-
411- /* Don't talk to strangers */
412- clp = nfs_cb_find_client (rqstp );
413- if (clp == NULL )
414- return SVC_DROP ;
415-
416- dprintk ("%s: %s NFSv4 callback!\n" , __func__ ,
417- svc_print_addr (rqstp , buf , sizeof (buf )));
418-
419372 switch (rqstp -> rq_authop -> flavour ) {
420- case RPC_AUTH_NULL :
421- if (rqstp -> rq_proc != CB_NULL )
422- ret = SVC_DENIED ;
423- break ;
424- case RPC_AUTH_UNIX :
425- break ;
426- case RPC_AUTH_GSS :
427- ret = check_gss_callback_principal (clp , rqstp );
428- break ;
429- default :
430- ret = SVC_DENIED ;
373+ case RPC_AUTH_NULL :
374+ if (rqstp -> rq_proc != CB_NULL )
375+ return SVC_DROP ;
376+ break ;
377+ case RPC_AUTH_GSS :
378+ /* No RPC_AUTH_GSS support yet in NFSv4.1 */
379+ if (svc_is_backchannel (rqstp ))
380+ return SVC_DROP ;
431381 }
432- nfs_put_client (clp );
433- return ret ;
382+ return SVC_OK ;
434383}
435384
436385/*
0 commit comments