Live Patching
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sasha Levin" <sashal@kernel.org>,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Miroslav Benes" <mbenes@suse.cz>,
	"Petr Mladek" <pmladek@suse.com>,
	"Joe Lawrence" <joe.lawrence@redhat.com>
Cc: "Song Liu" <song@kernel.org>,
	"Marcos Paulo de Souza" <mpdesouza@suse.com>,
	"Eva Kurchatova" <eva.kurchatova@virtuozzo.com>,
	"Yafang Shao" <laoar.shao@gmail.com>,
	"Shuah Khan" <shuah@kernel.org>,
	live-patching@vger.kernel.org
Subject: Re: [PATCH v3 1/2] selftests/livepatch: build test modules against the selected kernel
Date: Tue, 03 Nov 2026 22:43:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-196148@kernel.org> (raw)
In-Reply-To: <20261103222706.1642224-2-sashal@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests/livepatch: KDIR selection ignores .config without Module.symvers
--

commit ae4848cae1b2b7420ab6ac44f707bd616ad82b5a
Author: Sasha Levin <sashal@kernel.org>

selftests/livepatch: build test modules against the selected kernel

This commit updates the livepatch selftests build and test scripts to select
KDIR from O, KBUILD_OUTPUT, or the source tree before falling back to the
running kernel's build directory, stops forwarding O and KBUILD_OUTPUT to the
external module build, and skips building or running tests when
CONFIG_LIVEPATCH is disabled.

> diff --git a/tools/testing/selftests/livepatch/Makefile b/tools/testing/selftests/livepatch/Makefile
> index a080eb54a215d..5c631812575dc 100644
> --- a/tools/testing/selftests/livepatch/Makefile
> +++ b/tools/testing/selftests/livepatch/Makefile
> @@ -1,7 +1,26 @@
>  # SPDX-License-Identifier: GPL-2.0
>  
> +ifndef KDIR
> +LIVEPATCH_OBJTREE := $(firstword $(O) $(KBUILD_OUTPUT))
> +ifneq ($(and $(LIVEPATCH_OBJTREE),$(wildcard $(LIVEPATCH_OBJTREE)/Module.symvers)),)
> +KDIR := $(LIVEPATCH_OBJTREE)
> +else ifneq ($(wildcard ../../../../Module.symvers),)
> +KDIR := ../../../..
> +else
> +KDIR := /lib/modules/$(shell uname -r)/build
> +endif
> +endif
> +override KDIR := $(abspath $(KDIR))
> +export KDIR
> +MAKEOVERRIDES := $(filter-out KDIR=%,$(MAKEOVERRIDES))
> +
> +LIVEPATCH_CONFIG := $(shell if [ -r "$(KDIR)/.config" ]; then \
> +	grep -qx 'CONFIG_LIVEPATCH=y' "$(KDIR)/.config" && echo y || echo n; fi)

[Severity: Medium]
When KDIR is not explicitly set, KDIR only selects $(LIVEPATCH_OBJTREE) or
../../../.. if Module.symvers exists in that directory, falling back to
/lib/modules/$(shell uname -r)/build otherwise. Then LIVEPATCH_CONFIG checks
$(KDIR)/.config for CONFIG_LIVEPATCH=y.

If a kernel is configured and built with CONFIG_MODULES=n (so CONFIG_LIVEPATCH
is also disabled), the top-level Makefile clears KBUILD_MODULES and
scripts/Makefile.modpost sets output-symdump to vmlinux.symvers instead of
Module.symvers:

scripts/Makefile.modpost:
output-symdump := $(if $(KBUILD_MODULES), Module.symvers, vmlinux.symvers)

Because Module.symvers is never created in that build, or when running make
kselftest-all or building only a kernel image target before modules, .config
exists in $(LIVEPATCH_OBJTREE) or ../../../.. without Module.symvers.

In those cases, wouldn't KDIR ignore the target kernel directory and fall back
to /lib/modules/$(uname -r)/build, causing LIVEPATCH_CONFIG to read the
running host kernel's .config and attempt to build test_modules against the
host kernel instead of skipping or using the target kernel tree? Conversely,
if O= points to an unprepared kernel build tree configured with
CONFIG_LIVEPATCH=y, wouldn't KDIR silently fall back to ../../../.. or
/lib/modules/$(uname -r)/build instead of using O=?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103222706.1642224-1-sashal@kernel.org?part=1

  reply	other threads:[~2026-11-03 22:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 22:27 [PATCH v3 0/2] selftests/livepatch: fix building and running outside the host kernel Sasha Levin
2026-11-03 22:27 ` [PATCH v3 1/2] selftests/livepatch: build test modules against the selected kernel Sasha Levin
2026-11-03 22:43   ` sashiko-bot [this message]
2026-11-03 22:27 ` [PATCH v3 2/2] selftests/livepatch: skip based on the test modules instead of KDIR Sasha Levin

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=sashiko-outbox-196148@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eva.kurchatova@virtuozzo.com \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=laoar.shao@gmail.com \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=mpdesouza@suse.com \
    --cc=pmladek@suse.com \
    --cc=sashal@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shuah@kernel.org \
    --cc=song@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