NFSoRDMA client updates for 5.1 New features: - Convert rpc auth layer to use xdr_streams - Config option to disable insecure enctypes - Reduce size of RPC receive buffers Bugfixes and cleanups: - Fix sparse warnings - Check inline size before providing a write chunk - Reduce the receive doorbell rate - Various tracepoint improvements [Trond: Fix up merge conflicts] Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Unified · Split
| @@ -74,17 +74,6 @@ static void nlm4_compute_offsets(const struct nlm_lock *lock, · 73 unmodified lines | ||
| 74 | 74 | *l_len = loff_t_to_s64(fl->fl_end - fl->fl_start + 1); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | −/* | |
| 78 | − * Handle decode buffer overflows out-of-line. | |
| 79 | − */ | |
| 80 | −static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |
| 81 | −{ | |
| 82 | − dprintk("lockd: %s prematurely hit the end of our receive buffer. " | |
| 83 | − "Remaining buffer length is %tu words.\n", | |
| 84 | − func, xdr->end - xdr->p); | |
| 85 | −} | |
| 86 | − | |
| 87 | − | |
| 88 | 77 | /* |
| 89 | 78 | * Encode/decode NLMv4 basic data types |
| 90 | 79 | * |
| @@ -176,7 +165,6 @@ out_size: · 85 unmodified lines | ||
| 176 | 165 | dprintk("NFS: returned cookie was too long: %u\n", length); |
| 177 | 166 | return -EIO; |
| 178 | 167 | out_overflow: |
| 179 | − print_overflow_msg(__func__, xdr); | |
| 180 | 168 | return -EIO; |
| 181 | 169 | } |
| 182 | 170 | |
| @@ -236,7 +224,6 @@ out_bad_xdr: · 53 unmodified lines | ||
| 236 | 224 | __func__, be32_to_cpup(p)); |
| 237 | 225 | return -EIO; |
| 238 | 226 | out_overflow: |
| 239 | − print_overflow_msg(__func__, xdr); | |
| 240 | 227 | return -EIO; |
| 241 | 228 | } |
| 242 | 229 | |
| @@ -309,7 +296,6 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result) · 66 unmodified lines | ||
| 309 | 296 | out: |
| 310 | 297 | return error; |
| 311 | 298 | out_overflow: |
| 312 | − print_overflow_msg(__func__, xdr); | |
| 313 | 299 | return -EIO; |
| 314 | 300 | } |
| 315 | 301 | |
| @@ -70,17 +70,6 @@ static void nlm_compute_offsets(const struct nlm_lock *lock, · 69 unmodified lines | ||
| 70 | 70 | *l_len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | −/* | |
| 74 | − * Handle decode buffer overflows out-of-line. | |
| 75 | − */ | |
| 76 | −static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |
| 77 | −{ | |
| 78 | − dprintk("lockd: %s prematurely hit the end of our receive buffer. " | |
| 79 | − "Remaining buffer length is %tu words.\n", | |
| 80 | − func, xdr->end - xdr->p); | |
| 81 | −} | |
| 82 | − | |
| 83 | − | |
| 84 | 73 | /* |
| 85 | 74 | * Encode/decode NLMv3 basic data types |
| 86 | 75 | * |
| @@ -173,7 +162,6 @@ out_size: · 86 unmodified lines | ||
| 173 | 162 | dprintk("NFS: returned cookie was too long: %u\n", length); |
| 174 | 163 | return -EIO; |
| 175 | 164 | out_overflow: |
| 176 | − print_overflow_msg(__func__, xdr); | |
| 177 | 165 | return -EIO; |
| 178 | 166 | } |
| 179 | 167 | |
| @@ -231,7 +219,6 @@ out_enum: · 51 unmodified lines | ||
| 231 | 219 | __func__, be32_to_cpup(p)); |
| 232 | 220 | return -EIO; |
| 233 | 221 | out_overflow: |
| 234 | − print_overflow_msg(__func__, xdr); | |
| 235 | 222 | return -EIO; |
| 236 | 223 | } |
| 237 | 224 | |
| @@ -303,7 +290,6 @@ static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result) · 65 unmodified lines | ||
| 303 | 290 | out: |
| 304 | 291 | return error; |
| 305 | 292 | out_overflow: |
| 306 | − print_overflow_msg(__func__, xdr); | |
| 307 | 293 | return -EIO; |
| 308 | 294 | } |
| 309 | 295 | |
| @@ -72,16 +72,6 @@ static int nfs4_encode_void(struct svc_rqst *rqstp, __be32 *p) · 71 unmodified lines | ||
| 72 | 72 | return xdr_ressize_check(rqstp, p); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | −static __be32 *read_buf(struct xdr_stream *xdr, size_t nbytes) | |
| 76 | −{ | |
| 77 | − __be32 *p; | |
| 78 | − | |
| 79 | − p = xdr_inline_decode(xdr, nbytes); | |
| 80 | − if (unlikely(p == NULL)) | |
| 81 | − printk(KERN_WARNING "NFS: NFSv4 callback reply buffer overflowed!\n"); | |
| 82 | − return p; | |
| 83 | −} | |
| 84 | − | |
| 85 | 75 | static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len, |
| 86 | 76 | const char **str, size_t maxlen) |
| 87 | 77 | { |
| @@ -98,13 +88,13 @@ static __be32 decode_fh(struct xdr_stream *xdr, struct nfs_fh *fh) · 10 unmodified lines | ||
| 98 | 88 | { |
| 99 | 89 | __be32 *p; |
| 100 | 90 | |
| 101 | − p = read_buf(xdr, 4); | |
| 91 | + p = xdr_inline_decode(xdr, 4); | |
| 102 | 92 | if (unlikely(p == NULL)) |
| 103 | 93 | return htonl(NFS4ERR_RESOURCE); |
| 104 | 94 | fh->size = ntohl(*p); |
| 105 | 95 | if (fh->size > NFS4_FHSIZE) |
| 106 | 96 | return htonl(NFS4ERR_BADHANDLE); |
| 107 | − p = read_buf(xdr, fh->size); | |
| 97 | + p = xdr_inline_decode(xdr, fh->size); | |
| 108 | 98 | if (unlikely(p == NULL)) |
| 109 | 99 | return htonl(NFS4ERR_RESOURCE); |
| 110 | 100 | memcpy(&fh->data[0], p, fh->size); |
| @@ -117,11 +107,11 @@ static __be32 decode_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) · 6 unmodified lines | ||
| 117 | 107 | __be32 *p; |
| 118 | 108 | unsigned int attrlen; |
| 119 | 109 | |
| 120 | − p = read_buf(xdr, 4); | |
| 110 | + p = xdr_inline_decode(xdr, 4); | |
| 121 | 111 | if (unlikely(p == NULL)) |
| 122 | 112 | return htonl(NFS4ERR_RESOURCE); |
| 123 | 113 | attrlen = ntohl(*p); |
| 124 | − p = read_buf(xdr, attrlen << 2); | |
| 114 | + p = xdr_inline_decode(xdr, attrlen << 2); | |
| 125 | 115 | if (unlikely(p == NULL)) |
| 126 | 116 | return htonl(NFS4ERR_RESOURCE); |
| 127 | 117 | if (likely(attrlen > 0)) |
| @@ -135,7 +125,7 @@ static __be32 decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) · 7 unmodified lines | ||
| 135 | 125 | { |
| 136 | 126 | __be32 *p; |
| 137 | 127 | |
| 138 | − p = read_buf(xdr, NFS4_STATEID_SIZE); | |
| 128 | + p = xdr_inline_decode(xdr, NFS4_STATEID_SIZE); | |
| 139 | 129 | if (unlikely(p == NULL)) |
| 140 | 130 | return htonl(NFS4ERR_RESOURCE); |
| 141 | 131 | memcpy(stateid->data, p, NFS4_STATEID_SIZE); |
| @@ -156,7 +146,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound · 14 unmodified lines | ||
| 156 | 146 | status = decode_string(xdr, &hdr->taglen, &hdr->tag, CB_OP_TAGLEN_MAXSZ); |
| 157 | 147 | if (unlikely(status != 0)) |
| 158 | 148 | return status; |
| 159 | − p = read_buf(xdr, 12); | |
| 149 | + p = xdr_inline_decode(xdr, 12); | |
| 160 | 150 | if (unlikely(p == NULL)) |
| 161 | 151 | return htonl(NFS4ERR_RESOURCE); |
| 162 | 152 | hdr->minorversion = ntohl(*p++); |
| @@ -176,7 +166,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound · 13 unmodified lines | ||
| 176 | 166 | static __be32 decode_op_hdr(struct xdr_stream *xdr, unsigned int *op) |
| 177 | 167 | { |
| 178 | 168 | __be32 *p; |
| 179 | − p = read_buf(xdr, 4); | |
| 169 | + p = xdr_inline_decode(xdr, 4); | |
| 180 | 170 | if (unlikely(p == NULL)) |
| 181 | 171 | return htonl(NFS4ERR_RESOURCE_HDR); |
| 182 | 172 | *op = ntohl(*p); |
| @@ -205,7 +195,7 @@ static __be32 decode_recall_args(struct svc_rqst *rqstp, · 22 unmodified lines | ||
| 205 | 195 | status = decode_delegation_stateid(xdr, &args->stateid); |
| 206 | 196 | if (unlikely(status != 0)) |
| 207 | 197 | return status; |
| 208 | − p = read_buf(xdr, 4); | |
| 198 | + p = xdr_inline_decode(xdr, 4); | |
| 209 | 199 | if (unlikely(p == NULL)) |
| 210 | 200 | return htonl(NFS4ERR_RESOURCE); |
| 211 | 201 | args->truncate = ntohl(*p); |
| @@ -227,7 +217,7 @@ static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp, · 15 unmodified lines | ||
| 227 | 217 | __be32 status = 0; |
| 228 | 218 | uint32_t iomode; |
| 229 | 219 | |
| 230 | − p = read_buf(xdr, 4 * sizeof(uint32_t)); | |
| 220 | + p = xdr_inline_decode(xdr, 4 * sizeof(uint32_t)); | |
| 231 | 221 | if (unlikely(p == NULL)) |
| 232 | 222 | return htonl(NFS4ERR_BADXDR); |
| 233 | 223 | |
| @@ -245,14 +235,14 @@ static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp, · 11 unmodified lines | ||
| 245 | 235 | if (unlikely(status != 0)) |
| 246 | 236 | return status; |
| 247 | 237 | |
| 248 | − p = read_buf(xdr, 2 * sizeof(uint64_t)); | |
| 238 | + p = xdr_inline_decode(xdr, 2 * sizeof(uint64_t)); | |
| 249 | 239 | if (unlikely(p == NULL)) |
| 250 | 240 | return htonl(NFS4ERR_BADXDR); |
| 251 | 241 | p = xdr_decode_hyper(p, &args->cbl_range.offset); |
| 252 | 242 | p = xdr_decode_hyper(p, &args->cbl_range.length); |
| 253 | 243 | return decode_layout_stateid(xdr, &args->cbl_stateid); |
| 254 | 244 | } else if (args->cbl_recall_type == RETURN_FSID) { |
| 255 | − p = read_buf(xdr, 2 * sizeof(uint64_t)); | |
| 245 | + p = xdr_inline_decode(xdr, 2 * sizeof(uint64_t)); | |
| 256 | 246 | if (unlikely(p == NULL)) |
| 257 | 247 | return htonl(NFS4ERR_BADXDR); |
| 258 | 248 | p = xdr_decode_hyper(p, &args->cbl_fsid.major); |
| @@ -275,7 +265,7 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp, · 16 unmodified lines | ||
| 275 | 265 | args->ndevs = 0; |
| 276 | 266 | |
| 277 | 267 | /* Num of device notifications */ |
| 278 | − p = read_buf(xdr, sizeof(uint32_t)); | |
| 268 | + p = xdr_inline_decode(xdr, sizeof(uint32_t)); | |
| 279 | 269 | if (unlikely(p == NULL)) { |
| 280 | 270 | status = htonl(NFS4ERR_BADXDR); |
| 281 | 271 | goto out; |
| @@ -298,7 +288,8 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp, · 16 unmodified lines | ||
| 298 | 288 | for (i = 0; i < n; i++) { |
| 299 | 289 | struct cb_devicenotifyitem *dev = &args->devs[i]; |
| 300 | 290 | |
| 301 | − p = read_buf(xdr, (4 * sizeof(uint32_t)) + NFS4_DEVICEID4_SIZE); | |
| 291 | + p = xdr_inline_decode(xdr, (4 * sizeof(uint32_t)) + | |
| 292 | + NFS4_DEVICEID4_SIZE); | |
| 302 | 293 | if (unlikely(p == NULL)) { |
| 303 | 294 | status = htonl(NFS4ERR_BADXDR); |
| 304 | 295 | goto err; |
| @@ -329,7 +320,7 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp, · 24 unmodified lines | ||
| 329 | 320 | p += XDR_QUADLEN(NFS4_DEVICEID4_SIZE); |
| 330 | 321 | |
| 331 | 322 | if (dev->cbd_layout_type == NOTIFY_DEVICEID4_CHANGE) { |
| 332 | − p = read_buf(xdr, sizeof(uint32_t)); | |
| 323 | + p = xdr_inline_decode(xdr, sizeof(uint32_t)); | |
| 333 | 324 | if (unlikely(p == NULL)) { |
| 334 | 325 | status = htonl(NFS4ERR_BADXDR); |
| 335 | 326 | goto err; |
| @@ -359,7 +350,7 @@ static __be32 decode_sessionid(struct xdr_stream *xdr, · 23 unmodified lines | ||
| 359 | 350 | { |
| 360 | 351 | __be32 *p; |
| 361 | 352 | |
| 362 | − p = read_buf(xdr, NFS4_MAX_SESSIONID_LEN); | |
| 353 | + p = xdr_inline_decode(xdr, NFS4_MAX_SESSIONID_LEN); | |
| 363 | 354 | if (unlikely(p == NULL)) |
| 364 | 355 | return htonl(NFS4ERR_RESOURCE); |
| 365 | 356 | |
| @@ -379,13 +370,13 @@ static __be32 decode_rc_list(struct xdr_stream *xdr, · 13 unmodified lines | ||
| 379 | 370 | goto out; |
| 380 | 371 | |
| 381 | 372 | status = htonl(NFS4ERR_RESOURCE); |
| 382 | − p = read_buf(xdr, sizeof(uint32_t)); | |
| 373 | + p = xdr_inline_decode(xdr, sizeof(uint32_t)); | |
| 383 | 374 | if (unlikely(p == NULL)) |
| 384 | 375 | goto out; |
| 385 | 376 | |
| 386 | 377 | rc_list->rcl_nrefcalls = ntohl(*p++); |
| 387 | 378 | if (rc_list->rcl_nrefcalls) { |
| 388 | − p = read_buf(xdr, | |
| 379 | + p = xdr_inline_decode(xdr, | |
| 389 | 380 | rc_list->rcl_nrefcalls * 2 * sizeof(uint32_t)); |
| 390 | 381 | if (unlikely(p == NULL)) |
| 391 | 382 | goto out; |
| @@ -418,7 +409,7 @@ static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp, · 26 unmodified lines | ||
| 418 | 409 | if (status) |
| 419 | 410 | return status; |
| 420 | 411 | |
| 421 | − p = read_buf(xdr, 5 * sizeof(uint32_t)); | |
| 412 | + p = xdr_inline_decode(xdr, 5 * sizeof(uint32_t)); | |
| 422 | 413 | if (unlikely(p == NULL)) |
| 423 | 414 | return htonl(NFS4ERR_RESOURCE); |
| 424 | 415 | |
| @@ -461,7 +452,7 @@ static __be32 decode_recallany_args(struct svc_rqst *rqstp, · 36 unmodified lines | ||
| 461 | 452 | uint32_t bitmap[2]; |
| 462 | 453 | __be32 *p, status; |
| 463 | 454 | |
| 464 | − p = read_buf(xdr, 4); | |
| 455 | + p = xdr_inline_decode(xdr, 4); | |
| 465 | 456 | if (unlikely(p == NULL)) |
| 466 | 457 | return htonl(NFS4ERR_BADXDR); |
| 467 | 458 | args->craa_objs_to_keep = ntohl(*p++); |
| @@ -480,7 +471,7 @@ static __be32 decode_recallslot_args(struct svc_rqst *rqstp, · 12 unmodified lines | ||
| 480 | 471 | struct cb_recallslotargs *args = argp; |
| 481 | 472 | __be32 *p; |
| 482 | 473 | |
| 483 | − p = read_buf(xdr, 4); | |
| 474 | + p = xdr_inline_decode(xdr, 4); | |
| 484 | 475 | if (unlikely(p == NULL)) |
| 485 | 476 | return htonl(NFS4ERR_BADXDR); |
| 486 | 477 | args->crsa_target_highest_slotid = ntohl(*p++); |
| @@ -492,14 +483,14 @@ static __be32 decode_lockowner(struct xdr_stream *xdr, struct cb_notify_lock_arg · 5 unmodified lines | ||
| 492 | 483 | __be32 *p; |
| 493 | 484 | unsigned int len; |
| 494 | 485 | |
| 495 | − p = read_buf(xdr, 12); | |
| 486 | + p = xdr_inline_decode(xdr, 12); | |
| 496 | 487 | if (unlikely(p == NULL)) |
| 497 | 488 | return htonl(NFS4ERR_BADXDR); |
| 498 | 489 | |
| 499 | 490 | p = xdr_decode_hyper(p, &args->cbnl_owner.clientid); |
| 500 | 491 | len = be32_to_cpu(*p); |
| 501 | 492 | |
| 502 | − p = read_buf(xdr, len); | |
| 493 | + p = xdr_inline_decode(xdr, len); | |
| 503 | 494 | if (unlikely(p == NULL)) |
| 504 | 495 | return htonl(NFS4ERR_BADXDR); |
| 505 | 496 | |
| @@ -537,7 +528,7 @@ static __be32 decode_write_response(struct xdr_stream *xdr, · 31 unmodified lines | ||
| 537 | 528 | __be32 *p; |
| 538 | 529 | |
| 539 | 530 | /* skip the always zero field */ |
| 540 | − p = read_buf(xdr, 4); | |
| 531 | + p = xdr_inline_decode(xdr, 4); | |
| 541 | 532 | if (unlikely(!p)) |
| 542 | 533 | goto out; |
| 543 | 534 | p++; |
| @@ -577,7 +568,7 @@ static __be32 decode_offload_args(struct svc_rqst *rqstp, · 33 unmodified lines | ||
| 577 | 568 | return status; |
| 578 | 569 | |
| 579 | 570 | /* decode status */ |
| 580 | − p = read_buf(xdr, 4); | |
| 571 | + p = xdr_inline_decode(xdr, 4); | |
| 581 | 572 | if (unlikely(!p)) |
| 582 | 573 | goto out; |
| 583 | 574 | args->error = ntohl(*p++); |
| @@ -943,10 +934,11 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp) · 359 unmodified lines | ||
| 943 | 934 | }; |
| 944 | 935 | unsigned int nops = 0; |
| 945 | 936 | |
| 946 | − xdr_init_decode(&xdr_in, &rqstp->rq_arg, rqstp->rq_arg.head[0].iov_base); | |
| 937 | + xdr_init_decode(&xdr_in, &rqstp->rq_arg, | |
| 938 | + rqstp->rq_arg.head[0].iov_base, NULL); | |
| 947 | 939 | |
| 948 | 940 | p = (__be32*)((char *)rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len); |
| 949 | − xdr_init_encode(&xdr_out, &rqstp->rq_res, p); | |
| 941 | + xdr_init_encode(&xdr_out, &rqstp->rq_res, p, NULL); | |
| 950 | 942 | |
| 951 | 943 | status = decode_compound_hdr_arg(&xdr_in, &hdr_arg); |
| 952 | 944 | if (status == htonl(NFS4ERR_RESOURCE)) |
| @@ -2036,7 +2036,7 @@ ff_layout_encode_layoutreturn(struct xdr_stream *xdr, · 2035 unmodified lines | ||
| 2036 | 2036 | |
| 2037 | 2037 | dprintk("%s: Begin\n", __func__); |
| 2038 | 2038 | |
| 2039 | − xdr_init_encode(&tmp_xdr, &tmp_buf, NULL); | |
| 2039 | + xdr_init_encode(&tmp_xdr, &tmp_buf, NULL, NULL); | |
| 2040 | 2040 | |
| 2041 | 2041 | ff_layout_encode_ioerr(&tmp_xdr, args, ff_args); |
| 2042 | 2042 | ff_layout_encode_iostats_array(&tmp_xdr, args, ff_args); |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | #include <linux/nfs.h> |
| 23 | 23 | #include <linux/nfs2.h> |
| 24 | 24 | #include <linux/nfs_fs.h> |
| 25 | +#include "nfstrace.h" | |
| 25 | 26 | #include "internal.h" |
| 26 | 27 | |
| 27 | 28 | #define NFSDBG_FACILITY NFSDBG_XDR |
| @@ -55,41 +56,15 @@ · 27 unmodified lines | ||
| 55 | 56 | |
| 56 | 57 | #define NFS_attrstat_sz (1+NFS_fattr_sz) |
| 57 | 58 | #define NFS_diropres_sz (1+NFS_fhandle_sz+NFS_fattr_sz) |
| 58 | −#define NFS_readlinkres_sz (2) | |
| 59 | −#define NFS_readres_sz (1+NFS_fattr_sz+1) | |
| 59 | +#define NFS_readlinkres_sz (2+1) | |
| 60 | +#define NFS_readres_sz (1+NFS_fattr_sz+1+1) | |
| 60 | 61 | #define NFS_writeres_sz (NFS_attrstat_sz) |
| 61 | 62 | #define NFS_stat_sz (1) |
| 62 | −#define NFS_readdirres_sz (1) | |
| 63 | +#define NFS_readdirres_sz (1+1) | |
| 63 | 64 | #define NFS_statfsres_sz (1+NFS_info_sz) |
| 64 | 65 | |
| 65 | 66 | static int nfs_stat_to_errno(enum nfs_stat); |
| 66 | 67 | |
| 67 | −/* | |
| 68 | − * While encoding arguments, set up the reply buffer in advance to | |
| 69 | − * receive reply data directly into the page cache. | |
| 70 | − */ | |
| 71 | −static void prepare_reply_buffer(struct rpc_rqst *req, struct page **pages, | |
| 72 | − unsigned int base, unsigned int len, | |
| 73 | − unsigned int bufsize) | |
| 74 | −{ | |
| 75 | − struct rpc_auth *auth = req->rq_cred->cr_auth; | |
| 76 | − unsigned int replen; | |
| 77 | − | |
| 78 | − replen = RPC_REPHDRSIZE + auth->au_rslack + bufsize; | |
| 79 | − xdr_inline_pages(&req->rq_rcv_buf, replen << 2, pages, base, len); | |
| 80 | −} | |
| 81 | − | |
| 82 | −/* | |
| 83 | − * Handle decode buffer overflows out-of-line. | |
| 84 | − */ | |
| 85 | −static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |
| 86 | −{ | |
| 87 | − dprintk("NFS: %s prematurely hit the end of our receive buffer. " | |
| 88 | − "Remaining buffer length is %tu words.\n", | |
| 89 | − func, xdr->end - xdr->p); | |
| 90 | −} | |
| 91 | − | |
| 92 | − | |
| 93 | 68 | /* |
| 94 | 69 | * Encode/decode NFSv2 basic data types |
| 95 | 70 | * |
| @@ -110,8 +85,8 @@ static int decode_nfsdata(struct xdr_stream *xdr, struct nfs_pgio_res *result) · 14 unmodified lines | ||
| 110 | 85 | __be32 *p; |
| 111 | 86 | |
| 112 | 87 | p = xdr_inline_decode(xdr, 4); |
| 113 | − if (unlikely(p == NULL)) | |
| 114 | − goto out_overflow; | |
| 88 | + if (unlikely(!p)) | |
| 89 | + return -EIO; | |
| 115 | 90 | count = be32_to_cpup(p); |
| 116 | 91 | recvd = xdr_read_pages(xdr, count); |
| 117 | 92 | if (unlikely(count > recvd)) |
| @@ -125,9 +100,6 @@ out_cheating: · 7 unmodified lines | ||
| 125 | 100 | "count %u > recvd %u\n", count, recvd); |
| 126 | 101 | count = recvd; |
| 127 | 102 | goto out; |
| 128 | −out_overflow: | |
| 129 | − print_overflow_msg(__func__, xdr); | |
| 130 | − return -EIO; | |
| 131 | 103 | } |
| 132 | 104 | |
| 133 | 105 | /* |
| @@ -157,13 +129,16 @@ static int decode_stat(struct xdr_stream *xdr, enum nfs_stat *status) · 23 unmodified lines | ||
| 157 | 129 | __be32 *p; |
| 158 | 130 | |
| 159 | 131 | p = xdr_inline_decode(xdr, 4); |
| 160 | − if (unlikely(p == NULL)) | |
| 161 | − goto out_overflow; | |
| 132 | + if (unlikely(!p)) | |
| 133 | + return -EIO; | |
| 134 | + if (unlikely(*p != cpu_to_be32(NFS_OK))) | |
| 135 | + goto out_status; | |
| 136 | + *status = 0; | |
| 137 | + return 0; | |
| 138 | +out_status: | |
| 162 | 139 | *status = be32_to_cpup(p); |
| 140 | + trace_nfs_xdr_status((int)*status); | |
| 163 | 141 | return 0; |
| 164 | −out_overflow: | |
| 165 | − print_overflow_msg(__func__, xdr); | |
| 166 | − return -EIO; | |
| 167 | 142 | } |
| 168 | 143 | |
| 169 | 144 | /* |
| @@ -205,14 +180,11 @@ static int decode_fhandle(struct xdr_stream *xdr, struct nfs_fh *fh) · 35 unmodified lines | ||
| 205 | 180 | __be32 *p; |
| 206 | 181 | |
| 207 | 182 | p = xdr_inline_decode(xdr, NFS2_FHSIZE); |
| 208 | − if (unlikely(p == NULL)) | |
| 209 | − goto out_overflow; | |
| 183 | + if (unlikely(!p)) | |
| 184 | + return -EIO; | |
| 210 | 185 | fh->size = NFS2_FHSIZE; |
| 211 | 186 | memcpy(fh->data, p, NFS2_FHSIZE); |
| 212 | 187 | return 0; |
| 213 | −out_overflow: | |
| 214 | − print_overflow_msg(__func__, xdr); | |
| 215 | − return -EIO; | |
| 216 | 188 | } |
| 217 | 189 | |
| 218 | 190 | /* |
| @@ -282,8 +254,8 @@ static int decode_fattr(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 63 unmodified lines | ||
| 282 | 254 | __be32 *p; |
| 283 | 255 | |
| 284 | 256 | p = xdr_inline_decode(xdr, NFS_fattr_sz << 2); |
| 285 | − if (unlikely(p == NULL)) | |
| 286 | − goto out_overflow; | |
| 257 | + if (unlikely(!p)) | |
| 258 | + return -EIO; | |
| 287 | 259 | |
| 288 | 260 | fattr->valid |= NFS_ATTR_FATTR_V2; |
| 289 | 261 | |
| @@ -325,9 +297,6 @@ out_uid: · 35 unmodified lines | ||
| 325 | 297 | out_gid: |
| 326 | 298 | dprintk("NFS: returned invalid gid\n"); |
| 327 | 299 | return -EINVAL; |
| 328 | −out_overflow: | |
| 329 | − print_overflow_msg(__func__, xdr); | |
| 330 | − return -EIO; | |
| 331 | 300 | } |
| 332 | 301 | |
| 333 | 302 | /* |
| @@ -416,23 +385,20 @@ static int decode_filename_inline(struct xdr_stream *xdr, · 82 unmodified lines | ||
| 416 | 385 | u32 count; |
| 417 | 386 | |
| 418 | 387 | p = xdr_inline_decode(xdr, 4); |
| 419 | − if (unlikely(p == NULL)) | |
| 420 | − goto out_overflow; | |
| 388 | + if (unlikely(!p)) | |
| 389 | + return -EIO; | |
| 421 | 390 | count = be32_to_cpup(p); |
| 422 | 391 | if (count > NFS3_MAXNAMLEN) |
| 423 | 392 | goto out_nametoolong; |
| 424 | 393 | p = xdr_inline_decode(xdr, count); |
| 425 | − if (unlikely(p == NULL)) | |
| 426 | − goto out_overflow; | |
| 394 | + if (unlikely(!p)) | |
| 395 | + return -EIO; | |
| 427 | 396 | *name = (const char *)p; |
| 428 | 397 | *length = count; |
| 429 | 398 | return 0; |
| 430 | 399 | out_nametoolong: |
| 431 | 400 | dprintk("NFS: returned filename too long: %u\n", count); |
| 432 | 401 | return -ENAMETOOLONG; |
| 433 | −out_overflow: | |
| 434 | − print_overflow_msg(__func__, xdr); | |
| 435 | − return -EIO; | |
| 436 | 402 | } |
| 437 | 403 | |
| 438 | 404 | /* |
| @@ -455,8 +421,8 @@ static int decode_path(struct xdr_stream *xdr) · 16 unmodified lines | ||
| 455 | 421 | __be32 *p; |
| 456 | 422 | |
| 457 | 423 | p = xdr_inline_decode(xdr, 4); |
| 458 | − if (unlikely(p == NULL)) | |
| 459 | − goto out_overflow; | |
| 424 | + if (unlikely(!p)) | |
| 425 | + return -EIO; | |
| 460 | 426 | length = be32_to_cpup(p); |
| 461 | 427 | if (unlikely(length >= xdr->buf->page_len || length > NFS_MAXPATHLEN)) |
| 462 | 428 | goto out_size; |
| @@ -472,9 +438,6 @@ out_cheating: · 9 unmodified lines | ||
| 472 | 438 | dprintk("NFS: server cheating in pathname result: " |
| 473 | 439 | "length %u > received %u\n", length, recvd); |
| 474 | 440 | return -EIO; |
| 475 | −out_overflow: | |
| 476 | − print_overflow_msg(__func__, xdr); | |
| 477 | − return -EIO; | |
| 478 | 441 | } |
| 479 | 442 | |
| 480 | 443 | /* |
| @@ -615,8 +578,8 @@ static void nfs2_xdr_enc_readlinkargs(struct rpc_rqst *req, · 134 unmodified lines | ||
| 615 | 578 | const struct nfs_readlinkargs *args = data; |
| 616 | 579 | |
| 617 | 580 | encode_fhandle(xdr, args->fh); |
| 618 | − prepare_reply_buffer(req, args->pages, args->pgbase, | |
| 619 | − args->pglen, NFS_readlinkres_sz); | |
| 581 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 582 | + args->pglen, NFS_readlinkres_sz); | |
| 620 | 583 | } |
| 621 | 584 | |
| 622 | 585 | /* |
| @@ -651,8 +614,8 @@ static void nfs2_xdr_enc_readargs(struct rpc_rqst *req, · 28 unmodified lines | ||
| 651 | 614 | const struct nfs_pgio_args *args = data; |
| 652 | 615 | |
| 653 | 616 | encode_readargs(xdr, args); |
| 654 | − prepare_reply_buffer(req, args->pages, args->pgbase, | |
| 655 | − args->count, NFS_readres_sz); | |
| 617 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 618 | + args->count, NFS_readres_sz); | |
| 656 | 619 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
| 657 | 620 | } |
| 658 | 621 | |
| @@ -809,8 +772,8 @@ static void nfs2_xdr_enc_readdirargs(struct rpc_rqst *req, · 150 unmodified lines | ||
| 809 | 772 | const struct nfs_readdirargs *args = data; |
| 810 | 773 | |
| 811 | 774 | encode_readdirargs(xdr, args); |
| 812 | − prepare_reply_buffer(req, args->pages, 0, | |
| 813 | − args->count, NFS_readdirres_sz); | |
| 775 | + rpc_prepare_reply_pages(req, args->pages, 0, | |
| 776 | + args->count, NFS_readdirres_sz); | |
| 814 | 777 | } |
| 815 | 778 | |
| 816 | 779 | /* |
| @@ -951,12 +914,12 @@ int nfs2_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 134 unmodified lines | ||
| 951 | 914 | int error; |
| 952 | 915 | |
| 953 | 916 | p = xdr_inline_decode(xdr, 4); |
| 954 | − if (unlikely(p == NULL)) | |
| 955 | − goto out_overflow; | |
| 917 | + if (unlikely(!p)) | |
| 918 | + return -EAGAIN; | |
| 956 | 919 | if (*p++ == xdr_zero) { |
| 957 | 920 | p = xdr_inline_decode(xdr, 4); |
| 958 | − if (unlikely(p == NULL)) | |
| 959 | − goto out_overflow; | |
| 921 | + if (unlikely(!p)) | |
| 922 | + return -EAGAIN; | |
| 960 | 923 | if (*p++ == xdr_zero) |
| 961 | 924 | return -EAGAIN; |
| 962 | 925 | entry->eof = 1; |
| @@ -964,8 +927,8 @@ int nfs2_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 1 unmodified line | ||
| 964 | 927 | } |
| 965 | 928 | |
| 966 | 929 | p = xdr_inline_decode(xdr, 4); |
| 967 | − if (unlikely(p == NULL)) | |
| 968 | − goto out_overflow; | |
| 930 | + if (unlikely(!p)) | |
| 931 | + return -EAGAIN; | |
| 969 | 932 | entry->ino = be32_to_cpup(p); |
| 970 | 933 | |
| 971 | 934 | error = decode_filename_inline(xdr, &entry->name, &entry->len); |
| @@ -978,17 +941,13 @@ int nfs2_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 6 unmodified lines | ||
| 978 | 941 | */ |
| 979 | 942 | entry->prev_cookie = entry->cookie; |
| 980 | 943 | p = xdr_inline_decode(xdr, 4); |
| 981 | − if (unlikely(p == NULL)) | |
| 982 | − goto out_overflow; | |
| 944 | + if (unlikely(!p)) | |
| 945 | + return -EAGAIN; | |
| 983 | 946 | entry->cookie = be32_to_cpup(p); |
| 984 | 947 | |
| 985 | 948 | entry->d_type = DT_UNKNOWN; |
| 986 | 949 | |
| 987 | 950 | return 0; |
| 988 | − | |
| 989 | −out_overflow: | |
| 990 | − print_overflow_msg(__func__, xdr); | |
| 991 | − return -EAGAIN; | |
| 992 | 951 | } |
| 993 | 952 | |
| 994 | 953 | /* |
| @@ -1052,17 +1011,14 @@ static int decode_info(struct xdr_stream *xdr, struct nfs2_fsstat *result) · 57 unmodified lines | ||
| 1052 | 1011 | __be32 *p; |
| 1053 | 1012 | |
| 1054 | 1013 | p = xdr_inline_decode(xdr, NFS_info_sz << 2); |
| 1055 | − if (unlikely(p == NULL)) | |
| 1056 | − goto out_overflow; | |
| 1014 | + if (unlikely(!p)) | |
| 1015 | + return -EIO; | |
| 1057 | 1016 | result->tsize = be32_to_cpup(p++); |
| 1058 | 1017 | result->bsize = be32_to_cpup(p++); |
| 1059 | 1018 | result->blocks = be32_to_cpup(p++); |
| 1060 | 1019 | result->bfree = be32_to_cpup(p++); |
| 1061 | 1020 | result->bavail = be32_to_cpup(p); |
| 1062 | 1021 | return 0; |
| 1063 | −out_overflow: | |
| 1064 | − print_overflow_msg(__func__, xdr); | |
| 1065 | − return -EIO; | |
| 1066 | 1022 | } |
| 1067 | 1023 | |
| 1068 | 1024 | static int nfs2_xdr_dec_statfsres(struct rpc_rqst *req, struct xdr_stream *xdr, |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #include <linux/nfs3.h> |
| 22 | 22 | #include <linux/nfs_fs.h> |
| 23 | 23 | #include <linux/nfsacl.h> |
| 24 | +#include "nfstrace.h" | |
| 24 | 25 | #include "internal.h" |
| 25 | 26 | |
| 26 | 27 | #define NFSDBG_FACILITY NFSDBG_XDR |
| @@ -68,13 +69,13 @@ · 41 unmodified lines | ||
| 68 | 69 | #define NFS3_removeres_sz (NFS3_setattrres_sz) |
| 69 | 70 | #define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz)) |
| 70 | 71 | #define NFS3_accessres_sz (1+NFS3_post_op_attr_sz+1) |
| 71 | −#define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1) | |
| 72 | −#define NFS3_readres_sz (1+NFS3_post_op_attr_sz+3) | |
| 72 | +#define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1+1) | |
| 73 | +#define NFS3_readres_sz (1+NFS3_post_op_attr_sz+3+1) | |
| 73 | 74 | #define NFS3_writeres_sz (1+NFS3_wcc_data_sz+4) |
| 74 | 75 | #define NFS3_createres_sz (1+NFS3_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz) |
| 75 | 76 | #define NFS3_renameres_sz (1+(2 * NFS3_wcc_data_sz)) |
| 76 | 77 | #define NFS3_linkres_sz (1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz) |
| 77 | −#define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2) | |
| 78 | +#define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2+1) | |
| 78 | 79 | #define NFS3_fsstatres_sz (1+NFS3_post_op_attr_sz+13) |
| 79 | 80 | #define NFS3_fsinfores_sz (1+NFS3_post_op_attr_sz+12) |
| 80 | 81 | #define NFS3_pathconfres_sz (1+NFS3_post_op_attr_sz+6) |
| @@ -84,7 +85,7 @@ · 3 unmodified lines | ||
| 84 | 85 | #define ACL3_setaclargs_sz (NFS3_fh_sz+1+ \ |
| 85 | 86 | XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE)) |
| 86 | 87 | #define ACL3_getaclres_sz (1+NFS3_post_op_attr_sz+1+ \ |
| 87 | − XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE)) | |
| 88 | + XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE)+1) | |
| 88 | 89 | #define ACL3_setaclres_sz (1+NFS3_post_op_attr_sz) |
| 89 | 90 | |
| 90 | 91 | static int nfs3_stat_to_errno(enum nfs_stat); |
| @@ -103,32 +104,6 @@ static const umode_t nfs_type2fmt[] = { · 12 unmodified lines | ||
| 103 | 104 | [NF3FIFO] = S_IFIFO, |
| 104 | 105 | }; |
| 105 | 106 | |
| 106 | −/* | |
| 107 | − * While encoding arguments, set up the reply buffer in advance to | |
| 108 | − * receive reply data directly into the page cache. | |
| 109 | − */ | |
| 110 | −static void prepare_reply_buffer(struct rpc_rqst *req, struct page **pages, | |
| 111 | − unsigned int base, unsigned int len, | |
| 112 | − unsigned int bufsize) | |
| 113 | −{ | |
| 114 | − struct rpc_auth *auth = req->rq_cred->cr_auth; | |
| 115 | − unsigned int replen; | |
| 116 | − | |
| 117 | − replen = RPC_REPHDRSIZE + auth->au_rslack + bufsize; | |
| 118 | − xdr_inline_pages(&req->rq_rcv_buf, replen << 2, pages, base, len); | |
| 119 | −} | |
| 120 | − | |
| 121 | −/* | |
| 122 | − * Handle decode buffer overflows out-of-line. | |
| 123 | − */ | |
| 124 | −static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |
| 125 | −{ | |
| 126 | − dprintk("NFS: %s prematurely hit the end of our receive buffer. " | |
| 127 | − "Remaining buffer length is %tu words.\n", | |
| 128 | − func, xdr->end - xdr->p); | |
| 129 | −} | |
| 130 | − | |
| 131 | − | |
| 132 | 107 | /* |
| 133 | 108 | * Encode/decode NFSv3 basic data types |
| 134 | 109 | * |
| @@ -151,13 +126,10 @@ static int decode_uint32(struct xdr_stream *xdr, u32 *value) · 16 unmodified lines | ||
| 151 | 126 | __be32 *p; |
| 152 | 127 | |
| 153 | 128 | p = xdr_inline_decode(xdr, 4); |
| 154 | − if (unlikely(p == NULL)) | |
| 155 | − goto out_overflow; | |
| 129 | + if (unlikely(!p)) | |
| 130 | + return -EIO; | |
| 156 | 131 | *value = be32_to_cpup(p); |
| 157 | 132 | return 0; |
| 158 | −out_overflow: | |
| 159 | − print_overflow_msg(__func__, xdr); | |
| 160 | − return -EIO; | |
| 161 | 133 | } |
| 162 | 134 | |
| 163 | 135 | static int decode_uint64(struct xdr_stream *xdr, u64 *value) |
| @@ -165,13 +137,10 @@ static int decode_uint64(struct xdr_stream *xdr, u64 *value) · 1 unmodified line | ||
| 165 | 137 | __be32 *p; |
| 166 | 138 | |
| 167 | 139 | p = xdr_inline_decode(xdr, 8); |
| 168 | − if (unlikely(p == NULL)) | |
| 169 | − goto out_overflow; | |
| 140 | + if (unlikely(!p)) | |
| 141 | + return -EIO; | |
| 170 | 142 | xdr_decode_hyper(p, value); |
| 171 | 143 | return 0; |
| 172 | −out_overflow: | |
| 173 | − print_overflow_msg(__func__, xdr); | |
| 174 | − return -EIO; | |
| 175 | 144 | } |
| 176 | 145 | |
| 177 | 146 | /* |
| @@ -211,14 +180,14 @@ static int decode_inline_filename3(struct xdr_stream *xdr, · 33 unmodified lines | ||
| 211 | 180 | u32 count; |
| 212 | 181 | |
| 213 | 182 | p = xdr_inline_decode(xdr, 4); |
| 214 | − if (unlikely(p == NULL)) | |
| 215 | − goto out_overflow; | |
| 183 | + if (unlikely(!p)) | |
| 184 | + return -EIO; | |
| 216 | 185 | count = be32_to_cpup(p); |
| 217 | 186 | if (count > NFS3_MAXNAMLEN) |
| 218 | 187 | goto out_nametoolong; |
| 219 | 188 | p = xdr_inline_decode(xdr, count); |
| 220 | − if (unlikely(p == NULL)) | |
| 221 | − goto out_overflow; | |
| 189 | + if (unlikely(!p)) | |
| 190 | + return -EIO; | |
| 222 | 191 | *name = (const char *)p; |
| 223 | 192 | *length = count; |
| 224 | 193 | return 0; |
| @@ -226,9 +195,6 @@ static int decode_inline_filename3(struct xdr_stream *xdr, · 1 unmodified line | ||
| 226 | 195 | out_nametoolong: |
| 227 | 196 | dprintk("NFS: returned filename too long: %u\n", count); |
| 228 | 197 | return -ENAMETOOLONG; |
| 229 | −out_overflow: | |
| 230 | − print_overflow_msg(__func__, xdr); | |
| 231 | − return -EIO; | |
| 232 | 198 | } |
| 233 | 199 | |
| 234 | 200 | /* |
| @@ -249,8 +215,8 @@ static int decode_nfspath3(struct xdr_stream *xdr) · 14 unmodified lines | ||
| 249 | 215 | __be32 *p; |
| 250 | 216 | |
| 251 | 217 | p = xdr_inline_decode(xdr, 4); |
| 252 | − if (unlikely(p == NULL)) | |
| 253 | − goto out_overflow; | |
| 218 | + if (unlikely(!p)) | |
| 219 | + return -EIO; | |
| 254 | 220 | count = be32_to_cpup(p); |
| 255 | 221 | if (unlikely(count >= xdr->buf->page_len || count > NFS3_MAXPATHLEN)) |
| 256 | 222 | goto out_nametoolong; |
| @@ -267,9 +233,6 @@ out_cheating: · 10 unmodified lines | ||
| 267 | 233 | dprintk("NFS: server cheating in pathname result: " |
| 268 | 234 | "count %u > recvd %u\n", count, recvd); |
| 269 | 235 | return -EIO; |
| 270 | −out_overflow: | |
| 271 | − print_overflow_msg(__func__, xdr); | |
| 272 | − return -EIO; | |
| 273 | 236 | } |
| 274 | 237 | |
| 275 | 238 | /* |
| @@ -303,13 +266,10 @@ static int decode_cookieverf3(struct xdr_stream *xdr, __be32 *verifier) · 27 unmodified lines | ||
| 303 | 266 | __be32 *p; |
| 304 | 267 | |
| 305 | 268 | p = xdr_inline_decode(xdr, NFS3_COOKIEVERFSIZE); |
| 306 | − if (unlikely(p == NULL)) | |
| 307 | − goto out_overflow; | |
| 269 | + if (unlikely(!p)) | |
| 270 | + return -EIO; | |
| 308 | 271 | memcpy(verifier, p, NFS3_COOKIEVERFSIZE); |
| 309 | 272 | return 0; |
| 310 | −out_overflow: | |
| 311 | − print_overflow_msg(__func__, xdr); | |
| 312 | − return -EIO; | |
| 313 | 273 | } |
| 314 | 274 | |
| 315 | 275 | /* |
| @@ -330,13 +290,10 @@ static int decode_writeverf3(struct xdr_stream *xdr, struct nfs_write_verifier * · 14 unmodified lines | ||
| 330 | 290 | __be32 *p; |
| 331 | 291 | |
| 332 | 292 | p = xdr_inline_decode(xdr, NFS3_WRITEVERFSIZE); |
| 333 | − if (unlikely(p == NULL)) | |
| 334 | − goto out_overflow; | |
| 293 | + if (unlikely(!p)) | |
| 294 | + return -EIO; | |
| 335 | 295 | memcpy(verifier->data, p, NFS3_WRITEVERFSIZE); |
| 336 | 296 | return 0; |
| 337 | −out_overflow: | |
| 338 | − print_overflow_msg(__func__, xdr); | |
| 339 | − return -EIO; | |
| 340 | 297 | } |
| 341 | 298 | |
| 342 | 299 | /* |
| @@ -364,13 +321,16 @@ static int decode_nfsstat3(struct xdr_stream *xdr, enum nfs_stat *status) · 21 unmodified lines | ||
| 364 | 321 | __be32 *p; |
| 365 | 322 | |
| 366 | 323 | p = xdr_inline_decode(xdr, 4); |
| 367 | − if (unlikely(p == NULL)) | |
| 368 | − goto out_overflow; | |
| 324 | + if (unlikely(!p)) | |
| 325 | + return -EIO; | |
| 326 | + if (unlikely(*p != cpu_to_be32(NFS3_OK))) | |
| 327 | + goto out_status; | |
| 328 | + *status = 0; | |
| 329 | + return 0; | |
| 330 | +out_status: | |
| 369 | 331 | *status = be32_to_cpup(p); |
| 332 | + trace_nfs_xdr_status((int)*status); | |
| 370 | 333 | return 0; |
| 371 | −out_overflow: | |
| 372 | − print_overflow_msg(__func__, xdr); | |
| 373 | − return -EIO; | |
| 374 | 334 | } |
| 375 | 335 | |
| 376 | 336 | /* |
| @@ -453,23 +413,20 @@ static int decode_nfs_fh3(struct xdr_stream *xdr, struct nfs_fh *fh) · 76 unmodified lines | ||
| 453 | 413 | __be32 *p; |
| 454 | 414 | |
| 455 | 415 | p = xdr_inline_decode(xdr, 4); |
| 456 | − if (unlikely(p == NULL)) | |
| 457 | − goto out_overflow; | |
| 416 | + if (unlikely(!p)) | |
| 417 | + return -EIO; | |
| 458 | 418 | length = be32_to_cpup(p++); |
| 459 | 419 | if (unlikely(length > NFS3_FHSIZE)) |
| 460 | 420 | goto out_toobig; |
| 461 | 421 | p = xdr_inline_decode(xdr, length); |
| 462 | − if (unlikely(p == NULL)) | |
| 463 | − goto out_overflow; | |
| 422 | + if (unlikely(!p)) | |
| 423 | + return -EIO; | |
| 464 | 424 | fh->size = length; |
| 465 | 425 | memcpy(fh->data, p, length); |
| 466 | 426 | return 0; |
| 467 | 427 | out_toobig: |
| 468 | 428 | dprintk("NFS: file handle size (%u) too big\n", length); |
| 469 | 429 | return -E2BIG; |
| 470 | −out_overflow: | |
| 471 | − print_overflow_msg(__func__, xdr); | |
| 472 | − return -EIO; | |
| 473 | 430 | } |
| 474 | 431 | |
| 475 | 432 | static void zero_nfs_fh3(struct nfs_fh *fh) |
| @@ -655,8 +612,8 @@ static int decode_fattr3(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 179 unmodified lines | ||
| 655 | 612 | __be32 *p; |
| 656 | 613 | |
| 657 | 614 | p = xdr_inline_decode(xdr, NFS3_fattr_sz << 2); |
| 658 | − if (unlikely(p == NULL)) | |
| 659 | − goto out_overflow; | |
| 615 | + if (unlikely(!p)) | |
| 616 | + return -EIO; | |
| 660 | 617 | |
| 661 | 618 | p = xdr_decode_ftype3(p, &fmode); |
| 662 | 619 | |
| @@ -690,9 +647,6 @@ out_uid: · 27 unmodified lines | ||
| 690 | 647 | out_gid: |
| 691 | 648 | dprintk("NFS: returned invalid gid\n"); |
| 692 | 649 | return -EINVAL; |
| 693 | −out_overflow: | |
| 694 | − print_overflow_msg(__func__, xdr); | |
| 695 | − return -EIO; | |
| 696 | 650 | } |
| 697 | 651 | |
| 698 | 652 | /* |
| @@ -710,14 +664,11 @@ static int decode_post_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 11 unmodified lines | ||
| 710 | 664 | __be32 *p; |
| 711 | 665 | |
| 712 | 666 | p = xdr_inline_decode(xdr, 4); |
| 713 | − if (unlikely(p == NULL)) | |
| 714 | − goto out_overflow; | |
| 667 | + if (unlikely(!p)) | |
| 668 | + return -EIO; | |
| 715 | 669 | if (*p != xdr_zero) |
| 716 | 670 | return decode_fattr3(xdr, fattr); |
| 717 | 671 | return 0; |
| 718 | −out_overflow: | |
| 719 | − print_overflow_msg(__func__, xdr); | |
| 720 | − return -EIO; | |
| 721 | 672 | } |
| 722 | 673 | |
| 723 | 674 | /* |
| @@ -733,8 +684,8 @@ static int decode_wcc_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 9 unmodified lines | ||
| 733 | 684 | __be32 *p; |
| 734 | 685 | |
| 735 | 686 | p = xdr_inline_decode(xdr, NFS3_wcc_attr_sz << 2); |
| 736 | − if (unlikely(p == NULL)) | |
| 737 | − goto out_overflow; | |
| 687 | + if (unlikely(!p)) | |
| 688 | + return -EIO; | |
| 738 | 689 | |
| 739 | 690 | fattr->valid |= NFS_ATTR_FATTR_PRESIZE |
| 740 | 691 | | NFS_ATTR_FATTR_PRECHANGE |
| @@ -747,9 +698,6 @@ static int decode_wcc_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 6 unmodified lines | ||
| 747 | 698 | fattr->pre_change_attr = nfs_timespec_to_change_attr(&fattr->pre_ctime); |
| 748 | 699 | |
| 749 | 700 | return 0; |
| 750 | −out_overflow: | |
| 751 | − print_overflow_msg(__func__, xdr); | |
| 752 | − return -EIO; | |
| 753 | 701 | } |
| 754 | 702 | |
| 755 | 703 | /* |
| @@ -773,14 +721,11 @@ static int decode_pre_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr) · 17 unmodified lines | ||
| 773 | 721 | __be32 *p; |
| 774 | 722 | |
| 775 | 723 | p = xdr_inline_decode(xdr, 4); |
| 776 | − if (unlikely(p == NULL)) | |
| 777 | − goto out_overflow; | |
| 724 | + if (unlikely(!p)) | |
| 725 | + return -EIO; | |
| 778 | 726 | if (*p != xdr_zero) |
| 779 | 727 | return decode_wcc_attr(xdr, fattr); |
| 780 | 728 | return 0; |
| 781 | −out_overflow: | |
| 782 | − print_overflow_msg(__func__, xdr); | |
| 783 | − return -EIO; | |
| 784 | 729 | } |
| 785 | 730 | |
| 786 | 731 | static int decode_wcc_data(struct xdr_stream *xdr, struct nfs_fattr *fattr) |
| @@ -808,15 +753,12 @@ out: · 21 unmodified lines | ||
| 808 | 753 | static int decode_post_op_fh3(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 809 | 754 | { |
| 810 | 755 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 811 | − if (unlikely(p == NULL)) | |
| 812 | − goto out_overflow; | |
| 756 | + if (unlikely(!p)) | |
| 757 | + return -EIO; | |
| 813 | 758 | if (*p != xdr_zero) |
| 814 | 759 | return decode_nfs_fh3(xdr, fh); |
| 815 | 760 | zero_nfs_fh3(fh); |
| 816 | 761 | return 0; |
| 817 | −out_overflow: | |
| 818 | − print_overflow_msg(__func__, xdr); | |
| 819 | − return -EIO; | |
| 820 | 762 | } |
| 821 | 763 | |
| 822 | 764 | /* |
| @@ -953,8 +895,8 @@ static void nfs3_xdr_enc_readlink3args(struct rpc_rqst *req, · 130 unmodified lines | ||
| 953 | 895 | const struct nfs3_readlinkargs *args = data; |
| 954 | 896 | |
| 955 | 897 | encode_nfs_fh3(xdr, args->fh); |
| 956 | − prepare_reply_buffer(req, args->pages, args->pgbase, | |
| 957 | − args->pglen, NFS3_readlinkres_sz); | |
| 898 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 899 | + args->pglen, NFS3_readlinkres_sz); | |
| 958 | 900 | } |
| 959 | 901 | |
| 960 | 902 | /* |
| @@ -986,8 +928,8 @@ static void nfs3_xdr_enc_read3args(struct rpc_rqst *req, · 25 unmodified lines | ||
| 986 | 928 | unsigned int replen = args->replen ? args->replen : NFS3_readres_sz; |
| 987 | 929 | |
| 988 | 930 | encode_read3args(xdr, args); |
| 989 | − prepare_reply_buffer(req, args->pages, args->pgbase, | |
| 990 | − args->count, replen); | |
| 931 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 932 | + args->count, replen); | |
| 991 | 933 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
| 992 | 934 | } |
| 993 | 935 | |
| @@ -1279,7 +1221,7 @@ static void nfs3_xdr_enc_readdir3args(struct rpc_rqst *req, · 285 unmodified lines | ||
| 1279 | 1221 | const struct nfs3_readdirargs *args = data; |
| 1280 | 1222 | |
| 1281 | 1223 | encode_readdir3args(xdr, args); |
| 1282 | − prepare_reply_buffer(req, args->pages, 0, | |
| 1224 | + rpc_prepare_reply_pages(req, args->pages, 0, | |
| 1283 | 1225 | args->count, NFS3_readdirres_sz); |
| 1284 | 1226 | } |
| 1285 | 1227 | |
| @@ -1321,7 +1263,7 @@ static void nfs3_xdr_enc_readdirplus3args(struct rpc_rqst *req, · 35 unmodified lines | ||
| 1321 | 1263 | const struct nfs3_readdirargs *args = data; |
| 1322 | 1264 | |
| 1323 | 1265 | encode_readdirplus3args(xdr, args); |
| 1324 | − prepare_reply_buffer(req, args->pages, 0, | |
| 1266 | + rpc_prepare_reply_pages(req, args->pages, 0, | |
| 1325 | 1267 | args->count, NFS3_readdirres_sz); |
| 1326 | 1268 | } |
| 1327 | 1269 | |
| @@ -1366,7 +1308,7 @@ static void nfs3_xdr_enc_getacl3args(struct rpc_rqst *req, · 38 unmodified lines | ||
| 1366 | 1308 | encode_nfs_fh3(xdr, args->fh); |
| 1367 | 1309 | encode_uint32(xdr, args->mask); |
| 1368 | 1310 | if (args->mask & (NFS_ACL | NFS_DFACL)) { |
| 1369 | − prepare_reply_buffer(req, args->pages, 0, | |
| 1311 | + rpc_prepare_reply_pages(req, args->pages, 0, | |
| 1370 | 1312 | NFSACL_MAXPAGES << PAGE_SHIFT, |
| 1371 | 1313 | ACL3_getaclres_sz); |
| 1372 | 1314 | req->rq_rcv_buf.flags |= XDRBUF_SPARSE_PAGES; |
| @@ -1643,8 +1585,8 @@ static int decode_read3resok(struct xdr_stream *xdr, · 270 unmodified lines | ||
| 1643 | 1585 | __be32 *p; |
| 1644 | 1586 | |
| 1645 | 1587 | p = xdr_inline_decode(xdr, 4 + 4 + 4); |
| 1646 | − if (unlikely(p == NULL)) | |
| 1647 | − goto out_overflow; | |
| 1588 | + if (unlikely(!p)) | |
| 1589 | + return -EIO; | |
| 1648 | 1590 | count = be32_to_cpup(p++); |
| 1649 | 1591 | eof = be32_to_cpup(p++); |
| 1650 | 1592 | ocount = be32_to_cpup(p++); |
| @@ -1667,9 +1609,6 @@ out_cheating: · 16 unmodified lines | ||
| 1667 | 1609 | count = recvd; |
| 1668 | 1610 | eof = 0; |
| 1669 | 1611 | goto out; |
| 1670 | −out_overflow: | |
| 1671 | − print_overflow_msg(__func__, xdr); | |
| 1672 | − return -EIO; | |
| 1673 | 1612 | } |
| 1674 | 1613 | |
| 1675 | 1614 | static int nfs3_xdr_dec_read3res(struct rpc_rqst *req, struct xdr_stream *xdr, |
| @@ -1690,7 +1629,7 @@ static int nfs3_xdr_dec_read3res(struct rpc_rqst *req, struct xdr_stream *xdr, · 14 unmodified lines | ||
| 1690 | 1629 | result->op_status = status; |
| 1691 | 1630 | if (status != NFS3_OK) |
| 1692 | 1631 | goto out_status; |
| 1693 | − result->replen = 3 + ((xdr_stream_pos(xdr) - pos) >> 2); | |
| 1632 | + result->replen = 4 + ((xdr_stream_pos(xdr) - pos) >> 2); | |
| 1694 | 1633 | error = decode_read3resok(xdr, result); |
| 1695 | 1634 | out: |
| 1696 | 1635 | return error; |
| @@ -1731,22 +1670,18 @@ static int decode_write3resok(struct xdr_stream *xdr, · 34 unmodified lines | ||
| 1731 | 1670 | __be32 *p; |
| 1732 | 1671 | |
| 1733 | 1672 | p = xdr_inline_decode(xdr, 4 + 4); |
| 1734 | − if (unlikely(p == NULL)) | |
| 1735 | − goto out_overflow; | |
| 1673 | + if (unlikely(!p)) | |
| 1674 | + return -EIO; | |
| 1736 | 1675 | result->count = be32_to_cpup(p++); |
| 1737 | 1676 | result->verf->committed = be32_to_cpup(p++); |
| 1738 | 1677 | if (unlikely(result->verf->committed > NFS_FILE_SYNC)) |
| 1739 | 1678 | goto out_badvalue; |
| 1740 | 1679 | if (decode_writeverf3(xdr, &result->verf->verifier)) |
| 1741 | − goto out_eio; | |
| 1680 | + return -EIO; | |
| 1742 | 1681 | return result->count; |
| 1743 | 1682 | out_badvalue: |
| 1744 | 1683 | dprintk("NFS: bad stable_how value: %u\n", result->verf->committed); |
| 1745 | 1684 | return -EIO; |
| 1746 | −out_overflow: | |
| 1747 | − print_overflow_msg(__func__, xdr); | |
| 1748 | −out_eio: | |
| 1749 | − return -EIO; | |
| 1750 | 1685 | } |
| 1751 | 1686 | |
| 1752 | 1687 | static int nfs3_xdr_dec_write3res(struct rpc_rqst *req, struct xdr_stream *xdr, |
| @@ -2010,12 +1945,12 @@ int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 257 unmodified lines | ||
| 2010 | 1945 | u64 new_cookie; |
| 2011 | 1946 | |
| 2012 | 1947 | p = xdr_inline_decode(xdr, 4); |
| 2013 | − if (unlikely(p == NULL)) | |
| 2014 | − goto out_overflow; | |
| 1948 | + if (unlikely(!p)) | |
| 1949 | + return -EAGAIN; | |
| 2015 | 1950 | if (*p == xdr_zero) { |
| 2016 | 1951 | p = xdr_inline_decode(xdr, 4); |
| 2017 | − if (unlikely(p == NULL)) | |
| 2018 | − goto out_overflow; | |
| 1952 | + if (unlikely(!p)) | |
| 1953 | + return -EAGAIN; | |
| 2019 | 1954 | if (*p == xdr_zero) |
| 2020 | 1955 | return -EAGAIN; |
| 2021 | 1956 | entry->eof = 1; |
| @@ -2051,8 +1986,8 @@ int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 29 unmodified lines | ||
| 2051 | 1986 | |
| 2052 | 1987 | /* In fact, a post_op_fh3: */ |
| 2053 | 1988 | p = xdr_inline_decode(xdr, 4); |
| 2054 | − if (unlikely(p == NULL)) | |
| 2055 | − goto out_overflow; | |
| 1989 | + if (unlikely(!p)) | |
| 1990 | + return -EAGAIN; | |
| 2056 | 1991 | if (*p != xdr_zero) { |
| 2057 | 1992 | error = decode_nfs_fh3(xdr, entry->fh); |
| 2058 | 1993 | if (unlikely(error)) { |
| @@ -2069,9 +2004,6 @@ int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 10 unmodified lines | ||
| 2069 | 2004 | |
| 2070 | 2005 | return 0; |
| 2071 | 2006 | |
| 2072 | −out_overflow: | |
| 2073 | − print_overflow_msg(__func__, xdr); | |
| 2074 | − return -EAGAIN; | |
| 2075 | 2007 | out_truncated: |
| 2076 | 2008 | dprintk("NFS: directory entry contains invalid file handle\n"); |
| 2077 | 2009 | *entry = old; |
| @@ -2183,8 +2115,8 @@ static int decode_fsstat3resok(struct xdr_stream *xdr, · 105 unmodified lines | ||
| 2183 | 2115 | __be32 *p; |
| 2184 | 2116 | |
| 2185 | 2117 | p = xdr_inline_decode(xdr, 8 * 6 + 4); |
| 2186 | − if (unlikely(p == NULL)) | |
| 2187 | − goto out_overflow; | |
| 2118 | + if (unlikely(!p)) | |
| 2119 | + return -EIO; | |
| 2188 | 2120 | p = xdr_decode_size3(p, &result->tbytes); |
| 2189 | 2121 | p = xdr_decode_size3(p, &result->fbytes); |
| 2190 | 2122 | p = xdr_decode_size3(p, &result->abytes); |
| @@ -2193,9 +2125,6 @@ static int decode_fsstat3resok(struct xdr_stream *xdr, · 2 unmodified lines | ||
| 2193 | 2125 | xdr_decode_size3(p, &result->afiles); |
| 2194 | 2126 | /* ignore invarsec */ |
| 2195 | 2127 | return 0; |
| 2196 | −out_overflow: | |
| 2197 | − print_overflow_msg(__func__, xdr); | |
| 2198 | − return -EIO; | |
| 2199 | 2128 | } |
| 2200 | 2129 | |
| 2201 | 2130 | static int nfs3_xdr_dec_fsstat3res(struct rpc_rqst *req, |
| @@ -2255,8 +2184,8 @@ static int decode_fsinfo3resok(struct xdr_stream *xdr, · 53 unmodified lines | ||
| 2255 | 2184 | __be32 *p; |
| 2256 | 2185 | |
| 2257 | 2186 | p = xdr_inline_decode(xdr, 4 * 7 + 8 + 8 + 4); |
| 2258 | − if (unlikely(p == NULL)) | |
| 2259 | − goto out_overflow; | |
| 2187 | + if (unlikely(!p)) | |
| 2188 | + return -EIO; | |
| 2260 | 2189 | result->rtmax = be32_to_cpup(p++); |
| 2261 | 2190 | result->rtpref = be32_to_cpup(p++); |
| 2262 | 2191 | result->rtmult = be32_to_cpup(p++); |
| @@ -2270,9 +2199,6 @@ static int decode_fsinfo3resok(struct xdr_stream *xdr, · 7 unmodified lines | ||
| 2270 | 2199 | /* ignore properties */ |
| 2271 | 2200 | result->lease_time = 0; |
| 2272 | 2201 | return 0; |
| 2273 | −out_overflow: | |
| 2274 | − print_overflow_msg(__func__, xdr); | |
| 2275 | − return -EIO; | |
| 2276 | 2202 | } |
| 2277 | 2203 | |
| 2278 | 2204 | static int nfs3_xdr_dec_fsinfo3res(struct rpc_rqst *req, |
| @@ -2328,15 +2254,12 @@ static int decode_pathconf3resok(struct xdr_stream *xdr, · 49 unmodified lines | ||
| 2328 | 2254 | __be32 *p; |
| 2329 | 2255 | |
| 2330 | 2256 | p = xdr_inline_decode(xdr, 4 * 6); |
| 2331 | − if (unlikely(p == NULL)) | |
| 2332 | − goto out_overflow; | |
| 2257 | + if (unlikely(!p)) | |
| 2258 | + return -EIO; | |
| 2333 | 2259 | result->max_link = be32_to_cpup(p++); |
| 2334 | 2260 | result->max_namelen = be32_to_cpup(p); |
| 2335 | 2261 | /* ignore remaining fields */ |
| 2336 | 2262 | return 0; |
| 2337 | −out_overflow: | |
| 2338 | − print_overflow_msg(__func__, xdr); | |
| 2339 | − return -EIO; | |
| 2340 | 2263 | } |
| 2341 | 2264 | |
| 2342 | 2265 | static int nfs3_xdr_dec_pathconf3res(struct rpc_rqst *req, |
| @@ -394,7 +394,7 @@ static int decode_write_response(struct xdr_stream *xdr, · 393 unmodified lines | ||
| 394 | 394 | |
| 395 | 395 | p = xdr_inline_decode(xdr, 4); |
| 396 | 396 | if (unlikely(!p)) |
| 397 | − goto out_overflow; | |
| 397 | + return -EIO; | |
| 398 | 398 | count = be32_to_cpup(p); |
| 399 | 399 | if (count > 1) |
| 400 | 400 | return -EREMOTEIO; |
| @@ -402,18 +402,14 @@ static int decode_write_response(struct xdr_stream *xdr, · 1 unmodified line | ||
| 402 | 402 | status = decode_opaque_fixed(xdr, &res->stateid, |
| 403 | 403 | NFS4_STATEID_SIZE); |
| 404 | 404 | if (unlikely(status)) |
| 405 | − goto out_overflow; | |
| 405 | + return -EIO; | |
| 406 | 406 | } |
| 407 | 407 | p = xdr_inline_decode(xdr, 8 + 4); |
| 408 | 408 | if (unlikely(!p)) |
| 409 | − goto out_overflow; | |
| 409 | + return -EIO; | |
| 410 | 410 | p = xdr_decode_hyper(p, &res->count); |
| 411 | 411 | res->verifier.committed = be32_to_cpup(p); |
| 412 | 412 | return decode_verifier(xdr, &res->verifier.verifier); |
| 413 | − | |
| 414 | −out_overflow: | |
| 415 | − print_overflow_msg(__func__, xdr); | |
| 416 | − return -EIO; | |
| 417 | 413 | } |
| 418 | 414 | |
| 419 | 415 | static int decode_copy_requirements(struct xdr_stream *xdr, |
| @@ -422,14 +418,11 @@ static int decode_copy_requirements(struct xdr_stream *xdr, · 2 unmodified lines | ||
| 422 | 418 | |
| 423 | 419 | p = xdr_inline_decode(xdr, 4 + 4); |
| 424 | 420 | if (unlikely(!p)) |
| 425 | − goto out_overflow; | |
| 421 | + return -EIO; | |
| 426 | 422 | |
| 427 | 423 | res->consecutive = be32_to_cpup(p++); |
| 428 | 424 | res->synchronous = be32_to_cpup(p++); |
| 429 | 425 | return 0; |
| 430 | −out_overflow: | |
| 431 | − print_overflow_msg(__func__, xdr); | |
| 432 | − return -EIO; | |
| 433 | 426 | } |
| 434 | 427 | |
| 435 | 428 | static int decode_copy(struct xdr_stream *xdr, struct nfs42_copy_res *res) |
| @@ -474,15 +467,11 @@ static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res) · 38 unmodified lines | ||
| 474 | 467 | |
| 475 | 468 | p = xdr_inline_decode(xdr, 4 + 8); |
| 476 | 469 | if (unlikely(!p)) |
| 477 | − goto out_overflow; | |
| 470 | + return -EIO; | |
| 478 | 471 | |
| 479 | 472 | res->sr_eof = be32_to_cpup(p++); |
| 480 | 473 | p = xdr_decode_hyper(p, &res->sr_offset); |
| 481 | 474 | return 0; |
| 482 | − | |
| 483 | −out_overflow: | |
| 484 | − print_overflow_msg(__func__, xdr); | |
| 485 | − return -EIO; | |
| 486 | 475 | } |
| 487 | 476 | |
| 488 | 477 | static int decode_layoutstats(struct xdr_stream *xdr) |
| @@ -524,6 +524,31 @@ TRACE_EVENT(nfs4_setup_sequence, · 523 unmodified lines | ||
| 524 | 524 | ) |
| 525 | 525 | ); |
| 526 | 526 | |
| 527 | +TRACE_EVENT(nfs4_xdr_status, | |
| 528 | + TP_PROTO( | |
| 529 | + u32 op, | |
| 530 | + int error | |
| 531 | + ), | |
| 532 | + | |
| 533 | + TP_ARGS(op, error), | |
| 534 | + | |
| 535 | + TP_STRUCT__entry( | |
| 536 | + __field(u32, op) | |
| 537 | + __field(int, error) | |
| 538 | + ), | |
| 539 | + | |
| 540 | + TP_fast_assign( | |
| 541 | + __entry->op = op; | |
| 542 | + __entry->error = -error; | |
| 543 | + ), | |
| 544 | + | |
| 545 | + TP_printk( | |
| 546 | + "operation %d: nfs status %d (%s)", | |
| 547 | + __entry->op, | |
| 548 | + __entry->error, show_nfsv4_errors(__entry->error) | |
| 549 | + ) | |
| 550 | +); | |
| 551 | + | |
| 527 | 552 | DECLARE_EVENT_CLASS(nfs4_open_event, |
| 528 | 553 | TP_PROTO( |
| 529 | 554 | const struct nfs_open_context *ctx, |
| @@ -54,6 +54,7 @@ · 53 unmodified lines | ||
| 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,14 +215,14 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, · 154 unmodified lines | ||
| 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,14 +284,14 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, · 55 unmodified lines | ||
| 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,12 +392,13 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, · 94 unmodified lines | ||
| 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 */ + \ |
| @@ -1015,12 +1017,11 @@ static void encode_compound_hdr(struct xdr_stream *xdr, · 612 unmodified lines | ||
| 1015 | 1017 | struct compound_hdr *hdr) |
| 1016 | 1018 | { |
| 1017 | 1019 | __be32 *p; |
| 1018 | − struct rpc_auth *auth = req->rq_cred->cr_auth; | |
| 1019 | 1020 | |
| 1020 | 1021 | /* initialize running count of expected bytes in reply. |
| 1021 | 1022 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 1022 | 1023 | * 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; | |
| 1024 | + hdr->replen = 3 + hdr->taglen; | |
| 1024 | 1025 | |
| 1025 | 1026 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); |
| 1026 | 1027 | encode_string(xdr, hdr->taglen, hdr->tag); |
| @@ -2340,9 +2341,9 @@ static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, · 1313 unmodified lines | ||
| 2340 | 2341 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
| 2341 | 2342 | if (args->lg_args) { |
| 2342 | 2343 | 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); | |
| 2344 | + rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0, | |
| 2345 | + args->lg_args->layout.pglen, | |
| 2346 | + hdr.replen); | |
| 2346 | 2347 | } |
| 2347 | 2348 | encode_nops(&hdr); |
| 2348 | 2349 | } |
| @@ -2386,9 +2387,9 @@ static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, · 37 unmodified lines | ||
| 2386 | 2387 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
| 2387 | 2388 | if (args->lg_args) { |
| 2388 | 2389 | 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); | |
| 2390 | + rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0, | |
| 2391 | + args->lg_args->layout.pglen, | |
| 2392 | + hdr.replen); | |
| 2392 | 2393 | } |
| 2393 | 2394 | encode_nops(&hdr); |
| 2394 | 2395 | } |
| @@ -2498,8 +2499,8 @@ static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, · 103 unmodified lines | ||
| 2498 | 2499 | encode_putfh(xdr, args->fh, &hdr); |
| 2499 | 2500 | encode_readlink(xdr, args, req, &hdr); |
| 2500 | 2501 | |
| 2501 | − xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, | |
| 2502 | − args->pgbase, args->pglen); | |
| 2502 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 2503 | + args->pglen, hdr.replen); | |
| 2503 | 2504 | encode_nops(&hdr); |
| 2504 | 2505 | } |
| 2505 | 2506 | |
| @@ -2519,11 +2520,8 @@ static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, · 13 unmodified lines | ||
| 2519 | 2520 | encode_putfh(xdr, args->fh, &hdr); |
| 2520 | 2521 | encode_readdir(xdr, args, req, &hdr); |
| 2521 | 2522 | |
| 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); | |
| 2523 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 2524 | + args->count, hdr.replen); | |
| 2527 | 2525 | encode_nops(&hdr); |
| 2528 | 2526 | } |
| 2529 | 2527 | |
| @@ -2543,8 +2541,8 @@ static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, · 13 unmodified lines | ||
| 2543 | 2541 | encode_putfh(xdr, args->fh, &hdr); |
| 2544 | 2542 | encode_read(xdr, args, &hdr); |
| 2545 | 2543 | |
| 2546 | − xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, | |
| 2547 | − args->pages, args->pgbase, args->count); | |
| 2544 | + rpc_prepare_reply_pages(req, args->pages, args->pgbase, | |
| 2545 | + args->count, hdr.replen); | |
| 2548 | 2546 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
| 2549 | 2547 | encode_nops(&hdr); |
| 2550 | 2548 | } |
| @@ -2590,9 +2588,8 @@ static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, · 39 unmodified lines | ||
| 2590 | 2588 | encode_getattr(xdr, nfs4_acl_bitmap, NULL, |
| 2591 | 2589 | ARRAY_SIZE(nfs4_acl_bitmap), &hdr); |
| 2592 | 2590 | |
| 2593 | − xdr_inline_pages(&req->rq_rcv_buf, replen << 2, | |
| 2594 | − args->acl_pages, 0, args->acl_len); | |
| 2595 | − | |
| 2591 | + rpc_prepare_reply_pages(req, args->acl_pages, 0, | |
| 2592 | + args->acl_len, replen); | |
| 2596 | 2593 | encode_nops(&hdr); |
| 2597 | 2594 | } |
| 2598 | 2595 | |
| @@ -2813,9 +2810,8 @@ static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, · 214 unmodified lines | ||
| 2813 | 2810 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2814 | 2811 | } |
| 2815 | 2812 | |
| 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); | |
| 2813 | + rpc_prepare_reply_pages(req, (struct page **)&args->page, 0, | |
| 2814 | + PAGE_SIZE, replen); | |
| 2819 | 2815 | encode_nops(&hdr); |
| 2820 | 2816 | } |
| 2821 | 2817 | |
| @@ -3017,10 +3013,8 @@ static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, · 195 unmodified lines | ||
| 3017 | 3013 | |
| 3018 | 3014 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 3019 | 3015 | * 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 | − | |
| 3016 | + rpc_prepare_reply_pages(req, args->pdev->pages, args->pdev->pgbase, | |
| 3017 | + args->pdev->pglen, hdr.replen - 2); | |
| 3024 | 3018 | encode_nops(&hdr); |
| 3025 | 3019 | } |
| 3026 | 3020 | |
| @@ -3041,9 +3035,8 @@ static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, · 14 unmodified lines | ||
| 3041 | 3035 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 3042 | 3036 | encode_layoutget(xdr, args, &hdr); |
| 3043 | 3037 | |
| 3044 | − xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, | |
| 3045 | − args->layout.pages, 0, args->layout.pglen); | |
| 3046 | − | |
| 3038 | + rpc_prepare_reply_pages(req, args->layout.pages, 0, | |
| 3039 | + args->layout.pglen, hdr.replen); | |
| 3047 | 3040 | encode_nops(&hdr); |
| 3048 | 3041 | } |
| 3049 | 3042 | |
| @@ -3144,22 +3137,12 @@ static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, · 94 unmodified lines | ||
| 3144 | 3137 | } |
| 3145 | 3138 | #endif /* CONFIG_NFS_V4_1 */ |
| 3146 | 3139 | |
| 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 | 3140 | static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string) |
| 3155 | 3141 | { |
| 3156 | 3142 | ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string, |
| 3157 | 3143 | NFS4_OPAQUE_LIMIT); |
| 3158 | − if (unlikely(ret < 0)) { | |
| 3159 | − if (ret == -EBADMSG) | |
| 3160 | − print_overflow_msg(__func__, xdr); | |
| 3144 | + if (unlikely(ret < 0)) | |
| 3161 | 3145 | return -EIO; |
| 3162 | − } | |
| 3163 | 3146 | *len = ret; |
| 3164 | 3147 | return 0; |
| 3165 | 3148 | } |
| @@ -3170,22 +3153,19 @@ static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) · 4 unmodified lines | ||
| 3170 | 3153 | |
| 3171 | 3154 | p = xdr_inline_decode(xdr, 8); |
| 3172 | 3155 | if (unlikely(!p)) |
| 3173 | − goto out_overflow; | |
| 3156 | + return -EIO; | |
| 3174 | 3157 | hdr->status = be32_to_cpup(p++); |
| 3175 | 3158 | hdr->taglen = be32_to_cpup(p); |
| 3176 | 3159 | |
| 3177 | 3160 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 3178 | 3161 | if (unlikely(!p)) |
| 3179 | − goto out_overflow; | |
| 3162 | + return -EIO; | |
| 3180 | 3163 | hdr->tag = (char *)p; |
| 3181 | 3164 | p += XDR_QUADLEN(hdr->taglen); |
| 3182 | 3165 | hdr->nops = be32_to_cpup(p); |
| 3183 | 3166 | if (unlikely(hdr->nops < 1)) |
| 3184 | 3167 | return nfs4_stat_to_errno(hdr->status); |
| 3185 | 3168 | return 0; |
| 3186 | −out_overflow: | |
| 3187 | − print_overflow_msg(__func__, xdr); | |
| 3188 | − return -EIO; | |
| 3189 | 3169 | } |
| 3190 | 3170 | |
| 3191 | 3171 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, |
| @@ -3201,11 +3181,14 @@ static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, · 9 unmodified lines | ||
| 3201 | 3181 | opnum = be32_to_cpup(p++); |
| 3202 | 3182 | if (unlikely(opnum != expected)) |
| 3203 | 3183 | goto out_bad_operation; |
| 3184 | + if (unlikely(*p != cpu_to_be32(NFS_OK))) | |
| 3185 | + goto out_status; | |
| 3186 | + *nfs_retval = 0; | |
| 3187 | + return true; | |
| 3188 | +out_status: | |
| 3204 | 3189 | nfserr = be32_to_cpup(p); |
| 3205 | − if (nfserr == NFS_OK) | |
| 3206 | − *nfs_retval = 0; | |
| 3207 | − else | |
| 3208 | − *nfs_retval = nfs4_stat_to_errno(nfserr); | |
| 3190 | + trace_nfs4_xdr_status(opnum, nfserr); | |
| 3191 | + *nfs_retval = nfs4_stat_to_errno(nfserr); | |
| 3209 | 3192 | return true; |
| 3210 | 3193 | out_bad_operation: |
| 3211 | 3194 | dprintk("nfs: Server returned operation" |
| @@ -3214,7 +3197,6 @@ out_bad_operation: · 2 unmodified lines | ||
| 3214 | 3197 | *nfs_retval = -EREMOTEIO; |
| 3215 | 3198 | return false; |
| 3216 | 3199 | out_overflow: |
| 3217 | − print_overflow_msg(__func__, xdr); | |
| 3218 | 3200 | *nfs_retval = -EIO; |
| 3219 | 3201 | return false; |
| 3220 | 3202 | } |
| @@ -3235,10 +3217,9 @@ static int decode_ace(struct xdr_stream *xdr, void *ace) · 14 unmodified lines | ||
| 3235 | 3217 | char *str; |
| 3236 | 3218 | |
| 3237 | 3219 | 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; | |
| 3220 | + if (unlikely(!p)) | |
| 3221 | + return -EIO; | |
| 3222 | + return decode_opaque_inline(xdr, &strlen, &str); | |
| 3242 | 3223 | } |
| 3243 | 3224 | |
| 3244 | 3225 | static ssize_t |
| @@ -3249,10 +3230,9 @@ decode_bitmap4(struct xdr_stream *xdr, uint32_t *bitmap, size_t sz) · 4 unmodified lines | ||
| 3249 | 3230 | ret = xdr_stream_decode_uint32_array(xdr, bitmap, sz); |
| 3250 | 3231 | if (likely(ret >= 0)) |
| 3251 | 3232 | return ret; |
| 3252 | − if (ret == -EMSGSIZE) | |
| 3253 | − return sz; | |
| 3254 | − print_overflow_msg(__func__, xdr); | |
| 3255 | − return -EIO; | |
| 3233 | + if (ret != -EMSGSIZE) | |
| 3234 | + return -EIO; | |
| 3235 | + return sz; | |
| 3256 | 3236 | } |
| 3257 | 3237 | |
| 3258 | 3238 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| @@ -3268,13 +3248,10 @@ static int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, unsigne · 9 unmodified lines | ||
| 3268 | 3248 | |
| 3269 | 3249 | p = xdr_inline_decode(xdr, 4); |
| 3270 | 3250 | if (unlikely(!p)) |
| 3271 | − goto out_overflow; | |
| 3251 | + return -EIO; | |
| 3272 | 3252 | *attrlen = be32_to_cpup(p); |
| 3273 | 3253 | *savep = xdr_stream_pos(xdr); |
| 3274 | 3254 | return 0; |
| 3275 | −out_overflow: | |
| 3276 | − print_overflow_msg(__func__, xdr); | |
| 3277 | − return -EIO; | |
| 3278 | 3255 | } |
| 3279 | 3256 | |
| 3280 | 3257 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| @@ -3303,7 +3280,7 @@ static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t * · 22 unmodified lines | ||
| 3303 | 3280 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
| 3304 | 3281 | p = xdr_inline_decode(xdr, 4); |
| 3305 | 3282 | if (unlikely(!p)) |
| 3306 | − goto out_overflow; | |
| 3283 | + return -EIO; | |
| 3307 | 3284 | *type = be32_to_cpup(p); |
| 3308 | 3285 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
| 3309 | 3286 | dprintk("%s: bad type %d\n", __func__, *type); |
| @@ -3314,9 +3291,6 @@ static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t * · 4 unmodified lines | ||
| 3314 | 3291 | } |
| 3315 | 3292 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
| 3316 | 3293 | return ret; |
| 3317 | −out_overflow: | |
| 3318 | − print_overflow_msg(__func__, xdr); | |
| 3319 | − return -EIO; | |
| 3320 | 3294 | } |
| 3321 | 3295 | |
| 3322 | 3296 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| @@ -3330,15 +3304,12 @@ static int decode_attr_fh_expire_type(struct xdr_stream *xdr, · 7 unmodified lines | ||
| 3330 | 3304 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3331 | 3305 | p = xdr_inline_decode(xdr, 4); |
| 3332 | 3306 | if (unlikely(!p)) |
| 3333 | − goto out_overflow; | |
| 3307 | + return -EIO; | |
| 3334 | 3308 | *type = be32_to_cpup(p); |
| 3335 | 3309 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3336 | 3310 | } |
| 3337 | 3311 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3338 | 3312 | return 0; |
| 3339 | −out_overflow: | |
| 3340 | − print_overflow_msg(__func__, xdr); | |
| 3341 | − return -EIO; | |
| 3342 | 3313 | } |
| 3343 | 3314 | |
| 3344 | 3315 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| @@ -3352,7 +3323,7 @@ static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t · 7 unmodified lines | ||
| 3352 | 3323 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
| 3353 | 3324 | p = xdr_inline_decode(xdr, 8); |
| 3354 | 3325 | if (unlikely(!p)) |
| 3355 | − goto out_overflow; | |
| 3326 | + return -EIO; | |
| 3356 | 3327 | xdr_decode_hyper(p, change); |
| 3357 | 3328 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
| 3358 | 3329 | ret = NFS_ATTR_FATTR_CHANGE; |
| @@ -3360,9 +3331,6 @@ static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t · 1 unmodified line | ||
| 3360 | 3331 | dprintk("%s: change attribute=%Lu\n", __func__, |
| 3361 | 3332 | (unsigned long long)*change); |
| 3362 | 3333 | return ret; |
| 3363 | −out_overflow: | |
| 3364 | − print_overflow_msg(__func__, xdr); | |
| 3365 | − return -EIO; | |
| 3366 | 3334 | } |
| 3367 | 3335 | |
| 3368 | 3336 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| @@ -3376,16 +3344,13 @@ static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t * · 7 unmodified lines | ||
| 3376 | 3344 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
| 3377 | 3345 | p = xdr_inline_decode(xdr, 8); |
| 3378 | 3346 | if (unlikely(!p)) |
| 3379 | − goto out_overflow; | |
| 3347 | + return -EIO; | |
| 3380 | 3348 | xdr_decode_hyper(p, size); |
| 3381 | 3349 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
| 3382 | 3350 | ret = NFS_ATTR_FATTR_SIZE; |
| 3383 | 3351 | } |
| 3384 | 3352 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
| 3385 | 3353 | return ret; |
| 3386 | −out_overflow: | |
| 3387 | − print_overflow_msg(__func__, xdr); | |
| 3388 | − return -EIO; | |
| 3389 | 3354 | } |
| 3390 | 3355 | |
| 3391 | 3356 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3398,15 +3363,12 @@ static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, ui · 6 unmodified lines | ||
| 3398 | 3363 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
| 3399 | 3364 | p = xdr_inline_decode(xdr, 4); |
| 3400 | 3365 | if (unlikely(!p)) |
| 3401 | − goto out_overflow; | |
| 3366 | + return -EIO; | |
| 3402 | 3367 | *res = be32_to_cpup(p); |
| 3403 | 3368 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3404 | 3369 | } |
| 3405 | 3370 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
| 3406 | 3371 | return 0; |
| 3407 | −out_overflow: | |
| 3408 | − print_overflow_msg(__func__, xdr); | |
| 3409 | − return -EIO; | |
| 3410 | 3372 | } |
| 3411 | 3373 | |
| 3412 | 3374 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3419,15 +3381,12 @@ static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, · 6 unmodified lines | ||
| 3419 | 3381 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
| 3420 | 3382 | p = xdr_inline_decode(xdr, 4); |
| 3421 | 3383 | if (unlikely(!p)) |
| 3422 | − goto out_overflow; | |
| 3384 | + return -EIO; | |
| 3423 | 3385 | *res = be32_to_cpup(p); |
| 3424 | 3386 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3425 | 3387 | } |
| 3426 | 3388 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
| 3427 | 3389 | return 0; |
| 3428 | −out_overflow: | |
| 3429 | − print_overflow_msg(__func__, xdr); | |
| 3430 | − return -EIO; | |
| 3431 | 3390 | } |
| 3432 | 3391 | |
| 3433 | 3392 | static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid) |
| @@ -3442,7 +3401,7 @@ static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs · 8 unmodified lines | ||
| 3442 | 3401 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
| 3443 | 3402 | p = xdr_inline_decode(xdr, 16); |
| 3444 | 3403 | if (unlikely(!p)) |
| 3445 | − goto out_overflow; | |
| 3404 | + return -EIO; | |
| 3446 | 3405 | p = xdr_decode_hyper(p, &fsid->major); |
| 3447 | 3406 | xdr_decode_hyper(p, &fsid->minor); |
| 3448 | 3407 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
| @@ -3452,9 +3411,6 @@ static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs · 3 unmodified lines | ||
| 3452 | 3411 | (unsigned long long)fsid->major, |
| 3453 | 3412 | (unsigned long long)fsid->minor); |
| 3454 | 3413 | return ret; |
| 3455 | −out_overflow: | |
| 3456 | − print_overflow_msg(__func__, xdr); | |
| 3457 | − return -EIO; | |
| 3458 | 3414 | } |
| 3459 | 3415 | |
| 3460 | 3416 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3467,15 +3423,12 @@ static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint · 6 unmodified lines | ||
| 3467 | 3423 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
| 3468 | 3424 | p = xdr_inline_decode(xdr, 4); |
| 3469 | 3425 | if (unlikely(!p)) |
| 3470 | − goto out_overflow; | |
| 3426 | + return -EIO; | |
| 3471 | 3427 | *res = be32_to_cpup(p); |
| 3472 | 3428 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3473 | 3429 | } |
| 3474 | 3430 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
| 3475 | 3431 | return 0; |
| 3476 | −out_overflow: | |
| 3477 | − print_overflow_msg(__func__, xdr); | |
| 3478 | − return -EIO; | |
| 3479 | 3432 | } |
| 3480 | 3433 | |
| 3481 | 3434 | static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res) |
| @@ -3487,14 +3440,11 @@ static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t * · 5 unmodified lines | ||
| 3487 | 3440 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3488 | 3441 | p = xdr_inline_decode(xdr, 4); |
| 3489 | 3442 | if (unlikely(!p)) |
| 3490 | − goto out_overflow; | |
| 3443 | + return -EIO; | |
| 3491 | 3444 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
| 3492 | 3445 | *res = -be32_to_cpup(p); |
| 3493 | 3446 | } |
| 3494 | 3447 | return 0; |
| 3495 | −out_overflow: | |
| 3496 | − print_overflow_msg(__func__, xdr); | |
| 3497 | − return -EIO; | |
| 3498 | 3448 | } |
| 3499 | 3449 | |
| 3500 | 3450 | static int decode_attr_exclcreat_supported(struct xdr_stream *xdr, |
| @@ -3526,13 +3476,13 @@ static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, stru · 25 unmodified lines | ||
| 3526 | 3476 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3527 | 3477 | p = xdr_inline_decode(xdr, 4); |
| 3528 | 3478 | if (unlikely(!p)) |
| 3529 | − goto out_overflow; | |
| 3479 | + return -EIO; | |
| 3530 | 3480 | len = be32_to_cpup(p); |
| 3531 | 3481 | if (len > NFS4_FHSIZE) |
| 3532 | 3482 | return -EIO; |
| 3533 | 3483 | p = xdr_inline_decode(xdr, len); |
| 3534 | 3484 | if (unlikely(!p)) |
| 3535 | − goto out_overflow; | |
| 3485 | + return -EIO; | |
| 3536 | 3486 | if (fh != NULL) { |
| 3537 | 3487 | memcpy(fh->data, p, len); |
| 3538 | 3488 | fh->size = len; |
| @@ -3540,9 +3490,6 @@ static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, stru · 1 unmodified line | ||
| 3540 | 3490 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3541 | 3491 | } |
| 3542 | 3492 | return 0; |
| 3543 | −out_overflow: | |
| 3544 | − print_overflow_msg(__func__, xdr); | |
| 3545 | − return -EIO; | |
| 3546 | 3493 | } |
| 3547 | 3494 | |
| 3548 | 3495 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3555,15 +3502,12 @@ static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint · 6 unmodified lines | ||
| 3555 | 3502 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
| 3556 | 3503 | p = xdr_inline_decode(xdr, 4); |
| 3557 | 3504 | if (unlikely(!p)) |
| 3558 | − goto out_overflow; | |
| 3505 | + return -EIO; | |
| 3559 | 3506 | *res = be32_to_cpup(p); |
| 3560 | 3507 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3561 | 3508 | } |
| 3562 | 3509 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
| 3563 | 3510 | return 0; |
| 3564 | −out_overflow: | |
| 3565 | − print_overflow_msg(__func__, xdr); | |
| 3566 | − return -EIO; | |
| 3567 | 3511 | } |
| 3568 | 3512 | |
| 3569 | 3513 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| @@ -3577,16 +3521,13 @@ static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t · 7 unmodified lines | ||
| 3577 | 3521 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
| 3578 | 3522 | p = xdr_inline_decode(xdr, 8); |
| 3579 | 3523 | if (unlikely(!p)) |
| 3580 | − goto out_overflow; | |
| 3524 | + return -EIO; | |
| 3581 | 3525 | xdr_decode_hyper(p, fileid); |
| 3582 | 3526 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
| 3583 | 3527 | ret = NFS_ATTR_FATTR_FILEID; |
| 3584 | 3528 | } |
| 3585 | 3529 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
| 3586 | 3530 | return ret; |
| 3587 | −out_overflow: | |
| 3588 | − print_overflow_msg(__func__, xdr); | |
| 3589 | − return -EIO; | |
| 3590 | 3531 | } |
| 3591 | 3532 | |
| 3592 | 3533 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| @@ -3600,16 +3541,13 @@ static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitma · 7 unmodified lines | ||
| 3600 | 3541 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
| 3601 | 3542 | p = xdr_inline_decode(xdr, 8); |
| 3602 | 3543 | if (unlikely(!p)) |
| 3603 | − goto out_overflow; | |
| 3544 | + return -EIO; | |
| 3604 | 3545 | xdr_decode_hyper(p, fileid); |
| 3605 | 3546 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
| 3606 | 3547 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
| 3607 | 3548 | } |
| 3608 | 3549 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
| 3609 | 3550 | return ret; |
| 3610 | −out_overflow: | |
| 3611 | − print_overflow_msg(__func__, xdr); | |
| 3612 | − return -EIO; | |
| 3613 | 3551 | } |
| 3614 | 3552 | |
| 3615 | 3553 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -3623,15 +3561,12 @@ static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uin · 7 unmodified lines | ||
| 3623 | 3561 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
| 3624 | 3562 | p = xdr_inline_decode(xdr, 8); |
| 3625 | 3563 | if (unlikely(!p)) |
| 3626 | − goto out_overflow; | |
| 3564 | + return -EIO; | |
| 3627 | 3565 | xdr_decode_hyper(p, res); |
| 3628 | 3566 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3629 | 3567 | } |
| 3630 | 3568 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
| 3631 | 3569 | return status; |
| 3632 | −out_overflow: | |
| 3633 | − print_overflow_msg(__func__, xdr); | |
| 3634 | − return -EIO; | |
| 3635 | 3570 | } |
| 3636 | 3571 | |
| 3637 | 3572 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -3645,15 +3580,12 @@ static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint · 7 unmodified lines | ||
| 3645 | 3580 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
| 3646 | 3581 | p = xdr_inline_decode(xdr, 8); |
| 3647 | 3582 | if (unlikely(!p)) |
| 3648 | − goto out_overflow; | |
| 3583 | + return -EIO; | |
| 3649 | 3584 | xdr_decode_hyper(p, res); |
| 3650 | 3585 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3651 | 3586 | } |
| 3652 | 3587 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
| 3653 | 3588 | return status; |
| 3654 | −out_overflow: | |
| 3655 | − print_overflow_msg(__func__, xdr); | |
| 3656 | − return -EIO; | |
| 3657 | 3589 | } |
| 3658 | 3590 | |
| 3659 | 3591 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -3667,15 +3599,12 @@ static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uin · 7 unmodified lines | ||
| 3667 | 3599 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
| 3668 | 3600 | p = xdr_inline_decode(xdr, 8); |
| 3669 | 3601 | if (unlikely(!p)) |
| 3670 | − goto out_overflow; | |
| 3602 | + return -EIO; | |
| 3671 | 3603 | xdr_decode_hyper(p, res); |
| 3672 | 3604 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3673 | 3605 | } |
| 3674 | 3606 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
| 3675 | 3607 | return status; |
| 3676 | −out_overflow: | |
| 3677 | − print_overflow_msg(__func__, xdr); | |
| 3678 | − return -EIO; | |
| 3679 | 3608 | } |
| 3680 | 3609 | |
| 3681 | 3610 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| @@ -3686,7 +3615,7 @@ static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) · 4 unmodified lines | ||
| 3686 | 3615 | |
| 3687 | 3616 | p = xdr_inline_decode(xdr, 4); |
| 3688 | 3617 | if (unlikely(!p)) |
| 3689 | − goto out_overflow; | |
| 3618 | + return -EIO; | |
| 3690 | 3619 | n = be32_to_cpup(p); |
| 3691 | 3620 | if (n == 0) |
| 3692 | 3621 | goto root_path; |
| @@ -3718,9 +3647,6 @@ out_eio: · 25 unmodified lines | ||
| 3718 | 3647 | dprintk(" status %d", status); |
| 3719 | 3648 | status = -EIO; |
| 3720 | 3649 | goto out; |
| 3721 | −out_overflow: | |
| 3722 | − print_overflow_msg(__func__, xdr); | |
| 3723 | − return -EIO; | |
| 3724 | 3650 | } |
| 3725 | 3651 | |
| 3726 | 3652 | static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res) |
| @@ -3745,7 +3671,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st · 18 unmodified lines | ||
| 3745 | 3671 | goto out; |
| 3746 | 3672 | p = xdr_inline_decode(xdr, 4); |
| 3747 | 3673 | if (unlikely(!p)) |
| 3748 | − goto out_overflow; | |
| 3674 | + goto out_eio; | |
| 3749 | 3675 | n = be32_to_cpup(p); |
| 3750 | 3676 | if (n <= 0) |
| 3751 | 3677 | goto out_eio; |
| @@ -3758,7 +3684,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st · 6 unmodified lines | ||
| 3758 | 3684 | loc = &res->locations[res->nlocations]; |
| 3759 | 3685 | p = xdr_inline_decode(xdr, 4); |
| 3760 | 3686 | if (unlikely(!p)) |
| 3761 | − goto out_overflow; | |
| 3687 | + goto out_eio; | |
| 3762 | 3688 | m = be32_to_cpup(p); |
| 3763 | 3689 | |
| 3764 | 3690 | dprintk("%s: servers:\n", __func__); |
| @@ -3796,8 +3722,6 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st · 31 unmodified lines | ||
| 3796 | 3722 | out: |
| 3797 | 3723 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
| 3798 | 3724 | return status; |
| 3799 | −out_overflow: | |
| 3800 | − print_overflow_msg(__func__, xdr); | |
| 3801 | 3725 | out_eio: |
| 3802 | 3726 | status = -EIO; |
| 3803 | 3727 | goto out; |
| @@ -3814,15 +3738,12 @@ static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uin · 10 unmodified lines | ||
| 3814 | 3738 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
| 3815 | 3739 | p = xdr_inline_decode(xdr, 8); |
| 3816 | 3740 | if (unlikely(!p)) |
| 3817 | − goto out_overflow; | |
| 3741 | + return -EIO; | |
| 3818 | 3742 | xdr_decode_hyper(p, res); |
| 3819 | 3743 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3820 | 3744 | } |
| 3821 | 3745 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
| 3822 | 3746 | return status; |
| 3823 | −out_overflow: | |
| 3824 | − print_overflow_msg(__func__, xdr); | |
| 3825 | − return -EIO; | |
| 3826 | 3747 | } |
| 3827 | 3748 | |
| 3828 | 3749 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| @@ -3836,15 +3757,12 @@ static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_ · 7 unmodified lines | ||
| 3836 | 3757 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
| 3837 | 3758 | p = xdr_inline_decode(xdr, 4); |
| 3838 | 3759 | if (unlikely(!p)) |
| 3839 | − goto out_overflow; | |
| 3760 | + return -EIO; | |
| 3840 | 3761 | *maxlink = be32_to_cpup(p); |
| 3841 | 3762 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3842 | 3763 | } |
| 3843 | 3764 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
| 3844 | 3765 | return status; |
| 3845 | −out_overflow: | |
| 3846 | − print_overflow_msg(__func__, xdr); | |
| 3847 | − return -EIO; | |
| 3848 | 3766 | } |
| 3849 | 3767 | |
| 3850 | 3768 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| @@ -3858,15 +3776,12 @@ static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_ · 7 unmodified lines | ||
| 3858 | 3776 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
| 3859 | 3777 | p = xdr_inline_decode(xdr, 4); |
| 3860 | 3778 | if (unlikely(!p)) |
| 3861 | − goto out_overflow; | |
| 3779 | + return -EIO; | |
| 3862 | 3780 | *maxname = be32_to_cpup(p); |
| 3863 | 3781 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3864 | 3782 | } |
| 3865 | 3783 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
| 3866 | 3784 | return status; |
| 3867 | −out_overflow: | |
| 3868 | − print_overflow_msg(__func__, xdr); | |
| 3869 | − return -EIO; | |
| 3870 | 3785 | } |
| 3871 | 3786 | |
| 3872 | 3787 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3881,7 +3796,7 @@ static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_ · 8 unmodified lines | ||
| 3881 | 3796 | uint64_t maxread; |
| 3882 | 3797 | p = xdr_inline_decode(xdr, 8); |
| 3883 | 3798 | if (unlikely(!p)) |
| 3884 | − goto out_overflow; | |
| 3799 | + return -EIO; | |
| 3885 | 3800 | xdr_decode_hyper(p, &maxread); |
| 3886 | 3801 | if (maxread > 0x7FFFFFFF) |
| 3887 | 3802 | maxread = 0x7FFFFFFF; |
| @@ -3890,9 +3805,6 @@ static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_ · 2 unmodified lines | ||
| 3890 | 3805 | } |
| 3891 | 3806 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
| 3892 | 3807 | return status; |
| 3893 | −out_overflow: | |
| 3894 | − print_overflow_msg(__func__, xdr); | |
| 3895 | − return -EIO; | |
| 3896 | 3808 | } |
| 3897 | 3809 | |
| 3898 | 3810 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| @@ -3907,7 +3819,7 @@ static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32 · 8 unmodified lines | ||
| 3907 | 3819 | uint64_t maxwrite; |
| 3908 | 3820 | p = xdr_inline_decode(xdr, 8); |
| 3909 | 3821 | if (unlikely(!p)) |
| 3910 | − goto out_overflow; | |
| 3822 | + return -EIO; | |
| 3911 | 3823 | xdr_decode_hyper(p, &maxwrite); |
| 3912 | 3824 | if (maxwrite > 0x7FFFFFFF) |
| 3913 | 3825 | maxwrite = 0x7FFFFFFF; |
| @@ -3916,9 +3828,6 @@ static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32 · 2 unmodified lines | ||
| 3916 | 3828 | } |
| 3917 | 3829 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
| 3918 | 3830 | return status; |
| 3919 | −out_overflow: | |
| 3920 | − print_overflow_msg(__func__, xdr); | |
| 3921 | − return -EIO; | |
| 3922 | 3831 | } |
| 3923 | 3832 | |
| 3924 | 3833 | static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode) |
| @@ -3933,7 +3842,7 @@ static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *m · 8 unmodified lines | ||
| 3933 | 3842 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
| 3934 | 3843 | p = xdr_inline_decode(xdr, 4); |
| 3935 | 3844 | if (unlikely(!p)) |
| 3936 | − goto out_overflow; | |
| 3845 | + return -EIO; | |
| 3937 | 3846 | tmp = be32_to_cpup(p); |
| 3938 | 3847 | *mode = tmp & ~S_IFMT; |
| 3939 | 3848 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
| @@ -3941,9 +3850,6 @@ static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *m · 1 unmodified line | ||
| 3941 | 3850 | } |
| 3942 | 3851 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
| 3943 | 3852 | return ret; |
| 3944 | −out_overflow: | |
| 3945 | − print_overflow_msg(__func__, xdr); | |
| 3946 | − return -EIO; | |
| 3947 | 3853 | } |
| 3948 | 3854 | |
| 3949 | 3855 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| @@ -3957,16 +3863,13 @@ static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t · 7 unmodified lines | ||
| 3957 | 3863 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
| 3958 | 3864 | p = xdr_inline_decode(xdr, 4); |
| 3959 | 3865 | if (unlikely(!p)) |
| 3960 | − goto out_overflow; | |
| 3866 | + return -EIO; | |
| 3961 | 3867 | *nlink = be32_to_cpup(p); |
| 3962 | 3868 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
| 3963 | 3869 | ret = NFS_ATTR_FATTR_NLINK; |
| 3964 | 3870 | } |
| 3965 | 3871 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
| 3966 | 3872 | return ret; |
| 3967 | −out_overflow: | |
| 3968 | − print_overflow_msg(__func__, xdr); | |
| 3969 | − return -EIO; | |
| 3970 | 3873 | } |
| 3971 | 3874 | |
| 3972 | 3875 | static ssize_t decode_nfs4_string(struct xdr_stream *xdr, |
| @@ -4011,10 +3914,9 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, · 38 unmodified lines | ||
| 4011 | 3914 | return NFS_ATTR_FATTR_OWNER; |
| 4012 | 3915 | } |
| 4013 | 3916 | out: |
| 4014 | − if (len != -EBADMSG) | |
| 4015 | − return 0; | |
| 4016 | − print_overflow_msg(__func__, xdr); | |
| 4017 | − return -EIO; | |
| 3917 | + if (len == -EBADMSG) | |
| 3918 | + return -EIO; | |
| 3919 | + return 0; | |
| 4018 | 3920 | } |
| 4019 | 3921 | |
| 4020 | 3922 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
| @@ -4046,10 +3948,9 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, · 25 unmodified lines | ||
| 4046 | 3948 | return NFS_ATTR_FATTR_GROUP; |
| 4047 | 3949 | } |
| 4048 | 3950 | out: |
| 4049 | − if (len != -EBADMSG) | |
| 4050 | − return 0; | |
| 4051 | − print_overflow_msg(__func__, xdr); | |
| 4052 | − return -EIO; | |
| 3951 | + if (len == -EBADMSG) | |
| 3952 | + return -EIO; | |
| 3953 | + return 0; | |
| 4053 | 3954 | } |
| 4054 | 3955 | |
| 4055 | 3956 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| @@ -4066,7 +3967,7 @@ static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rde · 10 unmodified lines | ||
| 4066 | 3967 | |
| 4067 | 3968 | p = xdr_inline_decode(xdr, 8); |
| 4068 | 3969 | if (unlikely(!p)) |
| 4069 | − goto out_overflow; | |
| 3970 | + return -EIO; | |
| 4070 | 3971 | major = be32_to_cpup(p++); |
| 4071 | 3972 | minor = be32_to_cpup(p); |
| 4072 | 3973 | tmp = MKDEV(major, minor); |
| @@ -4077,9 +3978,6 @@ static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rde · 4 unmodified lines | ||
| 4077 | 3978 | } |
| 4078 | 3979 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
| 4079 | 3980 | return ret; |
| 4080 | −out_overflow: | |
| 4081 | − print_overflow_msg(__func__, xdr); | |
| 4082 | − return -EIO; | |
| 4083 | 3981 | } |
| 4084 | 3982 | |
| 4085 | 3983 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -4093,15 +3991,12 @@ static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uin · 7 unmodified lines | ||
| 4093 | 3991 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
| 4094 | 3992 | p = xdr_inline_decode(xdr, 8); |
| 4095 | 3993 | if (unlikely(!p)) |
| 4096 | − goto out_overflow; | |
| 3994 | + return -EIO; | |
| 4097 | 3995 | xdr_decode_hyper(p, res); |
| 4098 | 3996 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 4099 | 3997 | } |
| 4100 | 3998 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
| 4101 | 3999 | return status; |
| 4102 | −out_overflow: | |
| 4103 | − print_overflow_msg(__func__, xdr); | |
| 4104 | − return -EIO; | |
| 4105 | 4000 | } |
| 4106 | 4001 | |
| 4107 | 4002 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -4115,15 +4010,12 @@ static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint · 7 unmodified lines | ||
| 4115 | 4010 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
| 4116 | 4011 | p = xdr_inline_decode(xdr, 8); |
| 4117 | 4012 | if (unlikely(!p)) |
| 4118 | − goto out_overflow; | |
| 4013 | + return -EIO; | |
| 4119 | 4014 | xdr_decode_hyper(p, res); |
| 4120 | 4015 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 4121 | 4016 | } |
| 4122 | 4017 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
| 4123 | 4018 | return status; |
| 4124 | −out_overflow: | |
| 4125 | − print_overflow_msg(__func__, xdr); | |
| 4126 | − return -EIO; | |
| 4127 | 4019 | } |
| 4128 | 4020 | |
| 4129 | 4021 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| @@ -4137,15 +4029,12 @@ static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uin · 7 unmodified lines | ||
| 4137 | 4029 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
| 4138 | 4030 | p = xdr_inline_decode(xdr, 8); |
| 4139 | 4031 | if (unlikely(!p)) |
| 4140 | − goto out_overflow; | |
| 4032 | + return -EIO; | |
| 4141 | 4033 | xdr_decode_hyper(p, res); |
| 4142 | 4034 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 4143 | 4035 | } |
| 4144 | 4036 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
| 4145 | 4037 | return status; |
| 4146 | −out_overflow: | |
| 4147 | − print_overflow_msg(__func__, xdr); | |
| 4148 | − return -EIO; | |
| 4149 | 4038 | } |
| 4150 | 4039 | |
| 4151 | 4040 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| @@ -4159,7 +4048,7 @@ static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint · 7 unmodified lines | ||
| 4159 | 4048 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
| 4160 | 4049 | p = xdr_inline_decode(xdr, 8); |
| 4161 | 4050 | if (unlikely(!p)) |
| 4162 | − goto out_overflow; | |
| 4051 | + return -EIO; | |
| 4163 | 4052 | xdr_decode_hyper(p, used); |
| 4164 | 4053 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
| 4165 | 4054 | ret = NFS_ATTR_FATTR_SPACE_USED; |
| @@ -4167,9 +4056,6 @@ static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint · 1 unmodified line | ||
| 4167 | 4056 | dprintk("%s: space used=%Lu\n", __func__, |
| 4168 | 4057 | (unsigned long long)*used); |
| 4169 | 4058 | return ret; |
| 4170 | −out_overflow: | |
| 4171 | − print_overflow_msg(__func__, xdr); | |
| 4172 | − return -EIO; | |
| 4173 | 4059 | } |
| 4174 | 4060 | |
| 4175 | 4061 | static __be32 * |
| @@ -4189,12 +4075,9 @@ static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) · 13 unmodified lines | ||
| 4189 | 4075 | |
| 4190 | 4076 | p = xdr_inline_decode(xdr, nfstime4_maxsz << 2); |
| 4191 | 4077 | if (unlikely(!p)) |
| 4192 | − goto out_overflow; | |
| 4078 | + return -EIO; | |
| 4193 | 4079 | xdr_decode_nfstime4(p, time); |
| 4194 | 4080 | return 0; |
| 4195 | −out_overflow: | |
| 4196 | − print_overflow_msg(__func__, xdr); | |
| 4197 | − return -EIO; | |
| 4198 | 4081 | } |
| 4199 | 4082 | |
| 4200 | 4083 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| @@ -4265,19 +4148,19 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, · 64 unmodified lines | ||
| 4265 | 4148 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
| 4266 | 4149 | p = xdr_inline_decode(xdr, 4); |
| 4267 | 4150 | if (unlikely(!p)) |
| 4268 | − goto out_overflow; | |
| 4151 | + return -EIO; | |
| 4269 | 4152 | lfs = be32_to_cpup(p++); |
| 4270 | 4153 | p = xdr_inline_decode(xdr, 4); |
| 4271 | 4154 | if (unlikely(!p)) |
| 4272 | − goto out_overflow; | |
| 4155 | + return -EIO; | |
| 4273 | 4156 | pi = be32_to_cpup(p++); |
| 4274 | 4157 | p = xdr_inline_decode(xdr, 4); |
| 4275 | 4158 | if (unlikely(!p)) |
| 4276 | − goto out_overflow; | |
| 4159 | + return -EIO; | |
| 4277 | 4160 | len = be32_to_cpup(p++); |
| 4278 | 4161 | p = xdr_inline_decode(xdr, len); |
| 4279 | 4162 | if (unlikely(!p)) |
| 4280 | − goto out_overflow; | |
| 4163 | + return -EIO; | |
| 4281 | 4164 | if (len < NFS4_MAXLABELLEN) { |
| 4282 | 4165 | if (label) { |
| 4283 | 4166 | memcpy(label->label, p, len); |
| @@ -4295,10 +4178,6 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, · 11 unmodified lines | ||
| 4295 | 4178 | dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__, |
| 4296 | 4179 | (char *)label->label, label->len, label->pi, label->lfs); |
| 4297 | 4180 | return status; |
| 4298 | − | |
| 4299 | −out_overflow: | |
| 4300 | − print_overflow_msg(__func__, xdr); | |
| 4301 | − return -EIO; | |
| 4302 | 4181 | } |
| 4303 | 4182 | |
| 4304 | 4183 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| @@ -4342,14 +4221,11 @@ static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *c · 37 unmodified lines | ||
| 4342 | 4221 | |
| 4343 | 4222 | p = xdr_inline_decode(xdr, 20); |
| 4344 | 4223 | if (unlikely(!p)) |
| 4345 | − goto out_overflow; | |
| 4224 | + return -EIO; | |
| 4346 | 4225 | cinfo->atomic = be32_to_cpup(p++); |
| 4347 | 4226 | p = xdr_decode_hyper(p, &cinfo->before); |
| 4348 | 4227 | xdr_decode_hyper(p, &cinfo->after); |
| 4349 | 4228 | return 0; |
| 4350 | −out_overflow: | |
| 4351 | − print_overflow_msg(__func__, xdr); | |
| 4352 | − return -EIO; | |
| 4353 | 4229 | } |
| 4354 | 4230 | |
| 4355 | 4231 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
| @@ -4363,24 +4239,19 @@ static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) · 7 unmodified lines | ||
| 4363 | 4239 | return status; |
| 4364 | 4240 | p = xdr_inline_decode(xdr, 8); |
| 4365 | 4241 | if (unlikely(!p)) |
| 4366 | − goto out_overflow; | |
| 4242 | + return -EIO; | |
| 4367 | 4243 | supp = be32_to_cpup(p++); |
| 4368 | 4244 | acc = be32_to_cpup(p); |
| 4369 | 4245 | *supported = supp; |
| 4370 | 4246 | *access = acc; |
| 4371 | 4247 | return 0; |
| 4372 | −out_overflow: | |
| 4373 | − print_overflow_msg(__func__, xdr); | |
| 4374 | − return -EIO; | |
| 4375 | 4248 | } |
| 4376 | 4249 | |
| 4377 | 4250 | static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len) |
| 4378 | 4251 | { |
| 4379 | 4252 | ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len); |
| 4380 | − if (unlikely(ret < 0)) { | |
| 4381 | − print_overflow_msg(__func__, xdr); | |
| 4253 | + if (unlikely(ret < 0)) | |
| 4382 | 4254 | return -EIO; |
| 4383 | − } | |
| 4384 | 4255 | return 0; |
| 4385 | 4256 | } |
| 4386 | 4257 | |
| @@ -4460,13 +4331,11 @@ static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) · 73 unmodified lines | ||
| 4460 | 4331 | return status; |
| 4461 | 4332 | p = xdr_inline_decode(xdr, 4); |
| 4462 | 4333 | if (unlikely(!p)) |
| 4463 | − goto out_overflow; | |
| 4334 | + return -EIO; | |
| 4464 | 4335 | bmlen = be32_to_cpup(p); |
| 4465 | 4336 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4466 | 4337 | if (likely(p)) |
| 4467 | 4338 | return 0; |
| 4468 | −out_overflow: | |
| 4469 | − print_overflow_msg(__func__, xdr); | |
| 4470 | 4339 | return -EIO; |
| 4471 | 4340 | } |
| 4472 | 4341 | |
| @@ -4574,13 +4443,10 @@ static int decode_threshold_hint(struct xdr_stream *xdr, · 101 unmodified lines | ||
| 4574 | 4443 | if (likely(bitmap[0] & hint_bit)) { |
| 4575 | 4444 | p = xdr_inline_decode(xdr, 8); |
| 4576 | 4445 | if (unlikely(!p)) |
| 4577 | − goto out_overflow; | |
| 4446 | + return -EIO; | |
| 4578 | 4447 | xdr_decode_hyper(p, res); |
| 4579 | 4448 | } |
| 4580 | 4449 | return 0; |
| 4581 | −out_overflow: | |
| 4582 | − print_overflow_msg(__func__, xdr); | |
| 4583 | − return -EIO; | |
| 4584 | 4450 | } |
| 4585 | 4451 | |
| 4586 | 4452 | static int decode_first_threshold_item4(struct xdr_stream *xdr, |
| @@ -4593,10 +4459,8 @@ static int decode_first_threshold_item4(struct xdr_stream *xdr, · 6 unmodified lines | ||
| 4593 | 4459 | |
| 4594 | 4460 | /* layout type */ |
| 4595 | 4461 | p = xdr_inline_decode(xdr, 4); |
| 4596 | − if (unlikely(!p)) { | |
| 4597 | − print_overflow_msg(__func__, xdr); | |
| 4462 | + if (unlikely(!p)) | |
| 4598 | 4463 | return -EIO; |
| 4599 | − } | |
| 4600 | 4464 | res->l_type = be32_to_cpup(p); |
| 4601 | 4465 | |
| 4602 | 4466 | /* thi_hintset bitmap */ |
| @@ -4654,7 +4518,7 @@ static int decode_attr_mdsthreshold(struct xdr_stream *xdr, · 51 unmodified lines | ||
| 4654 | 4518 | return -EREMOTEIO; |
| 4655 | 4519 | p = xdr_inline_decode(xdr, 4); |
| 4656 | 4520 | if (unlikely(!p)) |
| 4657 | − goto out_overflow; | |
| 4521 | + return -EIO; | |
| 4658 | 4522 | num = be32_to_cpup(p); |
| 4659 | 4523 | if (num == 0) |
| 4660 | 4524 | return 0; |
| @@ -4667,9 +4531,6 @@ static int decode_attr_mdsthreshold(struct xdr_stream *xdr, · 6 unmodified lines | ||
| 4667 | 4531 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
| 4668 | 4532 | } |
| 4669 | 4533 | return status; |
| 4670 | −out_overflow: | |
| 4671 | − print_overflow_msg(__func__, xdr); | |
| 4672 | − return -EIO; | |
| 4673 | 4534 | } |
| 4674 | 4535 | |
| 4675 | 4536 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| @@ -4857,7 +4718,7 @@ static int decode_pnfs_layout_types(struct xdr_stream *xdr, · 181 unmodified lines | ||
| 4857 | 4718 | |
| 4858 | 4719 | p = xdr_inline_decode(xdr, 4); |
| 4859 | 4720 | if (unlikely(!p)) |
| 4860 | − goto out_overflow; | |
| 4721 | + return -EIO; | |
| 4861 | 4722 | fsinfo->nlayouttypes = be32_to_cpup(p); |
| 4862 | 4723 | |
| 4863 | 4724 | /* pNFS is not supported by the underlying file system */ |
| @@ -4867,7 +4728,7 @@ static int decode_pnfs_layout_types(struct xdr_stream *xdr, · 3 unmodified lines | ||
| 4867 | 4728 | /* Decode and set first layout type, move xdr->p past unused types */ |
| 4868 | 4729 | p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4); |
| 4869 | 4730 | if (unlikely(!p)) |
| 4870 | − goto out_overflow; | |
| 4731 | + return -EIO; | |
| 4871 | 4732 | |
| 4872 | 4733 | /* If we get too many, then just cap it at the max */ |
| 4873 | 4734 | if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) { |
| @@ -4879,9 +4740,6 @@ static int decode_pnfs_layout_types(struct xdr_stream *xdr, · 5 unmodified lines | ||
| 4879 | 4740 | for(i = 0; i < fsinfo->nlayouttypes; ++i) |
| 4880 | 4741 | fsinfo->layouttype[i] = be32_to_cpup(p++); |
| 4881 | 4742 | return 0; |
| 4882 | −out_overflow: | |
| 4883 | − print_overflow_msg(__func__, xdr); | |
| 4884 | − return -EIO; | |
| 4885 | 4743 | } |
| 4886 | 4744 | |
| 4887 | 4745 | /* |
| @@ -4915,10 +4773,8 @@ static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, · 27 unmodified lines | ||
| 4915 | 4773 | *res = 0; |
| 4916 | 4774 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4917 | 4775 | p = xdr_inline_decode(xdr, 4); |
| 4918 | − if (unlikely(!p)) { | |
| 4919 | − print_overflow_msg(__func__, xdr); | |
| 4776 | + if (unlikely(!p)) | |
| 4920 | 4777 | return -EIO; |
| 4921 | − } | |
| 4922 | 4778 | *res = be32_to_cpup(p); |
| 4923 | 4779 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4924 | 4780 | } |
| @@ -4937,10 +4793,8 @@ static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap, · 12 unmodified lines | ||
| 4937 | 4793 | *res = 0; |
| 4938 | 4794 | if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) { |
| 4939 | 4795 | p = xdr_inline_decode(xdr, 4); |
| 4940 | − if (unlikely(!p)) { | |
| 4941 | − print_overflow_msg(__func__, xdr); | |
| 4796 | + if (unlikely(!p)) | |
| 4942 | 4797 | return -EIO; |
| 4943 | − } | |
| 4944 | 4798 | *res = be32_to_cpup(p); |
| 4945 | 4799 | bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE; |
| 4946 | 4800 | } |
| @@ -5016,19 +4870,16 @@ static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) · 69 unmodified lines | ||
| 5016 | 4870 | |
| 5017 | 4871 | p = xdr_inline_decode(xdr, 4); |
| 5018 | 4872 | if (unlikely(!p)) |
| 5019 | − goto out_overflow; | |
| 4873 | + return -EIO; | |
| 5020 | 4874 | len = be32_to_cpup(p); |
| 5021 | 4875 | if (len > NFS4_FHSIZE) |
| 5022 | 4876 | return -EIO; |
| 5023 | 4877 | fh->size = len; |
| 5024 | 4878 | p = xdr_inline_decode(xdr, len); |
| 5025 | 4879 | if (unlikely(!p)) |
| 5026 | − goto out_overflow; | |
| 4880 | + return -EIO; | |
| 5027 | 4881 | memcpy(fh->data, p, len); |
| 5028 | 4882 | return 0; |
| 5029 | −out_overflow: | |
| 5030 | − print_overflow_msg(__func__, xdr); | |
| 5031 | − return -EIO; | |
| 5032 | 4883 | } |
| 5033 | 4884 | |
| 5034 | 4885 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| @@ -5052,7 +4903,7 @@ static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) · 17 unmodified lines | ||
| 5052 | 4903 | |
| 5053 | 4904 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
| 5054 | 4905 | if (unlikely(!p)) |
| 5055 | − goto out_overflow; | |
| 4906 | + return -EIO; | |
| 5056 | 4907 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
| 5057 | 4908 | p = xdr_decode_hyper(p, &length); |
| 5058 | 4909 | type = be32_to_cpup(p++); /* 4 byte read */ |
| @@ -5069,11 +4920,9 @@ static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) · 10 unmodified lines | ||
| 5069 | 4920 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 5070 | 4921 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 5071 | 4922 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
| 5072 | − if (likely(p)) | |
| 5073 | − return -NFS4ERR_DENIED; | |
| 5074 | −out_overflow: | |
| 5075 | − print_overflow_msg(__func__, xdr); | |
| 5076 | − return -EIO; | |
| 4923 | + if (likely(!p)) | |
| 4924 | + return -EIO; | |
| 4925 | + return -NFS4ERR_DENIED; | |
| 5077 | 4926 | } |
| 5078 | 4927 | |
| 5079 | 4928 | static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res) |
| @@ -5142,7 +4991,7 @@ static int decode_space_limit(struct xdr_stream *xdr, · 62 unmodified lines | ||
| 5142 | 4991 | |
| 5143 | 4992 | p = xdr_inline_decode(xdr, 12); |
| 5144 | 4993 | if (unlikely(!p)) |
| 5145 | − goto out_overflow; | |
| 4994 | + return -EIO; | |
| 5146 | 4995 | limit_type = be32_to_cpup(p++); |
| 5147 | 4996 | switch (limit_type) { |
| 5148 | 4997 | case NFS4_LIMIT_SIZE: |
| @@ -5156,9 +5005,6 @@ static int decode_space_limit(struct xdr_stream *xdr, · 7 unmodified lines | ||
| 5156 | 5005 | maxsize >>= PAGE_SHIFT; |
| 5157 | 5006 | *pagemod_limit = min_t(u64, maxsize, ULONG_MAX); |
| 5158 | 5007 | return 0; |
| 5159 | −out_overflow: | |
| 5160 | − print_overflow_msg(__func__, xdr); | |
| 5161 | − return -EIO; | |
| 5162 | 5008 | } |
| 5163 | 5009 | |
| 5164 | 5010 | static int decode_rw_delegation(struct xdr_stream *xdr, |
| @@ -5173,7 +5019,7 @@ static int decode_rw_delegation(struct xdr_stream *xdr, · 8 unmodified lines | ||
| 5173 | 5019 | return status; |
| 5174 | 5020 | p = xdr_inline_decode(xdr, 4); |
| 5175 | 5021 | if (unlikely(!p)) |
| 5176 | − goto out_overflow; | |
| 5022 | + return -EIO; | |
| 5177 | 5023 | res->do_recall = be32_to_cpup(p); |
| 5178 | 5024 | |
| 5179 | 5025 | switch (delegation_type) { |
| @@ -5186,9 +5032,6 @@ static int decode_rw_delegation(struct xdr_stream *xdr, · 6 unmodified lines | ||
| 5186 | 5032 | return -EIO; |
| 5187 | 5033 | } |
| 5188 | 5034 | return decode_ace(xdr, NULL); |
| 5189 | −out_overflow: | |
| 5190 | − print_overflow_msg(__func__, xdr); | |
| 5191 | − return -EIO; | |
| 5192 | 5035 | } |
| 5193 | 5036 | |
| 5194 | 5037 | static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| @@ -5198,7 +5041,7 @@ static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) · 3 unmodified lines | ||
| 5198 | 5041 | |
| 5199 | 5042 | p = xdr_inline_decode(xdr, 4); |
| 5200 | 5043 | if (unlikely(!p)) |
| 5201 | − goto out_overflow; | |
| 5044 | + return -EIO; | |
| 5202 | 5045 | why_no_delegation = be32_to_cpup(p); |
| 5203 | 5046 | switch (why_no_delegation) { |
| 5204 | 5047 | case WND4_CONTENTION: |
| @@ -5207,9 +5050,6 @@ static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) · 2 unmodified lines | ||
| 5207 | 5050 | /* Ignore for now */ |
| 5208 | 5051 | } |
| 5209 | 5052 | return 0; |
| 5210 | −out_overflow: | |
| 5211 | − print_overflow_msg(__func__, xdr); | |
| 5212 | − return -EIO; | |
| 5213 | 5053 | } |
| 5214 | 5054 | |
| 5215 | 5055 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| @@ -5219,7 +5059,7 @@ static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) · 3 unmodified lines | ||
| 5219 | 5059 | |
| 5220 | 5060 | p = xdr_inline_decode(xdr, 4); |
| 5221 | 5061 | if (unlikely(!p)) |
| 5222 | − goto out_overflow; | |
| 5062 | + return -EIO; | |
| 5223 | 5063 | delegation_type = be32_to_cpup(p); |
| 5224 | 5064 | res->delegation_type = 0; |
| 5225 | 5065 | switch (delegation_type) { |
| @@ -5232,9 +5072,6 @@ static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) · 6 unmodified lines | ||
| 5232 | 5072 | return decode_no_delegation(xdr, res); |
| 5233 | 5073 | } |
| 5234 | 5074 | return -EIO; |
| 5235 | −out_overflow: | |
| 5236 | − print_overflow_msg(__func__, xdr); | |
| 5237 | − return -EIO; | |
| 5238 | 5075 | } |
| 5239 | 5076 | |
| 5240 | 5077 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| @@ -5256,7 +5093,7 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) · 15 unmodified lines | ||
| 5256 | 5093 | |
| 5257 | 5094 | p = xdr_inline_decode(xdr, 8); |
| 5258 | 5095 | if (unlikely(!p)) |
| 5259 | − goto out_overflow; | |
| 5096 | + return -EIO; | |
| 5260 | 5097 | res->rflags = be32_to_cpup(p++); |
| 5261 | 5098 | bmlen = be32_to_cpup(p); |
| 5262 | 5099 | if (bmlen > 10) |
| @@ -5264,7 +5101,7 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) · 1 unmodified line | ||
| 5264 | 5101 | |
| 5265 | 5102 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5266 | 5103 | if (unlikely(!p)) |
| 5267 | − goto out_overflow; | |
| 5104 | + return -EIO; | |
| 5268 | 5105 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 5269 | 5106 | for (i = 0; i < savewords; ++i) |
| 5270 | 5107 | res->attrset[i] = be32_to_cpup(p++); |
| @@ -5275,9 +5112,6 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) · 4 unmodified lines | ||
| 5275 | 5112 | xdr_error: |
| 5276 | 5113 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
| 5277 | 5114 | return -EIO; |
| 5278 | −out_overflow: | |
| 5279 | − print_overflow_msg(__func__, xdr); | |
| 5280 | − return -EIO; | |
| 5281 | 5115 | } |
| 5282 | 5116 | |
| 5283 | 5117 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| @@ -5326,7 +5160,7 @@ static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, · 42 unmodified lines | ||
| 5326 | 5160 | return status; |
| 5327 | 5161 | p = xdr_inline_decode(xdr, 8); |
| 5328 | 5162 | if (unlikely(!p)) |
| 5329 | − goto out_overflow; | |
| 5163 | + return -EIO; | |
| 5330 | 5164 | eof = be32_to_cpup(p++); |
| 5331 | 5165 | count = be32_to_cpup(p); |
| 5332 | 5166 | recvd = xdr_read_pages(xdr, count); |
| @@ -5339,9 +5173,6 @@ static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, · 6 unmodified lines | ||
| 5339 | 5173 | res->eof = eof; |
| 5340 | 5174 | res->count = count; |
| 5341 | 5175 | return 0; |
| 5342 | −out_overflow: | |
| 5343 | − print_overflow_msg(__func__, xdr); | |
| 5344 | − return -EIO; | |
| 5345 | 5176 | } |
| 5346 | 5177 | |
| 5347 | 5178 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| @@ -5374,7 +5205,7 @@ static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) · 26 unmodified lines | ||
| 5374 | 5205 | /* Convert length of symlink */ |
| 5375 | 5206 | p = xdr_inline_decode(xdr, 4); |
| 5376 | 5207 | if (unlikely(!p)) |
| 5377 | − goto out_overflow; | |
| 5208 | + return -EIO; | |
| 5378 | 5209 | len = be32_to_cpup(p); |
| 5379 | 5210 | if (len >= rcvbuf->page_len || len <= 0) { |
| 5380 | 5211 | dprintk("nfs: server returned giant symlink!\n"); |
| @@ -5395,9 +5226,6 @@ static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) · 14 unmodified lines | ||
| 5395 | 5226 | */ |
| 5396 | 5227 | xdr_terminate_string(rcvbuf, len); |
| 5397 | 5228 | return 0; |
| 5398 | −out_overflow: | |
| 5399 | − print_overflow_msg(__func__, xdr); | |
| 5400 | − return -EIO; | |
| 5401 | 5229 | } |
| 5402 | 5230 | |
| 5403 | 5231 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| @@ -5500,7 +5328,6 @@ static int decode_setattr(struct xdr_stream *xdr) · 96 unmodified lines | ||
| 5500 | 5328 | return status; |
| 5501 | 5329 | if (decode_bitmap4(xdr, NULL, 0) >= 0) |
| 5502 | 5330 | return 0; |
| 5503 | − print_overflow_msg(__func__, xdr); | |
| 5504 | 5331 | return -EIO; |
| 5505 | 5332 | } |
| 5506 | 5333 | |
| @@ -5512,7 +5339,7 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_re · 5 unmodified lines | ||
| 5512 | 5339 | |
| 5513 | 5340 | p = xdr_inline_decode(xdr, 8); |
| 5514 | 5341 | if (unlikely(!p)) |
| 5515 | − goto out_overflow; | |
| 5342 | + return -EIO; | |
| 5516 | 5343 | opnum = be32_to_cpup(p++); |
| 5517 | 5344 | if (opnum != OP_SETCLIENTID) { |
| 5518 | 5345 | dprintk("nfs: decode_setclientid: Server returned operation" |
| @@ -5523,7 +5350,7 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_re · 4 unmodified lines | ||
| 5523 | 5350 | if (nfserr == NFS_OK) { |
| 5524 | 5351 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 5525 | 5352 | if (unlikely(!p)) |
| 5526 | − goto out_overflow; | |
| 5353 | + return -EIO; | |
| 5527 | 5354 | p = xdr_decode_hyper(p, &res->clientid); |
| 5528 | 5355 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
| 5529 | 5356 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| @@ -5532,28 +5359,25 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_re · 2 unmodified lines | ||
| 5532 | 5359 | /* skip netid string */ |
| 5533 | 5360 | p = xdr_inline_decode(xdr, 4); |
| 5534 | 5361 | if (unlikely(!p)) |
| 5535 | − goto out_overflow; | |
| 5362 | + return -EIO; | |
| 5536 | 5363 | len = be32_to_cpup(p); |
| 5537 | 5364 | p = xdr_inline_decode(xdr, len); |
| 5538 | 5365 | if (unlikely(!p)) |
| 5539 | − goto out_overflow; | |
| 5366 | + return -EIO; | |
| 5540 | 5367 | |
| 5541 | 5368 | /* skip uaddr string */ |
| 5542 | 5369 | p = xdr_inline_decode(xdr, 4); |
| 5543 | 5370 | if (unlikely(!p)) |
| 5544 | − goto out_overflow; | |
| 5371 | + return -EIO; | |
| 5545 | 5372 | len = be32_to_cpup(p); |
| 5546 | 5373 | p = xdr_inline_decode(xdr, len); |
| 5547 | 5374 | if (unlikely(!p)) |
| 5548 | − goto out_overflow; | |
| 5375 | + return -EIO; | |
| 5549 | 5376 | return -NFSERR_CLID_INUSE; |
| 5550 | 5377 | } else |
| 5551 | 5378 | return nfs4_stat_to_errno(nfserr); |
| 5552 | 5379 | |
| 5553 | 5380 | return 0; |
| 5554 | −out_overflow: | |
| 5555 | − print_overflow_msg(__func__, xdr); | |
| 5556 | − return -EIO; | |
| 5557 | 5381 | } |
| 5558 | 5382 | |
| 5559 | 5383 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| @@ -5572,13 +5396,10 @@ static int decode_write(struct xdr_stream *xdr, struct nfs_pgio_res *res) · 12 unmodified lines | ||
| 5572 | 5396 | |
| 5573 | 5397 | p = xdr_inline_decode(xdr, 8); |
| 5574 | 5398 | if (unlikely(!p)) |
| 5575 | − goto out_overflow; | |
| 5399 | + return -EIO; | |
| 5576 | 5400 | res->count = be32_to_cpup(p++); |
| 5577 | 5401 | res->verf->committed = be32_to_cpup(p++); |
| 5578 | 5402 | return decode_write_verifier(xdr, &res->verf->verifier); |
| 5579 | −out_overflow: | |
| 5580 | − print_overflow_msg(__func__, xdr); | |
| 5581 | − return -EIO; | |
| 5582 | 5403 | } |
| 5583 | 5404 | |
| 5584 | 5405 | static int decode_delegreturn(struct xdr_stream *xdr) |
| @@ -5594,30 +5415,24 @@ static int decode_secinfo_gss(struct xdr_stream *xdr, · 9 unmodified lines | ||
| 5594 | 5415 | |
| 5595 | 5416 | p = xdr_inline_decode(xdr, 4); |
| 5596 | 5417 | if (unlikely(!p)) |
| 5597 | − goto out_overflow; | |
| 5418 | + return -EIO; | |
| 5598 | 5419 | oid_len = be32_to_cpup(p); |
| 5599 | 5420 | if (oid_len > GSS_OID_MAX_LEN) |
| 5600 | − goto out_err; | |
| 5421 | + return -EINVAL; | |
| 5601 | 5422 | |
| 5602 | 5423 | p = xdr_inline_decode(xdr, oid_len); |
| 5603 | 5424 | if (unlikely(!p)) |
| 5604 | − goto out_overflow; | |
| 5425 | + return -EIO; | |
| 5605 | 5426 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
| 5606 | 5427 | flavor->flavor_info.oid.len = oid_len; |
| 5607 | 5428 | |
| 5608 | 5429 | p = xdr_inline_decode(xdr, 8); |
| 5609 | 5430 | if (unlikely(!p)) |
| 5610 | − goto out_overflow; | |
| 5431 | + return -EIO; | |
| 5611 | 5432 | flavor->flavor_info.qop = be32_to_cpup(p++); |
| 5612 | 5433 | flavor->flavor_info.service = be32_to_cpup(p); |
| 5613 | 5434 | |
| 5614 | 5435 | return 0; |
| 5615 | − | |
| 5616 | −out_overflow: | |
| 5617 | − print_overflow_msg(__func__, xdr); | |
| 5618 | − return -EIO; | |
| 5619 | −out_err: | |
| 5620 | − return -EINVAL; | |
| 5621 | 5436 | } |
| 5622 | 5437 | |
| 5623 | 5438 | static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| @@ -5629,7 +5444,7 @@ static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res · 5 unmodified lines | ||
| 5629 | 5444 | |
| 5630 | 5445 | p = xdr_inline_decode(xdr, 4); |
| 5631 | 5446 | if (unlikely(!p)) |
| 5632 | − goto out_overflow; | |
| 5447 | + return -EIO; | |
| 5633 | 5448 | |
| 5634 | 5449 | res->flavors->num_flavors = 0; |
| 5635 | 5450 | num_flavors = be32_to_cpup(p); |
| @@ -5641,7 +5456,7 @@ static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res · 5 unmodified lines | ||
| 5641 | 5456 | |
| 5642 | 5457 | p = xdr_inline_decode(xdr, 4); |
| 5643 | 5458 | if (unlikely(!p)) |
| 5644 | − goto out_overflow; | |
| 5459 | + return -EIO; | |
| 5645 | 5460 | sec_flavor->flavor = be32_to_cpup(p); |
| 5646 | 5461 | |
| 5647 | 5462 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
| @@ -5655,9 +5470,6 @@ static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res · 7 unmodified lines | ||
| 5655 | 5470 | status = 0; |
| 5656 | 5471 | out: |
| 5657 | 5472 | return status; |
| 5658 | −out_overflow: | |
| 5659 | − print_overflow_msg(__func__, xdr); | |
| 5660 | − return -EIO; | |
| 5661 | 5473 | } |
| 5662 | 5474 | |
| 5663 | 5475 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| @@ -5711,11 +5523,11 @@ static int decode_exchange_id(struct xdr_stream *xdr, · 47 unmodified lines | ||
| 5711 | 5523 | |
| 5712 | 5524 | p = xdr_inline_decode(xdr, 8); |
| 5713 | 5525 | if (unlikely(!p)) |
| 5714 | − goto out_overflow; | |
| 5526 | + return -EIO; | |
| 5715 | 5527 | xdr_decode_hyper(p, &res->clientid); |
| 5716 | 5528 | p = xdr_inline_decode(xdr, 12); |
| 5717 | 5529 | if (unlikely(!p)) |
| 5718 | − goto out_overflow; | |
| 5530 | + return -EIO; | |
| 5719 | 5531 | res->seqid = be32_to_cpup(p++); |
| 5720 | 5532 | res->flags = be32_to_cpup(p++); |
| 5721 | 5533 | |
| @@ -5739,7 +5551,7 @@ static int decode_exchange_id(struct xdr_stream *xdr, · 17 unmodified lines | ||
| 5739 | 5551 | /* server_owner4.so_minor_id */ |
| 5740 | 5552 | p = xdr_inline_decode(xdr, 8); |
| 5741 | 5553 | if (unlikely(!p)) |
| 5742 | − goto out_overflow; | |
| 5554 | + return -EIO; | |
| 5743 | 5555 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
| 5744 | 5556 | |
| 5745 | 5557 | /* server_owner4.so_major_id */ |
| @@ -5759,7 +5571,7 @@ static int decode_exchange_id(struct xdr_stream *xdr, · 13 unmodified lines | ||
| 5759 | 5571 | /* Implementation Id */ |
| 5760 | 5572 | p = xdr_inline_decode(xdr, 4); |
| 5761 | 5573 | if (unlikely(!p)) |
| 5762 | − goto out_overflow; | |
| 5574 | + return -EIO; | |
| 5763 | 5575 | impl_id_count = be32_to_cpup(p++); |
| 5764 | 5576 | |
| 5765 | 5577 | if (impl_id_count) { |
| @@ -5778,16 +5590,13 @@ static int decode_exchange_id(struct xdr_stream *xdr, · 12 unmodified lines | ||
| 5778 | 5590 | /* nii_date */ |
| 5779 | 5591 | p = xdr_inline_decode(xdr, 12); |
| 5780 | 5592 | if (unlikely(!p)) |
| 5781 | − goto out_overflow; | |
| 5593 | + return -EIO; | |
| 5782 | 5594 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5783 | 5595 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5784 | 5596 | |
| 5785 | 5597 | /* if there's more than one entry, ignore the rest */ |
| 5786 | 5598 | } |
| 5787 | 5599 | return 0; |
| 5788 | −out_overflow: | |
| 5789 | − print_overflow_msg(__func__, xdr); | |
| 5790 | − return -EIO; | |
| 5791 | 5600 | } |
| 5792 | 5601 | |
| 5793 | 5602 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| @@ -5798,7 +5607,7 @@ static int decode_chan_attrs(struct xdr_stream *xdr, · 4 unmodified lines | ||
| 5798 | 5607 | |
| 5799 | 5608 | p = xdr_inline_decode(xdr, 28); |
| 5800 | 5609 | if (unlikely(!p)) |
| 5801 | − goto out_overflow; | |
| 5610 | + return -EIO; | |
| 5802 | 5611 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5803 | 5612 | if (val) |
| 5804 | 5613 | return -EINVAL; /* no support for header padding yet */ |
| @@ -5816,12 +5625,9 @@ static int decode_chan_attrs(struct xdr_stream *xdr, · 11 unmodified lines | ||
| 5816 | 5625 | if (nr_attrs == 1) { |
| 5817 | 5626 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5818 | 5627 | if (unlikely(!p)) |
| 5819 | − goto out_overflow; | |
| 5628 | + return -EIO; | |
| 5820 | 5629 | } |
| 5821 | 5630 | return 0; |
| 5822 | −out_overflow: | |
| 5823 | − print_overflow_msg(__func__, xdr); | |
| 5824 | − return -EIO; | |
| 5825 | 5631 | } |
| 5826 | 5632 | |
| 5827 | 5633 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| @@ -5844,7 +5650,7 @@ static int decode_bind_conn_to_session(struct xdr_stream *xdr, · 16 unmodified lines | ||
| 5844 | 5650 | /* dir flags, rdma mode bool */ |
| 5845 | 5651 | p = xdr_inline_decode(xdr, 8); |
| 5846 | 5652 | if (unlikely(!p)) |
| 5847 | − goto out_overflow; | |
| 5653 | + return -EIO; | |
| 5848 | 5654 | |
| 5849 | 5655 | res->dir = be32_to_cpup(p++); |
| 5850 | 5656 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) |
| @@ -5855,9 +5661,6 @@ static int decode_bind_conn_to_session(struct xdr_stream *xdr, · 4 unmodified lines | ||
| 5855 | 5661 | res->use_conn_in_rdma_mode = true; |
| 5856 | 5662 | |
| 5857 | 5663 | return 0; |
| 5858 | −out_overflow: | |
| 5859 | − print_overflow_msg(__func__, xdr); | |
| 5860 | − return -EIO; | |
| 5861 | 5664 | } |
| 5862 | 5665 | |
| 5863 | 5666 | static int decode_create_session(struct xdr_stream *xdr, |
| @@ -5875,7 +5678,7 @@ static int decode_create_session(struct xdr_stream *xdr, · 11 unmodified lines | ||
| 5875 | 5678 | /* seqid, flags */ |
| 5876 | 5679 | p = xdr_inline_decode(xdr, 8); |
| 5877 | 5680 | if (unlikely(!p)) |
| 5878 | − goto out_overflow; | |
| 5681 | + return -EIO; | |
| 5879 | 5682 | res->seqid = be32_to_cpup(p++); |
| 5880 | 5683 | res->flags = be32_to_cpup(p); |
| 5881 | 5684 | |
| @@ -5884,9 +5687,6 @@ static int decode_create_session(struct xdr_stream *xdr, · 2 unmodified lines | ||
| 5884 | 5687 | if (!status) |
| 5885 | 5688 | status = decode_chan_attrs(xdr, &res->bc_attrs); |
| 5886 | 5689 | return status; |
| 5887 | −out_overflow: | |
| 5888 | − print_overflow_msg(__func__, xdr); | |
| 5889 | − return -EIO; | |
| 5890 | 5690 | } |
| 5891 | 5691 | |
| 5892 | 5692 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| @@ -5967,7 +5767,6 @@ out_err: · 74 unmodified lines | ||
| 5967 | 5767 | res->sr_status = status; |
| 5968 | 5768 | return status; |
| 5969 | 5769 | out_overflow: |
| 5970 | − print_overflow_msg(__func__, xdr); | |
| 5971 | 5770 | status = -EIO; |
| 5972 | 5771 | goto out_err; |
| 5973 | 5772 | #else /* CONFIG_NFS_V4_1 */ |
| @@ -5995,7 +5794,7 @@ static int decode_getdeviceinfo(struct xdr_stream *xdr, · 21 unmodified lines | ||
| 5995 | 5794 | if (status == -ETOOSMALL) { |
| 5996 | 5795 | p = xdr_inline_decode(xdr, 4); |
| 5997 | 5796 | if (unlikely(!p)) |
| 5998 | − goto out_overflow; | |
| 5797 | + return -EIO; | |
| 5999 | 5798 | pdev->mincount = be32_to_cpup(p); |
| 6000 | 5799 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 6001 | 5800 | __func__, pdev->mincount); |
| @@ -6005,7 +5804,7 @@ static int decode_getdeviceinfo(struct xdr_stream *xdr, · 3 unmodified lines | ||
| 6005 | 5804 | |
| 6006 | 5805 | p = xdr_inline_decode(xdr, 8); |
| 6007 | 5806 | if (unlikely(!p)) |
| 6008 | − goto out_overflow; | |
| 5807 | + return -EIO; | |
| 6009 | 5808 | type = be32_to_cpup(p++); |
| 6010 | 5809 | if (type != pdev->layout_type) { |
| 6011 | 5810 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| @@ -6019,19 +5818,19 @@ static int decode_getdeviceinfo(struct xdr_stream *xdr, · 7 unmodified lines | ||
| 6019 | 5818 | */ |
| 6020 | 5819 | pdev->mincount = be32_to_cpup(p); |
| 6021 | 5820 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
| 6022 | − goto out_overflow; | |
| 5821 | + return -EIO; | |
| 6023 | 5822 | |
| 6024 | 5823 | /* Parse notification bitmap, verifying that it is zero. */ |
| 6025 | 5824 | p = xdr_inline_decode(xdr, 4); |
| 6026 | 5825 | if (unlikely(!p)) |
| 6027 | − goto out_overflow; | |
| 5826 | + return -EIO; | |
| 6028 | 5827 | len = be32_to_cpup(p); |
| 6029 | 5828 | if (len) { |
| 6030 | 5829 | uint32_t i; |
| 6031 | 5830 | |
| 6032 | 5831 | p = xdr_inline_decode(xdr, 4 * len); |
| 6033 | 5832 | if (unlikely(!p)) |
| 6034 | − goto out_overflow; | |
| 5833 | + return -EIO; | |
| 6035 | 5834 | |
| 6036 | 5835 | res->notification = be32_to_cpup(p++); |
| 6037 | 5836 | for (i = 1; i < len; i++) { |
| @@ -6043,9 +5842,6 @@ static int decode_getdeviceinfo(struct xdr_stream *xdr, · 5 unmodified lines | ||
| 6043 | 5842 | } |
| 6044 | 5843 | } |
| 6045 | 5844 | return 0; |
| 6046 | −out_overflow: | |
| 6047 | − print_overflow_msg(__func__, xdr); | |
| 6048 | − return -EIO; | |
| 6049 | 5845 | } |
| 6050 | 5846 | |
| 6051 | 5847 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| @@ -6115,7 +5911,6 @@ out: · 63 unmodified lines | ||
| 6115 | 5911 | res->status = status; |
| 6116 | 5912 | return status; |
| 6117 | 5913 | out_overflow: |
| 6118 | − print_overflow_msg(__func__, xdr); | |
| 6119 | 5914 | status = -EIO; |
| 6120 | 5915 | goto out; |
| 6121 | 5916 | } |
| @@ -6131,16 +5926,13 @@ static int decode_layoutreturn(struct xdr_stream *xdr, · 9 unmodified lines | ||
| 6131 | 5926 | return status; |
| 6132 | 5927 | p = xdr_inline_decode(xdr, 4); |
| 6133 | 5928 | if (unlikely(!p)) |
| 6134 | − goto out_overflow; | |
| 5929 | + return -EIO; | |
| 6135 | 5930 | res->lrs_present = be32_to_cpup(p); |
| 6136 | 5931 | if (res->lrs_present) |
| 6137 | 5932 | status = decode_layout_stateid(xdr, &res->stateid); |
| 6138 | 5933 | else |
| 6139 | 5934 | nfs4_stateid_copy(&res->stateid, &invalid_stateid); |
| 6140 | 5935 | return status; |
| 6141 | −out_overflow: | |
| 6142 | − print_overflow_msg(__func__, xdr); | |
| 6143 | − return -EIO; | |
| 6144 | 5936 | } |
| 6145 | 5937 | |
| 6146 | 5938 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| @@ -6158,19 +5950,16 @@ static int decode_layoutcommit(struct xdr_stream *xdr, · 11 unmodified lines | ||
| 6158 | 5950 | |
| 6159 | 5951 | p = xdr_inline_decode(xdr, 4); |
| 6160 | 5952 | if (unlikely(!p)) |
| 6161 | − goto out_overflow; | |
| 5953 | + return -EIO; | |
| 6162 | 5954 | sizechanged = be32_to_cpup(p); |
| 6163 | 5955 | |
| 6164 | 5956 | if (sizechanged) { |
| 6165 | 5957 | /* throw away new size */ |
| 6166 | 5958 | p = xdr_inline_decode(xdr, 8); |
| 6167 | 5959 | if (unlikely(!p)) |
| 6168 | − goto out_overflow; | |
| 5960 | + return -EIO; | |
| 6169 | 5961 | } |
| 6170 | 5962 | return 0; |
| 6171 | −out_overflow: | |
| 6172 | − print_overflow_msg(__func__, xdr); | |
| 6173 | − return -EIO; | |
| 6174 | 5963 | } |
| 6175 | 5964 | |
| 6176 | 5965 | static int decode_test_stateid(struct xdr_stream *xdr, |
| @@ -6186,21 +5975,17 @@ static int decode_test_stateid(struct xdr_stream *xdr, · 9 unmodified lines | ||
| 6186 | 5975 | |
| 6187 | 5976 | p = xdr_inline_decode(xdr, 4); |
| 6188 | 5977 | if (unlikely(!p)) |
| 6189 | − goto out_overflow; | |
| 5978 | + return -EIO; | |
| 6190 | 5979 | num_res = be32_to_cpup(p++); |
| 6191 | 5980 | if (num_res != 1) |
| 6192 | − goto out; | |
| 5981 | + return -EIO; | |
| 6193 | 5982 | |
| 6194 | 5983 | p = xdr_inline_decode(xdr, 4); |
| 6195 | 5984 | if (unlikely(!p)) |
| 6196 | − goto out_overflow; | |
| 5985 | + return -EIO; | |
| 6197 | 5986 | res->status = be32_to_cpup(p++); |
| 6198 | 5987 | |
| 6199 | 5988 | return status; |
| 6200 | −out_overflow: | |
| 6201 | − print_overflow_msg(__func__, xdr); | |
| 6202 | −out: | |
| 6203 | − return -EIO; | |
| 6204 | 5989 | } |
| 6205 | 5990 | |
| 6206 | 5991 | static int decode_free_stateid(struct xdr_stream *xdr, |
| @@ -7570,11 +7355,11 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 1363 unmodified lines | ||
| 7570 | 7355 | uint64_t new_cookie; |
| 7571 | 7356 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 7572 | 7357 | if (unlikely(!p)) |
| 7573 | − goto out_overflow; | |
| 7358 | + return -EAGAIN; | |
| 7574 | 7359 | if (*p == xdr_zero) { |
| 7575 | 7360 | p = xdr_inline_decode(xdr, 4); |
| 7576 | 7361 | if (unlikely(!p)) |
| 7577 | − goto out_overflow; | |
| 7362 | + return -EAGAIN; | |
| 7578 | 7363 | if (*p == xdr_zero) |
| 7579 | 7364 | return -EAGAIN; |
| 7580 | 7365 | entry->eof = 1; |
| @@ -7583,13 +7368,13 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 2 unmodified lines | ||
| 7583 | 7368 | |
| 7584 | 7369 | p = xdr_inline_decode(xdr, 12); |
| 7585 | 7370 | if (unlikely(!p)) |
| 7586 | − goto out_overflow; | |
| 7371 | + return -EAGAIN; | |
| 7587 | 7372 | p = xdr_decode_hyper(p, &new_cookie); |
| 7588 | 7373 | entry->len = be32_to_cpup(p); |
| 7589 | 7374 | |
| 7590 | 7375 | p = xdr_inline_decode(xdr, entry->len); |
| 7591 | 7376 | if (unlikely(!p)) |
| 7592 | − goto out_overflow; | |
| 7377 | + return -EAGAIN; | |
| 7593 | 7378 | entry->name = (const char *) p; |
| 7594 | 7379 | |
| 7595 | 7380 | /* |
| @@ -7601,14 +7386,14 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 5 unmodified lines | ||
| 7601 | 7386 | entry->fattr->valid = 0; |
| 7602 | 7387 | |
| 7603 | 7388 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
| 7604 | − goto out_overflow; | |
| 7389 | + return -EAGAIN; | |
| 7605 | 7390 | |
| 7606 | 7391 | if (decode_attr_length(xdr, &len, &savep) < 0) |
| 7607 | − goto out_overflow; | |
| 7392 | + return -EAGAIN; | |
| 7608 | 7393 | |
| 7609 | 7394 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
| 7610 | 7395 | NULL, entry->label, entry->server) < 0) |
| 7611 | − goto out_overflow; | |
| 7396 | + return -EAGAIN; | |
| 7612 | 7397 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 7613 | 7398 | entry->ino = entry->fattr->mounted_on_fileid; |
| 7614 | 7399 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
| @@ -7622,10 +7407,6 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, · 7 unmodified lines | ||
| 7622 | 7407 | entry->cookie = new_cookie; |
| 7623 | 7408 | |
| 7624 | 7409 | return 0; |
| 7625 | − | |
| 7626 | −out_overflow: | |
| 7627 | − print_overflow_msg(__func__, xdr); | |
| 7628 | − return -EAGAIN; | |
| 7629 | 7410 | } |
| 7630 | 7411 | |
| 7631 | 7412 | /* |
| @@ -11,3 +11,4 @@ · 10 unmodified lines | ||
| 11 | 11 | |
| 12 | 12 | EXPORT_TRACEPOINT_SYMBOL_GPL(nfs_fsync_enter); |
| 13 | 13 | EXPORT_TRACEPOINT_SYMBOL_GPL(nfs_fsync_exit); |
| 14 | +EXPORT_TRACEPOINT_SYMBOL_GPL(nfs_xdr_status); | |
| @@ -969,6 +969,91 @@ TRACE_EVENT(nfs_commit_done, · 968 unmodified lines | ||
| 969 | 969 | ) |
| 970 | 970 | ); |
| 971 | 971 | |
| 972 | +TRACE_DEFINE_ENUM(NFS_OK); | |
| 973 | +TRACE_DEFINE_ENUM(NFSERR_PERM); | |
| 974 | +TRACE_DEFINE_ENUM(NFSERR_NOENT); | |
| 975 | +TRACE_DEFINE_ENUM(NFSERR_IO); | |
| 976 | +TRACE_DEFINE_ENUM(NFSERR_NXIO); | |
| 977 | +TRACE_DEFINE_ENUM(NFSERR_ACCES); | |
| 978 | +TRACE_DEFINE_ENUM(NFSERR_EXIST); | |
| 979 | +TRACE_DEFINE_ENUM(NFSERR_XDEV); | |
| 980 | +TRACE_DEFINE_ENUM(NFSERR_NODEV); | |
| 981 | +TRACE_DEFINE_ENUM(NFSERR_NOTDIR); | |
| 982 | +TRACE_DEFINE_ENUM(NFSERR_ISDIR); | |
| 983 | +TRACE_DEFINE_ENUM(NFSERR_INVAL); | |
| 984 | +TRACE_DEFINE_ENUM(NFSERR_FBIG); | |
| 985 | +TRACE_DEFINE_ENUM(NFSERR_NOSPC); | |
| 986 | +TRACE_DEFINE_ENUM(NFSERR_ROFS); | |
| 987 | +TRACE_DEFINE_ENUM(NFSERR_MLINK); | |
| 988 | +TRACE_DEFINE_ENUM(NFSERR_NAMETOOLONG); | |
| 989 | +TRACE_DEFINE_ENUM(NFSERR_NOTEMPTY); | |
| 990 | +TRACE_DEFINE_ENUM(NFSERR_DQUOT); | |
| 991 | +TRACE_DEFINE_ENUM(NFSERR_STALE); | |
| 992 | +TRACE_DEFINE_ENUM(NFSERR_REMOTE); | |
| 993 | +TRACE_DEFINE_ENUM(NFSERR_WFLUSH); | |
| 994 | +TRACE_DEFINE_ENUM(NFSERR_BADHANDLE); | |
| 995 | +TRACE_DEFINE_ENUM(NFSERR_NOT_SYNC); | |
| 996 | +TRACE_DEFINE_ENUM(NFSERR_BAD_COOKIE); | |
| 997 | +TRACE_DEFINE_ENUM(NFSERR_NOTSUPP); | |
| 998 | +TRACE_DEFINE_ENUM(NFSERR_TOOSMALL); | |
| 999 | +TRACE_DEFINE_ENUM(NFSERR_SERVERFAULT); | |
| 1000 | +TRACE_DEFINE_ENUM(NFSERR_BADTYPE); | |
| 1001 | +TRACE_DEFINE_ENUM(NFSERR_JUKEBOX); | |
| 1002 | + | |
| 1003 | +#define nfs_show_status(x) \ | |
| 1004 | + __print_symbolic(x, \ | |
| 1005 | + { NFS_OK, "OK" }, \ | |
| 1006 | + { NFSERR_PERM, "PERM" }, \ | |
| 1007 | + { NFSERR_NOENT, "NOENT" }, \ | |
| 1008 | + { NFSERR_IO, "IO" }, \ | |
| 1009 | + { NFSERR_NXIO, "NXIO" }, \ | |
| 1010 | + { NFSERR_ACCES, "ACCES" }, \ | |
| 1011 | + { NFSERR_EXIST, "EXIST" }, \ | |
| 1012 | + { NFSERR_XDEV, "XDEV" }, \ | |
| 1013 | + { NFSERR_NODEV, "NODEV" }, \ | |
| 1014 | + { NFSERR_NOTDIR, "NOTDIR" }, \ | |
| 1015 | + { NFSERR_ISDIR, "ISDIR" }, \ | |
| 1016 | + { NFSERR_INVAL, "INVAL" }, \ | |
| 1017 | + { NFSERR_FBIG, "FBIG" }, \ | |
| 1018 | + { NFSERR_NOSPC, "NOSPC" }, \ | |
| 1019 | + { NFSERR_ROFS, "ROFS" }, \ | |
| 1020 | + { NFSERR_MLINK, "MLINK" }, \ | |
| 1021 | + { NFSERR_NAMETOOLONG, "NAMETOOLONG" }, \ | |
| 1022 | + { NFSERR_NOTEMPTY, "NOTEMPTY" }, \ | |
| 1023 | + { NFSERR_DQUOT, "DQUOT" }, \ | |
| 1024 | + { NFSERR_STALE, "STALE" }, \ | |
| 1025 | + { NFSERR_REMOTE, "REMOTE" }, \ | |
| 1026 | + { NFSERR_WFLUSH, "WFLUSH" }, \ | |
| 1027 | + { NFSERR_BADHANDLE, "BADHANDLE" }, \ | |
| 1028 | + { NFSERR_NOT_SYNC, "NOTSYNC" }, \ | |
| 1029 | + { NFSERR_BAD_COOKIE, "BADCOOKIE" }, \ | |
| 1030 | + { NFSERR_NOTSUPP, "NOTSUPP" }, \ | |
| 1031 | + { NFSERR_TOOSMALL, "TOOSMALL" }, \ | |
| 1032 | + { NFSERR_SERVERFAULT, "REMOTEIO" }, \ | |
| 1033 | + { NFSERR_BADTYPE, "BADTYPE" }, \ | |
| 1034 | + { NFSERR_JUKEBOX, "JUKEBOX" }) | |
| 1035 | + | |
| 1036 | +TRACE_EVENT(nfs_xdr_status, | |
| 1037 | + TP_PROTO( | |
| 1038 | + int error | |
| 1039 | + ), | |
| 1040 | + | |
| 1041 | + TP_ARGS(error), | |
| 1042 | + | |
| 1043 | + TP_STRUCT__entry( | |
| 1044 | + __field(int, error) | |
| 1045 | + ), | |
| 1046 | + | |
| 1047 | + TP_fast_assign( | |
| 1048 | + __entry->error = error; | |
| 1049 | + ), | |
| 1050 | + | |
| 1051 | + TP_printk( | |
| 1052 | + "error=%d (%s)", | |
| 1053 | + __entry->error, nfs_show_status(__entry->error) | |
| 1054 | + ) | |
| 1055 | +); | |
| 1056 | + | |
| 972 | 1057 | #endif /* _TRACE_NFS_H */ |
| 973 | 1058 | |
| 974 | 1059 | #undef TRACE_INCLUDE_PATH |
| @@ -60,16 +60,6 @@ struct nfs4_cb_compound_hdr { · 59 unmodified lines | ||
| 60 | 60 | int status; |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | −/* | |
| 64 | − * Handle decode buffer overflows out-of-line. | |
| 65 | − */ | |
| 66 | −static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |
| 67 | −{ | |
| 68 | − dprintk("NFS: %s prematurely hit the end of our receive buffer. " | |
| 69 | − "Remaining buffer length is %tu words.\n", | |
| 70 | − func, xdr->end - xdr->p); | |
| 71 | −} | |
| 72 | − | |
| 73 | 63 | static __be32 *xdr_encode_empty_array(__be32 *p) |
| 74 | 64 | { |
| 75 | 65 | *p++ = xdr_zero; |
| @@ -240,7 +230,6 @@ static int decode_cb_op_status(struct xdr_stream *xdr, · 164 unmodified lines | ||
| 240 | 230 | *status = nfs_cb_stat_to_errno(be32_to_cpup(p)); |
| 241 | 231 | return 0; |
| 242 | 232 | out_overflow: |
| 243 | − print_overflow_msg(__func__, xdr); | |
| 244 | 233 | return -EIO; |
| 245 | 234 | out_unexpected: |
| 246 | 235 | dprintk("NFSD: Callback server returned operation %d but " |
| @@ -309,7 +298,6 @@ static int decode_cb_compound4res(struct xdr_stream *xdr, · 62 unmodified lines | ||
| 309 | 298 | hdr->nops = be32_to_cpup(p); |
| 310 | 299 | return 0; |
| 311 | 300 | out_overflow: |
| 312 | − print_overflow_msg(__func__, xdr); | |
| 313 | 301 | return -EIO; |
| 314 | 302 | } |
| 315 | 303 | |
| @@ -437,7 +425,6 @@ out: · 121 unmodified lines | ||
| 437 | 425 | cb->cb_seq_status = status; |
| 438 | 426 | return status; |
| 439 | 427 | out_overflow: |
| 440 | − print_overflow_msg(__func__, xdr); | |
| 441 | 428 | status = -EIO; |
| 442 | 429 | goto out; |
| 443 | 430 | } |
| @@ -74,14 +74,12 @@ struct rpc_cred_cache; · 73 unmodified lines | ||
| 74 | 74 | struct rpc_authops; |
| 75 | 75 | struct rpc_auth { |
| 76 | 76 | unsigned int au_cslack; /* call cred size estimate */ |
| 77 | − /* guess at number of u32's auth adds before | |
| 78 | − * reply data; normally the verifier size: */ | |
| 79 | − unsigned int au_rslack; | |
| 80 | − /* for gss, used to calculate au_rslack: */ | |
| 81 | − unsigned int au_verfsize; | |
| 82 | − | |
| 83 | − unsigned int au_flags; /* various flags */ | |
| 84 | − const struct rpc_authops *au_ops; /* operations */ | |
| 77 | + unsigned int au_rslack; /* reply cred size estimate */ | |
| 78 | + unsigned int au_verfsize; /* size of reply verifier */ | |
| 79 | + unsigned int au_ralign; /* words before UL header */ | |
| 80 | + | |
| 81 | + unsigned int au_flags; | |
| 82 | + const struct rpc_authops *au_ops; | |
| 85 | 83 | rpc_authflavor_t au_flavor; /* pseudoflavor (note may |
| 86 | 84 | * differ from the flavor in |
| 87 | 85 | * au_ops->au_flavor in gss |
| @@ -131,13 +129,15 @@ struct rpc_credops { · 43 unmodified lines | ||
| 131 | 129 | void (*crdestroy)(struct rpc_cred *); |
| 132 | 130 | |
| 133 | 131 | int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); |
| 134 | − __be32 * (*crmarshal)(struct rpc_task *, __be32 *); | |
| 132 | + int (*crmarshal)(struct rpc_task *task, | |
| 133 | + struct xdr_stream *xdr); | |
| 135 | 134 | int (*crrefresh)(struct rpc_task *); |
| 136 | − __be32 * (*crvalidate)(struct rpc_task *, __be32 *); | |
| 137 | − int (*crwrap_req)(struct rpc_task *, kxdreproc_t, | |
| 138 | − void *, __be32 *, void *); | |
| 139 | − int (*crunwrap_resp)(struct rpc_task *, kxdrdproc_t, | |
| 140 | − void *, __be32 *, void *); | |
| 135 | + int (*crvalidate)(struct rpc_task *task, | |
| 136 | + struct xdr_stream *xdr); | |
| 137 | + int (*crwrap_req)(struct rpc_task *task, | |
| 138 | + struct xdr_stream *xdr); | |
| 139 | + int (*crunwrap_resp)(struct rpc_task *task, | |
| 140 | + struct xdr_stream *xdr); | |
| 141 | 141 | int (*crkey_timeout)(struct rpc_cred *); |
| 142 | 142 | char * (*crstringify_acceptor)(struct rpc_cred *); |
| 143 | 143 | bool (*crneed_reencode)(struct rpc_task *); |
| @@ -165,10 +165,18 @@ struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred * · 21 unmodified lines | ||
| 165 | 165 | void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); |
| 166 | 166 | struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); |
| 167 | 167 | void put_rpccred(struct rpc_cred *); |
| 168 | −__be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); | |
| 169 | −__be32 * rpcauth_checkverf(struct rpc_task *, __be32 *); | |
| 170 | −int rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp, __be32 *data, void *obj); | |
| 171 | −int rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp, __be32 *data, void *obj); | |
| 168 | +int rpcauth_marshcred(struct rpc_task *task, | |
| 169 | + struct xdr_stream *xdr); | |
| 170 | +int rpcauth_checkverf(struct rpc_task *task, | |
| 171 | + struct xdr_stream *xdr); | |
| 172 | +int rpcauth_wrap_req_encode(struct rpc_task *task, | |
| 173 | + struct xdr_stream *xdr); | |
| 174 | +int rpcauth_wrap_req(struct rpc_task *task, | |
| 175 | + struct xdr_stream *xdr); | |
| 176 | +int rpcauth_unwrap_resp_decode(struct rpc_task *task, | |
| 177 | + struct xdr_stream *xdr); | |
| 178 | +int rpcauth_unwrap_resp(struct rpc_task *task, | |
| 179 | + struct xdr_stream *xdr); | |
| 172 | 180 | bool rpcauth_xmit_need_reencode(struct rpc_task *task); |
| 173 | 181 | int rpcauth_refreshcred(struct rpc_task *); |
| 174 | 182 | void rpcauth_invalcred(struct rpc_task *); |
| @@ -169,6 +169,9 @@ int rpcb_v4_register(struct net *net, const u32 program, · 168 unmodified lines | ||
| 169 | 169 | const char *netid); |
| 170 | 170 | void rpcb_getport_async(struct rpc_task *); |
| 171 | 171 | |
| 172 | +void rpc_prepare_reply_pages(struct rpc_rqst *req, struct page **pages, | |
| 173 | + unsigned int base, unsigned int len, | |
| 174 | + unsigned int hdrsize); | |
| 172 | 175 | void rpc_call_start(struct rpc_task *); |
| 173 | 176 | int rpc_call_async(struct rpc_clnt *clnt, |
| 174 | 177 | const struct rpc_message *msg, int flags, |
| @@ -1,4 +1,44 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ | |
| 1 | 2 | /* |
| 2 | − * Dumb way to share this static piece of information with nfsd | |
| 3 | + * Define the string that exports the set of kernel-supported | |
| 4 | + * Kerberos enctypes. This list is sent via upcall to gssd, and | |
| 5 | + * is also exposed via the nfsd /proc API. The consumers generally | |
| 6 | + * treat this as an ordered list, where the first item in the list | |
| 7 | + * is the most preferred. | |
| 8 | + */ | |
| 9 | + | |
| 10 | +#ifndef _LINUX_SUNRPC_GSS_KRB5_ENCTYPES_H | |
| 11 | +#define _LINUX_SUNRPC_GSS_KRB5_ENCTYPES_H | |
| 12 | + | |
| 13 | +#ifdef CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES | |
| 14 | + | |
| 15 | +/* | |
| 16 | + * NB: This list includes encryption types that were deprecated | |
| 17 | + * by RFC 8429 (DES3_CBC_SHA1 and ARCFOUR_HMAC). | |
| 18 | + * | |
| 19 | + * ENCTYPE_AES256_CTS_HMAC_SHA1_96 | |
| 20 | + * ENCTYPE_AES128_CTS_HMAC_SHA1_96 | |
| 21 | + * ENCTYPE_DES3_CBC_SHA1 | |
| 22 | + * ENCTYPE_ARCFOUR_HMAC | |
| 23 | + */ | |
| 24 | +#define KRB5_SUPPORTED_ENCTYPES "18,17,16,23" | |
| 25 | + | |
| 26 | +#else /* CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES */ | |
| 27 | + | |
| 28 | +/* | |
| 29 | + * NB: This list includes encryption types that were deprecated | |
| 30 | + * by RFC 8429 and RFC 6649. | |
| 31 | + * | |
| 32 | + * ENCTYPE_AES256_CTS_HMAC_SHA1_96 | |
| 33 | + * ENCTYPE_AES128_CTS_HMAC_SHA1_96 | |
| 34 | + * ENCTYPE_DES3_CBC_SHA1 | |
| 35 | + * ENCTYPE_ARCFOUR_HMAC | |
| 36 | + * ENCTYPE_DES_CBC_MD5 | |
| 37 | + * ENCTYPE_DES_CBC_CRC | |
| 38 | + * ENCTYPE_DES_CBC_MD4 | |
| 3 | 39 | */ |
| 4 | 40 | #define KRB5_SUPPORTED_ENCTYPES "18,17,16,23,3,1,2" |
| 41 | + | |
| 42 | +#endif /* CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES */ | |
| 43 | + | |
| 44 | +#endif /* _LINUX_SUNRPC_GSS_KRB5_ENCTYPES_H */ | |
| @@ -87,6 +87,16 @@ xdr_buf_init(struct xdr_buf *buf, void *start, size_t len) · 86 unmodified lines | ||
| 87 | 87 | #define xdr_one cpu_to_be32(1) |
| 88 | 88 | #define xdr_two cpu_to_be32(2) |
| 89 | 89 | |
| 90 | +#define rpc_auth_null cpu_to_be32(RPC_AUTH_NULL) | |
| 91 | +#define rpc_auth_unix cpu_to_be32(RPC_AUTH_UNIX) | |
| 92 | +#define rpc_auth_short cpu_to_be32(RPC_AUTH_SHORT) | |
| 93 | +#define rpc_auth_gss cpu_to_be32(RPC_AUTH_GSS) | |
| 94 | + | |
| 95 | +#define rpc_call cpu_to_be32(RPC_CALL) | |
| 96 | +#define rpc_reply cpu_to_be32(RPC_REPLY) | |
| 97 | + | |
| 98 | +#define rpc_msg_accepted cpu_to_be32(RPC_MSG_ACCEPTED) | |
| 99 | + | |
| 90 | 100 | #define rpc_success cpu_to_be32(RPC_SUCCESS) |
| 91 | 101 | #define rpc_prog_unavail cpu_to_be32(RPC_PROG_UNAVAIL) |
| 92 | 102 | #define rpc_prog_mismatch cpu_to_be32(RPC_PROG_MISMATCH) |
| @@ -95,6 +105,9 @@ xdr_buf_init(struct xdr_buf *buf, void *start, size_t len) · 2 unmodified lines | ||
| 95 | 105 | #define rpc_system_err cpu_to_be32(RPC_SYSTEM_ERR) |
| 96 | 106 | #define rpc_drop_reply cpu_to_be32(RPC_DROP_REPLY) |
| 97 | 107 | |
| 108 | +#define rpc_mismatch cpu_to_be32(RPC_MISMATCH) | |
| 109 | +#define rpc_auth_error cpu_to_be32(RPC_AUTH_ERROR) | |
| 110 | + | |
| 98 | 111 | #define rpc_auth_ok cpu_to_be32(RPC_AUTH_OK) |
| 99 | 112 | #define rpc_autherr_badcred cpu_to_be32(RPC_AUTH_BADCRED) |
| 100 | 113 | #define rpc_autherr_rejectedcred cpu_to_be32(RPC_AUTH_REJECTEDCRED) |
| @@ -103,7 +116,6 @@ xdr_buf_init(struct xdr_buf *buf, void *start, size_t len) · 2 unmodified lines | ||
| 103 | 116 | #define rpc_autherr_tooweak cpu_to_be32(RPC_AUTH_TOOWEAK) |
| 104 | 117 | #define rpcsec_gsserr_credproblem cpu_to_be32(RPCSEC_GSS_CREDPROBLEM) |
| 105 | 118 | #define rpcsec_gsserr_ctxproblem cpu_to_be32(RPCSEC_GSS_CTXPROBLEM) |
| 106 | −#define rpc_autherr_oldseqnum cpu_to_be32(101) | |
| 107 | 119 | |
| 108 | 120 | /* |
| 109 | 121 | * Miscellaneous XDR helper functions |
| @@ -167,7 +179,6 @@ xdr_adjust_iovec(struct kvec *iov, __be32 *p) · 57 unmodified lines | ||
| 167 | 179 | extern void xdr_shift_buf(struct xdr_buf *, size_t); |
| 168 | 180 | extern void xdr_buf_from_iov(struct kvec *, struct xdr_buf *); |
| 169 | 181 | extern int xdr_buf_subsegment(struct xdr_buf *, struct xdr_buf *, unsigned int, unsigned int); |
| 170 | −extern void xdr_buf_trim(struct xdr_buf *, unsigned int); | |
| 171 | 182 | extern int xdr_buf_read_netobj(struct xdr_buf *, struct xdr_netobj *, unsigned int); |
| 172 | 183 | extern int read_bytes_from_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int); |
| 173 | 184 | extern int write_bytes_to_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int); |
| @@ -217,6 +228,8 @@ struct xdr_stream { · 43 unmodified lines | ||
| 217 | 228 | struct kvec scratch; /* Scratch buffer */ |
| 218 | 229 | struct page **page_ptr; /* pointer to the current page */ |
| 219 | 230 | unsigned int nwords; /* Remaining decode buffer length */ |
| 231 | + | |
| 232 | + struct rpc_rqst *rqst; /* For debugging */ | |
| 220 | 233 | }; |
| 221 | 234 | |
| 222 | 235 | /* |
| @@ -227,7 +240,8 @@ typedef void (*kxdreproc_t)(struct rpc_rqst *rqstp, struct xdr_stream *xdr, · 4 unmodified lines | ||
| 227 | 240 | typedef int (*kxdrdproc_t)(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 228 | 241 | void *obj); |
| 229 | 242 | |
| 230 | −extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p); | |
| 243 | +extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, | |
| 244 | + __be32 *p, struct rpc_rqst *rqst); | |
| 231 | 245 | extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes); |
| 232 | 246 | extern void xdr_commit_encode(struct xdr_stream *xdr); |
| 233 | 247 | extern void xdr_truncate_encode(struct xdr_stream *xdr, size_t len); |
| @@ -235,7 +249,8 @@ extern int xdr_restrict_buflen(struct xdr_stream *xdr, int newbuflen); · 1 unmodified line | ||
| 235 | 249 | extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, |
| 236 | 250 | unsigned int base, unsigned int len); |
| 237 | 251 | extern unsigned int xdr_stream_pos(const struct xdr_stream *xdr); |
| 238 | −extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p); | |
| 252 | +extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, | |
| 253 | + __be32 *p, struct rpc_rqst *rqst); | |
| 239 | 254 | extern void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, |
| 240 | 255 | struct page **pages, unsigned int len); |
| 241 | 256 | extern void xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buflen); |
| @@ -196,8 +196,6 @@ struct rpc_xprt { · 195 unmodified lines | ||
| 196 | 196 | |
| 197 | 197 | size_t max_payload; /* largest RPC payload size, |
| 198 | 198 | in bytes */ |
| 199 | − unsigned int tsh_size; /* size of transport specific | |
| 200 | − header */ | |
| 201 | 199 | |
| 202 | 200 | struct rpc_wait_queue binding; /* requests waiting on rpcbind */ |
| 203 | 201 | struct rpc_wait_queue sending; /* requests waiting to send */ |
| @@ -362,11 +360,6 @@ struct rpc_xprt * xprt_alloc(struct net *net, size_t size, · 158 unmodified lines | ||
| 362 | 360 | unsigned int max_req); |
| 363 | 361 | void xprt_free(struct rpc_xprt *); |
| 364 | 362 | |
| 365 | −static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p) | |
| 366 | −{ | |
| 367 | − return p + xprt->tsh_size; | |
| 368 | −} | |
| 369 | − | |
| 370 | 363 | static inline int |
| 371 | 364 | xprt_enable_swap(struct rpc_xprt *xprt) |
| 372 | 365 | { |
| @@ -0,0 +1,361 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ | |
| 2 | +/* | |
| 3 | + * Copyright (c) 2018 Oracle. All rights reserved. | |
| 4 | + * | |
| 5 | + * Trace point definitions for the "rpcgss" subsystem. | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#undef TRACE_SYSTEM | |
| 9 | +#define TRACE_SYSTEM rpcgss | |
| 10 | + | |
| 11 | +#if !defined(_TRACE_RPCRDMA_H) || defined(TRACE_HEADER_MULTI_READ) | |
| 12 | +#define _TRACE_RPCGSS_H | |
| 13 | + | |
| 14 | +#include <linux/tracepoint.h> | |
| 15 | + | |
| 16 | +/** | |
| 17 | + ** GSS-API related trace events | |
| 18 | + **/ | |
| 19 | + | |
| 20 | +TRACE_DEFINE_ENUM(GSS_S_BAD_MECH); | |
| 21 | +TRACE_DEFINE_ENUM(GSS_S_BAD_NAME); | |
| 22 | +TRACE_DEFINE_ENUM(GSS_S_BAD_NAMETYPE); | |
| 23 | +TRACE_DEFINE_ENUM(GSS_S_BAD_BINDINGS); | |
| 24 | +TRACE_DEFINE_ENUM(GSS_S_BAD_STATUS); | |
| 25 | +TRACE_DEFINE_ENUM(GSS_S_BAD_SIG); | |
| 26 | +TRACE_DEFINE_ENUM(GSS_S_NO_CRED); | |
| 27 | +TRACE_DEFINE_ENUM(GSS_S_NO_CONTEXT); | |
| 28 | +TRACE_DEFINE_ENUM(GSS_S_DEFECTIVE_TOKEN); | |
| 29 | +TRACE_DEFINE_ENUM(GSS_S_DEFECTIVE_CREDENTIAL); | |
| 30 | +TRACE_DEFINE_ENUM(GSS_S_CREDENTIALS_EXPIRED); | |
| 31 | +TRACE_DEFINE_ENUM(GSS_S_CONTEXT_EXPIRED); | |
| 32 | +TRACE_DEFINE_ENUM(GSS_S_FAILURE); | |
| 33 | +TRACE_DEFINE_ENUM(GSS_S_BAD_QOP); | |
| 34 | +TRACE_DEFINE_ENUM(GSS_S_UNAUTHORIZED); | |
| 35 | +TRACE_DEFINE_ENUM(GSS_S_UNAVAILABLE); | |
| 36 | +TRACE_DEFINE_ENUM(GSS_S_DUPLICATE_ELEMENT); | |
| 37 | +TRACE_DEFINE_ENUM(GSS_S_NAME_NOT_MN); | |
| 38 | +TRACE_DEFINE_ENUM(GSS_S_CONTINUE_NEEDED); | |
| 39 | +TRACE_DEFINE_ENUM(GSS_S_DUPLICATE_TOKEN); | |
| 40 | +TRACE_DEFINE_ENUM(GSS_S_OLD_TOKEN); | |
| 41 | +TRACE_DEFINE_ENUM(GSS_S_UNSEQ_TOKEN); | |
| 42 | +TRACE_DEFINE_ENUM(GSS_S_GAP_TOKEN); | |
| 43 | + | |
| 44 | +#define show_gss_status(x) \ | |
| 45 | + __print_flags(x, "|", \ | |
| 46 | + { GSS_S_BAD_MECH, "GSS_S_BAD_MECH" }, \ | |
| 47 | + { GSS_S_BAD_NAME, "GSS_S_BAD_NAME" }, \ | |
| 48 | + { GSS_S_BAD_NAMETYPE, "GSS_S_BAD_NAMETYPE" }, \ | |
| 49 | + { GSS_S_BAD_BINDINGS, "GSS_S_BAD_BINDINGS" }, \ | |
| 50 | + { GSS_S_BAD_STATUS, "GSS_S_BAD_STATUS" }, \ | |
| 51 | + { GSS_S_BAD_SIG, "GSS_S_BAD_SIG" }, \ | |
| 52 | + { GSS_S_NO_CRED, "GSS_S_NO_CRED" }, \ | |
| 53 | + { GSS_S_NO_CONTEXT, "GSS_S_NO_CONTEXT" }, \ | |
| 54 | + { GSS_S_DEFECTIVE_TOKEN, "GSS_S_DEFECTIVE_TOKEN" }, \ | |
| 55 | + { GSS_S_DEFECTIVE_CREDENTIAL, "GSS_S_DEFECTIVE_CREDENTIAL" }, \ | |
| 56 | + { GSS_S_CREDENTIALS_EXPIRED, "GSS_S_CREDENTIALS_EXPIRED" }, \ | |
| 57 | + { GSS_S_CONTEXT_EXPIRED, "GSS_S_CONTEXT_EXPIRED" }, \ | |
| 58 | + { GSS_S_FAILURE, "GSS_S_FAILURE" }, \ | |
| 59 | + { GSS_S_BAD_QOP, "GSS_S_BAD_QOP" }, \ | |
| 60 | + { GSS_S_UNAUTHORIZED, "GSS_S_UNAUTHORIZED" }, \ | |
| 61 | + { GSS_S_UNAVAILABLE, "GSS_S_UNAVAILABLE" }, \ | |
| 62 | + { GSS_S_DUPLICATE_ELEMENT, "GSS_S_DUPLICATE_ELEMENT" }, \ | |
| 63 | + { GSS_S_NAME_NOT_MN, "GSS_S_NAME_NOT_MN" }, \ | |
| 64 | + { GSS_S_CONTINUE_NEEDED, "GSS_S_CONTINUE_NEEDED" }, \ | |
| 65 | + { GSS_S_DUPLICATE_TOKEN, "GSS_S_DUPLICATE_TOKEN" }, \ | |
| 66 | + { GSS_S_OLD_TOKEN, "GSS_S_OLD_TOKEN" }, \ | |
| 67 | + { GSS_S_UNSEQ_TOKEN, "GSS_S_UNSEQ_TOKEN" }, \ | |
| 68 | + { GSS_S_GAP_TOKEN, "GSS_S_GAP_TOKEN" }) | |
| 69 | + | |
| 70 | + | |
| 71 | +DECLARE_EVENT_CLASS(rpcgss_gssapi_event, | |
| 72 | + TP_PROTO( | |
| 73 | + const struct rpc_task *task, | |
| 74 | + u32 maj_stat | |
| 75 | + ), | |
| 76 | + | |
| 77 | + TP_ARGS(task, maj_stat), | |
| 78 | + | |
| 79 | + TP_STRUCT__entry( | |
| 80 | + __field(unsigned int, task_id) | |
| 81 | + __field(unsigned int, client_id) | |
| 82 | + __field(u32, maj_stat) | |
| 83 | + | |
| 84 | + ), | |
| 85 | + | |
| 86 | + TP_fast_assign( | |
| 87 | + __entry->task_id = task->tk_pid; | |
| 88 | + __entry->client_id = task->tk_client->cl_clid; | |
| 89 | + __entry->maj_stat = maj_stat; | |
| 90 | + ), | |
| 91 | + | |
| 92 | + TP_printk("task:%u@%u maj_stat=%s", | |
| 93 | + __entry->task_id, __entry->client_id, | |
| 94 | + __entry->maj_stat == 0 ? | |
| 95 | + "GSS_S_COMPLETE" : show_gss_status(__entry->maj_stat)) | |
| 96 | +); | |
| 97 | + | |
| 98 | +#define DEFINE_GSSAPI_EVENT(name) \ | |
| 99 | + DEFINE_EVENT(rpcgss_gssapi_event, rpcgss_##name, \ | |
| 100 | + TP_PROTO( \ | |
| 101 | + const struct rpc_task *task, \ | |
| 102 | + u32 maj_stat \ | |
| 103 | + ), \ | |
| 104 | + TP_ARGS(task, maj_stat)) | |
| 105 | + | |
| 106 | +TRACE_EVENT(rpcgss_import_ctx, | |
| 107 | + TP_PROTO( | |
| 108 | + int status | |
| 109 | + ), | |
| 110 | + | |
| 111 | + TP_ARGS(status), | |
| 112 | + | |
| 113 | + TP_STRUCT__entry( | |
| 114 | + __field(int, status) | |
| 115 | + ), | |
| 116 | + | |
| 117 | + TP_fast_assign( | |
| 118 | + __entry->status = status; | |
| 119 | + ), | |
| 120 | + | |
| 121 | + TP_printk("status=%d", __entry->status) | |
| 122 | +); | |
| 123 | + | |
| 124 | +DEFINE_GSSAPI_EVENT(get_mic); | |
| 125 | +DEFINE_GSSAPI_EVENT(verify_mic); | |
| 126 | +DEFINE_GSSAPI_EVENT(wrap); | |
| 127 | +DEFINE_GSSAPI_EVENT(unwrap); | |
| 128 | + | |
| 129 | + | |
| 130 | +/** | |
| 131 | + ** GSS auth unwrap failures | |
| 132 | + **/ | |
| 133 | + | |
| 134 | +TRACE_EVENT(rpcgss_unwrap_failed, | |
| 135 | + TP_PROTO( | |
| 136 | + const struct rpc_task *task | |
| 137 | + ), | |
| 138 | + | |
| 139 | + TP_ARGS(task), | |
| 140 | + | |
| 141 | + TP_STRUCT__entry( | |
| 142 | + __field(unsigned int, task_id) | |
| 143 | + __field(unsigned int, client_id) | |
| 144 | + ), | |
| 145 | + | |
| 146 | + TP_fast_assign( | |
| 147 | + __entry->task_id = task->tk_pid; | |
| 148 | + __entry->client_id = task->tk_client->cl_clid; | |
| 149 | + ), | |
| 150 | + | |
| 151 | + TP_printk("task:%u@%u", __entry->task_id, __entry->client_id) | |
| 152 | +); | |
| 153 | + | |
| 154 | +TRACE_EVENT(rpcgss_bad_seqno, | |
| 155 | + TP_PROTO( | |
| 156 | + const struct rpc_task *task, | |
| 157 | + u32 expected, | |
| 158 | + u32 received | |
| 159 | + ), | |
| 160 | + | |
| 161 | + TP_ARGS(task, expected, received), | |
| 162 | + | |
| 163 | + TP_STRUCT__entry( | |
| 164 | + __field(unsigned int, task_id) | |
| 165 | + __field(unsigned int, client_id) | |
| 166 | + __field(u32, expected) | |
| 167 | + __field(u32, received) | |
| 168 | + ), | |
| 169 | + | |
| 170 | + TP_fast_assign( | |
| 171 | + __entry->task_id = task->tk_pid; | |
| 172 | + __entry->client_id = task->tk_client->cl_clid; | |
| 173 | + __entry->expected = expected; | |
| 174 | + __entry->received = received; | |
| 175 | + ), | |
| 176 | + | |
| 177 | + TP_printk("task:%u@%u expected seqno %u, received seqno %u", | |
| 178 | + __entry->task_id, __entry->client_id, | |
| 179 | + __entry->expected, __entry->received) | |
| 180 | +); | |
| 181 | + | |
| 182 | +TRACE_EVENT(rpcgss_seqno, | |
| 183 | + TP_PROTO( | |
| 184 | + const struct rpc_task *task | |
| 185 | + ), | |
| 186 | + | |
| 187 | + TP_ARGS(task), | |
| 188 | + | |
| 189 | + TP_STRUCT__entry( | |
| 190 | + __field(unsigned int, task_id) | |
| 191 | + __field(unsigned int, client_id) | |
| 192 | + __field(u32, xid) | |
| 193 | + __field(u32, seqno) | |
| 194 | + ), | |
| 195 | + | |
| 196 | + TP_fast_assign( | |
| 197 | + const struct rpc_rqst *rqst = task->tk_rqstp; | |
| 198 | + | |
| 199 | + __entry->task_id = task->tk_pid; | |
| 200 | + __entry->client_id = task->tk_client->cl_clid; | |
| 201 | + __entry->xid = be32_to_cpu(rqst->rq_xid); | |
| 202 | + __entry->seqno = rqst->rq_seqno; | |
| 203 | + ), | |
| 204 | + | |
| 205 | + TP_printk("task:%u@%u xid=0x%08x seqno=%u", | |
| 206 | + __entry->task_id, __entry->client_id, | |
| 207 | + __entry->xid, __entry->seqno) | |
| 208 | +); | |
| 209 | + | |
| 210 | +TRACE_EVENT(rpcgss_need_reencode, | |
| 211 | + TP_PROTO( | |
| 212 | + const struct rpc_task *task, | |
| 213 | + u32 seq_xmit, | |
| 214 | + bool ret | |
| 215 | + ), | |
| 216 | + | |
| 217 | + TP_ARGS(task, seq_xmit, ret), | |
| 218 | + | |
| 219 | + TP_STRUCT__entry( | |
| 220 | + __field(unsigned int, task_id) | |
| 221 | + __field(unsigned int, client_id) | |
| 222 | + __field(u32, xid) | |
| 223 | + __field(u32, seq_xmit) | |
| 224 | + __field(u32, seqno) | |
| 225 | + __field(bool, ret) | |
| 226 | + ), | |
| 227 | + | |
| 228 | + TP_fast_assign( | |
| 229 | + __entry->task_id = task->tk_pid; | |
| 230 | + __entry->client_id = task->tk_client->cl_clid; | |
| 231 | + __entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid); | |
| 232 | + __entry->seq_xmit = seq_xmit; | |
| 233 | + __entry->seqno = task->tk_rqstp->rq_seqno; | |
| 234 | + __entry->ret = ret; | |
| 235 | + ), | |
| 236 | + | |
| 237 | + TP_printk("task:%u@%u xid=0x%08x rq_seqno=%u seq_xmit=%u reencode %sneeded", | |
| 238 | + __entry->task_id, __entry->client_id, | |
| 239 | + __entry->xid, __entry->seqno, __entry->seq_xmit, | |
| 240 | + __entry->ret ? "" : "un") | |
| 241 | +); | |
| 242 | + | |
| 243 | +/** | |
| 244 | + ** gssd upcall related trace events | |
| 245 | + **/ | |
| 246 | + | |
| 247 | +TRACE_EVENT(rpcgss_upcall_msg, | |
| 248 | + TP_PROTO( | |
| 249 | + const char *buf | |
| 250 | + ), | |
| 251 | + | |
| 252 | + TP_ARGS(buf), | |
| 253 | + | |
| 254 | + TP_STRUCT__entry( | |
| 255 | + __string(msg, buf) | |
| 256 | + ), | |
| 257 | + | |
| 258 | + TP_fast_assign( | |
| 259 | + __assign_str(msg, buf) | |
| 260 | + ), | |
| 261 | + | |
| 262 | + TP_printk("msg='%s'", __get_str(msg)) | |
| 263 | +); | |
| 264 | + | |
| 265 | +TRACE_EVENT(rpcgss_upcall_result, | |
| 266 | + TP_PROTO( | |
| 267 | + u32 uid, | |
| 268 | + int result | |
| 269 | + ), | |
| 270 | + | |
| 271 | + TP_ARGS(uid, result), | |
| 272 | + | |
| 273 | + TP_STRUCT__entry( | |
| 274 | + __field(u32, uid) | |
| 275 | + __field(int, result) | |
| 276 | + | |
| 277 | + ), | |
| 278 | + | |
| 279 | + TP_fast_assign( | |
| 280 | + __entry->uid = uid; | |
| 281 | + __entry->result = result; | |
| 282 | + ), | |
| 283 | + | |
| 284 | + TP_printk("for uid %u, result=%d", __entry->uid, __entry->result) | |
| 285 | +); | |
| 286 | + | |
| 287 | +TRACE_EVENT(rpcgss_context, | |
| 288 | + TP_PROTO( | |
| 289 | + unsigned long expiry, | |
| 290 | + unsigned long now, | |
| 291 | + unsigned int timeout, | |
| 292 | + unsigned int len, | |
| 293 | + const u8 *data | |
| 294 | + ), | |
| 295 | + | |
| 296 | + TP_ARGS(expiry, now, timeout, len, data), | |
| 297 | + | |
| 298 | + TP_STRUCT__entry( | |
| 299 | + __field(unsigned long, expiry) | |
| 300 | + __field(unsigned long, now) | |
| 301 | + __field(unsigned int, timeout) | |
| 302 | + __field(int, len) | |
| 303 | + __string(acceptor, data) | |
| 304 | + ), | |
| 305 | + | |
| 306 | + TP_fast_assign( | |
| 307 | + __entry->expiry = expiry; | |
| 308 | + __entry->now = now; | |
| 309 | + __entry->timeout = timeout; | |
| 310 | + __entry->len = len; | |
| 311 | + strncpy(__get_str(acceptor), data, len); | |
| 312 | + ), | |
| 313 | + | |
| 314 | + TP_printk("gc_expiry=%lu now=%lu timeout=%u acceptor=%.*s", | |
| 315 | + __entry->expiry, __entry->now, __entry->timeout, | |
| 316 | + __entry->len, __get_str(acceptor)) | |
| 317 | +); | |
| 318 | + | |
| 319 | + | |
| 320 | +/** | |
| 321 | + ** Miscellaneous events | |
| 322 | + */ | |
| 323 | + | |
| 324 | +TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5); | |
| 325 | +TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5I); | |
| 326 | +TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5P); | |
| 327 | + | |
| 328 | +#define show_pseudoflavor(x) \ | |
| 329 | + __print_symbolic(x, \ | |
| 330 | + { RPC_AUTH_GSS_KRB5, "RPC_AUTH_GSS_KRB5" }, \ | |
| 331 | + { RPC_AUTH_GSS_KRB5I, "RPC_AUTH_GSS_KRB5I" }, \ | |
| 332 | + { RPC_AUTH_GSS_KRB5P, "RPC_AUTH_GSS_KRB5P" }) | |
| 333 | + | |
| 334 | + | |
| 335 | +TRACE_EVENT(rpcgss_createauth, | |
| 336 | + TP_PROTO( | |
| 337 | + unsigned int flavor, | |
| 338 | + int error | |
| 339 | + ), | |
| 340 | + | |
| 341 | + TP_ARGS(flavor, error), | |
| 342 | + | |
| 343 | + TP_STRUCT__entry( | |
| 344 | + __field(unsigned int, flavor) | |
| 345 | + __field(int, error) | |
| 346 | + | |
| 347 | + ), | |
| 348 | + | |
| 349 | + TP_fast_assign( | |
| 350 | + __entry->flavor = flavor; | |
| 351 | + __entry->error = error; | |
| 352 | + ), | |
| 353 | + | |
| 354 | + TP_printk("flavor=%s error=%d", | |
| 355 | + show_pseudoflavor(__entry->flavor), __entry->error) | |
| 356 | +); | |
| 357 | + | |
| 358 | + | |
| 359 | +#endif /* _TRACE_RPCGSS_H */ | |
| 360 | + | |
| 361 | +#include <trace/define_trace.h> | |
| @@ -521,12 +521,18 @@ TRACE_EVENT(xprtrdma_post_send, · 520 unmodified lines | ||
| 521 | 521 | |
| 522 | 522 | TP_STRUCT__entry( |
| 523 | 523 | __field(const void *, req) |
| 524 | + __field(unsigned int, task_id) | |
| 525 | + __field(unsigned int, client_id) | |
| 524 | 526 | __field(int, num_sge) |
| 525 | 527 | __field(int, signaled) |
| 526 | 528 | __field(int, status) |
| 527 | 529 | ), |
| 528 | 530 | |
| 529 | 531 | TP_fast_assign( |
| 532 | + const struct rpc_rqst *rqst = &req->rl_slot; | |
| 533 | + | |
| 534 | + __entry->task_id = rqst->rq_task->tk_pid; | |
| 535 | + __entry->client_id = rqst->rq_task->tk_client->cl_clid; | |
| 530 | 536 | __entry->req = req; |
| 531 | 537 | __entry->num_sge = req->rl_sendctx->sc_wr.num_sge; |
| 532 | 538 | __entry->signaled = req->rl_sendctx->sc_wr.send_flags & |
| @@ -534,9 +540,11 @@ TRACE_EVENT(xprtrdma_post_send, · 1 unmodified line | ||
| 534 | 540 | __entry->status = status; |
| 535 | 541 | ), |
| 536 | 542 | |
| 537 | − TP_printk("req=%p, %d SGEs%s, status=%d", | |
| 543 | + TP_printk("task:%u@%u req=%p (%d SGE%s) %sstatus=%d", | |
| 544 | + __entry->task_id, __entry->client_id, | |
| 538 | 545 | __entry->req, __entry->num_sge, |
| 539 | − (__entry->signaled ? ", signaled" : ""), | |
| 546 | + (__entry->num_sge == 1 ? "" : "s"), | |
| 547 | + (__entry->signaled ? "signaled " : ""), | |
| 540 | 548 | __entry->status |
| 541 | 549 | ) |
| 542 | 550 | ); |
| @@ -77,6 +77,50 @@ TRACE_EVENT(rpc_request, · 76 unmodified lines | ||
| 77 | 77 | ) |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | +TRACE_DEFINE_ENUM(RPC_TASK_ASYNC); | |
| 81 | +TRACE_DEFINE_ENUM(RPC_TASK_SWAPPER); | |
| 82 | +TRACE_DEFINE_ENUM(RPC_CALL_MAJORSEEN); | |
| 83 | +TRACE_DEFINE_ENUM(RPC_TASK_ROOTCREDS); | |
| 84 | +TRACE_DEFINE_ENUM(RPC_TASK_DYNAMIC); | |
| 85 | +TRACE_DEFINE_ENUM(RPC_TASK_KILLED); | |
| 86 | +TRACE_DEFINE_ENUM(RPC_TASK_SOFT); | |
| 87 | +TRACE_DEFINE_ENUM(RPC_TASK_SOFTCONN); | |
| 88 | +TRACE_DEFINE_ENUM(RPC_TASK_SENT); | |
| 89 | +TRACE_DEFINE_ENUM(RPC_TASK_TIMEOUT); | |
| 90 | +TRACE_DEFINE_ENUM(RPC_TASK_NOCONNECT); | |
| 91 | +TRACE_DEFINE_ENUM(RPC_TASK_NO_RETRANS_TIMEOUT); | |
| 92 | + | |
| 93 | +#define rpc_show_task_flags(flags) \ | |
| 94 | + __print_flags(flags, "|", \ | |
| 95 | + { RPC_TASK_ASYNC, "ASYNC" }, \ | |
| 96 | + { RPC_TASK_SWAPPER, "SWAPPER" }, \ | |
| 97 | + { RPC_CALL_MAJORSEEN, "MAJORSEEN" }, \ | |
| 98 | + { RPC_TASK_ROOTCREDS, "ROOTCREDS" }, \ | |
| 99 | + { RPC_TASK_DYNAMIC, "DYNAMIC" }, \ | |
| 100 | + { RPC_TASK_KILLED, "KILLED" }, \ | |
| 101 | + { RPC_TASK_SOFT, "SOFT" }, \ | |
| 102 | + { RPC_TASK_SOFTCONN, "SOFTCONN" }, \ | |
| 103 | + { RPC_TASK_SENT, "SENT" }, \ | |
| 104 | + { RPC_TASK_TIMEOUT, "TIMEOUT" }, \ | |
| 105 | + { RPC_TASK_NOCONNECT, "NOCONNECT" }, \ | |
| 106 | + { RPC_TASK_NO_RETRANS_TIMEOUT, "NORTO" }) | |
| 107 | + | |
| 108 | +TRACE_DEFINE_ENUM(RPC_TASK_RUNNING); | |
| 109 | +TRACE_DEFINE_ENUM(RPC_TASK_QUEUED); | |
| 110 | +TRACE_DEFINE_ENUM(RPC_TASK_ACTIVE); | |
| 111 | +TRACE_DEFINE_ENUM(RPC_TASK_NEED_XMIT); | |
| 112 | +TRACE_DEFINE_ENUM(RPC_TASK_NEED_RECV); | |
| 113 | +TRACE_DEFINE_ENUM(RPC_TASK_MSG_PIN_WAIT); | |
| 114 | + | |
| 115 | +#define rpc_show_runstate(flags) \ | |
| 116 | + __print_flags(flags, "|", \ | |
| 117 | + { (1UL << RPC_TASK_RUNNING), "RUNNING" }, \ | |
| 118 | + { (1UL << RPC_TASK_QUEUED), "QUEUED" }, \ | |
| 119 | + { (1UL << RPC_TASK_ACTIVE), "ACTIVE" }, \ | |
| 120 | + { (1UL << RPC_TASK_NEED_XMIT), "NEED_XMIT" }, \ | |
| 121 | + { (1UL << RPC_TASK_NEED_RECV), "NEED_RECV" }, \ | |
| 122 | + { (1UL << RPC_TASK_MSG_PIN_WAIT), "MSG_PIN_WAIT" }) | |
| 123 | + | |
| 80 | 124 | DECLARE_EVENT_CLASS(rpc_task_running, |
| 81 | 125 | |
| 82 | 126 | TP_PROTO(const struct rpc_task *task, const void *action), |
| @@ -102,10 +146,10 @@ DECLARE_EVENT_CLASS(rpc_task_running, · 19 unmodified lines | ||
| 102 | 146 | __entry->flags = task->tk_flags; |
| 103 | 147 | ), |
| 104 | 148 | |
| 105 | − TP_printk("task:%u@%d flags=%4.4x state=%4.4lx status=%d action=%pf", | |
| 149 | + TP_printk("task:%u@%d flags=%s runstate=%s status=%d action=%pf", | |
| 106 | 150 | __entry->task_id, __entry->client_id, |
| 107 | − __entry->flags, | |
| 108 | − __entry->runstate, | |
| 151 | + rpc_show_task_flags(__entry->flags), | |
| 152 | + rpc_show_runstate(__entry->runstate), | |
| 109 | 153 | __entry->status, |
| 110 | 154 | __entry->action |
| 111 | 155 | ) |
| @@ -149,10 +193,10 @@ DECLARE_EVENT_CLASS(rpc_task_queued, · 37 unmodified lines | ||
| 149 | 193 | __assign_str(q_name, rpc_qname(q)); |
| 150 | 194 | ), |
| 151 | 195 | |
| 152 | − TP_printk("task:%u@%d flags=%4.4x state=%4.4lx status=%d timeout=%lu queue=%s", | |
| 196 | + TP_printk("task:%u@%d flags=%s runstate=%s status=%d timeout=%lu queue=%s", | |
| 153 | 197 | __entry->task_id, __entry->client_id, |
| 154 | − __entry->flags, | |
| 155 | − __entry->runstate, | |
| 198 | + rpc_show_task_flags(__entry->flags), | |
| 199 | + rpc_show_runstate(__entry->runstate), | |
| 156 | 200 | __entry->status, |
| 157 | 201 | __entry->timeout, |
| 158 | 202 | __get_str(q_name) |
| @@ -169,6 +213,87 @@ DECLARE_EVENT_CLASS(rpc_task_queued, · 10 unmodified lines | ||
| 169 | 213 | DEFINE_RPC_QUEUED_EVENT(sleep); |
| 170 | 214 | DEFINE_RPC_QUEUED_EVENT(wakeup); |
| 171 | 215 | |
| 216 | +DECLARE_EVENT_CLASS(rpc_failure, | |
| 217 | + | |
| 218 | + TP_PROTO(const struct rpc_task *task), | |
| 219 | + | |
| 220 | + TP_ARGS(task), | |
| 221 | + | |
| 222 | + TP_STRUCT__entry( | |
| 223 | + __field(unsigned int, task_id) | |
| 224 | + __field(unsigned int, client_id) | |
| 225 | + ), | |
| 226 | + | |
| 227 | + TP_fast_assign( | |
| 228 | + __entry->task_id = task->tk_pid; | |
| 229 | + __entry->client_id = task->tk_client->cl_clid; | |
| 230 | + ), | |
| 231 | + | |
| 232 | + TP_printk("task:%u@%u", | |
| 233 | + __entry->task_id, __entry->client_id) | |
| 234 | +); | |
| 235 | + | |
| 236 | +#define DEFINE_RPC_FAILURE(name) \ | |
| 237 | + DEFINE_EVENT(rpc_failure, rpc_bad_##name, \ | |
| 238 | + TP_PROTO( \ | |
| 239 | + const struct rpc_task *task \ | |
| 240 | + ), \ | |
| 241 | + TP_ARGS(task)) | |
| 242 | + | |
| 243 | +DEFINE_RPC_FAILURE(callhdr); | |
| 244 | +DEFINE_RPC_FAILURE(verifier); | |
| 245 | + | |
| 246 | +DECLARE_EVENT_CLASS(rpc_reply_event, | |
| 247 | + | |
| 248 | + TP_PROTO( | |
| 249 | + const struct rpc_task *task | |
| 250 | + ), | |
| 251 | + | |
| 252 | + TP_ARGS(task), | |
| 253 | + | |
| 254 | + TP_STRUCT__entry( | |
| 255 | + __field(unsigned int, task_id) | |
| 256 | + __field(unsigned int, client_id) | |
| 257 | + __field(u32, xid) | |
| 258 | + __string(progname, task->tk_client->cl_program->name) | |
| 259 | + __field(u32, version) | |
| 260 | + __string(procname, rpc_proc_name(task)) | |
| 261 | + __string(servername, task->tk_xprt->servername) | |
| 262 | + ), | |
| 263 | + | |
| 264 | + TP_fast_assign( | |
| 265 | + __entry->task_id = task->tk_pid; | |
| 266 | + __entry->client_id = task->tk_client->cl_clid; | |
| 267 | + __entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid); | |
| 268 | + __assign_str(progname, task->tk_client->cl_program->name) | |
| 269 | + __entry->version = task->tk_client->cl_vers; | |
| 270 | + __assign_str(procname, rpc_proc_name(task)) | |
| 271 | + __assign_str(servername, task->tk_xprt->servername) | |
| 272 | + ), | |
| 273 | + | |
| 274 | + TP_printk("task:%u@%d server=%s xid=0x%08x %sv%d %s", | |
| 275 | + __entry->task_id, __entry->client_id, __get_str(servername), | |
| 276 | + __entry->xid, __get_str(progname), __entry->version, | |
| 277 | + __get_str(procname)) | |
| 278 | +) | |
| 279 | + | |
| 280 | +#define DEFINE_RPC_REPLY_EVENT(name) \ | |
| 281 | + DEFINE_EVENT(rpc_reply_event, rpc__##name, \ | |
| 282 | + TP_PROTO( \ | |
| 283 | + const struct rpc_task *task \ | |
| 284 | + ), \ | |
| 285 | + TP_ARGS(task)) | |
| 286 | + | |
| 287 | +DEFINE_RPC_REPLY_EVENT(prog_unavail); | |
| 288 | +DEFINE_RPC_REPLY_EVENT(prog_mismatch); | |
| 289 | +DEFINE_RPC_REPLY_EVENT(proc_unavail); | |
| 290 | +DEFINE_RPC_REPLY_EVENT(garbage_args); | |
| 291 | +DEFINE_RPC_REPLY_EVENT(unparsable); | |
| 292 | +DEFINE_RPC_REPLY_EVENT(mismatch); | |
| 293 | +DEFINE_RPC_REPLY_EVENT(stale_creds); | |
| 294 | +DEFINE_RPC_REPLY_EVENT(bad_creds); | |
| 295 | +DEFINE_RPC_REPLY_EVENT(auth_tooweak); | |
| 296 | + | |
| 172 | 297 | TRACE_EVENT(rpc_stats_latency, |
| 173 | 298 | |
| 174 | 299 | TP_PROTO( |
| @@ -210,6 +335,169 @@ TRACE_EVENT(rpc_stats_latency, · 35 unmodified lines | ||
| 210 | 335 | __entry->backlog, __entry->rtt, __entry->execute) |
| 211 | 336 | ); |
| 212 | 337 | |
| 338 | +TRACE_EVENT(rpc_xdr_overflow, | |
| 339 | + TP_PROTO( | |
| 340 | + const struct xdr_stream *xdr, | |
| 341 | + size_t requested | |
| 342 | + ), | |
| 343 | + | |
| 344 | + TP_ARGS(xdr, requested), | |
| 345 | + | |
| 346 | + TP_STRUCT__entry( | |
| 347 | + __field(unsigned int, task_id) | |
| 348 | + __field(unsigned int, client_id) | |
| 349 | + __field(int, version) | |
| 350 | + __field(size_t, requested) | |
| 351 | + __field(const void *, end) | |
| 352 | + __field(const void *, p) | |
| 353 | + __field(const void *, head_base) | |
| 354 | + __field(size_t, head_len) | |
| 355 | + __field(const void *, tail_base) | |
| 356 | + __field(size_t, tail_len) | |
| 357 | + __field(unsigned int, page_len) | |
| 358 | + __field(unsigned int, len) | |
| 359 | + __string(progname, | |
| 360 | + xdr->rqst->rq_task->tk_client->cl_program->name) | |
| 361 | + __string(procedure, | |
| 362 | + xdr->rqst->rq_task->tk_msg.rpc_proc->p_name) | |
| 363 | + ), | |
| 364 | + | |
| 365 | + TP_fast_assign( | |
| 366 | + if (xdr->rqst) { | |
| 367 | + const struct rpc_task *task = xdr->rqst->rq_task; | |
| 368 | + | |
| 369 | + __entry->task_id = task->tk_pid; | |
| 370 | + __entry->client_id = task->tk_client->cl_clid; | |
| 371 | + __assign_str(progname, | |
| 372 | + task->tk_client->cl_program->name) | |
| 373 | + __entry->version = task->tk_client->cl_vers; | |
| 374 | + __assign_str(procedure, task->tk_msg.rpc_proc->p_name) | |
| 375 | + } else { | |
| 376 | + __entry->task_id = 0; | |
| 377 | + __entry->client_id = 0; | |
| 378 | + __assign_str(progname, "unknown") | |
| 379 | + __entry->version = 0; | |
| 380 | + __assign_str(procedure, "unknown") | |
| 381 | + } | |
| 382 | + __entry->requested = requested; | |
| 383 | + __entry->end = xdr->end; | |
| 384 | + __entry->p = xdr->p; | |
| 385 | + __entry->head_base = xdr->buf->head[0].iov_base, | |
| 386 | + __entry->head_len = xdr->buf->head[0].iov_len, | |
| 387 | + __entry->page_len = xdr->buf->page_len, | |
| 388 | + __entry->tail_base = xdr->buf->tail[0].iov_base, | |
| 389 | + __entry->tail_len = xdr->buf->tail[0].iov_len, | |
| 390 | + __entry->len = xdr->buf->len; | |
| 391 | + ), | |
| 392 | + | |
| 393 | + TP_printk( | |
| 394 | + "task:%u@%u %sv%d %s requested=%zu p=%p end=%p xdr=[%p,%zu]/%u/[%p,%zu]/%u\n", | |
| 395 | + __entry->task_id, __entry->client_id, | |
| 396 | + __get_str(progname), __entry->version, __get_str(procedure), | |
| 397 | + __entry->requested, __entry->p, __entry->end, | |
| 398 | + __entry->head_base, __entry->head_len, | |
| 399 | + __entry->page_len, | |
| 400 | + __entry->tail_base, __entry->tail_len, | |
| 401 | + __entry->len | |
| 402 | + ) | |
| 403 | +); | |
| 404 | + | |
| 405 | +TRACE_EVENT(rpc_xdr_alignment, | |
| 406 | + TP_PROTO( | |
| 407 | + const struct xdr_stream *xdr, | |
| 408 | + size_t offset, | |
| 409 | + unsigned int copied | |
| 410 | + ), | |
| 411 | + | |
| 412 | + TP_ARGS(xdr, offset, copied), | |
| 413 | + | |
| 414 | + TP_STRUCT__entry( | |
| 415 | + __field(unsigned int, task_id) | |
| 416 | + __field(unsigned int, client_id) | |
| 417 | + __field(int, version) | |
| 418 | + __field(size_t, offset) | |
| 419 | + __field(unsigned int, copied) | |
| 420 | + __field(const void *, head_base) | |
| 421 | + __field(size_t, head_len) | |
| 422 | + __field(const void *, tail_base) | |
| 423 | + __field(size_t, tail_len) | |
| 424 | + __field(unsigned int, page_len) | |
| 425 | + __field(unsigned int, len) | |
| 426 | + __string(progname, | |
| 427 | + xdr->rqst->rq_task->tk_client->cl_program->name) | |
| 428 | + __string(procedure, | |
| 429 | + xdr->rqst->rq_task->tk_msg.rpc_proc->p_name) | |
| 430 | + ), | |
| 431 | + | |
| 432 | + TP_fast_assign( | |
| 433 | + const struct rpc_task *task = xdr->rqst->rq_task; | |
| 434 | + | |
| 435 | + __entry->task_id = task->tk_pid; | |
| 436 | + __entry->client_id = task->tk_client->cl_clid; | |
| 437 | + __assign_str(progname, | |
| 438 | + task->tk_client->cl_program->name) | |
| 439 | + __entry->version = task->tk_client->cl_vers; | |
| 440 | + __assign_str(procedure, task->tk_msg.rpc_proc->p_name) | |
| 441 | + | |
| 442 | + __entry->offset = offset; | |
| 443 | + __entry->copied = copied; | |
| 444 | + __entry->head_base = xdr->buf->head[0].iov_base, | |
| 445 | + __entry->head_len = xdr->buf->head[0].iov_len, | |
| 446 | + __entry->page_len = xdr->buf->page_len, | |
| 447 | + __entry->tail_base = xdr->buf->tail[0].iov_base, | |
| 448 | + __entry->tail_len = xdr->buf->tail[0].iov_len, | |
| 449 | + __entry->len = xdr->buf->len; | |
| 450 | + ), | |
| 451 | + | |
| 452 | + TP_printk( | |
| 453 | + "task:%u@%u %sv%d %s offset=%zu copied=%u xdr=[%p,%zu]/%u/[%p,%zu]/%u\n", | |
| 454 | + __entry->task_id, __entry->client_id, | |
| 455 | + __get_str(progname), __entry->version, __get_str(procedure), | |
| 456 | + __entry->offset, __entry->copied, | |
| 457 | + __entry->head_base, __entry->head_len, | |
| 458 | + __entry->page_len, | |
| 459 | + __entry->tail_base, __entry->tail_len, | |
| 460 | + __entry->len | |
| 461 | + ) | |
| 462 | +); | |
| 463 | + | |
| 464 | +TRACE_EVENT(rpc_reply_pages, | |
| 465 | + TP_PROTO( | |
| 466 | + const struct rpc_rqst *req | |
| 467 | + ), | |
| 468 | + | |
| 469 | + TP_ARGS(req), | |
| 470 | + | |
| 471 | + TP_STRUCT__entry( | |
| 472 | + __field(unsigned int, task_id) | |
| 473 | + __field(unsigned int, client_id) | |
| 474 | + __field(const void *, head_base) | |
| 475 | + __field(size_t, head_len) | |
| 476 | + __field(const void *, tail_base) | |
| 477 | + __field(size_t, tail_len) | |
| 478 | + __field(unsigned int, page_len) | |
| 479 | + ), | |
| 480 | + | |
| 481 | + TP_fast_assign( | |
| 482 | + __entry->task_id = req->rq_task->tk_pid; | |
| 483 | + __entry->client_id = req->rq_task->tk_client->cl_clid; | |
| 484 | + | |
| 485 | + __entry->head_base = req->rq_rcv_buf.head[0].iov_base; | |
| 486 | + __entry->head_len = req->rq_rcv_buf.head[0].iov_len; | |
| 487 | + __entry->page_len = req->rq_rcv_buf.page_len; | |
| 488 | + __entry->tail_base = req->rq_rcv_buf.tail[0].iov_base; | |
| 489 | + __entry->tail_len = req->rq_rcv_buf.tail[0].iov_len; | |
| 490 | + ), | |
| 491 | + | |
| 492 | + TP_printk( | |
| 493 | + "task:%u@%u xdr=[%p,%zu]/%u/[%p,%zu]\n", | |
| 494 | + __entry->task_id, __entry->client_id, | |
| 495 | + __entry->head_base, __entry->head_len, | |
| 496 | + __entry->page_len, | |
| 497 | + __entry->tail_base, __entry->tail_len | |
| 498 | + ) | |
| 499 | +); | |
| 500 | + | |
| 213 | 501 | /* |
| 214 | 502 | * First define the enums in the below macros to be exported to userspace |
| 215 | 503 | * via TRACE_DEFINE_ENUM(). |
| @@ -404,9 +692,68 @@ DECLARE_EVENT_CLASS(rpc_xprt_event, · 188 unmodified lines | ||
| 404 | 692 | |
| 405 | 693 | DEFINE_RPC_XPRT_EVENT(timer); |
| 406 | 694 | DEFINE_RPC_XPRT_EVENT(lookup_rqst); |
| 407 | −DEFINE_RPC_XPRT_EVENT(transmit); | |
| 408 | 695 | DEFINE_RPC_XPRT_EVENT(complete_rqst); |
| 409 | 696 | |
| 697 | +TRACE_EVENT(xprt_transmit, | |
| 698 | + TP_PROTO( | |
| 699 | + const struct rpc_rqst *rqst, | |
| 700 | + int status | |
| 701 | + ), | |
| 702 | + | |
| 703 | + TP_ARGS(rqst, status), | |
| 704 | + | |
| 705 | + TP_STRUCT__entry( | |
| 706 | + __field(unsigned int, task_id) | |
| 707 | + __field(unsigned int, client_id) | |
| 708 | + __field(u32, xid) | |
| 709 | + __field(u32, seqno) | |
| 710 | + __field(int, status) | |
| 711 | + ), | |
| 712 | + | |
| 713 | + TP_fast_assign( | |
| 714 | + __entry->task_id = rqst->rq_task->tk_pid; | |
| 715 | + __entry->client_id = rqst->rq_task->tk_client->cl_clid; | |
| 716 | + __entry->xid = be32_to_cpu(rqst->rq_xid); | |
| 717 | + __entry->seqno = rqst->rq_seqno; | |
| 718 | + __entry->status = status; | |
| 719 | + ), | |
| 720 | + | |
| 721 | + TP_printk( | |
| 722 | + "task:%u@%u xid=0x%08x seqno=%u status=%d", | |
| 723 | + __entry->task_id, __entry->client_id, __entry->xid, | |
| 724 | + __entry->seqno, __entry->status) | |
| 725 | +); | |
| 726 | + | |
| 727 | +TRACE_EVENT(xprt_enq_xmit, | |
| 728 | + TP_PROTO( | |
| 729 | + const struct rpc_task *task, | |
| 730 | + int stage | |
| 731 | + ), | |
| 732 | + | |
| 733 | + TP_ARGS(task, stage), | |
| 734 | + | |
| 735 | + TP_STRUCT__entry( | |
| 736 | + __field(unsigned int, task_id) | |
| 737 | + __field(unsigned int, client_id) | |
| 738 | + __field(u32, xid) | |
| 739 | + __field(u32, seqno) | |
| 740 | + __field(int, stage) | |
| 741 | + ), | |
| 742 | + | |
| 743 | + TP_fast_assign( | |
| 744 | + __entry->task_id = task->tk_pid; | |
| 745 | + __entry->client_id = task->tk_client->cl_clid; | |
| 746 | + __entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid); | |
| 747 | + __entry->seqno = task->tk_rqstp->rq_seqno; | |
| 748 | + __entry->stage = stage; | |
| 749 | + ), | |
| 750 | + | |
| 751 | + TP_printk( | |
| 752 | + "task:%u@%u xid=0x%08x seqno=%u stage=%d", | |
| 753 | + __entry->task_id, __entry->client_id, __entry->xid, | |
| 754 | + __entry->seqno, __entry->stage) | |
| 755 | +); | |
| 756 | + | |
| 410 | 757 | TRACE_EVENT(xprt_ping, |
| 411 | 758 | TP_PROTO(const struct rpc_xprt *xprt, int status), |
| 412 | 759 | |
| @@ -34,6 +34,22 @@ config RPCSEC_GSS_KRB5 · 33 unmodified lines | ||
| 34 | 34 | |
| 35 | 35 | If unsure, say Y. |
| 36 | 36 | |
| 37 | +config CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES | |
| 38 | + bool "Secure RPC: Disable insecure Kerberos encryption types" | |
| 39 | + depends on RPCSEC_GSS_KRB5 | |
| 40 | + default n | |
| 41 | + help | |
| 42 | + Choose Y here to disable the use of deprecated encryption types | |
| 43 | + with the Kerberos version 5 GSS-API mechanism (RFC 1964). The | |
| 44 | + deprecated encryption types include DES-CBC-MD5, DES-CBC-CRC, | |
| 45 | + and DES-CBC-MD4. These types were deprecated by RFC 6649 because | |
| 46 | + they were found to be insecure. | |
| 47 | + | |
| 48 | + N is the default because many sites have deployed KDCs and | |
| 49 | + keytabs that contain only these deprecated encryption types. | |
| 50 | + Choosing Y prevents the use of known-insecure encryption types | |
| 51 | + but might result in compatibility problems. | |
| 52 | + | |
| 37 | 53 | config SUNRPC_DEBUG |
| 38 | 54 | bool "RPC: Enable dprintk debugging" |
| 39 | 55 | depends on SUNRPC && SYSCTL |
| @@ -17,9 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <linux/sunrpc/gss_api.h> |
| 18 | 18 | #include <linux/spinlock.h> |
| 19 | 19 | |
| 20 | −#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) | |
| 21 | −# define RPCDBG_FACILITY RPCDBG_AUTH | |
| 22 | −#endif | |
| 20 | +#include <trace/events/sunrpc.h> | |
| 23 | 21 | |
| 24 | 22 | #define RPC_CREDCACHE_DEFAULT_HASHBITS (4) |
| 25 | 23 | struct rpc_cred_cache { |
| @@ -267,8 +265,6 @@ rpcauth_list_flavors(rpc_authflavor_t *array, int size) · 241 unmodified lines | ||
| 267 | 265 | } |
| 268 | 266 | } |
| 269 | 267 | rcu_read_unlock(); |
| 270 | − | |
| 271 | − dprintk("RPC: %s returns %d\n", __func__, result); | |
| 272 | 268 | return result; |
| 273 | 269 | } |
| 274 | 270 | EXPORT_SYMBOL_GPL(rpcauth_list_flavors); |
| @@ -636,9 +632,6 @@ rpcauth_lookupcred(struct rpc_auth *auth, int flags) · 361 unmodified lines | ||
| 636 | 632 | struct rpc_cred *ret; |
| 637 | 633 | const struct cred *cred = current_cred(); |
| 638 | 634 | |
| 639 | − dprintk("RPC: looking up %s cred\n", | |
| 640 | − auth->au_ops->au_name); | |
| 641 | − | |
| 642 | 635 | memset(&acred, 0, sizeof(acred)); |
| 643 | 636 | acred.cred = cred; |
| 644 | 637 | ret = auth->au_ops->lookup_cred(auth, &acred, flags); |
| @@ -670,8 +663,6 @@ rpcauth_bind_root_cred(struct rpc_task *task, int lookupflags) · 25 unmodified lines | ||
| 670 | 663 | }; |
| 671 | 664 | struct rpc_cred *ret; |
| 672 | 665 | |
| 673 | − dprintk("RPC: %5u looking up %s cred\n", | |
| 674 | − task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); | |
| 675 | 666 | ret = auth->au_ops->lookup_cred(auth, &acred, lookupflags); |
| 676 | 667 | put_cred(acred.cred); |
| 677 | 668 | return ret; |
| @@ -688,8 +679,6 @@ rpcauth_bind_machine_cred(struct rpc_task *task, int lookupflags) · 10 unmodified lines | ||
| 688 | 679 | |
| 689 | 680 | if (!acred.principal) |
| 690 | 681 | return NULL; |
| 691 | − dprintk("RPC: %5u looking up %s machine cred\n", | |
| 692 | − task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); | |
| 693 | 682 | return auth->au_ops->lookup_cred(auth, &acred, lookupflags); |
| 694 | 683 | } |
| 695 | 684 | |
| @@ -698,8 +687,6 @@ rpcauth_bind_new_cred(struct rpc_task *task, int lookupflags) · 2 unmodified lines | ||
| 698 | 687 | { |
| 699 | 688 | struct rpc_auth *auth = task->tk_client->cl_auth; |
| 700 | 689 | |
| 701 | − dprintk("RPC: %5u looking up %s cred\n", | |
| 702 | − task->tk_pid, auth->au_ops->au_name); | |
| 703 | 690 | return rpcauth_lookupcred(auth, lookupflags); |
| 704 | 691 | } |
| 705 | 692 | |
| @@ -771,75 +758,102 @@ destroy: · 65 unmodified lines | ||
| 771 | 758 | } |
| 772 | 759 | EXPORT_SYMBOL_GPL(put_rpccred); |
| 773 | 760 | |
| 774 | −__be32 * | |
| 775 | −rpcauth_marshcred(struct rpc_task *task, __be32 *p) | |
| 761 | +/** | |
| 762 | + * rpcauth_marshcred - Append RPC credential to end of @xdr | |
| 763 | + * @task: controlling RPC task | |
| 764 | + * @xdr: xdr_stream containing initial portion of RPC Call header | |
| 765 | + * | |
| 766 | + * On success, an appropriate verifier is added to @xdr, @xdr is | |
| 767 | + * updated to point past the verifier, and zero is returned. | |
| 768 | + * Otherwise, @xdr is in an undefined state and a negative errno | |
| 769 | + * is returned. | |
| 770 | + */ | |
| 771 | +int rpcauth_marshcred(struct rpc_task *task, struct xdr_stream *xdr) | |
| 776 | 772 | { |
| 777 | − struct rpc_cred *cred = task->tk_rqstp->rq_cred; | |
| 773 | + const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; | |
| 778 | 774 | |
| 779 | − dprintk("RPC: %5u marshaling %s cred %p\n", | |
| 780 | − task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | |
| 781 | − | |
| 782 | − return cred->cr_ops->crmarshal(task, p); | |
| 775 | + return ops->crmarshal(task, xdr); | |
| 783 | 776 | } |
| 784 | 777 | |
| 785 | −__be32 * | |
| 786 | −rpcauth_checkverf(struct rpc_task *task, __be32 *p) | |
| 778 | +/** | |
| 779 | + * rpcauth_wrap_req_encode - XDR encode the RPC procedure | |
| 780 | + * @task: controlling RPC task | |
| 781 | + * @xdr: stream where on-the-wire bytes are to be marshalled | |
| 782 | + * | |
| 783 | + * On success, @xdr contains the encoded and wrapped message. | |
| 784 | + * Otherwise, @xdr is in an undefined state. | |
| 785 | + */ | |
| 786 | +int rpcauth_wrap_req_encode(struct rpc_task *task, struct xdr_stream *xdr) | |
| 787 | 787 | { |
| 788 | − struct rpc_cred *cred = task->tk_rqstp->rq_cred; | |
| 788 | + kxdreproc_t encode = task->tk_msg.rpc_proc->p_encode; | |
| 789 | 789 | |
| 790 | − dprintk("RPC: %5u validating %s cred %p\n", | |
| 791 | − task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | |
| 792 | − | |
| 793 | − return cred->cr_ops->crvalidate(task, p); | |
| 790 | + encode(task->tk_rqstp, xdr, task->tk_msg.rpc_argp); | |
| 791 | + return 0; | |
| 794 | 792 | } |
| 793 | +EXPORT_SYMBOL_GPL(rpcauth_wrap_req_encode); | |
| 795 | 794 | |
| 796 | −static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, | |
| 797 | − __be32 *data, void *obj) | |
| 795 | +/** | |
| 796 | + * rpcauth_wrap_req - XDR encode and wrap the RPC procedure | |
| 797 | + * @task: controlling RPC task | |
| 798 | + * @xdr: stream where on-the-wire bytes are to be marshalled | |
| 799 | + * | |
| 800 | + * On success, @xdr contains the encoded and wrapped message, | |
| 801 | + * and zero is returned. Otherwise, @xdr is in an undefined | |
| 802 | + * state and a negative errno is returned. | |
| 803 | + */ | |
| 804 | +int rpcauth_wrap_req(struct rpc_task *task, struct xdr_stream *xdr) | |
| 798 | 805 | { |
| 799 | − struct xdr_stream xdr; | |
| 806 | + const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; | |
| 800 | 807 | |
| 801 | − xdr_init_encode(&xdr, &rqstp->rq_snd_buf, data); | |
| 802 | − encode(rqstp, &xdr, obj); | |
| 808 | + return ops->crwrap_req(task, xdr); | |
| 803 | 809 | } |
| 804 | 810 | |
| 811 | +/** | |
| 812 | + * rpcauth_checkverf - Validate verifier in RPC Reply header | |
| 813 | + * @task: controlling RPC task | |
| 814 | + * @xdr: xdr_stream containing RPC Reply header | |
| 815 | + * | |
| 816 | + * On success, @xdr is updated to point past the verifier and | |
| 817 | + * zero is returned. Otherwise, @xdr is in an undefined state | |
| 818 | + * and a negative errno is returned. | |
| 819 | + */ | |
| 805 | 820 | int |
| 806 | −rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp, | |
| 807 | − __be32 *data, void *obj) | |
| 821 | +rpcauth_checkverf(struct rpc_task *task, struct xdr_stream *xdr) | |
| 808 | 822 | { |
| 809 | − struct rpc_cred *cred = task->tk_rqstp->rq_cred; | |
| 823 | + const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; | |
| 810 | 824 | |
| 811 | − dprintk("RPC: %5u using %s cred %p to wrap rpc data\n", | |
| 812 | − task->tk_pid, cred->cr_ops->cr_name, cred); | |
| 813 | − if (cred->cr_ops->crwrap_req) | |
| 814 | − return cred->cr_ops->crwrap_req(task, encode, rqstp, data, obj); | |
| 815 | − /* By default, we encode the arguments normally. */ | |
| 816 | − rpcauth_wrap_req_encode(encode, rqstp, data, obj); | |
| 817 | − return 0; | |
| 825 | + return ops->crvalidate(task, xdr); | |
| 818 | 826 | } |
| 819 | 827 | |
| 820 | −static int | |
| 821 | −rpcauth_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp, | |
| 822 | − __be32 *data, void *obj) | |
| 828 | +/** | |
| 829 | + * rpcauth_unwrap_resp_decode - Invoke XDR decode function | |
| 830 | + * @task: controlling RPC task | |
| 831 | + * @xdr: stream where the Reply message resides | |
| 832 | + * | |
| 833 | + * Returns zero on success; otherwise a negative errno is returned. | |
| 834 | + */ | |
| 835 | +int | |
| 836 | +rpcauth_unwrap_resp_decode(struct rpc_task *task, struct xdr_stream *xdr) | |
| 823 | 837 | { |
| 824 | − struct xdr_stream xdr; | |
| 838 | + kxdrdproc_t decode = task->tk_msg.rpc_proc->p_decode; | |
| 825 | 839 | |
| 826 | − xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, data); | |
| 827 | − return decode(rqstp, &xdr, obj); | |
| 840 | + return decode(task->tk_rqstp, xdr, task->tk_msg.rpc_resp); | |
| 828 | 841 | } |
| 842 | +EXPORT_SYMBOL_GPL(rpcauth_unwrap_resp_decode); | |
| 829 | 843 | |
| 844 | +/** | |
| 845 | + * rpcauth_unwrap_resp - Invoke unwrap and decode function for the cred | |
| 846 | + * @task: controlling RPC task | |
| 847 | + * @xdr: stream where the Reply message resides | |
| 848 | + * | |
| 849 | + * Returns zero on success; otherwise a negative errno is returned. | |
| 850 | + */ | |
| 830 | 851 | int |
| 831 | −rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp, | |
| 832 | − __be32 *data, void *obj) | |
| 852 | +rpcauth_unwrap_resp(struct rpc_task *task, struct xdr_stream *xdr) | |
| 833 | 853 | { |
| 834 | − struct rpc_cred *cred = task->tk_rqstp->rq_cred; | |
| 854 | + const struct rpc_credops *ops = task->tk_rqstp->rq_cred->cr_ops; | |
| 835 | 855 | |
| 836 | − dprintk("RPC: %5u using %s cred %p to unwrap rpc data\n", | |
| 837 | − task->tk_pid, cred->cr_ops->cr_name, cred); | |
| 838 | − if (cred->cr_ops->crunwrap_resp) | |
| 839 | − return cred->cr_ops->crunwrap_resp(task, decode, rqstp, | |
| 840 | − data, obj); | |
| 841 | − /* By default, we decode the arguments normally. */ | |
| 842 | − return rpcauth_unwrap_req_decode(decode, rqstp, data, obj); | |
| 856 | + return ops->crunwrap_resp(task, xdr); | |
| 843 | 857 | } |
| 844 | 858 | |
| 845 | 859 | bool |
| @@ -865,8 +879,6 @@ rpcauth_refreshcred(struct rpc_task *task) · 19 unmodified lines | ||
| 865 | 879 | goto out; |
| 866 | 880 | cred = task->tk_rqstp->rq_cred; |
| 867 | 881 | } |
| 868 | − dprintk("RPC: %5u refreshing %s cred %p\n", | |
| 869 | − task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | |
| 870 | 882 | |
| 871 | 883 | err = cred->cr_ops->crrefresh(task); |
| 872 | 884 | out: |
| @@ -880,8 +892,6 @@ rpcauth_invalcred(struct rpc_task *task) · 7 unmodified lines | ||
| 880 | 892 | { |
| 881 | 893 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
| 882 | 894 | |
| 883 | − dprintk("RPC: %5u invalidating %s cred %p\n", | |
| 884 | − task->tk_pid, cred->cr_auth->au_ops->au_name, cred); | |
| 885 | 895 | if (cred) |
| 886 | 896 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 887 | 897 | } |
| @@ -7,7 +7,7 @@ obj-$(CONFIG_SUNRPC_GSS) += auth_rpcgss.o · 6 unmodified lines | ||
| 7 | 7 | |
| 8 | 8 | auth_rpcgss-y := auth_gss.o gss_generic_token.o \ |
| 9 | 9 | gss_mech_switch.o svcauth_gss.o \ |
| 10 | − gss_rpc_upcall.o gss_rpc_xdr.o | |
| 10 | + gss_rpc_upcall.o gss_rpc_xdr.o trace.o | |
| 11 | 11 | |
| 12 | 12 | obj-$(CONFIG_RPCSEC_GSS_KRB5) += rpcsec_gss_krb5.o |
| 13 | 13 | |
| @@ -1,3 +1,4 @@ | ||
| 1 | +// SPDX-License-Identifier: BSD-3-Clause | |
| 1 | 2 | /* |
| 2 | 3 | * linux/net/sunrpc/auth_gss/auth_gss.c |
| 3 | 4 | * |
| @@ -8,34 +9,8 @@ · 4 unmodified lines | ||
| 8 | 9 | * |
| 9 | 10 | * Dug Song <dugsong@monkey.org> |
| 10 | 11 | * Andy Adamson <andros@umich.edu> |
| 11 | − * | |
| 12 | − * Redistribution and use in source and binary forms, with or without | |
| 13 | − * modification, are permitted provided that the following conditions | |
| 14 | − * are met: | |
| 15 | − * | |
| 16 | − * 1. Redistributions of source code must retain the above copyright | |
| 17 | − * notice, this list of conditions and the following disclaimer. | |
| 18 | − * 2. Redistributions in binary form must reproduce the above copyright | |
| 19 | − * notice, this list of conditions and the following disclaimer in the | |
| 20 | − * documentation and/or other materials provided with the distribution. | |
| 21 | − * 3. Neither the name of the University nor the names of its | |
| 22 | − * contributors may be used to endorse or promote products derived | |
| 23 | − * from this software without specific prior written permission. | |
| 24 | − * | |
| 25 | − * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
| 26 | − * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 27 | − * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 28 | − * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
| 29 | − * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 30 | − * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 31 | − * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
| 32 | − * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 33 | − * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 34 | − * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 35 | − * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 36 | 12 | */ |
| 37 | 13 | |
| 38 | − | |
| 39 | 14 | #include <linux/module.h> |
| 40 | 15 | #include <linux/init.h> |
| 41 | 16 | #include <linux/types.h> |
| @@ -55,6 +30,8 @@ · 13 unmodified lines | ||
| 55 | 30 | |
| 56 | 31 | #include "../netns.h" |
| 57 | 32 | |
| 33 | +#include <trace/events/rpcgss.h> | |
| 34 | + | |
| 58 | 35 | static const struct rpc_authops authgss_ops; |
| 59 | 36 | |
| 60 | 37 | static const struct rpc_credops gss_credops; |
| @@ -260,6 +237,7 @@ gss_fill_context(const void *p, const void *end, struct gss_cl_ctx *ctx, struct · 199 unmodified lines | ||
| 260 | 237 | } |
| 261 | 238 | ret = gss_import_sec_context(p, seclen, gm, &ctx->gc_gss_ctx, NULL, GFP_NOFS); |
| 262 | 239 | if (ret < 0) { |
| 240 | + trace_rpcgss_import_ctx(ret); | |
| 263 | 241 | p = ERR_PTR(ret); |
| 264 | 242 | goto err; |
| 265 | 243 | } |
| @@ -275,12 +253,9 @@ gss_fill_context(const void *p, const void *end, struct gss_cl_ctx *ctx, struct · 9 unmodified lines | ||
| 275 | 253 | if (IS_ERR(p)) |
| 276 | 254 | goto err; |
| 277 | 255 | done: |
| 278 | − dprintk("RPC: %s Success. gc_expiry %lu now %lu timeout %u acceptor %.*s\n", | |
| 279 | − __func__, ctx->gc_expiry, now, timeout, ctx->gc_acceptor.len, | |
| 280 | − ctx->gc_acceptor.data); | |
| 281 | − return p; | |
| 256 | + trace_rpcgss_context(ctx->gc_expiry, now, timeout, | |
| 257 | + ctx->gc_acceptor.len, ctx->gc_acceptor.data); | |
| 282 | 258 | err: |
| 283 | − dprintk("RPC: %s returns error %ld\n", __func__, -PTR_ERR(p)); | |
| 284 | 259 | return p; |
| 285 | 260 | } |
| 286 | 261 | |
| @@ -354,10 +329,8 @@ __gss_find_upcall(struct rpc_pipe *pipe, kuid_t uid, const struct gss_auth *auth · 67 unmodified lines | ||
| 354 | 329 | if (auth && pos->auth->service != auth->service) |
| 355 | 330 | continue; |
| 356 | 331 | refcount_inc(&pos->count); |
| 357 | − dprintk("RPC: %s found msg %p\n", __func__, pos); | |
| 358 | 332 | return pos; |
| 359 | 333 | } |
| 360 | − dprintk("RPC: %s found nothing\n", __func__); | |
| 361 | 334 | return NULL; |
| 362 | 335 | } |
| 363 | 336 | |
| @@ -456,7 +429,7 @@ static int gss_encode_v1_msg(struct gss_upcall_msg *gss_msg, · 92 unmodified lines | ||
| 456 | 429 | size_t buflen = sizeof(gss_msg->databuf); |
| 457 | 430 | int len; |
| 458 | 431 | |
| 459 | − len = scnprintf(p, buflen, "mech=%s uid=%d ", mech->gm_name, | |
| 432 | + len = scnprintf(p, buflen, "mech=%s uid=%d", mech->gm_name, | |
| 460 | 433 | from_kuid(&init_user_ns, gss_msg->uid)); |
| 461 | 434 | buflen -= len; |
| 462 | 435 | p += len; |
| @@ -467,7 +440,7 @@ static int gss_encode_v1_msg(struct gss_upcall_msg *gss_msg, · 4 unmodified lines | ||
| 467 | 440 | * identity that we are authenticating to. |
| 468 | 441 | */ |
| 469 | 442 | if (target_name) { |
| 470 | − len = scnprintf(p, buflen, "target=%s ", target_name); | |
| 443 | + len = scnprintf(p, buflen, " target=%s", target_name); | |
| 471 | 444 | buflen -= len; |
| 472 | 445 | p += len; |
| 473 | 446 | gss_msg->msg.len += len; |
| @@ -487,11 +460,11 @@ static int gss_encode_v1_msg(struct gss_upcall_msg *gss_msg, · 13 unmodified lines | ||
| 487 | 460 | char *c = strchr(service_name, '@'); |
| 488 | 461 | |
| 489 | 462 | if (!c) |
| 490 | − len = scnprintf(p, buflen, "service=%s ", | |
| 463 | + len = scnprintf(p, buflen, " service=%s", | |
| 491 | 464 | service_name); |
| 492 | 465 | else |
| 493 | 466 | len = scnprintf(p, buflen, |
| 494 | − "service=%.*s srchost=%s ", | |
| 467 | + " service=%.*s srchost=%s", | |
| 495 | 468 | (int)(c - service_name), |
| 496 | 469 | service_name, c + 1); |
| 497 | 470 | buflen -= len; |
| @@ -500,17 +473,17 @@ static int gss_encode_v1_msg(struct gss_upcall_msg *gss_msg, · 2 unmodified lines | ||
| 500 | 473 | } |
| 501 | 474 | |
| 502 | 475 | if (mech->gm_upcall_enctypes) { |
| 503 | − len = scnprintf(p, buflen, "enctypes=%s ", | |
| 476 | + len = scnprintf(p, buflen, " enctypes=%s", | |
| 504 | 477 | mech->gm_upcall_enctypes); |
| 505 | 478 | buflen -= len; |
| 506 | 479 | p += len; |
| 507 | 480 | gss_msg->msg.len += len; |
| 508 | 481 | } |
| 482 | + trace_rpcgss_upcall_msg(gss_msg->databuf); | |
| 509 | 483 | len = scnprintf(p, buflen, "\n"); |
| 510 | 484 | if (len == 0) |
| 511 | 485 | goto out_overflow; |
| 512 | 486 | gss_msg->msg.len += len; |
| 513 | − | |
| 514 | 487 | gss_msg->msg.data = gss_msg->databuf; |
| 515 | 488 | return 0; |
| 516 | 489 | out_overflow: |
| @@ -603,8 +576,6 @@ gss_refresh_upcall(struct rpc_task *task) · 86 unmodified lines | ||
| 603 | 576 | struct rpc_pipe *pipe; |
| 604 | 577 | int err = 0; |
| 605 | 578 | |
| 606 | − dprintk("RPC: %5u %s for uid %u\n", | |
| 607 | − task->tk_pid, __func__, from_kuid(&init_user_ns, cred->cr_cred->fsuid)); | |
| 608 | 579 | gss_msg = gss_setup_upcall(gss_auth, cred); |
| 609 | 580 | if (PTR_ERR(gss_msg) == -EAGAIN) { |
| 610 | 581 | /* XXX: warning on the first, under the assumption we |
| @@ -612,7 +583,8 @@ gss_refresh_upcall(struct rpc_task *task) · 1 unmodified line | ||
| 612 | 583 | warn_gssd(); |
| 613 | 584 | task->tk_timeout = 15*HZ; |
| 614 | 585 | rpc_sleep_on(&pipe_version_rpc_waitqueue, task, NULL); |
| 615 | − return -EAGAIN; | |
| 586 | + err = -EAGAIN; | |
| 587 | + goto out; | |
| 616 | 588 | } |
| 617 | 589 | if (IS_ERR(gss_msg)) { |
| 618 | 590 | err = PTR_ERR(gss_msg); |
| @@ -635,9 +607,8 @@ gss_refresh_upcall(struct rpc_task *task) · 16 unmodified lines | ||
| 635 | 607 | spin_unlock(&pipe->lock); |
| 636 | 608 | gss_release_msg(gss_msg); |
| 637 | 609 | out: |
| 638 | − dprintk("RPC: %5u %s for uid %u result %d\n", | |
| 639 | − task->tk_pid, __func__, | |
| 640 | − from_kuid(&init_user_ns, cred->cr_cred->fsuid), err); | |
| 610 | + trace_rpcgss_upcall_result(from_kuid(&init_user_ns, | |
| 611 | + cred->cr_cred->fsuid), err); | |
| 641 | 612 | return err; |
| 642 | 613 | } |
| 643 | 614 | |
| @@ -652,14 +623,13 @@ gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred) · 8 unmodified lines | ||
| 652 | 623 | DEFINE_WAIT(wait); |
| 653 | 624 | int err; |
| 654 | 625 | |
| 655 | − dprintk("RPC: %s for uid %u\n", | |
| 656 | − __func__, from_kuid(&init_user_ns, cred->cr_cred->fsuid)); | |
| 657 | 626 | retry: |
| 658 | 627 | err = 0; |
| 659 | 628 | /* if gssd is down, just skip upcalling altogether */ |
| 660 | 629 | if (!gssd_running(net)) { |
| 661 | 630 | warn_gssd(); |
| 662 | − return -EACCES; | |
| 631 | + err = -EACCES; | |
| 632 | + goto out; | |
| 663 | 633 | } |
| 664 | 634 | gss_msg = gss_setup_upcall(gss_auth, cred); |
| 665 | 635 | if (PTR_ERR(gss_msg) == -EAGAIN) { |
| @@ -700,8 +670,8 @@ out_intr: · 34 unmodified lines | ||
| 700 | 670 | finish_wait(&gss_msg->waitqueue, &wait); |
| 701 | 671 | gss_release_msg(gss_msg); |
| 702 | 672 | out: |
| 703 | − dprintk("RPC: %s for uid %u result %d\n", | |
| 704 | − __func__, from_kuid(&init_user_ns, cred->cr_cred->fsuid), err); | |
| 673 | + trace_rpcgss_upcall_result(from_kuid(&init_user_ns, | |
| 674 | + cred->cr_cred->fsuid), err); | |
| 705 | 675 | return err; |
| 706 | 676 | } |
| 707 | 677 | |
| @@ -794,7 +764,6 @@ err_put_ctx: · 86 unmodified lines | ||
| 794 | 764 | err: |
| 795 | 765 | kfree(buf); |
| 796 | 766 | out: |
| 797 | − dprintk("RPC: %s returning %zd\n", __func__, err); | |
| 798 | 767 | return err; |
| 799 | 768 | } |
| 800 | 769 | |
| @@ -863,8 +832,6 @@ gss_pipe_destroy_msg(struct rpc_pipe_msg *msg) · 62 unmodified lines | ||
| 863 | 832 | struct gss_upcall_msg *gss_msg = container_of(msg, struct gss_upcall_msg, msg); |
| 864 | 833 | |
| 865 | 834 | if (msg->errno < 0) { |
| 866 | − dprintk("RPC: %s releasing msg %p\n", | |
| 867 | − __func__, gss_msg); | |
| 868 | 835 | refcount_inc(&gss_msg->count); |
| 869 | 836 | gss_unhash_msg(gss_msg); |
| 870 | 837 | if (msg->errno == -ETIMEDOUT) |
| @@ -1024,8 +991,6 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) · 153 unmodified lines | ||
| 1024 | 991 | struct rpc_auth * auth; |
| 1025 | 992 | int err = -ENOMEM; /* XXX? */ |
| 1026 | 993 | |
| 1027 | − dprintk("RPC: creating GSS authenticator for client %p\n", clnt); | |
| 1028 | − | |
| 1029 | 994 | if (!try_module_get(THIS_MODULE)) |
| 1030 | 995 | return ERR_PTR(err); |
| 1031 | 996 | if (!(gss_auth = kmalloc(sizeof(*gss_auth), GFP_KERNEL))) |
| @@ -1041,10 +1006,8 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) · 9 unmodified lines | ||
| 1041 | 1006 | gss_auth->net = get_net(rpc_net_ns(clnt)); |
| 1042 | 1007 | err = -EINVAL; |
| 1043 | 1008 | gss_auth->mech = gss_mech_get_by_pseudoflavor(flavor); |
| 1044 | − if (!gss_auth->mech) { | |
| 1045 | − dprintk("RPC: Pseudoflavor %d not found!\n", flavor); | |
| 1009 | + if (!gss_auth->mech) | |
| 1046 | 1010 | goto err_put_net; |
| 1047 | − } | |
| 1048 | 1011 | gss_auth->service = gss_pseudoflavor_to_service(gss_auth->mech, flavor); |
| 1049 | 1012 | if (gss_auth->service == 0) |
| 1050 | 1013 | goto err_put_mech; |
| @@ -1053,6 +1016,8 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) · 2 unmodified lines | ||
| 1053 | 1016 | auth = &gss_auth->rpc_auth; |
| 1054 | 1017 | auth->au_cslack = GSS_CRED_SLACK >> 2; |
| 1055 | 1018 | auth->au_rslack = GSS_VERF_SLACK >> 2; |
| 1019 | + auth->au_verfsize = GSS_VERF_SLACK >> 2; | |
| 1020 | + auth->au_ralign = GSS_VERF_SLACK >> 2; | |
| 1056 | 1021 | auth->au_flags = 0; |
| 1057 | 1022 | auth->au_ops = &authgss_ops; |
| 1058 | 1023 | auth->au_flavor = flavor; |
| @@ -1099,6 +1064,7 @@ err_free: · 40 unmodified lines | ||
| 1099 | 1064 | kfree(gss_auth); |
| 1100 | 1065 | out_dec: |
| 1101 | 1066 | module_put(THIS_MODULE); |
| 1067 | + trace_rpcgss_createauth(flavor, err); | |
| 1102 | 1068 | return ERR_PTR(err); |
| 1103 | 1069 | } |
| 1104 | 1070 | |
| @@ -1135,9 +1101,6 @@ gss_destroy(struct rpc_auth *auth) · 30 unmodified lines | ||
| 1135 | 1101 | struct gss_auth *gss_auth = container_of(auth, |
| 1136 | 1102 | struct gss_auth, rpc_auth); |
| 1137 | 1103 | |
| 1138 | − dprintk("RPC: destroying GSS authenticator %p flavor %d\n", | |
| 1139 | − auth, auth->au_flavor); | |
| 1140 | − | |
| 1141 | 1104 | if (hash_hashed(&gss_auth->hash)) { |
| 1142 | 1105 | spin_lock(&gss_auth_hash_lock); |
| 1143 | 1106 | hash_del(&gss_auth->hash); |
| @@ -1300,8 +1263,6 @@ gss_send_destroy_context(struct rpc_cred *cred) · 156 unmodified lines | ||
| 1300 | 1263 | static void |
| 1301 | 1264 | gss_do_free_ctx(struct gss_cl_ctx *ctx) |
| 1302 | 1265 | { |
| 1303 | − dprintk("RPC: %s\n", __func__); | |
| 1304 | − | |
| 1305 | 1266 | gss_delete_sec_context(&ctx->gc_gss_ctx); |
| 1306 | 1267 | kfree(ctx->gc_wire_ctx.data); |
| 1307 | 1268 | kfree(ctx->gc_acceptor.data); |
| @@ -1324,7 +1285,6 @@ gss_free_ctx(struct gss_cl_ctx *ctx) · 16 unmodified lines | ||
| 1324 | 1285 | static void |
| 1325 | 1286 | gss_free_cred(struct gss_cred *gss_cred) |
| 1326 | 1287 | { |
| 1327 | − dprintk("RPC: %s cred=%p\n", __func__, gss_cred); | |
| 1328 | 1288 | kfree(gss_cred); |
| 1329 | 1289 | } |
| 1330 | 1290 | |
| @@ -1381,10 +1341,6 @@ gss_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t · 50 unmodified lines | ||
| 1381 | 1341 | struct gss_cred *cred = NULL; |
| 1382 | 1342 | int err = -ENOMEM; |
| 1383 | 1343 | |
| 1384 | − dprintk("RPC: %s for uid %d, flavor %d\n", | |
| 1385 | − __func__, from_kuid(&init_user_ns, acred->cred->fsuid), | |
| 1386 | − auth->au_flavor); | |
| 1387 | − | |
| 1388 | 1344 | if (!(cred = kzalloc(sizeof(*cred), gfp))) |
| 1389 | 1345 | goto out_err; |
| 1390 | 1346 | |
| @@ -1400,7 +1356,6 @@ gss_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t · 9 unmodified lines | ||
| 1400 | 1356 | return &cred->gc_base; |
| 1401 | 1357 | |
| 1402 | 1358 | out_err: |
| 1403 | − dprintk("RPC: %s failed with error %d\n", __func__, err); | |
| 1404 | 1359 | return ERR_PTR(err); |
| 1405 | 1360 | } |
| 1406 | 1361 | |
| @@ -1526,69 +1481,84 @@ out: · 119 unmodified lines | ||
| 1526 | 1481 | } |
| 1527 | 1482 | |
| 1528 | 1483 | /* |
| 1529 | −* Marshal credentials. | |
| 1530 | −* Maybe we should keep a cached credential for performance reasons. | |
| 1531 | −*/ | |
| 1532 | −static __be32 * | |
| 1533 | −gss_marshal(struct rpc_task *task, __be32 *p) | |
| 1484 | + * Marshal credentials. | |
| 1485 | + * | |
| 1486 | + * The expensive part is computing the verifier. We can't cache a | |
| 1487 | + * pre-computed version of the verifier because the seqno, which | |
| 1488 | + * is different every time, is included in the MIC. | |
| 1489 | + */ | |
| 1490 | +static int gss_marshal(struct rpc_task *task, struct xdr_stream *xdr) | |
| 1534 | 1491 | { |
| 1535 | 1492 | struct rpc_rqst *req = task->tk_rqstp; |
| 1536 | 1493 | struct rpc_cred *cred = req->rq_cred; |
| 1537 | 1494 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, |
| 1538 | 1495 | gc_base); |
| 1539 | 1496 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
| 1540 | − __be32 *cred_len; | |
| 1497 | + __be32 *p, *cred_len; | |
| 1541 | 1498 | u32 maj_stat = 0; |
| 1542 | 1499 | struct xdr_netobj mic; |
| 1543 | 1500 | struct kvec iov; |
| 1544 | 1501 | struct xdr_buf verf_buf; |
| 1502 | + int status; | |
| 1545 | 1503 | |
| 1546 | − dprintk("RPC: %5u %s\n", task->tk_pid, __func__); | |
| 1504 | + /* Credential */ | |
| 1547 | 1505 | |
| 1548 | − *p++ = htonl(RPC_AUTH_GSS); | |
| 1506 | + p = xdr_reserve_space(xdr, 7 * sizeof(*p) + | |
| 1507 | + ctx->gc_wire_ctx.len); | |
| 1508 | + if (!p) | |
| 1509 | + goto marshal_failed; | |
| 1510 | + *p++ = rpc_auth_gss; | |
| 1549 | 1511 | cred_len = p++; |
| 1550 | 1512 | |
| 1551 | 1513 | spin_lock(&ctx->gc_seq_lock); |
| 1552 | 1514 | req->rq_seqno = (ctx->gc_seq < MAXSEQ) ? ctx->gc_seq++ : MAXSEQ; |
| 1553 | 1515 | spin_unlock(&ctx->gc_seq_lock); |
| 1554 | 1516 | if (req->rq_seqno == MAXSEQ) |
| 1555 | − goto out_expired; | |
| 1517 | + goto expired; | |
| 1518 | + trace_rpcgss_seqno(task); | |
| 1556 | 1519 | |
| 1557 | − *p++ = htonl((u32) RPC_GSS_VERSION); | |
| 1558 | − *p++ = htonl((u32) ctx->gc_proc); | |
| 1559 | − *p++ = htonl((u32) req->rq_seqno); | |
| 1560 | − *p++ = htonl((u32) gss_cred->gc_service); | |
| 1520 | + *p++ = cpu_to_be32(RPC_GSS_VERSION); | |
| 1521 | + *p++ = cpu_to_be32(ctx->gc_proc); | |
| 1522 | + *p++ = cpu_to_be32(req->rq_seqno); | |
| 1523 | + *p++ = cpu_to_be32(gss_cred->gc_service); | |
| 1561 | 1524 | p = xdr_encode_netobj(p, &ctx->gc_wire_ctx); |
| 1562 | − *cred_len = htonl((p - (cred_len + 1)) << 2); | |
| 1525 | + *cred_len = cpu_to_be32((p - (cred_len + 1)) << 2); | |
| 1526 | + | |
| 1527 | + /* Verifier */ | |
| 1563 | 1528 | |
| 1564 | 1529 | /* We compute the checksum for the verifier over the xdr-encoded bytes |
| 1565 | 1530 | * starting with the xid and ending at the end of the credential: */ |
| 1566 | − iov.iov_base = xprt_skip_transport_header(req->rq_xprt, | |
| 1567 | − req->rq_snd_buf.head[0].iov_base); | |
| 1531 | + iov.iov_base = req->rq_snd_buf.head[0].iov_base; | |
| 1568 | 1532 | iov.iov_len = (u8 *)p - (u8 *)iov.iov_base; |
| 1569 | 1533 | xdr_buf_from_iov(&iov, &verf_buf); |
| 1570 | 1534 | |
| 1571 | − /* set verifier flavor*/ | |
| 1572 | − *p++ = htonl(RPC_AUTH_GSS); | |
| 1573 | − | |
| 1535 | + p = xdr_reserve_space(xdr, sizeof(*p)); | |
| 1536 | + if (!p) | |
| 1537 | + goto marshal_failed; | |
| 1538 | + *p++ = rpc_auth_gss; | |
| 1574 | 1539 | mic.data = (u8 *)(p + 1); |
| 1575 | 1540 | maj_stat = gss_get_mic(ctx->gc_gss_ctx, &verf_buf, &mic); |
| 1576 | − if (maj_stat == GSS_S_CONTEXT_EXPIRED) { | |
| 1577 | − goto out_expired; | |
| 1578 | − } else if (maj_stat != 0) { | |
| 1579 | − pr_warn("gss_marshal: gss_get_mic FAILED (%d)\n", maj_stat); | |
| 1580 | − task->tk_status = -EIO; | |
| 1581 | − goto out_put_ctx; | |
| 1582 | − } | |
| 1583 | − p = xdr_encode_opaque(p, NULL, mic.len); | |
| 1541 | + if (maj_stat == GSS_S_CONTEXT_EXPIRED) | |
| 1542 | + goto expired; | |
| 1543 | + else if (maj_stat != 0) | |
| 1544 | + goto bad_mic; | |
| 1545 | + if (xdr_stream_encode_opaque_inline(xdr, (void **)&p, mic.len) < 0) | |
| 1546 | + goto marshal_failed; | |
| 1547 | + status = 0; | |
| 1548 | +out: | |
| 1584 | 1549 | gss_put_ctx(ctx); |
| 1585 | − return p; | |
| 1586 | −out_expired: | |
| 1550 | + return status; | |
| 1551 | +expired: | |
| 1587 | 1552 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1588 | − task->tk_status = -EKEYEXPIRED; | |
| 1589 | −out_put_ctx: | |
| 1590 | − gss_put_ctx(ctx); | |
| 1591 | − return NULL; | |
| 1553 | + status = -EKEYEXPIRED; | |
| 1554 | + goto out; | |
| 1555 | +marshal_failed: | |
| 1556 | + status = -EMSGSIZE; | |
| 1557 | + goto out; | |
| 1558 | +bad_mic: | |
| 1559 | + trace_rpcgss_get_mic(task, maj_stat); | |
| 1560 | + status = -EIO; | |
| 1561 | + goto out; | |
| 1592 | 1562 | } |
| 1593 | 1563 | |
| 1594 | 1564 | static int gss_renew_cred(struct rpc_task *task) |
| @@ -1662,116 +1632,105 @@ gss_refresh_null(struct rpc_task *task) · 67 unmodified lines | ||
| 1662 | 1632 | return 0; |
| 1663 | 1633 | } |
| 1664 | 1634 | |
| 1665 | −static __be32 * | |
| 1666 | −gss_validate(struct rpc_task *task, __be32 *p) | |
| 1635 | +static int | |
| 1636 | +gss_validate(struct rpc_task *task, struct xdr_stream *xdr) | |
| 1667 | 1637 | { |
| 1668 | 1638 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
| 1669 | 1639 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
| 1670 | − __be32 *seq = NULL; | |
| 1640 | + __be32 *p, *seq = NULL; | |
| 1671 | 1641 | struct kvec iov; |
| 1672 | 1642 | struct xdr_buf verf_buf; |
| 1673 | 1643 | struct xdr_netobj mic; |
| 1674 | − u32 flav,len; | |
| 1675 | − u32 maj_stat; | |
| 1676 | − __be32 *ret = ERR_PTR(-EIO); | |
| 1644 | + u32 len, maj_stat; | |
| 1645 | + int status; | |
| 1677 | 1646 | |
| 1678 | − dprintk("RPC: %5u %s\n", task->tk_pid, __func__); | |
| 1647 | + p = xdr_inline_decode(xdr, 2 * sizeof(*p)); | |
| 1648 | + if (!p) | |
| 1649 | + goto validate_failed; | |
| 1650 | + if (*p++ != rpc_auth_gss) | |
| 1651 | + goto validate_failed; | |
| 1652 | + len = be32_to_cpup(p); | |
| 1653 | + if (len > RPC_MAX_AUTH_SIZE) | |
| 1654 | + goto validate_failed; | |
| 1655 | + p = xdr_inline_decode(xdr, len); | |
| 1656 | + if (!p) | |
| 1657 | + goto validate_failed; | |
| 1679 | 1658 | |
| 1680 | − flav = ntohl(*p++); | |
| 1681 | − if ((len = ntohl(*p++)) > RPC_MAX_AUTH_SIZE) | |
| 1682 | − goto out_bad; | |
| 1683 | − if (flav != RPC_AUTH_GSS) | |
| 1684 | − goto out_bad; | |
| 1685 | 1659 | seq = kmalloc(4, GFP_NOFS); |
| 1686 | 1660 | if (!seq) |
| 1687 | − goto out_bad; | |
| 1688 | − *seq = htonl(task->tk_rqstp->rq_seqno); | |
| 1661 | + goto validate_failed; | |
| 1662 | + *seq = cpu_to_be32(task->tk_rqstp->rq_seqno); | |
| 1689 | 1663 | iov.iov_base = seq; |
| 1690 | 1664 | iov.iov_len = 4; |
| 1691 | 1665 | xdr_buf_from_iov(&iov, &verf_buf); |
| 1692 | 1666 | mic.data = (u8 *)p; |
| 1693 | 1667 | mic.len = len; |
| 1694 | − | |
| 1695 | − ret = ERR_PTR(-EACCES); | |
| 1696 | 1668 | maj_stat = gss_verify_mic(ctx->gc_gss_ctx, &verf_buf, &mic); |
| 1697 | 1669 | if (maj_stat == GSS_S_CONTEXT_EXPIRED) |
| 1698 | 1670 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1699 | − if (maj_stat) { | |
| 1700 | − dprintk("RPC: %5u %s: gss_verify_mic returned error 0x%08x\n", | |
| 1701 | − task->tk_pid, __func__, maj_stat); | |
| 1702 | − goto out_bad; | |
| 1703 | − } | |
| 1671 | + if (maj_stat) | |
| 1672 | + goto bad_mic; | |
| 1673 | + | |
| 1704 | 1674 | /* We leave it to unwrap to calculate au_rslack. For now we just |
| 1705 | 1675 | * calculate the length of the verifier: */ |
| 1706 | 1676 | cred->cr_auth->au_verfsize = XDR_QUADLEN(len) + 2; |
| 1677 | + status = 0; | |
| 1678 | +out: | |
| 1707 | 1679 | gss_put_ctx(ctx); |
| 1708 | − dprintk("RPC: %5u %s: gss_verify_mic succeeded.\n", | |
| 1709 | − task->tk_pid, __func__); | |
| 1710 | − kfree(seq); | |
| 1711 | − return p + XDR_QUADLEN(len); | |
| 1712 | −out_bad: | |
| 1713 | − gss_put_ctx(ctx); | |
| 1714 | − dprintk("RPC: %5u %s failed ret %ld.\n", task->tk_pid, __func__, | |
| 1715 | − PTR_ERR(ret)); | |
| 1716 | 1680 | kfree(seq); |
| 1717 | − return ret; | |
| 1718 | −} | |
| 1719 | − | |
| 1720 | −static void gss_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp, | |
| 1721 | − __be32 *p, void *obj) | |
| 1722 | −{ | |
| 1723 | − struct xdr_stream xdr; | |
| 1681 | + return status; | |
| 1724 | 1682 | |
| 1725 | − xdr_init_encode(&xdr, &rqstp->rq_snd_buf, p); | |
| 1726 | − encode(rqstp, &xdr, obj); | |
| 1683 | +validate_failed: | |
| 1684 | + status = -EIO; | |
| 1685 | + goto out; | |
| 1686 | +bad_mic: | |
| 1687 | + trace_rpcgss_verify_mic(task, maj_stat); | |
| 1688 | + status = -EACCES; | |
| 1689 | + goto out; | |
| 1727 | 1690 | } |
| 1728 | 1691 | |
| 1729 | −static inline int | |
| 1730 | −gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1731 | − kxdreproc_t encode, struct rpc_rqst *rqstp, | |
| 1732 | − __be32 *p, void *obj) | |
| 1692 | +static int gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1693 | + struct rpc_task *task, struct xdr_stream *xdr) | |
| 1733 | 1694 | { |
| 1734 | − struct xdr_buf *snd_buf = &rqstp->rq_snd_buf; | |
| 1735 | − struct xdr_buf integ_buf; | |
| 1736 | − __be32 *integ_len = NULL; | |
| 1695 | + struct rpc_rqst *rqstp = task->tk_rqstp; | |
| 1696 | + struct xdr_buf integ_buf, *snd_buf = &rqstp->rq_snd_buf; | |
| 1737 | 1697 | struct xdr_netobj mic; |
| 1738 | − u32 offset; | |
| 1739 | − __be32 *q; | |
| 1740 | − struct kvec *iov; | |
| 1741 | − u32 maj_stat = 0; | |
| 1742 | − int status = -EIO; | |
| 1698 | + __be32 *p, *integ_len; | |
| 1699 | + u32 offset, maj_stat; | |
| 1743 | 1700 | |
| 1701 | + p = xdr_reserve_space(xdr, 2 * sizeof(*p)); | |
| 1702 | + if (!p) | |
| 1703 | + goto wrap_failed; | |
| 1744 | 1704 | integ_len = p++; |
| 1745 | − offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; | |
| 1746 | − *p++ = htonl(rqstp->rq_seqno); | |
| 1705 | + *p = cpu_to_be32(rqstp->rq_seqno); | |
| 1747 | 1706 | |
| 1748 | − gss_wrap_req_encode(encode, rqstp, p, obj); | |
| 1707 | + if (rpcauth_wrap_req_encode(task, xdr)) | |
| 1708 | + goto wrap_failed; | |
| 1749 | 1709 | |
| 1710 | + offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; | |
| 1750 | 1711 | if (xdr_buf_subsegment(snd_buf, &integ_buf, |
| 1751 | 1712 | offset, snd_buf->len - offset)) |
| 1752 | − return status; | |
| 1753 | − *integ_len = htonl(integ_buf.len); | |
| 1713 | + goto wrap_failed; | |
| 1714 | + *integ_len = cpu_to_be32(integ_buf.len); | |
| 1754 | 1715 | |
| 1755 | − /* guess whether we're in the head or the tail: */ | |
| 1756 | − if (snd_buf->page_len || snd_buf->tail[0].iov_len) | |
| 1757 | − iov = snd_buf->tail; | |
| 1758 | − else | |
| 1759 | − iov = snd_buf->head; | |
| 1760 | − p = iov->iov_base + iov->iov_len; | |
| 1716 | + p = xdr_reserve_space(xdr, 0); | |
| 1717 | + if (!p) | |
| 1718 | + goto wrap_failed; | |
| 1761 | 1719 | mic.data = (u8 *)(p + 1); |
| 1762 | − | |
| 1763 | 1720 | maj_stat = gss_get_mic(ctx->gc_gss_ctx, &integ_buf, &mic); |
| 1764 | − status = -EIO; /* XXX? */ | |
| 1765 | 1721 | if (maj_stat == GSS_S_CONTEXT_EXPIRED) |
| 1766 | 1722 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1767 | 1723 | else if (maj_stat) |
| 1768 | − return status; | |
| 1769 | − q = xdr_encode_opaque(p, NULL, mic.len); | |
| 1770 | − | |
| 1771 | − offset = (u8 *)q - (u8 *)p; | |
| 1772 | − iov->iov_len += offset; | |
| 1773 | − snd_buf->len += offset; | |
| 1724 | + goto bad_mic; | |
| 1725 | + /* Check that the trailing MIC fit in the buffer, after the fact */ | |
| 1726 | + if (xdr_stream_encode_opaque_inline(xdr, (void **)&p, mic.len) < 0) | |
| 1727 | + goto wrap_failed; | |
| 1774 | 1728 | return 0; |
| 1729 | +wrap_failed: | |
| 1730 | + return -EMSGSIZE; | |
| 1731 | +bad_mic: | |
| 1732 | + trace_rpcgss_get_mic(task, maj_stat); | |
| 1733 | + return -EIO; | |
| 1775 | 1734 | } |
| 1776 | 1735 | |
| 1777 | 1736 | static void |
| @@ -1822,61 +1781,62 @@ out: · 44 unmodified lines | ||
| 1822 | 1781 | return -EAGAIN; |
| 1823 | 1782 | } |
| 1824 | 1783 | |
| 1825 | −static inline int | |
| 1826 | −gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1827 | − kxdreproc_t encode, struct rpc_rqst *rqstp, | |
| 1828 | − __be32 *p, void *obj) | |
| 1784 | +static int gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1785 | + struct rpc_task *task, struct xdr_stream *xdr) | |
| 1829 | 1786 | { |
| 1787 | + struct rpc_rqst *rqstp = task->tk_rqstp; | |
| 1830 | 1788 | struct xdr_buf *snd_buf = &rqstp->rq_snd_buf; |
| 1831 | − u32 offset; | |
| 1832 | − u32 maj_stat; | |
| 1789 | + u32 pad, offset, maj_stat; | |
| 1833 | 1790 | int status; |
| 1834 | − __be32 *opaque_len; | |
| 1791 | + __be32 *p, *opaque_len; | |
| 1835 | 1792 | struct page **inpages; |
| 1836 | 1793 | int first; |
| 1837 | − int pad; | |
| 1838 | 1794 | struct kvec *iov; |
| 1839 | − char *tmp; | |
| 1840 | 1795 | |
| 1796 | + status = -EIO; | |
| 1797 | + p = xdr_reserve_space(xdr, 2 * sizeof(*p)); | |
| 1798 | + if (!p) | |
| 1799 | + goto wrap_failed; | |
| 1841 | 1800 | opaque_len = p++; |
| 1842 | − offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; | |
| 1843 | − *p++ = htonl(rqstp->rq_seqno); | |
| 1801 | + *p = cpu_to_be32(rqstp->rq_seqno); | |
| 1844 | 1802 | |
| 1845 | − gss_wrap_req_encode(encode, rqstp, p, obj); | |
| 1803 | + if (rpcauth_wrap_req_encode(task, xdr)) | |
| 1804 | + goto wrap_failed; | |
| 1846 | 1805 | |
| 1847 | 1806 | status = alloc_enc_pages(rqstp); |
| 1848 | − if (status) | |
| 1849 | − return status; | |
| 1807 | + if (unlikely(status)) | |
| 1808 | + goto wrap_failed; | |
| 1850 | 1809 | first = snd_buf->page_base >> PAGE_SHIFT; |
| 1851 | 1810 | inpages = snd_buf->pages + first; |
| 1852 | 1811 | snd_buf->pages = rqstp->rq_enc_pages; |
| 1853 | 1812 | snd_buf->page_base -= first << PAGE_SHIFT; |
| 1854 | 1813 | /* |
| 1855 | − * Give the tail its own page, in case we need extra space in the | |
| 1856 | − * head when wrapping: | |
| 1814 | + * Move the tail into its own page, in case gss_wrap needs | |
| 1815 | + * more space in the head when wrapping. | |
| 1857 | 1816 | * |
| 1858 | − * call_allocate() allocates twice the slack space required | |
| 1859 | − * by the authentication flavor to rq_callsize. | |
| 1860 | − * For GSS, slack is GSS_CRED_SLACK. | |
| 1817 | + * Still... Why can't gss_wrap just slide the tail down? | |
| 1861 | 1818 | */ |
| 1862 | 1819 | if (snd_buf->page_len || snd_buf->tail[0].iov_len) { |
| 1820 | + char *tmp; | |
| 1821 | + | |
| 1863 | 1822 | tmp = page_address(rqstp->rq_enc_pages[rqstp->rq_enc_pages_num - 1]); |
| 1864 | 1823 | memcpy(tmp, snd_buf->tail[0].iov_base, snd_buf->tail[0].iov_len); |
| 1865 | 1824 | snd_buf->tail[0].iov_base = tmp; |
| 1866 | 1825 | } |
| 1826 | + offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base; | |
| 1867 | 1827 | maj_stat = gss_wrap(ctx->gc_gss_ctx, offset, snd_buf, inpages); |
| 1868 | 1828 | /* slack space should prevent this ever happening: */ |
| 1869 | − BUG_ON(snd_buf->len > snd_buf->buflen); | |
| 1870 | − status = -EIO; | |
| 1829 | + if (unlikely(snd_buf->len > snd_buf->buflen)) | |
| 1830 | + goto wrap_failed; | |
| 1871 | 1831 | /* We're assuming that when GSS_S_CONTEXT_EXPIRED, the encryption was |
| 1872 | 1832 | * done anyway, so it's safe to put the request on the wire: */ |
| 1873 | 1833 | if (maj_stat == GSS_S_CONTEXT_EXPIRED) |
| 1874 | 1834 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1875 | 1835 | else if (maj_stat) |
| 1876 | − return status; | |
| 1836 | + goto bad_wrap; | |
| 1877 | 1837 | |
| 1878 | − *opaque_len = htonl(snd_buf->len - offset); | |
| 1879 | − /* guess whether we're in the head or the tail: */ | |
| 1838 | + *opaque_len = cpu_to_be32(snd_buf->len - offset); | |
| 1839 | + /* guess whether the pad goes into the head or the tail: */ | |
| 1880 | 1840 | if (snd_buf->page_len || snd_buf->tail[0].iov_len) |
| 1881 | 1841 | iov = snd_buf->tail; |
| 1882 | 1842 | else |
| @@ -1888,118 +1848,154 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, · 5 unmodified lines | ||
| 1888 | 1848 | snd_buf->len += pad; |
| 1889 | 1849 | |
| 1890 | 1850 | return 0; |
| 1851 | +wrap_failed: | |
| 1852 | + return status; | |
| 1853 | +bad_wrap: | |
| 1854 | + trace_rpcgss_wrap(task, maj_stat); | |
| 1855 | + return -EIO; | |
| 1891 | 1856 | } |
| 1892 | 1857 | |
| 1893 | −static int | |
| 1894 | −gss_wrap_req(struct rpc_task *task, | |
| 1895 | − kxdreproc_t encode, void *rqstp, __be32 *p, void *obj) | |
| 1858 | +static int gss_wrap_req(struct rpc_task *task, struct xdr_stream *xdr) | |
| 1896 | 1859 | { |
| 1897 | 1860 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
| 1898 | 1861 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, |
| 1899 | 1862 | gc_base); |
| 1900 | 1863 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
| 1901 | − int status = -EIO; | |
| 1864 | + int status; | |
| 1902 | 1865 | |
| 1903 | − dprintk("RPC: %5u %s\n", task->tk_pid, __func__); | |
| 1866 | + status = -EIO; | |
| 1904 | 1867 | if (ctx->gc_proc != RPC_GSS_PROC_DATA) { |
| 1905 | 1868 | /* The spec seems a little ambiguous here, but I think that not |
| 1906 | 1869 | * wrapping context destruction requests makes the most sense. |
| 1907 | 1870 | */ |
| 1908 | − gss_wrap_req_encode(encode, rqstp, p, obj); | |
| 1909 | − status = 0; | |
| 1871 | + status = rpcauth_wrap_req_encode(task, xdr); | |
| 1910 | 1872 | goto out; |
| 1911 | 1873 | } |
| 1912 | 1874 | switch (gss_cred->gc_service) { |
| 1913 | 1875 | case RPC_GSS_SVC_NONE: |
| 1914 | − gss_wrap_req_encode(encode, rqstp, p, obj); | |
| 1915 | − status = 0; | |
| 1876 | + status = rpcauth_wrap_req_encode(task, xdr); | |
| 1916 | 1877 | break; |
| 1917 | 1878 | case RPC_GSS_SVC_INTEGRITY: |
| 1918 | − status = gss_wrap_req_integ(cred, ctx, encode, rqstp, p, obj); | |
| 1879 | + status = gss_wrap_req_integ(cred, ctx, task, xdr); | |
| 1919 | 1880 | break; |
| 1920 | 1881 | case RPC_GSS_SVC_PRIVACY: |
| 1921 | − status = gss_wrap_req_priv(cred, ctx, encode, rqstp, p, obj); | |
| 1882 | + status = gss_wrap_req_priv(cred, ctx, task, xdr); | |
| 1922 | 1883 | break; |
| 1884 | + default: | |
| 1885 | + status = -EIO; | |
| 1923 | 1886 | } |
| 1924 | 1887 | out: |
| 1925 | 1888 | gss_put_ctx(ctx); |
| 1926 | − dprintk("RPC: %5u %s returning %d\n", task->tk_pid, __func__, status); | |
| 1927 | 1889 | return status; |
| 1928 | 1890 | } |
| 1929 | 1891 | |
| 1930 | −static inline int | |
| 1931 | −gss_unwrap_resp_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1932 | − struct rpc_rqst *rqstp, __be32 **p) | |
| 1892 | +static int | |
| 1893 | +gss_unwrap_resp_auth(struct rpc_cred *cred) | |
| 1933 | 1894 | { |
| 1934 | − struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf; | |
| 1935 | − struct xdr_buf integ_buf; | |
| 1895 | + struct rpc_auth *auth = cred->cr_auth; | |
| 1896 | + | |
| 1897 | + auth->au_rslack = auth->au_verfsize; | |
| 1898 | + auth->au_ralign = auth->au_verfsize; | |
| 1899 | + return 0; | |
| 1900 | +} | |
| 1901 | + | |
| 1902 | +static int | |
| 1903 | +gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred, | |
| 1904 | + struct gss_cl_ctx *ctx, struct rpc_rqst *rqstp, | |
| 1905 | + struct xdr_stream *xdr) | |
| 1906 | +{ | |
| 1907 | + struct xdr_buf integ_buf, *rcv_buf = &rqstp->rq_rcv_buf; | |
| 1908 | + u32 data_offset, mic_offset, integ_len, maj_stat; | |
| 1909 | + struct rpc_auth *auth = cred->cr_auth; | |
| 1936 | 1910 | struct xdr_netobj mic; |
| 1937 | − u32 data_offset, mic_offset; | |
| 1938 | − u32 integ_len; | |
| 1939 | − u32 maj_stat; | |
| 1940 | − int status = -EIO; | |
| 1911 | + __be32 *p; | |
| 1941 | 1912 | |
| 1942 | − integ_len = ntohl(*(*p)++); | |
| 1913 | + p = xdr_inline_decode(xdr, 2 * sizeof(*p)); | |
| 1914 | + if (unlikely(!p)) | |
| 1915 | + goto unwrap_failed; | |
| 1916 | + integ_len = be32_to_cpup(p++); | |
| 1943 | 1917 | if (integ_len & 3) |
| 1944 | − return status; | |
| 1945 | − data_offset = (u8 *)(*p) - (u8 *)rcv_buf->head[0].iov_base; | |
| 1918 | + goto unwrap_failed; | |
| 1919 | + data_offset = (u8 *)(p) - (u8 *)rcv_buf->head[0].iov_base; | |
| 1946 | 1920 | mic_offset = integ_len + data_offset; |
| 1947 | 1921 | if (mic_offset > rcv_buf->len) |
| 1948 | − return status; | |
| 1949 | − if (ntohl(*(*p)++) != rqstp->rq_seqno) | |
| 1950 | − return status; | |
| 1951 | − | |
| 1952 | − if (xdr_buf_subsegment(rcv_buf, &integ_buf, data_offset, | |
| 1953 | − mic_offset - data_offset)) | |
| 1954 | − return status; | |
| 1922 | + goto unwrap_failed; | |
| 1923 | + if (be32_to_cpup(p) != rqstp->rq_seqno) | |
| 1924 | + goto bad_seqno; | |
| 1955 | 1925 | |
| 1926 | + if (xdr_buf_subsegment(rcv_buf, &integ_buf, data_offset, integ_len)) | |
| 1927 | + goto unwrap_failed; | |
| 1956 | 1928 | if (xdr_buf_read_netobj(rcv_buf, &mic, mic_offset)) |
| 1957 | − return status; | |
| 1958 | − | |
| 1929 | + goto unwrap_failed; | |
| 1959 | 1930 | maj_stat = gss_verify_mic(ctx->gc_gss_ctx, &integ_buf, &mic); |
| 1960 | 1931 | if (maj_stat == GSS_S_CONTEXT_EXPIRED) |
| 1961 | 1932 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1962 | 1933 | if (maj_stat != GSS_S_COMPLETE) |
| 1963 | − return status; | |
| 1934 | + goto bad_mic; | |
| 1935 | + | |
| 1936 | + auth->au_rslack = auth->au_verfsize + 2 + 1 + XDR_QUADLEN(mic.len); | |
| 1937 | + auth->au_ralign = auth->au_verfsize + 2; | |
| 1964 | 1938 | return 0; |
| 1939 | +unwrap_failed: | |
| 1940 | + trace_rpcgss_unwrap_failed(task); | |
| 1941 | + return -EIO; | |
| 1942 | +bad_seqno: | |
| 1943 | + trace_rpcgss_bad_seqno(task, rqstp->rq_seqno, be32_to_cpup(p)); | |
| 1944 | + return -EIO; | |
| 1945 | +bad_mic: | |
| 1946 | + trace_rpcgss_verify_mic(task, maj_stat); | |
| 1947 | + return -EIO; | |
| 1965 | 1948 | } |
| 1966 | 1949 | |
| 1967 | −static inline int | |
| 1968 | −gss_unwrap_resp_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, | |
| 1969 | − struct rpc_rqst *rqstp, __be32 **p) | |
| 1970 | −{ | |
| 1971 | − struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf; | |
| 1972 | − u32 offset; | |
| 1973 | − u32 opaque_len; | |
| 1974 | − u32 maj_stat; | |
| 1975 | − int status = -EIO; | |
| 1976 | − | |
| 1977 | − opaque_len = ntohl(*(*p)++); | |
| 1978 | − offset = (u8 *)(*p) - (u8 *)rcv_buf->head[0].iov_base; | |
| 1950 | +static int | |
| 1951 | +gss_unwrap_resp_priv(struct rpc_task *task, struct rpc_cred *cred, | |
| 1952 | + struct gss_cl_ctx *ctx, struct rpc_rqst *rqstp, | |
| 1953 | + struct xdr_stream *xdr) | |
| 1954 | +{ | |
| 1955 | + struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf; | |
| 1956 | + struct kvec *head = rqstp->rq_rcv_buf.head; | |
| 1957 | + struct rpc_auth *auth = cred->cr_auth; | |
| 1958 | + unsigned int savedlen = rcv_buf->len; | |
| 1959 | + u32 offset, opaque_len, maj_stat; | |
| 1960 | + __be32 *p; | |
| 1961 | + | |
| 1962 | + p = xdr_inline_decode(xdr, 2 * sizeof(*p)); | |
| 1963 | + if (unlikely(!p)) | |
| 1964 | + goto unwrap_failed; | |
| 1965 | + opaque_len = be32_to_cpup(p++); | |
| 1966 | + offset = (u8 *)(p) - (u8 *)head->iov_base; | |
| 1979 | 1967 | if (offset + opaque_len > rcv_buf->len) |
| 1980 | − return status; | |
| 1981 | − /* remove padding: */ | |
| 1968 | + goto unwrap_failed; | |
| 1982 | 1969 | rcv_buf->len = offset + opaque_len; |
| 1983 | 1970 | |
| 1984 | 1971 | maj_stat = gss_unwrap(ctx->gc_gss_ctx, offset, rcv_buf); |
| 1985 | 1972 | if (maj_stat == GSS_S_CONTEXT_EXPIRED) |
| 1986 | 1973 | clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); |
| 1987 | 1974 | if (maj_stat != GSS_S_COMPLETE) |
| 1988 | − return status; | |
| 1989 | − if (ntohl(*(*p)++) != rqstp->rq_seqno) | |
| 1990 | − return status; | |
| 1975 | + goto bad_unwrap; | |
| 1976 | + /* gss_unwrap decrypted the sequence number */ | |
| 1977 | + if (be32_to_cpup(p++) != rqstp->rq_seqno) | |
| 1978 | + goto bad_seqno; | |
| 1991 | 1979 | |
| 1992 | − return 0; | |
| 1993 | −} | |
| 1994 | − | |
| 1995 | −static int | |
| 1996 | −gss_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp, | |
| 1997 | − __be32 *p, void *obj) | |
| 1998 | −{ | |
| 1999 | − struct xdr_stream xdr; | |
| 1980 | + /* gss_unwrap redacts the opaque blob from the head iovec. | |
| 1981 | + * rcv_buf has changed, thus the stream needs to be reset. | |
| 1982 | + */ | |
| 1983 | + xdr_init_decode(xdr, rcv_buf, p, rqstp); | |
| 2000 | 1984 | |
| 2001 | − xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | |
| 2002 | − return decode(rqstp, &xdr, obj); | |
| 1985 | + auth->au_rslack = auth->au_verfsize + 2 + | |
| 1986 | + XDR_QUADLEN(savedlen - rcv_buf->len); | |
| 1987 | + auth->au_ralign = auth->au_verfsize + 2 + | |
| 1988 | + XDR_QUADLEN(savedlen - rcv_buf->len); | |
| 1989 | + return 0; | |
| 1990 | +unwrap_failed: | |
| 1991 | + trace_rpcgss_unwrap_failed(task); | |
| 1992 | + return -EIO; | |
| 1993 | +bad_seqno: | |
| 1994 | + trace_rpcgss_bad_seqno(task, rqstp->rq_seqno, be32_to_cpup(--p)); | |
| 1995 | + return -EIO; | |
| 1996 | +bad_unwrap: | |
| 1997 | + trace_rpcgss_unwrap(task, maj_stat); | |
| 1998 | + return -EIO; | |
| 2003 | 1999 | } |
| 2004 | 2000 | |
| 2005 | 2001 | static bool |
| @@ -2014,14 +2010,14 @@ gss_xmit_need_reencode(struct rpc_task *task) · 8 unmodified lines | ||
| 2014 | 2010 | struct rpc_rqst *req = task->tk_rqstp; |
| 2015 | 2011 | struct rpc_cred *cred = req->rq_cred; |
| 2016 | 2012 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
| 2017 | − u32 win, seq_xmit; | |
| 2013 | + u32 win, seq_xmit = 0; | |
| 2018 | 2014 | bool ret = true; |
| 2019 | 2015 | |
| 2020 | 2016 | if (!ctx) |
| 2021 | − return true; | |
| 2017 | + goto out; | |
| 2022 | 2018 | |
| 2023 | 2019 | if (gss_seq_is_newer(req->rq_seqno, READ_ONCE(ctx->gc_seq))) |
| 2024 | − goto out; | |
| 2020 | + goto out_ctx; | |
| 2025 | 2021 | |
| 2026 | 2022 | seq_xmit = READ_ONCE(ctx->gc_seq_xmit); |
| 2027 | 2023 | while (gss_seq_is_newer(req->rq_seqno, seq_xmit)) { |
| @@ -2030,56 +2026,51 @@ gss_xmit_need_reencode(struct rpc_task *task) · 2 unmodified lines | ||
| 2030 | 2026 | seq_xmit = cmpxchg(&ctx->gc_seq_xmit, tmp, req->rq_seqno); |
| 2031 | 2027 | if (seq_xmit == tmp) { |
| 2032 | 2028 | ret = false; |
| 2033 | − goto out; | |
| 2029 | + goto out_ctx; | |
| 2034 | 2030 | } |
| 2035 | 2031 | } |
| 2036 | 2032 | |
| 2037 | 2033 | win = ctx->gc_win; |
| 2038 | 2034 | if (win > 0) |
| 2039 | 2035 | ret = !gss_seq_is_newer(req->rq_seqno, seq_xmit - win); |
| 2040 | −out: | |
| 2036 | + | |
| 2037 | +out_ctx: | |
| 2041 | 2038 | gss_put_ctx(ctx); |
| 2039 | +out: | |
| 2040 | + trace_rpcgss_need_reencode(task, seq_xmit, ret); | |
| 2042 | 2041 | return ret; |
| 2043 | 2042 | } |
| 2044 | 2043 | |
| 2045 | 2044 | static int |
| 2046 | −gss_unwrap_resp(struct rpc_task *task, | |
| 2047 | − kxdrdproc_t decode, void *rqstp, __be32 *p, void *obj) | |
| 2045 | +gss_unwrap_resp(struct rpc_task *task, struct xdr_stream *xdr) | |
| 2048 | 2046 | { |
| 2049 | − struct rpc_cred *cred = task->tk_rqstp->rq_cred; | |
| 2047 | + struct rpc_rqst *rqstp = task->tk_rqstp; | |
| 2048 | + struct rpc_cred *cred = rqstp->rq_cred; | |
| 2050 | 2049 | struct gss_cred *gss_cred = container_of(cred, struct gss_cred, |
| 2051 | 2050 | gc_base); |
| 2052 | 2051 | struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); |
| 2053 | − __be32 *savedp = p; | |
| 2054 | − struct kvec *head = ((struct rpc_rqst *)rqstp)->rq_rcv_buf.head; | |
| 2055 | − int savedlen = head->iov_len; | |
| 2056 | − int status = -EIO; | |
| 2052 | + int status = -EIO; | |
| 2057 | 2053 | |
| 2058 | 2054 | if (ctx->gc_proc != RPC_GSS_PROC_DATA) |
| 2059 | 2055 | goto out_decode; |
| 2060 | 2056 | switch (gss_cred->gc_service) { |
| 2061 | 2057 | case RPC_GSS_SVC_NONE: |
| 2058 | + status = gss_unwrap_resp_auth(cred); | |
| 2062 | 2059 | break; |
| 2063 | 2060 | case RPC_GSS_SVC_INTEGRITY: |
| 2064 | − status = gss_unwrap_resp_integ(cred, ctx, rqstp, &p); | |
| 2065 | − if (status) | |
| 2066 | − goto out; | |
| 2061 | + status = gss_unwrap_resp_integ(task, cred, ctx, rqstp, xdr); | |
| 2067 | 2062 | break; |
| 2068 | 2063 | case RPC_GSS_SVC_PRIVACY: |
| 2069 | − status = gss_unwrap_resp_priv(cred, ctx, rqstp, &p); | |
| 2070 | − if (status) | |
| 2071 | − goto out; | |
| 2064 | + status = gss_unwrap_resp_priv(task, cred, ctx, rqstp, xdr); | |
| 2072 | 2065 | break; |
| 2073 | 2066 | } |
| 2074 | − /* take into account extra slack for integrity and privacy cases: */ | |
| 2075 | − cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + (p - savedp) | |
| 2076 | − + (savedlen - head->iov_len); | |
| 2067 | + if (status) | |
| 2068 | + goto out; | |
| 2069 | + | |
| 2077 | 2070 | out_decode: |
| 2078 | − status = gss_unwrap_req_decode(decode, rqstp, p, obj); | |
| 2071 | + status = rpcauth_unwrap_resp_decode(task, xdr); | |
| 2079 | 2072 | out: |
| 2080 | 2073 | gss_put_ctx(ctx); |
| 2081 | − dprintk("RPC: %5u %s returning %d\n", | |
| 2082 | − task->tk_pid, __func__, status); | |
| 2083 | 2074 | return status; |
| 2084 | 2075 | } |
| 2085 | 2076 | |
| @@ -1,3 +1,4 @@ | ||
| 1 | +// SPDX-License-Identifier: BSD-3-Clause | |
| 1 | 2 | /* |
| 2 | 3 | * linux/net/sunrpc/gss_krb5_mech.c |
| 3 | 4 | * |
| @@ -6,32 +7,6 @@ · 2 unmodified lines | ||
| 6 | 7 | * |
| 7 | 8 | * Andy Adamson <andros@umich.edu> |
| 8 | 9 | * J. Bruce Fields <bfields@umich.edu> |
| 9 | − * | |
| 10 | − * Redistribution and use in source and binary forms, with or without | |
| 11 | − * modification, are permitted provided that the following conditions | |
| 12 | − * are met: | |
| 13 | − * | |
| 14 | − * 1. Redistributions of source code must retain the above copyright | |
| 15 | − * notice, this list of conditions and the following disclaimer. | |
| 16 | − * 2. Redistributions in binary form must reproduce the above copyright | |
| 17 | − * notice, this list of conditions and the following disclaimer in the | |
| 18 | − * documentation and/or other materials provided with the distribution. | |
| 19 | − * 3. Neither the name of the University nor the names of its | |
| 20 | − * contributors may be used to endorse or promote products derived | |
| 21 | − * from this software without specific prior written permission. | |
| 22 | − * | |
| 23 | − * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
| 24 | − * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 25 | − * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 26 | − * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
| 27 | − * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 28 | − * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 29 | − * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
| 30 | − * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 31 | − * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 32 | − * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 33 | − * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 34 | − * | |
| 35 | 10 | */ |
| 36 | 11 | |
| 37 | 12 | #include <crypto/hash.h> |
| @@ -53,6 +28,7 @@ · 15 unmodified lines | ||
| 53 | 28 | static struct gss_api_mech gss_kerberos_mech; /* forward declaration */ |
| 54 | 29 | |
| 55 | 30 | static const struct gss_krb5_enctype supported_gss_krb5_enctypes[] = { |
| 31 | +#ifndef CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES | |
| 56 | 32 | /* |
| 57 | 33 | * DES (All DES enctypes are mapped to the same gss functionality) |
| 58 | 34 | */ |
| @@ -74,6 +50,7 @@ static const struct gss_krb5_enctype supported_gss_krb5_enctypes[] = { · 15 unmodified lines | ||
| 74 | 50 | .cksumlength = 8, |
| 75 | 51 | .keyed_cksum = 0, |
| 76 | 52 | }, |
| 53 | +#endif /* CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES */ | |
| 77 | 54 | /* |
| 78 | 55 | * RC4-HMAC |
| 79 | 56 | */ |
| @@ -570,14 +570,16 @@ gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf) · 569 unmodified lines | ||
| 570 | 570 | */ |
| 571 | 571 | movelen = min_t(unsigned int, buf->head[0].iov_len, buf->len); |
| 572 | 572 | movelen -= offset + GSS_KRB5_TOK_HDR_LEN + headskip; |
| 573 | − BUG_ON(offset + GSS_KRB5_TOK_HDR_LEN + headskip + movelen > | |
| 574 | − buf->head[0].iov_len); | |
| 573 | + if (offset + GSS_KRB5_TOK_HDR_LEN + headskip + movelen > | |
| 574 | + buf->head[0].iov_len) | |
| 575 | + return GSS_S_FAILURE; | |
| 575 | 576 | memmove(ptr, ptr + GSS_KRB5_TOK_HDR_LEN + headskip, movelen); |
| 576 | 577 | buf->head[0].iov_len -= GSS_KRB5_TOK_HDR_LEN + headskip; |
| 577 | 578 | buf->len -= GSS_KRB5_TOK_HDR_LEN + headskip; |
| 578 | 579 | |
| 579 | 580 | /* Trim off the trailing "extra count" and checksum blob */ |
| 580 | − xdr_buf_trim(buf, ec + GSS_KRB5_TOK_HDR_LEN + tailskip); | |
| 581 | + buf->len -= ec + GSS_KRB5_TOK_HDR_LEN + tailskip; | |
| 582 | + | |
| 581 | 583 | return GSS_S_COMPLETE; |
| 582 | 584 | } |
| 583 | 585 | |
| @@ -1,3 +1,4 @@ | ||
| 1 | +// SPDX-License-Identifier: BSD-3-Clause | |
| 1 | 2 | /* |
| 2 | 3 | * linux/net/sunrpc/gss_mech_switch.c |
| 3 | 4 | * |
| @@ -5,32 +6,6 @@ · 1 unmodified line | ||
| 5 | 6 | * All rights reserved. |
| 6 | 7 | * |
| 7 | 8 | * J. Bruce Fields <bfields@umich.edu> |
| 8 | − * | |
| 9 | − * Redistribution and use in source and binary forms, with or without | |
| 10 | − * modification, are permitted provided that the following conditions | |
| 11 | − * are met: | |
| 12 | − * | |
| 13 | − * 1. Redistributions of source code must retain the above copyright | |
| 14 | − * notice, this list of conditions and the following disclaimer. | |
| 15 | − * 2. Redistributions in binary form must reproduce the above copyright | |
| 16 | − * notice, this list of conditions and the following disclaimer in the | |
| 17 | − * documentation and/or other materials provided with the distribution. | |
| 18 | − * 3. Neither the name of the University nor the names of its | |
| 19 | − * contributors may be used to endorse or promote products derived | |
| 20 | − * from this software without specific prior written permission. | |
| 21 | − * | |
| 22 | − * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
| 23 | − * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 24 | − * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 25 | − * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
| 26 | − * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 27 | − * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 28 | − * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
| 29 | − * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 30 | − * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 31 | − * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 32 | − * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 33 | − * | |
| 34 | 9 | */ |
| 35 | 10 | |
| 36 | 11 | #include <linux/types.h> |
| @@ -1,21 +1,8 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 1 | 2 | /* |
| 2 | 3 | * linux/net/sunrpc/gss_rpc_upcall.c |
| 3 | 4 | * |
| 4 | 5 | * Copyright (C) 2012 Simo Sorce <simo@redhat.com> |
| 5 | − * | |
| 6 | − * This program is free software; you can redistribute it and/or modify | |
| 7 | − * it under the terms of the GNU General Public License as published by | |
| 8 | − * the Free Software Foundation; either version 2 of the License, or | |
| 9 | − * (at your option) any later version. | |
| 10 | − * | |
| 11 | − * This program is distributed in the hope that it will be useful, | |
| 12 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | − * GNU General Public License for more details. | |
| 15 | − * | |
| 16 | − * You should have received a copy of the GNU General Public License | |
| 17 | − * along with this program; if not, write to the Free Software | |
| 18 | − * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 19 | 6 | */ |
| 20 | 7 | |
| 21 | 8 | #include <linux/types.h> |
| @@ -1,21 +1,8 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 1 | 2 | /* |
| 2 | 3 | * linux/net/sunrpc/gss_rpc_upcall.h |
| 3 | 4 | * |
| 4 | 5 | * Copyright (C) 2012 Simo Sorce <simo@redhat.com> |
| 5 | − * | |
| 6 | − * This program is free software; you can redistribute it and/or modify | |
| 7 | − * it under the terms of the GNU General Public License as published by | |
| 8 | − * the Free Software Foundation; either version 2 of the License, or | |
| 9 | − * (at your option) any later version. | |
| 10 | − * | |
| 11 | − * This program is distributed in the hope that it will be useful, | |
| 12 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | − * GNU General Public License for more details. | |
| 15 | − * | |
| 16 | − * You should have received a copy of the GNU General Public License | |
| 17 | − * along with this program; if not, write to the Free Software | |
| 18 | − * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 19 | 6 | */ |
| 20 | 7 | |
| 21 | 8 | #ifndef _GSS_RPC_UPCALL_H |
| @@ -45,4 +32,5 @@ void gssp_free_upcall_data(struct gssp_upcall_data *data); · 23 unmodified lines | ||
| 45 | 32 | void init_gssp_clnt(struct sunrpc_net *); |
| 46 | 33 | int set_gssp_clnt(struct net *); |
| 47 | 34 | void clear_gssp_clnt(struct sunrpc_net *); |
| 35 | + | |
| 48 | 36 | #endif /* _GSS_RPC_UPCALL_H */ |
| @@ -1,21 +1,8 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0+ | |
| 1 | 2 | /* |
| 2 | 3 | * GSS Proxy upcall module |
| 3 | 4 | * |
| 4 | 5 | * Copyright (C) 2012 Simo Sorce <simo@redhat.com> |
| 5 | − * | |
| 6 | − * This program is free software; you can redistribute it and/or modify | |
| 7 | − * it under the terms of the GNU General Public License as published by | |
| 8 | − * the Free Software Foundation; either version 2 of the License, or | |
| 9 | − * (at your option) any later version. | |
| 10 | − * | |
| 11 | − * This program is distributed in the hope that it will be useful, | |
| 12 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | − * GNU General Public License for more details. | |
| 15 | − * | |
| 16 | − * You should have received a copy of the GNU General Public License | |
| 17 | − * along with this program; if not, write to the Free Software | |
| 18 | − * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 19 | 6 | */ |
| 20 | 7 | |
| 21 | 8 | #include <linux/sunrpc/svcauth.h> |
| @@ -1,21 +1,8 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ | |
| 1 | 2 | /* |
| 2 | 3 | * GSS Proxy upcall module |
| 3 | 4 | * |
| 4 | 5 | * Copyright (C) 2012 Simo Sorce <simo@redhat.com> |
| 5 | − * | |
| 6 | − * This program is free software; you can redistribute it and/or modify | |
| 7 | − * it under the terms of the GNU General Public License as published by | |
| 8 | − * the Free Software Foundation; either version 2 of the License, or | |
| 9 | − * (at your option) any later version. | |
| 10 | − * | |
| 11 | − * This program is distributed in the hope that it will be useful, | |
| 12 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | − * GNU General Public License for more details. | |
| 15 | − * | |
| 16 | − * You should have received a copy of the GNU General Public License | |
| 17 | − * along with this program; if not, write to the Free Software | |
| 18 | − * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 19 | 6 | */ |
| 20 | 7 | |
| 21 | 8 | #ifndef _LINUX_GSS_RPC_XDR_H |
| @@ -262,6 +249,4 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp, · 240 unmodified lines | ||
| 262 | 249 | #define GSSX_ARG_wrap_size_limit_sz 0 |
| 263 | 250 | #define GSSX_RES_wrap_size_limit_sz 0 |
| 264 | 251 | |
| 265 | − | |
| 266 | − | |
| 267 | 252 | #endif /* _LINUX_GSS_RPC_XDR_H */ |
| @@ -1,3 +1,4 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 1 | 2 | /* |
| 2 | 3 | * Neil Brown <neilb@cse.unsw.edu.au> |
| 3 | 4 | * J. Bruce Fields <bfields@umich.edu> |
| @@ -896,7 +897,7 @@ unwrap_integ_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct g · 892 unmodified lines | ||
| 896 | 897 | if (svc_getnl(&buf->head[0]) != seq) |
| 897 | 898 | goto out; |
| 898 | 899 | /* trim off the mic and padding at the end before returning */ |
| 899 | − xdr_buf_trim(buf, round_up_to_quad(mic.len) + 4); | |
| 900 | + buf->len -= 4 + round_up_to_quad(mic.len); | |
| 900 | 901 | stat = 0; |
| 901 | 902 | out: |
| 902 | 903 | kfree(mic.data); |
| @@ -0,0 +1,11 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +/* | |
| 3 | + * Copyright (c) 2018, 2019 Oracle. All rights reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +#include <linux/sunrpc/clnt.h> | |
| 7 | +#include <linux/sunrpc/sched.h> | |
| 8 | +#include <linux/sunrpc/gss_err.h> | |
| 9 | + | |
| 10 | +#define CREATE_TRACE_POINTS | |
| 11 | +#include <trace/events/rpcgss.h> | |
| @@ -59,15 +59,21 @@ nul_match(struct auth_cred *acred, struct rpc_cred *cred, int taskflags) · 58 unmodified lines | ||
| 59 | 59 | /* |
| 60 | 60 | * Marshal credential. |
| 61 | 61 | */ |
| 62 | −static __be32 * | |
| 63 | −nul_marshal(struct rpc_task *task, __be32 *p) | |
| 62 | +static int | |
| 63 | +nul_marshal(struct rpc_task *task, struct xdr_stream *xdr) | |
| 64 | 64 | { |
| 65 | − *p++ = htonl(RPC_AUTH_NULL); | |
| 66 | − *p++ = 0; | |
| 67 | − *p++ = htonl(RPC_AUTH_NULL); | |
| 68 | − *p++ = 0; | |
| 69 | − | |
| 70 | − return p; | |
| 65 | + __be32 *p; | |
| 66 | + | |
| 67 | + p = xdr_reserve_space(xdr, 4 * sizeof(*p)); | |
| 68 | + if (!p) | |
| 69 | + return -EMSGSIZE; | |
| 70 | + /* Credential */ | |
| 71 | + *p++ = rpc_auth_null; | |
| 72 | + *p++ = xdr_zero; | |
| 73 | + /* Verifier */ | |
| 74 | + *p++ = rpc_auth_null; | |
| 75 | + *p = xdr_zero; | |
| 76 | + return 0; | |
| 71 | 77 | } |
| 72 | 78 | |
| 73 | 79 | /* |
| @@ -80,25 +86,19 @@ nul_refresh(struct rpc_task *task) · 6 unmodified lines | ||
| 80 | 86 | return 0; |
| 81 | 87 | } |
| 82 | 88 | |
| 83 | −static __be32 * | |
| 84 | −nul_validate(struct rpc_task *task, __be32 *p) | |
| 89 | +static int | |
| 90 | +nul_validate(struct rpc_task *task, struct xdr_stream *xdr) | |
| 85 | 91 | { |
| 86 | − rpc_authflavor_t flavor; | |
| 87 | − u32 size; | |
| 88 | − | |
| 89 | − flavor = ntohl(*p++); | |
| 90 | − if (flavor != RPC_AUTH_NULL) { | |
| 91 | − printk("RPC: bad verf flavor: %u\n", flavor); | |
| 92 | − return ERR_PTR(-EIO); | |
| 93 | − } | |
| 94 | − | |
| 95 | − size = ntohl(*p++); | |
| 96 | − if (size != 0) { | |
| 97 | − printk("RPC: bad verf size: %u\n", size); | |
| 98 | − return ERR_PTR(-EIO); | |
| 99 | − } | |
| 100 | − | |
| 101 | − return p; | |
| 92 | + __be32 *p; | |
| 93 | + | |
| 94 | + p = xdr_inline_decode(xdr, 2 * sizeof(*p)); | |
| 95 | + if (!p) | |
| 96 | + return -EIO; | |
| 97 | + if (*p++ != rpc_auth_null) | |
| 98 | + return -EIO; | |
| 99 | + if (*p != xdr_zero) | |
| 100 | + return -EIO; | |
| 101 | + return 0; | |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | const struct rpc_authops authnull_ops = { |
| @@ -114,6 +114,8 @@ static · 9 unmodified lines | ||
| 114 | 114 | struct rpc_auth null_auth = { |
| 115 | 115 | .au_cslack = NUL_CALLSLACK, |
| 116 | 116 | .au_rslack = NUL_REPLYSLACK, |
| 117 | + .au_verfsize = NUL_REPLYSLACK, | |
| 118 | + .au_ralign = NUL_REPLYSLACK, | |
| 117 | 119 | .au_ops = &authnull_ops, |
| 118 | 120 | .au_flavor = RPC_AUTH_NULL, |
| 119 | 121 | .au_count = REFCOUNT_INIT(1), |
| @@ -125,8 +127,10 @@ const struct rpc_credops null_credops = { · 5 unmodified lines | ||
| 125 | 127 | .crdestroy = nul_destroy_cred, |
| 126 | 128 | .crmatch = nul_match, |
| 127 | 129 | .crmarshal = nul_marshal, |
| 130 | + .crwrap_req = rpcauth_wrap_req_encode, | |
| 128 | 131 | .crrefresh = nul_refresh, |
| 129 | 132 | .crvalidate = nul_validate, |
| 133 | + .crunwrap_resp = rpcauth_unwrap_resp_decode, | |
| 130 | 134 | }; |
| 131 | 135 | |
| 132 | 136 | static |
| @@ -28,8 +28,6 @@ static mempool_t *unix_pool; · 27 unmodified lines | ||
| 28 | 28 | static struct rpc_auth * |
| 29 | 29 | unx_create(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) |
| 30 | 30 | { |
| 31 | − dprintk("RPC: creating UNIX authenticator for client %p\n", | |
| 32 | − clnt); | |
| 33 | 31 | refcount_inc(&unix_auth.au_count); |
| 34 | 32 | return &unix_auth; |
| 35 | 33 | } |
| @@ -37,7 +35,6 @@ unx_create(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt) · 1 unmodified line | ||
| 37 | 35 | static void |
| 38 | 36 | unx_destroy(struct rpc_auth *auth) |
| 39 | 37 | { |
| 40 | − dprintk("RPC: destroying UNIX authenticator %p\n", auth); | |
| 41 | 38 | } |
| 42 | 39 | |
| 43 | 40 | /* |
| @@ -48,10 +45,6 @@ unx_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) · 4 unmodified lines | ||
| 48 | 45 | { |
| 49 | 46 | struct rpc_cred *ret = mempool_alloc(unix_pool, GFP_NOFS); |
| 50 | 47 | |
| 51 | − dprintk("RPC: allocating UNIX cred for uid %d gid %d\n", | |
| 52 | − from_kuid(&init_user_ns, acred->cred->fsuid), | |
| 53 | − from_kgid(&init_user_ns, acred->cred->fsgid)); | |
| 54 | − | |
| 55 | 48 | rpcauth_init_cred(ret, acred, auth, &unix_credops); |
| 56 | 49 | ret->cr_flags = 1UL << RPCAUTH_CRED_UPTODATE; |
| 57 | 50 | return ret; |
| @@ -61,7 +54,7 @@ static void · 3 unmodified lines | ||
| 61 | 54 | unx_free_cred_callback(struct rcu_head *head) |
| 62 | 55 | { |
| 63 | 56 | struct rpc_cred *rpc_cred = container_of(head, struct rpc_cred, cr_rcu); |
| 64 | − dprintk("RPC: unx_free_cred %p\n", rpc_cred); | |
| 57 | + | |
| 65 | 58 | put_cred(rpc_cred->cr_cred); |
| 66 | 59 | mempool_free(rpc_cred, unix_pool); |
| 67 | 60 | } |
| @@ -106,37 +99,55 @@ unx_match(struct auth_cred *acred, struct rpc_cred *cred, int flags) · 38 unmodified lines | ||
| 106 | 99 | * Marshal credentials. |
| 107 | 100 | * Maybe we should keep a cached credential for performance reasons. |
| 108 | 101 | */ |
| 109 | −static __be32 * | |
| 110 | −unx_marshal(struct rpc_task *task, __be32 *p) | |
| 102 | +static int | |
| 103 | +unx_marshal(struct rpc_task *task, struct xdr_stream *xdr) | |
| 111 | 104 | { |
| 112 | 105 | struct rpc_clnt *clnt = task->tk_client; |
| 113 | 106 | struct rpc_cred *cred = task->tk_rqstp->rq_cred; |
| 114 | − __be32 *base, *hold; | |
| 107 | + __be32 *p, *cred_len, *gidarr_len; | |
| 115 | 108 | int i; |
| 116 | 109 | struct group_info *gi = cred->cr_cred->group_info; |
| 117 | 110 | |
| 118 | − *p++ = htonl(RPC_AUTH_UNIX); | |
| 119 | − base = p++; | |
| 120 | − *p++ = htonl(jiffies/HZ); | |
| 121 | − | |
| 122 | − /* | |
| 123 | − * Copy the UTS nodename captured when the client was created. | |
| 124 | − */ | |
| 125 | − p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); | |
| 126 | − | |
| 127 | − *p++ = htonl((u32) from_kuid(&init_user_ns, cred->cr_cred->fsuid)); | |
| 128 | − *p++ = htonl((u32) from_kgid(&init_user_ns, cred->cr_cred->fsgid)); | |
| 129 | − hold = p++; | |
| 111 | + /* Credential */ | |
| 112 | + | |
| 113 | + p = xdr_reserve_space(xdr, 3 * sizeof(*p)); | |
| 114 | + if (!p) | |
| 115 | + goto marshal_failed; | |
| 116 | + *p++ = rpc_auth_unix; | |
| 117 | + cred_len = p++; | |
| 118 | + *p++ = xdr_zero; /* stamp */ | |
| 119 | + if (xdr_stream_encode_opaque(xdr, clnt->cl_nodename, | |
| 120 | + clnt->cl_nodelen) < 0) | |
| 121 | + goto marshal_failed; | |
| 122 | + p = xdr_reserve_space(xdr, 3 * sizeof(*p)); | |
| 123 | + if (!p) | |
| 124 | + goto marshal_failed; | |
| 125 | + *p++ = cpu_to_be32(from_kuid(&init_user_ns, cred->cr_cred->fsuid)); | |
| 126 | + *p++ = cpu_to_be32(from_kgid(&init_user_ns, cred->cr_cred->fsgid)); | |
| 127 | + | |
| 128 | + gidarr_len = p++; | |
| 130 | 129 | if (gi) |
| 131 | 130 | for (i = 0; i < UNX_NGROUPS && i < gi->ngroups; i++) |
| 132 | − *p++ = htonl((u32) from_kgid(&init_user_ns, gi->gid[i])); | |
| 133 | − *hold = htonl(p - hold - 1); /* gid array length */ | |
| 134 | − *base = htonl((p - base - 1) << 2); /* cred length */ | |
| 131 | + *p++ = cpu_to_be32(from_kgid(&init_user_ns, | |
| 132 | + gi->gid[i])); | |
| 133 | + *gidarr_len = cpu_to_be32(p - gidarr_len - 1); | |
| 134 | + *cred_len = cpu_to_be32((p - cred_len - 1) << 2); | |
| 135 | + p = xdr_reserve_space(xdr, (p - gidarr_len - 1) << 2); | |
| 136 | + if (!p) | |
| 137 | + goto marshal_failed; | |
| 138 | + | |
| 139 | + /* Verifier */ | |
| 140 | + | |
| 141 | + p = xdr_reserve_space(xdr, 2 * sizeof(*p)); | |
| 142 | + if (!p) | |
| 143 | + goto marshal_failed; | |
| 144 | + *p++ = rpc_auth_null; | |
| 145 | + *p = xdr_zero; | |
| 135 | 146 | |
| 136 | − *p++ = htonl(RPC_AUTH_NULL); | |
| 137 | − *p++ = htonl(0); | |
| 147 | + return 0; | |
| 138 | 148 | |
| 139 | − return p; | |
| 149 | +marshal_failed: | |
| 150 | + return -EMSGSIZE; | |
| 140 | 151 | } |
| 141 | 152 | |
| 142 | 153 | /* |
| @@ -149,29 +160,35 @@ unx_refresh(struct rpc_task *task) · 6 unmodified lines | ||
| 149 | 160 | return 0; |
| 150 | 161 | } |
| 151 | 162 | |
| 152 | −static __be32 * | |
| 153 | −unx_validate(struct rpc_task *task, __be32 *p) | |
| 163 | +static int | |
| 164 | +unx_validate(struct rpc_task *task, struct xdr_stream *xdr) | |
| 154 | 165 | { |
| 155 | − rpc_authflavor_t flavor; | |
| 156 | − u32 size; | |
| 157 | − | |
| 158 | − flavor = ntohl(*p++); | |
| 159 | − if (flavor != RPC_AUTH_NULL && | |
| 160 | − flavor != RPC_AUTH_UNIX && | |
| 161 | − flavor != RPC_AUTH_SHORT) { | |
| 162 | − printk("RPC: bad verf flavor: %u\n", flavor); | |
| 163 | − return ERR_PTR(-EIO); | |
| 164 | − } | |
| 165 | − | |
| 166 | − size = ntohl(*p++); | |
| 167 | − if (size > RPC_MAX_AUTH_SIZE) { | |
| 168 | − printk("RPC: giant verf size: %u\n", size); | |
| 169 | − return ERR_PTR(-EIO); | |
| 166 | + struct rpc_auth *auth = task->tk_rqstp->rq_cred->cr_auth; | |
| 167 | + __be32 *p; | |
| 168 | + u32 size; | |
| 169 | + | |
| 170 | + p = xdr_inline_decode(xdr, 2 * sizeof(*p)); | |
| 171 | + if (!p) | |
| 172 | + return -EIO; | |
| 173 | + switch (*p++) { | |
| 174 | + case rpc_auth_null: | |
| 175 | + case rpc_auth_unix: | |
| 176 | + case rpc_auth_short: | |
| 177 | + break; | |
| 178 | + default: | |
| 179 | + return -EIO; | |
| 170 | 180 | } |
| 171 | − task->tk_rqstp->rq_cred->cr_auth->au_rslack = (size >> 2) + 2; | |
| 172 | − p += (size >> 2); | |
| 173 | − | |
| 174 | − return p; | |
| 181 | + size = be32_to_cpup(p); | |
| 182 | + if (size > RPC_MAX_AUTH_SIZE) | |
| 183 | + return -EIO; | |
| 184 | + p = xdr_inline_decode(xdr, size); | |
| 185 | + if (!p) | |
| 186 | + return -EIO; | |
| 187 | + | |
| 188 | + auth->au_verfsize = XDR_QUADLEN(size) + 2; | |
| 189 | + auth->au_rslack = XDR_QUADLEN(size) + 2; | |
| 190 | + auth->au_ralign = XDR_QUADLEN(size) + 2; | |
| 191 | + return 0; | |
| 175 | 192 | } |
| 176 | 193 | |
| 177 | 194 | int __init rpc_init_authunix(void) |
| @@ -198,6 +215,7 @@ static · 20 unmodified lines | ||
| 198 | 215 | struct rpc_auth unix_auth = { |
| 199 | 216 | .au_cslack = UNX_CALLSLACK, |
| 200 | 217 | .au_rslack = NUL_REPLYSLACK, |
| 218 | + .au_verfsize = NUL_REPLYSLACK, | |
| 201 | 219 | .au_ops = &authunix_ops, |
| 202 | 220 | .au_flavor = RPC_AUTH_UNIX, |
| 203 | 221 | .au_count = REFCOUNT_INIT(1), |
| @@ -209,6 +227,8 @@ const struct rpc_credops unix_credops = { · 5 unmodified lines | ||
| 209 | 227 | .crdestroy = unx_destroy_cred, |
| 210 | 228 | .crmatch = unx_match, |
| 211 | 229 | .crmarshal = unx_marshal, |
| 230 | + .crwrap_req = rpcauth_wrap_req_encode, | |
| 212 | 231 | .crrefresh = unx_refresh, |
| 213 | 232 | .crvalidate = unx_validate, |
| 233 | + .crunwrap_resp = rpcauth_unwrap_resp_decode, | |
| 214 | 234 | }; |
| @@ -77,8 +77,10 @@ static void call_timeout(struct rpc_task *task); · 76 unmodified lines | ||
| 77 | 77 | static void call_connect(struct rpc_task *task); |
| 78 | 78 | static void call_connect_status(struct rpc_task *task); |
| 79 | 79 | |
| 80 | −static __be32 *rpc_encode_header(struct rpc_task *task); | |
| 81 | −static __be32 *rpc_verify_header(struct rpc_task *task); | |
| 80 | +static int rpc_encode_header(struct rpc_task *task, | |
| 81 | + struct xdr_stream *xdr); | |
| 82 | +static int rpc_decode_header(struct rpc_task *task, | |
| 83 | + struct xdr_stream *xdr); | |
| 82 | 84 | static int rpc_ping(struct rpc_clnt *clnt); |
| 83 | 85 | |
| 84 | 86 | static void rpc_register_client(struct rpc_clnt *clnt) |
| @@ -1162,6 +1164,29 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req) · 1077 unmodified lines | ||
| 1162 | 1164 | } |
| 1163 | 1165 | #endif /* CONFIG_SUNRPC_BACKCHANNEL */ |
| 1164 | 1166 | |
| 1167 | +/** | |
| 1168 | + * rpc_prepare_reply_pages - Prepare to receive a reply data payload into pages | |
| 1169 | + * @req: RPC request to prepare | |
| 1170 | + * @pages: vector of struct page pointers | |
| 1171 | + * @base: offset in first page where receive should start, in bytes | |
| 1172 | + * @len: expected size of the upper layer data payload, in bytes | |
| 1173 | + * @hdrsize: expected size of upper layer reply header, in XDR words | |
| 1174 | + * | |
| 1175 | + */ | |
| 1176 | +void rpc_prepare_reply_pages(struct rpc_rqst *req, struct page **pages, | |
| 1177 | + unsigned int base, unsigned int len, | |
| 1178 | + unsigned int hdrsize) | |
| 1179 | +{ | |
| 1180 | + /* Subtract one to force an extra word of buffer space for the | |
| 1181 | + * payload's XDR pad to fall into the rcv_buf's tail iovec. | |
| 1182 | + */ | |
| 1183 | + hdrsize += RPC_REPHDRSIZE + req->rq_cred->cr_auth->au_ralign - 1; | |
| 1184 | + | |
| 1185 | + xdr_inline_pages(&req->rq_rcv_buf, hdrsize << 2, pages, base, len); | |
| 1186 | + trace_rpc_reply_pages(req); | |
| 1187 | +} | |
| 1188 | +EXPORT_SYMBOL_GPL(rpc_prepare_reply_pages); | |
| 1189 | + | |
| 1165 | 1190 | void |
| 1166 | 1191 | rpc_call_start(struct rpc_task *task) |
| 1167 | 1192 | { |
| @@ -1665,7 +1690,7 @@ call_refreshresult(struct rpc_task *task) · 497 unmodified lines | ||
| 1665 | 1690 | static void |
| 1666 | 1691 | call_allocate(struct rpc_task *task) |
| 1667 | 1692 | { |
| 1668 | − unsigned int slack = task->tk_rqstp->rq_cred->cr_auth->au_cslack; | |
| 1693 | + const struct rpc_auth *auth = task->tk_rqstp->rq_cred->cr_auth; | |
| 1669 | 1694 | struct rpc_rqst *req = task->tk_rqstp; |
| 1670 | 1695 | struct rpc_xprt *xprt = req->rq_xprt; |
| 1671 | 1696 | const struct rpc_procinfo *proc = task->tk_msg.rpc_proc; |
| @@ -1690,9 +1715,10 @@ call_allocate(struct rpc_task *task) · 18 unmodified lines | ||
| 1690 | 1715 | * and reply headers, and convert both values |
| 1691 | 1716 | * to byte sizes. |
| 1692 | 1717 | */ |
| 1693 | − req->rq_callsize = RPC_CALLHDRSIZE + (slack << 1) + proc->p_arglen; | |
| 1718 | + req->rq_callsize = RPC_CALLHDRSIZE + (auth->au_cslack << 1) + | |
| 1719 | + proc->p_arglen; | |
| 1694 | 1720 | req->rq_callsize <<= 2; |
| 1695 | − req->rq_rcvsize = RPC_REPHDRSIZE + slack + proc->p_replen; | |
| 1721 | + req->rq_rcvsize = RPC_REPHDRSIZE + auth->au_rslack + proc->p_replen; | |
| 1696 | 1722 | req->rq_rcvsize <<= 2; |
| 1697 | 1723 | |
| 1698 | 1724 | status = xprt->ops->buf_alloc(task); |
| @@ -1728,10 +1754,7 @@ static void · 29 unmodified lines | ||
| 1728 | 1754 | rpc_xdr_encode(struct rpc_task *task) |
| 1729 | 1755 | { |
| 1730 | 1756 | struct rpc_rqst *req = task->tk_rqstp; |
| 1731 | − kxdreproc_t encode; | |
| 1732 | − __be32 *p; | |
| 1733 | − | |
| 1734 | − dprint_status(task); | |
| 1757 | + struct xdr_stream xdr; | |
| 1735 | 1758 | |
| 1736 | 1759 | xdr_buf_init(&req->rq_snd_buf, |
| 1737 | 1760 | req->rq_buffer, |
| @@ -1740,18 +1763,13 @@ rpc_xdr_encode(struct rpc_task *task) · 2 unmodified lines | ||
| 1740 | 1763 | req->rq_rbuffer, |
| 1741 | 1764 | req->rq_rcvsize); |
| 1742 | 1765 | |
| 1743 | − p = rpc_encode_header(task); | |
| 1744 | − if (p == NULL) | |
| 1745 | − return; | |
| 1746 | − | |
| 1747 | − encode = task->tk_msg.rpc_proc->p_encode; | |
| 1748 | − if (encode == NULL) | |
| 1766 | + req->rq_snd_buf.head[0].iov_len = 0; | |
| 1767 | + xdr_init_encode(&xdr, &req->rq_snd_buf, | |
| 1768 | + req->rq_snd_buf.head[0].iov_base, req); | |
| 1769 | + if (rpc_encode_header(task, &xdr)) | |
| 1749 | 1770 | return; |
| 1750 | 1771 | |
| 1751 | − task->tk_status = rpcauth_wrap_req(task, encode, req, p, | |
| 1752 | − task->tk_msg.rpc_argp); | |
| 1753 | − if (task->tk_status == 0) | |
| 1754 | − xprt_request_prepare(req); | |
| 1772 | + task->tk_status = rpcauth_wrap_req(task, &xdr); | |
| 1755 | 1773 | } |
| 1756 | 1774 | |
| 1757 | 1775 | /* |
| @@ -1762,6 +1780,7 @@ call_encode(struct rpc_task *task) · 4 unmodified lines | ||
| 1762 | 1780 | { |
| 1763 | 1781 | if (!rpc_task_need_encode(task)) |
| 1764 | 1782 | goto out; |
| 1783 | + dprint_status(task); | |
| 1765 | 1784 | /* Encode here so that rpcsec_gss can use correct sequence number. */ |
| 1766 | 1785 | rpc_xdr_encode(task); |
| 1767 | 1786 | /* Did the encode result in an error condition? */ |
| @@ -1779,6 +1798,8 @@ call_encode(struct rpc_task *task) · 11 unmodified lines | ||
| 1779 | 1798 | rpc_exit(task, task->tk_status); |
| 1780 | 1799 | } |
| 1781 | 1800 | return; |
| 1801 | + } else { | |
| 1802 | + xprt_request_prepare(task->tk_rqstp); | |
| 1782 | 1803 | } |
| 1783 | 1804 | |
| 1784 | 1805 | /* Add task to reply queue before transmission to avoid races */ |
| @@ -2255,12 +2276,11 @@ call_decode(struct rpc_task *task) · 470 unmodified lines | ||
| 2255 | 2276 | { |
| 2256 | 2277 | struct rpc_clnt *clnt = task->tk_client; |
| 2257 | 2278 | struct rpc_rqst *req = task->tk_rqstp; |
| 2258 | − kxdrdproc_t decode = task->tk_msg.rpc_proc->p_decode; | |
| 2259 | − __be32 *p; | |
| 2279 | + struct xdr_stream xdr; | |
| 2260 | 2280 | |
| 2261 | 2281 | dprint_status(task); |
| 2262 | 2282 | |
| 2263 | − if (!decode) { | |
| 2283 | + if (!task->tk_msg.rpc_proc->p_decode) { | |
| 2264 | 2284 | task->tk_action = rpc_exit_task; |
| 2265 | 2285 | return; |
| 2266 | 2286 | } |
| @@ -2296,212 +2316,190 @@ call_decode(struct rpc_task *task) · 29 unmodified lines | ||
| 2296 | 2316 | goto out_retry; |
| 2297 | 2317 | } |
| 2298 | 2318 | |
| 2299 | − p = rpc_verify_header(task); | |
| 2300 | − if (IS_ERR(p)) { | |
| 2301 | − if (p == ERR_PTR(-EAGAIN)) | |
| 2302 | − goto out_retry; | |
| 2319 | + xdr_init_decode(&xdr, &req->rq_rcv_buf, | |
| 2320 | + req->rq_rcv_buf.head[0].iov_base, req); | |
| 2321 | + switch (rpc_decode_header(task, &xdr)) { | |
| 2322 | + case 0: | |
| 2323 | + task->tk_action = rpc_exit_task; | |
| 2324 | + task->tk_status = rpcauth_unwrap_resp(task, &xdr); | |
| 2325 | + dprintk("RPC: %5u %s result %d\n", | |
| 2326 | + task->tk_pid, __func__, task->tk_status); | |
| 2303 | 2327 | return; |
| 2304 | − } | |
| 2305 | − task->tk_action = rpc_exit_task; | |
| 2306 | − | |
| 2307 | − task->tk_status = rpcauth_unwrap_resp(task, decode, req, p, | |
| 2308 | − task->tk_msg.rpc_resp); | |
| 2309 | − | |
| 2310 | − dprintk("RPC: %5u call_decode result %d\n", task->tk_pid, | |
| 2311 | − task->tk_status); | |
| 2312 | − return; | |
| 2328 | + case -EAGAIN: | |
| 2313 | 2329 | out_retry: |
| 2314 | − task->tk_status = 0; | |
| 2315 | − /* Note: rpc_verify_header() may have freed the RPC slot */ | |
| 2316 | − if (task->tk_rqstp == req) { | |
| 2317 | − xdr_free_bvec(&req->rq_rcv_buf); | |
| 2318 | − req->rq_reply_bytes_recvd = req->rq_rcv_buf.len = 0; | |
| 2319 | − if (task->tk_client->cl_discrtry) | |
| 2320 | − xprt_conditional_disconnect(req->rq_xprt, | |
| 2321 | − req->rq_connect_cookie); | |
| 2330 | + task->tk_status = 0; | |
| 2331 | + /* Note: rpc_decode_header() may have freed the RPC slot */ | |
| 2332 | + if (task->tk_rqstp == req) { | |
| 2333 | + xdr_free_bvec(&req->rq_rcv_buf); | |
| 2334 | + req->rq_reply_bytes_recvd = 0; | |
| 2335 | + req->rq_rcv_buf.len = 0; | |
| 2336 | + if (task->tk_client->cl_discrtry) | |
| 2337 | + xprt_conditional_disconnect(req->rq_xprt, | |
| 2338 | + req->rq_connect_cookie); | |
| 2339 | + } | |
| 2322 | 2340 | } |
| 2323 | 2341 | } |
| 2324 | 2342 | |
| 2325 | −static __be32 * | |
| 2326 | −rpc_encode_header(struct rpc_task *task) | |
| 2343 | +static int | |
| 2344 | +rpc_encode_header(struct rpc_task *task, struct xdr_stream *xdr) | |
| 2327 | 2345 | { |
| 2328 | 2346 | struct rpc_clnt *clnt = task->tk_client; |
| 2329 | 2347 | struct rpc_rqst *req = task->tk_rqstp; |
| 2330 | − __be32 *p = req->rq_svec[0].iov_base; | |
| 2331 | − | |
| 2332 | − /* FIXME: check buffer size? */ | |
| 2333 | − | |
| 2334 | − p = xprt_skip_transport_header(req->rq_xprt, p); | |
| 2335 | − *p++ = req->rq_xid; /* XID */ | |
| 2336 | − *p++ = htonl(RPC_CALL); /* CALL */ | |
| 2337 | − *p++ = htonl(RPC_VERSION); /* RPC version */ | |
| 2338 | − *p++ = htonl(clnt->cl_prog); /* program number */ | |
| 2339 | − *p++ = htonl(clnt->cl_vers); /* program version */ | |
| 2340 | − *p++ = htonl(task->tk_msg.rpc_proc->p_proc); /* procedure */ | |
| 2341 | − p = rpcauth_marshcred(task, p); | |
| 2342 | − if (p) | |
| 2343 | − req->rq_slen = xdr_adjust_iovec(&req->rq_svec[0], p); | |
| 2344 | − return p; | |
| 2348 | + __be32 *p; | |
| 2349 | + int error; | |
| 2350 | + | |
| 2351 | + error = -EMSGSIZE; | |
| 2352 | + p = xdr_reserve_space(xdr, RPC_CALLHDRSIZE << 2); | |
| 2353 | + if (!p) | |
| 2354 | + goto out_fail; | |
| 2355 | + *p++ = req->rq_xid; | |
| 2356 | + *p++ = rpc_call; | |
| 2357 | + *p++ = cpu_to_be32(RPC_VERSION); | |
| 2358 | + *p++ = cpu_to_be32(clnt->cl_prog); | |
| 2359 | + *p++ = cpu_to_be32(clnt->cl_vers); | |
| 2360 | + *p = cpu_to_be32(task->tk_msg.rpc_proc->p_proc); | |
| 2361 | + | |
| 2362 | + error = rpcauth_marshcred(task, xdr); | |
| 2363 | + if (error < 0) | |
| 2364 | + goto out_fail; | |
| 2365 | + return 0; | |
| 2366 | +out_fail: | |
| 2367 | + trace_rpc_bad_callhdr(task); | |
| 2368 | + rpc_exit(task, error); | |
| 2369 | + return error; | |
| 2345 | 2370 | } |
| 2346 | 2371 | |
| 2347 | −static __be32 * | |
| 2348 | −rpc_verify_header(struct rpc_task *task) | |
| 2372 | +static noinline int | |
| 2373 | +rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr) | |
| 2349 | 2374 | { |
| 2350 | 2375 | struct rpc_clnt *clnt = task->tk_client; |
| 2351 | − struct kvec *iov = &task->tk_rqstp->rq_rcv_buf.head[0]; | |
| 2352 | − int len = task->tk_rqstp->rq_rcv_buf.len >> 2; | |
| 2353 | − __be32 *p = iov->iov_base; | |
| 2354 | − u32 n; | |
| 2355 | 2376 | int error = -EACCES; |
| 2377 | + __be32 *p; | |
| 2356 | 2378 | |
| 2357 | − if ((task->tk_rqstp->rq_rcv_buf.len & 3) != 0) { | |
| 2358 | − /* RFC-1014 says that the representation of XDR data must be a | |
| 2359 | − * multiple of four bytes | |
| 2360 | − * - if it isn't pointer subtraction in the NFS client may give | |
| 2361 | − * undefined results | |
| 2362 | − */ | |
| 2363 | − dprintk("RPC: %5u %s: XDR representation not a multiple of" | |
| 2364 | − " 4 bytes: 0x%x\n", task->tk_pid, __func__, | |
| 2365 | − task->tk_rqstp->rq_rcv_buf.len); | |
| 2366 | − error = -EIO; | |
| 2367 | − goto out_err; | |
| 2368 | − } | |
| 2369 | − if ((len -= 3) < 0) | |
| 2370 | − goto out_overflow; | |
| 2371 | − | |
| 2372 | − p += 1; /* skip XID */ | |
| 2373 | − if ((n = ntohl(*p++)) != RPC_REPLY) { | |
| 2374 | − dprintk("RPC: %5u %s: not an RPC reply: %x\n", | |
| 2375 | − task->tk_pid, __func__, n); | |
| 2376 | − error = -EIO; | |
| 2377 | − goto out_garbage; | |
| 2378 | − } | |
| 2379 | − | |
| 2380 | − if ((n = ntohl(*p++)) != RPC_MSG_ACCEPTED) { | |
| 2381 | − if (--len < 0) | |
| 2382 | − goto out_overflow; | |
| 2383 | − switch ((n = ntohl(*p++))) { | |
| 2384 | − case RPC_AUTH_ERROR: | |
| 2385 | − break; | |
| 2386 | − case RPC_MISMATCH: | |
| 2387 | − dprintk("RPC: %5u %s: RPC call version mismatch!\n", | |
| 2388 | − task->tk_pid, __func__); | |
| 2389 | − error = -EPROTONOSUPPORT; | |
| 2390 | − goto out_err; | |
| 2391 | − default: | |
| 2392 | − dprintk("RPC: %5u %s: RPC call rejected, " | |
| 2393 | − "unknown error: %x\n", | |
| 2394 | − task->tk_pid, __func__, n); | |
| 2395 | − error = -EIO; | |
| 2396 | − goto out_err; | |
| 2397 | − } | |
| 2398 | − if (--len < 0) | |
| 2399 | − goto out_overflow; | |
| 2400 | − switch ((n = ntohl(*p++))) { | |
| 2401 | − case RPC_AUTH_REJECTEDCRED: | |
| 2402 | − case RPC_AUTH_REJECTEDVERF: | |
| 2403 | − case RPCSEC_GSS_CREDPROBLEM: | |
| 2404 | − case RPCSEC_GSS_CTXPROBLEM: | |
| 2405 | − if (!task->tk_cred_retry) | |
| 2406 | − break; | |
| 2407 | − task->tk_cred_retry--; | |
| 2408 | − dprintk("RPC: %5u %s: retry stale creds\n", | |
| 2409 | − task->tk_pid, __func__); | |
| 2410 | − rpcauth_invalcred(task); | |
| 2411 | − /* Ensure we obtain a new XID! */ | |
| 2412 | − xprt_release(task); | |
| 2413 | − task->tk_action = call_reserve; | |
| 2414 | − goto out_retry; | |
| 2415 | − case RPC_AUTH_BADCRED: | |
| 2416 | − case RPC_AUTH_BADVERF: | |
| 2417 | − /* possibly garbled cred/verf? */ | |
| 2418 | − if (!task->tk_garb_retry) | |
| 2419 | − break; | |
| 2420 | − task->tk_garb_retry--; | |
| 2421 | − dprintk("RPC: %5u %s: retry garbled creds\n", | |
| 2422 | − task->tk_pid, __func__); | |
| 2423 | − task->tk_action = call_encode; | |
| 2424 | − goto out_retry; | |
| 2425 | − case RPC_AUTH_TOOWEAK: | |
| 2426 | − printk(KERN_NOTICE "RPC: server %s requires stronger " | |
| 2427 | − "authentication.\n", | |
| 2428 | − task->tk_xprt->servername); | |
| 2429 | − break; | |
| 2430 | − default: | |
| 2431 | − dprintk("RPC: %5u %s: unknown auth error: %x\n", | |
| 2432 | − task->tk_pid, __func__, n); | |
| 2433 | − error = -EIO; | |
| 2434 | − } | |
| 2435 | − dprintk("RPC: %5u %s: call rejected %d\n", | |
| 2436 | − task->tk_pid, __func__, n); | |
| 2437 | − goto out_err; | |
| 2438 | − } | |
| 2439 | − p = rpcauth_checkverf(task, p); | |
| 2440 | − if (IS_ERR(p)) { | |
| 2441 | − error = PTR_ERR(p); | |
| 2442 | − dprintk("RPC: %5u %s: auth check failed with %d\n", | |
| 2443 | − task->tk_pid, __func__, error); | |
| 2444 | − goto out_garbage; /* bad verifier, retry */ | |
| 2445 | − } | |
| 2446 | − len = p - (__be32 *)iov->iov_base - 1; | |
| 2447 | − if (len < 0) | |
| 2448 | − goto out_overflow; | |
| 2449 | − switch ((n = ntohl(*p++))) { | |
| 2450 | − case RPC_SUCCESS: | |
| 2451 | − return p; | |
| 2452 | − case RPC_PROG_UNAVAIL: | |
| 2453 | − dprintk("RPC: %5u %s: program %u is unsupported " | |
| 2454 | − "by server %s\n", task->tk_pid, __func__, | |
| 2455 | − (unsigned int)clnt->cl_prog, | |
| 2456 | − task->tk_xprt->servername); | |
| 2379 | + /* RFC-1014 says that the representation of XDR data must be a | |
| 2380 | + * multiple of four bytes | |
| 2381 | + * - if it isn't pointer subtraction in the NFS client may give | |
| 2382 | + * undefined results | |
| 2383 | + */ | |
| 2384 | + if (task->tk_rqstp->rq_rcv_buf.len & 3) | |
| 2385 | + goto out_badlen; | |
| 2386 | + | |
| 2387 | + p = xdr_inline_decode(xdr, 3 * sizeof(*p)); | |
| 2388 | + if (!p) | |
| 2389 | + goto out_unparsable; | |
| 2390 | + p++; /* skip XID */ | |
| 2391 | + if (*p++ != rpc_reply) | |
| 2392 | + goto out_unparsable; | |
| 2393 | + if (*p++ != rpc_msg_accepted) | |
| 2394 | + goto out_msg_denied; | |
| 2395 | + | |
| 2396 | + error = rpcauth_checkverf(task, xdr); | |
| 2397 | + if (error) | |
| 2398 | + goto out_verifier; | |
| 2399 | + | |
| 2400 | + p = xdr_inline_decode(xdr, sizeof(*p)); | |
| 2401 | + if (!p) | |
| 2402 | + goto out_unparsable; | |
| 2403 | + switch (*p) { | |
| 2404 | + case rpc_success: | |
| 2405 | + return 0; | |
| 2406 | + case rpc_prog_unavail: | |
| 2407 | + trace_rpc__prog_unavail(task); | |
| 2457 | 2408 | error = -EPFNOSUPPORT; |
| 2458 | 2409 | goto out_err; |
| 2459 | − case RPC_PROG_MISMATCH: | |
| 2460 | − dprintk("RPC: %5u %s: program %u, version %u unsupported " | |
| 2461 | − "by server %s\n", task->tk_pid, __func__, | |
| 2462 | − (unsigned int)clnt->cl_prog, | |
| 2463 | − (unsigned int)clnt->cl_vers, | |
| 2464 | − task->tk_xprt->servername); | |
| 2410 | + case rpc_prog_mismatch: | |
| 2411 | + trace_rpc__prog_mismatch(task); | |
| 2465 | 2412 | error = -EPROTONOSUPPORT; |
| 2466 | 2413 | goto out_err; |
| 2467 | − case RPC_PROC_UNAVAIL: | |
| 2468 | − dprintk("RPC: %5u %s: proc %s unsupported by program %u, " | |
| 2469 | − "version %u on server %s\n", | |
| 2470 | − task->tk_pid, __func__, | |
| 2471 | − rpc_proc_name(task), | |
| 2472 | − clnt->cl_prog, clnt->cl_vers, | |
| 2473 | − task->tk_xprt->servername); | |
| 2414 | + case rpc_proc_unavail: | |
| 2415 | + trace_rpc__proc_unavail(task); | |
| 2474 | 2416 | error = -EOPNOTSUPP; |
| 2475 | 2417 | goto out_err; |
| 2476 | − case RPC_GARBAGE_ARGS: | |
| 2477 | − dprintk("RPC: %5u %s: server saw garbage\n", | |
| 2478 | − task->tk_pid, __func__); | |
| 2479 | − break; /* retry */ | |
| 2418 | + case rpc_garbage_args: | |
| 2419 | + trace_rpc__garbage_args(task); | |
| 2420 | + break; | |
| 2480 | 2421 | default: |
| 2481 | − dprintk("RPC: %5u %s: server accept status: %x\n", | |
| 2482 | − task->tk_pid, __func__, n); | |
| 2483 | − /* Also retry */ | |
| 2422 | + trace_rpc__unparsable(task); | |
| 2484 | 2423 | } |
| 2485 | 2424 | |
| 2486 | 2425 | out_garbage: |
| 2487 | 2426 | clnt->cl_stats->rpcgarbage++; |
| 2488 | 2427 | if (task->tk_garb_retry) { |
| 2489 | 2428 | task->tk_garb_retry--; |
| 2490 | − dprintk("RPC: %5u %s: retrying\n", | |
| 2491 | − task->tk_pid, __func__); | |
| 2492 | 2429 | task->tk_action = call_encode; |
| 2493 | −out_retry: | |
| 2494 | − return ERR_PTR(-EAGAIN); | |
| 2430 | + return -EAGAIN; | |
| 2495 | 2431 | } |
| 2496 | 2432 | out_err: |
| 2497 | 2433 | rpc_exit(task, error); |
| 2498 | − dprintk("RPC: %5u %s: call failed with error %d\n", task->tk_pid, | |
| 2499 | − __func__, error); | |
| 2500 | − return ERR_PTR(error); | |
| 2501 | −out_overflow: | |
| 2502 | − dprintk("RPC: %5u %s: server reply was truncated.\n", task->tk_pid, | |
| 2503 | − __func__); | |
| 2434 | + return error; | |
| 2435 | + | |
| 2436 | +out_badlen: | |
| 2437 | + trace_rpc__unparsable(task); | |
| 2438 | + error = -EIO; | |
| 2439 | + goto out_err; | |
| 2440 | + | |
| 2441 | +out_unparsable: | |
| 2442 | + trace_rpc__unparsable(task); | |
| 2443 | + error = -EIO; | |
| 2444 | + goto out_garbage; | |
| 2445 | + | |
| 2446 | +out_verifier: | |
| 2447 | + trace_rpc_bad_verifier(task); | |
| 2504 | 2448 | goto out_garbage; |
| 2449 | + | |
| 2450 | +out_msg_denied: | |
| 2451 | + p = xdr_inline_decode(xdr, sizeof(*p)); | |
| 2452 | + if (!p) | |
| 2453 | + goto out_unparsable; | |
| 2454 | + switch (*p++) { | |
| 2455 | + case rpc_auth_error: | |
| 2456 | + break; | |
| 2457 | + case rpc_mismatch: | |
| 2458 | + trace_rpc__mismatch(task); | |
| 2459 | + error = -EPROTONOSUPPORT; | |
| 2460 | + goto out_err; | |
| 2461 | + default: | |
| 2462 | + trace_rpc__unparsable(task); | |
| 2463 | + error = -EIO; | |
| 2464 | + goto out_err; | |
| 2465 | + } | |
| 2466 | + | |
| 2467 | + p = xdr_inline_decode(xdr, sizeof(*p)); | |
| 2468 | + if (!p) | |
| 2469 | + goto out_unparsable; | |
| 2470 | + switch (*p++) { | |
| 2471 | + case rpc_autherr_rejectedcred: | |
| 2472 | + case rpc_autherr_rejectedverf: | |
| 2473 | + case rpcsec_gsserr_credproblem: | |
| 2474 | + case rpcsec_gsserr_ctxproblem: | |
| 2475 | + if (!task->tk_cred_retry) | |
| 2476 | + break; | |
| 2477 | + task->tk_cred_retry--; | |
| 2478 | + trace_rpc__stale_creds(task); | |
| 2479 | + rpcauth_invalcred(task); | |
| 2480 | + /* Ensure we obtain a new XID! */ | |
| 2481 | + xprt_release(task); | |
| 2482 | + task->tk_action = call_reserve; | |
| 2483 | + return -EAGAIN; | |
| 2484 | + case rpc_autherr_badcred: | |
| 2485 | + case rpc_autherr_badverf: | |
| 2486 | + /* possibly garbled cred/verf? */ | |
| 2487 | + if (!task->tk_garb_retry) | |
| 2488 | + break; | |
| 2489 | + task->tk_garb_retry--; | |
| 2490 | + trace_rpc__bad_creds(task); | |
| 2491 | + task->tk_action = call_encode; | |
| 2492 | + return -EAGAIN; | |
| 2493 | + case rpc_autherr_tooweak: | |
| 2494 | + trace_rpc__auth_tooweak(task); | |
| 2495 | + pr_warn("RPC: server %s requires stronger authentication.\n", | |
| 2496 | + task->tk_xprt->servername); | |
| 2497 | + break; | |
| 2498 | + default: | |
| 2499 | + trace_rpc__unparsable(task); | |
| 2500 | + error = -EIO; | |
| 2501 | + } | |
| 2502 | + goto out_err; | |
| 2505 | 2503 | } |
| 2506 | 2504 | |
| 2507 | 2505 | static void rpcproc_encode_null(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| @@ -1144,17 +1144,6 @@ void svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) · 1143 unmodified lines | ||
| 1144 | 1144 | static __printf(2,3) void svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) {} |
| 1145 | 1145 | #endif |
| 1146 | 1146 | |
| 1147 | −/* | |
| 1148 | − * Setup response header for TCP, it has a 4B record length field. | |
| 1149 | − */ | |
| 1150 | −static void svc_tcp_prep_reply_hdr(struct svc_rqst *rqstp) | |
| 1151 | −{ | |
| 1152 | − struct kvec *resv = &rqstp->rq_res.head[0]; | |
| 1153 | − | |
| 1154 | − /* tcp needs a space for the record length... */ | |
| 1155 | − svc_putnl(resv, 0); | |
| 1156 | −} | |
| 1157 | − | |
| 1158 | 1147 | /* |
| 1159 | 1148 | * Common routine for processing the RPC request. |
| 1160 | 1149 | */ |
| @@ -1182,10 +1171,6 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv) · 21 unmodified lines | ||
| 1182 | 1171 | set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags); |
| 1183 | 1172 | clear_bit(RQ_DROPME, &rqstp->rq_flags); |
| 1184 | 1173 | |
| 1185 | − /* Setup reply header */ | |
| 1186 | − if (rqstp->rq_prot == IPPROTO_TCP) | |
| 1187 | − svc_tcp_prep_reply_hdr(rqstp); | |
| 1188 | − | |
| 1189 | 1174 | svc_putu32(resv, rqstp->rq_xid); |
| 1190 | 1175 | |
| 1191 | 1176 | vers = svc_getnl(argv); |
| @@ -1443,6 +1428,10 @@ svc_process(struct svc_rqst *rqstp) · 251 unmodified lines | ||
| 1443 | 1428 | goto out_drop; |
| 1444 | 1429 | } |
| 1445 | 1430 | |
| 1431 | + /* Reserve space for the record marker */ | |
| 1432 | + if (rqstp->rq_prot == IPPROTO_TCP) | |
| 1433 | + svc_putnl(resv, 0); | |
| 1434 | + | |
| 1446 | 1435 | /* Returns 1 for send, 0 for drop */ |
| 1447 | 1436 | if (likely(svc_process_common(rqstp, argv, resv))) |
| 1448 | 1437 | return svc_send(rqstp); |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | #include <linux/sunrpc/xdr.h> |
| 17 | 17 | #include <linux/sunrpc/msg_prot.h> |
| 18 | 18 | #include <linux/bvec.h> |
| 19 | +#include <trace/events/sunrpc.h> | |
| 19 | 20 | |
| 20 | 21 | /* |
| 21 | 22 | * XDR functions for basic NFS types |
| @@ -162,6 +163,15 @@ xdr_free_bvec(struct xdr_buf *buf) · 140 unmodified lines | ||
| 162 | 163 | buf->bvec = NULL; |
| 163 | 164 | } |
| 164 | 165 | |
| 166 | +/** | |
| 167 | + * xdr_inline_pages - Prepare receive buffer for a large reply | |
| 168 | + * @xdr: xdr_buf into which reply will be placed | |
| 169 | + * @offset: expected offset where data payload will start, in bytes | |
| 170 | + * @pages: vector of struct page pointers | |
| 171 | + * @base: offset in first page where receive should start, in bytes | |
| 172 | + * @len: expected size of the upper layer data payload, in bytes | |
| 173 | + * | |
| 174 | + */ | |
| 165 | 175 | void |
| 166 | 176 | xdr_inline_pages(struct xdr_buf *xdr, unsigned int offset, |
| 167 | 177 | struct page **pages, unsigned int base, unsigned int len) |
| @@ -179,6 +189,8 @@ xdr_inline_pages(struct xdr_buf *xdr, unsigned int offset, · 11 unmodified lines | ||
| 179 | 189 | |
| 180 | 190 | tail->iov_base = buf + offset; |
| 181 | 191 | tail->iov_len = buflen - offset; |
| 192 | + if ((xdr->page_len & 3) == 0) | |
| 193 | + tail->iov_len -= sizeof(__be32); | |
| 182 | 194 | |
| 183 | 195 | xdr->buflen += len; |
| 184 | 196 | } |
| @@ -346,13 +358,15 @@ EXPORT_SYMBOL_GPL(_copy_from_pages); · 161 unmodified lines | ||
| 346 | 358 | * 'len' bytes. The extra data is not lost, but is instead |
| 347 | 359 | * moved into the inlined pages and/or the tail. |
| 348 | 360 | */ |
| 349 | −static void | |
| 361 | +static unsigned int | |
| 350 | 362 | xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) |
| 351 | 363 | { |
| 352 | 364 | struct kvec *head, *tail; |
| 353 | 365 | size_t copy, offs; |
| 354 | 366 | unsigned int pglen = buf->page_len; |
| 367 | + unsigned int result; | |
| 355 | 368 | |
| 369 | + result = 0; | |
| 356 | 370 | tail = buf->tail; |
| 357 | 371 | head = buf->head; |
| 358 | 372 | |
| @@ -366,6 +380,7 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) · 7 unmodified lines | ||
| 366 | 380 | copy = tail->iov_len - len; |
| 367 | 381 | memmove((char *)tail->iov_base + len, |
| 368 | 382 | tail->iov_base, copy); |
| 383 | + result += copy; | |
| 369 | 384 | } |
| 370 | 385 | /* Copy from the inlined pages into the tail */ |
| 371 | 386 | copy = len; |
| @@ -376,11 +391,13 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) · 4 unmodified lines | ||
| 376 | 391 | copy = 0; |
| 377 | 392 | else if (copy > tail->iov_len - offs) |
| 378 | 393 | copy = tail->iov_len - offs; |
| 379 | − if (copy != 0) | |
| 394 | + if (copy != 0) { | |
| 380 | 395 | _copy_from_pages((char *)tail->iov_base + offs, |
| 381 | 396 | buf->pages, |
| 382 | 397 | buf->page_base + pglen + offs - len, |
| 383 | 398 | copy); |
| 399 | + result += copy; | |
| 400 | + } | |
| 384 | 401 | /* Do we also need to copy data from the head into the tail ? */ |
| 385 | 402 | if (len > pglen) { |
| 386 | 403 | offs = copy = len - pglen; |
| @@ -390,6 +407,7 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) · 3 unmodified lines | ||
| 390 | 407 | (char *)head->iov_base + |
| 391 | 408 | head->iov_len - offs, |
| 392 | 409 | copy); |
| 410 | + result += copy; | |
| 393 | 411 | } |
| 394 | 412 | } |
| 395 | 413 | /* Now handle pages */ |
| @@ -405,12 +423,15 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) · 9 unmodified lines | ||
| 405 | 423 | _copy_to_pages(buf->pages, buf->page_base, |
| 406 | 424 | (char *)head->iov_base + head->iov_len - len, |
| 407 | 425 | copy); |
| 426 | + result += copy; | |
| 408 | 427 | } |
| 409 | 428 | head->iov_len -= len; |
| 410 | 429 | buf->buflen -= len; |
| 411 | 430 | /* Have we truncated the message? */ |
| 412 | 431 | if (buf->len > buf->buflen) |
| 413 | 432 | buf->len = buf->buflen; |
| 433 | + | |
| 434 | + return result; | |
| 414 | 435 | } |
| 415 | 436 | |
| 416 | 437 | /** |
| @@ -422,14 +443,16 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len) · 5 unmodified lines | ||
| 422 | 443 | * 'len' bytes. The extra data is not lost, but is instead |
| 423 | 444 | * moved into the tail. |
| 424 | 445 | */ |
| 425 | −static void | |
| 446 | +static unsigned int | |
| 426 | 447 | xdr_shrink_pagelen(struct xdr_buf *buf, size_t len) |
| 427 | 448 | { |
| 428 | 449 | struct kvec *tail; |
| 429 | 450 | size_t copy; |
| 430 | 451 | unsigned int pglen = buf->page_len; |
| 431 | 452 | unsigned int tailbuf_len; |
| 453 | + unsigned int result; | |
| 432 | 454 | |
| 455 | + result = 0; | |
| 433 | 456 | tail = buf->tail; |
| 434 | 457 | BUG_ON (len > pglen); |
| 435 | 458 | |
| @@ -447,18 +470,22 @@ xdr_shrink_pagelen(struct xdr_buf *buf, size_t len) · 11 unmodified lines | ||
| 447 | 470 | if (tail->iov_len > len) { |
| 448 | 471 | char *p = (char *)tail->iov_base + len; |
| 449 | 472 | memmove(p, tail->iov_base, tail->iov_len - len); |
| 473 | + result += tail->iov_len - len; | |
| 450 | 474 | } else |
| 451 | 475 | copy = tail->iov_len; |
| 452 | 476 | /* Copy from the inlined pages into the tail */ |
| 453 | 477 | _copy_from_pages((char *)tail->iov_base, |
| 454 | 478 | buf->pages, buf->page_base + pglen - len, |
| 455 | 479 | copy); |
| 480 | + result += copy; | |
| 456 | 481 | } |
| 457 | 482 | buf->page_len -= len; |
| 458 | 483 | buf->buflen -= len; |
| 459 | 484 | /* Have we truncated the message? */ |
| 460 | 485 | if (buf->len > buf->buflen) |
| 461 | 486 | buf->len = buf->buflen; |
| 487 | + | |
| 488 | + return result; | |
| 462 | 489 | } |
| 463 | 490 | |
| 464 | 491 | void |
| @@ -483,6 +510,7 @@ EXPORT_SYMBOL_GPL(xdr_stream_pos); · 18 unmodified lines | ||
| 483 | 510 | * @xdr: pointer to xdr_stream struct |
| 484 | 511 | * @buf: pointer to XDR buffer in which to encode data |
| 485 | 512 | * @p: current pointer inside XDR buffer |
| 513 | + * @rqst: pointer to controlling rpc_rqst, for debugging | |
| 486 | 514 | * |
| 487 | 515 | * Note: at the moment the RPC client only passes the length of our |
| 488 | 516 | * scratch buffer in the xdr_buf's header kvec. Previously this |
| @@ -491,7 +519,8 @@ EXPORT_SYMBOL_GPL(xdr_stream_pos); · 2 unmodified lines | ||
| 491 | 519 | * of the buffer length, and takes care of adjusting the kvec |
| 492 | 520 | * length for us. |
| 493 | 521 | */ |
| 494 | −void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p) | |
| 522 | +void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p, | |
| 523 | + struct rpc_rqst *rqst) | |
| 495 | 524 | { |
| 496 | 525 | struct kvec *iov = buf->head; |
| 497 | 526 | int scratch_len = buf->buflen - buf->page_len - buf->tail[0].iov_len; |
| @@ -513,6 +542,7 @@ void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p) · 15 unmodified lines | ||
| 513 | 542 | buf->len += len; |
| 514 | 543 | iov->iov_len += len; |
| 515 | 544 | } |
| 545 | + xdr->rqst = rqst; | |
| 516 | 546 | } |
| 517 | 547 | EXPORT_SYMBOL_GPL(xdr_init_encode); |
| 518 | 548 | |
| @@ -551,9 +581,9 @@ static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, · 32 unmodified lines | ||
| 551 | 581 | int frag1bytes, frag2bytes; |
| 552 | 582 | |
| 553 | 583 | if (nbytes > PAGE_SIZE) |
| 554 | − return NULL; /* Bigger buffers require special handling */ | |
| 584 | + goto out_overflow; /* Bigger buffers require special handling */ | |
| 555 | 585 | if (xdr->buf->len + nbytes > xdr->buf->buflen) |
| 556 | − return NULL; /* Sorry, we're totally out of space */ | |
| 586 | + goto out_overflow; /* Sorry, we're totally out of space */ | |
| 557 | 587 | frag1bytes = (xdr->end - xdr->p) << 2; |
| 558 | 588 | frag2bytes = nbytes - frag1bytes; |
| 559 | 589 | if (xdr->iov) |
| @@ -582,6 +612,9 @@ static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, · 22 unmodified lines | ||
| 582 | 612 | xdr->buf->page_len += frag2bytes; |
| 583 | 613 | xdr->buf->len += nbytes; |
| 584 | 614 | return p; |
| 615 | +out_overflow: | |
| 616 | + trace_rpc_xdr_overflow(xdr, nbytes); | |
| 617 | + return NULL; | |
| 585 | 618 | } |
| 586 | 619 | |
| 587 | 620 | /** |
| @@ -819,8 +852,10 @@ static bool xdr_set_next_buffer(struct xdr_stream *xdr) · 231 unmodified lines | ||
| 819 | 852 | * @xdr: pointer to xdr_stream struct |
| 820 | 853 | * @buf: pointer to XDR buffer from which to decode data |
| 821 | 854 | * @p: current pointer inside XDR buffer |
| 855 | + * @rqst: pointer to controlling rpc_rqst, for debugging | |
| 822 | 856 | */ |
| 823 | −void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p) | |
| 857 | +void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p, | |
| 858 | + struct rpc_rqst *rqst) | |
| 824 | 859 | { |
| 825 | 860 | xdr->buf = buf; |
| 826 | 861 | xdr->scratch.iov_base = NULL; |
| @@ -836,6 +871,7 @@ void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p) · 9 unmodified lines | ||
| 836 | 871 | xdr->nwords -= p - xdr->p; |
| 837 | 872 | xdr->p = p; |
| 838 | 873 | } |
| 874 | + xdr->rqst = rqst; | |
| 839 | 875 | } |
| 840 | 876 | EXPORT_SYMBOL_GPL(xdr_init_decode); |
| 841 | 877 | |
| @@ -854,7 +890,7 @@ void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, · 12 unmodified lines | ||
| 854 | 890 | buf->page_len = len; |
| 855 | 891 | buf->buflen = len; |
| 856 | 892 | buf->len = len; |
| 857 | − xdr_init_decode(xdr, buf, NULL); | |
| 893 | + xdr_init_decode(xdr, buf, NULL, NULL); | |
| 858 | 894 | } |
| 859 | 895 | EXPORT_SYMBOL_GPL(xdr_init_decode_pages); |
| 860 | 896 | |
| @@ -896,20 +932,23 @@ static __be32 *xdr_copy_to_scratch(struct xdr_stream *xdr, size_t nbytes) · 35 unmodified lines | ||
| 896 | 932 | size_t cplen = (char *)xdr->end - (char *)xdr->p; |
| 897 | 933 | |
| 898 | 934 | if (nbytes > xdr->scratch.iov_len) |
| 899 | − return NULL; | |
| 935 | + goto out_overflow; | |
| 900 | 936 | p = __xdr_inline_decode(xdr, cplen); |
| 901 | 937 | if (p == NULL) |
| 902 | 938 | return NULL; |
| 903 | 939 | memcpy(cpdest, p, cplen); |
| 940 | + if (!xdr_set_next_buffer(xdr)) | |
| 941 | + goto out_overflow; | |
| 904 | 942 | cpdest += cplen; |
| 905 | 943 | nbytes -= cplen; |
| 906 | − if (!xdr_set_next_buffer(xdr)) | |
| 907 | − return NULL; | |
| 908 | 944 | p = __xdr_inline_decode(xdr, nbytes); |
| 909 | 945 | if (p == NULL) |
| 910 | 946 | return NULL; |
| 911 | 947 | memcpy(cpdest, p, nbytes); |
| 912 | 948 | return xdr->scratch.iov_base; |
| 949 | +out_overflow: | |
| 950 | + trace_rpc_xdr_overflow(xdr, nbytes); | |
| 951 | + return NULL; | |
| 913 | 952 | } |
| 914 | 953 | |
| 915 | 954 | /** |
| @@ -926,14 +965,17 @@ __be32 * xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes) · 10 unmodified lines | ||
| 926 | 965 | { |
| 927 | 966 | __be32 *p; |
| 928 | 967 | |
| 929 | − if (nbytes == 0) | |
| 968 | + if (unlikely(nbytes == 0)) | |
| 930 | 969 | return xdr->p; |
| 931 | 970 | if (xdr->p == xdr->end && !xdr_set_next_buffer(xdr)) |
| 932 | − return NULL; | |
| 971 | + goto out_overflow; | |
| 933 | 972 | p = __xdr_inline_decode(xdr, nbytes); |
| 934 | 973 | if (p != NULL) |
| 935 | 974 | return p; |
| 936 | 975 | return xdr_copy_to_scratch(xdr, nbytes); |
| 976 | +out_overflow: | |
| 977 | + trace_rpc_xdr_overflow(xdr, nbytes); | |
| 978 | + return NULL; | |
| 937 | 979 | } |
| 938 | 980 | EXPORT_SYMBOL_GPL(xdr_inline_decode); |
| 939 | 981 | |
| @@ -943,13 +985,17 @@ static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len) · 3 unmodified lines | ||
| 943 | 985 | struct kvec *iov; |
| 944 | 986 | unsigned int nwords = XDR_QUADLEN(len); |
| 945 | 987 | unsigned int cur = xdr_stream_pos(xdr); |
| 988 | + unsigned int copied, offset; | |
| 946 | 989 | |
| 947 | 990 | if (xdr->nwords == 0) |
| 948 | 991 | return 0; |
| 992 | + | |
| 949 | 993 | /* Realign pages to current pointer position */ |
| 950 | − iov = buf->head; | |
| 994 | + iov = buf->head; | |
| 951 | 995 | if (iov->iov_len > cur) { |
| 952 | − xdr_shrink_bufhead(buf, iov->iov_len - cur); | |
| 996 | + offset = iov->iov_len - cur; | |
| 997 | + copied = xdr_shrink_bufhead(buf, offset); | |
| 998 | + trace_rpc_xdr_alignment(xdr, offset, copied); | |
| 953 | 999 | xdr->nwords = XDR_QUADLEN(buf->len - cur); |
| 954 | 1000 | } |
| 955 | 1001 | |
| @@ -961,7 +1007,9 @@ static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len) · 5 unmodified lines | ||
| 961 | 1007 | len = buf->page_len; |
| 962 | 1008 | else if (nwords < xdr->nwords) { |
| 963 | 1009 | /* Truncate page data and move it into the tail */ |
| 964 | − xdr_shrink_pagelen(buf, buf->page_len - len); | |
| 1010 | + offset = buf->page_len - len; | |
| 1011 | + copied = xdr_shrink_pagelen(buf, offset); | |
| 1012 | + trace_rpc_xdr_alignment(xdr, offset, copied); | |
| 965 | 1013 | xdr->nwords = XDR_QUADLEN(buf->len - cur); |
| 966 | 1014 | } |
| 967 | 1015 | return len; |
| @@ -1102,47 +1150,6 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf, · 134 unmodified lines | ||
| 1102 | 1150 | } |
| 1103 | 1151 | EXPORT_SYMBOL_GPL(xdr_buf_subsegment); |
| 1104 | 1152 | |
| 1105 | −/** | |
| 1106 | − * xdr_buf_trim - lop at most "len" bytes off the end of "buf" | |
| 1107 | − * @buf: buf to be trimmed | |
| 1108 | − * @len: number of bytes to reduce "buf" by | |
| 1109 | − * | |
| 1110 | − * Trim an xdr_buf by the given number of bytes by fixing up the lengths. Note | |
| 1111 | − * that it's possible that we'll trim less than that amount if the xdr_buf is | |
| 1112 | − * too small, or if (for instance) it's all in the head and the parser has | |
| 1113 | − * already read too far into it. | |
| 1114 | − */ | |
| 1115 | −void xdr_buf_trim(struct xdr_buf *buf, unsigned int len) | |
| 1116 | −{ | |
| 1117 | − size_t cur; | |
| 1118 | − unsigned int trim = len; | |
| 1119 | − | |
| 1120 | − if (buf->tail[0].iov_len) { | |
| 1121 | − cur = min_t(size_t, buf->tail[0].iov_len, trim); | |
| 1122 | − buf->tail[0].iov_len -= cur; | |
| 1123 | − trim -= cur; | |
| 1124 | − if (!trim) | |
| 1125 | − goto fix_len; | |
| 1126 | − } | |
| 1127 | − | |
| 1128 | − if (buf->page_len) { | |
| 1129 | − cur = min_t(unsigned int, buf->page_len, trim); | |
| 1130 | − buf->page_len -= cur; | |
| 1131 | − trim -= cur; | |
| 1132 | − if (!trim) | |
| 1133 | − goto fix_len; | |
| 1134 | − } | |
| 1135 | − | |
| 1136 | − if (buf->head[0].iov_len) { | |
| 1137 | − cur = min_t(size_t, buf->head[0].iov_len, trim); | |
| 1138 | − buf->head[0].iov_len -= cur; | |
| 1139 | − trim -= cur; | |
| 1140 | − } | |
| 1141 | −fix_len: | |
| 1142 | − buf->len -= (len - trim); | |
| 1143 | −} | |
| 1144 | −EXPORT_SYMBOL_GPL(xdr_buf_trim); | |
| 1145 | − | |
| 1146 | 1153 | static void __read_bytes_from_xdr_buf(struct xdr_buf *subbuf, void *obj, unsigned int len) |
| 1147 | 1154 | { |
| 1148 | 1155 | unsigned int this_len; |
| @@ -1168,6 +1168,7 @@ xprt_request_enqueue_transmit(struct rpc_task *task) · 1167 unmodified lines | ||
| 1168 | 1168 | /* Note: req is added _before_ pos */ |
| 1169 | 1169 | list_add_tail(&req->rq_xmit, &pos->rq_xmit); |
| 1170 | 1170 | INIT_LIST_HEAD(&req->rq_xmit2); |
| 1171 | + trace_xprt_enq_xmit(task, 1); | |
| 1171 | 1172 | goto out; |
| 1172 | 1173 | } |
| 1173 | 1174 | } else if (RPC_IS_SWAPPER(task)) { |
| @@ -1179,6 +1180,7 @@ xprt_request_enqueue_transmit(struct rpc_task *task) · 5 unmodified lines | ||
| 1179 | 1180 | /* Note: req is added _before_ pos */ |
| 1180 | 1181 | list_add_tail(&req->rq_xmit, &pos->rq_xmit); |
| 1181 | 1182 | INIT_LIST_HEAD(&req->rq_xmit2); |
| 1183 | + trace_xprt_enq_xmit(task, 2); | |
| 1182 | 1184 | goto out; |
| 1183 | 1185 | } |
| 1184 | 1186 | } else if (!req->rq_seqno) { |
| @@ -1187,11 +1189,13 @@ xprt_request_enqueue_transmit(struct rpc_task *task) · 2 unmodified lines | ||
| 1187 | 1189 | continue; |
| 1188 | 1190 | list_add_tail(&req->rq_xmit2, &pos->rq_xmit2); |
| 1189 | 1191 | INIT_LIST_HEAD(&req->rq_xmit); |
| 1192 | + trace_xprt_enq_xmit(task, 3); | |
| 1190 | 1193 | goto out; |
| 1191 | 1194 | } |
| 1192 | 1195 | } |
| 1193 | 1196 | list_add_tail(&req->rq_xmit, &xprt->xmit_queue); |
| 1194 | 1197 | INIT_LIST_HEAD(&req->rq_xmit2); |
| 1198 | + trace_xprt_enq_xmit(task, 4); | |
| 1195 | 1199 | out: |
| 1196 | 1200 | set_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate); |
| 1197 | 1201 | spin_unlock(&xprt->queue_lock); |
| @@ -1316,8 +1320,6 @@ xprt_request_transmit(struct rpc_rqst *req, struct rpc_task *snd_task) · 118 unmodified lines | ||
| 1316 | 1320 | int is_retrans = RPC_WAS_SENT(task); |
| 1317 | 1321 | int status; |
| 1318 | 1322 | |
| 1319 | − dprintk("RPC: %5u xprt_transmit(%u)\n", task->tk_pid, req->rq_slen); | |
| 1320 | − | |
| 1321 | 1323 | if (!req->rq_bytes_sent) { |
| 1322 | 1324 | if (xprt_request_data_received(task)) { |
| 1323 | 1325 | status = 0; |
| @@ -1339,9 +1341,9 @@ xprt_request_transmit(struct rpc_rqst *req, struct rpc_task *snd_task) · 15 unmodified lines | ||
| 1339 | 1341 | |
| 1340 | 1342 | connect_cookie = xprt->connect_cookie; |
| 1341 | 1343 | status = xprt->ops->send_request(req); |
| 1342 | − trace_xprt_transmit(xprt, req->rq_xid, status); | |
| 1343 | 1344 | if (status != 0) { |
| 1344 | 1345 | req->rq_ntrans--; |
| 1346 | + trace_xprt_transmit(req, status); | |
| 1345 | 1347 | return status; |
| 1346 | 1348 | } |
| 1347 | 1349 | |
| @@ -1350,7 +1352,6 @@ xprt_request_transmit(struct rpc_rqst *req, struct rpc_task *snd_task) · 2 unmodified lines | ||
| 1350 | 1352 | |
| 1351 | 1353 | xprt_inject_disconnect(xprt); |
| 1352 | 1354 | |
| 1353 | − dprintk("RPC: %5u xmit complete\n", task->tk_pid); | |
| 1354 | 1355 | task->tk_flags |= RPC_TASK_SENT; |
| 1355 | 1356 | spin_lock_bh(&xprt->transport_lock); |
| 1356 | 1357 | |
| @@ -1363,6 +1364,7 @@ xprt_request_transmit(struct rpc_rqst *req, struct rpc_task *snd_task) · 6 unmodified lines | ||
| 1363 | 1364 | |
| 1364 | 1365 | req->rq_connect_cookie = connect_cookie; |
| 1365 | 1366 | out_dequeue: |
| 1367 | + trace_xprt_transmit(req, status); | |
| 1366 | 1368 | xprt_request_dequeue_transmit(task); |
| 1367 | 1369 | rpc_wake_up_queued_task_set_status(&xprt->sending, task, status); |
| 1368 | 1370 | return status; |
| @@ -123,7 +123,7 @@ static int rpcrdma_bc_marshal_reply(struct rpc_rqst *rqst) · 122 unmodified lines | ||
| 123 | 123 | |
| 124 | 124 | rpcrdma_set_xdrlen(&req->rl_hdrbuf, 0); |
| 125 | 125 | xdr_init_encode(&req->rl_stream, &req->rl_hdrbuf, |
| 126 | − req->rl_rdmabuf->rg_base); | |
| 126 | + req->rl_rdmabuf->rg_base, rqst); | |
| 127 | 127 | |
| 128 | 128 | p = xdr_reserve_space(&req->rl_stream, 28); |
| 129 | 129 | if (unlikely(!p)) |
| @@ -391,7 +391,7 @@ frwr_wc_localinv_wake(struct ib_cq *cq, struct ib_wc *wc) · 390 unmodified lines | ||
| 391 | 391 | */ |
| 392 | 392 | struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt, |
| 393 | 393 | struct rpcrdma_mr_seg *seg, |
| 394 | − int nsegs, bool writing, u32 xid, | |
| 394 | + int nsegs, bool writing, __be32 xid, | |
| 395 | 395 | struct rpcrdma_mr **out) |
| 396 | 396 | { |
| 397 | 397 | struct rpcrdma_ia *ia = &r_xprt->rx_ia; |
| @@ -446,7 +446,7 @@ struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt, · 48 unmodified lines | ||
| 446 | 446 | goto out_mapmr_err; |
| 447 | 447 | |
| 448 | 448 | ibmr->iova &= 0x00000000ffffffff; |
| 449 | − ibmr->iova |= ((u64)cpu_to_be32(xid)) << 32; | |
| 449 | + ibmr->iova |= ((u64)be32_to_cpu(xid)) << 32; | |
| 450 | 450 | key = (u8)(ibmr->rkey & 0x000000FF); |
| 451 | 451 | ib_update_fast_reg_key(ibmr, ++key); |
| 452 | 452 | |
| @@ -164,6 +164,21 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, · 163 unmodified lines | ||
| 164 | 164 | return rqst->rq_rcv_buf.buflen <= ia->ri_max_inline_read; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | +/* The client is required to provide a Reply chunk if the maximum | |
| 168 | + * size of the non-payload part of the RPC Reply is larger than | |
| 169 | + * the inline threshold. | |
| 170 | + */ | |
| 171 | +static bool | |
| 172 | +rpcrdma_nonpayload_inline(const struct rpcrdma_xprt *r_xprt, | |
| 173 | + const struct rpc_rqst *rqst) | |
| 174 | +{ | |
| 175 | + const struct xdr_buf *buf = &rqst->rq_rcv_buf; | |
| 176 | + const struct rpcrdma_ia *ia = &r_xprt->rx_ia; | |
| 177 | + | |
| 178 | + return buf->head[0].iov_len + buf->tail[0].iov_len < | |
| 179 | + ia->ri_max_inline_read; | |
| 180 | +} | |
| 181 | + | |
| 167 | 182 | /* Split @vec on page boundaries into SGEs. FMR registers pages, not |
| 168 | 183 | * a byte range. Other modes coalesce these SGEs into a single MR |
| 169 | 184 | * when they can. |
| @@ -733,7 +748,7 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst) · 563 unmodified lines | ||
| 733 | 748 | |
| 734 | 749 | rpcrdma_set_xdrlen(&req->rl_hdrbuf, 0); |
| 735 | 750 | xdr_init_encode(xdr, &req->rl_hdrbuf, |
| 736 | − req->rl_rdmabuf->rg_base); | |
| 751 | + req->rl_rdmabuf->rg_base, rqst); | |
| 737 | 752 | |
| 738 | 753 | /* Fixed header fields */ |
| 739 | 754 | ret = -EMSGSIZE; |
| @@ -762,7 +777,8 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst) · 22 unmodified lines | ||
| 762 | 777 | */ |
| 763 | 778 | if (rpcrdma_results_inline(r_xprt, rqst)) |
| 764 | 779 | wtype = rpcrdma_noch; |
| 765 | − else if (ddp_allowed && rqst->rq_rcv_buf.flags & XDRBUF_READ) | |
| 780 | + else if ((ddp_allowed && rqst->rq_rcv_buf.flags & XDRBUF_READ) && | |
| 781 | + rpcrdma_nonpayload_inline(r_xprt, rqst)) | |
| 766 | 782 | wtype = rpcrdma_writech; |
| 767 | 783 | else |
| 768 | 784 | wtype = rpcrdma_replych; |
| @@ -1313,7 +1329,7 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *rep) · 544 unmodified lines | ||
| 1313 | 1329 | |
| 1314 | 1330 | /* Fixed transport header fields */ |
| 1315 | 1331 | xdr_init_decode(&rep->rr_stream, &rep->rr_hdrbuf, |
| 1316 | − rep->rr_hdrbuf.head[0].iov_base); | |
| 1332 | + rep->rr_hdrbuf.head[0].iov_base, NULL); | |
| 1317 | 1333 | p = xdr_inline_decode(&rep->rr_stream, 4 * sizeof(*p)); |
| 1318 | 1334 | if (unlikely(!p)) |
| 1319 | 1335 | goto out_shortreply; |
| @@ -304,7 +304,6 @@ xprt_setup_rdma_bc(struct xprt_create *args) · 303 unmodified lines | ||
| 304 | 304 | xprt->idle_timeout = RPCRDMA_IDLE_DISC_TO; |
| 305 | 305 | |
| 306 | 306 | xprt->prot = XPRT_TRANSPORT_BC_RDMA; |
| 307 | − xprt->tsh_size = 0; | |
| 308 | 307 | xprt->ops = &xprt_rdma_bc_procs; |
| 309 | 308 | |
| 310 | 309 | memcpy(&xprt->addr, args->dstaddr, args->addrlen); |
| @@ -332,7 +332,6 @@ xprt_setup_rdma(struct xprt_create *args) · 331 unmodified lines | ||
| 332 | 332 | xprt->idle_timeout = RPCRDMA_IDLE_DISC_TO; |
| 333 | 333 | |
| 334 | 334 | xprt->resvport = 0; /* privileged port not needed */ |
| 335 | − xprt->tsh_size = 0; /* RPC-RDMA handles framing */ | |
| 336 | 335 | xprt->ops = &xprt_rdma_procs; |
| 337 | 336 | |
| 338 | 337 | /* |
| @@ -1481,6 +1481,8 @@ rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp) · 1480 unmodified lines | ||
| 1481 | 1481 | if (ep->rep_receive_count > needed) |
| 1482 | 1482 | goto out; |
| 1483 | 1483 | needed -= ep->rep_receive_count; |
| 1484 | + if (!temp) | |
| 1485 | + needed += RPCRDMA_MAX_RECV_BATCH; | |
| 1484 | 1486 | |
| 1485 | 1487 | count = 0; |
| 1486 | 1488 | wr = NULL; |
| @@ -205,6 +205,16 @@ struct rpcrdma_rep { · 204 unmodified lines | ||
| 205 | 205 | struct ib_recv_wr rr_recv_wr; |
| 206 | 206 | }; |
| 207 | 207 | |
| 208 | +/* To reduce the rate at which a transport invokes ib_post_recv | |
| 209 | + * (and thus the hardware doorbell rate), xprtrdma posts Receive | |
| 210 | + * WRs in batches. | |
| 211 | + * | |
| 212 | + * Setting this to zero disables Receive post batching. | |
| 213 | + */ | |
| 214 | +enum { | |
| 215 | + RPCRDMA_MAX_RECV_BATCH = 7, | |
| 216 | +}; | |
| 217 | + | |
| 208 | 218 | /* struct rpcrdma_sendctx - DMA mapped SGEs to unmap after Send completes |
| 209 | 219 | */ |
| 210 | 220 | struct rpcrdma_req; |
| @@ -577,7 +587,7 @@ void frwr_release_mr(struct rpcrdma_mr *mr); · 366 unmodified lines | ||
| 577 | 587 | size_t frwr_maxpages(struct rpcrdma_xprt *r_xprt); |
| 578 | 588 | struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt, |
| 579 | 589 | struct rpcrdma_mr_seg *seg, |
| 580 | − int nsegs, bool writing, u32 xid, | |
| 590 | + int nsegs, bool writing, __be32 xid, | |
| 581 | 591 | struct rpcrdma_mr **mr); |
| 582 | 592 | int frwr_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req); |
| 583 | 593 | void frwr_reminv(struct rpcrdma_rep *rep, struct list_head *mrs); |
| @@ -769,6 +769,29 @@ static int xs_send_pagedata(struct socket *sock, struct msghdr *msg, struct xdr_ · 768 unmodified lines | ||
| 769 | 769 | return xs_sendmsg(sock, msg, base + xdr->page_base); |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | +#define xs_record_marker_len() sizeof(rpc_fraghdr) | |
| 773 | + | |
| 774 | +/* Common case: | |
| 775 | + * - stream transport | |
| 776 | + * - sending from byte 0 of the message | |
| 777 | + * - the message is wholly contained in @xdr's head iovec | |
| 778 | + */ | |
| 779 | +static int xs_send_rm_and_kvec(struct socket *sock, struct msghdr *msg, | |
| 780 | + rpc_fraghdr marker, struct kvec *vec, size_t base) | |
| 781 | +{ | |
| 782 | + struct kvec iov[2] = { | |
| 783 | + [0] = { | |
| 784 | + .iov_base = &marker, | |
| 785 | + .iov_len = sizeof(marker) | |
| 786 | + }, | |
| 787 | + [1] = *vec, | |
| 788 | + }; | |
| 789 | + size_t len = iov[0].iov_len + iov[1].iov_len; | |
| 790 | + | |
| 791 | + iov_iter_kvec(&msg->msg_iter, WRITE, iov, 2, len); | |
| 792 | + return xs_sendmsg(sock, msg, base); | |
| 793 | +} | |
| 794 | + | |
| 772 | 795 | /** |
| 773 | 796 | * xs_sendpages - write pages directly to a socket |
| 774 | 797 | * @sock: socket to send on |
| @@ -776,34 +799,42 @@ static int xs_send_pagedata(struct socket *sock, struct msghdr *msg, struct xdr_ · 1 unmodified line | ||
| 776 | 799 | * @addrlen: UDP only -- length of destination address |
| 777 | 800 | * @xdr: buffer containing this request |
| 778 | 801 | * @base: starting position in the buffer |
| 802 | + * @rm: stream record marker field | |
| 779 | 803 | * @sent_p: return the total number of bytes successfully queued for sending |
| 780 | 804 | * |
| 781 | 805 | */ |
| 782 | −static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, int *sent_p) | |
| 806 | +static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, rpc_fraghdr rm, int *sent_p) | |
| 783 | 807 | { |
| 784 | 808 | struct msghdr msg = { |
| 785 | 809 | .msg_name = addr, |
| 786 | 810 | .msg_namelen = addrlen, |
| 787 | 811 | .msg_flags = XS_SENDMSG_FLAGS | MSG_MORE, |
| 788 | 812 | }; |
| 789 | − unsigned int remainder = xdr->len - base; | |
| 813 | + unsigned int rmsize = rm ? sizeof(rm) : 0; | |
| 814 | + unsigned int remainder = rmsize + xdr->len - base; | |
| 815 | + unsigned int want; | |
| 790 | 816 | int err = 0; |
| 791 | 817 | |
| 792 | 818 | if (unlikely(!sock)) |
| 793 | 819 | return -ENOTSOCK; |
| 794 | 820 | |
| 795 | − if (base < xdr->head[0].iov_len) { | |
| 796 | − unsigned int len = xdr->head[0].iov_len - base; | |
| 821 | + want = xdr->head[0].iov_len + rmsize; | |
| 822 | + if (base < want) { | |
| 823 | + unsigned int len = want - base; | |
| 797 | 824 | remainder -= len; |
| 798 | 825 | if (remainder == 0) |
| 799 | 826 | msg.msg_flags &= ~MSG_MORE; |
| 800 | − err = xs_send_kvec(sock, &msg, &xdr->head[0], base); | |
| 827 | + if (rmsize) | |
| 828 | + err = xs_send_rm_and_kvec(sock, &msg, rm, | |
| 829 | + &xdr->head[0], base); | |
| 830 | + else | |
| 831 | + err = xs_send_kvec(sock, &msg, &xdr->head[0], base); | |
| 801 | 832 | if (remainder == 0 || err != len) |
| 802 | 833 | goto out; |
| 803 | 834 | *sent_p += err; |
| 804 | 835 | base = 0; |
| 805 | 836 | } else |
| 806 | − base -= xdr->head[0].iov_len; | |
| 837 | + base -= want; | |
| 807 | 838 | |
| 808 | 839 | if (base < xdr->page_len) { |
| 809 | 840 | unsigned int len = xdr->page_len - base; |
| @@ -891,13 +922,14 @@ xs_send_request_was_aborted(struct sock_xprt *transport, struct rpc_rqst *req) · 81 unmodified lines | ||
| 891 | 922 | } |
| 892 | 923 | |
| 893 | 924 | /* |
| 894 | − * Construct a stream transport record marker in @buf. | |
| 925 | + * Return the stream record marker field for a record of length < 2^31-1 | |
| 895 | 926 | */ |
| 896 | −static inline void xs_encode_stream_record_marker(struct xdr_buf *buf) | |
| 927 | +static rpc_fraghdr | |
| 928 | +xs_stream_record_marker(struct xdr_buf *xdr) | |
| 897 | 929 | { |
| 898 | − u32 reclen = buf->len - sizeof(rpc_fraghdr); | |
| 899 | − rpc_fraghdr *base = buf->head[0].iov_base; | |
| 900 | − *base = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | reclen); | |
| 930 | + if (!xdr->len) | |
| 931 | + return 0; | |
| 932 | + return cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | (u32)xdr->len); | |
| 901 | 933 | } |
| 902 | 934 | |
| 903 | 935 | /** |
| @@ -926,14 +958,13 @@ static int xs_local_send_request(struct rpc_rqst *req) · 22 unmodified lines | ||
| 926 | 958 | return -ENOTCONN; |
| 927 | 959 | } |
| 928 | 960 | |
| 929 | − xs_encode_stream_record_marker(&req->rq_snd_buf); | |
| 930 | − | |
| 931 | 961 | xs_pktdump("packet data:", |
| 932 | 962 | req->rq_svec->iov_base, req->rq_svec->iov_len); |
| 933 | 963 | |
| 934 | 964 | req->rq_xtime = ktime_get(); |
| 935 | 965 | status = xs_sendpages(transport->sock, NULL, 0, xdr, |
| 936 | 966 | transport->xmit.offset, |
| 967 | + xs_stream_record_marker(xdr), | |
| 937 | 968 | &sent); |
| 938 | 969 | dprintk("RPC: %s(%u) = %d\n", |
| 939 | 970 | __func__, xdr->len - transport->xmit.offset, status); |
| @@ -1001,7 +1032,7 @@ static int xs_udp_send_request(struct rpc_rqst *req) · 61 unmodified lines | ||
| 1001 | 1032 | |
| 1002 | 1033 | req->rq_xtime = ktime_get(); |
| 1003 | 1034 | status = xs_sendpages(transport->sock, xs_addr(xprt), xprt->addrlen, |
| 1004 | − xdr, 0, &sent); | |
| 1035 | + xdr, 0, 0, &sent); | |
| 1005 | 1036 | |
| 1006 | 1037 | dprintk("RPC: xs_udp_send_request(%u) = %d\n", |
| 1007 | 1038 | xdr->len, status); |
| @@ -1076,8 +1107,6 @@ static int xs_tcp_send_request(struct rpc_rqst *req) · 68 unmodified lines | ||
| 1076 | 1107 | return -ENOTCONN; |
| 1077 | 1108 | } |
| 1078 | 1109 | |
| 1079 | − xs_encode_stream_record_marker(&req->rq_snd_buf); | |
| 1080 | − | |
| 1081 | 1110 | xs_pktdump("packet data:", |
| 1082 | 1111 | req->rq_svec->iov_base, |
| 1083 | 1112 | req->rq_svec->iov_len); |
| @@ -1093,6 +1122,7 @@ static int xs_tcp_send_request(struct rpc_rqst *req) · 9 unmodified lines | ||
| 1093 | 1122 | sent = 0; |
| 1094 | 1123 | status = xs_sendpages(transport->sock, NULL, 0, xdr, |
| 1095 | 1124 | transport->xmit.offset, |
| 1125 | + xs_stream_record_marker(xdr), | |
| 1096 | 1126 | &sent); |
| 1097 | 1127 | |
| 1098 | 1128 | dprintk("RPC: xs_tcp_send_request(%u) = %d\n", |
| @@ -2547,26 +2577,35 @@ static int bc_sendto(struct rpc_rqst *req) · 1448 unmodified lines | ||
| 2547 | 2577 | { |
| 2548 | 2578 | int len; |
| 2549 | 2579 | struct xdr_buf *xbufp = &req->rq_snd_buf; |
| 2550 | − struct rpc_xprt *xprt = req->rq_xprt; | |
| 2551 | 2580 | struct sock_xprt *transport = |
| 2552 | − container_of(xprt, struct sock_xprt, xprt); | |
| 2553 | − struct socket *sock = transport->sock; | |
| 2581 | + container_of(req->rq_xprt, struct sock_xprt, xprt); | |
| 2554 | 2582 | unsigned long headoff; |
| 2555 | 2583 | unsigned long tailoff; |
| 2584 | + struct page *tailpage; | |
| 2585 | + struct msghdr msg = { | |
| 2586 | + .msg_flags = MSG_MORE | |
| 2587 | + }; | |
| 2588 | + rpc_fraghdr marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | | |
| 2589 | + (u32)xbufp->len); | |
| 2590 | + struct kvec iov = { | |
| 2591 | + .iov_base = &marker, | |
| 2592 | + .iov_len = sizeof(marker), | |
| 2593 | + }; | |
| 2556 | 2594 | |
| 2557 | − xs_encode_stream_record_marker(xbufp); | |
| 2595 | + len = kernel_sendmsg(transport->sock, &msg, &iov, 1, iov.iov_len); | |
| 2596 | + if (len != iov.iov_len) | |
| 2597 | + return -EAGAIN; | |
| 2558 | 2598 | |
| 2599 | + tailpage = NULL; | |
| 2600 | + if (xbufp->tail[0].iov_len) | |
| 2601 | + tailpage = virt_to_page(xbufp->tail[0].iov_base); | |
| 2559 | 2602 | tailoff = (unsigned long)xbufp->tail[0].iov_base & ~PAGE_MASK; |
| 2560 | 2603 | headoff = (unsigned long)xbufp->head[0].iov_base & ~PAGE_MASK; |
| 2561 | − len = svc_send_common(sock, xbufp, | |
| 2604 | + len = svc_send_common(transport->sock, xbufp, | |
| 2562 | 2605 | virt_to_page(xbufp->head[0].iov_base), headoff, |
| 2563 | − xbufp->tail[0].iov_base, tailoff); | |
| 2564 | − | |
| 2565 | − if (len != xbufp->len) { | |
| 2566 | − printk(KERN_NOTICE "Error sending entire callback!\n"); | |
| 2567 | − len = -EAGAIN; | |
| 2568 | − } | |
| 2569 | − | |
| 2606 | + tailpage, tailoff); | |
| 2607 | + if (len != xbufp->len) | |
| 2608 | + return -EAGAIN; | |
| 2570 | 2609 | return len; |
| 2571 | 2610 | } |
| 2572 | 2611 | |
| @@ -2806,7 +2845,6 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args) · 233 unmodified lines | ||
| 2806 | 2845 | transport = container_of(xprt, struct sock_xprt, xprt); |
| 2807 | 2846 | |
| 2808 | 2847 | xprt->prot = 0; |
| 2809 | − xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); | |
| 2810 | 2848 | xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; |
| 2811 | 2849 | |
| 2812 | 2850 | xprt->bind_timeout = XS_BIND_TO; |
| @@ -2875,7 +2913,6 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args) · 62 unmodified lines | ||
| 2875 | 2913 | transport = container_of(xprt, struct sock_xprt, xprt); |
| 2876 | 2914 | |
| 2877 | 2915 | xprt->prot = IPPROTO_UDP; |
| 2878 | − xprt->tsh_size = 0; | |
| 2879 | 2916 | /* XXX: header size can vary due to auth type, IPv6, etc. */ |
| 2880 | 2917 | xprt->max_payload = (1U << 16) - (MAX_HEADER << 3); |
| 2881 | 2918 | |
| @@ -2955,7 +2992,6 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) · 73 unmodified lines | ||
| 2955 | 2992 | transport = container_of(xprt, struct sock_xprt, xprt); |
| 2956 | 2993 | |
| 2957 | 2994 | xprt->prot = IPPROTO_TCP; |
| 2958 | − xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); | |
| 2959 | 2995 | xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; |
| 2960 | 2996 | |
| 2961 | 2997 | xprt->bind_timeout = XS_BIND_TO; |
| @@ -3028,7 +3064,6 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args) · 66 unmodified lines | ||
| 3028 | 3064 | transport = container_of(xprt, struct sock_xprt, xprt); |
| 3029 | 3065 | |
| 3030 | 3066 | xprt->prot = IPPROTO_TCP; |
| 3031 | − xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); | |
| 3032 | 3067 | xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; |
| 3033 | 3068 | xprt->timeout = &xs_tcp_default_timeout; |
| 3034 | 3069 | |