Skip to contentSkip to conversation

liquidio: avoid vm low memory crashes

PATCH In review Felix Manlunas 4 participants 7 messages Jul 18, 2017 – Jul 19, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 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 not seen when the driver was exercised normally. Rather, they were brought about through manual fault injection. They are being included in the interest of hardening the driver against unforeseen circumstances.

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().

change log:
V1 -> V2:
1. Corrected syntax in 'Subject' lines; no functional or code changes.

Rick Farrington (3):
liquidio: lowmem: init allocated memory to 0
liquidio: lowmem: do not dereference null ptr
liquidio: lowmem: init allocated memory to 0

 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
2.9.0
#1 lore raw

PATCH v2 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
index 2e190de..6456683 100644
@@ -275,12 +275,12 @@ int octeon_init_droq(struct octeon_device *oct,
 		droq->max_count);
 
 	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
2.9.0
#2 lore raw

PATCH v2 2/3 liquidio: lowmem: do not dereference null ptr

In reply to Felix Manlunas

From: 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
index 6456683..f7b5d68 100644
@@ -145,6 +145,8 @@ octeon_droq_destroy_ring_buffers(struct octeon_device *oct,
 
 	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
2.9.0
#3 lore raw

PATCH v2 3/3 liquidio: lowmem: init allocated memory to 0

In reply to Felix Manlunas

From: 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
index 623e28c..f10014f7 100644
@@ -876,11 +876,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));
@@ -923,9 +923,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
2.9.0
#4 lore raw
In reply to Felix Manlunas
Quoted 16 lines · Felix Manlunas

From: Rick Farrington <[email protected]>

This patchset addresses issues brought about by low memory conditions in a VM. These conditions were not seen when the driver was exercised normally. Rather, they were brought about through manual fault injection. They are being included in the interest of hardening the driver against unforeseen circumstances.

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().

Quoted 8 lines

change log:
V1 -> V2:
1. Corrected syntax in 'Subject' lines; no functional or code changes.

Rick Farrington (3):
liquidio: lowmem: init allocated memory to 0
liquidio: lowmem: do not dereference null ptr
liquidio: lowmem: init allocated memory to 0

I'm feeling déjà vu here. We already discussed that zero allocated arrays have nothing to do with low memory conditions. Why are you continuing to use this misleading term here?

Quoted 8 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(-)

--
2.9.0

#5 lore raw

My apologies Leon - I did not infer that the subject line should have been changed from your previous correspondence. I will correct it.

Rick

-----Original Message-----
From: Leon Romanovsky [mailto:[email protected]]
Sent: Monday, July 17, 2017 11:23 PM
To: Manlunas, Felix <[email protected]>
Cc: [email protected]; [email protected]; Vatsavayi, Raghu <[email protected]>; Chickles, Derek <[email protected]>; Burla, Satananda <[email protected]>; Ricardo Farrington <[email protected]>
Subject: Re: [PATCH v2 net-next 0/3] liquidio: avoid vm low memory crashes

Quoted 16 lines · Felix Manlunas

From: Rick Farrington <[email protected]>

This patchset addresses issues brought about by low memory conditions in a VM. These conditions were not seen when the driver was exercised normally. Rather, they were brought about through manual fault injection. They are being included in the interest of hardening the driver against unforeseen circumstances.

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().

Quoted 8 lines

change log:
V1 -> V2:
1. Corrected syntax in 'Subject' lines; no functional or code changes.

Rick Farrington (3):
liquidio: lowmem: init allocated memory to 0
liquidio: lowmem: do not dereference null ptr
liquidio: lowmem: init allocated memory to 0

I'm feeling déjà vu here. We already discussed that zero allocated arrays have nothing to do with low memory conditions. Why are you continuing to use this misleading term here?

Quoted 8 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(-)

--
2.9.0

maintainer
#6 lore raw
In reply to Felix Manlunas

From: Felix Manlunas <[email protected]>
Date: Mon, 17 Jul 2017 17:49:20 -0700

Quoted 16 lines

From: Rick Farrington <[email protected]>

This patchset addresses issues brought about by low memory conditions in a VM. These conditions were not seen when the driver was exercised normally. Rather, they were brought about through manual fault injection. They are being included in the interest of hardening the driver against unforeseen circumstances.

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().

Quoted 3 lines

change log:
V1 -> V2:
1. Corrected syntax in 'Subject' lines; no functional or code changes.

Series applied. I removed the "[0]" in this commit log message.

Thanks.