.. | .. |
---|
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; |
---|
4279 | 4169 | if (len < NFS4_MAXLABELLEN) { |
---|
4280 | 4170 | if (label) { |
---|
4281 | 4171 | if (label->len) { |
---|
.. | .. |
---|
4298 | 4188 | label->len, label->pi, label->lfs); |
---|
4299 | 4189 | } |
---|
4300 | 4190 | return status; |
---|
4301 | | - |
---|
4302 | | -out_overflow: |
---|
4303 | | - print_overflow_msg(__func__, xdr); |
---|
4304 | | - return -EIO; |
---|
4305 | 4191 | } |
---|
4306 | 4192 | |
---|
4307 | | -static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
---|
| 4193 | +static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time) |
---|
4308 | 4194 | { |
---|
4309 | 4195 | int status = 0; |
---|
4310 | 4196 | |
---|
.. | .. |
---|
4318 | 4204 | status = NFS_ATTR_FATTR_MTIME; |
---|
4319 | 4205 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
---|
4320 | 4206 | } |
---|
4321 | | - dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
---|
| 4207 | + dprintk("%s: mtime=%lld\n", __func__, time->tv_sec); |
---|
4322 | 4208 | return status; |
---|
| 4209 | +} |
---|
| 4210 | + |
---|
| 4211 | +static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap, |
---|
| 4212 | + uint32_t *res) |
---|
| 4213 | +{ |
---|
| 4214 | + __be32 *p; |
---|
| 4215 | + |
---|
| 4216 | + *res = 0; |
---|
| 4217 | + if (unlikely(bitmap[2] & (FATTR4_WORD2_XATTR_SUPPORT - 1U))) |
---|
| 4218 | + return -EIO; |
---|
| 4219 | + if (likely(bitmap[2] & FATTR4_WORD2_XATTR_SUPPORT)) { |
---|
| 4220 | + p = xdr_inline_decode(xdr, 4); |
---|
| 4221 | + if (unlikely(!p)) |
---|
| 4222 | + return -EIO; |
---|
| 4223 | + *res = be32_to_cpup(p); |
---|
| 4224 | + bitmap[2] &= ~FATTR4_WORD2_XATTR_SUPPORT; |
---|
| 4225 | + } |
---|
| 4226 | + dprintk("%s: XATTR support=%s\n", __func__, |
---|
| 4227 | + *res == 0 ? "false" : "true"); |
---|
| 4228 | + return 0; |
---|
4323 | 4229 | } |
---|
4324 | 4230 | |
---|
4325 | 4231 | static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen) |
---|
.. | .. |
---|
4345 | 4251 | |
---|
4346 | 4252 | p = xdr_inline_decode(xdr, 20); |
---|
4347 | 4253 | if (unlikely(!p)) |
---|
4348 | | - goto out_overflow; |
---|
| 4254 | + return -EIO; |
---|
4349 | 4255 | cinfo->atomic = be32_to_cpup(p++); |
---|
4350 | 4256 | p = xdr_decode_hyper(p, &cinfo->before); |
---|
4351 | 4257 | xdr_decode_hyper(p, &cinfo->after); |
---|
4352 | 4258 | return 0; |
---|
4353 | | -out_overflow: |
---|
4354 | | - print_overflow_msg(__func__, xdr); |
---|
4355 | | - return -EIO; |
---|
4356 | 4259 | } |
---|
4357 | 4260 | |
---|
4358 | 4261 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
---|
.. | .. |
---|
4366 | 4269 | return status; |
---|
4367 | 4270 | p = xdr_inline_decode(xdr, 8); |
---|
4368 | 4271 | if (unlikely(!p)) |
---|
4369 | | - goto out_overflow; |
---|
| 4272 | + return -EIO; |
---|
4370 | 4273 | supp = be32_to_cpup(p++); |
---|
4371 | 4274 | acc = be32_to_cpup(p); |
---|
4372 | 4275 | *supported = supp; |
---|
4373 | 4276 | *access = acc; |
---|
4374 | 4277 | return 0; |
---|
4375 | | -out_overflow: |
---|
4376 | | - print_overflow_msg(__func__, xdr); |
---|
4377 | | - return -EIO; |
---|
4378 | 4278 | } |
---|
4379 | 4279 | |
---|
4380 | 4280 | static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len) |
---|
4381 | 4281 | { |
---|
4382 | 4282 | ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len); |
---|
4383 | | - if (unlikely(ret < 0)) { |
---|
4384 | | - print_overflow_msg(__func__, xdr); |
---|
| 4283 | + if (unlikely(ret < 0)) |
---|
4385 | 4284 | return -EIO; |
---|
4386 | | - } |
---|
4387 | 4285 | return 0; |
---|
4388 | 4286 | } |
---|
4389 | 4287 | |
---|
.. | .. |
---|
4466 | 4364 | return status; |
---|
4467 | 4365 | p = xdr_inline_decode(xdr, 4); |
---|
4468 | 4366 | if (unlikely(!p)) |
---|
4469 | | - goto out_overflow; |
---|
| 4367 | + return -EIO; |
---|
4470 | 4368 | bmlen = be32_to_cpup(p); |
---|
4471 | 4369 | p = xdr_inline_decode(xdr, bmlen << 2); |
---|
4472 | 4370 | if (likely(p)) |
---|
4473 | 4371 | return 0; |
---|
4474 | | -out_overflow: |
---|
4475 | | - print_overflow_msg(__func__, xdr); |
---|
4476 | 4372 | return -EIO; |
---|
4477 | 4373 | } |
---|
4478 | 4374 | |
---|
.. | .. |
---|
4580 | 4476 | if (likely(bitmap[0] & hint_bit)) { |
---|
4581 | 4477 | p = xdr_inline_decode(xdr, 8); |
---|
4582 | 4478 | if (unlikely(!p)) |
---|
4583 | | - goto out_overflow; |
---|
| 4479 | + return -EIO; |
---|
4584 | 4480 | xdr_decode_hyper(p, res); |
---|
4585 | 4481 | } |
---|
4586 | 4482 | return 0; |
---|
4587 | | -out_overflow: |
---|
4588 | | - print_overflow_msg(__func__, xdr); |
---|
4589 | | - return -EIO; |
---|
4590 | 4483 | } |
---|
4591 | 4484 | |
---|
4592 | 4485 | static int decode_first_threshold_item4(struct xdr_stream *xdr, |
---|
.. | .. |
---|
4599 | 4492 | |
---|
4600 | 4493 | /* layout type */ |
---|
4601 | 4494 | p = xdr_inline_decode(xdr, 4); |
---|
4602 | | - if (unlikely(!p)) { |
---|
4603 | | - print_overflow_msg(__func__, xdr); |
---|
| 4495 | + if (unlikely(!p)) |
---|
4604 | 4496 | return -EIO; |
---|
4605 | | - } |
---|
4606 | 4497 | res->l_type = be32_to_cpup(p); |
---|
4607 | 4498 | |
---|
4608 | 4499 | /* thi_hintset bitmap */ |
---|
.. | .. |
---|
4660 | 4551 | return -EREMOTEIO; |
---|
4661 | 4552 | p = xdr_inline_decode(xdr, 4); |
---|
4662 | 4553 | if (unlikely(!p)) |
---|
4663 | | - goto out_overflow; |
---|
| 4554 | + return -EIO; |
---|
4664 | 4555 | num = be32_to_cpup(p); |
---|
4665 | 4556 | if (num == 0) |
---|
4666 | 4557 | return 0; |
---|
.. | .. |
---|
4673 | 4564 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
---|
4674 | 4565 | } |
---|
4675 | 4566 | return status; |
---|
4676 | | -out_overflow: |
---|
4677 | | - print_overflow_msg(__func__, xdr); |
---|
4678 | | - return -EIO; |
---|
4679 | 4567 | } |
---|
4680 | 4568 | |
---|
4681 | 4569 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
---|
.. | .. |
---|
4863 | 4751 | |
---|
4864 | 4752 | p = xdr_inline_decode(xdr, 4); |
---|
4865 | 4753 | if (unlikely(!p)) |
---|
4866 | | - goto out_overflow; |
---|
| 4754 | + return -EIO; |
---|
4867 | 4755 | fsinfo->nlayouttypes = be32_to_cpup(p); |
---|
4868 | 4756 | |
---|
4869 | 4757 | /* pNFS is not supported by the underlying file system */ |
---|
.. | .. |
---|
4873 | 4761 | /* Decode and set first layout type, move xdr->p past unused types */ |
---|
4874 | 4762 | p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4); |
---|
4875 | 4763 | if (unlikely(!p)) |
---|
4876 | | - goto out_overflow; |
---|
| 4764 | + return -EIO; |
---|
4877 | 4765 | |
---|
4878 | 4766 | /* If we get too many, then just cap it at the max */ |
---|
4879 | 4767 | if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) { |
---|
.. | .. |
---|
4885 | 4773 | for(i = 0; i < fsinfo->nlayouttypes; ++i) |
---|
4886 | 4774 | fsinfo->layouttype[i] = be32_to_cpup(p++); |
---|
4887 | 4775 | return 0; |
---|
4888 | | -out_overflow: |
---|
4889 | | - print_overflow_msg(__func__, xdr); |
---|
4890 | | - return -EIO; |
---|
4891 | 4776 | } |
---|
4892 | 4777 | |
---|
4893 | 4778 | /* |
---|
.. | .. |
---|
4921 | 4806 | *res = 0; |
---|
4922 | 4807 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
---|
4923 | 4808 | p = xdr_inline_decode(xdr, 4); |
---|
4924 | | - if (unlikely(!p)) { |
---|
4925 | | - print_overflow_msg(__func__, xdr); |
---|
| 4809 | + if (unlikely(!p)) |
---|
4926 | 4810 | return -EIO; |
---|
4927 | | - } |
---|
4928 | 4811 | *res = be32_to_cpup(p); |
---|
4929 | 4812 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
---|
4930 | 4813 | } |
---|
.. | .. |
---|
4943 | 4826 | *res = 0; |
---|
4944 | 4827 | if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) { |
---|
4945 | 4828 | p = xdr_inline_decode(xdr, 4); |
---|
4946 | | - if (unlikely(!p)) { |
---|
4947 | | - print_overflow_msg(__func__, xdr); |
---|
| 4829 | + if (unlikely(!p)) |
---|
4948 | 4830 | return -EIO; |
---|
4949 | | - } |
---|
4950 | 4831 | *res = be32_to_cpup(p); |
---|
4951 | 4832 | bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE; |
---|
4952 | 4833 | } |
---|
.. | .. |
---|
5001 | 4882 | if (status) |
---|
5002 | 4883 | goto xdr_error; |
---|
5003 | 4884 | |
---|
| 4885 | + status = decode_attr_xattrsupport(xdr, bitmap, |
---|
| 4886 | + &fsinfo->xattr_support); |
---|
| 4887 | + if (status) |
---|
| 4888 | + goto xdr_error; |
---|
| 4889 | + |
---|
5004 | 4890 | status = verify_attr_len(xdr, savep, attrlen); |
---|
5005 | 4891 | xdr_error: |
---|
5006 | 4892 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
---|
.. | .. |
---|
5022 | 4908 | |
---|
5023 | 4909 | p = xdr_inline_decode(xdr, 4); |
---|
5024 | 4910 | if (unlikely(!p)) |
---|
5025 | | - goto out_overflow; |
---|
| 4911 | + return -EIO; |
---|
5026 | 4912 | len = be32_to_cpup(p); |
---|
5027 | 4913 | if (len > NFS4_FHSIZE) |
---|
5028 | 4914 | return -EIO; |
---|
5029 | 4915 | fh->size = len; |
---|
5030 | 4916 | p = xdr_inline_decode(xdr, len); |
---|
5031 | 4917 | if (unlikely(!p)) |
---|
5032 | | - goto out_overflow; |
---|
| 4918 | + return -EIO; |
---|
5033 | 4919 | memcpy(fh->data, p, len); |
---|
5034 | 4920 | return 0; |
---|
5035 | | -out_overflow: |
---|
5036 | | - print_overflow_msg(__func__, xdr); |
---|
5037 | | - return -EIO; |
---|
5038 | 4921 | } |
---|
5039 | 4922 | |
---|
5040 | 4923 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
---|
.. | .. |
---|
5058 | 4941 | |
---|
5059 | 4942 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
---|
5060 | 4943 | if (unlikely(!p)) |
---|
5061 | | - goto out_overflow; |
---|
| 4944 | + return -EIO; |
---|
5062 | 4945 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
---|
5063 | 4946 | p = xdr_decode_hyper(p, &length); |
---|
5064 | 4947 | type = be32_to_cpup(p++); /* 4 byte read */ |
---|
.. | .. |
---|
5075 | 4958 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
---|
5076 | 4959 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
---|
5077 | 4960 | 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; |
---|
| 4961 | + if (likely(!p)) |
---|
| 4962 | + return -EIO; |
---|
| 4963 | + return -NFS4ERR_DENIED; |
---|
5083 | 4964 | } |
---|
5084 | 4965 | |
---|
5085 | 4966 | static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res) |
---|
.. | .. |
---|
5148 | 5029 | |
---|
5149 | 5030 | p = xdr_inline_decode(xdr, 12); |
---|
5150 | 5031 | if (unlikely(!p)) |
---|
5151 | | - goto out_overflow; |
---|
| 5032 | + return -EIO; |
---|
5152 | 5033 | limit_type = be32_to_cpup(p++); |
---|
5153 | 5034 | switch (limit_type) { |
---|
5154 | 5035 | case NFS4_LIMIT_SIZE: |
---|
.. | .. |
---|
5162 | 5043 | maxsize >>= PAGE_SHIFT; |
---|
5163 | 5044 | *pagemod_limit = min_t(u64, maxsize, ULONG_MAX); |
---|
5164 | 5045 | return 0; |
---|
5165 | | -out_overflow: |
---|
5166 | | - print_overflow_msg(__func__, xdr); |
---|
5167 | | - return -EIO; |
---|
5168 | 5046 | } |
---|
5169 | 5047 | |
---|
5170 | 5048 | static int decode_rw_delegation(struct xdr_stream *xdr, |
---|
.. | .. |
---|
5179 | 5057 | return status; |
---|
5180 | 5058 | p = xdr_inline_decode(xdr, 4); |
---|
5181 | 5059 | if (unlikely(!p)) |
---|
5182 | | - goto out_overflow; |
---|
| 5060 | + return -EIO; |
---|
5183 | 5061 | res->do_recall = be32_to_cpup(p); |
---|
5184 | 5062 | |
---|
5185 | 5063 | switch (delegation_type) { |
---|
.. | .. |
---|
5192 | 5070 | return -EIO; |
---|
5193 | 5071 | } |
---|
5194 | 5072 | return decode_ace(xdr, NULL); |
---|
5195 | | -out_overflow: |
---|
5196 | | - print_overflow_msg(__func__, xdr); |
---|
5197 | | - return -EIO; |
---|
5198 | 5073 | } |
---|
5199 | 5074 | |
---|
5200 | 5075 | static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
---|
.. | .. |
---|
5204 | 5079 | |
---|
5205 | 5080 | p = xdr_inline_decode(xdr, 4); |
---|
5206 | 5081 | if (unlikely(!p)) |
---|
5207 | | - goto out_overflow; |
---|
| 5082 | + return -EIO; |
---|
5208 | 5083 | why_no_delegation = be32_to_cpup(p); |
---|
5209 | 5084 | switch (why_no_delegation) { |
---|
5210 | 5085 | case WND4_CONTENTION: |
---|
.. | .. |
---|
5213 | 5088 | /* Ignore for now */ |
---|
5214 | 5089 | } |
---|
5215 | 5090 | return 0; |
---|
5216 | | -out_overflow: |
---|
5217 | | - print_overflow_msg(__func__, xdr); |
---|
5218 | | - return -EIO; |
---|
5219 | 5091 | } |
---|
5220 | 5092 | |
---|
5221 | 5093 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
---|
.. | .. |
---|
5225 | 5097 | |
---|
5226 | 5098 | p = xdr_inline_decode(xdr, 4); |
---|
5227 | 5099 | if (unlikely(!p)) |
---|
5228 | | - goto out_overflow; |
---|
| 5100 | + return -EIO; |
---|
5229 | 5101 | delegation_type = be32_to_cpup(p); |
---|
5230 | 5102 | res->delegation_type = 0; |
---|
5231 | 5103 | switch (delegation_type) { |
---|
.. | .. |
---|
5237 | 5109 | case NFS4_OPEN_DELEGATE_NONE_EXT: |
---|
5238 | 5110 | return decode_no_delegation(xdr, res); |
---|
5239 | 5111 | } |
---|
5240 | | - return -EIO; |
---|
5241 | | -out_overflow: |
---|
5242 | | - print_overflow_msg(__func__, xdr); |
---|
5243 | 5112 | return -EIO; |
---|
5244 | 5113 | } |
---|
5245 | 5114 | |
---|
.. | .. |
---|
5262 | 5131 | |
---|
5263 | 5132 | p = xdr_inline_decode(xdr, 8); |
---|
5264 | 5133 | if (unlikely(!p)) |
---|
5265 | | - goto out_overflow; |
---|
| 5134 | + return -EIO; |
---|
5266 | 5135 | res->rflags = be32_to_cpup(p++); |
---|
5267 | 5136 | bmlen = be32_to_cpup(p); |
---|
5268 | 5137 | if (bmlen > 10) |
---|
.. | .. |
---|
5270 | 5139 | |
---|
5271 | 5140 | p = xdr_inline_decode(xdr, bmlen << 2); |
---|
5272 | 5141 | if (unlikely(!p)) |
---|
5273 | | - goto out_overflow; |
---|
| 5142 | + return -EIO; |
---|
5274 | 5143 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
---|
5275 | 5144 | for (i = 0; i < savewords; ++i) |
---|
5276 | 5145 | res->attrset[i] = be32_to_cpup(p++); |
---|
.. | .. |
---|
5280 | 5149 | return decode_delegation(xdr, res); |
---|
5281 | 5150 | xdr_error: |
---|
5282 | 5151 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
---|
5283 | | - return -EIO; |
---|
5284 | | -out_overflow: |
---|
5285 | | - print_overflow_msg(__func__, xdr); |
---|
5286 | 5152 | return -EIO; |
---|
5287 | 5153 | } |
---|
5288 | 5154 | |
---|
.. | .. |
---|
5332 | 5198 | return status; |
---|
5333 | 5199 | p = xdr_inline_decode(xdr, 8); |
---|
5334 | 5200 | if (unlikely(!p)) |
---|
5335 | | - goto out_overflow; |
---|
| 5201 | + return -EIO; |
---|
5336 | 5202 | eof = be32_to_cpup(p++); |
---|
5337 | 5203 | count = be32_to_cpup(p); |
---|
5338 | 5204 | recvd = xdr_read_pages(xdr, count); |
---|
.. | .. |
---|
5345 | 5211 | res->eof = eof; |
---|
5346 | 5212 | res->count = count; |
---|
5347 | 5213 | return 0; |
---|
5348 | | -out_overflow: |
---|
5349 | | - print_overflow_msg(__func__, xdr); |
---|
5350 | | - return -EIO; |
---|
5351 | 5214 | } |
---|
5352 | 5215 | |
---|
5353 | 5216 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
---|
.. | .. |
---|
5380 | 5243 | /* Convert length of symlink */ |
---|
5381 | 5244 | p = xdr_inline_decode(xdr, 4); |
---|
5382 | 5245 | if (unlikely(!p)) |
---|
5383 | | - goto out_overflow; |
---|
| 5246 | + return -EIO; |
---|
5384 | 5247 | len = be32_to_cpup(p); |
---|
5385 | 5248 | if (len >= rcvbuf->page_len || len <= 0) { |
---|
5386 | 5249 | dprintk("nfs: server returned giant symlink!\n"); |
---|
.. | .. |
---|
5396 | 5259 | * The XDR encode routine has set things up so that |
---|
5397 | 5260 | * the link text will be copied directly into the |
---|
5398 | 5261 | * buffer. We just have to do overflow-checking, |
---|
5399 | | - * and and null-terminate the text (the VFS expects |
---|
| 5262 | + * and null-terminate the text (the VFS expects |
---|
5400 | 5263 | * null-termination). |
---|
5401 | 5264 | */ |
---|
5402 | 5265 | xdr_terminate_string(rcvbuf, len); |
---|
5403 | 5266 | return 0; |
---|
5404 | | -out_overflow: |
---|
5405 | | - print_overflow_msg(__func__, xdr); |
---|
5406 | | - return -EIO; |
---|
5407 | 5267 | } |
---|
5408 | 5268 | |
---|
5409 | 5269 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
---|
.. | .. |
---|
5451 | 5311 | uint32_t attrlen, |
---|
5452 | 5312 | bitmap[3] = {0}; |
---|
5453 | 5313 | int status; |
---|
5454 | | - unsigned int pg_offset; |
---|
5455 | 5314 | |
---|
5456 | 5315 | res->acl_len = 0; |
---|
5457 | 5316 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
---|
5458 | 5317 | goto out; |
---|
5459 | 5318 | |
---|
5460 | 5319 | 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 | 5320 | |
---|
5465 | 5321 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
---|
5466 | 5322 | goto out; |
---|
.. | .. |
---|
5474 | 5330 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
---|
5475 | 5331 | * are stored with the acl data to handle the problem of |
---|
5476 | 5332 | * variable length bitmaps.*/ |
---|
5477 | | - res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset; |
---|
| 5333 | + res->acl_data_offset = xdr_page_pos(xdr); |
---|
5478 | 5334 | res->acl_len = attrlen; |
---|
5479 | 5335 | |
---|
5480 | 5336 | /* Check for receive buffer overflow */ |
---|
.. | .. |
---|
5506 | 5362 | return status; |
---|
5507 | 5363 | if (decode_bitmap4(xdr, NULL, 0) >= 0) |
---|
5508 | 5364 | return 0; |
---|
5509 | | - print_overflow_msg(__func__, xdr); |
---|
5510 | 5365 | return -EIO; |
---|
5511 | 5366 | } |
---|
5512 | 5367 | |
---|
.. | .. |
---|
5518 | 5373 | |
---|
5519 | 5374 | p = xdr_inline_decode(xdr, 8); |
---|
5520 | 5375 | if (unlikely(!p)) |
---|
5521 | | - goto out_overflow; |
---|
| 5376 | + return -EIO; |
---|
5522 | 5377 | opnum = be32_to_cpup(p++); |
---|
5523 | 5378 | if (opnum != OP_SETCLIENTID) { |
---|
5524 | 5379 | dprintk("nfs: decode_setclientid: Server returned operation" |
---|
.. | .. |
---|
5529 | 5384 | if (nfserr == NFS_OK) { |
---|
5530 | 5385 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
---|
5531 | 5386 | if (unlikely(!p)) |
---|
5532 | | - goto out_overflow; |
---|
| 5387 | + return -EIO; |
---|
5533 | 5388 | p = xdr_decode_hyper(p, &res->clientid); |
---|
5534 | 5389 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
---|
5535 | 5390 | } else if (nfserr == NFSERR_CLID_INUSE) { |
---|
.. | .. |
---|
5538 | 5393 | /* skip netid string */ |
---|
5539 | 5394 | p = xdr_inline_decode(xdr, 4); |
---|
5540 | 5395 | if (unlikely(!p)) |
---|
5541 | | - goto out_overflow; |
---|
| 5396 | + return -EIO; |
---|
5542 | 5397 | len = be32_to_cpup(p); |
---|
5543 | 5398 | p = xdr_inline_decode(xdr, len); |
---|
5544 | 5399 | if (unlikely(!p)) |
---|
5545 | | - goto out_overflow; |
---|
| 5400 | + return -EIO; |
---|
5546 | 5401 | |
---|
5547 | 5402 | /* skip uaddr string */ |
---|
5548 | 5403 | p = xdr_inline_decode(xdr, 4); |
---|
5549 | 5404 | if (unlikely(!p)) |
---|
5550 | | - goto out_overflow; |
---|
| 5405 | + return -EIO; |
---|
5551 | 5406 | len = be32_to_cpup(p); |
---|
5552 | 5407 | p = xdr_inline_decode(xdr, len); |
---|
5553 | 5408 | if (unlikely(!p)) |
---|
5554 | | - goto out_overflow; |
---|
| 5409 | + return -EIO; |
---|
5555 | 5410 | return -NFSERR_CLID_INUSE; |
---|
5556 | 5411 | } else |
---|
5557 | 5412 | return nfs4_stat_to_errno(nfserr); |
---|
5558 | 5413 | |
---|
5559 | 5414 | return 0; |
---|
5560 | | -out_overflow: |
---|
5561 | | - print_overflow_msg(__func__, xdr); |
---|
5562 | | - return -EIO; |
---|
5563 | 5415 | } |
---|
5564 | 5416 | |
---|
5565 | 5417 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
---|
.. | .. |
---|
5578 | 5430 | |
---|
5579 | 5431 | p = xdr_inline_decode(xdr, 8); |
---|
5580 | 5432 | if (unlikely(!p)) |
---|
5581 | | - goto out_overflow; |
---|
| 5433 | + return -EIO; |
---|
5582 | 5434 | res->count = be32_to_cpup(p++); |
---|
5583 | 5435 | res->verf->committed = be32_to_cpup(p++); |
---|
5584 | 5436 | return decode_write_verifier(xdr, &res->verf->verifier); |
---|
5585 | | -out_overflow: |
---|
5586 | | - print_overflow_msg(__func__, xdr); |
---|
5587 | | - return -EIO; |
---|
5588 | 5437 | } |
---|
5589 | 5438 | |
---|
5590 | 5439 | static int decode_delegreturn(struct xdr_stream *xdr) |
---|
.. | .. |
---|
5600 | 5449 | |
---|
5601 | 5450 | p = xdr_inline_decode(xdr, 4); |
---|
5602 | 5451 | if (unlikely(!p)) |
---|
5603 | | - goto out_overflow; |
---|
| 5452 | + return -EIO; |
---|
5604 | 5453 | oid_len = be32_to_cpup(p); |
---|
5605 | 5454 | if (oid_len > GSS_OID_MAX_LEN) |
---|
5606 | | - goto out_err; |
---|
| 5455 | + return -EINVAL; |
---|
5607 | 5456 | |
---|
5608 | 5457 | p = xdr_inline_decode(xdr, oid_len); |
---|
5609 | 5458 | if (unlikely(!p)) |
---|
5610 | | - goto out_overflow; |
---|
| 5459 | + return -EIO; |
---|
5611 | 5460 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
---|
5612 | 5461 | flavor->flavor_info.oid.len = oid_len; |
---|
5613 | 5462 | |
---|
5614 | 5463 | p = xdr_inline_decode(xdr, 8); |
---|
5615 | 5464 | if (unlikely(!p)) |
---|
5616 | | - goto out_overflow; |
---|
| 5465 | + return -EIO; |
---|
5617 | 5466 | flavor->flavor_info.qop = be32_to_cpup(p++); |
---|
5618 | 5467 | flavor->flavor_info.service = be32_to_cpup(p); |
---|
5619 | 5468 | |
---|
5620 | 5469 | return 0; |
---|
5621 | | - |
---|
5622 | | -out_overflow: |
---|
5623 | | - print_overflow_msg(__func__, xdr); |
---|
5624 | | - return -EIO; |
---|
5625 | | -out_err: |
---|
5626 | | - return -EINVAL; |
---|
5627 | 5470 | } |
---|
5628 | 5471 | |
---|
5629 | 5472 | static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
---|
.. | .. |
---|
5635 | 5478 | |
---|
5636 | 5479 | p = xdr_inline_decode(xdr, 4); |
---|
5637 | 5480 | if (unlikely(!p)) |
---|
5638 | | - goto out_overflow; |
---|
| 5481 | + return -EIO; |
---|
5639 | 5482 | |
---|
5640 | 5483 | res->flavors->num_flavors = 0; |
---|
5641 | 5484 | num_flavors = be32_to_cpup(p); |
---|
.. | .. |
---|
5647 | 5490 | |
---|
5648 | 5491 | p = xdr_inline_decode(xdr, 4); |
---|
5649 | 5492 | if (unlikely(!p)) |
---|
5650 | | - goto out_overflow; |
---|
| 5493 | + return -EIO; |
---|
5651 | 5494 | sec_flavor->flavor = be32_to_cpup(p); |
---|
5652 | 5495 | |
---|
5653 | 5496 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
---|
.. | .. |
---|
5661 | 5504 | status = 0; |
---|
5662 | 5505 | out: |
---|
5663 | 5506 | return status; |
---|
5664 | | -out_overflow: |
---|
5665 | | - print_overflow_msg(__func__, xdr); |
---|
5666 | | - return -EIO; |
---|
5667 | 5507 | } |
---|
5668 | 5508 | |
---|
5669 | 5509 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
---|
.. | .. |
---|
5717 | 5557 | |
---|
5718 | 5558 | p = xdr_inline_decode(xdr, 8); |
---|
5719 | 5559 | if (unlikely(!p)) |
---|
5720 | | - goto out_overflow; |
---|
| 5560 | + return -EIO; |
---|
5721 | 5561 | xdr_decode_hyper(p, &res->clientid); |
---|
5722 | 5562 | p = xdr_inline_decode(xdr, 12); |
---|
5723 | 5563 | if (unlikely(!p)) |
---|
5724 | | - goto out_overflow; |
---|
| 5564 | + return -EIO; |
---|
5725 | 5565 | res->seqid = be32_to_cpup(p++); |
---|
5726 | 5566 | res->flags = be32_to_cpup(p++); |
---|
5727 | 5567 | |
---|
.. | .. |
---|
5745 | 5585 | /* server_owner4.so_minor_id */ |
---|
5746 | 5586 | p = xdr_inline_decode(xdr, 8); |
---|
5747 | 5587 | if (unlikely(!p)) |
---|
5748 | | - goto out_overflow; |
---|
| 5588 | + return -EIO; |
---|
5749 | 5589 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
---|
5750 | 5590 | |
---|
5751 | 5591 | /* server_owner4.so_major_id */ |
---|
.. | .. |
---|
5765 | 5605 | /* Implementation Id */ |
---|
5766 | 5606 | p = xdr_inline_decode(xdr, 4); |
---|
5767 | 5607 | if (unlikely(!p)) |
---|
5768 | | - goto out_overflow; |
---|
| 5608 | + return -EIO; |
---|
5769 | 5609 | impl_id_count = be32_to_cpup(p++); |
---|
5770 | 5610 | |
---|
5771 | 5611 | if (impl_id_count) { |
---|
.. | .. |
---|
5784 | 5624 | /* nii_date */ |
---|
5785 | 5625 | p = xdr_inline_decode(xdr, 12); |
---|
5786 | 5626 | if (unlikely(!p)) |
---|
5787 | | - goto out_overflow; |
---|
| 5627 | + return -EIO; |
---|
5788 | 5628 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
---|
5789 | 5629 | res->impl_id->date.nseconds = be32_to_cpup(p); |
---|
5790 | 5630 | |
---|
5791 | 5631 | /* if there's more than one entry, ignore the rest */ |
---|
5792 | 5632 | } |
---|
5793 | 5633 | return 0; |
---|
5794 | | -out_overflow: |
---|
5795 | | - print_overflow_msg(__func__, xdr); |
---|
5796 | | - return -EIO; |
---|
5797 | 5634 | } |
---|
5798 | 5635 | |
---|
5799 | 5636 | static int decode_chan_attrs(struct xdr_stream *xdr, |
---|
.. | .. |
---|
5804 | 5641 | |
---|
5805 | 5642 | p = xdr_inline_decode(xdr, 28); |
---|
5806 | 5643 | if (unlikely(!p)) |
---|
5807 | | - goto out_overflow; |
---|
| 5644 | + return -EIO; |
---|
5808 | 5645 | val = be32_to_cpup(p++); /* headerpadsz */ |
---|
5809 | 5646 | if (val) |
---|
5810 | 5647 | return -EINVAL; /* no support for header padding yet */ |
---|
.. | .. |
---|
5822 | 5659 | if (nr_attrs == 1) { |
---|
5823 | 5660 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
---|
5824 | 5661 | if (unlikely(!p)) |
---|
5825 | | - goto out_overflow; |
---|
| 5662 | + return -EIO; |
---|
5826 | 5663 | } |
---|
5827 | 5664 | return 0; |
---|
5828 | | -out_overflow: |
---|
5829 | | - print_overflow_msg(__func__, xdr); |
---|
5830 | | - return -EIO; |
---|
5831 | 5665 | } |
---|
5832 | 5666 | |
---|
5833 | 5667 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
---|
.. | .. |
---|
5850 | 5684 | /* dir flags, rdma mode bool */ |
---|
5851 | 5685 | p = xdr_inline_decode(xdr, 8); |
---|
5852 | 5686 | if (unlikely(!p)) |
---|
5853 | | - goto out_overflow; |
---|
| 5687 | + return -EIO; |
---|
5854 | 5688 | |
---|
5855 | 5689 | res->dir = be32_to_cpup(p++); |
---|
5856 | 5690 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) |
---|
.. | .. |
---|
5861 | 5695 | res->use_conn_in_rdma_mode = true; |
---|
5862 | 5696 | |
---|
5863 | 5697 | return 0; |
---|
5864 | | -out_overflow: |
---|
5865 | | - print_overflow_msg(__func__, xdr); |
---|
5866 | | - return -EIO; |
---|
5867 | 5698 | } |
---|
5868 | 5699 | |
---|
5869 | 5700 | static int decode_create_session(struct xdr_stream *xdr, |
---|
.. | .. |
---|
5881 | 5712 | /* seqid, flags */ |
---|
5882 | 5713 | p = xdr_inline_decode(xdr, 8); |
---|
5883 | 5714 | if (unlikely(!p)) |
---|
5884 | | - goto out_overflow; |
---|
| 5715 | + return -EIO; |
---|
5885 | 5716 | res->seqid = be32_to_cpup(p++); |
---|
5886 | 5717 | res->flags = be32_to_cpup(p); |
---|
5887 | 5718 | |
---|
.. | .. |
---|
5890 | 5721 | if (!status) |
---|
5891 | 5722 | status = decode_chan_attrs(xdr, &res->bc_attrs); |
---|
5892 | 5723 | return status; |
---|
5893 | | -out_overflow: |
---|
5894 | | - print_overflow_msg(__func__, xdr); |
---|
5895 | | - return -EIO; |
---|
5896 | 5724 | } |
---|
5897 | 5725 | |
---|
5898 | 5726 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
---|
.. | .. |
---|
5973 | 5801 | res->sr_status = status; |
---|
5974 | 5802 | return status; |
---|
5975 | 5803 | out_overflow: |
---|
5976 | | - print_overflow_msg(__func__, xdr); |
---|
5977 | 5804 | status = -EIO; |
---|
5978 | 5805 | goto out_err; |
---|
5979 | 5806 | #else /* CONFIG_NFS_V4_1 */ |
---|
.. | .. |
---|
6001 | 5828 | if (status == -ETOOSMALL) { |
---|
6002 | 5829 | p = xdr_inline_decode(xdr, 4); |
---|
6003 | 5830 | if (unlikely(!p)) |
---|
6004 | | - goto out_overflow; |
---|
| 5831 | + return -EIO; |
---|
6005 | 5832 | pdev->mincount = be32_to_cpup(p); |
---|
6006 | 5833 | dprintk("%s: Min count too small. mincnt = %u\n", |
---|
6007 | 5834 | __func__, pdev->mincount); |
---|
.. | .. |
---|
6011 | 5838 | |
---|
6012 | 5839 | p = xdr_inline_decode(xdr, 8); |
---|
6013 | 5840 | if (unlikely(!p)) |
---|
6014 | | - goto out_overflow; |
---|
| 5841 | + return -EIO; |
---|
6015 | 5842 | type = be32_to_cpup(p++); |
---|
6016 | 5843 | if (type != pdev->layout_type) { |
---|
6017 | 5844 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
---|
.. | .. |
---|
6025 | 5852 | */ |
---|
6026 | 5853 | pdev->mincount = be32_to_cpup(p); |
---|
6027 | 5854 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
---|
6028 | | - goto out_overflow; |
---|
| 5855 | + return -EIO; |
---|
6029 | 5856 | |
---|
6030 | 5857 | /* Parse notification bitmap, verifying that it is zero. */ |
---|
6031 | 5858 | p = xdr_inline_decode(xdr, 4); |
---|
6032 | 5859 | if (unlikely(!p)) |
---|
6033 | | - goto out_overflow; |
---|
| 5860 | + return -EIO; |
---|
6034 | 5861 | len = be32_to_cpup(p); |
---|
6035 | 5862 | if (len) { |
---|
6036 | 5863 | uint32_t i; |
---|
6037 | 5864 | |
---|
6038 | 5865 | p = xdr_inline_decode(xdr, 4 * len); |
---|
6039 | 5866 | if (unlikely(!p)) |
---|
6040 | | - goto out_overflow; |
---|
| 5867 | + return -EIO; |
---|
6041 | 5868 | |
---|
6042 | 5869 | res->notification = be32_to_cpup(p++); |
---|
6043 | 5870 | for (i = 1; i < len; i++) { |
---|
.. | .. |
---|
6049 | 5876 | } |
---|
6050 | 5877 | } |
---|
6051 | 5878 | return 0; |
---|
6052 | | -out_overflow: |
---|
6053 | | - print_overflow_msg(__func__, xdr); |
---|
6054 | | - return -EIO; |
---|
6055 | 5879 | } |
---|
6056 | 5880 | |
---|
6057 | 5881 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
---|
.. | .. |
---|
6121 | 5945 | res->status = status; |
---|
6122 | 5946 | return status; |
---|
6123 | 5947 | out_overflow: |
---|
6124 | | - print_overflow_msg(__func__, xdr); |
---|
6125 | 5948 | status = -EIO; |
---|
6126 | 5949 | goto out; |
---|
6127 | 5950 | } |
---|
.. | .. |
---|
6137 | 5960 | return status; |
---|
6138 | 5961 | p = xdr_inline_decode(xdr, 4); |
---|
6139 | 5962 | if (unlikely(!p)) |
---|
6140 | | - goto out_overflow; |
---|
| 5963 | + return -EIO; |
---|
6141 | 5964 | res->lrs_present = be32_to_cpup(p); |
---|
6142 | 5965 | if (res->lrs_present) |
---|
6143 | 5966 | status = decode_layout_stateid(xdr, &res->stateid); |
---|
6144 | 5967 | else |
---|
6145 | 5968 | nfs4_stateid_copy(&res->stateid, &invalid_stateid); |
---|
6146 | 5969 | return status; |
---|
6147 | | -out_overflow: |
---|
6148 | | - print_overflow_msg(__func__, xdr); |
---|
6149 | | - return -EIO; |
---|
6150 | 5970 | } |
---|
6151 | 5971 | |
---|
6152 | 5972 | static int decode_layoutcommit(struct xdr_stream *xdr, |
---|
.. | .. |
---|
6164 | 5984 | |
---|
6165 | 5985 | p = xdr_inline_decode(xdr, 4); |
---|
6166 | 5986 | if (unlikely(!p)) |
---|
6167 | | - goto out_overflow; |
---|
| 5987 | + return -EIO; |
---|
6168 | 5988 | sizechanged = be32_to_cpup(p); |
---|
6169 | 5989 | |
---|
6170 | 5990 | if (sizechanged) { |
---|
6171 | 5991 | /* throw away new size */ |
---|
6172 | 5992 | p = xdr_inline_decode(xdr, 8); |
---|
6173 | 5993 | if (unlikely(!p)) |
---|
6174 | | - goto out_overflow; |
---|
| 5994 | + return -EIO; |
---|
6175 | 5995 | } |
---|
6176 | 5996 | return 0; |
---|
6177 | | -out_overflow: |
---|
6178 | | - print_overflow_msg(__func__, xdr); |
---|
6179 | | - return -EIO; |
---|
6180 | 5997 | } |
---|
6181 | 5998 | |
---|
6182 | 5999 | static int decode_test_stateid(struct xdr_stream *xdr, |
---|
.. | .. |
---|
6192 | 6009 | |
---|
6193 | 6010 | p = xdr_inline_decode(xdr, 4); |
---|
6194 | 6011 | if (unlikely(!p)) |
---|
6195 | | - goto out_overflow; |
---|
| 6012 | + return -EIO; |
---|
6196 | 6013 | num_res = be32_to_cpup(p++); |
---|
6197 | 6014 | if (num_res != 1) |
---|
6198 | | - goto out; |
---|
| 6015 | + return -EIO; |
---|
6199 | 6016 | |
---|
6200 | 6017 | p = xdr_inline_decode(xdr, 4); |
---|
6201 | 6018 | if (unlikely(!p)) |
---|
6202 | | - goto out_overflow; |
---|
| 6019 | + return -EIO; |
---|
6203 | 6020 | res->status = be32_to_cpup(p++); |
---|
6204 | 6021 | |
---|
6205 | 6022 | return status; |
---|
6206 | | -out_overflow: |
---|
6207 | | - print_overflow_msg(__func__, xdr); |
---|
6208 | | -out: |
---|
6209 | | - return -EIO; |
---|
6210 | 6023 | } |
---|
6211 | 6024 | |
---|
6212 | 6025 | static int decode_free_stateid(struct xdr_stream *xdr, |
---|
.. | .. |
---|
7343 | 7156 | return status; |
---|
7344 | 7157 | } |
---|
7345 | 7158 | |
---|
| 7159 | +#endif |
---|
| 7160 | + |
---|
7346 | 7161 | /* |
---|
7347 | 7162 | * Decode GET_LEASE_TIME response |
---|
7348 | 7163 | */ |
---|
.. | .. |
---|
7363 | 7178 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
---|
7364 | 7179 | return status; |
---|
7365 | 7180 | } |
---|
| 7181 | + |
---|
| 7182 | +#ifdef CONFIG_NFS_V4_1 |
---|
7366 | 7183 | |
---|
7367 | 7184 | /* |
---|
7368 | 7185 | * Decode RECLAIM_COMPLETE response |
---|
.. | .. |
---|
7576 | 7393 | uint64_t new_cookie; |
---|
7577 | 7394 | __be32 *p = xdr_inline_decode(xdr, 4); |
---|
7578 | 7395 | if (unlikely(!p)) |
---|
7579 | | - goto out_overflow; |
---|
| 7396 | + return -EAGAIN; |
---|
7580 | 7397 | if (*p == xdr_zero) { |
---|
7581 | 7398 | p = xdr_inline_decode(xdr, 4); |
---|
7582 | 7399 | if (unlikely(!p)) |
---|
7583 | | - goto out_overflow; |
---|
| 7400 | + return -EAGAIN; |
---|
7584 | 7401 | if (*p == xdr_zero) |
---|
7585 | 7402 | return -EAGAIN; |
---|
7586 | 7403 | entry->eof = 1; |
---|
.. | .. |
---|
7589 | 7406 | |
---|
7590 | 7407 | p = xdr_inline_decode(xdr, 12); |
---|
7591 | 7408 | if (unlikely(!p)) |
---|
7592 | | - goto out_overflow; |
---|
| 7409 | + return -EAGAIN; |
---|
7593 | 7410 | p = xdr_decode_hyper(p, &new_cookie); |
---|
7594 | 7411 | entry->len = be32_to_cpup(p); |
---|
7595 | 7412 | |
---|
7596 | 7413 | p = xdr_inline_decode(xdr, entry->len); |
---|
7597 | 7414 | if (unlikely(!p)) |
---|
7598 | | - goto out_overflow; |
---|
| 7415 | + return -EAGAIN; |
---|
7599 | 7416 | entry->name = (const char *) p; |
---|
7600 | 7417 | |
---|
7601 | 7418 | /* |
---|
.. | .. |
---|
7607 | 7424 | entry->fattr->valid = 0; |
---|
7608 | 7425 | |
---|
7609 | 7426 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
---|
7610 | | - goto out_overflow; |
---|
| 7427 | + return -EAGAIN; |
---|
7611 | 7428 | |
---|
7612 | 7429 | if (decode_attr_length(xdr, &len, &savep) < 0) |
---|
7613 | | - goto out_overflow; |
---|
| 7430 | + return -EAGAIN; |
---|
7614 | 7431 | |
---|
7615 | 7432 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
---|
7616 | 7433 | NULL, entry->label, entry->server) < 0) |
---|
7617 | | - goto out_overflow; |
---|
| 7434 | + return -EAGAIN; |
---|
7618 | 7435 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
---|
7619 | 7436 | entry->ino = entry->fattr->mounted_on_fileid; |
---|
7620 | 7437 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
---|
.. | .. |
---|
7628 | 7445 | entry->cookie = new_cookie; |
---|
7629 | 7446 | |
---|
7630 | 7447 | return 0; |
---|
7631 | | - |
---|
7632 | | -out_overflow: |
---|
7633 | | - print_overflow_msg(__func__, xdr); |
---|
7634 | | - return -EAGAIN; |
---|
7635 | 7448 | } |
---|
7636 | 7449 | |
---|
7637 | 7450 | /* |
---|
.. | .. |
---|
7671 | 7484 | { NFS4ERR_SYMLINK, -ELOOP }, |
---|
7672 | 7485 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
---|
7673 | 7486 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
---|
| 7487 | + { NFS4ERR_NOXATTR, -ENODATA }, |
---|
| 7488 | + { NFS4ERR_XATTR2BIG, -E2BIG }, |
---|
7674 | 7489 | { -1, -EIO } |
---|
7675 | 7490 | }; |
---|
7676 | 7491 | |
---|
.. | .. |
---|
7776 | 7591 | PROC41(CREATE_SESSION, enc_create_session, dec_create_session), |
---|
7777 | 7592 | PROC41(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
---|
7778 | 7593 | PROC41(SEQUENCE, enc_sequence, dec_sequence), |
---|
7779 | | - PROC41(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
---|
| 7594 | + PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
---|
7780 | 7595 | PROC41(RECLAIM_COMPLETE,enc_reclaim_complete, dec_reclaim_complete), |
---|
7781 | 7596 | PROC41(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
---|
7782 | 7597 | PROC41(LAYOUTGET, enc_layoutget, dec_layoutget), |
---|
.. | .. |
---|
7796 | 7611 | PROC42(CLONE, enc_clone, dec_clone), |
---|
7797 | 7612 | PROC42(COPY, enc_copy, dec_copy), |
---|
7798 | 7613 | PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel), |
---|
| 7614 | + PROC42(COPY_NOTIFY, enc_copy_notify, dec_copy_notify), |
---|
7799 | 7615 | PROC(LOOKUPP, enc_lookupp, dec_lookupp), |
---|
| 7616 | + PROC42(LAYOUTERROR, enc_layouterror, dec_layouterror), |
---|
| 7617 | + PROC42(GETXATTR, enc_getxattr, dec_getxattr), |
---|
| 7618 | + PROC42(SETXATTR, enc_setxattr, dec_setxattr), |
---|
| 7619 | + PROC42(LISTXATTRS, enc_listxattrs, dec_listxattrs), |
---|
| 7620 | + PROC42(REMOVEXATTR, enc_removexattr, dec_removexattr), |
---|
| 7621 | + PROC42(READ_PLUS, enc_read_plus, dec_read_plus), |
---|
7800 | 7622 | }; |
---|
7801 | 7623 | |
---|
7802 | 7624 | static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)]; |
---|