From: Petr Mladek <pmladek@suse.com>
To: Marcos Paulo de Souza <mpdesouza@suse.com>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
Joe Lawrence <joe.lawrence@redhat.com>,
Shuah Khan <shuah@kernel.org>,
live-patching@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, marcos@mpdesouza.com
Subject: Re: [PATCH 3/4] selftests: livepatch: Adapt mod_target module to pass on 4.12 kernels
Date: Fri, 5 Jun 2026 16:36:47 +0200 [thread overview]
Message-ID: <aiLe_3T3rHd2-Ryb@pathway.suse.cz> (raw)
In-Reply-To: <20260524-livepatch-unload-on-fail-v1-3-7465de7f741d@suse.com>
On Sun 2026-05-24 20:50:32, Marcos Paulo de Souza wrote:
> Use the stable module_param_cb API instead of proc_fs for exposing module
> state. This approach is compatible with kernel 4.12 and later. The end
> result is the same: the module has a function that shows a string, which
> is later livepatched to show a different string. The only difference is
> that the file being checked is now a module parameter instead of a
> procfs entry.
>
> --- a/tools/testing/selftests/livepatch/test-livepatch.sh
> +++ b/tools/testing/selftests/livepatch/test-livepatch.sh
> @@ -198,26 +198,25 @@ livepatch: '$MOD_REPLACE': unpatching complete
> % rmmod $MOD_REPLACE"
>
>
> -# - load a target module that provides /proc/test_klp_mod_target with
> -# original output
> -# - load a livepatch that patches the target module's show function
> -# - verify the proc entry returns livepatched output
> +# - load a target module with module_param_cb get data with original output
> +# - load a livepatch that patches the target module's get function
> +# - verify the parameter get function returns the livepatched output
> # - disable and unload the livepatch
> -# - verify the proc entry returns original output again
> +# - verify the parameter get function returns the original output again
> # - unload the target module
>
> start_test "module function patching"
>
> load_mod $MOD_TARGET
>
> -if [[ "$(cat /proc/$MOD_TARGET)" != "$MOD_TARGET: original output" ]] ; then
> +if [[ "$(cat $SYSFS_MODULE_DIR/$MOD_TARGET/parameters/klp_mod_arg)" != "$MOD_TARGET: original output" ]] ; then
I would personally call the parameter "test" or something simple.
A better descriptive name was needed in the top-level /proc directory
to prevent conflicts. But the module-specific parameter is
checked module-specific directory...
> echo -e "FAIL\n\n"
> die "livepatch kselftest(s) failed"
> fi
>
> --- a/tools/testing/selftests/livepatch/test_modules/test_klp_mod_patch.c
> +++ b/tools/testing/selftests/livepatch/test_modules/test_klp_mod_patch.c
> @@ -8,17 +8,16 @@
> #include <linux/livepatch.h>
> #include <linux/seq_file.h>
>
> -static int livepatch_mod_target_show(struct seq_file *m, void *v)
> +static int livepatch_mod_target_get(char *buffer, const struct kernel_param *kp)
> {
> - seq_printf(m, "%s: %s\n", THIS_MODULE->name,
> - "this has been live patched");
> - return 0;
> + return sprintf(buffer, "%s: %s\n", THIS_MODULE->name,
> + "this has been live patched");
Please, use sysfs_emit() instead of sprintf(). It is a specifically
designed API for sysfs output. It prevents a potential buffer overflow.
It is less important here. But we should show good examples...
> }
>
> static struct klp_func funcs[] = {
> {
> - .old_name = "test_klp_mod_target_show",
> - .new_func = livepatch_mod_target_show,
> + .old_name = "test_klp_mod_target_get",
> + .new_func = livepatch_mod_target_get,
> },
> {},
> };
Otherwise the change looks good to me.
Best Regards,
Petr
next prev parent reply other threads:[~2026-06-05 14:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-24 23:50 [PATCH 0/4] selftests: livepatch: Support 4.12 kernels Marcos Paulo de Souza
2026-05-24 23:50 ` [PATCH 1/4] selftests: livepatch: Introduce _remove_mod function Marcos Paulo de Souza
2026-05-24 23:59 ` sashiko-bot
2026-05-25 11:49 ` Marcos Paulo de Souza
2026-06-05 13:44 ` Petr Mladek
2026-05-24 23:50 ` [PATCH 2/4] selftests: livepatch: Remove leftover modules when a testcase fails Marcos Paulo de Souza
2026-05-25 0:06 ` sashiko-bot
2026-06-05 14:15 ` Petr Mladek
2026-06-05 13:59 ` Petr Mladek
2026-05-24 23:50 ` [PATCH 3/4] selftests: livepatch: Adapt mod_target module to pass on 4.12 kernels Marcos Paulo de Souza
2026-05-25 0:24 ` sashiko-bot
2026-06-05 14:05 ` Marcos Paulo de Souza
2026-06-05 14:39 ` Petr Mladek
2026-06-05 14:36 ` Petr Mladek [this message]
2026-05-24 23:50 ` [PATCH 4/4] selftests: livepatch: Add information about minimum kernel support Marcos Paulo de Souza
2026-05-25 0:29 ` sashiko-bot
2026-06-05 15:14 ` Petr Mladek
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=aiLe_3T3rHd2-Ryb@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=marcos@mpdesouza.com \
--cc=mbenes@suse.cz \
--cc=mpdesouza@suse.com \
--cc=shuah@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