* [LTP] [PATCH 0/2] Two small fixes for kconfig parser
@ 2021-09-15 14:37 ` Cyril Hrubis
2021-09-15 14:37 ` Cyril Hrubis
2021-09-15 14:37 ` Cyril Hrubis
0 siblings, 2 replies; 6+ messages in thread
From: Cyril Hrubis @ 2021-09-15 14:37 UTC (permalink / raw)
To: ltp
Cyril Hrubis (2):
lib: tst_kconfig: Fix typo Constrain -> Constraint
lib: tst_kconfig: Fix segfaults on variable value mismatch
lib/newlib_tests/config07 | 5 +++++
lib/tst_kconfig.c | 6 +++++-
2 files changed, 10 insertions(+), 1 deletion(-)
create mode 100644 lib/newlib_tests/config07
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH 1/2] lib: tst_kconfig: Fix typo Constrain -> Constraint
@ 2021-09-15 14:37 ` Cyril Hrubis
2021-09-16 10:20 ` Richard Palethorpe
0 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2021-09-15 14:37 UTC (permalink / raw)
To: ltp
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
lib/tst_kconfig.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
index c2b85821b..c9de3017b 100644
--- a/lib/tst_kconfig.c
+++ b/lib/tst_kconfig.c
@@ -497,7 +497,7 @@ void tst_kconfig_check(const char *const kconfigs[])
if (val != 1) {
abort_test = 1;
- tst_res(TINFO, "Constrain '%s' not satisfied!", kconfigs[i]);
+ tst_res(TINFO, "Constraint '%s' not satisfied!", kconfigs[i]);
dump_vars(exprs[i]);
}
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH 2/2] lib: tst_kconfig: Fix segfaults on variable value mismatch
@ 2021-09-15 14:37 ` Cyril Hrubis
2021-09-16 10:41 ` Richard Palethorpe
0 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2021-09-15 14:37 UTC (permalink / raw)
To: ltp
If we add CONFIG_FOO=value to the test .needs_kconfig while the kernel
config will not define the particular value we will blindly call
strlen() on the val->val and end up with SegFault. Fix this by checking
that the variable has value set first.
Also initialize the val->val to NULL so that we get segfaults 100% of
the time when we attempt to dereference the value when not defined.
+ Test
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
lib/newlib_tests/config07 | 5 +++++
lib/tst_kconfig.c | 4 ++++
2 files changed, 9 insertions(+)
create mode 100644 lib/newlib_tests/config07
diff --git a/lib/newlib_tests/config07 b/lib/newlib_tests/config07
new file mode 100644
index 000000000..dd67120f7
--- /dev/null
+++ b/lib/newlib_tests/config07
@@ -0,0 +1,5 @@
+# The default hostaname value mismatch
+CONFIG_MMU=y
+CONFIG_EXT4_FS=m
+CONFIG_PGTABLE_LEVELS=4
+CONFIG_DEFAULT_HOSTNAME=m
diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
index c9de3017b..5af67b0a5 100644
--- a/lib/tst_kconfig.c
+++ b/lib/tst_kconfig.c
@@ -392,6 +392,7 @@ static inline unsigned int populate_vars(struct tst_expr *exprs[],
strncpy(vars[cnt].id, j->tok, vars[cnt].id_len);
vars[cnt].id[vars[cnt].id_len] = 0;
vars[cnt].choice = 0;
+ vars[cnt].val = NULL;
var = find_var(vars, cnt, vars[cnt].id);
@@ -435,6 +436,9 @@ static int map(struct tst_expr_tok *expr)
if (choice != 'v')
return var->choice == choice;
+ if (var->choice != 'v')
+ return 0;
+
if (strlen(var->val) != len)
return 0;
--
2.32.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH 1/2] lib: tst_kconfig: Fix typo Constrain -> Constraint
@ 2021-09-16 10:20 ` Richard Palethorpe
0 siblings, 0 replies; 6+ messages in thread
From: Richard Palethorpe @ 2021-09-16 10:20 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi,
Reviewed-by: Richard Palethorpe <rpalethorpe@suse.com>
Cyril Hrubis <chrubis@suse.cz> writes:
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
> lib/tst_kconfig.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> index c2b85821b..c9de3017b 100644
> --- a/lib/tst_kconfig.c
> +++ b/lib/tst_kconfig.c
> @@ -497,7 +497,7 @@ void tst_kconfig_check(const char *const kconfigs[])
>
> if (val != 1) {
> abort_test = 1;
> - tst_res(TINFO, "Constrain '%s' not satisfied!", kconfigs[i]);
> + tst_res(TINFO, "Constraint '%s' not satisfied!", kconfigs[i]);
> dump_vars(exprs[i]);
> }
>
> --
> 2.32.0
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH 2/2] lib: tst_kconfig: Fix segfaults on variable value mismatch
@ 2021-09-16 10:41 ` Richard Palethorpe
2021-09-16 13:06 ` Cyril Hrubis
0 siblings, 1 reply; 6+ messages in thread
From: Richard Palethorpe @ 2021-09-16 10:41 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hello,
Reviewed-by: Richard Palethorpe <rpalethorpe@suse.com>
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH 2/2] lib: tst_kconfig: Fix segfaults on variable value mismatch
@ 2021-09-16 13:06 ` Cyril Hrubis
0 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2021-09-16 13:06 UTC (permalink / raw)
To: Richard Palethorpe; +Cc: ltp
Hi!
Thanks for the review, pushed.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-09-16 13:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15 14:37 [LTP] [PATCH 0/2] Two small fixes for kconfig parser Cyril Hrubis
2021-09-15 14:37 ` Cyril Hrubis
2021-09-15 14:37 ` [LTP] [PATCH 1/2] lib: tst_kconfig: Fix typo Constrain -> Constraint Cyril Hrubis
2021-09-15 14:37 ` Cyril Hrubis
2021-09-16 10:20 ` Richard Palethorpe
2021-09-16 10:20 ` Richard Palethorpe
2021-09-15 14:37 ` [LTP] [PATCH 2/2] lib: tst_kconfig: Fix segfaults on variable value mismatch Cyril Hrubis
2021-09-15 14:37 ` Cyril Hrubis
2021-09-16 10:41 ` Richard Palethorpe
2021-09-16 10:41 ` Richard Palethorpe
2021-09-16 13:06 ` Cyril Hrubis
2021-09-16 13:06 ` Cyril Hrubis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.