LiquidIO: avoid VM low memory crashes
Subsystems (3)
cover LiquidIO: avoid VM low memory crashes
From: Rick Farrington <[email protected]>
This patchset addresses issues brought about by low memory conditions in a VM. These conditions were only seen when VM's were intentionally created with small amounts of memory (for stress testing).
1. Fix GPF in octeon_init_droq(); zero the allocated block 'recv_buf_list'. This prevents a GPF trying to access an invalid 'recv_buf_list[i]' entry in octeon_droq_destroy_ring_buffers() if init didn't alloc all entries.
2. Don't dereference a NULL ptr in octeon_droq_destroy_ring_buffers().
3. For defensive programming, zero the allocated block 'oct->droq[0]' in octeon_setup_output_queues() and 'oct->instr_queue[0]' in octeon_setup_instr_queues().
drivers/net/ethernet/cavium/liquidio/octeon_device.c | 8 ++++---- drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/3 LiquidIO: lowmem: init allocated memory to 0
From: Rick Farrington <[email protected]>
Fix GPF in octeon_init_droq(); zero the allocated block 'recv_buf_list'. This prevents a GPF trying to access an invalid 'recv_buf_list[i]' entry in octeon_droq_destroy_ring_buffers() if init didn't alloc all entries.
--- drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/cavium/liquidio/octeon_droq.c +2 -2
@@ -289,12 +289,12 @@ int octeon_init_droq(struct octeon_device *oct, } droq->recv_buf_list = (struct octeon_recv_buffer *) -vmalloc_node (droq->max_count * +vzalloc_node (droq->max_count *OCT_DROQ_RECVBUF_SIZE , numa_node);if (!droq->recv_buf_list) droq->recv_buf_list = (struct octeon_recv_buffer *) -vmalloc (droq->max_count * +vzalloc (droq->max_count *OCT_DROQ_RECVBUF_SIZE );if (!droq->recv_buf_list) {dev_err (&oct->pci_dev->dev,"Output queue recv buf list alloc failed\n" );
Signature · 1 line
1.8.3.1
PATCH 2/3 LiquidIO: lowmem: do not dereference NULL ptr
In reply to Felix ManlunasFrom: Rick Farrington <[email protected]>
Don't dereference a NULL ptr in octeon_droq_destroy_ring_buffers().
--- drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/cavium/liquidio/octeon_droq.c +2 -0
@@ -145,6 +145,8 @@ static void octeon_droq_reset_indices(struct octeon_droq *droq)for (i =0 ; i < droq->max_count; i++) { pg_info = &droq->recv_buf_list[i].pg_info; +if (!pg_info) +continue ;if (pg_info->dma) lio_unmap_ring(oct->pci_dev,
Signature · 1 line
1.8.3.1
PATCH 3/3 LiquidIO: lowmem: init allocated memory to 0
In reply to Felix ManlunasFrom: Rick Farrington <[email protected]>
For defensive programming, zero the allocated block 'oct->droq[0]' in octeon_setup_output_queues() and 'oct->instr_queue[0]' in octeon_setup_instr_queues().
--- drivers/net/ethernet/cavium/liquidio/octeon_device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/cavium/liquidio/octeon_device.c +4 -4
@@ -880,11 +880,11 @@ int octeon_setup_instr_queues(struct octeon_device *oct) oct->num_iqs =0 ; - oct->instr_queue[0 ] =vmalloc_node (sizeof (*oct->instr_queue[0 ]), + oct->instr_queue[0 ] =vzalloc_node (sizeof (*oct->instr_queue[0 ]), numa_node);if (!oct->instr_queue[0 ]) oct->instr_queue[0 ] = -vmalloc (sizeof (struct octeon_instr_queue )); +vzalloc (sizeof (struct octeon_instr_queue ));if (!oct->instr_queue[0 ])return 1 ;memset (oct->instr_queue[0 ],0 ,sizeof (struct octeon_instr_queue ));
@@ -927,9 +927,9 @@ int octeon_setup_output_queues(struct octeon_device *oct) desc_size =CFG_GET_DEF_RX_BUF_SIZE (CHIP_CONF (oct, cn23xx_vf)); } oct->num_oqs =0 ; - oct->droq[0 ] =vmalloc_node (sizeof (*oct->droq[0 ]), numa_node); + oct->droq[0 ] =vzalloc_node (sizeof (*oct->droq[0 ]), numa_node);if (!oct->droq[0 ]) - oct->droq[0 ] =vmalloc (sizeof (*oct->droq[0 ])); + oct->droq[0 ] =vzalloc (sizeof (*oct->droq[0 ]));if (!oct->droq[0 ])return 1 ;
Signature · 1 line
1.8.3.1
Quoted 6 lines · Felix Manlunas
From: Rick Farrington <[email protected]>
This patchset addresses issues brought about by low memory conditions in a VM. These conditions were only seen when VM's were intentionally created with small amounts of memory (for stress testing).
Quoted 8 lines
1. Fix GPF in
octeon_init_droq(); zero the allocated block 'recv_buf_list'. This prevents a GPF trying to access an invalid 'recv_buf_list[i]' entry inocteon_droq_destroy_ring_buffers()if init didn't alloc all entries.
2. Don't dereference a NULL ptr inocteon_droq_destroy_ring_buffers().
3. For defensive programming, zero the allocated block 'oct->droq[0]' inocteon_setup_output_queues()and 'oct->instr_queue[0]' inocteon_setup_instr_queues().
While these patches are harmless, I don't really understand how allocating the same arrays just with zeros in it can prevent low memory crashes. Once you used v[m,z]alloc, you should expect for failures in these flows and relying on content of that page is not called "solve the bug".
Thanks
Quoted 7 lines
drivers/net/ethernet/cavium/liquidio/octeon_device.c | 8 ++++---- drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-)--
1.8.3.1
David Miller
maintainerPlease no "StudlyCaps" in the subject lines, the name of the driver and the directory it is in is "liquidio" in all lower-case.
Thank you.