service: don't walk out of bounds when checking services
authorAaron Conole <aconole@redhat.com>
Tue, 3 Dec 2019 21:15:44 +0000 (16:15 -0500)
committerDavid Marchand <david.marchand@redhat.com>
Fri, 20 Dec 2019 14:09:35 +0000 (15:09 +0100)
commit2e088e6f94b773233c06440763c1be43d0d705b3
treeb9a79f273851ebd8d44f9f4960134f239c7c3fcf
parent30a0df64aaed5cbf33fd5d237d5812cee1cc0ef9
service: don't walk out of bounds when checking services

The service_valid call is used without properly bounds checking the
input parameter.  Almost all instances of the service_valid call are
inside a for() loop that prevents excessive walks, but some of the
public APIs don't bounds check and will pass invalid arguments.

Prevent this by using SERVICE_GET_OR_ERR_RET where it makes sense,
and adding a bounds check to one service_valid() use.

Fixes: 8d39d3e237c2 ("service: fix race in service on app lcore function")
Fixes: e9139a32f6e8 ("service: add function to run on app lcore")
Fixes: e30dd31847d2 ("service: add mechanism for quiescing")
Cc: stable@dpdk.org
Signed-off-by: Aaron Conole <aconole@redhat.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
lib/librte_eal/common/rte_service.c