mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: HONG Yifan <elsk@google.com>
Cc: kernel-team@android.com, linux-kbuild@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] kconfig: recursive checks drop file/lineno
Date: Thu, 18 Jul 2024 02:10:52 +0900	[thread overview]
Message-ID: <CAK7LNATdQuPAwC_y71epb_bANqdzJ6SXUUnipCttbgjXF8-Pyw@mail.gmail.com> (raw)
In-Reply-To: <20240717015042.339931-1-elsk@google.com>

On Wed, Jul 17, 2024 at 10:51 AM HONG Yifan <elsk@google.com> wrote:
>
> This prevents segfault when getting filename and lineno in recursive
> checks.
>
> If the following snippet is found in Kconfig:
>
> [Test code 1]
>
> config FOO
>         bool
>         depends on BAR
>         select BAR
>
> ... without BAR defined; then there is a segfault.
>
>   Kconfig:34:error: recursive dependency detected!
>   Kconfig:34:   symbol FOO depends on BAR
>   make[4]: *** [scripts/kconfig/Makefile:85: allnoconfig] Segmentation fault
>
> This is because of the following. BAR is a fake entry created by
> sym_lookup() with prop being NULL. In the recursive check, there is a
> NULL check for prop to fall back to stack->sym->prop if stack->prop is
> NULL. However, in this case, stack->sym points to the fake BAR entry
> created by sym_lookup(), so prop is still NULL. prop was then referenced
> without additional NULL checks, causing segfault.
>
> As the previous email thread suggests, the file and lineno for select is
> also wrong:
>
> [Test code 2]
>
> config FOO
>        bool
>
> config BAR
>        bool
>
> config FOO
>        bool "FOO"
>        depends on BAR
>        select BAR
>
>   $ make defconfig
>   *** Default configuration is based on 'x86_64_defconfig'
>   Kconfig:1:error: recursive dependency detected!
>   Kconfig:1: symbol FOO depends on BAR
>   Kconfig:4: symbol BAR is selected by FOO
>   [...]
>
> Kconfig:4 should be Kconfig:10.
>
> This patch deletes the wrong and segfault-prone filename/lineno
> inference completely. With this patch, Test code 1 yields:
>
> error: recursive dependency detected!
>         symbol FOO depends on BAR
>         symbol BAR is selected by FOO
>
> Link: https://lore.kernel.org/linux-kbuild/20240627231919.2461945-1-elsk@google.com/T/
> Link: https://lore.kernel.org/linux-kbuild/20240620211112.500465-1-elsk@google.com/
> Link: https://lore.kernel.org/linux-kbuild/20240618185609.4096399-1-elsk@google.com/
> Signed-off-by: HONG Yifan <elsk@google.com>
>
> --
> v4: Rebased & addressed comments from masahiroy@kernel.org. Simplify
>     code by dropping `prop` variable.
> v3: Rebase on top of
>     https://lore.kernel.org/linux-kbuild/20240626182212.3758235-1-masahiroy@kernel.org/T/#t
>     & resolve merge conflicts. Fix
>     scripts/kconfig/tests/err_recursive_dep/expected_stderr
> v2: Delete all filenames/lineno completely as suggested by
>     masahiroy@kernel.org


Applied to linux-kbuild.
Thanks!


-- 
Best Regards
Masahiro Yamada

      reply	other threads:[~2024-07-17 17:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-27 23:19 [PATCH v3] " HONG Yifan
2024-07-04 16:25 ` Masahiro Yamada
2024-07-17  1:50   ` [PATCH v4] " HONG Yifan
2024-07-17 17:10     ` Masahiro Yamada [this message]

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=CAK7LNATdQuPAwC_y71epb_bANqdzJ6SXUUnipCttbgjXF8-Pyw@mail.gmail.com \
    --to=masahiroy@kernel.org \
    --cc=elsk@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®