Skip to content
/ linux Public

Commit 19aa416

Browse files
avasummergregkh
authored andcommitted
bnxt_en: fix OOB access in DBG_BUF_PRODUCER async event handler
commit 64dcbde upstream. The ASYNC_EVENT_CMPL_EVENT_ID_DBG_BUF_PRODUCER handler in bnxt_async_event_process() uses a firmware-supplied 'type' field directly as an index into bp->bs_trace[] without bounds validation. The 'type' field is a 16-bit value extracted from DMA-mapped completion ring memory that the NIC writes directly to host RAM. A malicious or compromised NIC can supply any value from 0 to 65535, causing an out-of-bounds access into kernel heap memory. The bnxt_bs_trace_check_wrap() call then dereferences bs_trace->magic_byte and writes to bs_trace->last_offset and bs_trace->wrapped, leading to kernel memory corruption or a crash. Fix by adding a bounds check and defining BNXT_TRACE_MAX as DBG_LOG_BUFFER_FLUSH_REQ_TYPE_ERR_QPC_TRACE + 1 to cover all currently defined firmware trace types (0x0 through 0xc). Fixes: 84fcd94 ("bnxt_en: Manage the FW trace context memory") Reported-by: Yuhao Jiang <danisjiang@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Junrui Luo <moonafterrain@outlook.com> Reviewed-by: Michael Chan <michael.chan@broadcom.com> Link: https://patch.msgid.link/SYBPR01MB7881A253A1C9775D277F30E9AF42A@SYBPR01MB7881.ausprd01.prod.outlook.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1f47140 commit 19aa416

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2927,6 +2927,8 @@ static int bnxt_async_event_process(struct bnxt *bp,
29272927
u16 type = (u16)BNXT_EVENT_BUF_PRODUCER_TYPE(data1);
29282928
u32 offset = BNXT_EVENT_BUF_PRODUCER_OFFSET(data2);
29292929

2930+
if (type >= ARRAY_SIZE(bp->bs_trace))
2931+
goto async_event_process_exit;
29302932
bnxt_bs_trace_check_wrap(&bp->bs_trace[type], offset);
29312933
goto async_event_process_exit;
29322934
}

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2134,7 +2134,7 @@ enum board_idx {
21342134
};
21352135

21362136
#define BNXT_TRACE_BUF_MAGIC_BYTE ((u8)0xbc)
2137-
#define BNXT_TRACE_MAX 11
2137+
#define BNXT_TRACE_MAX (DBG_LOG_BUFFER_FLUSH_REQ_TYPE_ERR_QPC_TRACE + 1)
21382138

21392139
struct bnxt_bs_trace_info {
21402140
u8 *magic_byte;

0 commit comments

Comments
 (0)