Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178224280
D60336.1796280755.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D60336.1796280755.diff
View Options
Index: sys/dev/mpi3mr/mpi3mr.c
===================================================================
--- sys/dev/mpi3mr/mpi3mr.c
+++ sys/dev/mpi3mr/mpi3mr.c
@@ -4180,7 +4180,7 @@
*
* Return: Nothing
*/
-static void mpi3mr_pcietopochg_evt_th(struct mpi3mr_softc *sc,
+static bool mpi3mr_pcietopochg_evt_th(struct mpi3mr_softc *sc,
Mpi3EventNotificationReply_t *event_reply)
{
Mpi3EventDataPcieTopologyChangeList_t *topo_evt =
@@ -4189,6 +4189,23 @@
U16 handle;
U8 reason_code;
struct mpi3mr_target *tgtdev = NULL;
+ U16 max_entries;
+
+ if (((U32)event_reply->EventDataLength * 4) <
+ offsetof(Mpi3EventDataPcieTopologyChangeList_t, PortEntry)) {
+ mpi3mr_dprint(sc, MPI3MR_ERROR,
+ "PCIe topology event: event_data_length too small\n");
+ return (false);
+ }
+ max_entries = (((U32)event_reply->EventDataLength * 4) -
+ offsetof(Mpi3EventDataPcieTopologyChangeList_t, PortEntry)) /
+ sizeof(topo_evt->PortEntry[0]);
+ if (topo_evt->NumEntries > max_entries) {
+ mpi3mr_dprint(sc, MPI3MR_ERROR,
+ "PCIe topology event: num_entries(%d) exceeds max(%d)\n",
+ topo_evt->NumEntries, max_entries);
+ return (false);
+ }
for (i = 0; i < topo_evt->NumEntries; i++) {
handle = le16toh(topo_evt->PortEntry[i].AttachedDevHandle);
@@ -4225,6 +4242,7 @@
break;
}
}
+ return (true);
}
/**
@@ -4239,7 +4257,7 @@
*
* Return: Nothing
*/
-static void mpi3mr_sastopochg_evt_th(struct mpi3mr_softc *sc,
+static bool mpi3mr_sastopochg_evt_th(struct mpi3mr_softc *sc,
Mpi3EventNotificationReply_t *event_reply)
{
Mpi3EventDataSasTopologyChangeList_t *topo_evt =
@@ -4248,6 +4266,23 @@
U16 handle;
U8 reason_code;
struct mpi3mr_target *tgtdev = NULL;
+ U16 max_entries;
+
+ if (((U32)event_reply->EventDataLength * 4) <
+ offsetof(Mpi3EventDataSasTopologyChangeList_t, PhyEntry)) {
+ mpi3mr_dprint(sc, MPI3MR_ERROR,
+ "SAS topology event: event_data_length too small\n");
+ return (false);
+ }
+ max_entries = (((U32)event_reply->EventDataLength * 4) -
+ offsetof(Mpi3EventDataSasTopologyChangeList_t, PhyEntry)) /
+ sizeof(topo_evt->PhyEntry[0]);
+ if (topo_evt->NumEntries > max_entries) {
+ mpi3mr_dprint(sc, MPI3MR_ERROR,
+ "SAS topology event: num_entries(%d) exceeds max(%d)\n",
+ topo_evt->NumEntries, max_entries);
+ return (false);
+ }
for (i = 0; i < topo_evt->NumEntries; i++) {
handle = le16toh(topo_evt->PhyEntry[i].AttachedDevHandle);
@@ -4284,7 +4319,7 @@
break;
}
}
-
+ return (true);
}
/**
* mpi3mr_devstatuschg_evt_th - DeviceStatusChange evt tophalf
@@ -4516,14 +4551,12 @@
}
case MPI3_EVENT_SAS_TOPOLOGY_CHANGE_LIST:
{
- process_evt_bh = 1;
- mpi3mr_sastopochg_evt_th(sc, event_reply);
+ process_evt_bh = mpi3mr_sastopochg_evt_th(sc, event_reply);
break;
}
case MPI3_EVENT_PCIE_TOPOLOGY_CHANGE_LIST:
{
- process_evt_bh = 1;
- mpi3mr_pcietopochg_evt_th(sc, event_reply);
+ process_evt_bh = mpi3mr_pcietopochg_evt_th(sc, event_reply);
break;
}
case MPI3_EVENT_PREPARE_FOR_RESET:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 3, 6:52 AM (21 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42174609
Default Alt Text
D60336.1796280755.diff (2 KB)
Attached To
Mode
D60336: mpi3mr: Validate entry counts against payload length in topology events
Attached
Detach File
Event Timeline