@@ -142,7 +142,11 @@ static inline __be32 check_pseudo_root(struct dentry *dentry,
142
142
* dentry. On success, the results are used to set fh_export and
143
143
* fh_dentry.
144
144
*/
145
- static __be32 nfsd_set_fh_dentry (struct svc_rqst * rqstp , struct svc_fh * fhp )
145
+ static __be32 nfsd_set_fh_dentry (struct svc_rqst * rqstp , struct net * net ,
146
+ struct svc_cred * cred ,
147
+ struct auth_domain * client ,
148
+ struct auth_domain * gssclient ,
149
+ struct svc_fh * fhp )
146
150
{
147
151
struct knfsd_fh * fh = & fhp -> fh_handle ;
148
152
struct fid * fid = NULL ;
@@ -184,8 +188,8 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
184
188
data_left -= len ;
185
189
if (data_left < 0 )
186
190
return error ;
187
- exp = rqst_exp_find (& rqstp -> rq_chandle , SVC_NET ( rqstp ) ,
188
- rqstp -> rq_client , rqstp -> rq_gssclient ,
191
+ exp = rqst_exp_find (rqstp ? & rqstp -> rq_chandle : NULL ,
192
+ net , client , gssclient ,
189
193
fh -> fh_fsid_type , fh -> fh_fsid );
190
194
fid = (struct fid * )(fh -> fh_fsid + len );
191
195
@@ -220,7 +224,7 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
220
224
put_cred (override_creds (new ));
221
225
put_cred (new );
222
226
} else {
223
- error = nfsd_setuser_and_check_port (rqstp , & rqstp -> rq_cred , exp );
227
+ error = nfsd_setuser_and_check_port (rqstp , cred , exp );
224
228
if (error )
225
229
goto out ;
226
230
}
@@ -295,42 +299,33 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
295
299
}
296
300
297
301
/**
298
- * fh_verify - filehandle lookup and access checking
299
- * @rqstp: pointer to current rpc request
302
+ * __fh_verify - filehandle lookup and access checking
303
+ * @rqstp: RPC transaction context, or NULL
304
+ * @net: net namespace in which to perform the export lookup
305
+ * @cred: RPC user credential
306
+ * @client: RPC auth domain
307
+ * @gssclient: RPC GSS auth domain, or NULL
300
308
* @fhp: filehandle to be verified
301
309
* @type: expected type of object pointed to by filehandle
302
310
* @access: type of access needed to object
303
311
*
304
- * Look up a dentry from the on-the-wire filehandle, check the client's
305
- * access to the export, and set the current task's credentials.
306
- *
307
- * Regardless of success or failure of fh_verify(), fh_put() should be
308
- * called on @fhp when the caller is finished with the filehandle.
309
- *
310
- * fh_verify() may be called multiple times on a given filehandle, for
311
- * example, when processing an NFSv4 compound. The first call will look
312
- * up a dentry using the on-the-wire filehandle. Subsequent calls will
313
- * skip the lookup and just perform the other checks and possibly change
314
- * the current task's credentials.
315
- *
316
- * @type specifies the type of object expected using one of the S_IF*
317
- * constants defined in include/linux/stat.h. The caller may use zero
318
- * to indicate that it doesn't care, or a negative integer to indicate
319
- * that it expects something not of the given type.
320
- *
321
- * @access is formed from the NFSD_MAY_* constants defined in
322
- * fs/nfsd/vfs.h.
312
+ * See fh_verify() for further descriptions of @fhp, @type, and @access.
323
313
*/
324
- __be32
325
- fh_verify (struct svc_rqst * rqstp , struct svc_fh * fhp , umode_t type , int access )
314
+ static __be32
315
+ __fh_verify (struct svc_rqst * rqstp ,
316
+ struct net * net , struct svc_cred * cred ,
317
+ struct auth_domain * client ,
318
+ struct auth_domain * gssclient ,
319
+ struct svc_fh * fhp , umode_t type , int access )
326
320
{
327
- struct nfsd_net * nn = net_generic (SVC_NET ( rqstp ) , nfsd_net_id );
321
+ struct nfsd_net * nn = net_generic (net , nfsd_net_id );
328
322
struct svc_export * exp = NULL ;
329
323
struct dentry * dentry ;
330
324
__be32 error ;
331
325
332
326
if (!fhp -> fh_dentry ) {
333
- error = nfsd_set_fh_dentry (rqstp , fhp );
327
+ error = nfsd_set_fh_dentry (rqstp , net , cred , client ,
328
+ gssclient , fhp );
334
329
if (error )
335
330
goto out ;
336
331
}
@@ -359,7 +354,7 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access)
359
354
if (error )
360
355
goto out ;
361
356
362
- error = nfsd_setuser_and_check_port (rqstp , & rqstp -> rq_cred , exp );
357
+ error = nfsd_setuser_and_check_port (rqstp , cred , exp );
363
358
if (error )
364
359
goto out ;
365
360
@@ -389,14 +384,48 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access)
389
384
390
385
skip_pseudoflavor_check :
391
386
/* Finally, check access permissions. */
392
- error = nfsd_permission (& rqstp -> rq_cred , exp , dentry , access );
387
+ error = nfsd_permission (cred , exp , dentry , access );
393
388
out :
394
389
trace_nfsd_fh_verify_err (rqstp , fhp , type , access , error );
395
390
if (error == nfserr_stale )
396
391
nfsd_stats_fh_stale_inc (nn , exp );
397
392
return error ;
398
393
}
399
394
395
+ /**
396
+ * fh_verify - filehandle lookup and access checking
397
+ * @rqstp: pointer to current rpc request
398
+ * @fhp: filehandle to be verified
399
+ * @type: expected type of object pointed to by filehandle
400
+ * @access: type of access needed to object
401
+ *
402
+ * Look up a dentry from the on-the-wire filehandle, check the client's
403
+ * access to the export, and set the current task's credentials.
404
+ *
405
+ * Regardless of success or failure of fh_verify(), fh_put() should be
406
+ * called on @fhp when the caller is finished with the filehandle.
407
+ *
408
+ * fh_verify() may be called multiple times on a given filehandle, for
409
+ * example, when processing an NFSv4 compound. The first call will look
410
+ * up a dentry using the on-the-wire filehandle. Subsequent calls will
411
+ * skip the lookup and just perform the other checks and possibly change
412
+ * the current task's credentials.
413
+ *
414
+ * @type specifies the type of object expected using one of the S_IF*
415
+ * constants defined in include/linux/stat.h. The caller may use zero
416
+ * to indicate that it doesn't care, or a negative integer to indicate
417
+ * that it expects something not of the given type.
418
+ *
419
+ * @access is formed from the NFSD_MAY_* constants defined in
420
+ * fs/nfsd/vfs.h.
421
+ */
422
+ __be32
423
+ fh_verify (struct svc_rqst * rqstp , struct svc_fh * fhp , umode_t type , int access )
424
+ {
425
+ return __fh_verify (rqstp , SVC_NET (rqstp ), & rqstp -> rq_cred ,
426
+ rqstp -> rq_client , rqstp -> rq_gssclient ,
427
+ fhp , type , access );
428
+ }
400
429
401
430
/*
402
431
* Compose a file handle for an NFS reply.
0 commit comments