mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miroslav Benes <mbenes@suse.cz>
To: Andrea Parri <parri.andrea@gmail.com>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
	Jiri Kosina <jikos@kernel.org>,  Petr Mladek <pmladek@suse.com>,
	Joe Lawrence <joe.lawrence@redhat.com>,
	 Song Liu <song@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	 live-patching@vger.kernel.org, linux-kernel@vger.kernel.org,
	 stable@vger.kernel.org, petr.pavlu@suse.com
Subject: Re: [PATCH] livepatch: Fix races between stack check and module load/unload
Date: Fri, 16 Oct 2026 16:31:02 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LSU.2.21.2610161625430.16668@pobox.suse.cz> (raw)
In-Reply-To: <20261014133553.102324-1-parri.andrea@gmail.com>

> An LLM found it while auditing kernel/livepatch/.  It is not a
> production issue.  The reproducer was written by an LLM as well; it is
> below, apply it with "git apply -p0".  It keeps a transition stuck on
> a few kthreads and reloads a patched module in a loop.  On v7.3-rc7 it
> faults in klp_find_ops() within a few minutes with KCSAN_STRICT=y.

Ok, kthreads certainly make it easier.
 
> > I wonder whether we could just decline delete_module() in this case and
> > return -EBUSY. It should be a rare operation anyway. Alternatively we
> > could increase refcounts of all patched modules during a transition and
> > decrease them after.
> 
> I don't think either covers all the paths.  klp_module_going() is also
> called when a module's init fails, or when its load is aborted after
> klp_module_coming(), and neither -EBUSY nor a module reference prevents
> that.  Loading a patched module also adds to klp_ops under the walk.
> And klp_find_ops() walks the global klp_ops list, so it's the modules of
> all patches that matter, not just the transition patch.

Correct. You would need to check all and you would need to hook up to the 
module loader differently to the current state.

> > I am not saying we should not do the RCU protection but it feels like a
> > can of worms a bit so if there is an easier way...
> 
> I could split it: one patch RCU-protecting klp_ops, which fixes the
> crash, and a second one for the ordering on module reload, which was found
> by inspection and has not been reproduced.  Would that be easier to review?

Please. It should always be well structured (a logical change per a 
separate patch and such).

Let's explore Petr's proposal first though.

Miroslav

  reply	other threads:[~2026-10-16 14:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 14:05 Andrea Parri
2026-10-12 14:49 ` Peter Zijlstra
2026-10-12 15:07   ` Andrea Parri
2026-10-14 12:23 ` Miroslav Benes
2026-10-14 13:35   ` Andrea Parri
2026-10-16 14:31     ` Miroslav Benes [this message]
2026-10-14 14:30   ` Petr Mladek
2026-10-14 20:36     ` Andrea Parri

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=alpine.LSU.2.21.2610161625430.16668@pobox.suse.cz \
    --to=mbenes@suse.cz \
    --cc=jikos@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=parri.andrea@gmail.com \
    --cc=peterz@infradead.org \
    --cc=petr.pavlu@suse.com \
    --cc=pmladek@suse.com \
    --cc=song@kernel.org \
    --cc=stable@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®