Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. diff --git a/net/9p/client.c b/net/9p/client.c
  2. index 18c5271910dc..2225df1ed8fc 100644
  3. --- a/net/9p/client.c
  4. +++ b/net/9p/client.c
  5. @@ -340,7 +340,7 @@ struct p9_req_t *p9_tag_lookup(struct p9_client *c, u16 tag)
  6. * buffer to read the data into */
  7. tag++;
  8.  
  9. - if(tag >= c->max_tag)
  10. + if(tag >= c->max_tag)
  11. return NULL;
  12.  
  13. row = tag / P9_ROW_MAXTAG;
  14. @@ -477,20 +477,11 @@ p9_parse_header(struct p9_fcall *pdu, int32_t *size, int8_t *type, int16_t *tag,
  15. int err;
  16.  
  17. pdu->offset = 0;
  18. - if (pdu->size == 0)
  19. - pdu->size = 7;
  20.  
  21. err = p9pdu_readf(pdu, 0, "dbw", &r_size, &r_type, &r_tag);
  22. if (err)
  23. goto rewind_and_exit;
  24.  
  25. - pdu->size = r_size;
  26. - pdu->id = r_type;
  27. - pdu->tag = r_tag;
  28. -
  29. - p9_debug(P9_DEBUG_9P, "<<< size=%d type: %d tag: %d\n",
  30. - pdu->size, pdu->id, pdu->tag);
  31. -
  32. if (type)
  33. *type = r_type;
  34. if (tag)
  35. @@ -498,6 +489,16 @@ p9_parse_header(struct p9_fcall *pdu, int32_t *size, int8_t *type, int16_t *tag,
  36. if (size)
  37. *size = r_size;
  38.  
  39. + if (pdu->size != r_size || r_size < 7) {
  40. + err = -EINVAL;
  41. + goto rewind_and_exit;
  42. + }
  43. +
  44. + pdu->id = r_type;
  45. + pdu->tag = r_tag;
  46. +
  47. + p9_debug(P9_DEBUG_9P, "<<< size=%d type: %d tag: %d\n",
  48. + pdu->size, pdu->id, pdu->tag);
  49.  
  50. rewind_and_exit:
  51. if (rewind)
  52. @@ -524,6 +525,12 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
  53. int ecode;
  54.  
  55. err = p9_parse_header(req->rc, NULL, &type, NULL, 0);
  56. + if (req->rc->size >= c->msize) {
  57. + p9_debug(P9_DEBUG_ERROR,
  58. + "requested packet size too big: %d\n",
  59. + req->rc->size);
  60. + return -EIO;
  61. + }
  62. /*
  63. * dump the response from server
  64. * This should be after check errors which poplulate pdu_fcall.
  65. @@ -1575,7 +1582,7 @@ p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err)
  66. int count = iov_iter_count(to);
  67. int rsize, non_zc = 0;
  68. char *dataptr;
  69. -
  70. +
  71. rsize = fid->iounit;
  72. if (!rsize || rsize > clnt->msize-P9_IOHDRSZ)
  73. rsize = clnt->msize - P9_IOHDRSZ;
  74. diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
  75. index 588bf88c3305..fadf9b43a287 100644
  76. --- a/net/9p/trans_fd.c
  77. +++ b/net/9p/trans_fd.c
  78. @@ -324,7 +324,9 @@ static void p9_read_work(struct work_struct *work)
  79. if ((!m->req) && (m->rc.offset == m->rc.capacity)) {
  80. p9_debug(P9_DEBUG_TRANS, "got new header\n");
  81.  
  82. - err = p9_parse_header(&m->rc, NULL, NULL, NULL, 0);
  83. + /* Header size */
  84. + m->rc.size = 7;
  85. + err = p9_parse_header(&m->rc, &m->rc.size, NULL, NULL, 0);
  86. if (err) {
  87. p9_debug(P9_DEBUG_ERROR,
  88. "error parsing header: %d\n", err);
  89. diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
  90. index 3d414acb7015..2649b2ebf961 100644
  91. --- a/net/9p/trans_rdma.c
  92. +++ b/net/9p/trans_rdma.c
  93. @@ -320,6 +320,7 @@ recv_done(struct ib_cq *cq, struct ib_wc *wc)
  94. if (wc->status != IB_WC_SUCCESS)
  95. goto err_out;
  96.  
  97. + c->rc->size = wc->byte_len;
  98. err = p9_parse_header(c->rc, NULL, NULL, &tag, 1);
  99. if (err)
  100. goto err_out;
  101. diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
  102. index 05006cbb3361..6d515f7ebfaf 100644
  103. --- a/net/9p/trans_virtio.c
  104. +++ b/net/9p/trans_virtio.c
  105. @@ -159,8 +159,10 @@ static void req_done(struct virtqueue *vq)
  106. spin_unlock_irqrestore(&chan->lock, flags);
  107. /* Wakeup if anyone waiting for VirtIO ring space. */
  108. wake_up(chan->vc_wq);
  109. - if (len)
  110. + if (len) {
  111. + req->rc->size = len;
  112. p9_client_cb(chan->client, req, REQ_STATUS_RCVD);
  113. + }
  114. }
  115. }
  116.  
  117. @@ -446,7 +448,7 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req,
  118. out += pack_sg_list_p(chan->sg, out, VIRTQUEUE_NUM,
  119. out_pages, out_nr_pages, offs, outlen);
  120. }
  121. -
  122. +
  123. /*
  124. * Take care of in data
  125. * For example TREAD have 11.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement