| .. | .. |
|---|
| 54 | 54 | #include <linux/nfs_fs.h> |
|---|
| 55 | 55 | |
|---|
| 56 | 56 | #include "nfs4_fs.h" |
|---|
| 57 | +#include "nfs4trace.h" |
|---|
| 57 | 58 | #include "internal.h" |
|---|
| 58 | 59 | #include "nfs4idmap.h" |
|---|
| 59 | 60 | #include "nfs4session.h" |
|---|
| .. | .. |
|---|
| 214 | 215 | nfs4_fattr_bitmap_maxsz) |
|---|
| 215 | 216 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ |
|---|
| 216 | 217 | encode_stateid_maxsz + 3) |
|---|
| 217 | | -#define decode_read_maxsz (op_decode_hdr_maxsz + 2) |
|---|
| 218 | +#define decode_read_maxsz (op_decode_hdr_maxsz + 2 + 1) |
|---|
| 218 | 219 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
|---|
| 219 | 220 | 2 + encode_verifier_maxsz + 5 + \ |
|---|
| 220 | 221 | nfs4_label_maxsz) |
|---|
| 221 | 222 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
|---|
| 222 | | - decode_verifier_maxsz) |
|---|
| 223 | + decode_verifier_maxsz + 1) |
|---|
| 223 | 224 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
|---|
| 224 | | -#define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) |
|---|
| 225 | +#define decode_readlink_maxsz (op_decode_hdr_maxsz + 1 + 1) |
|---|
| 225 | 226 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
|---|
| 226 | 227 | encode_stateid_maxsz + 4) |
|---|
| 227 | 228 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ |
|---|
| .. | .. |
|---|
| 283 | 284 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) |
|---|
| 284 | 285 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
|---|
| 285 | 286 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ |
|---|
| 286 | | - nfs4_fattr_bitmap_maxsz + 1) |
|---|
| 287 | + nfs4_fattr_bitmap_maxsz + 1 + 1) |
|---|
| 287 | 288 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
|---|
| 288 | 289 | encode_stateid_maxsz + 3) |
|---|
| 289 | 290 | #define decode_setacl_maxsz (decode_setattr_maxsz) |
|---|
| 290 | 291 | #define encode_fs_locations_maxsz \ |
|---|
| 291 | 292 | (encode_getattr_maxsz) |
|---|
| 292 | 293 | #define decode_fs_locations_maxsz \ |
|---|
| 293 | | - (0) |
|---|
| 294 | + (1) |
|---|
| 294 | 295 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
|---|
| 295 | 296 | #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4)) |
|---|
| 296 | 297 | |
|---|
| .. | .. |
|---|
| 391 | 392 | 1 /* opaque devaddr4 length */ + \ |
|---|
| 392 | 393 | /* devaddr4 payload is read into page */ \ |
|---|
| 393 | 394 | 1 /* notification bitmap length */ + \ |
|---|
| 394 | | - 1 /* notification bitmap, word 0 */) |
|---|
| 395 | + 1 /* notification bitmap, word 0 */ + \ |
|---|
| 396 | + 1 /* possible XDR padding */) |
|---|
| 395 | 397 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
|---|
| 396 | 398 | encode_stateid_maxsz) |
|---|
| 397 | 399 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ |
|---|
| 398 | 400 | decode_stateid_maxsz + \ |
|---|
| 399 | | - XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) |
|---|
| 401 | + XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE) + 1) |
|---|
| 400 | 402 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
|---|
| 401 | 403 | 2 /* offset */ + \ |
|---|
| 402 | 404 | 2 /* length */ + \ |
|---|
| .. | .. |
|---|
| 835 | 837 | #define NFS4_dec_sequence_sz \ |
|---|
| 836 | 838 | (compound_decode_hdr_maxsz + \ |
|---|
| 837 | 839 | decode_sequence_maxsz) |
|---|
| 840 | +#endif |
|---|
| 838 | 841 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
|---|
| 839 | 842 | encode_sequence_maxsz + \ |
|---|
| 840 | 843 | encode_putrootfh_maxsz + \ |
|---|
| .. | .. |
|---|
| 843 | 846 | decode_sequence_maxsz + \ |
|---|
| 844 | 847 | decode_putrootfh_maxsz + \ |
|---|
| 845 | 848 | decode_fsinfo_maxsz) |
|---|
| 849 | +#if defined(CONFIG_NFS_V4_1) |
|---|
| 846 | 850 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
|---|
| 847 | 851 | encode_sequence_maxsz + \ |
|---|
| 848 | 852 | encode_reclaim_complete_maxsz) |
|---|
| .. | .. |
|---|
| 1015 | 1019 | struct compound_hdr *hdr) |
|---|
| 1016 | 1020 | { |
|---|
| 1017 | 1021 | __be32 *p; |
|---|
| 1018 | | - struct rpc_auth *auth = req->rq_cred->cr_auth; |
|---|
| 1019 | 1022 | |
|---|
| 1020 | 1023 | /* initialize running count of expected bytes in reply. |
|---|
| 1021 | 1024 | * NOTE: the replied tag SHOULD be the same is the one sent, |
|---|
| 1022 | 1025 | * but this is not required as a MUST for the server to do so. */ |
|---|
| 1023 | | - hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
|---|
| 1026 | + hdr->replen = 3 + hdr->taglen; |
|---|
| 1024 | 1027 | |
|---|
| 1025 | 1028 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); |
|---|
| 1026 | 1029 | encode_string(xdr, hdr->taglen, hdr->tag); |
|---|
| .. | .. |
|---|
| 1056 | 1059 | } |
|---|
| 1057 | 1060 | |
|---|
| 1058 | 1061 | static __be32 * |
|---|
| 1059 | | -xdr_encode_nfstime4(__be32 *p, const struct timespec *t) |
|---|
| 1062 | +xdr_encode_nfstime4(__be32 *p, const struct timespec64 *t) |
|---|
| 1060 | 1063 | { |
|---|
| 1061 | | - p = xdr_encode_hyper(p, (__s64)t->tv_sec); |
|---|
| 1064 | + p = xdr_encode_hyper(p, t->tv_sec); |
|---|
| 1062 | 1065 | *p++ = cpu_to_be32(t->tv_nsec); |
|---|
| 1063 | 1066 | return p; |
|---|
| 1064 | 1067 | } |
|---|
| .. | .. |
|---|
| 1069 | 1072 | const struct nfs_server *server, |
|---|
| 1070 | 1073 | const uint32_t attrmask[]) |
|---|
| 1071 | 1074 | { |
|---|
| 1072 | | - struct timespec ts; |
|---|
| 1073 | 1075 | char owner_name[IDMAP_NAMESZ]; |
|---|
| 1074 | 1076 | char owner_group[IDMAP_NAMESZ]; |
|---|
| 1075 | 1077 | int owner_namelen = 0; |
|---|
| .. | .. |
|---|
| 1158 | 1160 | if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
|---|
| 1159 | 1161 | if (iap->ia_valid & ATTR_ATIME_SET) { |
|---|
| 1160 | 1162 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
|---|
| 1161 | | - ts = timespec64_to_timespec(iap->ia_atime); |
|---|
| 1162 | | - p = xdr_encode_nfstime4(p, &ts); |
|---|
| 1163 | + p = xdr_encode_nfstime4(p, &iap->ia_atime); |
|---|
| 1163 | 1164 | } else |
|---|
| 1164 | 1165 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
|---|
| 1165 | 1166 | } |
|---|
| 1166 | 1167 | if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
|---|
| 1167 | 1168 | if (iap->ia_valid & ATTR_MTIME_SET) { |
|---|
| 1168 | 1169 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
|---|
| 1169 | | - ts = timespec64_to_timespec(iap->ia_mtime); |
|---|
| 1170 | | - p = xdr_encode_nfstime4(p, &ts); |
|---|
| 1170 | + p = xdr_encode_nfstime4(p, &iap->ia_mtime); |
|---|
| 1171 | 1171 | } else |
|---|
| 1172 | 1172 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
|---|
| 1173 | 1173 | } |
|---|
| .. | .. |
|---|
| 2340 | 2340 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
|---|
| 2341 | 2341 | if (args->lg_args) { |
|---|
| 2342 | 2342 | encode_layoutget(xdr, args->lg_args, &hdr); |
|---|
| 2343 | | - xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
|---|
| 2344 | | - args->lg_args->layout.pages, |
|---|
| 2345 | | - 0, args->lg_args->layout.pglen); |
|---|
| 2343 | + rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0, |
|---|
| 2344 | + args->lg_args->layout.pglen, |
|---|
| 2345 | + hdr.replen); |
|---|
| 2346 | 2346 | } |
|---|
| 2347 | 2347 | encode_nops(&hdr); |
|---|
| 2348 | 2348 | } |
|---|
| .. | .. |
|---|
| 2386 | 2386 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
|---|
| 2387 | 2387 | if (args->lg_args) { |
|---|
| 2388 | 2388 | encode_layoutget(xdr, args->lg_args, &hdr); |
|---|
| 2389 | | - xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
|---|
| 2390 | | - args->lg_args->layout.pages, |
|---|
| 2391 | | - 0, args->lg_args->layout.pglen); |
|---|
| 2389 | + rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0, |
|---|
| 2390 | + args->lg_args->layout.pglen, |
|---|
| 2391 | + hdr.replen); |
|---|
| 2392 | 2392 | } |
|---|
| 2393 | 2393 | encode_nops(&hdr); |
|---|
| 2394 | 2394 | } |
|---|
| .. | .. |
|---|
| 2498 | 2498 | encode_putfh(xdr, args->fh, &hdr); |
|---|
| 2499 | 2499 | encode_readlink(xdr, args, req, &hdr); |
|---|
| 2500 | 2500 | |
|---|
| 2501 | | - xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
|---|
| 2502 | | - args->pgbase, args->pglen); |
|---|
| 2501 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, |
|---|
| 2502 | + args->pglen, hdr.replen); |
|---|
| 2503 | 2503 | encode_nops(&hdr); |
|---|
| 2504 | 2504 | } |
|---|
| 2505 | 2505 | |
|---|
| .. | .. |
|---|
| 2519 | 2519 | encode_putfh(xdr, args->fh, &hdr); |
|---|
| 2520 | 2520 | encode_readdir(xdr, args, req, &hdr); |
|---|
| 2521 | 2521 | |
|---|
| 2522 | | - xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
|---|
| 2523 | | - args->pgbase, args->count); |
|---|
| 2524 | | - dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
|---|
| 2525 | | - __func__, hdr.replen << 2, args->pages, |
|---|
| 2526 | | - args->pgbase, args->count); |
|---|
| 2522 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, |
|---|
| 2523 | + args->count, hdr.replen); |
|---|
| 2527 | 2524 | encode_nops(&hdr); |
|---|
| 2528 | 2525 | } |
|---|
| 2529 | 2526 | |
|---|
| .. | .. |
|---|
| 2543 | 2540 | encode_putfh(xdr, args->fh, &hdr); |
|---|
| 2544 | 2541 | encode_read(xdr, args, &hdr); |
|---|
| 2545 | 2542 | |
|---|
| 2546 | | - xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
|---|
| 2547 | | - args->pages, args->pgbase, args->count); |
|---|
| 2543 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, |
|---|
| 2544 | + args->count, hdr.replen); |
|---|
| 2548 | 2545 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
|---|
| 2549 | 2546 | encode_nops(&hdr); |
|---|
| 2550 | 2547 | } |
|---|
| .. | .. |
|---|
| 2590 | 2587 | encode_getattr(xdr, nfs4_acl_bitmap, NULL, |
|---|
| 2591 | 2588 | ARRAY_SIZE(nfs4_acl_bitmap), &hdr); |
|---|
| 2592 | 2589 | |
|---|
| 2593 | | - xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
|---|
| 2594 | | - args->acl_pages, 0, args->acl_len); |
|---|
| 2595 | | - |
|---|
| 2590 | + rpc_prepare_reply_pages(req, args->acl_pages, 0, |
|---|
| 2591 | + args->acl_len, replen + 1); |
|---|
| 2596 | 2592 | encode_nops(&hdr); |
|---|
| 2597 | 2593 | } |
|---|
| 2598 | 2594 | |
|---|
| .. | .. |
|---|
| 2813 | 2809 | encode_fs_locations(xdr, args->bitmask, &hdr); |
|---|
| 2814 | 2810 | } |
|---|
| 2815 | 2811 | |
|---|
| 2816 | | - /* Set up reply kvec to capture returned fs_locations array. */ |
|---|
| 2817 | | - xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
|---|
| 2818 | | - (struct page **)&args->page, 0, PAGE_SIZE); |
|---|
| 2812 | + rpc_prepare_reply_pages(req, (struct page **)&args->page, 0, |
|---|
| 2813 | + PAGE_SIZE, replen + 1); |
|---|
| 2819 | 2814 | encode_nops(&hdr); |
|---|
| 2820 | 2815 | } |
|---|
| 2821 | 2816 | |
|---|
| .. | .. |
|---|
| 2961 | 2956 | encode_nops(&hdr); |
|---|
| 2962 | 2957 | } |
|---|
| 2963 | 2958 | |
|---|
| 2959 | +#endif |
|---|
| 2960 | + |
|---|
| 2964 | 2961 | /* |
|---|
| 2965 | 2962 | * a GET_LEASE_TIME request |
|---|
| 2966 | 2963 | */ |
|---|
| .. | .. |
|---|
| 2980 | 2977 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
|---|
| 2981 | 2978 | encode_nops(&hdr); |
|---|
| 2982 | 2979 | } |
|---|
| 2980 | + |
|---|
| 2981 | +#ifdef CONFIG_NFS_V4_1 |
|---|
| 2983 | 2982 | |
|---|
| 2984 | 2983 | /* |
|---|
| 2985 | 2984 | * a RECLAIM_COMPLETE request |
|---|
| .. | .. |
|---|
| 3010 | 3009 | struct compound_hdr hdr = { |
|---|
| 3011 | 3010 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
|---|
| 3012 | 3011 | }; |
|---|
| 3012 | + uint32_t replen; |
|---|
| 3013 | 3013 | |
|---|
| 3014 | 3014 | encode_compound_hdr(xdr, req, &hdr); |
|---|
| 3015 | 3015 | encode_sequence(xdr, &args->seq_args, &hdr); |
|---|
| 3016 | + |
|---|
| 3017 | + replen = hdr.replen + op_decode_hdr_maxsz; |
|---|
| 3018 | + |
|---|
| 3016 | 3019 | encode_getdeviceinfo(xdr, args, &hdr); |
|---|
| 3017 | 3020 | |
|---|
| 3018 | | - /* set up reply kvec. Subtract notification bitmap max size (2) |
|---|
| 3019 | | - * so that notification bitmap is put in xdr_buf tail */ |
|---|
| 3020 | | - xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, |
|---|
| 3021 | | - args->pdev->pages, args->pdev->pgbase, |
|---|
| 3022 | | - args->pdev->pglen); |
|---|
| 3023 | | - |
|---|
| 3021 | + /* set up reply kvec. device_addr4 opaque data is read into the |
|---|
| 3022 | + * pages */ |
|---|
| 3023 | + rpc_prepare_reply_pages(req, args->pdev->pages, args->pdev->pgbase, |
|---|
| 3024 | + args->pdev->pglen, replen + 2 + 1); |
|---|
| 3024 | 3025 | encode_nops(&hdr); |
|---|
| 3025 | 3026 | } |
|---|
| 3026 | 3027 | |
|---|
| .. | .. |
|---|
| 3041 | 3042 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
|---|
| 3042 | 3043 | encode_layoutget(xdr, args, &hdr); |
|---|
| 3043 | 3044 | |
|---|
| 3044 | | - xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
|---|
| 3045 | | - args->layout.pages, 0, args->layout.pglen); |
|---|
| 3046 | | - |
|---|
| 3045 | + rpc_prepare_reply_pages(req, args->layout.pages, 0, |
|---|
| 3046 | + args->layout.pglen, hdr.replen); |
|---|
| 3047 | 3047 | encode_nops(&hdr); |
|---|
| 3048 | 3048 | } |
|---|
| 3049 | 3049 | |
|---|
| .. | .. |
|---|
| 3144 | 3144 | } |
|---|
| 3145 | 3145 | #endif /* CONFIG_NFS_V4_1 */ |
|---|
| 3146 | 3146 | |
|---|
| 3147 | | -static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
|---|
| 3148 | | -{ |
|---|
| 3149 | | - dprintk("nfs: %s: prematurely hit end of receive buffer. " |
|---|
| 3150 | | - "Remaining buffer length is %tu words.\n", |
|---|
| 3151 | | - func, xdr->end - xdr->p); |
|---|
| 3152 | | -} |
|---|
| 3153 | | - |
|---|
| 3154 | 3147 | static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string) |
|---|
| 3155 | 3148 | { |
|---|
| 3156 | 3149 | ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string, |
|---|
| 3157 | 3150 | NFS4_OPAQUE_LIMIT); |
|---|
| 3158 | | - if (unlikely(ret < 0)) { |
|---|
| 3159 | | - if (ret == -EBADMSG) |
|---|
| 3160 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3151 | + if (unlikely(ret < 0)) |
|---|
| 3161 | 3152 | return -EIO; |
|---|
| 3162 | | - } |
|---|
| 3163 | 3153 | *len = ret; |
|---|
| 3164 | 3154 | return 0; |
|---|
| 3165 | 3155 | } |
|---|
| .. | .. |
|---|
| 3170 | 3160 | |
|---|
| 3171 | 3161 | p = xdr_inline_decode(xdr, 8); |
|---|
| 3172 | 3162 | if (unlikely(!p)) |
|---|
| 3173 | | - goto out_overflow; |
|---|
| 3163 | + return -EIO; |
|---|
| 3174 | 3164 | hdr->status = be32_to_cpup(p++); |
|---|
| 3175 | 3165 | hdr->taglen = be32_to_cpup(p); |
|---|
| 3176 | 3166 | |
|---|
| 3177 | 3167 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
|---|
| 3178 | 3168 | if (unlikely(!p)) |
|---|
| 3179 | | - goto out_overflow; |
|---|
| 3169 | + return -EIO; |
|---|
| 3180 | 3170 | hdr->tag = (char *)p; |
|---|
| 3181 | 3171 | p += XDR_QUADLEN(hdr->taglen); |
|---|
| 3182 | 3172 | hdr->nops = be32_to_cpup(p); |
|---|
| 3183 | 3173 | if (unlikely(hdr->nops < 1)) |
|---|
| 3184 | 3174 | return nfs4_stat_to_errno(hdr->status); |
|---|
| 3185 | 3175 | return 0; |
|---|
| 3186 | | -out_overflow: |
|---|
| 3187 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3188 | | - return -EIO; |
|---|
| 3189 | 3176 | } |
|---|
| 3190 | 3177 | |
|---|
| 3191 | 3178 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, |
|---|
| .. | .. |
|---|
| 3201 | 3188 | opnum = be32_to_cpup(p++); |
|---|
| 3202 | 3189 | if (unlikely(opnum != expected)) |
|---|
| 3203 | 3190 | goto out_bad_operation; |
|---|
| 3191 | + if (unlikely(*p != cpu_to_be32(NFS_OK))) |
|---|
| 3192 | + goto out_status; |
|---|
| 3193 | + *nfs_retval = 0; |
|---|
| 3194 | + return true; |
|---|
| 3195 | +out_status: |
|---|
| 3204 | 3196 | nfserr = be32_to_cpup(p); |
|---|
| 3205 | | - if (nfserr == NFS_OK) |
|---|
| 3206 | | - *nfs_retval = 0; |
|---|
| 3207 | | - else |
|---|
| 3208 | | - *nfs_retval = nfs4_stat_to_errno(nfserr); |
|---|
| 3197 | + trace_nfs4_xdr_status(xdr, opnum, nfserr); |
|---|
| 3198 | + *nfs_retval = nfs4_stat_to_errno(nfserr); |
|---|
| 3209 | 3199 | return true; |
|---|
| 3210 | 3200 | out_bad_operation: |
|---|
| 3211 | 3201 | dprintk("nfs: Server returned operation" |
|---|
| .. | .. |
|---|
| 3214 | 3204 | *nfs_retval = -EREMOTEIO; |
|---|
| 3215 | 3205 | return false; |
|---|
| 3216 | 3206 | out_overflow: |
|---|
| 3217 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3218 | 3207 | *nfs_retval = -EIO; |
|---|
| 3219 | 3208 | return false; |
|---|
| 3220 | 3209 | } |
|---|
| .. | .. |
|---|
| 3235 | 3224 | char *str; |
|---|
| 3236 | 3225 | |
|---|
| 3237 | 3226 | p = xdr_inline_decode(xdr, 12); |
|---|
| 3238 | | - if (likely(p)) |
|---|
| 3239 | | - return decode_opaque_inline(xdr, &strlen, &str); |
|---|
| 3240 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3241 | | - return -EIO; |
|---|
| 3227 | + if (unlikely(!p)) |
|---|
| 3228 | + return -EIO; |
|---|
| 3229 | + return decode_opaque_inline(xdr, &strlen, &str); |
|---|
| 3242 | 3230 | } |
|---|
| 3243 | 3231 | |
|---|
| 3244 | 3232 | static ssize_t |
|---|
| .. | .. |
|---|
| 3249 | 3237 | ret = xdr_stream_decode_uint32_array(xdr, bitmap, sz); |
|---|
| 3250 | 3238 | if (likely(ret >= 0)) |
|---|
| 3251 | 3239 | return ret; |
|---|
| 3252 | | - if (ret == -EMSGSIZE) |
|---|
| 3253 | | - return sz; |
|---|
| 3254 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3255 | | - return -EIO; |
|---|
| 3240 | + if (ret != -EMSGSIZE) |
|---|
| 3241 | + return -EIO; |
|---|
| 3242 | + return sz; |
|---|
| 3256 | 3243 | } |
|---|
| 3257 | 3244 | |
|---|
| 3258 | 3245 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
|---|
| .. | .. |
|---|
| 3268 | 3255 | |
|---|
| 3269 | 3256 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3270 | 3257 | if (unlikely(!p)) |
|---|
| 3271 | | - goto out_overflow; |
|---|
| 3258 | + return -EIO; |
|---|
| 3272 | 3259 | *attrlen = be32_to_cpup(p); |
|---|
| 3273 | 3260 | *savep = xdr_stream_pos(xdr); |
|---|
| 3274 | 3261 | return 0; |
|---|
| 3275 | | -out_overflow: |
|---|
| 3276 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3277 | | - return -EIO; |
|---|
| 3278 | 3262 | } |
|---|
| 3279 | 3263 | |
|---|
| 3280 | 3264 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
|---|
| .. | .. |
|---|
| 3303 | 3287 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
|---|
| 3304 | 3288 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3305 | 3289 | if (unlikely(!p)) |
|---|
| 3306 | | - goto out_overflow; |
|---|
| 3290 | + return -EIO; |
|---|
| 3307 | 3291 | *type = be32_to_cpup(p); |
|---|
| 3308 | 3292 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
|---|
| 3309 | 3293 | dprintk("%s: bad type %d\n", __func__, *type); |
|---|
| .. | .. |
|---|
| 3314 | 3298 | } |
|---|
| 3315 | 3299 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
|---|
| 3316 | 3300 | return ret; |
|---|
| 3317 | | -out_overflow: |
|---|
| 3318 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3319 | | - return -EIO; |
|---|
| 3320 | 3301 | } |
|---|
| 3321 | 3302 | |
|---|
| 3322 | 3303 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
|---|
| .. | .. |
|---|
| 3330 | 3311 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
|---|
| 3331 | 3312 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3332 | 3313 | if (unlikely(!p)) |
|---|
| 3333 | | - goto out_overflow; |
|---|
| 3314 | + return -EIO; |
|---|
| 3334 | 3315 | *type = be32_to_cpup(p); |
|---|
| 3335 | 3316 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
|---|
| 3336 | 3317 | } |
|---|
| 3337 | 3318 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
|---|
| 3338 | 3319 | return 0; |
|---|
| 3339 | | -out_overflow: |
|---|
| 3340 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3341 | | - return -EIO; |
|---|
| 3342 | 3320 | } |
|---|
| 3343 | 3321 | |
|---|
| 3344 | 3322 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
|---|
| .. | .. |
|---|
| 3352 | 3330 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
|---|
| 3353 | 3331 | p = xdr_inline_decode(xdr, 8); |
|---|
| 3354 | 3332 | if (unlikely(!p)) |
|---|
| 3355 | | - goto out_overflow; |
|---|
| 3333 | + return -EIO; |
|---|
| 3356 | 3334 | xdr_decode_hyper(p, change); |
|---|
| 3357 | 3335 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
|---|
| 3358 | 3336 | ret = NFS_ATTR_FATTR_CHANGE; |
|---|
| .. | .. |
|---|
| 3360 | 3338 | dprintk("%s: change attribute=%Lu\n", __func__, |
|---|
| 3361 | 3339 | (unsigned long long)*change); |
|---|
| 3362 | 3340 | return ret; |
|---|
| 3363 | | -out_overflow: |
|---|
| 3364 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3365 | | - return -EIO; |
|---|
| 3366 | 3341 | } |
|---|
| 3367 | 3342 | |
|---|
| 3368 | 3343 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
|---|
| .. | .. |
|---|
| 3376 | 3351 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
|---|
| 3377 | 3352 | p = xdr_inline_decode(xdr, 8); |
|---|
| 3378 | 3353 | if (unlikely(!p)) |
|---|
| 3379 | | - goto out_overflow; |
|---|
| 3354 | + return -EIO; |
|---|
| 3380 | 3355 | xdr_decode_hyper(p, size); |
|---|
| 3381 | 3356 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
|---|
| 3382 | 3357 | ret = NFS_ATTR_FATTR_SIZE; |
|---|
| 3383 | 3358 | } |
|---|
| 3384 | 3359 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
|---|
| 3385 | 3360 | return ret; |
|---|
| 3386 | | -out_overflow: |
|---|
| 3387 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3388 | | - return -EIO; |
|---|
| 3389 | 3361 | } |
|---|
| 3390 | 3362 | |
|---|
| 3391 | 3363 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
|---|
| .. | .. |
|---|
| 3398 | 3370 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
|---|
| 3399 | 3371 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3400 | 3372 | if (unlikely(!p)) |
|---|
| 3401 | | - goto out_overflow; |
|---|
| 3373 | + return -EIO; |
|---|
| 3402 | 3374 | *res = be32_to_cpup(p); |
|---|
| 3403 | 3375 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
|---|
| 3404 | 3376 | } |
|---|
| 3405 | 3377 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
|---|
| 3406 | 3378 | return 0; |
|---|
| 3407 | | -out_overflow: |
|---|
| 3408 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3409 | | - return -EIO; |
|---|
| 3410 | 3379 | } |
|---|
| 3411 | 3380 | |
|---|
| 3412 | 3381 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
|---|
| .. | .. |
|---|
| 3419 | 3388 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
|---|
| 3420 | 3389 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3421 | 3390 | if (unlikely(!p)) |
|---|
| 3422 | | - goto out_overflow; |
|---|
| 3391 | + return -EIO; |
|---|
| 3423 | 3392 | *res = be32_to_cpup(p); |
|---|
| 3424 | 3393 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
|---|
| 3425 | 3394 | } |
|---|
| 3426 | 3395 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
|---|
| 3427 | 3396 | return 0; |
|---|
| 3428 | | -out_overflow: |
|---|
| 3429 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3430 | | - return -EIO; |
|---|
| 3431 | 3397 | } |
|---|
| 3432 | 3398 | |
|---|
| 3433 | 3399 | static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid) |
|---|
| .. | .. |
|---|
| 3442 | 3408 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
|---|
| 3443 | 3409 | p = xdr_inline_decode(xdr, 16); |
|---|
| 3444 | 3410 | if (unlikely(!p)) |
|---|
| 3445 | | - goto out_overflow; |
|---|
| 3411 | + return -EIO; |
|---|
| 3446 | 3412 | p = xdr_decode_hyper(p, &fsid->major); |
|---|
| 3447 | 3413 | xdr_decode_hyper(p, &fsid->minor); |
|---|
| 3448 | 3414 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
|---|
| .. | .. |
|---|
| 3452 | 3418 | (unsigned long long)fsid->major, |
|---|
| 3453 | 3419 | (unsigned long long)fsid->minor); |
|---|
| 3454 | 3420 | return ret; |
|---|
| 3455 | | -out_overflow: |
|---|
| 3456 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3457 | | - return -EIO; |
|---|
| 3458 | 3421 | } |
|---|
| 3459 | 3422 | |
|---|
| 3460 | 3423 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
|---|
| .. | .. |
|---|
| 3467 | 3430 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
|---|
| 3468 | 3431 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3469 | 3432 | if (unlikely(!p)) |
|---|
| 3470 | | - goto out_overflow; |
|---|
| 3433 | + return -EIO; |
|---|
| 3471 | 3434 | *res = be32_to_cpup(p); |
|---|
| 3472 | 3435 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
|---|
| 3473 | 3436 | } |
|---|
| 3474 | | - dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
|---|
| 3437 | + dprintk("%s: lease time=%u\n", __func__, (unsigned int)*res); |
|---|
| 3475 | 3438 | return 0; |
|---|
| 3476 | | -out_overflow: |
|---|
| 3477 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3478 | | - return -EIO; |
|---|
| 3479 | 3439 | } |
|---|
| 3480 | 3440 | |
|---|
| 3481 | 3441 | static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res) |
|---|
| .. | .. |
|---|
| 3487 | 3447 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
|---|
| 3488 | 3448 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3489 | 3449 | if (unlikely(!p)) |
|---|
| 3490 | | - goto out_overflow; |
|---|
| 3450 | + return -EIO; |
|---|
| 3491 | 3451 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
|---|
| 3492 | 3452 | *res = -be32_to_cpup(p); |
|---|
| 3493 | 3453 | } |
|---|
| 3494 | 3454 | return 0; |
|---|
| 3495 | | -out_overflow: |
|---|
| 3496 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3497 | | - return -EIO; |
|---|
| 3498 | 3455 | } |
|---|
| 3499 | 3456 | |
|---|
| 3500 | 3457 | static int decode_attr_exclcreat_supported(struct xdr_stream *xdr, |
|---|
| .. | .. |
|---|
| 3516 | 3473 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
|---|
| 3517 | 3474 | { |
|---|
| 3518 | 3475 | __be32 *p; |
|---|
| 3519 | | - int len; |
|---|
| 3476 | + u32 len; |
|---|
| 3520 | 3477 | |
|---|
| 3521 | 3478 | if (fh != NULL) |
|---|
| 3522 | 3479 | memset(fh, 0, sizeof(*fh)); |
|---|
| .. | .. |
|---|
| 3526 | 3483 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
|---|
| 3527 | 3484 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3528 | 3485 | if (unlikely(!p)) |
|---|
| 3529 | | - goto out_overflow; |
|---|
| 3486 | + return -EIO; |
|---|
| 3530 | 3487 | len = be32_to_cpup(p); |
|---|
| 3531 | 3488 | if (len > NFS4_FHSIZE) |
|---|
| 3532 | 3489 | return -EIO; |
|---|
| 3533 | 3490 | p = xdr_inline_decode(xdr, len); |
|---|
| 3534 | 3491 | if (unlikely(!p)) |
|---|
| 3535 | | - goto out_overflow; |
|---|
| 3492 | + return -EIO; |
|---|
| 3536 | 3493 | if (fh != NULL) { |
|---|
| 3537 | 3494 | memcpy(fh->data, p, len); |
|---|
| 3538 | 3495 | fh->size = len; |
|---|
| .. | .. |
|---|
| 3540 | 3497 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
|---|
| 3541 | 3498 | } |
|---|
| 3542 | 3499 | return 0; |
|---|
| 3543 | | -out_overflow: |
|---|
| 3544 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3545 | | - return -EIO; |
|---|
| 3546 | 3500 | } |
|---|
| 3547 | 3501 | |
|---|
| 3548 | 3502 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
|---|
| .. | .. |
|---|
| 3555 | 3509 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
|---|
| 3556 | 3510 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3557 | 3511 | if (unlikely(!p)) |
|---|
| 3558 | | - goto out_overflow; |
|---|
| 3512 | + return -EIO; |
|---|
| 3559 | 3513 | *res = be32_to_cpup(p); |
|---|
| 3560 | 3514 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
|---|
| 3561 | 3515 | } |
|---|
| 3562 | 3516 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
|---|
| 3563 | 3517 | return 0; |
|---|
| 3564 | | -out_overflow: |
|---|
| 3565 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3566 | | - return -EIO; |
|---|
| 3567 | 3518 | } |
|---|
| 3568 | 3519 | |
|---|
| 3569 | 3520 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
|---|
| .. | .. |
|---|
| 3577 | 3528 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
|---|
| 3578 | 3529 | p = xdr_inline_decode(xdr, 8); |
|---|
| 3579 | 3530 | if (unlikely(!p)) |
|---|
| 3580 | | - goto out_overflow; |
|---|
| 3531 | + return -EIO; |
|---|
| 3581 | 3532 | xdr_decode_hyper(p, fileid); |
|---|
| 3582 | 3533 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
|---|
| 3583 | 3534 | ret = NFS_ATTR_FATTR_FILEID; |
|---|
| 3584 | 3535 | } |
|---|
| 3585 | 3536 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
|---|
| 3586 | 3537 | return ret; |
|---|
| 3587 | | -out_overflow: |
|---|
| 3588 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3589 | | - return -EIO; |
|---|
| 3590 | 3538 | } |
|---|
| 3591 | 3539 | |
|---|
| 3592 | 3540 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
|---|
| .. | .. |
|---|
| 3600 | 3548 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
|---|
| 3601 | 3549 | p = xdr_inline_decode(xdr, 8); |
|---|
| 3602 | 3550 | if (unlikely(!p)) |
|---|
| 3603 | | - goto out_overflow; |
|---|
| 3551 | + return -EIO; |
|---|
| 3604 | 3552 | xdr_decode_hyper(p, fileid); |
|---|
| 3605 | 3553 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
|---|
| 3606 | 3554 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
|---|
| 3607 | 3555 | } |
|---|
| 3608 | 3556 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
|---|
| 3609 | 3557 | return ret; |
|---|
| 3610 | | -out_overflow: |
|---|
| 3611 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3612 | | - return -EIO; |
|---|
| 3613 | 3558 | } |
|---|
| 3614 | 3559 | |
|---|
| 3615 | 3560 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
|---|
| .. | .. |
|---|
| 3623 | 3568 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
|---|
| 3624 | 3569 | p = xdr_inline_decode(xdr, 8); |
|---|
| 3625 | 3570 | if (unlikely(!p)) |
|---|
| 3626 | | - goto out_overflow; |
|---|
| 3571 | + return -EIO; |
|---|
| 3627 | 3572 | xdr_decode_hyper(p, res); |
|---|
| 3628 | 3573 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
|---|
| 3629 | 3574 | } |
|---|
| 3630 | 3575 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
|---|
| 3631 | 3576 | return status; |
|---|
| 3632 | | -out_overflow: |
|---|
| 3633 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3634 | | - return -EIO; |
|---|
| 3635 | 3577 | } |
|---|
| 3636 | 3578 | |
|---|
| 3637 | 3579 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
|---|
| .. | .. |
|---|
| 3645 | 3587 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
|---|
| 3646 | 3588 | p = xdr_inline_decode(xdr, 8); |
|---|
| 3647 | 3589 | if (unlikely(!p)) |
|---|
| 3648 | | - goto out_overflow; |
|---|
| 3590 | + return -EIO; |
|---|
| 3649 | 3591 | xdr_decode_hyper(p, res); |
|---|
| 3650 | 3592 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
|---|
| 3651 | 3593 | } |
|---|
| 3652 | 3594 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
|---|
| 3653 | 3595 | return status; |
|---|
| 3654 | | -out_overflow: |
|---|
| 3655 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3656 | | - return -EIO; |
|---|
| 3657 | 3596 | } |
|---|
| 3658 | 3597 | |
|---|
| 3659 | 3598 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
|---|
| .. | .. |
|---|
| 3667 | 3606 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
|---|
| 3668 | 3607 | p = xdr_inline_decode(xdr, 8); |
|---|
| 3669 | 3608 | if (unlikely(!p)) |
|---|
| 3670 | | - goto out_overflow; |
|---|
| 3609 | + return -EIO; |
|---|
| 3671 | 3610 | xdr_decode_hyper(p, res); |
|---|
| 3672 | 3611 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
|---|
| 3673 | 3612 | } |
|---|
| 3674 | 3613 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
|---|
| 3675 | 3614 | return status; |
|---|
| 3676 | | -out_overflow: |
|---|
| 3677 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3678 | | - return -EIO; |
|---|
| 3679 | 3615 | } |
|---|
| 3680 | 3616 | |
|---|
| 3681 | 3617 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
|---|
| .. | .. |
|---|
| 3686 | 3622 | |
|---|
| 3687 | 3623 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3688 | 3624 | if (unlikely(!p)) |
|---|
| 3689 | | - goto out_overflow; |
|---|
| 3625 | + return -EIO; |
|---|
| 3690 | 3626 | n = be32_to_cpup(p); |
|---|
| 3691 | 3627 | if (n == 0) |
|---|
| 3692 | 3628 | goto root_path; |
|---|
| .. | .. |
|---|
| 3718 | 3654 | dprintk(" status %d", status); |
|---|
| 3719 | 3655 | status = -EIO; |
|---|
| 3720 | 3656 | goto out; |
|---|
| 3721 | | -out_overflow: |
|---|
| 3722 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3723 | | - return -EIO; |
|---|
| 3724 | 3657 | } |
|---|
| 3725 | 3658 | |
|---|
| 3726 | 3659 | static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res) |
|---|
| .. | .. |
|---|
| 3745 | 3678 | goto out; |
|---|
| 3746 | 3679 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3747 | 3680 | if (unlikely(!p)) |
|---|
| 3748 | | - goto out_overflow; |
|---|
| 3681 | + goto out_eio; |
|---|
| 3749 | 3682 | n = be32_to_cpup(p); |
|---|
| 3750 | 3683 | for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { |
|---|
| 3751 | 3684 | u32 m; |
|---|
| .. | .. |
|---|
| 3756 | 3689 | loc = &res->locations[res->nlocations]; |
|---|
| 3757 | 3690 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3758 | 3691 | if (unlikely(!p)) |
|---|
| 3759 | | - goto out_overflow; |
|---|
| 3692 | + goto out_eio; |
|---|
| 3760 | 3693 | m = be32_to_cpup(p); |
|---|
| 3761 | 3694 | |
|---|
| 3762 | 3695 | dprintk("%s: servers:\n", __func__); |
|---|
| .. | .. |
|---|
| 3794 | 3727 | out: |
|---|
| 3795 | 3728 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
|---|
| 3796 | 3729 | return status; |
|---|
| 3797 | | -out_overflow: |
|---|
| 3798 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3799 | 3730 | out_eio: |
|---|
| 3800 | 3731 | status = -EIO; |
|---|
| 3801 | 3732 | goto out; |
|---|
| .. | .. |
|---|
| 3812 | 3743 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
|---|
| 3813 | 3744 | p = xdr_inline_decode(xdr, 8); |
|---|
| 3814 | 3745 | if (unlikely(!p)) |
|---|
| 3815 | | - goto out_overflow; |
|---|
| 3746 | + return -EIO; |
|---|
| 3816 | 3747 | xdr_decode_hyper(p, res); |
|---|
| 3817 | 3748 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
|---|
| 3818 | 3749 | } |
|---|
| 3819 | 3750 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
|---|
| 3820 | 3751 | return status; |
|---|
| 3821 | | -out_overflow: |
|---|
| 3822 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3823 | | - return -EIO; |
|---|
| 3824 | 3752 | } |
|---|
| 3825 | 3753 | |
|---|
| 3826 | 3754 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
|---|
| .. | .. |
|---|
| 3834 | 3762 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
|---|
| 3835 | 3763 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3836 | 3764 | if (unlikely(!p)) |
|---|
| 3837 | | - goto out_overflow; |
|---|
| 3765 | + return -EIO; |
|---|
| 3838 | 3766 | *maxlink = be32_to_cpup(p); |
|---|
| 3839 | 3767 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
|---|
| 3840 | 3768 | } |
|---|
| 3841 | 3769 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
|---|
| 3842 | 3770 | return status; |
|---|
| 3843 | | -out_overflow: |
|---|
| 3844 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3845 | | - return -EIO; |
|---|
| 3846 | 3771 | } |
|---|
| 3847 | 3772 | |
|---|
| 3848 | 3773 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
|---|
| .. | .. |
|---|
| 3856 | 3781 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
|---|
| 3857 | 3782 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3858 | 3783 | if (unlikely(!p)) |
|---|
| 3859 | | - goto out_overflow; |
|---|
| 3784 | + return -EIO; |
|---|
| 3860 | 3785 | *maxname = be32_to_cpup(p); |
|---|
| 3861 | 3786 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
|---|
| 3862 | 3787 | } |
|---|
| 3863 | 3788 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
|---|
| 3864 | 3789 | return status; |
|---|
| 3865 | | -out_overflow: |
|---|
| 3866 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3867 | | - return -EIO; |
|---|
| 3868 | 3790 | } |
|---|
| 3869 | 3791 | |
|---|
| 3870 | 3792 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
|---|
| .. | .. |
|---|
| 3879 | 3801 | uint64_t maxread; |
|---|
| 3880 | 3802 | p = xdr_inline_decode(xdr, 8); |
|---|
| 3881 | 3803 | if (unlikely(!p)) |
|---|
| 3882 | | - goto out_overflow; |
|---|
| 3804 | + return -EIO; |
|---|
| 3883 | 3805 | xdr_decode_hyper(p, &maxread); |
|---|
| 3884 | 3806 | if (maxread > 0x7FFFFFFF) |
|---|
| 3885 | 3807 | maxread = 0x7FFFFFFF; |
|---|
| .. | .. |
|---|
| 3888 | 3810 | } |
|---|
| 3889 | 3811 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
|---|
| 3890 | 3812 | return status; |
|---|
| 3891 | | -out_overflow: |
|---|
| 3892 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3893 | | - return -EIO; |
|---|
| 3894 | 3813 | } |
|---|
| 3895 | 3814 | |
|---|
| 3896 | 3815 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
|---|
| .. | .. |
|---|
| 3905 | 3824 | uint64_t maxwrite; |
|---|
| 3906 | 3825 | p = xdr_inline_decode(xdr, 8); |
|---|
| 3907 | 3826 | if (unlikely(!p)) |
|---|
| 3908 | | - goto out_overflow; |
|---|
| 3827 | + return -EIO; |
|---|
| 3909 | 3828 | xdr_decode_hyper(p, &maxwrite); |
|---|
| 3910 | 3829 | if (maxwrite > 0x7FFFFFFF) |
|---|
| 3911 | 3830 | maxwrite = 0x7FFFFFFF; |
|---|
| .. | .. |
|---|
| 3914 | 3833 | } |
|---|
| 3915 | 3834 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
|---|
| 3916 | 3835 | return status; |
|---|
| 3917 | | -out_overflow: |
|---|
| 3918 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3919 | | - return -EIO; |
|---|
| 3920 | 3836 | } |
|---|
| 3921 | 3837 | |
|---|
| 3922 | 3838 | static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode) |
|---|
| .. | .. |
|---|
| 3931 | 3847 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
|---|
| 3932 | 3848 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3933 | 3849 | if (unlikely(!p)) |
|---|
| 3934 | | - goto out_overflow; |
|---|
| 3850 | + return -EIO; |
|---|
| 3935 | 3851 | tmp = be32_to_cpup(p); |
|---|
| 3936 | 3852 | *mode = tmp & ~S_IFMT; |
|---|
| 3937 | 3853 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
|---|
| .. | .. |
|---|
| 3939 | 3855 | } |
|---|
| 3940 | 3856 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
|---|
| 3941 | 3857 | return ret; |
|---|
| 3942 | | -out_overflow: |
|---|
| 3943 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3944 | | - return -EIO; |
|---|
| 3945 | 3858 | } |
|---|
| 3946 | 3859 | |
|---|
| 3947 | 3860 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
|---|
| .. | .. |
|---|
| 3955 | 3868 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
|---|
| 3956 | 3869 | p = xdr_inline_decode(xdr, 4); |
|---|
| 3957 | 3870 | if (unlikely(!p)) |
|---|
| 3958 | | - goto out_overflow; |
|---|
| 3871 | + return -EIO; |
|---|
| 3959 | 3872 | *nlink = be32_to_cpup(p); |
|---|
| 3960 | 3873 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
|---|
| 3961 | 3874 | ret = NFS_ATTR_FATTR_NLINK; |
|---|
| 3962 | 3875 | } |
|---|
| 3963 | 3876 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
|---|
| 3964 | 3877 | return ret; |
|---|
| 3965 | | -out_overflow: |
|---|
| 3966 | | - print_overflow_msg(__func__, xdr); |
|---|
| 3967 | | - return -EIO; |
|---|
| 3968 | 3878 | } |
|---|
| 3969 | 3879 | |
|---|
| 3970 | 3880 | static ssize_t decode_nfs4_string(struct xdr_stream *xdr, |
|---|
| .. | .. |
|---|
| 4009 | 3919 | return NFS_ATTR_FATTR_OWNER; |
|---|
| 4010 | 3920 | } |
|---|
| 4011 | 3921 | out: |
|---|
| 4012 | | - if (len != -EBADMSG) |
|---|
| 4013 | | - return 0; |
|---|
| 4014 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4015 | | - return -EIO; |
|---|
| 3922 | + if (len == -EBADMSG) |
|---|
| 3923 | + return -EIO; |
|---|
| 3924 | + return 0; |
|---|
| 4016 | 3925 | } |
|---|
| 4017 | 3926 | |
|---|
| 4018 | 3927 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
|---|
| .. | .. |
|---|
| 4044 | 3953 | return NFS_ATTR_FATTR_GROUP; |
|---|
| 4045 | 3954 | } |
|---|
| 4046 | 3955 | out: |
|---|
| 4047 | | - if (len != -EBADMSG) |
|---|
| 4048 | | - return 0; |
|---|
| 4049 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4050 | | - return -EIO; |
|---|
| 3956 | + if (len == -EBADMSG) |
|---|
| 3957 | + return -EIO; |
|---|
| 3958 | + return 0; |
|---|
| 4051 | 3959 | } |
|---|
| 4052 | 3960 | |
|---|
| 4053 | 3961 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
|---|
| .. | .. |
|---|
| 4064 | 3972 | |
|---|
| 4065 | 3973 | p = xdr_inline_decode(xdr, 8); |
|---|
| 4066 | 3974 | if (unlikely(!p)) |
|---|
| 4067 | | - goto out_overflow; |
|---|
| 3975 | + return -EIO; |
|---|
| 4068 | 3976 | major = be32_to_cpup(p++); |
|---|
| 4069 | 3977 | minor = be32_to_cpup(p); |
|---|
| 4070 | 3978 | tmp = MKDEV(major, minor); |
|---|
| .. | .. |
|---|
| 4075 | 3983 | } |
|---|
| 4076 | 3984 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
|---|
| 4077 | 3985 | return ret; |
|---|
| 4078 | | -out_overflow: |
|---|
| 4079 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4080 | | - return -EIO; |
|---|
| 4081 | 3986 | } |
|---|
| 4082 | 3987 | |
|---|
| 4083 | 3988 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
|---|
| .. | .. |
|---|
| 4091 | 3996 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
|---|
| 4092 | 3997 | p = xdr_inline_decode(xdr, 8); |
|---|
| 4093 | 3998 | if (unlikely(!p)) |
|---|
| 4094 | | - goto out_overflow; |
|---|
| 3999 | + return -EIO; |
|---|
| 4095 | 4000 | xdr_decode_hyper(p, res); |
|---|
| 4096 | 4001 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
|---|
| 4097 | 4002 | } |
|---|
| 4098 | 4003 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
|---|
| 4099 | 4004 | return status; |
|---|
| 4100 | | -out_overflow: |
|---|
| 4101 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4102 | | - return -EIO; |
|---|
| 4103 | 4005 | } |
|---|
| 4104 | 4006 | |
|---|
| 4105 | 4007 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
|---|
| .. | .. |
|---|
| 4113 | 4015 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
|---|
| 4114 | 4016 | p = xdr_inline_decode(xdr, 8); |
|---|
| 4115 | 4017 | if (unlikely(!p)) |
|---|
| 4116 | | - goto out_overflow; |
|---|
| 4018 | + return -EIO; |
|---|
| 4117 | 4019 | xdr_decode_hyper(p, res); |
|---|
| 4118 | 4020 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
|---|
| 4119 | 4021 | } |
|---|
| 4120 | 4022 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
|---|
| 4121 | 4023 | return status; |
|---|
| 4122 | | -out_overflow: |
|---|
| 4123 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4124 | | - return -EIO; |
|---|
| 4125 | 4024 | } |
|---|
| 4126 | 4025 | |
|---|
| 4127 | 4026 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
|---|
| .. | .. |
|---|
| 4135 | 4034 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
|---|
| 4136 | 4035 | p = xdr_inline_decode(xdr, 8); |
|---|
| 4137 | 4036 | if (unlikely(!p)) |
|---|
| 4138 | | - goto out_overflow; |
|---|
| 4037 | + return -EIO; |
|---|
| 4139 | 4038 | xdr_decode_hyper(p, res); |
|---|
| 4140 | 4039 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
|---|
| 4141 | 4040 | } |
|---|
| 4142 | 4041 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
|---|
| 4143 | 4042 | return status; |
|---|
| 4144 | | -out_overflow: |
|---|
| 4145 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4146 | | - return -EIO; |
|---|
| 4147 | 4043 | } |
|---|
| 4148 | 4044 | |
|---|
| 4149 | 4045 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
|---|
| .. | .. |
|---|
| 4157 | 4053 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
|---|
| 4158 | 4054 | p = xdr_inline_decode(xdr, 8); |
|---|
| 4159 | 4055 | if (unlikely(!p)) |
|---|
| 4160 | | - goto out_overflow; |
|---|
| 4056 | + return -EIO; |
|---|
| 4161 | 4057 | xdr_decode_hyper(p, used); |
|---|
| 4162 | 4058 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
|---|
| 4163 | 4059 | ret = NFS_ATTR_FATTR_SPACE_USED; |
|---|
| .. | .. |
|---|
| 4165 | 4061 | dprintk("%s: space used=%Lu\n", __func__, |
|---|
| 4166 | 4062 | (unsigned long long)*used); |
|---|
| 4167 | 4063 | return ret; |
|---|
| 4168 | | -out_overflow: |
|---|
| 4169 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4170 | | - return -EIO; |
|---|
| 4171 | 4064 | } |
|---|
| 4172 | 4065 | |
|---|
| 4173 | 4066 | static __be32 * |
|---|
| 4174 | | -xdr_decode_nfstime4(__be32 *p, struct timespec *t) |
|---|
| 4067 | +xdr_decode_nfstime4(__be32 *p, struct timespec64 *t) |
|---|
| 4175 | 4068 | { |
|---|
| 4176 | 4069 | __u64 sec; |
|---|
| 4177 | 4070 | |
|---|
| 4178 | 4071 | p = xdr_decode_hyper(p, &sec); |
|---|
| 4179 | | - t-> tv_sec = (time_t)sec; |
|---|
| 4072 | + t-> tv_sec = sec; |
|---|
| 4180 | 4073 | t->tv_nsec = be32_to_cpup(p++); |
|---|
| 4181 | 4074 | return p; |
|---|
| 4182 | 4075 | } |
|---|
| 4183 | 4076 | |
|---|
| 4184 | | -static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) |
|---|
| 4077 | +static int decode_attr_time(struct xdr_stream *xdr, struct timespec64 *time) |
|---|
| 4185 | 4078 | { |
|---|
| 4186 | 4079 | __be32 *p; |
|---|
| 4187 | 4080 | |
|---|
| 4188 | 4081 | p = xdr_inline_decode(xdr, nfstime4_maxsz << 2); |
|---|
| 4189 | 4082 | if (unlikely(!p)) |
|---|
| 4190 | | - goto out_overflow; |
|---|
| 4083 | + return -EIO; |
|---|
| 4191 | 4084 | xdr_decode_nfstime4(p, time); |
|---|
| 4192 | 4085 | return 0; |
|---|
| 4193 | | -out_overflow: |
|---|
| 4194 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4195 | | - return -EIO; |
|---|
| 4196 | 4086 | } |
|---|
| 4197 | 4087 | |
|---|
| 4198 | | -static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
|---|
| 4088 | +static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time) |
|---|
| 4199 | 4089 | { |
|---|
| 4200 | 4090 | int status = 0; |
|---|
| 4201 | 4091 | |
|---|
| .. | .. |
|---|
| 4209 | 4099 | status = NFS_ATTR_FATTR_ATIME; |
|---|
| 4210 | 4100 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
|---|
| 4211 | 4101 | } |
|---|
| 4212 | | - dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
|---|
| 4102 | + dprintk("%s: atime=%lld\n", __func__, time->tv_sec); |
|---|
| 4213 | 4103 | return status; |
|---|
| 4214 | 4104 | } |
|---|
| 4215 | 4105 | |
|---|
| 4216 | | -static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
|---|
| 4106 | +static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time) |
|---|
| 4217 | 4107 | { |
|---|
| 4218 | 4108 | int status = 0; |
|---|
| 4219 | 4109 | |
|---|
| .. | .. |
|---|
| 4227 | 4117 | status = NFS_ATTR_FATTR_CTIME; |
|---|
| 4228 | 4118 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
|---|
| 4229 | 4119 | } |
|---|
| 4230 | | - dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
|---|
| 4120 | + dprintk("%s: ctime=%lld\n", __func__, time->tv_sec); |
|---|
| 4231 | 4121 | return status; |
|---|
| 4232 | 4122 | } |
|---|
| 4233 | 4123 | |
|---|
| 4234 | 4124 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
|---|
| 4235 | | - struct timespec *time) |
|---|
| 4125 | + struct timespec64 *time) |
|---|
| 4236 | 4126 | { |
|---|
| 4237 | 4127 | int status = 0; |
|---|
| 4238 | 4128 | |
|---|
| .. | .. |
|---|
| 4244 | 4134 | status = decode_attr_time(xdr, time); |
|---|
| 4245 | 4135 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
|---|
| 4246 | 4136 | } |
|---|
| 4247 | | - dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, |
|---|
| 4248 | | - (long)time->tv_nsec); |
|---|
| 4137 | + dprintk("%s: time_delta=%lld %ld\n", __func__, time->tv_sec, |
|---|
| 4138 | + time->tv_nsec); |
|---|
| 4249 | 4139 | return status; |
|---|
| 4250 | 4140 | } |
|---|
| 4251 | 4141 | |
|---|
| .. | .. |
|---|
| 4263 | 4153 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
|---|
| 4264 | 4154 | p = xdr_inline_decode(xdr, 4); |
|---|
| 4265 | 4155 | if (unlikely(!p)) |
|---|
| 4266 | | - goto out_overflow; |
|---|
| 4156 | + return -EIO; |
|---|
| 4267 | 4157 | lfs = be32_to_cpup(p++); |
|---|
| 4268 | 4158 | p = xdr_inline_decode(xdr, 4); |
|---|
| 4269 | 4159 | if (unlikely(!p)) |
|---|
| 4270 | | - goto out_overflow; |
|---|
| 4160 | + return -EIO; |
|---|
| 4271 | 4161 | pi = be32_to_cpup(p++); |
|---|
| 4272 | 4162 | p = xdr_inline_decode(xdr, 4); |
|---|
| 4273 | 4163 | if (unlikely(!p)) |
|---|
| 4274 | | - goto out_overflow; |
|---|
| 4164 | + return -EIO; |
|---|
| 4275 | 4165 | len = be32_to_cpup(p++); |
|---|
| 4276 | 4166 | p = xdr_inline_decode(xdr, len); |
|---|
| 4277 | 4167 | if (unlikely(!p)) |
|---|
| 4278 | | - goto out_overflow; |
|---|
| 4168 | + return -EIO; |
|---|
| 4169 | + bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL; |
|---|
| 4279 | 4170 | if (len < NFS4_MAXLABELLEN) { |
|---|
| 4280 | | - if (label) { |
|---|
| 4281 | | - if (label->len) { |
|---|
| 4282 | | - if (label->len < len) |
|---|
| 4283 | | - return -ERANGE; |
|---|
| 4284 | | - memcpy(label->label, p, len); |
|---|
| 4285 | | - } |
|---|
| 4171 | + if (label && label->len) { |
|---|
| 4172 | + if (label->len < len) |
|---|
| 4173 | + return -ERANGE; |
|---|
| 4174 | + memcpy(label->label, p, len); |
|---|
| 4286 | 4175 | label->len = len; |
|---|
| 4287 | 4176 | label->pi = pi; |
|---|
| 4288 | 4177 | label->lfs = lfs; |
|---|
| 4289 | 4178 | status = NFS_ATTR_FATTR_V4_SECURITY_LABEL; |
|---|
| 4290 | 4179 | } |
|---|
| 4291 | | - bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL; |
|---|
| 4292 | 4180 | } else |
|---|
| 4293 | 4181 | printk(KERN_WARNING "%s: label too long (%u)!\n", |
|---|
| 4294 | 4182 | __func__, len); |
|---|
| .. | .. |
|---|
| 4298 | 4186 | label->len, label->pi, label->lfs); |
|---|
| 4299 | 4187 | } |
|---|
| 4300 | 4188 | return status; |
|---|
| 4301 | | - |
|---|
| 4302 | | -out_overflow: |
|---|
| 4303 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4304 | | - return -EIO; |
|---|
| 4305 | 4189 | } |
|---|
| 4306 | 4190 | |
|---|
| 4307 | | -static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
|---|
| 4191 | +static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time) |
|---|
| 4308 | 4192 | { |
|---|
| 4309 | 4193 | int status = 0; |
|---|
| 4310 | 4194 | |
|---|
| .. | .. |
|---|
| 4318 | 4202 | status = NFS_ATTR_FATTR_MTIME; |
|---|
| 4319 | 4203 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
|---|
| 4320 | 4204 | } |
|---|
| 4321 | | - dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
|---|
| 4205 | + dprintk("%s: mtime=%lld\n", __func__, time->tv_sec); |
|---|
| 4322 | 4206 | return status; |
|---|
| 4207 | +} |
|---|
| 4208 | + |
|---|
| 4209 | +static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap, |
|---|
| 4210 | + uint32_t *res) |
|---|
| 4211 | +{ |
|---|
| 4212 | + __be32 *p; |
|---|
| 4213 | + |
|---|
| 4214 | + *res = 0; |
|---|
| 4215 | + if (unlikely(bitmap[2] & (FATTR4_WORD2_XATTR_SUPPORT - 1U))) |
|---|
| 4216 | + return -EIO; |
|---|
| 4217 | + if (likely(bitmap[2] & FATTR4_WORD2_XATTR_SUPPORT)) { |
|---|
| 4218 | + p = xdr_inline_decode(xdr, 4); |
|---|
| 4219 | + if (unlikely(!p)) |
|---|
| 4220 | + return -EIO; |
|---|
| 4221 | + *res = be32_to_cpup(p); |
|---|
| 4222 | + bitmap[2] &= ~FATTR4_WORD2_XATTR_SUPPORT; |
|---|
| 4223 | + } |
|---|
| 4224 | + dprintk("%s: XATTR support=%s\n", __func__, |
|---|
| 4225 | + *res == 0 ? "false" : "true"); |
|---|
| 4226 | + return 0; |
|---|
| 4323 | 4227 | } |
|---|
| 4324 | 4228 | |
|---|
| 4325 | 4229 | static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen) |
|---|
| .. | .. |
|---|
| 4345 | 4249 | |
|---|
| 4346 | 4250 | p = xdr_inline_decode(xdr, 20); |
|---|
| 4347 | 4251 | if (unlikely(!p)) |
|---|
| 4348 | | - goto out_overflow; |
|---|
| 4252 | + return -EIO; |
|---|
| 4349 | 4253 | cinfo->atomic = be32_to_cpup(p++); |
|---|
| 4350 | 4254 | p = xdr_decode_hyper(p, &cinfo->before); |
|---|
| 4351 | 4255 | xdr_decode_hyper(p, &cinfo->after); |
|---|
| 4352 | 4256 | return 0; |
|---|
| 4353 | | -out_overflow: |
|---|
| 4354 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4355 | | - return -EIO; |
|---|
| 4356 | 4257 | } |
|---|
| 4357 | 4258 | |
|---|
| 4358 | 4259 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
|---|
| .. | .. |
|---|
| 4366 | 4267 | return status; |
|---|
| 4367 | 4268 | p = xdr_inline_decode(xdr, 8); |
|---|
| 4368 | 4269 | if (unlikely(!p)) |
|---|
| 4369 | | - goto out_overflow; |
|---|
| 4270 | + return -EIO; |
|---|
| 4370 | 4271 | supp = be32_to_cpup(p++); |
|---|
| 4371 | 4272 | acc = be32_to_cpup(p); |
|---|
| 4372 | 4273 | *supported = supp; |
|---|
| 4373 | 4274 | *access = acc; |
|---|
| 4374 | 4275 | return 0; |
|---|
| 4375 | | -out_overflow: |
|---|
| 4376 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4377 | | - return -EIO; |
|---|
| 4378 | 4276 | } |
|---|
| 4379 | 4277 | |
|---|
| 4380 | 4278 | static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len) |
|---|
| 4381 | 4279 | { |
|---|
| 4382 | 4280 | ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len); |
|---|
| 4383 | | - if (unlikely(ret < 0)) { |
|---|
| 4384 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4281 | + if (unlikely(ret < 0)) |
|---|
| 4385 | 4282 | return -EIO; |
|---|
| 4386 | | - } |
|---|
| 4387 | 4283 | return 0; |
|---|
| 4388 | 4284 | } |
|---|
| 4389 | 4285 | |
|---|
| .. | .. |
|---|
| 4466 | 4362 | return status; |
|---|
| 4467 | 4363 | p = xdr_inline_decode(xdr, 4); |
|---|
| 4468 | 4364 | if (unlikely(!p)) |
|---|
| 4469 | | - goto out_overflow; |
|---|
| 4365 | + return -EIO; |
|---|
| 4470 | 4366 | bmlen = be32_to_cpup(p); |
|---|
| 4471 | 4367 | p = xdr_inline_decode(xdr, bmlen << 2); |
|---|
| 4472 | 4368 | if (likely(p)) |
|---|
| 4473 | 4369 | return 0; |
|---|
| 4474 | | -out_overflow: |
|---|
| 4475 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4476 | 4370 | return -EIO; |
|---|
| 4477 | 4371 | } |
|---|
| 4478 | 4372 | |
|---|
| .. | .. |
|---|
| 4580 | 4474 | if (likely(bitmap[0] & hint_bit)) { |
|---|
| 4581 | 4475 | p = xdr_inline_decode(xdr, 8); |
|---|
| 4582 | 4476 | if (unlikely(!p)) |
|---|
| 4583 | | - goto out_overflow; |
|---|
| 4477 | + return -EIO; |
|---|
| 4584 | 4478 | xdr_decode_hyper(p, res); |
|---|
| 4585 | 4479 | } |
|---|
| 4586 | 4480 | return 0; |
|---|
| 4587 | | -out_overflow: |
|---|
| 4588 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4589 | | - return -EIO; |
|---|
| 4590 | 4481 | } |
|---|
| 4591 | 4482 | |
|---|
| 4592 | 4483 | static int decode_first_threshold_item4(struct xdr_stream *xdr, |
|---|
| .. | .. |
|---|
| 4599 | 4490 | |
|---|
| 4600 | 4491 | /* layout type */ |
|---|
| 4601 | 4492 | p = xdr_inline_decode(xdr, 4); |
|---|
| 4602 | | - if (unlikely(!p)) { |
|---|
| 4603 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4493 | + if (unlikely(!p)) |
|---|
| 4604 | 4494 | return -EIO; |
|---|
| 4605 | | - } |
|---|
| 4606 | 4495 | res->l_type = be32_to_cpup(p); |
|---|
| 4607 | 4496 | |
|---|
| 4608 | 4497 | /* thi_hintset bitmap */ |
|---|
| .. | .. |
|---|
| 4660 | 4549 | return -EREMOTEIO; |
|---|
| 4661 | 4550 | p = xdr_inline_decode(xdr, 4); |
|---|
| 4662 | 4551 | if (unlikely(!p)) |
|---|
| 4663 | | - goto out_overflow; |
|---|
| 4552 | + return -EIO; |
|---|
| 4664 | 4553 | num = be32_to_cpup(p); |
|---|
| 4665 | 4554 | if (num == 0) |
|---|
| 4666 | 4555 | return 0; |
|---|
| .. | .. |
|---|
| 4673 | 4562 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
|---|
| 4674 | 4563 | } |
|---|
| 4675 | 4564 | return status; |
|---|
| 4676 | | -out_overflow: |
|---|
| 4677 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4678 | | - return -EIO; |
|---|
| 4679 | 4565 | } |
|---|
| 4680 | 4566 | |
|---|
| 4681 | 4567 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
|---|
| .. | .. |
|---|
| 4863 | 4749 | |
|---|
| 4864 | 4750 | p = xdr_inline_decode(xdr, 4); |
|---|
| 4865 | 4751 | if (unlikely(!p)) |
|---|
| 4866 | | - goto out_overflow; |
|---|
| 4752 | + return -EIO; |
|---|
| 4867 | 4753 | fsinfo->nlayouttypes = be32_to_cpup(p); |
|---|
| 4868 | 4754 | |
|---|
| 4869 | 4755 | /* pNFS is not supported by the underlying file system */ |
|---|
| .. | .. |
|---|
| 4873 | 4759 | /* Decode and set first layout type, move xdr->p past unused types */ |
|---|
| 4874 | 4760 | p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4); |
|---|
| 4875 | 4761 | if (unlikely(!p)) |
|---|
| 4876 | | - goto out_overflow; |
|---|
| 4762 | + return -EIO; |
|---|
| 4877 | 4763 | |
|---|
| 4878 | 4764 | /* If we get too many, then just cap it at the max */ |
|---|
| 4879 | 4765 | if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) { |
|---|
| .. | .. |
|---|
| 4885 | 4771 | for(i = 0; i < fsinfo->nlayouttypes; ++i) |
|---|
| 4886 | 4772 | fsinfo->layouttype[i] = be32_to_cpup(p++); |
|---|
| 4887 | 4773 | return 0; |
|---|
| 4888 | | -out_overflow: |
|---|
| 4889 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4890 | | - return -EIO; |
|---|
| 4891 | 4774 | } |
|---|
| 4892 | 4775 | |
|---|
| 4893 | 4776 | /* |
|---|
| .. | .. |
|---|
| 4921 | 4804 | *res = 0; |
|---|
| 4922 | 4805 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
|---|
| 4923 | 4806 | p = xdr_inline_decode(xdr, 4); |
|---|
| 4924 | | - if (unlikely(!p)) { |
|---|
| 4925 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4807 | + if (unlikely(!p)) |
|---|
| 4926 | 4808 | return -EIO; |
|---|
| 4927 | | - } |
|---|
| 4928 | 4809 | *res = be32_to_cpup(p); |
|---|
| 4929 | 4810 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
|---|
| 4930 | 4811 | } |
|---|
| .. | .. |
|---|
| 4943 | 4824 | *res = 0; |
|---|
| 4944 | 4825 | if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) { |
|---|
| 4945 | 4826 | p = xdr_inline_decode(xdr, 4); |
|---|
| 4946 | | - if (unlikely(!p)) { |
|---|
| 4947 | | - print_overflow_msg(__func__, xdr); |
|---|
| 4827 | + if (unlikely(!p)) |
|---|
| 4948 | 4828 | return -EIO; |
|---|
| 4949 | | - } |
|---|
| 4950 | 4829 | *res = be32_to_cpup(p); |
|---|
| 4951 | 4830 | bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE; |
|---|
| 4952 | 4831 | } |
|---|
| .. | .. |
|---|
| 5001 | 4880 | if (status) |
|---|
| 5002 | 4881 | goto xdr_error; |
|---|
| 5003 | 4882 | |
|---|
| 4883 | + status = decode_attr_xattrsupport(xdr, bitmap, |
|---|
| 4884 | + &fsinfo->xattr_support); |
|---|
| 4885 | + if (status) |
|---|
| 4886 | + goto xdr_error; |
|---|
| 4887 | + |
|---|
| 5004 | 4888 | status = verify_attr_len(xdr, savep, attrlen); |
|---|
| 5005 | 4889 | xdr_error: |
|---|
| 5006 | 4890 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
|---|
| .. | .. |
|---|
| 5022 | 4906 | |
|---|
| 5023 | 4907 | p = xdr_inline_decode(xdr, 4); |
|---|
| 5024 | 4908 | if (unlikely(!p)) |
|---|
| 5025 | | - goto out_overflow; |
|---|
| 4909 | + return -EIO; |
|---|
| 5026 | 4910 | len = be32_to_cpup(p); |
|---|
| 5027 | 4911 | if (len > NFS4_FHSIZE) |
|---|
| 5028 | 4912 | return -EIO; |
|---|
| 5029 | 4913 | fh->size = len; |
|---|
| 5030 | 4914 | p = xdr_inline_decode(xdr, len); |
|---|
| 5031 | 4915 | if (unlikely(!p)) |
|---|
| 5032 | | - goto out_overflow; |
|---|
| 4916 | + return -EIO; |
|---|
| 5033 | 4917 | memcpy(fh->data, p, len); |
|---|
| 5034 | 4918 | return 0; |
|---|
| 5035 | | -out_overflow: |
|---|
| 5036 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5037 | | - return -EIO; |
|---|
| 5038 | 4919 | } |
|---|
| 5039 | 4920 | |
|---|
| 5040 | 4921 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
|---|
| .. | .. |
|---|
| 5058 | 4939 | |
|---|
| 5059 | 4940 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
|---|
| 5060 | 4941 | if (unlikely(!p)) |
|---|
| 5061 | | - goto out_overflow; |
|---|
| 4942 | + return -EIO; |
|---|
| 5062 | 4943 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
|---|
| 5063 | 4944 | p = xdr_decode_hyper(p, &length); |
|---|
| 5064 | 4945 | type = be32_to_cpup(p++); /* 4 byte read */ |
|---|
| .. | .. |
|---|
| 5075 | 4956 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
|---|
| 5076 | 4957 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
|---|
| 5077 | 4958 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
|---|
| 5078 | | - if (likely(p)) |
|---|
| 5079 | | - return -NFS4ERR_DENIED; |
|---|
| 5080 | | -out_overflow: |
|---|
| 5081 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5082 | | - return -EIO; |
|---|
| 4959 | + if (likely(!p)) |
|---|
| 4960 | + return -EIO; |
|---|
| 4961 | + return -NFS4ERR_DENIED; |
|---|
| 5083 | 4962 | } |
|---|
| 5084 | 4963 | |
|---|
| 5085 | 4964 | static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res) |
|---|
| .. | .. |
|---|
| 5148 | 5027 | |
|---|
| 5149 | 5028 | p = xdr_inline_decode(xdr, 12); |
|---|
| 5150 | 5029 | if (unlikely(!p)) |
|---|
| 5151 | | - goto out_overflow; |
|---|
| 5030 | + return -EIO; |
|---|
| 5152 | 5031 | limit_type = be32_to_cpup(p++); |
|---|
| 5153 | 5032 | switch (limit_type) { |
|---|
| 5154 | 5033 | case NFS4_LIMIT_SIZE: |
|---|
| .. | .. |
|---|
| 5162 | 5041 | maxsize >>= PAGE_SHIFT; |
|---|
| 5163 | 5042 | *pagemod_limit = min_t(u64, maxsize, ULONG_MAX); |
|---|
| 5164 | 5043 | return 0; |
|---|
| 5165 | | -out_overflow: |
|---|
| 5166 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5167 | | - return -EIO; |
|---|
| 5168 | 5044 | } |
|---|
| 5169 | 5045 | |
|---|
| 5170 | 5046 | static int decode_rw_delegation(struct xdr_stream *xdr, |
|---|
| .. | .. |
|---|
| 5179 | 5055 | return status; |
|---|
| 5180 | 5056 | p = xdr_inline_decode(xdr, 4); |
|---|
| 5181 | 5057 | if (unlikely(!p)) |
|---|
| 5182 | | - goto out_overflow; |
|---|
| 5058 | + return -EIO; |
|---|
| 5183 | 5059 | res->do_recall = be32_to_cpup(p); |
|---|
| 5184 | 5060 | |
|---|
| 5185 | 5061 | switch (delegation_type) { |
|---|
| .. | .. |
|---|
| 5192 | 5068 | return -EIO; |
|---|
| 5193 | 5069 | } |
|---|
| 5194 | 5070 | return decode_ace(xdr, NULL); |
|---|
| 5195 | | -out_overflow: |
|---|
| 5196 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5197 | | - return -EIO; |
|---|
| 5198 | 5071 | } |
|---|
| 5199 | 5072 | |
|---|
| 5200 | 5073 | static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
|---|
| .. | .. |
|---|
| 5204 | 5077 | |
|---|
| 5205 | 5078 | p = xdr_inline_decode(xdr, 4); |
|---|
| 5206 | 5079 | if (unlikely(!p)) |
|---|
| 5207 | | - goto out_overflow; |
|---|
| 5080 | + return -EIO; |
|---|
| 5208 | 5081 | why_no_delegation = be32_to_cpup(p); |
|---|
| 5209 | 5082 | switch (why_no_delegation) { |
|---|
| 5210 | 5083 | case WND4_CONTENTION: |
|---|
| .. | .. |
|---|
| 5213 | 5086 | /* Ignore for now */ |
|---|
| 5214 | 5087 | } |
|---|
| 5215 | 5088 | return 0; |
|---|
| 5216 | | -out_overflow: |
|---|
| 5217 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5218 | | - return -EIO; |
|---|
| 5219 | 5089 | } |
|---|
| 5220 | 5090 | |
|---|
| 5221 | 5091 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
|---|
| .. | .. |
|---|
| 5225 | 5095 | |
|---|
| 5226 | 5096 | p = xdr_inline_decode(xdr, 4); |
|---|
| 5227 | 5097 | if (unlikely(!p)) |
|---|
| 5228 | | - goto out_overflow; |
|---|
| 5098 | + return -EIO; |
|---|
| 5229 | 5099 | delegation_type = be32_to_cpup(p); |
|---|
| 5230 | 5100 | res->delegation_type = 0; |
|---|
| 5231 | 5101 | switch (delegation_type) { |
|---|
| .. | .. |
|---|
| 5237 | 5107 | case NFS4_OPEN_DELEGATE_NONE_EXT: |
|---|
| 5238 | 5108 | return decode_no_delegation(xdr, res); |
|---|
| 5239 | 5109 | } |
|---|
| 5240 | | - return -EIO; |
|---|
| 5241 | | -out_overflow: |
|---|
| 5242 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5243 | 5110 | return -EIO; |
|---|
| 5244 | 5111 | } |
|---|
| 5245 | 5112 | |
|---|
| .. | .. |
|---|
| 5262 | 5129 | |
|---|
| 5263 | 5130 | p = xdr_inline_decode(xdr, 8); |
|---|
| 5264 | 5131 | if (unlikely(!p)) |
|---|
| 5265 | | - goto out_overflow; |
|---|
| 5132 | + return -EIO; |
|---|
| 5266 | 5133 | res->rflags = be32_to_cpup(p++); |
|---|
| 5267 | 5134 | bmlen = be32_to_cpup(p); |
|---|
| 5268 | 5135 | if (bmlen > 10) |
|---|
| .. | .. |
|---|
| 5270 | 5137 | |
|---|
| 5271 | 5138 | p = xdr_inline_decode(xdr, bmlen << 2); |
|---|
| 5272 | 5139 | if (unlikely(!p)) |
|---|
| 5273 | | - goto out_overflow; |
|---|
| 5140 | + return -EIO; |
|---|
| 5274 | 5141 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
|---|
| 5275 | 5142 | for (i = 0; i < savewords; ++i) |
|---|
| 5276 | 5143 | res->attrset[i] = be32_to_cpup(p++); |
|---|
| .. | .. |
|---|
| 5280 | 5147 | return decode_delegation(xdr, res); |
|---|
| 5281 | 5148 | xdr_error: |
|---|
| 5282 | 5149 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
|---|
| 5283 | | - return -EIO; |
|---|
| 5284 | | -out_overflow: |
|---|
| 5285 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5286 | 5150 | return -EIO; |
|---|
| 5287 | 5151 | } |
|---|
| 5288 | 5152 | |
|---|
| .. | .. |
|---|
| 5332 | 5196 | return status; |
|---|
| 5333 | 5197 | p = xdr_inline_decode(xdr, 8); |
|---|
| 5334 | 5198 | if (unlikely(!p)) |
|---|
| 5335 | | - goto out_overflow; |
|---|
| 5199 | + return -EIO; |
|---|
| 5336 | 5200 | eof = be32_to_cpup(p++); |
|---|
| 5337 | 5201 | count = be32_to_cpup(p); |
|---|
| 5338 | 5202 | recvd = xdr_read_pages(xdr, count); |
|---|
| .. | .. |
|---|
| 5345 | 5209 | res->eof = eof; |
|---|
| 5346 | 5210 | res->count = count; |
|---|
| 5347 | 5211 | return 0; |
|---|
| 5348 | | -out_overflow: |
|---|
| 5349 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5350 | | - return -EIO; |
|---|
| 5351 | 5212 | } |
|---|
| 5352 | 5213 | |
|---|
| 5353 | 5214 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
|---|
| .. | .. |
|---|
| 5380 | 5241 | /* Convert length of symlink */ |
|---|
| 5381 | 5242 | p = xdr_inline_decode(xdr, 4); |
|---|
| 5382 | 5243 | if (unlikely(!p)) |
|---|
| 5383 | | - goto out_overflow; |
|---|
| 5244 | + return -EIO; |
|---|
| 5384 | 5245 | len = be32_to_cpup(p); |
|---|
| 5385 | 5246 | if (len >= rcvbuf->page_len || len <= 0) { |
|---|
| 5386 | 5247 | dprintk("nfs: server returned giant symlink!\n"); |
|---|
| .. | .. |
|---|
| 5396 | 5257 | * The XDR encode routine has set things up so that |
|---|
| 5397 | 5258 | * the link text will be copied directly into the |
|---|
| 5398 | 5259 | * buffer. We just have to do overflow-checking, |
|---|
| 5399 | | - * and and null-terminate the text (the VFS expects |
|---|
| 5260 | + * and null-terminate the text (the VFS expects |
|---|
| 5400 | 5261 | * null-termination). |
|---|
| 5401 | 5262 | */ |
|---|
| 5402 | 5263 | xdr_terminate_string(rcvbuf, len); |
|---|
| 5403 | 5264 | return 0; |
|---|
| 5404 | | -out_overflow: |
|---|
| 5405 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5406 | | - return -EIO; |
|---|
| 5407 | 5265 | } |
|---|
| 5408 | 5266 | |
|---|
| 5409 | 5267 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
|---|
| .. | .. |
|---|
| 5451 | 5309 | uint32_t attrlen, |
|---|
| 5452 | 5310 | bitmap[3] = {0}; |
|---|
| 5453 | 5311 | int status; |
|---|
| 5454 | | - unsigned int pg_offset; |
|---|
| 5455 | 5312 | |
|---|
| 5456 | 5313 | res->acl_len = 0; |
|---|
| 5457 | 5314 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
|---|
| 5458 | 5315 | goto out; |
|---|
| 5459 | 5316 | |
|---|
| 5460 | 5317 | xdr_enter_page(xdr, xdr->buf->page_len); |
|---|
| 5461 | | - |
|---|
| 5462 | | - /* Calculate the offset of the page data */ |
|---|
| 5463 | | - pg_offset = xdr->buf->head[0].iov_len; |
|---|
| 5464 | 5318 | |
|---|
| 5465 | 5319 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
|---|
| 5466 | 5320 | goto out; |
|---|
| .. | .. |
|---|
| 5474 | 5328 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
|---|
| 5475 | 5329 | * are stored with the acl data to handle the problem of |
|---|
| 5476 | 5330 | * variable length bitmaps.*/ |
|---|
| 5477 | | - res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset; |
|---|
| 5331 | + res->acl_data_offset = xdr_page_pos(xdr); |
|---|
| 5478 | 5332 | res->acl_len = attrlen; |
|---|
| 5479 | 5333 | |
|---|
| 5480 | 5334 | /* Check for receive buffer overflow */ |
|---|
| .. | .. |
|---|
| 5506 | 5360 | return status; |
|---|
| 5507 | 5361 | if (decode_bitmap4(xdr, NULL, 0) >= 0) |
|---|
| 5508 | 5362 | return 0; |
|---|
| 5509 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5510 | 5363 | return -EIO; |
|---|
| 5511 | 5364 | } |
|---|
| 5512 | 5365 | |
|---|
| .. | .. |
|---|
| 5518 | 5371 | |
|---|
| 5519 | 5372 | p = xdr_inline_decode(xdr, 8); |
|---|
| 5520 | 5373 | if (unlikely(!p)) |
|---|
| 5521 | | - goto out_overflow; |
|---|
| 5374 | + return -EIO; |
|---|
| 5522 | 5375 | opnum = be32_to_cpup(p++); |
|---|
| 5523 | 5376 | if (opnum != OP_SETCLIENTID) { |
|---|
| 5524 | 5377 | dprintk("nfs: decode_setclientid: Server returned operation" |
|---|
| .. | .. |
|---|
| 5529 | 5382 | if (nfserr == NFS_OK) { |
|---|
| 5530 | 5383 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
|---|
| 5531 | 5384 | if (unlikely(!p)) |
|---|
| 5532 | | - goto out_overflow; |
|---|
| 5385 | + return -EIO; |
|---|
| 5533 | 5386 | p = xdr_decode_hyper(p, &res->clientid); |
|---|
| 5534 | 5387 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
|---|
| 5535 | 5388 | } else if (nfserr == NFSERR_CLID_INUSE) { |
|---|
| .. | .. |
|---|
| 5538 | 5391 | /* skip netid string */ |
|---|
| 5539 | 5392 | p = xdr_inline_decode(xdr, 4); |
|---|
| 5540 | 5393 | if (unlikely(!p)) |
|---|
| 5541 | | - goto out_overflow; |
|---|
| 5394 | + return -EIO; |
|---|
| 5542 | 5395 | len = be32_to_cpup(p); |
|---|
| 5543 | 5396 | p = xdr_inline_decode(xdr, len); |
|---|
| 5544 | 5397 | if (unlikely(!p)) |
|---|
| 5545 | | - goto out_overflow; |
|---|
| 5398 | + return -EIO; |
|---|
| 5546 | 5399 | |
|---|
| 5547 | 5400 | /* skip uaddr string */ |
|---|
| 5548 | 5401 | p = xdr_inline_decode(xdr, 4); |
|---|
| 5549 | 5402 | if (unlikely(!p)) |
|---|
| 5550 | | - goto out_overflow; |
|---|
| 5403 | + return -EIO; |
|---|
| 5551 | 5404 | len = be32_to_cpup(p); |
|---|
| 5552 | 5405 | p = xdr_inline_decode(xdr, len); |
|---|
| 5553 | 5406 | if (unlikely(!p)) |
|---|
| 5554 | | - goto out_overflow; |
|---|
| 5407 | + return -EIO; |
|---|
| 5555 | 5408 | return -NFSERR_CLID_INUSE; |
|---|
| 5556 | 5409 | } else |
|---|
| 5557 | 5410 | return nfs4_stat_to_errno(nfserr); |
|---|
| 5558 | 5411 | |
|---|
| 5559 | 5412 | return 0; |
|---|
| 5560 | | -out_overflow: |
|---|
| 5561 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5562 | | - return -EIO; |
|---|
| 5563 | 5413 | } |
|---|
| 5564 | 5414 | |
|---|
| 5565 | 5415 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
|---|
| .. | .. |
|---|
| 5578 | 5428 | |
|---|
| 5579 | 5429 | p = xdr_inline_decode(xdr, 8); |
|---|
| 5580 | 5430 | if (unlikely(!p)) |
|---|
| 5581 | | - goto out_overflow; |
|---|
| 5431 | + return -EIO; |
|---|
| 5582 | 5432 | res->count = be32_to_cpup(p++); |
|---|
| 5583 | 5433 | res->verf->committed = be32_to_cpup(p++); |
|---|
| 5584 | 5434 | return decode_write_verifier(xdr, &res->verf->verifier); |
|---|
| 5585 | | -out_overflow: |
|---|
| 5586 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5587 | | - return -EIO; |
|---|
| 5588 | 5435 | } |
|---|
| 5589 | 5436 | |
|---|
| 5590 | 5437 | static int decode_delegreturn(struct xdr_stream *xdr) |
|---|
| .. | .. |
|---|
| 5600 | 5447 | |
|---|
| 5601 | 5448 | p = xdr_inline_decode(xdr, 4); |
|---|
| 5602 | 5449 | if (unlikely(!p)) |
|---|
| 5603 | | - goto out_overflow; |
|---|
| 5450 | + return -EIO; |
|---|
| 5604 | 5451 | oid_len = be32_to_cpup(p); |
|---|
| 5605 | 5452 | if (oid_len > GSS_OID_MAX_LEN) |
|---|
| 5606 | | - goto out_err; |
|---|
| 5453 | + return -EINVAL; |
|---|
| 5607 | 5454 | |
|---|
| 5608 | 5455 | p = xdr_inline_decode(xdr, oid_len); |
|---|
| 5609 | 5456 | if (unlikely(!p)) |
|---|
| 5610 | | - goto out_overflow; |
|---|
| 5457 | + return -EIO; |
|---|
| 5611 | 5458 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
|---|
| 5612 | 5459 | flavor->flavor_info.oid.len = oid_len; |
|---|
| 5613 | 5460 | |
|---|
| 5614 | 5461 | p = xdr_inline_decode(xdr, 8); |
|---|
| 5615 | 5462 | if (unlikely(!p)) |
|---|
| 5616 | | - goto out_overflow; |
|---|
| 5463 | + return -EIO; |
|---|
| 5617 | 5464 | flavor->flavor_info.qop = be32_to_cpup(p++); |
|---|
| 5618 | 5465 | flavor->flavor_info.service = be32_to_cpup(p); |
|---|
| 5619 | 5466 | |
|---|
| 5620 | 5467 | return 0; |
|---|
| 5621 | | - |
|---|
| 5622 | | -out_overflow: |
|---|
| 5623 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5624 | | - return -EIO; |
|---|
| 5625 | | -out_err: |
|---|
| 5626 | | - return -EINVAL; |
|---|
| 5627 | 5468 | } |
|---|
| 5628 | 5469 | |
|---|
| 5629 | 5470 | static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
|---|
| .. | .. |
|---|
| 5635 | 5476 | |
|---|
| 5636 | 5477 | p = xdr_inline_decode(xdr, 4); |
|---|
| 5637 | 5478 | if (unlikely(!p)) |
|---|
| 5638 | | - goto out_overflow; |
|---|
| 5479 | + return -EIO; |
|---|
| 5639 | 5480 | |
|---|
| 5640 | 5481 | res->flavors->num_flavors = 0; |
|---|
| 5641 | 5482 | num_flavors = be32_to_cpup(p); |
|---|
| .. | .. |
|---|
| 5647 | 5488 | |
|---|
| 5648 | 5489 | p = xdr_inline_decode(xdr, 4); |
|---|
| 5649 | 5490 | if (unlikely(!p)) |
|---|
| 5650 | | - goto out_overflow; |
|---|
| 5491 | + return -EIO; |
|---|
| 5651 | 5492 | sec_flavor->flavor = be32_to_cpup(p); |
|---|
| 5652 | 5493 | |
|---|
| 5653 | 5494 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
|---|
| .. | .. |
|---|
| 5661 | 5502 | status = 0; |
|---|
| 5662 | 5503 | out: |
|---|
| 5663 | 5504 | return status; |
|---|
| 5664 | | -out_overflow: |
|---|
| 5665 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5666 | | - return -EIO; |
|---|
| 5667 | 5505 | } |
|---|
| 5668 | 5506 | |
|---|
| 5669 | 5507 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
|---|
| .. | .. |
|---|
| 5717 | 5555 | |
|---|
| 5718 | 5556 | p = xdr_inline_decode(xdr, 8); |
|---|
| 5719 | 5557 | if (unlikely(!p)) |
|---|
| 5720 | | - goto out_overflow; |
|---|
| 5558 | + return -EIO; |
|---|
| 5721 | 5559 | xdr_decode_hyper(p, &res->clientid); |
|---|
| 5722 | 5560 | p = xdr_inline_decode(xdr, 12); |
|---|
| 5723 | 5561 | if (unlikely(!p)) |
|---|
| 5724 | | - goto out_overflow; |
|---|
| 5562 | + return -EIO; |
|---|
| 5725 | 5563 | res->seqid = be32_to_cpup(p++); |
|---|
| 5726 | 5564 | res->flags = be32_to_cpup(p++); |
|---|
| 5727 | 5565 | |
|---|
| .. | .. |
|---|
| 5745 | 5583 | /* server_owner4.so_minor_id */ |
|---|
| 5746 | 5584 | p = xdr_inline_decode(xdr, 8); |
|---|
| 5747 | 5585 | if (unlikely(!p)) |
|---|
| 5748 | | - goto out_overflow; |
|---|
| 5586 | + return -EIO; |
|---|
| 5749 | 5587 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
|---|
| 5750 | 5588 | |
|---|
| 5751 | 5589 | /* server_owner4.so_major_id */ |
|---|
| .. | .. |
|---|
| 5765 | 5603 | /* Implementation Id */ |
|---|
| 5766 | 5604 | p = xdr_inline_decode(xdr, 4); |
|---|
| 5767 | 5605 | if (unlikely(!p)) |
|---|
| 5768 | | - goto out_overflow; |
|---|
| 5606 | + return -EIO; |
|---|
| 5769 | 5607 | impl_id_count = be32_to_cpup(p++); |
|---|
| 5770 | 5608 | |
|---|
| 5771 | 5609 | if (impl_id_count) { |
|---|
| .. | .. |
|---|
| 5784 | 5622 | /* nii_date */ |
|---|
| 5785 | 5623 | p = xdr_inline_decode(xdr, 12); |
|---|
| 5786 | 5624 | if (unlikely(!p)) |
|---|
| 5787 | | - goto out_overflow; |
|---|
| 5625 | + return -EIO; |
|---|
| 5788 | 5626 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
|---|
| 5789 | 5627 | res->impl_id->date.nseconds = be32_to_cpup(p); |
|---|
| 5790 | 5628 | |
|---|
| 5791 | 5629 | /* if there's more than one entry, ignore the rest */ |
|---|
| 5792 | 5630 | } |
|---|
| 5793 | 5631 | return 0; |
|---|
| 5794 | | -out_overflow: |
|---|
| 5795 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5796 | | - return -EIO; |
|---|
| 5797 | 5632 | } |
|---|
| 5798 | 5633 | |
|---|
| 5799 | 5634 | static int decode_chan_attrs(struct xdr_stream *xdr, |
|---|
| .. | .. |
|---|
| 5804 | 5639 | |
|---|
| 5805 | 5640 | p = xdr_inline_decode(xdr, 28); |
|---|
| 5806 | 5641 | if (unlikely(!p)) |
|---|
| 5807 | | - goto out_overflow; |
|---|
| 5642 | + return -EIO; |
|---|
| 5808 | 5643 | val = be32_to_cpup(p++); /* headerpadsz */ |
|---|
| 5809 | 5644 | if (val) |
|---|
| 5810 | 5645 | return -EINVAL; /* no support for header padding yet */ |
|---|
| .. | .. |
|---|
| 5822 | 5657 | if (nr_attrs == 1) { |
|---|
| 5823 | 5658 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
|---|
| 5824 | 5659 | if (unlikely(!p)) |
|---|
| 5825 | | - goto out_overflow; |
|---|
| 5660 | + return -EIO; |
|---|
| 5826 | 5661 | } |
|---|
| 5827 | 5662 | return 0; |
|---|
| 5828 | | -out_overflow: |
|---|
| 5829 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5830 | | - return -EIO; |
|---|
| 5831 | 5663 | } |
|---|
| 5832 | 5664 | |
|---|
| 5833 | 5665 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
|---|
| .. | .. |
|---|
| 5850 | 5682 | /* dir flags, rdma mode bool */ |
|---|
| 5851 | 5683 | p = xdr_inline_decode(xdr, 8); |
|---|
| 5852 | 5684 | if (unlikely(!p)) |
|---|
| 5853 | | - goto out_overflow; |
|---|
| 5685 | + return -EIO; |
|---|
| 5854 | 5686 | |
|---|
| 5855 | 5687 | res->dir = be32_to_cpup(p++); |
|---|
| 5856 | 5688 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) |
|---|
| .. | .. |
|---|
| 5861 | 5693 | res->use_conn_in_rdma_mode = true; |
|---|
| 5862 | 5694 | |
|---|
| 5863 | 5695 | return 0; |
|---|
| 5864 | | -out_overflow: |
|---|
| 5865 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5866 | | - return -EIO; |
|---|
| 5867 | 5696 | } |
|---|
| 5868 | 5697 | |
|---|
| 5869 | 5698 | static int decode_create_session(struct xdr_stream *xdr, |
|---|
| .. | .. |
|---|
| 5881 | 5710 | /* seqid, flags */ |
|---|
| 5882 | 5711 | p = xdr_inline_decode(xdr, 8); |
|---|
| 5883 | 5712 | if (unlikely(!p)) |
|---|
| 5884 | | - goto out_overflow; |
|---|
| 5713 | + return -EIO; |
|---|
| 5885 | 5714 | res->seqid = be32_to_cpup(p++); |
|---|
| 5886 | 5715 | res->flags = be32_to_cpup(p); |
|---|
| 5887 | 5716 | |
|---|
| .. | .. |
|---|
| 5890 | 5719 | if (!status) |
|---|
| 5891 | 5720 | status = decode_chan_attrs(xdr, &res->bc_attrs); |
|---|
| 5892 | 5721 | return status; |
|---|
| 5893 | | -out_overflow: |
|---|
| 5894 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5895 | | - return -EIO; |
|---|
| 5896 | 5722 | } |
|---|
| 5897 | 5723 | |
|---|
| 5898 | 5724 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
|---|
| .. | .. |
|---|
| 5973 | 5799 | res->sr_status = status; |
|---|
| 5974 | 5800 | return status; |
|---|
| 5975 | 5801 | out_overflow: |
|---|
| 5976 | | - print_overflow_msg(__func__, xdr); |
|---|
| 5977 | 5802 | status = -EIO; |
|---|
| 5978 | 5803 | goto out_err; |
|---|
| 5979 | 5804 | #else /* CONFIG_NFS_V4_1 */ |
|---|
| .. | .. |
|---|
| 6001 | 5826 | if (status == -ETOOSMALL) { |
|---|
| 6002 | 5827 | p = xdr_inline_decode(xdr, 4); |
|---|
| 6003 | 5828 | if (unlikely(!p)) |
|---|
| 6004 | | - goto out_overflow; |
|---|
| 5829 | + return -EIO; |
|---|
| 6005 | 5830 | pdev->mincount = be32_to_cpup(p); |
|---|
| 6006 | 5831 | dprintk("%s: Min count too small. mincnt = %u\n", |
|---|
| 6007 | 5832 | __func__, pdev->mincount); |
|---|
| .. | .. |
|---|
| 6011 | 5836 | |
|---|
| 6012 | 5837 | p = xdr_inline_decode(xdr, 8); |
|---|
| 6013 | 5838 | if (unlikely(!p)) |
|---|
| 6014 | | - goto out_overflow; |
|---|
| 5839 | + return -EIO; |
|---|
| 6015 | 5840 | type = be32_to_cpup(p++); |
|---|
| 6016 | 5841 | if (type != pdev->layout_type) { |
|---|
| 6017 | 5842 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
|---|
| .. | .. |
|---|
| 6025 | 5850 | */ |
|---|
| 6026 | 5851 | pdev->mincount = be32_to_cpup(p); |
|---|
| 6027 | 5852 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
|---|
| 6028 | | - goto out_overflow; |
|---|
| 5853 | + return -EIO; |
|---|
| 6029 | 5854 | |
|---|
| 6030 | 5855 | /* Parse notification bitmap, verifying that it is zero. */ |
|---|
| 6031 | 5856 | p = xdr_inline_decode(xdr, 4); |
|---|
| 6032 | 5857 | if (unlikely(!p)) |
|---|
| 6033 | | - goto out_overflow; |
|---|
| 5858 | + return -EIO; |
|---|
| 6034 | 5859 | len = be32_to_cpup(p); |
|---|
| 6035 | 5860 | if (len) { |
|---|
| 6036 | 5861 | uint32_t i; |
|---|
| 6037 | 5862 | |
|---|
| 6038 | 5863 | p = xdr_inline_decode(xdr, 4 * len); |
|---|
| 6039 | 5864 | if (unlikely(!p)) |
|---|
| 6040 | | - goto out_overflow; |
|---|
| 5865 | + return -EIO; |
|---|
| 6041 | 5866 | |
|---|
| 6042 | 5867 | res->notification = be32_to_cpup(p++); |
|---|
| 6043 | 5868 | for (i = 1; i < len; i++) { |
|---|
| .. | .. |
|---|
| 6049 | 5874 | } |
|---|
| 6050 | 5875 | } |
|---|
| 6051 | 5876 | return 0; |
|---|
| 6052 | | -out_overflow: |
|---|
| 6053 | | - print_overflow_msg(__func__, xdr); |
|---|
| 6054 | | - return -EIO; |
|---|
| 6055 | 5877 | } |
|---|
| 6056 | 5878 | |
|---|
| 6057 | 5879 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
|---|
| .. | .. |
|---|
| 6121 | 5943 | res->status = status; |
|---|
| 6122 | 5944 | return status; |
|---|
| 6123 | 5945 | out_overflow: |
|---|
| 6124 | | - print_overflow_msg(__func__, xdr); |
|---|
| 6125 | 5946 | status = -EIO; |
|---|
| 6126 | 5947 | goto out; |
|---|
| 6127 | 5948 | } |
|---|
| .. | .. |
|---|
| 6137 | 5958 | return status; |
|---|
| 6138 | 5959 | p = xdr_inline_decode(xdr, 4); |
|---|
| 6139 | 5960 | if (unlikely(!p)) |
|---|
| 6140 | | - goto out_overflow; |
|---|
| 5961 | + return -EIO; |
|---|
| 6141 | 5962 | res->lrs_present = be32_to_cpup(p); |
|---|
| 6142 | 5963 | if (res->lrs_present) |
|---|
| 6143 | 5964 | status = decode_layout_stateid(xdr, &res->stateid); |
|---|
| 6144 | 5965 | else |
|---|
| 6145 | 5966 | nfs4_stateid_copy(&res->stateid, &invalid_stateid); |
|---|
| 6146 | 5967 | return status; |
|---|
| 6147 | | -out_overflow: |
|---|
| 6148 | | - print_overflow_msg(__func__, xdr); |
|---|
| 6149 | | - return -EIO; |
|---|
| 6150 | 5968 | } |
|---|
| 6151 | 5969 | |
|---|
| 6152 | 5970 | static int decode_layoutcommit(struct xdr_stream *xdr, |
|---|
| .. | .. |
|---|
| 6164 | 5982 | |
|---|
| 6165 | 5983 | p = xdr_inline_decode(xdr, 4); |
|---|
| 6166 | 5984 | if (unlikely(!p)) |
|---|
| 6167 | | - goto out_overflow; |
|---|
| 5985 | + return -EIO; |
|---|
| 6168 | 5986 | sizechanged = be32_to_cpup(p); |
|---|
| 6169 | 5987 | |
|---|
| 6170 | 5988 | if (sizechanged) { |
|---|
| 6171 | 5989 | /* throw away new size */ |
|---|
| 6172 | 5990 | p = xdr_inline_decode(xdr, 8); |
|---|
| 6173 | 5991 | if (unlikely(!p)) |
|---|
| 6174 | | - goto out_overflow; |
|---|
| 5992 | + return -EIO; |
|---|
| 6175 | 5993 | } |
|---|
| 6176 | 5994 | return 0; |
|---|
| 6177 | | -out_overflow: |
|---|
| 6178 | | - print_overflow_msg(__func__, xdr); |
|---|
| 6179 | | - return -EIO; |
|---|
| 6180 | 5995 | } |
|---|
| 6181 | 5996 | |
|---|
| 6182 | 5997 | static int decode_test_stateid(struct xdr_stream *xdr, |
|---|
| .. | .. |
|---|
| 6192 | 6007 | |
|---|
| 6193 | 6008 | p = xdr_inline_decode(xdr, 4); |
|---|
| 6194 | 6009 | if (unlikely(!p)) |
|---|
| 6195 | | - goto out_overflow; |
|---|
| 6010 | + return -EIO; |
|---|
| 6196 | 6011 | num_res = be32_to_cpup(p++); |
|---|
| 6197 | 6012 | if (num_res != 1) |
|---|
| 6198 | | - goto out; |
|---|
| 6013 | + return -EIO; |
|---|
| 6199 | 6014 | |
|---|
| 6200 | 6015 | p = xdr_inline_decode(xdr, 4); |
|---|
| 6201 | 6016 | if (unlikely(!p)) |
|---|
| 6202 | | - goto out_overflow; |
|---|
| 6017 | + return -EIO; |
|---|
| 6203 | 6018 | res->status = be32_to_cpup(p++); |
|---|
| 6204 | 6019 | |
|---|
| 6205 | 6020 | return status; |
|---|
| 6206 | | -out_overflow: |
|---|
| 6207 | | - print_overflow_msg(__func__, xdr); |
|---|
| 6208 | | -out: |
|---|
| 6209 | | - return -EIO; |
|---|
| 6210 | 6021 | } |
|---|
| 6211 | 6022 | |
|---|
| 6212 | 6023 | static int decode_free_stateid(struct xdr_stream *xdr, |
|---|
| .. | .. |
|---|
| 7343 | 7154 | return status; |
|---|
| 7344 | 7155 | } |
|---|
| 7345 | 7156 | |
|---|
| 7157 | +#endif |
|---|
| 7158 | + |
|---|
| 7346 | 7159 | /* |
|---|
| 7347 | 7160 | * Decode GET_LEASE_TIME response |
|---|
| 7348 | 7161 | */ |
|---|
| .. | .. |
|---|
| 7363 | 7176 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
|---|
| 7364 | 7177 | return status; |
|---|
| 7365 | 7178 | } |
|---|
| 7179 | + |
|---|
| 7180 | +#ifdef CONFIG_NFS_V4_1 |
|---|
| 7366 | 7181 | |
|---|
| 7367 | 7182 | /* |
|---|
| 7368 | 7183 | * Decode RECLAIM_COMPLETE response |
|---|
| .. | .. |
|---|
| 7576 | 7391 | uint64_t new_cookie; |
|---|
| 7577 | 7392 | __be32 *p = xdr_inline_decode(xdr, 4); |
|---|
| 7578 | 7393 | if (unlikely(!p)) |
|---|
| 7579 | | - goto out_overflow; |
|---|
| 7394 | + return -EAGAIN; |
|---|
| 7580 | 7395 | if (*p == xdr_zero) { |
|---|
| 7581 | 7396 | p = xdr_inline_decode(xdr, 4); |
|---|
| 7582 | 7397 | if (unlikely(!p)) |
|---|
| 7583 | | - goto out_overflow; |
|---|
| 7398 | + return -EAGAIN; |
|---|
| 7584 | 7399 | if (*p == xdr_zero) |
|---|
| 7585 | 7400 | return -EAGAIN; |
|---|
| 7586 | 7401 | entry->eof = 1; |
|---|
| .. | .. |
|---|
| 7589 | 7404 | |
|---|
| 7590 | 7405 | p = xdr_inline_decode(xdr, 12); |
|---|
| 7591 | 7406 | if (unlikely(!p)) |
|---|
| 7592 | | - goto out_overflow; |
|---|
| 7407 | + return -EAGAIN; |
|---|
| 7593 | 7408 | p = xdr_decode_hyper(p, &new_cookie); |
|---|
| 7594 | 7409 | entry->len = be32_to_cpup(p); |
|---|
| 7595 | 7410 | |
|---|
| 7596 | 7411 | p = xdr_inline_decode(xdr, entry->len); |
|---|
| 7597 | 7412 | if (unlikely(!p)) |
|---|
| 7598 | | - goto out_overflow; |
|---|
| 7413 | + return -EAGAIN; |
|---|
| 7599 | 7414 | entry->name = (const char *) p; |
|---|
| 7600 | 7415 | |
|---|
| 7601 | 7416 | /* |
|---|
| .. | .. |
|---|
| 7607 | 7422 | entry->fattr->valid = 0; |
|---|
| 7608 | 7423 | |
|---|
| 7609 | 7424 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
|---|
| 7610 | | - goto out_overflow; |
|---|
| 7425 | + return -EAGAIN; |
|---|
| 7611 | 7426 | |
|---|
| 7612 | 7427 | if (decode_attr_length(xdr, &len, &savep) < 0) |
|---|
| 7613 | | - goto out_overflow; |
|---|
| 7428 | + return -EAGAIN; |
|---|
| 7614 | 7429 | |
|---|
| 7615 | 7430 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
|---|
| 7616 | 7431 | NULL, entry->label, entry->server) < 0) |
|---|
| 7617 | | - goto out_overflow; |
|---|
| 7432 | + return -EAGAIN; |
|---|
| 7618 | 7433 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
|---|
| 7619 | 7434 | entry->ino = entry->fattr->mounted_on_fileid; |
|---|
| 7620 | 7435 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
|---|
| .. | .. |
|---|
| 7628 | 7443 | entry->cookie = new_cookie; |
|---|
| 7629 | 7444 | |
|---|
| 7630 | 7445 | return 0; |
|---|
| 7631 | | - |
|---|
| 7632 | | -out_overflow: |
|---|
| 7633 | | - print_overflow_msg(__func__, xdr); |
|---|
| 7634 | | - return -EAGAIN; |
|---|
| 7635 | 7446 | } |
|---|
| 7636 | 7447 | |
|---|
| 7637 | 7448 | /* |
|---|
| .. | .. |
|---|
| 7671 | 7482 | { NFS4ERR_SYMLINK, -ELOOP }, |
|---|
| 7672 | 7483 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
|---|
| 7673 | 7484 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
|---|
| 7485 | + { NFS4ERR_NOXATTR, -ENODATA }, |
|---|
| 7486 | + { NFS4ERR_XATTR2BIG, -E2BIG }, |
|---|
| 7674 | 7487 | { -1, -EIO } |
|---|
| 7675 | 7488 | }; |
|---|
| 7676 | 7489 | |
|---|
| .. | .. |
|---|
| 7776 | 7589 | PROC41(CREATE_SESSION, enc_create_session, dec_create_session), |
|---|
| 7777 | 7590 | PROC41(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
|---|
| 7778 | 7591 | PROC41(SEQUENCE, enc_sequence, dec_sequence), |
|---|
| 7779 | | - PROC41(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
|---|
| 7592 | + PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
|---|
| 7780 | 7593 | PROC41(RECLAIM_COMPLETE,enc_reclaim_complete, dec_reclaim_complete), |
|---|
| 7781 | 7594 | PROC41(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
|---|
| 7782 | 7595 | PROC41(LAYOUTGET, enc_layoutget, dec_layoutget), |
|---|
| .. | .. |
|---|
| 7796 | 7609 | PROC42(CLONE, enc_clone, dec_clone), |
|---|
| 7797 | 7610 | PROC42(COPY, enc_copy, dec_copy), |
|---|
| 7798 | 7611 | PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel), |
|---|
| 7612 | + PROC42(COPY_NOTIFY, enc_copy_notify, dec_copy_notify), |
|---|
| 7799 | 7613 | PROC(LOOKUPP, enc_lookupp, dec_lookupp), |
|---|
| 7614 | + PROC42(LAYOUTERROR, enc_layouterror, dec_layouterror), |
|---|
| 7615 | + PROC42(GETXATTR, enc_getxattr, dec_getxattr), |
|---|
| 7616 | + PROC42(SETXATTR, enc_setxattr, dec_setxattr), |
|---|
| 7617 | + PROC42(LISTXATTRS, enc_listxattrs, dec_listxattrs), |
|---|
| 7618 | + PROC42(REMOVEXATTR, enc_removexattr, dec_removexattr), |
|---|
| 7619 | + PROC42(READ_PLUS, enc_read_plus, dec_read_plus), |
|---|
| 7800 | 7620 | }; |
|---|
| 7801 | 7621 | |
|---|
| 7802 | 7622 | static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)]; |
|---|