v3:
  - Patch 3/8: fix the commit message to match what the check closes.
    zxdh_vport_to_vfid() does not use pfid for VF ports, so the
    residual is a VF forging the vport of another VF on the same
    epid, not just a sibling under the same PF. The code is
    unchanged, the closed cases are the PF-port and cross-epid ones.
  - Patch 6/8: add a static_assert in zxdh_msg.h pinning that
    struct zxdh_msg_info fits in ZXDH_BAR_MSG_PAYLOAD_MAX_LEN, the
    premise the receive buffer allocation relies on.

v2:
  - Patch 8/8: add the missing check in zxdh_bar_msg_ack_async_msg_proc(),
    the hunk described by the commit message was dropped when the v1
    changes were carried into the tree, only the reply-path check in
    zxdh_bar_chan_sync_msg_reps_get() was actually sent, so the
    VF-reachable path was unchanged (reported by maintainer review).
  - Patch 4/8: drop the paragraph claiming what the compiler does with
    the uninitialised read at -O1 and above; the fix does not depend
    on codegen for undefined behaviour, and just state that del_flag
    is read uninitialized when the group loop breaks early.

v1:
  This series fixes issues in the zxdh PF/VF mailbox handling that were
  found by a code scan of the driver, reported to us by the DPDK
  community. All of them are on the PF receive path, where fields of a
  message written by a VF into the shared BAR window are trusted more
  than they should be, plus two ordinary local bugs the scan found on
  the way:
- The dispatcher hands msg_head vport/pcieid to the handlers without
  comparing them with the sender, so a request can be aimed at any
  port (patch 3).
- The header module_id is checked as 8-bit but indexes a table as
  16-bit, and the async ack msg_id indexes the 256-entry seqid table
  without a bound check; both are out-of-bounds accesses up to a
  function call through a wild pointer (patches 7, 8).
- The receive buffer is allocated with the sender-declared length but
  accessed as a full struct, corrupting the heap; and the async
  no-ack exit leaks the buffer, allowing a guest to exhaust the PF
  heap (patches 5, 6).
- An uninitialised DTB entry is freed on a flow query error path,
  and an uninitialised multicast delete flag makes the PF delete the
  multicast entries of every port whenever one port leaves a group,
  with no attacker involved; the latter is a v25.11 regression
  (patches 2, 4).
- A VLAN id above 4095 from a VF message turns into an out-of-range
  ERAM row index (patch 1).

  The sender check of patch 3 was verified on hardware; it rejects
  requests naming a PF port or a port on another epid, while a VF
  forging the vport of another VF on the same epid is left to
  device-side protection that is planned. Each patch has been checked
  to apply on the current main branch.

Junlong Wang (8):
  net/zxdh: reject out-of-range VLAN ID from VF
  net/zxdh: initialise DTB entry in flow query
  net/zxdh: refuse PF mailbox requests not naming a VF of this PF
  net/zxdh: initialise multicast delete flag
  net/zxdh: free receive buffer on the async no-ack exit
  net/zxdh: allocate a zeroed full-size payload buffer
  net/zxdh: check full 16-bit module id of recv msg
  net/zxdh: check msg id before indexing the seqid table

 drivers/net/zxdh/zxdh_flow.c   |  2 +-
 drivers/net/zxdh/zxdh_msg.c    | 61 ++++++++++++++++++++++++++++------
 drivers/net/zxdh/zxdh_msg.h    |  3 ++
 drivers/net/zxdh/zxdh_tables.c |  2 +-
 4 files changed, 56 insertions(+), 12 deletions(-)

-- 
2.27.0

Reply via email to