Skip to content

fix crash on device args with no driver options

Stephen Hemminger dpdk-dev 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4devargs: fix NULL args with global device syntaxlib/eal/common/eal_common_devargs.c+4 -00 replies
2/4kvargs: harden rte_kvargs_parselib/kvargs/rte_kvargs.c+5 -10 replies
3/4test/devargs: use unit test suite runnerapp/test/test_devargs.c+21 -200 replies
4/4test/devargs: add tests for missing device argumentsapp/test/test_devargs.c app/test/test_kvargs.c+76 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] fix crash on device args with no driver options

A device given in the global syntax with no driver layer, such as "bus=vdev,name=net_af_packet0", leaves devargs args NULL because drv_str shares a union with it and is never set. The legacy syntax always sets args, to an empty string when there are no options, and drivers rely on that. Passing the NULL to rte_kvargs_parse() crashes in strdup().

The first patch makes the global syntax match the legacy one by defaulting to an empty string. The second hardens rte_kvargs_parse() so a NULL gives an empty list rather than a crash; NULL is not excluded by the API documentation, and an empty list is the sensible reading of "no arguments".

The last two patches add the missing coverage. There was no test for a device string without driver arguments, which is how this went unnoticed. Converting the devargs test to the unit test suite runner comes first so the new case is reported on its own rather than short-circuiting the rest of the file.

Verified both new tests fail without the fixes: the devargs case trips its args-NULL assertion, and the kvargs case faults in strdup().

Bugzilla ID: 2049

Stephen Hemminger (4):
devargs: fix NULL args with global device syntax
kvargs: harden rte_kvargs_parse test/devargs: use unit test suite runner test/devargs: add tests for missing device arguments

 app/test/test_devargs.c             | 101 ++++++++++++++++++++++------
 app/test/test_kvargs.c              |  16 +++++
 lib/eal/common/eal_common_devargs.c |   4 ++
 lib/kvargs/rte_kvargs.c             |   6 +-
 4 files changed, 106 insertions(+), 21 deletions(-)
Signature · 1 line
2.53.0