All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: jpoimboe@kernel.org, jikos@kernel.org, mbenes@suse.cz,
	joe.lawrence@redhat.com, song@kernel.org,
	live-patching@vger.kernel.org
Subject: Re: [PATCH v7 for-next 7/8] selftests/livepatch: Add test for state ID conflict across provides
Date: Wed, 2 Sep 2026 17:25:17 +0200	[thread overview]
Message-ID: <apg_3dLUGBeCjKoM@pathway.suse.cz> (raw)
In-Reply-To: <20260825114641.80452-8-laoar.shao@gmail.com>

On Tue 2026-08-25 19:46:40, Yafang Shao wrote:
> Livepatches with different provides ids must not share the same state
> id. If a second livepatch attempts to reuse a state id already
> registered by a livepatch with a different provides id, the loading
> will fail. However, if the second livepatch's obsoletes list includes
> the first livepatch's provides id, the second livepatch replaces the
> first one and may reuse the same state id.
> 
> Add provides and obsoletes module parameters to test_klp_state.c and
> test_klp_state2.c (guarded by #ifndef KLP_HAS_REPLACE) so that they
> can be loaded with different provides ids and obsoletes ids.
> 
> Add a "state id conflict across provides" test scenario to
> test-provides.sh:
> 
>   - Load test_klp_state with provides=1, which registers state ID 1.
>   - Attempt to load test_klp_state2 with provides=2, which reuses the
>     same state ID 1. The second livepatch is rejected because
>     livepatches with different provides ids must not share the same
>     state id.
>   - Disable and unload the remaining livepatch.
> 
> Add a "taking over system state via obsoletes" test scenario to
> test-state.sh:
> 
>   - Load test_klp_state with provides=10, which registers state ID 1.
>   - Load test_klp_state2 with provides=20 obsoletes=10, which reuses the
>     same state ID 1. Although the provides ids differ, the second livepatch
>     replaces the first one because its obsoletes list includes the first
>     livepatch's provides id (10). The state is taken over successfully.
>   - Unload the replaced livepatch, then disable and unload the second
>     livepatch.
> 
> Assisted-by: Comagic:DeepSeek-V4-Flash
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
>  .../livepatch/test-provides-obsoletes.sh      | 86 +++++++++++++++++++
>  .../livepatch/test_modules/test_klp_state.c   |  9 ++
>  .../livepatch/test_modules/test_klp_state2.c  | 19 ++++
>  3 files changed, 114 insertions(+)
> 
> diff --git a/tools/testing/selftests/livepatch/test-provides-obsoletes.sh b/tools/testing/selftests/livepatch/test-provides-obsoletes.sh
> index 2707457b9133..f9a9f9b28490 100755
> --- a/tools/testing/selftests/livepatch/test-provides-obsoletes.sh
> +++ b/tools/testing/selftests/livepatch/test-provides-obsoletes.sh
> @@ -6,6 +6,8 @@
>  
>  MOD_ATOMIC=test_klp_atomic_replace
>  MOD_LIVEPATCH=test_klp_livepatch
> +MOD_STATE=test_klp_state
> +MOD_STATE2=test_klp_state2
>  
>  setup_config
>  
> @@ -171,4 +173,88 @@ livepatch: '$MOD_ATOMIC': completing unpatching transition
>  livepatch: '$MOD_ATOMIC': unpatching complete
>  % rmmod $MOD_ATOMIC"
>  
> +# - load a livepatch with provides=1 that registers state ID 1
> +# - try to load another livepatch with provides=2 that reuses the same
> +#   state ID. The second one must be rejected because livepatches with
> +#   different provides ids must not share the same state id.
> +# - disable and unload the remaining livepatch
> +
> +start_test "state id conflict across provides"
> +
> +load_lp $MOD_STATE provides=1
> +load_failing_mod $MOD_STATE2 provides=2

It is not obvious why it should fail because we do not know the used
state id. It might be better to define it via a parameter. It would
even allow to test more variants:

# same state, same provides
load_lp $MOD_STATE_LP1 state=1 provides=1
load_lp $MOD_STATE_LP2 state=1 provides=1

# same state, misc provides
load_lp $MOD_STATE_LP1 state=1 provides=1
load_failing_mod $MOD_STATE_LP2 state=1 provides=2

# same states, replaced by obsoletes
load_lp $MOD_STATE_LP1 state=1 provides=1
load_lp $MOD_STATE_LP2 state=1 provides=2 obsoletes=1

# misc states, same provides
load_lp $MOD_STATE_LP1 state=1 provides=1
load_failing_mod $MOD_STATE_LP2 state=2 provides=1

# misc states, misc provides
load_lp $MOD_STATE_LP1 state=1 provides=1
load_lp $MOD_STATE_LP2 state=2 provides=2

Best Regards,
Petr

  reply	other threads:[~2026-09-02 15:25 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 11:46 [PATCH v7 for-next 0/8] livepatch: Introduce replace set support Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 1/8] livepatch: Make klp_find_func() non static Yafang Shao
2026-09-08 14:24   ` Miroslav Benes
2026-08-25 11:46 ` [PATCH v7 for-next 2/8] livepatch: Call klp_init_patch_early() earlier Yafang Shao
2026-08-25 12:06   ` sashiko-bot
2026-08-25 12:11     ` Yafang Shao
2026-08-27 23:57   ` Josh Poimboeuf
2026-08-28  2:24     ` Yafang Shao
2026-09-08 14:24   ` Miroslav Benes
2026-08-25 11:46 ` [PATCH v7 for-next 3/8] livepatch: Implement replace set for scoped atomic replace Yafang Shao
2026-08-25 11:59   ` sashiko-bot
2026-08-25 12:10     ` Yafang Shao
2026-08-28  0:26   ` Josh Poimboeuf
2026-08-28  3:03     ` Yafang Shao
2026-08-28  3:39       ` Josh Poimboeuf
2026-08-28  5:42         ` Yafang Shao
2026-09-02  7:31   ` Replace rules: was: " Petr Mladek
2026-09-02  9:40     ` Yafang Shao
2026-09-02 11:50       ` Yafang Shao
2026-09-03 10:01         ` Petr Mladek
2026-09-06  2:58           ` Yafang Shao
2026-09-03  9:27       ` Petr Mladek
2026-09-03 21:18         ` Song Liu
2026-09-06  8:34           ` Yafang Shao
2026-09-09 12:32         ` Miroslav Benes
2026-09-09 18:45           ` Song Liu
2026-09-10  8:31             ` Miroslav Benes
2026-09-10  9:17               ` Yafang Shao
2026-09-10 21:59               ` Song Liu
2026-09-02  7:34   ` documentation: " Petr Mladek
2026-09-02  9:50     ` Yafang Shao
2026-09-03  7:30       ` Petr Mladek
2026-09-02  7:37   ` code cleanup: " Petr Mladek
2026-09-02  9:52     ` Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 4/8] livepatch: Deprecate stack_order Yafang Shao
2026-08-28  0:29   ` Josh Poimboeuf
2026-08-28  3:14     ` Yafang Shao
2026-09-02 12:01   ` Petr Mladek
2026-09-02 12:20     ` Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 5/8] selftests/livepatch: Adapt atomic replace tests to provides/obsoletes Yafang Shao
2026-08-28  0:31   ` Josh Poimboeuf
2026-08-28  3:56     ` Yafang Shao
2026-09-02 13:45   ` Petr Mladek
2026-09-03  3:23     ` Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 6/8] selftests/livepatch: Add provides/obsoletes test scenarios Yafang Shao
2026-09-02 15:15   ` Petr Mladek
2026-09-03  5:43     ` Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 7/8] selftests/livepatch: Add test for state ID conflict across provides Yafang Shao
2026-09-02 15:25   ` Petr Mladek [this message]
2026-09-03  5:44     ` Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 8/8] selftests/livepatch: Add test for function " Yafang Shao
2026-09-02 15:51   ` Petr Mladek
2026-09-03  5:48     ` Yafang Shao

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=apg_3dLUGBeCjKoM@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=jikos@kernel.org \
    --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=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 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.