eal: fix core number validation
PATCH v2 1/1 eal: fix core number validation
When incorrect core value or range provided, as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
--
v2: Replace strtoul with strtol
Modified log message
--
--- lib/librte_eal/common/eal_common_options.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
lib/librte_eal/common/eal_common_options.c +10 -2
@@ -592,7 +592,7 @@ eal_parse_corelist(const char *corelist)if (*corelist =='\0' )return -1 ; errno =0 ; - idx =strtoul (corelist, &end,10 ); + idx =strtol (corelist, &end,10 );if (errno || end ==NULL )return -1 ;while (isblank (*end))
@@ -603,6 +603,11 @@ eal_parse_corelist(const char *corelist) max = idx;if (min ==RTE_MAX_LCORE ) min = idx; +if ((unsigned int )idx >= cfg->lcore_count || + (unsigned int )min >= cfg->lcore_count) { +return -1 ; + } +for (idx = min; idx <= max; idx++) {if (cfg->lcore_role[idx] !=ROLE_RTE ) { cfg->lcore_role[idx] =ROLE_RTE ;
@@ -1103,6 +1108,7 @@ eal_parse_common_option(int opt, const char *optarg, {static int b_used;static int w_used; +struct rte_config *cfg =rte_eal_get_configuration ();switch (opt) {/* blacklist */
@@ -1145,7 +1151,9 @@ eal_parse_common_option(int opt, const char *optarg,/* corelist */ case 'l' :if (eal_parse_corelist (optarg) <0 ) { -RTE_LOG (ERR ,EAL ,"invalid core list\n" ); +RTE_LOG (ERR ,EAL , +"Invalid core number given core range should be(0, %u)\n" , + cfg->lcore_count-1 );return -1 ; }
Signature · 1 line
2.17.2
Quoted 12 lines · Hari kumar Vemula
When incorrect core value or range provided, as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
Fixes d888cb8b9613 ("eal: add core list input format")--
v2: Replace strtoul with strtol
Modified log message
You did not take my other comments into account and the ut updates are missing.
Signature · 1 line
David Marchand
PATCH v2 1/1 eal: fix core number validation
In reply to Hari kumar VemulaFrom: Hari kumar Vemula <[email protected]>
When incorrect core value or range provided, as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
Added ut check for negative core values. Added unit test case for invalid core number range.
--- lib/librte_eal/common/eal_common_options.c | 10 ++++++++-- test/test/test_eal_flags.c | 14 +++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-)
lib/librte_eal/common/eal_common_options.c +7 -2
@@ -592,7 +592,9 @@ eal_parse_corelist(const char *corelist)if (*corelist =='\0' )return -1 ; errno =0 ; - idx =strtoul (corelist, &end,10 ); + idx =strtol (corelist, &end,10 ); +if (idx <0 || idx >= (int )cfg->lcore_count) +return -1 ;if (errno || end ==NULL )return -1 ;while (isblank (*end))
@@ -603,6 +605,7 @@ eal_parse_corelist(const char *corelist) max = idx;if (min ==RTE_MAX_LCORE ) min = idx;for (idx = min; idx <= max; idx++) {if (cfg->lcore_role[idx] !=ROLE_RTE ) { cfg->lcore_role[idx] =ROLE_RTE ;
@@ -1103,6 +1106,7 @@ eal_parse_common_option(int opt, const char *optarg, {static int b_used;static int w_used; +struct rte_config *cfg =rte_eal_get_configuration ();switch (opt) {/* blacklist */
@@ -1145,7 +1149,9 @@ eal_parse_common_option(int opt, const char *optarg,/* corelist */ case 'l' :if (eal_parse_corelist (optarg) <0 ) { -RTE_LOG (ERR ,EAL ,"invalid core list\n" ); +RTE_LOG (ERR ,EAL , +"Invalid core number, core range should be (0, %u)\n" , + cfg->lcore_count-1 );return -1 ; }
test/test/test_eal_flags.c +13 -1
@@ -513,6 +513,16 @@ test_missing_c_flag(void)const char *argv25[] = { prgname, prefix, mp_flag,"-n" ,"3" ,"--lcores" ,"0-1,2@(5-7),(3-5)@(0,2),(0,6),7" }; +/* when core number is negative value*/ +const char *const argv26[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"-5" }; +const char *const argv27[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"-5-7" }; +/* when core number is maximum value*/ +const char *const argv28[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"999999999" }; +const char *const argv29[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"1-9999999" };if (launch_proc (argv2) !=0 ) { printf("Error - "
@@ -556,7 +566,9 @@ test_missing_c_flag(void) launch_proc(argv18) == 0 || launch_proc(argv19) == 0 || launch_proc(argv20) == 0 || launch_proc(argv21) == 0 || launch_proc(argv21) == 0 || launch_proc(argv22) == 0 || - launch_proc(argv23) == 0 || launch_proc(argv24) == 0) { + launch_proc(argv23) == 0 || launch_proc(argv24) == 0 || + launch_proc(argv26) == 0 || launch_proc(argv27) == 0 || + launch_proc(argv28) == 0 || launch_proc(argv29) == 0) {printf ("Error - " "process ran without error with invalid --lcore flag\n" );return -1 ;
Signature · 1 line
2.17.2
PATCH v3 1/1 eal: fix core number validation
In reply to Hari kumar VemulaWhen incorrect core value or range provided, as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
Added ut check for negative core values. Added unit test case for invalid core number range.
--
v3: Added unit test cases for invalid core number range
v2: Replace strtoul with strtol
Modified log message
--
--- lib/librte_eal/common/eal_common_options.c | 9 +++++++-- test/test/test_eal_flags.c | 14 +++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-)
lib/librte_eal/common/eal_common_options.c +7 -2
@@ -592,7 +592,9 @@ eal_parse_corelist(const char *corelist)if (*corelist =='\0' )return -1 ; errno =0 ; - idx =strtoul (corelist, &end,10 ); + idx =strtol (corelist, &end,10 ); +if (idx <0 || idx >= (int )cfg->lcore_count) +return -1 ;if (errno || end ==NULL )return -1 ;while (isblank (*end))
@@ -1103,6 +1105,7 @@ eal_parse_common_option(int opt, const char *optarg, {static int b_used;static int w_used; +struct rte_config *cfg =rte_eal_get_configuration ();switch (opt) {/* blacklist */
@@ -1145,7 +1148,9 @@ eal_parse_common_option(int opt, const char *optarg,/* corelist */ case 'l' :if (eal_parse_corelist (optarg) <0 ) { -RTE_LOG (ERR ,EAL ,"invalid core list\n" ); +RTE_LOG (ERR ,EAL , +"Invalid core number, core range should be (0, %u)\n" , + cfg->lcore_count-1 );return -1 ; }
test/test/test_eal_flags.c +13 -1
@@ -513,6 +513,16 @@ test_missing_c_flag(void)const char *argv25[] = { prgname, prefix, mp_flag,"-n" ,"3" ,"--lcores" ,"0-1,2@(5-7),(3-5)@(0,2),(0,6),7" }; +/* core number is negative value */ +const char *const argv26[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"-5" }; +const char *const argv27[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"-5-7" }; +/* core number is maximum value */ +const char *const argv28[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"999999999" }; +const char *const argv29[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"1-9999999" };if (launch_proc (argv2) !=0 ) { printf("Error - "
@@ -556,7 +566,9 @@ test_missing_c_flag(void) launch_proc(argv18) == 0 || launch_proc(argv19) == 0 || launch_proc(argv20) == 0 || launch_proc(argv21) == 0 || launch_proc(argv21) == 0 || launch_proc(argv22) == 0 || - launch_proc(argv23) == 0 || launch_proc(argv24) == 0) { + launch_proc(argv23) == 0 || launch_proc(argv24) == 0 || + launch_proc(argv26) == 0 || launch_proc(argv27) == 0 || + launch_proc(argv28) == 0 || launch_proc(argv29) == 0) {printf ("Error - " "process ran without error with invalid --lcore flag\n" );return -1 ;
Signature · 1 line
2.17.2
Hello Hari,
Quoted 30 lines · Hari Kumar Vemula
When incorrect core value or range provided, as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
Added ut check for negative core values. Added unit test case for invalid core number range.
Fixes d888cb8b9613 ("eal: add core list input format")--
v3: Added unit test cases for invalid core number range
v2: Replace strtoul with strtol
Modified log message
--Signed-off-by Hari Kumar Vemula <[email protected]>--- lib/librte_eal/common/eal_common_options.c | 9 +++++++-- test/test/test_eal_flags.c | 14 +++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-)lib/librte_eal/common/eal_common_options.c +0
-0
lib/librte_eal/common/eal_common_options.c eal_parse_corelist(const char *corelist) · line 600
Quoted 10 lines
lib/librte_eal/common/eal_common_options.c +3
-1@@ -592,7 +592,9 @@ eal_parse_corelist(const char *corelist)if (*corelist =='\0' )return -1 ; errno =0 ; - idx =strtoul (corelist, &end,10 ); + idx =strtol (corelist, &end,10 ); +if (idx <0 || idx >= (int )cfg->lcore_count) +return -1 ;if (errno || end ==NULL )return -1 ;while (isblank (*end))
Please fix indentation.
Quoted 11 lines
lib/librte_eal/common/eal_common_options.c +1
-0@@ -1103,6 +1105,7 @@ eal_parse_common_option(int opt, const char *optarg, {static int b_used;static int w_used; +struct rte_config *cfg =rte_eal_get_configuration ();switch (opt) {/* blacklist */
lib/librte_eal/common/eal_common_options.c eal_parse_common_option(int opt, const char *optarg, · line 1156
Quoted 10 lines
lib/librte_eal/common/eal_common_options.c +3
-1@@ -1145,7 +1148,9 @@ eal_parse_common_option(int opt, const char *optarg,/* corelist */ case 'l' :if (eal_parse_corelist (optarg) <0 ) { -RTE_LOG (ERR ,EAL ,"invalid core list\n" ); +RTE_LOG (ERR ,EAL , + "Invalid core number, core range should be (0, %u)\n", + cfg->lcore_count-1 );return -1 ; }
eal_parse_corelist can error for both invalid core number but also for incorrectly formatted input.
How about "invalid core list, please check core numbers are in [0, %u] range" ?
test/test/test_eal_flags.c +0 -0
test/test/test_eal_flags.c test_missing_c_flag(void) · line 521
Quoted 13 lines
index
2acab9d69..28e68a6c9100644test/test/test_eal_flags.c +5
-0@@ -513,6 +513,16 @@ test_missing_c_flag(void)const char *argv25[] = { prgname, prefix, mp_flag,"-n" ,"3" ,"--lcores" ,"0-1,2@(5-7),(3-5)@(0,2),(0,6),7" }; +/* core number is negative value */ +const char *const argv26[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"-5" }; +const char *const argv27[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"-5-7" };
+ /* core number is maximum value */
test/test/test_eal_flags.c test_missing_c_flag(void) · line 526
Quoted 5 lines
test/test/test_eal_flags.c +4
-0+const char *const argv28[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"999999999" }; +const char *const argv29[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"1-9999999" };
Well, the maximum value is not really "999999999". Please check against RTE_MAX_LCORE.
Signature · 1 line
David Marchand
PATCH v4 1/1 eal: fix core number validation
In reply to Hari kumar VemulaWhen incorrect core value or range provided, as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
Added ut check for negative core values. Added unit test case for invalid core number range.
--
v4: Used RTE_MAX_LCORE for max core check
v3: Added unit test cases for invalid core number range
v2: Replace strtoul with strtol
Modified log message
--- lib/librte_eal/common/eal_common_options.c | 9 +++++++-- test/test/test_eal_flags.c | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-)
lib/librte_eal/common/eal_common_options.c +7 -2
@@ -592,7 +592,9 @@ eal_parse_corelist(const char *corelist)if (*corelist =='\0' )return -1 ; errno =0 ; - idx =strtoul (corelist, &end,10 ); + idx =strtol (corelist, &end,10 ); +if (idx <0 || idx >= (int )cfg->lcore_count) +return -1 ;if (errno || end ==NULL )return -1 ;while (isblank (*end))
@@ -1103,6 +1105,7 @@ eal_parse_common_option(int opt, const char *optarg, {static int b_used;static int w_used; +struct rte_config *cfg =rte_eal_get_configuration ();switch (opt) {/* blacklist */
@@ -1145,7 +1148,9 @@ eal_parse_common_option(int opt, const char *optarg,/* corelist */ case 'l' :if (eal_parse_corelist (optarg) <0 ) { -RTE_LOG (ERR ,EAL ,"invalid core list\n" ); +RTE_LOG (ERR ,EAL , +"invalid core list, please check core numbers are in [0, %u] range\n" , + cfg->lcore_count-1 );return -1 ; }
test/test/test_eal_flags.c +14 -1
@@ -18,6 +18,7 @@#include <sys/file.h> #include <limits.h> +#include <rte_per_lcore.h> #include <rte_debug.h> #include <rte_string_fns.h>
@@ -513,6 +514,16 @@ test_missing_c_flag(void)const char *argv25[] = { prgname, prefix, mp_flag,"-n" ,"3" ,"--lcores" ,"0-1,2@(5-7),(3-5)@(0,2),(0,6),7" }; +/* core number is negative value */ +const char *const argv26[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"-5" }; +const char *const argv27[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"-5-7" }; +/* core number is maximum value */ +const char *const argv28[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"RTE_MAX_LCORE+1" }; +const char *const argv29[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"1-(RTE_MAX_LCORE+1)" };if (launch_proc (argv2) !=0 ) { printf("Error - "
@@ -556,7 +567,9 @@ test_missing_c_flag(void) launch_proc(argv18) == 0 || launch_proc(argv19) == 0 || launch_proc(argv20) == 0 || launch_proc(argv21) == 0 || launch_proc(argv21) == 0 || launch_proc(argv22) == 0 || - launch_proc(argv23) == 0 || launch_proc(argv24) == 0) { + launch_proc(argv23) == 0 || launch_proc(argv24) == 0 || + launch_proc(argv26) == 0 || launch_proc(argv27) == 0 || + launch_proc(argv28) == 0 || launch_proc(argv29) == 0) {printf ("Error - " "process ran without error with invalid --lcore flag\n" );return -1 ;
Signature · 1 line
2.17.2
Quoted 14 lines · Hari Kumar Vemula
test/test/test_eal_flags.c +1
-0@@ -18,6 +18,7 @@#include <sys/file.h> #include <limits.h> +#include <rte_per_lcore.h> #include <rte_debug.h> #include <rte_string_fns.h>
test/test/test_eal_flags.c test_missing_c_flag(void) · line 517
Quoted 4 lines
test/test/test_eal_flags.c +0
-0@@ -513,6 +514,16 @@ test_missing_c_flag(void)const char *argv25[] = { prgname, prefix, mp_flag,"-n" ,"3" ,"--lcores" ,"0-1,2@(5-7),(3-5)@(0,2),(0,6),7" };
+ /* core number is negative value */
test/test/test_eal_flags.c test_missing_c_flag(void) · line 527
Quoted 5 lines
test/test/test_eal_flags.c +4
-0+const char *const argv26[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"-5" }; +const char *const argv27[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"-5-7" };
I did not see this before, but you fixed the "-l" eal option, not "--lcores" option.
So those unit tests are wrong.
test/test/test_eal_flags.c test_missing_c_flag(void) · line 529
Quoted 10 lines
test/test/test_eal_flags.c +5
-0+/* core number is maximum value */ +const char *const argv28[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"RTE_MAX_LCORE+1" }; +const char *const argv29[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"--lcores" ,"1-(RTE_MAX_LCORE+1)" };if (launch_proc (argv2) !=0 ) { printf("Error - "
Passing "RTE_MAX_LCORE+1" is indeed wrong (be it with "-l" or "--lcores" options), but I would still prefer to check the formatted value of RTE_MAX_LCORE (no need for that +1, btw).
So please, in next version, test against "-l", RTE_STR(RTE_MAX_LCORE) and "-l", "1-" RTE_STR(RTE_MAX_LCORE).
Thanks.
Signature · 1 line
David Marchand
PATCH v5 1/1 eal: fix core number validation
In reply to Hari Kumar VemulaWhen incorrect core value or range provided, as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
Added ut check for negative core values. Added unit test case for invalid core number range.
--
v5: corrected unit test case for -l option
v4: Used RTE_MAX_LCORE for max core check
v3: Added unit test cases for invalid core number range
v2: Replace strtoul with strtol
Modified log message
--- lib/librte_eal/common/eal_common_options.c | 9 +++++++-- test/test/test_eal_flags.c | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-)
lib/librte_eal/common/eal_common_options.c +7 -2
@@ -592,7 +592,9 @@ eal_parse_corelist(const char *corelist)if (*corelist =='\0' )return -1 ; errno =0 ; - idx =strtoul (corelist, &end,10 ); + idx =strtol (corelist, &end,10 ); +if (idx <0 || idx >= (int )cfg->lcore_count) +return -1 ;if (errno || end ==NULL )return -1 ;while (isblank (*end))
@@ -1103,6 +1105,7 @@ eal_parse_common_option(int opt, const char *optarg, {static int b_used;static int w_used; +struct rte_config *cfg =rte_eal_get_configuration ();switch (opt) {/* blacklist */
@@ -1145,7 +1148,9 @@ eal_parse_common_option(int opt, const char *optarg,/* corelist */ case 'l' :if (eal_parse_corelist (optarg) <0 ) { -RTE_LOG (ERR ,EAL ,"invalid core list\n" ); +RTE_LOG (ERR ,EAL , +"invalid core list, please check core numbers are in [0, %u] range\n" , + cfg->lcore_count-1 );return -1 ; }
test/test/test_eal_flags.c +14 -1
@@ -18,6 +18,7 @@#include <sys/file.h> #include <limits.h> +#include <rte_per_lcore.h> #include <rte_debug.h> #include <rte_string_fns.h>
@@ -513,6 +514,16 @@ test_missing_c_flag(void)const char *argv25[] = { prgname, prefix, mp_flag,"-n" ,"3" ,"--lcores" ,"0-1,2@(5-7),(3-5)@(0,2),(0,6),7" }; +/* core number is negative value */ +const char *const argv26[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"-l" ,"-5" }; +const char *const argv27[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"-l" ,"-5-7" }; +/* core number is maximum value */ +const char *const argv28[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"-l" ,RTE_STR (RTE_MAX_LCORE ) }; +const char *const argv29[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"-l" ,"1-" RTE_STR (RTE_MAX_LCORE ) };if (launch_proc (argv2) !=0 ) { printf("Error - "
@@ -556,7 +567,9 @@ test_missing_c_flag(void) launch_proc(argv18) == 0 || launch_proc(argv19) == 0 || launch_proc(argv20) == 0 || launch_proc(argv21) == 0 || launch_proc(argv21) == 0 || launch_proc(argv22) == 0 || - launch_proc(argv23) == 0 || launch_proc(argv24) == 0) { + launch_proc(argv23) == 0 || launch_proc(argv24) == 0 || + launch_proc(argv26) == 0 || launch_proc(argv27) == 0 || + launch_proc(argv28) == 0 || launch_proc(argv29) == 0) {printf ("Error - " "process ran without error with invalid --lcore flag\n" );return -1 ;
Signature · 1 line
2.17.2
Quoted 18 lines · Hari Kumar Vemula
test/test/test_eal_flags.c +3
-0@@ -18,6 +18,7 @@#include <sys/file.h> #include <limits.h> +#include <rte_per_lcore.h> #include <rte_debug.h> #include <rte_string_fns.h> @@ -513,6 +514,16 @@ test_missing_c_flag(void)const char *argv25[] = { prgname, prefix, mp_flag,"-n" ,"3" ,"--lcores" ,"0-1,2@(5-7),(3-5)@(0,2),(0,6),7" }; +/* core number is negative value */ +const char *const argv26[] = { prgname, prefix, mp_flag,
test/test/test_eal_flags.c test_missing_c_flag(void) · line 528
Quoted 10 lines
test/test/test_eal_flags.c +8
-0+ "-n", "3", "-l", "-5" }; +const char *const argv27[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"-l" ,"-5-7" }; +/* core number is maximum value */ +const char *const argv28[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"-l" ,RTE_STR (RTE_MAX_LCORE ) }; +const char *const argv29[] = { prgname, prefix, mp_flag, +"-n" ,"3" ,"-l" ,"1-" RTE_STR (RTE_MAX_LCORE ) };
Please move this block with the other "-l" options. You can add my Reviewed-by tag with this.
Thanks.
Signature · 1 line
David Marchand
PATCH v6 1/1 eal: fix core number validation
In reply to Hari Kumar VemulaWhen incorrect core value or range provided, as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
Added ut check for negative core values. Added unit test case for invalid core number range.
--
v6: Changed testcase order
v5: Corrected unit test case for -l option
v4: Used RTE_MAX_LCORE for max core check
v3: Added unit test cases for invalid core number range
v2: Replace strtoul with strtol
Modified log message
--- lib/librte_eal/common/eal_common_options.c | 9 +++- test/test/test_eal_flags.c | 61 ++++++++++++++-------- 2 files changed, 45 insertions(+), 25 deletions(-)
lib/librte_eal/common/eal_common_options.c +7 -2
@@ -592,7 +592,9 @@ eal_parse_corelist(const char *corelist)if (*corelist =='\0' )return -1 ; errno =0 ; - idx =strtoul (corelist, &end,10 ); + idx =strtol (corelist, &end,10 ); +if (idx <0 || idx >= (int )cfg->lcore_count) +return -1 ;if (errno || end ==NULL )return -1 ;while (isblank (*end))
@@ -1103,6 +1105,7 @@ eal_parse_common_option(int opt, const char *optarg, {static int b_used;static int w_used; +struct rte_config *cfg =rte_eal_get_configuration ();switch (opt) {/* blacklist */
@@ -1145,7 +1148,9 @@ eal_parse_common_option(int opt, const char *optarg,/* corelist */ case 'l' :if (eal_parse_corelist (optarg) <0 ) { -RTE_LOG (ERR ,EAL ,"invalid core list\n" ); +RTE_LOG (ERR ,EAL , +"invalid core list, please check core numbers are in [0, %u] range\n" , + cfg->lcore_count-1 );return -1 ; }
test/test/test_eal_flags.c +38 -23
115 lines not on this page · raw message
Signature · 1 line
2.17.2
Quoted 20 lines · Hari Kumar Vemula
When incorrect core value or range provided, as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
Added ut check for negative core values. Added unit test case for invalid core number range.
Fixes d888cb8b9613 ("eal: add core list input format")Signed-off-by Hari Kumar Vemula <[email protected]>Reviewed-by David Marchand <[email protected]>--
v6: Changed testcase order
v5: Corrected unit test case for -l option
v4: UsedRTE_MAX_LCOREfor max core check
v3: Added unit test cases for invalid core number range
v2: Replace strtoul with strtol
Modified log message
Quoted 5 lines
--- lib/librte_eal/common/eal_common_options.c | 9 +++- test/test/test_eal_flags.c | 61 ++++++++++++++-------- 2 files changed, 45 insertions(+), 25 deletions(-)
Is this patch related to, or does it fix Bugzilla #19?
https://bugs.dpdk.org/show_bug.cgi?id=19
/Bruce
Quoted 26 lines · Bruce Richardson
Quoted 20 lines · Hari Kumar Vemula
When incorrect core value or range provided, as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
Added ut check for negative core values. Added unit test case for invalid core number range.
Fixes d888cb8b9613 ("eal: add core list input format")Signed-off-by Hari Kumar Vemula <[email protected]>Reviewed-by David Marchand <[email protected]>--
v6: Changed testcase order
v5: Corrected unit test case for -l option
v4: UsedRTE_MAX_LCOREfor max core check
v3: Added unit test cases for invalid core number range
v2: Replace strtoul with strtol
Modified log messageQuoted 5 lines
--- lib/librte_eal/common/eal_common_options.c | 9 +++- test/test/test_eal_flags.c | 61 ++++++++++++++-------- 2 files changed, 45 insertions(+), 25 deletions(-)
Quoted 3 lines
Is this patch related to, or does it fix Bugzilla #19?
Separate issue, from my pov.
I would say the issue happens with a dpdk process that has no cpu available wrt CONFIG_RTE_MAX_CORES.eal_auto_detect_cores() then removes all cores from cfg->lcore_role[], then eal_adjust_config() an incorrect master lcore is chosen at cfg->master_lcore = rte_get_next_lcore(-1, 0, 0); ?
Signature · 1 line
David Marchand
Thomas Monjalon
Applied17/01/2019 13:13, Hari Kumar Vemula:
Quoted 5 lines
When incorrect core value or range provided, as part of -l command line option, a crash occurs.
Added valid range checks to fix the crash.
Quoted 8 lines
Added ut check for negative core values. Added unit test case for invalid core number range.
Fixes d888cb8b9613 ("eal: add core list input format")Signed-off-by Hari Kumar Vemula <[email protected]>Reviewed-by David Marchand <[email protected]>
Applied, thanks