LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Michal Marek <mmarek@suse.cz>
To: Ulf Magnusson <ulfalizer.lkml@gmail.com>,
linux-kbuild@vger.kernel.org, zippel@linux-m68k.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kconfig: undefined symbols can crash dependency loop detection
Date: Thu, 10 Feb 2011 16:23:55 +0100 [thread overview]
Message-ID: <4D54030B.5040407@suse.cz> (raw)
In-Reply-To: <20110204231611.GA9344@ulf>
On 5.2.2011 00:16, Ulf Magnusson wrote:
> The Kconfig
>
> config FOO
> bool "FOO" if BAR
> select BAR
>
> has a dependency loop involving an undefined symbol BAR. This causes a
> segfault in sym_check_print_recursive() as it assumes all symbols have a
> non-null 'prop', which is not the case for undefined symbols. This is a
> proposed fix.
>
> Signed-off-by: Ulf Magnusson <ulfalizer.lkml@gmail.com>
> ---
> scripts/kconfig/symbol.c | 32 ++++++++++++++++++++++++++++----
> 1 files changed, 28 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
> index a796c95..81a217f 100644
> --- a/scripts/kconfig/symbol.c
> +++ b/scripts/kconfig/symbol.c
> @@ -5,6 +5,7 @@
>
> #include <ctype.h>
> #include <stdlib.h>
> +#include <stdio.h>
> #include <string.h>
> #include <regex.h>
> #include <sys/utsname.h>
> @@ -972,6 +973,10 @@ static void sym_check_print_recursive(struct symbol *last_sym)
> struct menu *menu = NULL;
> struct property *prop;
> struct dep_stack cv_stack;
> + const char *filename;
> + int lineno;
> + char undef_msg_buf[100];
> + int snprintf_size;
>
> if (sym_is_choice_value(last_sym)) {
> dep_stack_insert(&cv_stack, last_sym);
> @@ -1001,18 +1006,37 @@ static void sym_check_print_recursive(struct symbol *last_sym)
> break;
> }
> }
> +
> + if (prop) {
> + filename = prop->file->name;
> + lineno = prop->lineno;
> + } else {
> + /* The dependency loop involves an undefined symbol.
> + * Checking sym->name is probably unnecessary here, but
> + * just to be on the safe side. */
> + snprintf_size = snprintf(undef_msg_buf,
> + sizeof(undef_msg_buf),
> + "<no file, %s is undefined>",
> + sym->name ? sym->name :
> + "<choice>");
> + if (snprintf_size > sizeof(undef_msg_buf))
> + undef_msg_buf[sizeof(undef_msg_buf) - 1] = '\0';
> + filename = undef_msg_buf;
> + lineno = 0;
Good catch. But as this handles a corner case involving a severely
borken Kconfig file, I would simply do
filename = "<unknown>";
lineno = 0;
and be done with it.
Michal
next prev parent reply other threads:[~2011-02-10 15:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-04 23:16 Ulf Magnusson
2011-02-10 15:23 ` Michal Marek [this message]
2011-02-10 22:35 ` Ulf Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D54030B.5040407@suse.cz \
--to=mmarek@suse.cz \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ulfalizer.lkml@gmail.com \
--cc=zippel@linux-m68k.org \
--subject='Re: [PATCH] kconfig: undefined symbols can crash dependency loop detection' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).