]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[linda] Validate payload length
authorMichael Brown <mcb30@ipxe.org>
Wed, 30 Mar 2016 06:27:09 +0000 (07:27 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 30 Mar 2016 06:27:09 +0000 (07:27 +0100)
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>
src/drivers/infiniband/linda.c

index 391fff429a0342a6bdd633592cb8e3ca3be14039..77d50d1103830ed2e99fd93a672a84ac0743b783 100644 (file)
@@ -1271,8 +1271,15 @@ static void linda_complete_recv ( struct ib_device *ibdev,
                        /* Completing the eager buffer described in
                         * this header entry.
                         */
-                       iob_put ( iobuf, payload_len );
-                       rc = ( err ? -EIO : ( useegrbfr ? 0 : -ECANCELED ) );
+                       if ( payload_len <= iob_tailroom ( iobuf ) ) {
+                               iob_put ( iobuf, payload_len );
+                               rc = ( err ?
+                                      -EIO : ( useegrbfr ? 0 : -ECANCELED ) );
+                       } else {
+                               DBGC ( linda, "Linda %p bad payload len %zd\n",
+                                      linda, payload_len );
+                               rc = -EPROTO;
+                       }
                        /* Redirect to target QP if necessary */
                        if ( qp != intended_qp ) {
                                DBGC ( linda, "Linda %p redirecting QPN %ld "
@@ -1283,7 +1290,7 @@ static void linda_complete_recv ( struct ib_device *ibdev,
                                intended_qp->recv.fill++;
                        }
                        ib_complete_recv ( ibdev, intended_qp, &dest, &source,
-                                          iobuf, rc);
+                                          iobuf, rc );
                } else {
                        /* Completing on a skipped-over eager buffer */
                        ib_complete_recv ( ibdev, qp, &dest, &source, iobuf,