hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/fs/nfs/nfs4xdr.c
....@@ -54,6 +54,7 @@
5454 #include <linux/nfs_fs.h>
5555
5656 #include "nfs4_fs.h"
57
+#include "nfs4trace.h"
5758 #include "internal.h"
5859 #include "nfs4idmap.h"
5960 #include "nfs4session.h"
....@@ -214,14 +215,14 @@
214215 nfs4_fattr_bitmap_maxsz)
215216 #define encode_read_maxsz (op_encode_hdr_maxsz + \
216217 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)
218219 #define encode_readdir_maxsz (op_encode_hdr_maxsz + \
219220 2 + encode_verifier_maxsz + 5 + \
220221 nfs4_label_maxsz)
221222 #define decode_readdir_maxsz (op_decode_hdr_maxsz + \
222
- decode_verifier_maxsz)
223
+ decode_verifier_maxsz + 1)
223224 #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)
225226 #define encode_write_maxsz (op_encode_hdr_maxsz + \
226227 encode_stateid_maxsz + 4)
227228 #define decode_write_maxsz (op_decode_hdr_maxsz + \
....@@ -283,14 +284,14 @@
283284 #define decode_delegreturn_maxsz (op_decode_hdr_maxsz)
284285 #define encode_getacl_maxsz (encode_getattr_maxsz)
285286 #define decode_getacl_maxsz (op_decode_hdr_maxsz + \
286
- nfs4_fattr_bitmap_maxsz + 1)
287
+ nfs4_fattr_bitmap_maxsz + 1 + 1)
287288 #define encode_setacl_maxsz (op_encode_hdr_maxsz + \
288289 encode_stateid_maxsz + 3)
289290 #define decode_setacl_maxsz (decode_setattr_maxsz)
290291 #define encode_fs_locations_maxsz \
291292 (encode_getattr_maxsz)
292293 #define decode_fs_locations_maxsz \
293
- (0)
294
+ (1)
294295 #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz)
295296 #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4))
296297
....@@ -391,12 +392,13 @@
391392 1 /* opaque devaddr4 length */ + \
392393 /* devaddr4 payload is read into page */ \
393394 1 /* notification bitmap length */ + \
394
- 1 /* notification bitmap, word 0 */)
395
+ 1 /* notification bitmap, word 0 */ + \
396
+ 1 /* possible XDR padding */)
395397 #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \
396398 encode_stateid_maxsz)
397399 #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \
398400 decode_stateid_maxsz + \
399
- XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE))
401
+ XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE) + 1)
400402 #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \
401403 2 /* offset */ + \
402404 2 /* length */ + \
....@@ -835,6 +837,7 @@
835837 #define NFS4_dec_sequence_sz \
836838 (compound_decode_hdr_maxsz + \
837839 decode_sequence_maxsz)
840
+#endif
838841 #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \
839842 encode_sequence_maxsz + \
840843 encode_putrootfh_maxsz + \
....@@ -843,6 +846,7 @@
843846 decode_sequence_maxsz + \
844847 decode_putrootfh_maxsz + \
845848 decode_fsinfo_maxsz)
849
+#if defined(CONFIG_NFS_V4_1)
846850 #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \
847851 encode_sequence_maxsz + \
848852 encode_reclaim_complete_maxsz)
....@@ -1015,12 +1019,11 @@
10151019 struct compound_hdr *hdr)
10161020 {
10171021 __be32 *p;
1018
- struct rpc_auth *auth = req->rq_cred->cr_auth;
10191022
10201023 /* initialize running count of expected bytes in reply.
10211024 * NOTE: the replied tag SHOULD be the same is the one sent,
10221025 * 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;
10241027
10251028 WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN);
10261029 encode_string(xdr, hdr->taglen, hdr->tag);
....@@ -1056,9 +1059,9 @@
10561059 }
10571060
10581061 static __be32 *
1059
-xdr_encode_nfstime4(__be32 *p, const struct timespec *t)
1062
+xdr_encode_nfstime4(__be32 *p, const struct timespec64 *t)
10601063 {
1061
- p = xdr_encode_hyper(p, (__s64)t->tv_sec);
1064
+ p = xdr_encode_hyper(p, t->tv_sec);
10621065 *p++ = cpu_to_be32(t->tv_nsec);
10631066 return p;
10641067 }
....@@ -1069,7 +1072,6 @@
10691072 const struct nfs_server *server,
10701073 const uint32_t attrmask[])
10711074 {
1072
- struct timespec ts;
10731075 char owner_name[IDMAP_NAMESZ];
10741076 char owner_group[IDMAP_NAMESZ];
10751077 int owner_namelen = 0;
....@@ -1158,16 +1160,14 @@
11581160 if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) {
11591161 if (iap->ia_valid & ATTR_ATIME_SET) {
11601162 *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);
11631164 } else
11641165 *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
11651166 }
11661167 if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) {
11671168 if (iap->ia_valid & ATTR_MTIME_SET) {
11681169 *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);
11711171 } else
11721172 *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
11731173 }
....@@ -2340,9 +2340,9 @@
23402340 encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
23412341 if (args->lg_args) {
23422342 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);
23462346 }
23472347 encode_nops(&hdr);
23482348 }
....@@ -2386,9 +2386,9 @@
23862386 encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
23872387 if (args->lg_args) {
23882388 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);
23922392 }
23932393 encode_nops(&hdr);
23942394 }
....@@ -2498,8 +2498,8 @@
24982498 encode_putfh(xdr, args->fh, &hdr);
24992499 encode_readlink(xdr, args, req, &hdr);
25002500
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);
25032503 encode_nops(&hdr);
25042504 }
25052505
....@@ -2519,11 +2519,8 @@
25192519 encode_putfh(xdr, args->fh, &hdr);
25202520 encode_readdir(xdr, args, req, &hdr);
25212521
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);
25272524 encode_nops(&hdr);
25282525 }
25292526
....@@ -2543,8 +2540,8 @@
25432540 encode_putfh(xdr, args->fh, &hdr);
25442541 encode_read(xdr, args, &hdr);
25452542
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);
25482545 req->rq_rcv_buf.flags |= XDRBUF_READ;
25492546 encode_nops(&hdr);
25502547 }
....@@ -2590,9 +2587,8 @@
25902587 encode_getattr(xdr, nfs4_acl_bitmap, NULL,
25912588 ARRAY_SIZE(nfs4_acl_bitmap), &hdr);
25922589
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);
25962592 encode_nops(&hdr);
25972593 }
25982594
....@@ -2813,9 +2809,8 @@
28132809 encode_fs_locations(xdr, args->bitmask, &hdr);
28142810 }
28152811
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);
28192814 encode_nops(&hdr);
28202815 }
28212816
....@@ -2961,6 +2956,8 @@
29612956 encode_nops(&hdr);
29622957 }
29632958
2959
+#endif
2960
+
29642961 /*
29652962 * a GET_LEASE_TIME request
29662963 */
....@@ -2980,6 +2977,8 @@
29802977 encode_fsinfo(xdr, lease_bitmap, &hdr);
29812978 encode_nops(&hdr);
29822979 }
2980
+
2981
+#ifdef CONFIG_NFS_V4_1
29832982
29842983 /*
29852984 * a RECLAIM_COMPLETE request
....@@ -3010,17 +3009,19 @@
30103009 struct compound_hdr hdr = {
30113010 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
30123011 };
3012
+ uint32_t replen;
30133013
30143014 encode_compound_hdr(xdr, req, &hdr);
30153015 encode_sequence(xdr, &args->seq_args, &hdr);
3016
+
3017
+ replen = hdr.replen + op_decode_hdr_maxsz;
3018
+
30163019 encode_getdeviceinfo(xdr, args, &hdr);
30173020
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);
30243025 encode_nops(&hdr);
30253026 }
30263027
....@@ -3041,9 +3042,8 @@
30413042 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
30423043 encode_layoutget(xdr, args, &hdr);
30433044
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);
30473047 encode_nops(&hdr);
30483048 }
30493049
....@@ -3144,22 +3144,12 @@
31443144 }
31453145 #endif /* CONFIG_NFS_V4_1 */
31463146
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
-
31543147 static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string)
31553148 {
31563149 ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string,
31573150 NFS4_OPAQUE_LIMIT);
3158
- if (unlikely(ret < 0)) {
3159
- if (ret == -EBADMSG)
3160
- print_overflow_msg(__func__, xdr);
3151
+ if (unlikely(ret < 0))
31613152 return -EIO;
3162
- }
31633153 *len = ret;
31643154 return 0;
31653155 }
....@@ -3170,22 +3160,19 @@
31703160
31713161 p = xdr_inline_decode(xdr, 8);
31723162 if (unlikely(!p))
3173
- goto out_overflow;
3163
+ return -EIO;
31743164 hdr->status = be32_to_cpup(p++);
31753165 hdr->taglen = be32_to_cpup(p);
31763166
31773167 p = xdr_inline_decode(xdr, hdr->taglen + 4);
31783168 if (unlikely(!p))
3179
- goto out_overflow;
3169
+ return -EIO;
31803170 hdr->tag = (char *)p;
31813171 p += XDR_QUADLEN(hdr->taglen);
31823172 hdr->nops = be32_to_cpup(p);
31833173 if (unlikely(hdr->nops < 1))
31843174 return nfs4_stat_to_errno(hdr->status);
31853175 return 0;
3186
-out_overflow:
3187
- print_overflow_msg(__func__, xdr);
3188
- return -EIO;
31893176 }
31903177
31913178 static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected,
....@@ -3201,11 +3188,14 @@
32013188 opnum = be32_to_cpup(p++);
32023189 if (unlikely(opnum != expected))
32033190 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:
32043196 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);
32093199 return true;
32103200 out_bad_operation:
32113201 dprintk("nfs: Server returned operation"
....@@ -3214,7 +3204,6 @@
32143204 *nfs_retval = -EREMOTEIO;
32153205 return false;
32163206 out_overflow:
3217
- print_overflow_msg(__func__, xdr);
32183207 *nfs_retval = -EIO;
32193208 return false;
32203209 }
....@@ -3235,10 +3224,9 @@
32353224 char *str;
32363225
32373226 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);
32423230 }
32433231
32443232 static ssize_t
....@@ -3249,10 +3237,9 @@
32493237 ret = xdr_stream_decode_uint32_array(xdr, bitmap, sz);
32503238 if (likely(ret >= 0))
32513239 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;
32563243 }
32573244
32583245 static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
....@@ -3268,13 +3255,10 @@
32683255
32693256 p = xdr_inline_decode(xdr, 4);
32703257 if (unlikely(!p))
3271
- goto out_overflow;
3258
+ return -EIO;
32723259 *attrlen = be32_to_cpup(p);
32733260 *savep = xdr_stream_pos(xdr);
32743261 return 0;
3275
-out_overflow:
3276
- print_overflow_msg(__func__, xdr);
3277
- return -EIO;
32783262 }
32793263
32803264 static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask)
....@@ -3303,7 +3287,7 @@
33033287 if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) {
33043288 p = xdr_inline_decode(xdr, 4);
33053289 if (unlikely(!p))
3306
- goto out_overflow;
3290
+ return -EIO;
33073291 *type = be32_to_cpup(p);
33083292 if (*type < NF4REG || *type > NF4NAMEDATTR) {
33093293 dprintk("%s: bad type %d\n", __func__, *type);
....@@ -3314,9 +3298,6 @@
33143298 }
33153299 dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]);
33163300 return ret;
3317
-out_overflow:
3318
- print_overflow_msg(__func__, xdr);
3319
- return -EIO;
33203301 }
33213302
33223303 static int decode_attr_fh_expire_type(struct xdr_stream *xdr,
....@@ -3330,15 +3311,12 @@
33303311 if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) {
33313312 p = xdr_inline_decode(xdr, 4);
33323313 if (unlikely(!p))
3333
- goto out_overflow;
3314
+ return -EIO;
33343315 *type = be32_to_cpup(p);
33353316 bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE;
33363317 }
33373318 dprintk("%s: expire type=0x%x\n", __func__, *type);
33383319 return 0;
3339
-out_overflow:
3340
- print_overflow_msg(__func__, xdr);
3341
- return -EIO;
33423320 }
33433321
33443322 static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change)
....@@ -3352,7 +3330,7 @@
33523330 if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) {
33533331 p = xdr_inline_decode(xdr, 8);
33543332 if (unlikely(!p))
3355
- goto out_overflow;
3333
+ return -EIO;
33563334 xdr_decode_hyper(p, change);
33573335 bitmap[0] &= ~FATTR4_WORD0_CHANGE;
33583336 ret = NFS_ATTR_FATTR_CHANGE;
....@@ -3360,9 +3338,6 @@
33603338 dprintk("%s: change attribute=%Lu\n", __func__,
33613339 (unsigned long long)*change);
33623340 return ret;
3363
-out_overflow:
3364
- print_overflow_msg(__func__, xdr);
3365
- return -EIO;
33663341 }
33673342
33683343 static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size)
....@@ -3376,16 +3351,13 @@
33763351 if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) {
33773352 p = xdr_inline_decode(xdr, 8);
33783353 if (unlikely(!p))
3379
- goto out_overflow;
3354
+ return -EIO;
33803355 xdr_decode_hyper(p, size);
33813356 bitmap[0] &= ~FATTR4_WORD0_SIZE;
33823357 ret = NFS_ATTR_FATTR_SIZE;
33833358 }
33843359 dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size);
33853360 return ret;
3386
-out_overflow:
3387
- print_overflow_msg(__func__, xdr);
3388
- return -EIO;
33893361 }
33903362
33913363 static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
....@@ -3398,15 +3370,12 @@
33983370 if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) {
33993371 p = xdr_inline_decode(xdr, 4);
34003372 if (unlikely(!p))
3401
- goto out_overflow;
3373
+ return -EIO;
34023374 *res = be32_to_cpup(p);
34033375 bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT;
34043376 }
34053377 dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true");
34063378 return 0;
3407
-out_overflow:
3408
- print_overflow_msg(__func__, xdr);
3409
- return -EIO;
34103379 }
34113380
34123381 static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
....@@ -3419,15 +3388,12 @@
34193388 if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) {
34203389 p = xdr_inline_decode(xdr, 4);
34213390 if (unlikely(!p))
3422
- goto out_overflow;
3391
+ return -EIO;
34233392 *res = be32_to_cpup(p);
34243393 bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT;
34253394 }
34263395 dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true");
34273396 return 0;
3428
-out_overflow:
3429
- print_overflow_msg(__func__, xdr);
3430
- return -EIO;
34313397 }
34323398
34333399 static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid)
....@@ -3442,7 +3408,7 @@
34423408 if (likely(bitmap[0] & FATTR4_WORD0_FSID)) {
34433409 p = xdr_inline_decode(xdr, 16);
34443410 if (unlikely(!p))
3445
- goto out_overflow;
3411
+ return -EIO;
34463412 p = xdr_decode_hyper(p, &fsid->major);
34473413 xdr_decode_hyper(p, &fsid->minor);
34483414 bitmap[0] &= ~FATTR4_WORD0_FSID;
....@@ -3452,9 +3418,6 @@
34523418 (unsigned long long)fsid->major,
34533419 (unsigned long long)fsid->minor);
34543420 return ret;
3455
-out_overflow:
3456
- print_overflow_msg(__func__, xdr);
3457
- return -EIO;
34583421 }
34593422
34603423 static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
....@@ -3467,15 +3430,12 @@
34673430 if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) {
34683431 p = xdr_inline_decode(xdr, 4);
34693432 if (unlikely(!p))
3470
- goto out_overflow;
3433
+ return -EIO;
34713434 *res = be32_to_cpup(p);
34723435 bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME;
34733436 }
3474
- dprintk("%s: file size=%u\n", __func__, (unsigned int)*res);
3437
+ dprintk("%s: lease time=%u\n", __func__, (unsigned int)*res);
34753438 return 0;
3476
-out_overflow:
3477
- print_overflow_msg(__func__, xdr);
3478
- return -EIO;
34793439 }
34803440
34813441 static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res)
....@@ -3487,14 +3447,11 @@
34873447 if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) {
34883448 p = xdr_inline_decode(xdr, 4);
34893449 if (unlikely(!p))
3490
- goto out_overflow;
3450
+ return -EIO;
34913451 bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR;
34923452 *res = -be32_to_cpup(p);
34933453 }
34943454 return 0;
3495
-out_overflow:
3496
- print_overflow_msg(__func__, xdr);
3497
- return -EIO;
34983455 }
34993456
35003457 static int decode_attr_exclcreat_supported(struct xdr_stream *xdr,
....@@ -3516,7 +3473,7 @@
35163473 static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh)
35173474 {
35183475 __be32 *p;
3519
- int len;
3476
+ u32 len;
35203477
35213478 if (fh != NULL)
35223479 memset(fh, 0, sizeof(*fh));
....@@ -3526,13 +3483,13 @@
35263483 if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) {
35273484 p = xdr_inline_decode(xdr, 4);
35283485 if (unlikely(!p))
3529
- goto out_overflow;
3486
+ return -EIO;
35303487 len = be32_to_cpup(p);
35313488 if (len > NFS4_FHSIZE)
35323489 return -EIO;
35333490 p = xdr_inline_decode(xdr, len);
35343491 if (unlikely(!p))
3535
- goto out_overflow;
3492
+ return -EIO;
35363493 if (fh != NULL) {
35373494 memcpy(fh->data, p, len);
35383495 fh->size = len;
....@@ -3540,9 +3497,6 @@
35403497 bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE;
35413498 }
35423499 return 0;
3543
-out_overflow:
3544
- print_overflow_msg(__func__, xdr);
3545
- return -EIO;
35463500 }
35473501
35483502 static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
....@@ -3555,15 +3509,12 @@
35553509 if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) {
35563510 p = xdr_inline_decode(xdr, 4);
35573511 if (unlikely(!p))
3558
- goto out_overflow;
3512
+ return -EIO;
35593513 *res = be32_to_cpup(p);
35603514 bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT;
35613515 }
35623516 dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res);
35633517 return 0;
3564
-out_overflow:
3565
- print_overflow_msg(__func__, xdr);
3566
- return -EIO;
35673518 }
35683519
35693520 static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
....@@ -3577,16 +3528,13 @@
35773528 if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) {
35783529 p = xdr_inline_decode(xdr, 8);
35793530 if (unlikely(!p))
3580
- goto out_overflow;
3531
+ return -EIO;
35813532 xdr_decode_hyper(p, fileid);
35823533 bitmap[0] &= ~FATTR4_WORD0_FILEID;
35833534 ret = NFS_ATTR_FATTR_FILEID;
35843535 }
35853536 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
35863537 return ret;
3587
-out_overflow:
3588
- print_overflow_msg(__func__, xdr);
3589
- return -EIO;
35903538 }
35913539
35923540 static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
....@@ -3600,16 +3548,13 @@
36003548 if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) {
36013549 p = xdr_inline_decode(xdr, 8);
36023550 if (unlikely(!p))
3603
- goto out_overflow;
3551
+ return -EIO;
36043552 xdr_decode_hyper(p, fileid);
36053553 bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
36063554 ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID;
36073555 }
36083556 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
36093557 return ret;
3610
-out_overflow:
3611
- print_overflow_msg(__func__, xdr);
3612
- return -EIO;
36133558 }
36143559
36153560 static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
....@@ -3623,15 +3568,12 @@
36233568 if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) {
36243569 p = xdr_inline_decode(xdr, 8);
36253570 if (unlikely(!p))
3626
- goto out_overflow;
3571
+ return -EIO;
36273572 xdr_decode_hyper(p, res);
36283573 bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL;
36293574 }
36303575 dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res);
36313576 return status;
3632
-out_overflow:
3633
- print_overflow_msg(__func__, xdr);
3634
- return -EIO;
36353577 }
36363578
36373579 static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
....@@ -3645,15 +3587,12 @@
36453587 if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) {
36463588 p = xdr_inline_decode(xdr, 8);
36473589 if (unlikely(!p))
3648
- goto out_overflow;
3590
+ return -EIO;
36493591 xdr_decode_hyper(p, res);
36503592 bitmap[0] &= ~FATTR4_WORD0_FILES_FREE;
36513593 }
36523594 dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res);
36533595 return status;
3654
-out_overflow:
3655
- print_overflow_msg(__func__, xdr);
3656
- return -EIO;
36573596 }
36583597
36593598 static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
....@@ -3667,15 +3606,12 @@
36673606 if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) {
36683607 p = xdr_inline_decode(xdr, 8);
36693608 if (unlikely(!p))
3670
- goto out_overflow;
3609
+ return -EIO;
36713610 xdr_decode_hyper(p, res);
36723611 bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL;
36733612 }
36743613 dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res);
36753614 return status;
3676
-out_overflow:
3677
- print_overflow_msg(__func__, xdr);
3678
- return -EIO;
36793615 }
36803616
36813617 static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
....@@ -3686,7 +3622,7 @@
36863622
36873623 p = xdr_inline_decode(xdr, 4);
36883624 if (unlikely(!p))
3689
- goto out_overflow;
3625
+ return -EIO;
36903626 n = be32_to_cpup(p);
36913627 if (n == 0)
36923628 goto root_path;
....@@ -3718,9 +3654,6 @@
37183654 dprintk(" status %d", status);
37193655 status = -EIO;
37203656 goto out;
3721
-out_overflow:
3722
- print_overflow_msg(__func__, xdr);
3723
- return -EIO;
37243657 }
37253658
37263659 static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res)
....@@ -3745,7 +3678,7 @@
37453678 goto out;
37463679 p = xdr_inline_decode(xdr, 4);
37473680 if (unlikely(!p))
3748
- goto out_overflow;
3681
+ goto out_eio;
37493682 n = be32_to_cpup(p);
37503683 for (res->nlocations = 0; res->nlocations < n; res->nlocations++) {
37513684 u32 m;
....@@ -3756,7 +3689,7 @@
37563689 loc = &res->locations[res->nlocations];
37573690 p = xdr_inline_decode(xdr, 4);
37583691 if (unlikely(!p))
3759
- goto out_overflow;
3692
+ goto out_eio;
37603693 m = be32_to_cpup(p);
37613694
37623695 dprintk("%s: servers:\n", __func__);
....@@ -3794,8 +3727,6 @@
37943727 out:
37953728 dprintk("%s: fs_locations done, error = %d\n", __func__, status);
37963729 return status;
3797
-out_overflow:
3798
- print_overflow_msg(__func__, xdr);
37993730 out_eio:
38003731 status = -EIO;
38013732 goto out;
....@@ -3812,15 +3743,12 @@
38123743 if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) {
38133744 p = xdr_inline_decode(xdr, 8);
38143745 if (unlikely(!p))
3815
- goto out_overflow;
3746
+ return -EIO;
38163747 xdr_decode_hyper(p, res);
38173748 bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE;
38183749 }
38193750 dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res);
38203751 return status;
3821
-out_overflow:
3822
- print_overflow_msg(__func__, xdr);
3823
- return -EIO;
38243752 }
38253753
38263754 static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink)
....@@ -3834,15 +3762,12 @@
38343762 if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) {
38353763 p = xdr_inline_decode(xdr, 4);
38363764 if (unlikely(!p))
3837
- goto out_overflow;
3765
+ return -EIO;
38383766 *maxlink = be32_to_cpup(p);
38393767 bitmap[0] &= ~FATTR4_WORD0_MAXLINK;
38403768 }
38413769 dprintk("%s: maxlink=%u\n", __func__, *maxlink);
38423770 return status;
3843
-out_overflow:
3844
- print_overflow_msg(__func__, xdr);
3845
- return -EIO;
38463771 }
38473772
38483773 static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname)
....@@ -3856,15 +3781,12 @@
38563781 if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) {
38573782 p = xdr_inline_decode(xdr, 4);
38583783 if (unlikely(!p))
3859
- goto out_overflow;
3784
+ return -EIO;
38603785 *maxname = be32_to_cpup(p);
38613786 bitmap[0] &= ~FATTR4_WORD0_MAXNAME;
38623787 }
38633788 dprintk("%s: maxname=%u\n", __func__, *maxname);
38643789 return status;
3865
-out_overflow:
3866
- print_overflow_msg(__func__, xdr);
3867
- return -EIO;
38683790 }
38693791
38703792 static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
....@@ -3879,7 +3801,7 @@
38793801 uint64_t maxread;
38803802 p = xdr_inline_decode(xdr, 8);
38813803 if (unlikely(!p))
3882
- goto out_overflow;
3804
+ return -EIO;
38833805 xdr_decode_hyper(p, &maxread);
38843806 if (maxread > 0x7FFFFFFF)
38853807 maxread = 0x7FFFFFFF;
....@@ -3888,9 +3810,6 @@
38883810 }
38893811 dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res);
38903812 return status;
3891
-out_overflow:
3892
- print_overflow_msg(__func__, xdr);
3893
- return -EIO;
38943813 }
38953814
38963815 static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
....@@ -3905,7 +3824,7 @@
39053824 uint64_t maxwrite;
39063825 p = xdr_inline_decode(xdr, 8);
39073826 if (unlikely(!p))
3908
- goto out_overflow;
3827
+ return -EIO;
39093828 xdr_decode_hyper(p, &maxwrite);
39103829 if (maxwrite > 0x7FFFFFFF)
39113830 maxwrite = 0x7FFFFFFF;
....@@ -3914,9 +3833,6 @@
39143833 }
39153834 dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res);
39163835 return status;
3917
-out_overflow:
3918
- print_overflow_msg(__func__, xdr);
3919
- return -EIO;
39203836 }
39213837
39223838 static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode)
....@@ -3931,7 +3847,7 @@
39313847 if (likely(bitmap[1] & FATTR4_WORD1_MODE)) {
39323848 p = xdr_inline_decode(xdr, 4);
39333849 if (unlikely(!p))
3934
- goto out_overflow;
3850
+ return -EIO;
39353851 tmp = be32_to_cpup(p);
39363852 *mode = tmp & ~S_IFMT;
39373853 bitmap[1] &= ~FATTR4_WORD1_MODE;
....@@ -3939,9 +3855,6 @@
39393855 }
39403856 dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode);
39413857 return ret;
3942
-out_overflow:
3943
- print_overflow_msg(__func__, xdr);
3944
- return -EIO;
39453858 }
39463859
39473860 static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink)
....@@ -3955,16 +3868,13 @@
39553868 if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) {
39563869 p = xdr_inline_decode(xdr, 4);
39573870 if (unlikely(!p))
3958
- goto out_overflow;
3871
+ return -EIO;
39593872 *nlink = be32_to_cpup(p);
39603873 bitmap[1] &= ~FATTR4_WORD1_NUMLINKS;
39613874 ret = NFS_ATTR_FATTR_NLINK;
39623875 }
39633876 dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink);
39643877 return ret;
3965
-out_overflow:
3966
- print_overflow_msg(__func__, xdr);
3967
- return -EIO;
39683878 }
39693879
39703880 static ssize_t decode_nfs4_string(struct xdr_stream *xdr,
....@@ -4009,10 +3919,9 @@
40093919 return NFS_ATTR_FATTR_OWNER;
40103920 }
40113921 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;
40163925 }
40173926
40183927 static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
....@@ -4044,10 +3953,9 @@
40443953 return NFS_ATTR_FATTR_GROUP;
40453954 }
40463955 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;
40513959 }
40523960
40533961 static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev)
....@@ -4064,7 +3972,7 @@
40643972
40653973 p = xdr_inline_decode(xdr, 8);
40663974 if (unlikely(!p))
4067
- goto out_overflow;
3975
+ return -EIO;
40683976 major = be32_to_cpup(p++);
40693977 minor = be32_to_cpup(p);
40703978 tmp = MKDEV(major, minor);
....@@ -4075,9 +3983,6 @@
40753983 }
40763984 dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor);
40773985 return ret;
4078
-out_overflow:
4079
- print_overflow_msg(__func__, xdr);
4080
- return -EIO;
40813986 }
40823987
40833988 static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
....@@ -4091,15 +3996,12 @@
40913996 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) {
40923997 p = xdr_inline_decode(xdr, 8);
40933998 if (unlikely(!p))
4094
- goto out_overflow;
3999
+ return -EIO;
40954000 xdr_decode_hyper(p, res);
40964001 bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL;
40974002 }
40984003 dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res);
40994004 return status;
4100
-out_overflow:
4101
- print_overflow_msg(__func__, xdr);
4102
- return -EIO;
41034005 }
41044006
41054007 static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
....@@ -4113,15 +4015,12 @@
41134015 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) {
41144016 p = xdr_inline_decode(xdr, 8);
41154017 if (unlikely(!p))
4116
- goto out_overflow;
4018
+ return -EIO;
41174019 xdr_decode_hyper(p, res);
41184020 bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE;
41194021 }
41204022 dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res);
41214023 return status;
4122
-out_overflow:
4123
- print_overflow_msg(__func__, xdr);
4124
- return -EIO;
41254024 }
41264025
41274026 static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
....@@ -4135,15 +4034,12 @@
41354034 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) {
41364035 p = xdr_inline_decode(xdr, 8);
41374036 if (unlikely(!p))
4138
- goto out_overflow;
4037
+ return -EIO;
41394038 xdr_decode_hyper(p, res);
41404039 bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL;
41414040 }
41424041 dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res);
41434042 return status;
4144
-out_overflow:
4145
- print_overflow_msg(__func__, xdr);
4146
- return -EIO;
41474043 }
41484044
41494045 static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used)
....@@ -4157,7 +4053,7 @@
41574053 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) {
41584054 p = xdr_inline_decode(xdr, 8);
41594055 if (unlikely(!p))
4160
- goto out_overflow;
4056
+ return -EIO;
41614057 xdr_decode_hyper(p, used);
41624058 bitmap[1] &= ~FATTR4_WORD1_SPACE_USED;
41634059 ret = NFS_ATTR_FATTR_SPACE_USED;
....@@ -4165,37 +4061,31 @@
41654061 dprintk("%s: space used=%Lu\n", __func__,
41664062 (unsigned long long)*used);
41674063 return ret;
4168
-out_overflow:
4169
- print_overflow_msg(__func__, xdr);
4170
- return -EIO;
41714064 }
41724065
41734066 static __be32 *
4174
-xdr_decode_nfstime4(__be32 *p, struct timespec *t)
4067
+xdr_decode_nfstime4(__be32 *p, struct timespec64 *t)
41754068 {
41764069 __u64 sec;
41774070
41784071 p = xdr_decode_hyper(p, &sec);
4179
- t-> tv_sec = (time_t)sec;
4072
+ t-> tv_sec = sec;
41804073 t->tv_nsec = be32_to_cpup(p++);
41814074 return p;
41824075 }
41834076
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)
41854078 {
41864079 __be32 *p;
41874080
41884081 p = xdr_inline_decode(xdr, nfstime4_maxsz << 2);
41894082 if (unlikely(!p))
4190
- goto out_overflow;
4083
+ return -EIO;
41914084 xdr_decode_nfstime4(p, time);
41924085 return 0;
4193
-out_overflow:
4194
- print_overflow_msg(__func__, xdr);
4195
- return -EIO;
41964086 }
41974087
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)
41994089 {
42004090 int status = 0;
42014091
....@@ -4209,11 +4099,11 @@
42094099 status = NFS_ATTR_FATTR_ATIME;
42104100 bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS;
42114101 }
4212
- dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec);
4102
+ dprintk("%s: atime=%lld\n", __func__, time->tv_sec);
42134103 return status;
42144104 }
42154105
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)
42174107 {
42184108 int status = 0;
42194109
....@@ -4227,12 +4117,12 @@
42274117 status = NFS_ATTR_FATTR_CTIME;
42284118 bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA;
42294119 }
4230
- dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec);
4120
+ dprintk("%s: ctime=%lld\n", __func__, time->tv_sec);
42314121 return status;
42324122 }
42334123
42344124 static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap,
4235
- struct timespec *time)
4125
+ struct timespec64 *time)
42364126 {
42374127 int status = 0;
42384128
....@@ -4244,8 +4134,8 @@
42444134 status = decode_attr_time(xdr, time);
42454135 bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA;
42464136 }
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);
42494139 return status;
42504140 }
42514141
....@@ -4263,19 +4153,19 @@
42634153 if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) {
42644154 p = xdr_inline_decode(xdr, 4);
42654155 if (unlikely(!p))
4266
- goto out_overflow;
4156
+ return -EIO;
42674157 lfs = be32_to_cpup(p++);
42684158 p = xdr_inline_decode(xdr, 4);
42694159 if (unlikely(!p))
4270
- goto out_overflow;
4160
+ return -EIO;
42714161 pi = be32_to_cpup(p++);
42724162 p = xdr_inline_decode(xdr, 4);
42734163 if (unlikely(!p))
4274
- goto out_overflow;
4164
+ return -EIO;
42754165 len = be32_to_cpup(p++);
42764166 p = xdr_inline_decode(xdr, len);
42774167 if (unlikely(!p))
4278
- goto out_overflow;
4168
+ return -EIO;
42794169 if (len < NFS4_MAXLABELLEN) {
42804170 if (label) {
42814171 if (label->len) {
....@@ -4298,13 +4188,9 @@
42984188 label->len, label->pi, label->lfs);
42994189 }
43004190 return status;
4301
-
4302
-out_overflow:
4303
- print_overflow_msg(__func__, xdr);
4304
- return -EIO;
43054191 }
43064192
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)
43084194 {
43094195 int status = 0;
43104196
....@@ -4318,8 +4204,28 @@
43184204 status = NFS_ATTR_FATTR_MTIME;
43194205 bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY;
43204206 }
4321
- dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec);
4207
+ dprintk("%s: mtime=%lld\n", __func__, time->tv_sec);
43224208 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;
43234229 }
43244230
43254231 static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen)
....@@ -4345,14 +4251,11 @@
43454251
43464252 p = xdr_inline_decode(xdr, 20);
43474253 if (unlikely(!p))
4348
- goto out_overflow;
4254
+ return -EIO;
43494255 cinfo->atomic = be32_to_cpup(p++);
43504256 p = xdr_decode_hyper(p, &cinfo->before);
43514257 xdr_decode_hyper(p, &cinfo->after);
43524258 return 0;
4353
-out_overflow:
4354
- print_overflow_msg(__func__, xdr);
4355
- return -EIO;
43564259 }
43574260
43584261 static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access)
....@@ -4366,24 +4269,19 @@
43664269 return status;
43674270 p = xdr_inline_decode(xdr, 8);
43684271 if (unlikely(!p))
4369
- goto out_overflow;
4272
+ return -EIO;
43704273 supp = be32_to_cpup(p++);
43714274 acc = be32_to_cpup(p);
43724275 *supported = supp;
43734276 *access = acc;
43744277 return 0;
4375
-out_overflow:
4376
- print_overflow_msg(__func__, xdr);
4377
- return -EIO;
43784278 }
43794279
43804280 static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)
43814281 {
43824282 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))
43854284 return -EIO;
4386
- }
43874285 return 0;
43884286 }
43894287
....@@ -4466,13 +4364,11 @@
44664364 return status;
44674365 p = xdr_inline_decode(xdr, 4);
44684366 if (unlikely(!p))
4469
- goto out_overflow;
4367
+ return -EIO;
44704368 bmlen = be32_to_cpup(p);
44714369 p = xdr_inline_decode(xdr, bmlen << 2);
44724370 if (likely(p))
44734371 return 0;
4474
-out_overflow:
4475
- print_overflow_msg(__func__, xdr);
44764372 return -EIO;
44774373 }
44784374
....@@ -4580,13 +4476,10 @@
45804476 if (likely(bitmap[0] & hint_bit)) {
45814477 p = xdr_inline_decode(xdr, 8);
45824478 if (unlikely(!p))
4583
- goto out_overflow;
4479
+ return -EIO;
45844480 xdr_decode_hyper(p, res);
45854481 }
45864482 return 0;
4587
-out_overflow:
4588
- print_overflow_msg(__func__, xdr);
4589
- return -EIO;
45904483 }
45914484
45924485 static int decode_first_threshold_item4(struct xdr_stream *xdr,
....@@ -4599,10 +4492,8 @@
45994492
46004493 /* layout type */
46014494 p = xdr_inline_decode(xdr, 4);
4602
- if (unlikely(!p)) {
4603
- print_overflow_msg(__func__, xdr);
4495
+ if (unlikely(!p))
46044496 return -EIO;
4605
- }
46064497 res->l_type = be32_to_cpup(p);
46074498
46084499 /* thi_hintset bitmap */
....@@ -4660,7 +4551,7 @@
46604551 return -EREMOTEIO;
46614552 p = xdr_inline_decode(xdr, 4);
46624553 if (unlikely(!p))
4663
- goto out_overflow;
4554
+ return -EIO;
46644555 num = be32_to_cpup(p);
46654556 if (num == 0)
46664557 return 0;
....@@ -4673,9 +4564,6 @@
46734564 bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD;
46744565 }
46754566 return status;
4676
-out_overflow:
4677
- print_overflow_msg(__func__, xdr);
4678
- return -EIO;
46794567 }
46804568
46814569 static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap,
....@@ -4863,7 +4751,7 @@
48634751
48644752 p = xdr_inline_decode(xdr, 4);
48654753 if (unlikely(!p))
4866
- goto out_overflow;
4754
+ return -EIO;
48674755 fsinfo->nlayouttypes = be32_to_cpup(p);
48684756
48694757 /* pNFS is not supported by the underlying file system */
....@@ -4873,7 +4761,7 @@
48734761 /* Decode and set first layout type, move xdr->p past unused types */
48744762 p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4);
48754763 if (unlikely(!p))
4876
- goto out_overflow;
4764
+ return -EIO;
48774765
48784766 /* If we get too many, then just cap it at the max */
48794767 if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) {
....@@ -4885,9 +4773,6 @@
48854773 for(i = 0; i < fsinfo->nlayouttypes; ++i)
48864774 fsinfo->layouttype[i] = be32_to_cpup(p++);
48874775 return 0;
4888
-out_overflow:
4889
- print_overflow_msg(__func__, xdr);
4890
- return -EIO;
48914776 }
48924777
48934778 /*
....@@ -4921,10 +4806,8 @@
49214806 *res = 0;
49224807 if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) {
49234808 p = xdr_inline_decode(xdr, 4);
4924
- if (unlikely(!p)) {
4925
- print_overflow_msg(__func__, xdr);
4809
+ if (unlikely(!p))
49264810 return -EIO;
4927
- }
49284811 *res = be32_to_cpup(p);
49294812 bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE;
49304813 }
....@@ -4943,10 +4826,8 @@
49434826 *res = 0;
49444827 if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) {
49454828 p = xdr_inline_decode(xdr, 4);
4946
- if (unlikely(!p)) {
4947
- print_overflow_msg(__func__, xdr);
4829
+ if (unlikely(!p))
49484830 return -EIO;
4949
- }
49504831 *res = be32_to_cpup(p);
49514832 bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE;
49524833 }
....@@ -5001,6 +4882,11 @@
50014882 if (status)
50024883 goto xdr_error;
50034884
4885
+ status = decode_attr_xattrsupport(xdr, bitmap,
4886
+ &fsinfo->xattr_support);
4887
+ if (status)
4888
+ goto xdr_error;
4889
+
50044890 status = verify_attr_len(xdr, savep, attrlen);
50054891 xdr_error:
50064892 dprintk("%s: xdr returned %d!\n", __func__, -status);
....@@ -5022,19 +4908,16 @@
50224908
50234909 p = xdr_inline_decode(xdr, 4);
50244910 if (unlikely(!p))
5025
- goto out_overflow;
4911
+ return -EIO;
50264912 len = be32_to_cpup(p);
50274913 if (len > NFS4_FHSIZE)
50284914 return -EIO;
50294915 fh->size = len;
50304916 p = xdr_inline_decode(xdr, len);
50314917 if (unlikely(!p))
5032
- goto out_overflow;
4918
+ return -EIO;
50334919 memcpy(fh->data, p, len);
50344920 return 0;
5035
-out_overflow:
5036
- print_overflow_msg(__func__, xdr);
5037
- return -EIO;
50384921 }
50394922
50404923 static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
....@@ -5058,7 +4941,7 @@
50584941
50594942 p = xdr_inline_decode(xdr, 32); /* read 32 bytes */
50604943 if (unlikely(!p))
5061
- goto out_overflow;
4944
+ return -EIO;
50624945 p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */
50634946 p = xdr_decode_hyper(p, &length);
50644947 type = be32_to_cpup(p++); /* 4 byte read */
....@@ -5075,11 +4958,9 @@
50754958 p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */
50764959 namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */
50774960 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;
50834964 }
50844965
50854966 static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
....@@ -5148,7 +5029,7 @@
51485029
51495030 p = xdr_inline_decode(xdr, 12);
51505031 if (unlikely(!p))
5151
- goto out_overflow;
5032
+ return -EIO;
51525033 limit_type = be32_to_cpup(p++);
51535034 switch (limit_type) {
51545035 case NFS4_LIMIT_SIZE:
....@@ -5162,9 +5043,6 @@
51625043 maxsize >>= PAGE_SHIFT;
51635044 *pagemod_limit = min_t(u64, maxsize, ULONG_MAX);
51645045 return 0;
5165
-out_overflow:
5166
- print_overflow_msg(__func__, xdr);
5167
- return -EIO;
51685046 }
51695047
51705048 static int decode_rw_delegation(struct xdr_stream *xdr,
....@@ -5179,7 +5057,7 @@
51795057 return status;
51805058 p = xdr_inline_decode(xdr, 4);
51815059 if (unlikely(!p))
5182
- goto out_overflow;
5060
+ return -EIO;
51835061 res->do_recall = be32_to_cpup(p);
51845062
51855063 switch (delegation_type) {
....@@ -5192,9 +5070,6 @@
51925070 return -EIO;
51935071 }
51945072 return decode_ace(xdr, NULL);
5195
-out_overflow:
5196
- print_overflow_msg(__func__, xdr);
5197
- return -EIO;
51985073 }
51995074
52005075 static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
....@@ -5204,7 +5079,7 @@
52045079
52055080 p = xdr_inline_decode(xdr, 4);
52065081 if (unlikely(!p))
5207
- goto out_overflow;
5082
+ return -EIO;
52085083 why_no_delegation = be32_to_cpup(p);
52095084 switch (why_no_delegation) {
52105085 case WND4_CONTENTION:
....@@ -5213,9 +5088,6 @@
52135088 /* Ignore for now */
52145089 }
52155090 return 0;
5216
-out_overflow:
5217
- print_overflow_msg(__func__, xdr);
5218
- return -EIO;
52195091 }
52205092
52215093 static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
....@@ -5225,7 +5097,7 @@
52255097
52265098 p = xdr_inline_decode(xdr, 4);
52275099 if (unlikely(!p))
5228
- goto out_overflow;
5100
+ return -EIO;
52295101 delegation_type = be32_to_cpup(p);
52305102 res->delegation_type = 0;
52315103 switch (delegation_type) {
....@@ -5237,9 +5109,6 @@
52375109 case NFS4_OPEN_DELEGATE_NONE_EXT:
52385110 return decode_no_delegation(xdr, res);
52395111 }
5240
- return -EIO;
5241
-out_overflow:
5242
- print_overflow_msg(__func__, xdr);
52435112 return -EIO;
52445113 }
52455114
....@@ -5262,7 +5131,7 @@
52625131
52635132 p = xdr_inline_decode(xdr, 8);
52645133 if (unlikely(!p))
5265
- goto out_overflow;
5134
+ return -EIO;
52665135 res->rflags = be32_to_cpup(p++);
52675136 bmlen = be32_to_cpup(p);
52685137 if (bmlen > 10)
....@@ -5270,7 +5139,7 @@
52705139
52715140 p = xdr_inline_decode(xdr, bmlen << 2);
52725141 if (unlikely(!p))
5273
- goto out_overflow;
5142
+ return -EIO;
52745143 savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE);
52755144 for (i = 0; i < savewords; ++i)
52765145 res->attrset[i] = be32_to_cpup(p++);
....@@ -5280,9 +5149,6 @@
52805149 return decode_delegation(xdr, res);
52815150 xdr_error:
52825151 dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen);
5283
- return -EIO;
5284
-out_overflow:
5285
- print_overflow_msg(__func__, xdr);
52865152 return -EIO;
52875153 }
52885154
....@@ -5332,7 +5198,7 @@
53325198 return status;
53335199 p = xdr_inline_decode(xdr, 8);
53345200 if (unlikely(!p))
5335
- goto out_overflow;
5201
+ return -EIO;
53365202 eof = be32_to_cpup(p++);
53375203 count = be32_to_cpup(p);
53385204 recvd = xdr_read_pages(xdr, count);
....@@ -5345,9 +5211,6 @@
53455211 res->eof = eof;
53465212 res->count = count;
53475213 return 0;
5348
-out_overflow:
5349
- print_overflow_msg(__func__, xdr);
5350
- return -EIO;
53515214 }
53525215
53535216 static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir)
....@@ -5380,7 +5243,7 @@
53805243 /* Convert length of symlink */
53815244 p = xdr_inline_decode(xdr, 4);
53825245 if (unlikely(!p))
5383
- goto out_overflow;
5246
+ return -EIO;
53845247 len = be32_to_cpup(p);
53855248 if (len >= rcvbuf->page_len || len <= 0) {
53865249 dprintk("nfs: server returned giant symlink!\n");
....@@ -5396,14 +5259,11 @@
53965259 * The XDR encode routine has set things up so that
53975260 * the link text will be copied directly into the
53985261 * 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
54005263 * null-termination).
54015264 */
54025265 xdr_terminate_string(rcvbuf, len);
54035266 return 0;
5404
-out_overflow:
5405
- print_overflow_msg(__func__, xdr);
5406
- return -EIO;
54075267 }
54085268
54095269 static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
....@@ -5451,16 +5311,12 @@
54515311 uint32_t attrlen,
54525312 bitmap[3] = {0};
54535313 int status;
5454
- unsigned int pg_offset;
54555314
54565315 res->acl_len = 0;
54575316 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
54585317 goto out;
54595318
54605319 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;
54645320
54655321 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
54665322 goto out;
....@@ -5474,7 +5330,7 @@
54745330 /* The bitmap (xdr len + bitmaps) and the attr xdr len words
54755331 * are stored with the acl data to handle the problem of
54765332 * variable length bitmaps.*/
5477
- res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset;
5333
+ res->acl_data_offset = xdr_page_pos(xdr);
54785334 res->acl_len = attrlen;
54795335
54805336 /* Check for receive buffer overflow */
....@@ -5506,7 +5362,6 @@
55065362 return status;
55075363 if (decode_bitmap4(xdr, NULL, 0) >= 0)
55085364 return 0;
5509
- print_overflow_msg(__func__, xdr);
55105365 return -EIO;
55115366 }
55125367
....@@ -5518,7 +5373,7 @@
55185373
55195374 p = xdr_inline_decode(xdr, 8);
55205375 if (unlikely(!p))
5521
- goto out_overflow;
5376
+ return -EIO;
55225377 opnum = be32_to_cpup(p++);
55235378 if (opnum != OP_SETCLIENTID) {
55245379 dprintk("nfs: decode_setclientid: Server returned operation"
....@@ -5529,7 +5384,7 @@
55295384 if (nfserr == NFS_OK) {
55305385 p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE);
55315386 if (unlikely(!p))
5532
- goto out_overflow;
5387
+ return -EIO;
55335388 p = xdr_decode_hyper(p, &res->clientid);
55345389 memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE);
55355390 } else if (nfserr == NFSERR_CLID_INUSE) {
....@@ -5538,28 +5393,25 @@
55385393 /* skip netid string */
55395394 p = xdr_inline_decode(xdr, 4);
55405395 if (unlikely(!p))
5541
- goto out_overflow;
5396
+ return -EIO;
55425397 len = be32_to_cpup(p);
55435398 p = xdr_inline_decode(xdr, len);
55445399 if (unlikely(!p))
5545
- goto out_overflow;
5400
+ return -EIO;
55465401
55475402 /* skip uaddr string */
55485403 p = xdr_inline_decode(xdr, 4);
55495404 if (unlikely(!p))
5550
- goto out_overflow;
5405
+ return -EIO;
55515406 len = be32_to_cpup(p);
55525407 p = xdr_inline_decode(xdr, len);
55535408 if (unlikely(!p))
5554
- goto out_overflow;
5409
+ return -EIO;
55555410 return -NFSERR_CLID_INUSE;
55565411 } else
55575412 return nfs4_stat_to_errno(nfserr);
55585413
55595414 return 0;
5560
-out_overflow:
5561
- print_overflow_msg(__func__, xdr);
5562
- return -EIO;
55635415 }
55645416
55655417 static int decode_setclientid_confirm(struct xdr_stream *xdr)
....@@ -5578,13 +5430,10 @@
55785430
55795431 p = xdr_inline_decode(xdr, 8);
55805432 if (unlikely(!p))
5581
- goto out_overflow;
5433
+ return -EIO;
55825434 res->count = be32_to_cpup(p++);
55835435 res->verf->committed = be32_to_cpup(p++);
55845436 return decode_write_verifier(xdr, &res->verf->verifier);
5585
-out_overflow:
5586
- print_overflow_msg(__func__, xdr);
5587
- return -EIO;
55885437 }
55895438
55905439 static int decode_delegreturn(struct xdr_stream *xdr)
....@@ -5600,30 +5449,24 @@
56005449
56015450 p = xdr_inline_decode(xdr, 4);
56025451 if (unlikely(!p))
5603
- goto out_overflow;
5452
+ return -EIO;
56045453 oid_len = be32_to_cpup(p);
56055454 if (oid_len > GSS_OID_MAX_LEN)
5606
- goto out_err;
5455
+ return -EINVAL;
56075456
56085457 p = xdr_inline_decode(xdr, oid_len);
56095458 if (unlikely(!p))
5610
- goto out_overflow;
5459
+ return -EIO;
56115460 memcpy(flavor->flavor_info.oid.data, p, oid_len);
56125461 flavor->flavor_info.oid.len = oid_len;
56135462
56145463 p = xdr_inline_decode(xdr, 8);
56155464 if (unlikely(!p))
5616
- goto out_overflow;
5465
+ return -EIO;
56175466 flavor->flavor_info.qop = be32_to_cpup(p++);
56185467 flavor->flavor_info.service = be32_to_cpup(p);
56195468
56205469 return 0;
5621
-
5622
-out_overflow:
5623
- print_overflow_msg(__func__, xdr);
5624
- return -EIO;
5625
-out_err:
5626
- return -EINVAL;
56275470 }
56285471
56295472 static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
....@@ -5635,7 +5478,7 @@
56355478
56365479 p = xdr_inline_decode(xdr, 4);
56375480 if (unlikely(!p))
5638
- goto out_overflow;
5481
+ return -EIO;
56395482
56405483 res->flavors->num_flavors = 0;
56415484 num_flavors = be32_to_cpup(p);
....@@ -5647,7 +5490,7 @@
56475490
56485491 p = xdr_inline_decode(xdr, 4);
56495492 if (unlikely(!p))
5650
- goto out_overflow;
5493
+ return -EIO;
56515494 sec_flavor->flavor = be32_to_cpup(p);
56525495
56535496 if (sec_flavor->flavor == RPC_AUTH_GSS) {
....@@ -5661,9 +5504,6 @@
56615504 status = 0;
56625505 out:
56635506 return status;
5664
-out_overflow:
5665
- print_overflow_msg(__func__, xdr);
5666
- return -EIO;
56675507 }
56685508
56695509 static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
....@@ -5717,11 +5557,11 @@
57175557
57185558 p = xdr_inline_decode(xdr, 8);
57195559 if (unlikely(!p))
5720
- goto out_overflow;
5560
+ return -EIO;
57215561 xdr_decode_hyper(p, &res->clientid);
57225562 p = xdr_inline_decode(xdr, 12);
57235563 if (unlikely(!p))
5724
- goto out_overflow;
5564
+ return -EIO;
57255565 res->seqid = be32_to_cpup(p++);
57265566 res->flags = be32_to_cpup(p++);
57275567
....@@ -5745,7 +5585,7 @@
57455585 /* server_owner4.so_minor_id */
57465586 p = xdr_inline_decode(xdr, 8);
57475587 if (unlikely(!p))
5748
- goto out_overflow;
5588
+ return -EIO;
57495589 p = xdr_decode_hyper(p, &res->server_owner->minor_id);
57505590
57515591 /* server_owner4.so_major_id */
....@@ -5765,7 +5605,7 @@
57655605 /* Implementation Id */
57665606 p = xdr_inline_decode(xdr, 4);
57675607 if (unlikely(!p))
5768
- goto out_overflow;
5608
+ return -EIO;
57695609 impl_id_count = be32_to_cpup(p++);
57705610
57715611 if (impl_id_count) {
....@@ -5784,16 +5624,13 @@
57845624 /* nii_date */
57855625 p = xdr_inline_decode(xdr, 12);
57865626 if (unlikely(!p))
5787
- goto out_overflow;
5627
+ return -EIO;
57885628 p = xdr_decode_hyper(p, &res->impl_id->date.seconds);
57895629 res->impl_id->date.nseconds = be32_to_cpup(p);
57905630
57915631 /* if there's more than one entry, ignore the rest */
57925632 }
57935633 return 0;
5794
-out_overflow:
5795
- print_overflow_msg(__func__, xdr);
5796
- return -EIO;
57975634 }
57985635
57995636 static int decode_chan_attrs(struct xdr_stream *xdr,
....@@ -5804,7 +5641,7 @@
58045641
58055642 p = xdr_inline_decode(xdr, 28);
58065643 if (unlikely(!p))
5807
- goto out_overflow;
5644
+ return -EIO;
58085645 val = be32_to_cpup(p++); /* headerpadsz */
58095646 if (val)
58105647 return -EINVAL; /* no support for header padding yet */
....@@ -5822,12 +5659,9 @@
58225659 if (nr_attrs == 1) {
58235660 p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */
58245661 if (unlikely(!p))
5825
- goto out_overflow;
5662
+ return -EIO;
58265663 }
58275664 return 0;
5828
-out_overflow:
5829
- print_overflow_msg(__func__, xdr);
5830
- return -EIO;
58315665 }
58325666
58335667 static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid)
....@@ -5850,7 +5684,7 @@
58505684 /* dir flags, rdma mode bool */
58515685 p = xdr_inline_decode(xdr, 8);
58525686 if (unlikely(!p))
5853
- goto out_overflow;
5687
+ return -EIO;
58545688
58555689 res->dir = be32_to_cpup(p++);
58565690 if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH)
....@@ -5861,9 +5695,6 @@
58615695 res->use_conn_in_rdma_mode = true;
58625696
58635697 return 0;
5864
-out_overflow:
5865
- print_overflow_msg(__func__, xdr);
5866
- return -EIO;
58675698 }
58685699
58695700 static int decode_create_session(struct xdr_stream *xdr,
....@@ -5881,7 +5712,7 @@
58815712 /* seqid, flags */
58825713 p = xdr_inline_decode(xdr, 8);
58835714 if (unlikely(!p))
5884
- goto out_overflow;
5715
+ return -EIO;
58855716 res->seqid = be32_to_cpup(p++);
58865717 res->flags = be32_to_cpup(p);
58875718
....@@ -5890,9 +5721,6 @@
58905721 if (!status)
58915722 status = decode_chan_attrs(xdr, &res->bc_attrs);
58925723 return status;
5893
-out_overflow:
5894
- print_overflow_msg(__func__, xdr);
5895
- return -EIO;
58965724 }
58975725
58985726 static int decode_destroy_session(struct xdr_stream *xdr, void *dummy)
....@@ -5973,7 +5801,6 @@
59735801 res->sr_status = status;
59745802 return status;
59755803 out_overflow:
5976
- print_overflow_msg(__func__, xdr);
59775804 status = -EIO;
59785805 goto out_err;
59795806 #else /* CONFIG_NFS_V4_1 */
....@@ -6001,7 +5828,7 @@
60015828 if (status == -ETOOSMALL) {
60025829 p = xdr_inline_decode(xdr, 4);
60035830 if (unlikely(!p))
6004
- goto out_overflow;
5831
+ return -EIO;
60055832 pdev->mincount = be32_to_cpup(p);
60065833 dprintk("%s: Min count too small. mincnt = %u\n",
60075834 __func__, pdev->mincount);
....@@ -6011,7 +5838,7 @@
60115838
60125839 p = xdr_inline_decode(xdr, 8);
60135840 if (unlikely(!p))
6014
- goto out_overflow;
5841
+ return -EIO;
60155842 type = be32_to_cpup(p++);
60165843 if (type != pdev->layout_type) {
60175844 dprintk("%s: layout mismatch req: %u pdev: %u\n",
....@@ -6025,19 +5852,19 @@
60255852 */
60265853 pdev->mincount = be32_to_cpup(p);
60275854 if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount)
6028
- goto out_overflow;
5855
+ return -EIO;
60295856
60305857 /* Parse notification bitmap, verifying that it is zero. */
60315858 p = xdr_inline_decode(xdr, 4);
60325859 if (unlikely(!p))
6033
- goto out_overflow;
5860
+ return -EIO;
60345861 len = be32_to_cpup(p);
60355862 if (len) {
60365863 uint32_t i;
60375864
60385865 p = xdr_inline_decode(xdr, 4 * len);
60395866 if (unlikely(!p))
6040
- goto out_overflow;
5867
+ return -EIO;
60415868
60425869 res->notification = be32_to_cpup(p++);
60435870 for (i = 1; i < len; i++) {
....@@ -6049,9 +5876,6 @@
60495876 }
60505877 }
60515878 return 0;
6052
-out_overflow:
6053
- print_overflow_msg(__func__, xdr);
6054
- return -EIO;
60555879 }
60565880
60575881 static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
....@@ -6121,7 +5945,6 @@
61215945 res->status = status;
61225946 return status;
61235947 out_overflow:
6124
- print_overflow_msg(__func__, xdr);
61255948 status = -EIO;
61265949 goto out;
61275950 }
....@@ -6137,16 +5960,13 @@
61375960 return status;
61385961 p = xdr_inline_decode(xdr, 4);
61395962 if (unlikely(!p))
6140
- goto out_overflow;
5963
+ return -EIO;
61415964 res->lrs_present = be32_to_cpup(p);
61425965 if (res->lrs_present)
61435966 status = decode_layout_stateid(xdr, &res->stateid);
61445967 else
61455968 nfs4_stateid_copy(&res->stateid, &invalid_stateid);
61465969 return status;
6147
-out_overflow:
6148
- print_overflow_msg(__func__, xdr);
6149
- return -EIO;
61505970 }
61515971
61525972 static int decode_layoutcommit(struct xdr_stream *xdr,
....@@ -6164,19 +5984,16 @@
61645984
61655985 p = xdr_inline_decode(xdr, 4);
61665986 if (unlikely(!p))
6167
- goto out_overflow;
5987
+ return -EIO;
61685988 sizechanged = be32_to_cpup(p);
61695989
61705990 if (sizechanged) {
61715991 /* throw away new size */
61725992 p = xdr_inline_decode(xdr, 8);
61735993 if (unlikely(!p))
6174
- goto out_overflow;
5994
+ return -EIO;
61755995 }
61765996 return 0;
6177
-out_overflow:
6178
- print_overflow_msg(__func__, xdr);
6179
- return -EIO;
61805997 }
61815998
61825999 static int decode_test_stateid(struct xdr_stream *xdr,
....@@ -6192,21 +6009,17 @@
61926009
61936010 p = xdr_inline_decode(xdr, 4);
61946011 if (unlikely(!p))
6195
- goto out_overflow;
6012
+ return -EIO;
61966013 num_res = be32_to_cpup(p++);
61976014 if (num_res != 1)
6198
- goto out;
6015
+ return -EIO;
61996016
62006017 p = xdr_inline_decode(xdr, 4);
62016018 if (unlikely(!p))
6202
- goto out_overflow;
6019
+ return -EIO;
62036020 res->status = be32_to_cpup(p++);
62046021
62056022 return status;
6206
-out_overflow:
6207
- print_overflow_msg(__func__, xdr);
6208
-out:
6209
- return -EIO;
62106023 }
62116024
62126025 static int decode_free_stateid(struct xdr_stream *xdr,
....@@ -7343,6 +7156,8 @@
73437156 return status;
73447157 }
73457158
7159
+#endif
7160
+
73467161 /*
73477162 * Decode GET_LEASE_TIME response
73487163 */
....@@ -7363,6 +7178,8 @@
73637178 status = decode_fsinfo(xdr, res->lr_fsinfo);
73647179 return status;
73657180 }
7181
+
7182
+#ifdef CONFIG_NFS_V4_1
73667183
73677184 /*
73687185 * Decode RECLAIM_COMPLETE response
....@@ -7576,11 +7393,11 @@
75767393 uint64_t new_cookie;
75777394 __be32 *p = xdr_inline_decode(xdr, 4);
75787395 if (unlikely(!p))
7579
- goto out_overflow;
7396
+ return -EAGAIN;
75807397 if (*p == xdr_zero) {
75817398 p = xdr_inline_decode(xdr, 4);
75827399 if (unlikely(!p))
7583
- goto out_overflow;
7400
+ return -EAGAIN;
75847401 if (*p == xdr_zero)
75857402 return -EAGAIN;
75867403 entry->eof = 1;
....@@ -7589,13 +7406,13 @@
75897406
75907407 p = xdr_inline_decode(xdr, 12);
75917408 if (unlikely(!p))
7592
- goto out_overflow;
7409
+ return -EAGAIN;
75937410 p = xdr_decode_hyper(p, &new_cookie);
75947411 entry->len = be32_to_cpup(p);
75957412
75967413 p = xdr_inline_decode(xdr, entry->len);
75977414 if (unlikely(!p))
7598
- goto out_overflow;
7415
+ return -EAGAIN;
75997416 entry->name = (const char *) p;
76007417
76017418 /*
....@@ -7607,14 +7424,14 @@
76077424 entry->fattr->valid = 0;
76087425
76097426 if (decode_attr_bitmap(xdr, bitmap) < 0)
7610
- goto out_overflow;
7427
+ return -EAGAIN;
76117428
76127429 if (decode_attr_length(xdr, &len, &savep) < 0)
7613
- goto out_overflow;
7430
+ return -EAGAIN;
76147431
76157432 if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh,
76167433 NULL, entry->label, entry->server) < 0)
7617
- goto out_overflow;
7434
+ return -EAGAIN;
76187435 if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)
76197436 entry->ino = entry->fattr->mounted_on_fileid;
76207437 else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID)
....@@ -7628,10 +7445,6 @@
76287445 entry->cookie = new_cookie;
76297446
76307447 return 0;
7631
-
7632
-out_overflow:
7633
- print_overflow_msg(__func__, xdr);
7634
- return -EAGAIN;
76357448 }
76367449
76377450 /*
....@@ -7671,6 +7484,8 @@
76717484 { NFS4ERR_SYMLINK, -ELOOP },
76727485 { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP },
76737486 { NFS4ERR_DEADLOCK, -EDEADLK },
7487
+ { NFS4ERR_NOXATTR, -ENODATA },
7488
+ { NFS4ERR_XATTR2BIG, -E2BIG },
76747489 { -1, -EIO }
76757490 };
76767491
....@@ -7776,7 +7591,7 @@
77767591 PROC41(CREATE_SESSION, enc_create_session, dec_create_session),
77777592 PROC41(DESTROY_SESSION, enc_destroy_session, dec_destroy_session),
77787593 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),
77807595 PROC41(RECLAIM_COMPLETE,enc_reclaim_complete, dec_reclaim_complete),
77817596 PROC41(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo),
77827597 PROC41(LAYOUTGET, enc_layoutget, dec_layoutget),
....@@ -7796,7 +7611,14 @@
77967611 PROC42(CLONE, enc_clone, dec_clone),
77977612 PROC42(COPY, enc_copy, dec_copy),
77987613 PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel),
7614
+ PROC42(COPY_NOTIFY, enc_copy_notify, dec_copy_notify),
77997615 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),
78007622 };
78017623
78027624 static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)];