|
38 | 38 | #include <linux/namei.h>
|
39 | 39 | #include <linux/swap.h>
|
40 | 40 | #include <linux/pagemap.h>
|
| 41 | +#include <linux/ratelimit.h> |
41 | 42 | #include <linux/sunrpc/svcauth_gss.h>
|
42 | 43 | #include <linux/sunrpc/clnt.h>
|
43 | 44 | #include "xdr4.h"
|
@@ -3338,18 +3339,26 @@ static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_s
|
3338 | 3339 | return nfserr_old_stateid;
|
3339 | 3340 | }
|
3340 | 3341 |
|
3341 |
| -__be32 nfs4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid) |
| 3342 | +static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid) |
3342 | 3343 | {
|
3343 | 3344 | struct nfs4_stid *s;
|
3344 | 3345 | struct nfs4_ol_stateid *ols;
|
3345 | 3346 | __be32 status;
|
3346 | 3347 |
|
3347 |
| - if (STALE_STATEID(stateid)) |
3348 |
| - return nfserr_stale_stateid; |
3349 |
| - |
| 3348 | + if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) |
| 3349 | + return nfserr_bad_stateid; |
| 3350 | + /* Client debugging aid. */ |
| 3351 | + if (!same_clid(&stateid->si_opaque.so_clid, &cl->cl_clientid)) { |
| 3352 | + char addr_str[INET6_ADDRSTRLEN]; |
| 3353 | + rpc_ntop((struct sockaddr *)&cl->cl_addr, addr_str, |
| 3354 | + sizeof(addr_str)); |
| 3355 | + pr_warn_ratelimited("NFSD: client %s testing state ID " |
| 3356 | + "with incorrect client ID\n", addr_str); |
| 3357 | + return nfserr_bad_stateid; |
| 3358 | + } |
3350 | 3359 | s = find_stateid(cl, stateid);
|
3351 | 3360 | if (!s)
|
3352 |
| - return nfserr_stale_stateid; |
| 3361 | + return nfserr_bad_stateid; |
3353 | 3362 | status = check_stateid_generation(stateid, &s->sc_stateid, 1);
|
3354 | 3363 | if (status)
|
3355 | 3364 | return status;
|
@@ -3468,7 +3477,8 @@ nfsd4_test_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
3468 | 3477 |
|
3469 | 3478 | nfs4_lock_state();
|
3470 | 3479 | list_for_each_entry(stateid, &test_stateid->ts_stateid_list, ts_id_list)
|
3471 |
| - stateid->ts_id_status = nfs4_validate_stateid(cl, &stateid->ts_id_stateid); |
| 3480 | + stateid->ts_id_status = |
| 3481 | + nfsd4_validate_stateid(cl, &stateid->ts_id_stateid); |
3472 | 3482 | nfs4_unlock_state();
|
3473 | 3483 |
|
3474 | 3484 | return nfs_ok;
|
|
0 commit comments