[dpdk-dev,v2] memory: fix segfault on rte_mem_virt2memseg() call with invalid addr
Checks
Commit Message
When trying to use it with an address that's not
managed by DPDK it would segfault due to a missing
check. The doc says this function returns either
a pointer or NULL, so let it do so.
Changes from v1:
* removed gerrit change id
* added "git fixline" tags
Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists")
Cc: anatoly.burakov@intel.com
Cc: stable@dpdk.org
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
---
lib/librte_eal/common/eal_common_memory.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On 01-Jun-18 2:44 PM, Dariusz Stojaczyk wrote:
> When trying to use it with an address that's not
> managed by DPDK it would segfault due to a missing
> check. The doc says this function returns either
> a pointer or NULL, so let it do so.
>
> Changes from v1:
> * removed gerrit change id
> * added "git fixline" tags
>
> Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists")
> Cc: anatoly.burakov@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
> ---
Please include Acks (Reviews, Tests...) in the commit message if they
were given for the previous version of the patchset. Also do not list
changes you've made in the commit message; instead, list changes in the
patch notes, after the first "---", like so:
area: fix blah
This patch fixes this and that.
Fixes: 123456 ("area: a buggy commit")
Cc: bug.author@example.com
Signed-off-by: Fix Author <fix.author@example.com>
Acked-by: fix.reviewer@example.com
---
v2:
- Fixed this
- Fixed that
@@ -536,6 +536,9 @@ virt2memseg(const void *addr, const struct rte_memseg_list *msl)
void *start, *end;
int ms_idx;
+ if (msl == NULL)
+ return NULL;
+
/* a memseg list was specified, check if it's the right one */
start = msl->base_va;
end = RTE_PTR_ADD(start, (size_t)msl->page_sz * msl->memseg_arr.len);