mirror of https://github.com/ipxe/ipxe.git
[qib7322] Validate payload length
There is no way for the hardware to give us an invalid length in the LRH, since it must have parsed this length field in order to perform header splitting. However, this is difficult to prove conclusively. Add an unnecessary length check to explicitly reject any packets larger than the posted receive I/O buffer. Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/52/head
parent
c9af896314
commit
597521ef53
|
@ -1507,8 +1507,15 @@ static void qib7322_complete_recv ( struct ib_device *ibdev,
|
||||||
/* Completing the eager buffer described in
|
/* Completing the eager buffer described in
|
||||||
* this header entry.
|
* this header entry.
|
||||||
*/
|
*/
|
||||||
iob_put ( iobuf, payload_len );
|
if ( payload_len <= iob_tailroom ( iobuf ) ) {
|
||||||
rc = ( err ? -EIO : ( useegrbfr ? 0 : -ECANCELED ) );
|
iob_put ( iobuf, payload_len );
|
||||||
|
rc = ( err ?
|
||||||
|
-EIO : ( useegrbfr ? 0 : -ECANCELED ) );
|
||||||
|
} else {
|
||||||
|
DBGC ( qib7322, "QIB7322 %p bad payload len "
|
||||||
|
"%zd\n", qib7322, payload_len );
|
||||||
|
rc = -EPROTO;
|
||||||
|
}
|
||||||
/* Redirect to target QP if necessary */
|
/* Redirect to target QP if necessary */
|
||||||
if ( qp != intended_qp ) {
|
if ( qp != intended_qp ) {
|
||||||
DBGC2 ( qib7322, "QIB7322 %p redirecting QPN "
|
DBGC2 ( qib7322, "QIB7322 %p redirecting QPN "
|
||||||
|
@ -1519,7 +1526,7 @@ static void qib7322_complete_recv ( struct ib_device *ibdev,
|
||||||
intended_qp->recv.fill++;
|
intended_qp->recv.fill++;
|
||||||
}
|
}
|
||||||
ib_complete_recv ( ibdev, intended_qp, &dest, &source,
|
ib_complete_recv ( ibdev, intended_qp, &dest, &source,
|
||||||
iobuf, rc);
|
iobuf, rc );
|
||||||
} else {
|
} else {
|
||||||
/* Completing on a skipped-over eager buffer */
|
/* Completing on a skipped-over eager buffer */
|
||||||
ib_complete_recv ( ibdev, qp, &dest, &source, iobuf,
|
ib_complete_recv ( ibdev, qp, &dest, &source, iobuf,
|
||||||
|
|
Loading…
Reference in New Issue