* [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes
@ 2017-06-08 3:50 Felix Manlunas
2017-06-08 3:52 ` [PATCH net-next 1/3] LiquidIO: lowmem: init allocated memory to 0 Felix Manlunas
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Felix Manlunas @ 2017-06-08 3:50 UTC (permalink / raw)
To: davem
Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla,
ricardo.farrington
From: Rick Farrington <ricardo.farrington@cavium.com>
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(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/3] LiquidIO: lowmem: init allocated memory to 0
2017-06-08 3:50 [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes Felix Manlunas
@ 2017-06-08 3:52 ` Felix Manlunas
2017-06-08 3:52 ` [PATCH net-next 2/3] LiquidIO: lowmem: do not dereference NULL ptr Felix Manlunas
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Felix Manlunas @ 2017-06-08 3:52 UTC (permalink / raw)
To: davem
Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla,
ricardo.farrington
From: Rick Farrington <ricardo.farrington@cavium.com>
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.
Signed-off-by: Rick Farrington <ricardo.farrington@cavium.com>
Signed-off-by: Satanand Burla <satananda.burla@cavium.com>
Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
---
drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
index 286be55..07c764d 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
@@ -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");
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 2/3] LiquidIO: lowmem: do not dereference NULL ptr
2017-06-08 3:50 [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes Felix Manlunas
2017-06-08 3:52 ` [PATCH net-next 1/3] LiquidIO: lowmem: init allocated memory to 0 Felix Manlunas
@ 2017-06-08 3:52 ` Felix Manlunas
2017-06-08 3:53 ` [PATCH net-next 3/3] LiquidIO: lowmem: init allocated memory to 0 Felix Manlunas
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Felix Manlunas @ 2017-06-08 3:52 UTC (permalink / raw)
To: davem
Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla,
ricardo.farrington
From: Rick Farrington <ricardo.farrington@cavium.com>
Don't dereference a NULL ptr in octeon_droq_destroy_ring_buffers().
Signed-off-by: Rick Farrington <ricardo.farrington@cavium.com>
Signed-off-by: Satanand Burla <satananda.burla@cavium.com>
Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
---
drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
index 07c764d..d868252 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
@@ -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,
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 3/3] LiquidIO: lowmem: init allocated memory to 0
2017-06-08 3:50 [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes Felix Manlunas
2017-06-08 3:52 ` [PATCH net-next 1/3] LiquidIO: lowmem: init allocated memory to 0 Felix Manlunas
2017-06-08 3:52 ` [PATCH net-next 2/3] LiquidIO: lowmem: do not dereference NULL ptr Felix Manlunas
@ 2017-06-08 3:53 ` Felix Manlunas
2017-06-08 7:12 ` [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes Leon Romanovsky
2017-06-08 13:16 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Felix Manlunas @ 2017-06-08 3:53 UTC (permalink / raw)
To: davem
Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla,
ricardo.farrington
From: Rick Farrington <ricardo.farrington@cavium.com>
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().
Signed-off-by: Rick Farrington <ricardo.farrington@cavium.com>
Signed-off-by: Satanand Burla <satananda.burla@cavium.com>
Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
---
drivers/net/ethernet/cavium/liquidio/octeon_device.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.c b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
index 3b7cc93..087820b 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
@@ -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;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes
2017-06-08 3:50 [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes Felix Manlunas
` (2 preceding siblings ...)
2017-06-08 3:53 ` [PATCH net-next 3/3] LiquidIO: lowmem: init allocated memory to 0 Felix Manlunas
@ 2017-06-08 7:12 ` Leon Romanovsky
2017-06-08 13:16 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2017-06-08 7:12 UTC (permalink / raw)
To: Felix Manlunas
Cc: davem, netdev, raghu.vatsavayi, derek.chickles, satananda.burla,
ricardo.farrington
[-- Attachment #1: Type: text/plain, Size: 1314 bytes --]
On Wed, Jun 07, 2017 at 08:50:45PM -0700, Felix Manlunas wrote:
> From: Rick Farrington <ricardo.farrington@cavium.com>
>
> 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().
>
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
> 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
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes
2017-06-08 3:50 [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes Felix Manlunas
` (3 preceding siblings ...)
2017-06-08 7:12 ` [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes Leon Romanovsky
@ 2017-06-08 13:16 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-06-08 13:16 UTC (permalink / raw)
To: felix.manlunas
Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla,
ricardo.farrington
Please 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-06-08 13:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-08 3:50 [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes Felix Manlunas
2017-06-08 3:52 ` [PATCH net-next 1/3] LiquidIO: lowmem: init allocated memory to 0 Felix Manlunas
2017-06-08 3:52 ` [PATCH net-next 2/3] LiquidIO: lowmem: do not dereference NULL ptr Felix Manlunas
2017-06-08 3:53 ` [PATCH net-next 3/3] LiquidIO: lowmem: init allocated memory to 0 Felix Manlunas
2017-06-08 7:12 ` [PATCH net-next 0/3] LiquidIO: avoid VM low memory crashes Leon Romanovsky
2017-06-08 13:16 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).