.. | .. |
---|
22 | 22 | #include <linux/nfs.h> |
---|
23 | 23 | #include <linux/nfs2.h> |
---|
24 | 24 | #include <linux/nfs_fs.h> |
---|
| 25 | +#include "nfstrace.h" |
---|
25 | 26 | #include "internal.h" |
---|
26 | 27 | |
---|
27 | 28 | #define NFSDBG_FACILITY NFSDBG_XDR |
---|
.. | .. |
---|
55 | 56 | |
---|
56 | 57 | #define NFS_attrstat_sz (1+NFS_fattr_sz) |
---|
57 | 58 | #define NFS_diropres_sz (1+NFS_fhandle_sz+NFS_fattr_sz) |
---|
58 | | -#define NFS_readlinkres_sz (2) |
---|
59 | | -#define NFS_readres_sz (1+NFS_fattr_sz+1) |
---|
| 59 | +#define NFS_readlinkres_sz (2+1) |
---|
| 60 | +#define NFS_readres_sz (1+NFS_fattr_sz+1+1) |
---|
60 | 61 | #define NFS_writeres_sz (NFS_attrstat_sz) |
---|
61 | 62 | #define NFS_stat_sz (1) |
---|
62 | | -#define NFS_readdirres_sz (1) |
---|
| 63 | +#define NFS_readdirres_sz (1+1) |
---|
63 | 64 | #define NFS_statfsres_sz (1+NFS_info_sz) |
---|
64 | 65 | |
---|
65 | 66 | static int nfs_stat_to_errno(enum nfs_stat); |
---|
66 | | - |
---|
67 | | -/* |
---|
68 | | - * While encoding arguments, set up the reply buffer in advance to |
---|
69 | | - * receive reply data directly into the page cache. |
---|
70 | | - */ |
---|
71 | | -static void prepare_reply_buffer(struct rpc_rqst *req, struct page **pages, |
---|
72 | | - unsigned int base, unsigned int len, |
---|
73 | | - unsigned int bufsize) |
---|
74 | | -{ |
---|
75 | | - struct rpc_auth *auth = req->rq_cred->cr_auth; |
---|
76 | | - unsigned int replen; |
---|
77 | | - |
---|
78 | | - replen = RPC_REPHDRSIZE + auth->au_rslack + bufsize; |
---|
79 | | - xdr_inline_pages(&req->rq_rcv_buf, replen << 2, pages, base, len); |
---|
80 | | -} |
---|
81 | | - |
---|
82 | | -/* |
---|
83 | | - * Handle decode buffer overflows out-of-line. |
---|
84 | | - */ |
---|
85 | | -static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
---|
86 | | -{ |
---|
87 | | - dprintk("NFS: %s prematurely hit the end of our receive buffer. " |
---|
88 | | - "Remaining buffer length is %tu words.\n", |
---|
89 | | - func, xdr->end - xdr->p); |
---|
90 | | -} |
---|
91 | | - |
---|
92 | 67 | |
---|
93 | 68 | /* |
---|
94 | 69 | * Encode/decode NFSv2 basic data types |
---|
.. | .. |
---|
101 | 76 | * or decoded inline. |
---|
102 | 77 | */ |
---|
103 | 78 | |
---|
| 79 | +static struct user_namespace *rpc_userns(const struct rpc_clnt *clnt) |
---|
| 80 | +{ |
---|
| 81 | + if (clnt && clnt->cl_cred) |
---|
| 82 | + return clnt->cl_cred->user_ns; |
---|
| 83 | + return &init_user_ns; |
---|
| 84 | +} |
---|
| 85 | + |
---|
| 86 | +static struct user_namespace *rpc_rqst_userns(const struct rpc_rqst *rqstp) |
---|
| 87 | +{ |
---|
| 88 | + if (rqstp->rq_task) |
---|
| 89 | + return rpc_userns(rqstp->rq_task->tk_client); |
---|
| 90 | + return &init_user_ns; |
---|
| 91 | +} |
---|
| 92 | + |
---|
104 | 93 | /* |
---|
105 | 94 | * typedef opaque nfsdata<>; |
---|
106 | 95 | */ |
---|
.. | .. |
---|
110 | 99 | __be32 *p; |
---|
111 | 100 | |
---|
112 | 101 | p = xdr_inline_decode(xdr, 4); |
---|
113 | | - if (unlikely(p == NULL)) |
---|
114 | | - goto out_overflow; |
---|
| 102 | + if (unlikely(!p)) |
---|
| 103 | + return -EIO; |
---|
115 | 104 | count = be32_to_cpup(p); |
---|
116 | 105 | recvd = xdr_read_pages(xdr, count); |
---|
117 | 106 | if (unlikely(count > recvd)) |
---|
.. | .. |
---|
125 | 114 | "count %u > recvd %u\n", count, recvd); |
---|
126 | 115 | count = recvd; |
---|
127 | 116 | goto out; |
---|
128 | | -out_overflow: |
---|
129 | | - print_overflow_msg(__func__, xdr); |
---|
130 | | - return -EIO; |
---|
131 | 117 | } |
---|
132 | 118 | |
---|
133 | 119 | /* |
---|
.. | .. |
---|
157 | 143 | __be32 *p; |
---|
158 | 144 | |
---|
159 | 145 | p = xdr_inline_decode(xdr, 4); |
---|
160 | | - if (unlikely(p == NULL)) |
---|
161 | | - goto out_overflow; |
---|
162 | | - *status = be32_to_cpup(p); |
---|
| 146 | + if (unlikely(!p)) |
---|
| 147 | + return -EIO; |
---|
| 148 | + if (unlikely(*p != cpu_to_be32(NFS_OK))) |
---|
| 149 | + goto out_status; |
---|
| 150 | + *status = 0; |
---|
163 | 151 | return 0; |
---|
164 | | -out_overflow: |
---|
165 | | - print_overflow_msg(__func__, xdr); |
---|
166 | | - return -EIO; |
---|
| 152 | +out_status: |
---|
| 153 | + *status = be32_to_cpup(p); |
---|
| 154 | + trace_nfs_xdr_status(xdr, (int)*status); |
---|
| 155 | + return 0; |
---|
167 | 156 | } |
---|
168 | 157 | |
---|
169 | 158 | /* |
---|
.. | .. |
---|
205 | 194 | __be32 *p; |
---|
206 | 195 | |
---|
207 | 196 | p = xdr_inline_decode(xdr, NFS2_FHSIZE); |
---|
208 | | - if (unlikely(p == NULL)) |
---|
209 | | - goto out_overflow; |
---|
| 197 | + if (unlikely(!p)) |
---|
| 198 | + return -EIO; |
---|
210 | 199 | fh->size = NFS2_FHSIZE; |
---|
211 | 200 | memcpy(fh->data, p, NFS2_FHSIZE); |
---|
212 | 201 | return 0; |
---|
213 | | -out_overflow: |
---|
214 | | - print_overflow_msg(__func__, xdr); |
---|
215 | | - return -EIO; |
---|
216 | 202 | } |
---|
217 | 203 | |
---|
218 | 204 | /* |
---|
.. | .. |
---|
223 | 209 | * unsigned int useconds; |
---|
224 | 210 | * }; |
---|
225 | 211 | */ |
---|
226 | | -static __be32 *xdr_encode_time(__be32 *p, const struct timespec *timep) |
---|
| 212 | +static __be32 *xdr_encode_time(__be32 *p, const struct timespec64 *timep) |
---|
227 | 213 | { |
---|
228 | | - *p++ = cpu_to_be32(timep->tv_sec); |
---|
| 214 | + *p++ = cpu_to_be32((u32)timep->tv_sec); |
---|
229 | 215 | if (timep->tv_nsec != 0) |
---|
230 | 216 | *p++ = cpu_to_be32(timep->tv_nsec / NSEC_PER_USEC); |
---|
231 | 217 | else |
---|
.. | .. |
---|
241 | 227 | * Illustrated" by Brent Callaghan, Addison-Wesley, ISBN 0-201-32750-5. |
---|
242 | 228 | */ |
---|
243 | 229 | static __be32 *xdr_encode_current_server_time(__be32 *p, |
---|
244 | | - const struct timespec *timep) |
---|
| 230 | + const struct timespec64 *timep) |
---|
245 | 231 | { |
---|
246 | 232 | *p++ = cpu_to_be32(timep->tv_sec); |
---|
247 | 233 | *p++ = cpu_to_be32(1000000); |
---|
248 | 234 | return p; |
---|
249 | 235 | } |
---|
250 | 236 | |
---|
251 | | -static __be32 *xdr_decode_time(__be32 *p, struct timespec *timep) |
---|
| 237 | +static __be32 *xdr_decode_time(__be32 *p, struct timespec64 *timep) |
---|
252 | 238 | { |
---|
253 | 239 | timep->tv_sec = be32_to_cpup(p++); |
---|
254 | 240 | timep->tv_nsec = be32_to_cpup(p++) * NSEC_PER_USEC; |
---|
.. | .. |
---|
276 | 262 | * }; |
---|
277 | 263 | * |
---|
278 | 264 | */ |
---|
279 | | -static int decode_fattr(struct xdr_stream *xdr, struct nfs_fattr *fattr) |
---|
| 265 | +static int decode_fattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
---|
| 266 | + struct user_namespace *userns) |
---|
280 | 267 | { |
---|
281 | 268 | u32 rdev, type; |
---|
282 | 269 | __be32 *p; |
---|
283 | 270 | |
---|
284 | 271 | p = xdr_inline_decode(xdr, NFS_fattr_sz << 2); |
---|
285 | | - if (unlikely(p == NULL)) |
---|
286 | | - goto out_overflow; |
---|
| 272 | + if (unlikely(!p)) |
---|
| 273 | + return -EIO; |
---|
287 | 274 | |
---|
288 | 275 | fattr->valid |= NFS_ATTR_FATTR_V2; |
---|
289 | 276 | |
---|
.. | .. |
---|
291 | 278 | |
---|
292 | 279 | fattr->mode = be32_to_cpup(p++); |
---|
293 | 280 | fattr->nlink = be32_to_cpup(p++); |
---|
294 | | - fattr->uid = make_kuid(&init_user_ns, be32_to_cpup(p++)); |
---|
| 281 | + fattr->uid = make_kuid(userns, be32_to_cpup(p++)); |
---|
295 | 282 | if (!uid_valid(fattr->uid)) |
---|
296 | 283 | goto out_uid; |
---|
297 | | - fattr->gid = make_kgid(&init_user_ns, be32_to_cpup(p++)); |
---|
| 284 | + fattr->gid = make_kgid(userns, be32_to_cpup(p++)); |
---|
298 | 285 | if (!gid_valid(fattr->gid)) |
---|
299 | 286 | goto out_gid; |
---|
300 | 287 | |
---|
.. | .. |
---|
325 | 312 | out_gid: |
---|
326 | 313 | dprintk("NFS: returned invalid gid\n"); |
---|
327 | 314 | return -EINVAL; |
---|
328 | | -out_overflow: |
---|
329 | | - print_overflow_msg(__func__, xdr); |
---|
330 | | - return -EIO; |
---|
331 | 315 | } |
---|
332 | 316 | |
---|
333 | 317 | /* |
---|
.. | .. |
---|
352 | 336 | return p; |
---|
353 | 337 | } |
---|
354 | 338 | |
---|
355 | | -static void encode_sattr(struct xdr_stream *xdr, const struct iattr *attr) |
---|
| 339 | +static void encode_sattr(struct xdr_stream *xdr, const struct iattr *attr, |
---|
| 340 | + struct user_namespace *userns) |
---|
356 | 341 | { |
---|
357 | | - struct timespec ts; |
---|
358 | 342 | __be32 *p; |
---|
359 | 343 | |
---|
360 | 344 | p = xdr_reserve_space(xdr, NFS_sattr_sz << 2); |
---|
.. | .. |
---|
364 | 348 | else |
---|
365 | 349 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
---|
366 | 350 | if (attr->ia_valid & ATTR_UID) |
---|
367 | | - *p++ = cpu_to_be32(from_kuid(&init_user_ns, attr->ia_uid)); |
---|
| 351 | + *p++ = cpu_to_be32(from_kuid_munged(userns, attr->ia_uid)); |
---|
368 | 352 | else |
---|
369 | 353 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
---|
370 | 354 | if (attr->ia_valid & ATTR_GID) |
---|
371 | | - *p++ = cpu_to_be32(from_kgid(&init_user_ns, attr->ia_gid)); |
---|
| 355 | + *p++ = cpu_to_be32(from_kgid_munged(userns, attr->ia_gid)); |
---|
372 | 356 | else |
---|
373 | 357 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
---|
374 | 358 | if (attr->ia_valid & ATTR_SIZE) |
---|
.. | .. |
---|
376 | 360 | else |
---|
377 | 361 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
---|
378 | 362 | |
---|
379 | | - if (attr->ia_valid & ATTR_ATIME_SET) { |
---|
380 | | - ts = timespec64_to_timespec(attr->ia_atime); |
---|
381 | | - p = xdr_encode_time(p, &ts); |
---|
382 | | - } else if (attr->ia_valid & ATTR_ATIME) { |
---|
383 | | - ts = timespec64_to_timespec(attr->ia_atime); |
---|
384 | | - p = xdr_encode_current_server_time(p, &ts); |
---|
385 | | - } else |
---|
| 363 | + if (attr->ia_valid & ATTR_ATIME_SET) |
---|
| 364 | + p = xdr_encode_time(p, &attr->ia_atime); |
---|
| 365 | + else if (attr->ia_valid & ATTR_ATIME) |
---|
| 366 | + p = xdr_encode_current_server_time(p, &attr->ia_atime); |
---|
| 367 | + else |
---|
386 | 368 | p = xdr_time_not_set(p); |
---|
387 | | - if (attr->ia_valid & ATTR_MTIME_SET) { |
---|
388 | | - ts = timespec64_to_timespec(attr->ia_mtime); |
---|
389 | | - xdr_encode_time(p, &ts); |
---|
390 | | - } else if (attr->ia_valid & ATTR_MTIME) { |
---|
391 | | - ts = timespec64_to_timespec(attr->ia_mtime); |
---|
392 | | - xdr_encode_current_server_time(p, &ts); |
---|
393 | | - } else |
---|
| 369 | + if (attr->ia_valid & ATTR_MTIME_SET) |
---|
| 370 | + xdr_encode_time(p, &attr->ia_mtime); |
---|
| 371 | + else if (attr->ia_valid & ATTR_MTIME) |
---|
| 372 | + xdr_encode_current_server_time(p, &attr->ia_mtime); |
---|
| 373 | + else |
---|
394 | 374 | xdr_time_not_set(p); |
---|
395 | 375 | } |
---|
396 | 376 | |
---|
.. | .. |
---|
416 | 396 | u32 count; |
---|
417 | 397 | |
---|
418 | 398 | p = xdr_inline_decode(xdr, 4); |
---|
419 | | - if (unlikely(p == NULL)) |
---|
420 | | - goto out_overflow; |
---|
| 399 | + if (unlikely(!p)) |
---|
| 400 | + return -EIO; |
---|
421 | 401 | count = be32_to_cpup(p); |
---|
422 | 402 | if (count > NFS3_MAXNAMLEN) |
---|
423 | 403 | goto out_nametoolong; |
---|
424 | 404 | p = xdr_inline_decode(xdr, count); |
---|
425 | | - if (unlikely(p == NULL)) |
---|
426 | | - goto out_overflow; |
---|
| 405 | + if (unlikely(!p)) |
---|
| 406 | + return -EIO; |
---|
427 | 407 | *name = (const char *)p; |
---|
428 | 408 | *length = count; |
---|
429 | 409 | return 0; |
---|
430 | 410 | out_nametoolong: |
---|
431 | 411 | dprintk("NFS: returned filename too long: %u\n", count); |
---|
432 | 412 | return -ENAMETOOLONG; |
---|
433 | | -out_overflow: |
---|
434 | | - print_overflow_msg(__func__, xdr); |
---|
435 | | - return -EIO; |
---|
436 | 413 | } |
---|
437 | 414 | |
---|
438 | 415 | /* |
---|
.. | .. |
---|
455 | 432 | __be32 *p; |
---|
456 | 433 | |
---|
457 | 434 | p = xdr_inline_decode(xdr, 4); |
---|
458 | | - if (unlikely(p == NULL)) |
---|
459 | | - goto out_overflow; |
---|
| 435 | + if (unlikely(!p)) |
---|
| 436 | + return -EIO; |
---|
460 | 437 | length = be32_to_cpup(p); |
---|
461 | 438 | if (unlikely(length >= xdr->buf->page_len || length > NFS_MAXPATHLEN)) |
---|
462 | 439 | goto out_size; |
---|
.. | .. |
---|
472 | 449 | dprintk("NFS: server cheating in pathname result: " |
---|
473 | 450 | "length %u > received %u\n", length, recvd); |
---|
474 | 451 | return -EIO; |
---|
475 | | -out_overflow: |
---|
476 | | - print_overflow_msg(__func__, xdr); |
---|
477 | | - return -EIO; |
---|
478 | 452 | } |
---|
479 | 453 | |
---|
480 | 454 | /* |
---|
.. | .. |
---|
488 | 462 | * }; |
---|
489 | 463 | */ |
---|
490 | 464 | static int decode_attrstat(struct xdr_stream *xdr, struct nfs_fattr *result, |
---|
491 | | - __u32 *op_status) |
---|
| 465 | + __u32 *op_status, |
---|
| 466 | + struct user_namespace *userns) |
---|
492 | 467 | { |
---|
493 | 468 | enum nfs_stat status; |
---|
494 | 469 | int error; |
---|
.. | .. |
---|
500 | 475 | *op_status = status; |
---|
501 | 476 | if (status != NFS_OK) |
---|
502 | 477 | goto out_default; |
---|
503 | | - error = decode_fattr(xdr, result); |
---|
| 478 | + error = decode_fattr(xdr, result, userns); |
---|
504 | 479 | out: |
---|
505 | 480 | return error; |
---|
506 | 481 | out_default: |
---|
.. | .. |
---|
535 | 510 | * void; |
---|
536 | 511 | * }; |
---|
537 | 512 | */ |
---|
538 | | -static int decode_diropok(struct xdr_stream *xdr, struct nfs_diropok *result) |
---|
| 513 | +static int decode_diropok(struct xdr_stream *xdr, struct nfs_diropok *result, |
---|
| 514 | + struct user_namespace *userns) |
---|
539 | 515 | { |
---|
540 | 516 | int error; |
---|
541 | 517 | |
---|
542 | 518 | error = decode_fhandle(xdr, result->fh); |
---|
543 | 519 | if (unlikely(error)) |
---|
544 | 520 | goto out; |
---|
545 | | - error = decode_fattr(xdr, result->fattr); |
---|
| 521 | + error = decode_fattr(xdr, result->fattr, userns); |
---|
546 | 522 | out: |
---|
547 | 523 | return error; |
---|
548 | 524 | } |
---|
549 | 525 | |
---|
550 | | -static int decode_diropres(struct xdr_stream *xdr, struct nfs_diropok *result) |
---|
| 526 | +static int decode_diropres(struct xdr_stream *xdr, struct nfs_diropok *result, |
---|
| 527 | + struct user_namespace *userns) |
---|
551 | 528 | { |
---|
552 | 529 | enum nfs_stat status; |
---|
553 | 530 | int error; |
---|
.. | .. |
---|
557 | 534 | goto out; |
---|
558 | 535 | if (status != NFS_OK) |
---|
559 | 536 | goto out_default; |
---|
560 | | - error = decode_diropok(xdr, result); |
---|
| 537 | + error = decode_diropok(xdr, result, userns); |
---|
561 | 538 | out: |
---|
562 | 539 | return error; |
---|
563 | 540 | out_default: |
---|
.. | .. |
---|
596 | 573 | const struct nfs_sattrargs *args = data; |
---|
597 | 574 | |
---|
598 | 575 | encode_fhandle(xdr, args->fh); |
---|
599 | | - encode_sattr(xdr, args->sattr); |
---|
| 576 | + encode_sattr(xdr, args->sattr, rpc_rqst_userns(req)); |
---|
600 | 577 | } |
---|
601 | 578 | |
---|
602 | 579 | static void nfs2_xdr_enc_diropargs(struct rpc_rqst *req, |
---|
.. | .. |
---|
615 | 592 | const struct nfs_readlinkargs *args = data; |
---|
616 | 593 | |
---|
617 | 594 | encode_fhandle(xdr, args->fh); |
---|
618 | | - prepare_reply_buffer(req, args->pages, args->pgbase, |
---|
619 | | - args->pglen, NFS_readlinkres_sz); |
---|
| 595 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, |
---|
| 596 | + args->pglen, NFS_readlinkres_sz); |
---|
620 | 597 | } |
---|
621 | 598 | |
---|
622 | 599 | /* |
---|
.. | .. |
---|
651 | 628 | const struct nfs_pgio_args *args = data; |
---|
652 | 629 | |
---|
653 | 630 | encode_readargs(xdr, args); |
---|
654 | | - prepare_reply_buffer(req, args->pages, args->pgbase, |
---|
655 | | - args->count, NFS_readres_sz); |
---|
| 631 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, |
---|
| 632 | + args->count, NFS_readres_sz); |
---|
656 | 633 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
---|
657 | 634 | } |
---|
658 | 635 | |
---|
.. | .. |
---|
711 | 688 | const struct nfs_createargs *args = data; |
---|
712 | 689 | |
---|
713 | 690 | encode_diropargs(xdr, args->fh, args->name, args->len); |
---|
714 | | - encode_sattr(xdr, args->sattr); |
---|
| 691 | + encode_sattr(xdr, args->sattr, rpc_rqst_userns(req)); |
---|
715 | 692 | } |
---|
716 | 693 | |
---|
717 | 694 | static void nfs2_xdr_enc_removeargs(struct rpc_rqst *req, |
---|
.. | .. |
---|
778 | 755 | |
---|
779 | 756 | encode_diropargs(xdr, args->fromfh, args->fromname, args->fromlen); |
---|
780 | 757 | encode_path(xdr, args->pages, args->pathlen); |
---|
781 | | - encode_sattr(xdr, args->sattr); |
---|
| 758 | + encode_sattr(xdr, args->sattr, rpc_rqst_userns(req)); |
---|
782 | 759 | } |
---|
783 | 760 | |
---|
784 | 761 | /* |
---|
.. | .. |
---|
809 | 786 | const struct nfs_readdirargs *args = data; |
---|
810 | 787 | |
---|
811 | 788 | encode_readdirargs(xdr, args); |
---|
812 | | - prepare_reply_buffer(req, args->pages, 0, |
---|
813 | | - args->count, NFS_readdirres_sz); |
---|
| 789 | + rpc_prepare_reply_pages(req, args->pages, 0, |
---|
| 790 | + args->count, NFS_readdirres_sz); |
---|
814 | 791 | } |
---|
815 | 792 | |
---|
816 | 793 | /* |
---|
.. | .. |
---|
840 | 817 | static int nfs2_xdr_dec_attrstat(struct rpc_rqst *req, struct xdr_stream *xdr, |
---|
841 | 818 | void *result) |
---|
842 | 819 | { |
---|
843 | | - return decode_attrstat(xdr, result, NULL); |
---|
| 820 | + return decode_attrstat(xdr, result, NULL, rpc_rqst_userns(req)); |
---|
844 | 821 | } |
---|
845 | 822 | |
---|
846 | 823 | static int nfs2_xdr_dec_diropres(struct rpc_rqst *req, struct xdr_stream *xdr, |
---|
847 | 824 | void *result) |
---|
848 | 825 | { |
---|
849 | | - return decode_diropres(xdr, result); |
---|
| 826 | + return decode_diropres(xdr, result, rpc_rqst_userns(req)); |
---|
850 | 827 | } |
---|
851 | 828 | |
---|
852 | 829 | /* |
---|
.. | .. |
---|
901 | 878 | result->op_status = status; |
---|
902 | 879 | if (status != NFS_OK) |
---|
903 | 880 | goto out_default; |
---|
904 | | - error = decode_fattr(xdr, result->fattr); |
---|
| 881 | + error = decode_fattr(xdr, result->fattr, rpc_rqst_userns(req)); |
---|
905 | 882 | if (unlikely(error)) |
---|
906 | 883 | goto out; |
---|
907 | 884 | error = decode_nfsdata(xdr, result); |
---|
.. | .. |
---|
918 | 895 | |
---|
919 | 896 | /* All NFSv2 writes are "file sync" writes */ |
---|
920 | 897 | result->verf->committed = NFS_FILE_SYNC; |
---|
921 | | - return decode_attrstat(xdr, result->fattr, &result->op_status); |
---|
| 898 | + return decode_attrstat(xdr, result->fattr, &result->op_status, |
---|
| 899 | + rpc_rqst_userns(req)); |
---|
922 | 900 | } |
---|
923 | 901 | |
---|
924 | 902 | /** |
---|
.. | .. |
---|
951 | 929 | int error; |
---|
952 | 930 | |
---|
953 | 931 | p = xdr_inline_decode(xdr, 4); |
---|
954 | | - if (unlikely(p == NULL)) |
---|
955 | | - goto out_overflow; |
---|
| 932 | + if (unlikely(!p)) |
---|
| 933 | + return -EAGAIN; |
---|
956 | 934 | if (*p++ == xdr_zero) { |
---|
957 | 935 | p = xdr_inline_decode(xdr, 4); |
---|
958 | | - if (unlikely(p == NULL)) |
---|
959 | | - goto out_overflow; |
---|
| 936 | + if (unlikely(!p)) |
---|
| 937 | + return -EAGAIN; |
---|
960 | 938 | if (*p++ == xdr_zero) |
---|
961 | 939 | return -EAGAIN; |
---|
962 | 940 | entry->eof = 1; |
---|
.. | .. |
---|
964 | 942 | } |
---|
965 | 943 | |
---|
966 | 944 | p = xdr_inline_decode(xdr, 4); |
---|
967 | | - if (unlikely(p == NULL)) |
---|
968 | | - goto out_overflow; |
---|
| 945 | + if (unlikely(!p)) |
---|
| 946 | + return -EAGAIN; |
---|
969 | 947 | entry->ino = be32_to_cpup(p); |
---|
970 | 948 | |
---|
971 | 949 | error = decode_filename_inline(xdr, &entry->name, &entry->len); |
---|
972 | 950 | if (unlikely(error)) |
---|
973 | | - return error; |
---|
| 951 | + return error == -ENAMETOOLONG ? -ENAMETOOLONG : -EAGAIN; |
---|
974 | 952 | |
---|
975 | 953 | /* |
---|
976 | 954 | * The type (size and byte order) of nfscookie isn't defined in |
---|
.. | .. |
---|
978 | 956 | */ |
---|
979 | 957 | entry->prev_cookie = entry->cookie; |
---|
980 | 958 | p = xdr_inline_decode(xdr, 4); |
---|
981 | | - if (unlikely(p == NULL)) |
---|
982 | | - goto out_overflow; |
---|
| 959 | + if (unlikely(!p)) |
---|
| 960 | + return -EAGAIN; |
---|
983 | 961 | entry->cookie = be32_to_cpup(p); |
---|
984 | 962 | |
---|
985 | 963 | entry->d_type = DT_UNKNOWN; |
---|
986 | 964 | |
---|
987 | 965 | return 0; |
---|
988 | | - |
---|
989 | | -out_overflow: |
---|
990 | | - print_overflow_msg(__func__, xdr); |
---|
991 | | - return -EAGAIN; |
---|
992 | 966 | } |
---|
993 | 967 | |
---|
994 | 968 | /* |
---|
.. | .. |
---|
1052 | 1026 | __be32 *p; |
---|
1053 | 1027 | |
---|
1054 | 1028 | p = xdr_inline_decode(xdr, NFS_info_sz << 2); |
---|
1055 | | - if (unlikely(p == NULL)) |
---|
1056 | | - goto out_overflow; |
---|
| 1029 | + if (unlikely(!p)) |
---|
| 1030 | + return -EIO; |
---|
1057 | 1031 | result->tsize = be32_to_cpup(p++); |
---|
1058 | 1032 | result->bsize = be32_to_cpup(p++); |
---|
1059 | 1033 | result->blocks = be32_to_cpup(p++); |
---|
1060 | 1034 | result->bfree = be32_to_cpup(p++); |
---|
1061 | 1035 | result->bavail = be32_to_cpup(p); |
---|
1062 | 1036 | return 0; |
---|
1063 | | -out_overflow: |
---|
1064 | | - print_overflow_msg(__func__, xdr); |
---|
1065 | | - return -EIO; |
---|
1066 | 1037 | } |
---|
1067 | 1038 | |
---|
1068 | 1039 | static int nfs2_xdr_dec_statfsres(struct rpc_rqst *req, struct xdr_stream *xdr, |
---|