History

perf/arm-cmn: Reject unsupported hardware configurations

So far we've been fairly lax about accepting both unknown CMN models (at least with a warning), and unknown revisions of those which we do know, as although things do frequently change between releases, typically enough remains the same to be somewhat useful for at least some basic bringup checks. However, we also make assumptions of the maximum supported sizes and numbers of things in various places, and there's no guarantee that something new might not be bigger and lead to nasty array overflows. Make sure we only try to run on things that actually match our assumptions and so will not risk memory corruption. We have at least always failed on completely unknown node types, so update that error message for clarity and consistency too.

Robin Murphy committed 9 months ago

Commit 36c0de01 parent 283182c1 file · +14 −1Browse files

Unified · Split

drivers/perf/arm-cmn.c+14−1
@@ -2422,6 +2422,15 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset) · 2421 unmodified lines
2422 arm_cmn_init_node_info(cmn, reg & CMN_CHILD_NODE_ADDR, dn);2422 arm_cmn_init_node_info(cmn, reg & CMN_CHILD_NODE_ADDR, dn);
2423 dn->portid_bits = xp->portid_bits;2423 dn->portid_bits = xp->portid_bits;
2424 dn->deviceid_bits = xp->deviceid_bits;2424 dn->deviceid_bits = xp->deviceid_bits;
2425 /*
2426 * Logical IDs are assigned from 0 per node type, so as
2427 * soon as we see one bigger than expected, we can assume
2428 * there are more than we can cope with.
2429 */
2430 if (dn->logid > CMN_MAX_NODES_PER_EVENT) {
2431 dev_err(cmn->dev, "Node ID invalid for supported CMN versions: %d\n", dn->logid);
2432 return -ENODEV;
2433 }
2425 2434
2426 switch (dn->type) {2435 switch (dn->type) {
2427 case CMN_TYPE_DTC:2436 case CMN_TYPE_DTC:
@@ -2471,7 +2480,7 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset) · 43 unmodified lines
2471 break;2480 break;
2472 /* Something has gone horribly wrong */2481 /* Something has gone horribly wrong */
2473 default:2482 default:
2474 dev_err(cmn->dev, "invalid device node type: 0x%x\n", dn->type);2483 dev_err(cmn->dev, "Device node type invalid for supported CMN versions: 0x%x\n", dn->type);
2475 return -ENODEV;2484 return -ENODEV;
2476 }2485 }
2477 }2486 }
@@ -2499,6 +2508,10 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset) · 21 unmodified lines
2499 cmn->mesh_x = cmn->num_xps;2508 cmn->mesh_x = cmn->num_xps;
2500 cmn->mesh_y = cmn->num_xps / cmn->mesh_x;2509 cmn->mesh_y = cmn->num_xps / cmn->mesh_x;
2501 2510
2511 if (max(cmn->mesh_x, cmn->mesh_y) > CMN_MAX_DIMENSION) {
2512 dev_err(cmn->dev, "Mesh size invalid for supported CMN versions: %dx%d\n", cmn->mesh_x, cmn->mesh_y);
2513 return -ENODEV;
2514 }
2502 /* 1x1 config plays havoc with XP event encodings */2515 /* 1x1 config plays havoc with XP event encodings */
2503 if (cmn->num_xps == 1)2516 if (cmn->num_xps == 1)
2504 dev_warn(cmn->dev, "1x1 config not fully supported, translate XP events manually\n");2517 dev_warn(cmn->dev, "1x1 config not fully supported, translate XP events manually\n");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t