Skip to content

Commit 0f30868

Browse files
sbrivio-rhdavem330
authored andcommitted
cxgb4: Fix stack out-of-bounds read due to wrong size to t4_record_mbox()
Passing commands for logging to t4_record_mbox() with size MBOX_LEN, when the actual command size is actually smaller, causes out-of-bounds stack accesses in t4_record_mbox() while copying command words here: for (i = 0; i < size / 8; i++) entry->cmd[i] = be64_to_cpu(cmd[i]); Up to 48 bytes from the stack are then leaked to debugfs. This happens whenever we send (and log) commands described by structs fw_sched_cmd (32 bytes leaked), fw_vi_rxmode_cmd (48), fw_hello_cmd (48), fw_bye_cmd (48), fw_initialize_cmd (48), fw_reset_cmd (48), fw_pfvf_cmd (32), fw_eq_eth_cmd (16), fw_eq_ctrl_cmd (32), fw_eq_ofld_cmd (32), fw_acl_mac_cmd(16), fw_rss_glb_config_cmd(32), fw_rss_vi_config_cmd(32), fw_devlog_cmd(32), fw_vi_enable_cmd(48), fw_port_cmd(32), fw_sched_cmd(32), fw_devlog_cmd(32). The cxgb4vf driver got this right instead. When we call t4_record_mbox() to log a command reply, a MBOX_LEN size can be used though, as get_mbox_rpl() will fill cmd_rpl up completely. Fixes: 7f080c3 ("cxgb4: Add support to enable logging of firmware mailbox commands") Signed-off-by: Stefano Brivio <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ad4540c commit 0f30868

File tree

1 file changed

+3
-3
lines changed
  • drivers/net/ethernet/chelsio/cxgb4

1 file changed

+3
-3
lines changed

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,12 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd,
369369
list_del(&entry.list);
370370
spin_unlock(&adap->mbox_lock);
371371
ret = (v == MBOX_OWNER_FW) ? -EBUSY : -ETIMEDOUT;
372-
t4_record_mbox(adap, cmd, MBOX_LEN, access, ret);
372+
t4_record_mbox(adap, cmd, size, access, ret);
373373
return ret;
374374
}
375375

376376
/* Copy in the new mailbox command and send it on its way ... */
377-
t4_record_mbox(adap, cmd, MBOX_LEN, access, 0);
377+
t4_record_mbox(adap, cmd, size, access, 0);
378378
for (i = 0; i < size; i += 8)
379379
t4_write_reg64(adap, data_reg + i, be64_to_cpu(*p++));
380380

@@ -426,7 +426,7 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd,
426426
}
427427

428428
ret = (pcie_fw & PCIE_FW_ERR_F) ? -ENXIO : -ETIMEDOUT;
429-
t4_record_mbox(adap, cmd, MBOX_LEN, access, ret);
429+
t4_record_mbox(adap, cmd, size, access, ret);
430430
dev_err(adap->pdev_dev, "command %#x in mailbox %d timed out\n",
431431
*(const u8 *)cmd, mbox);
432432
t4_report_fw_error(adap);

0 commit comments

Comments
 (0)