mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Bradley Morgan <include@grrlz.net>
Cc: Kees Cook <kees@kernel.org>,
	linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Dmitry Osipenko <dmitry.osipenko@collabora.com>,
	Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Subject: Re: [PATCH] reboot: don't use cb_data to tell if the static sys-off handler is free
Date: Mon, 27 Jul 2026 16:07:53 -0700	[thread overview]
Message-ID: <20260727160753.57df153ccc25cb5273ac4a8d@linux-foundation.org> (raw)
In-Reply-To: <20260726225541.13304-1-include@grrlz.net>

On Sun, 26 Jul 2026 22:55:41 +0000 Bradley Morgan <include@grrlz.net> wrote:

> There is one static handler for SYS_OFF_PRIO_PLATFORM, shared by all
> modes, so the second platform priority registration has to fail with
> -EBUSY. alloc_sys_off_handler() decides that by testing cb_data.
> 
> cb_data is caller data though, and nothing says it has to be set. A
> registration that passes NULL for it leaves the static handler
> looking free, so the next one gets the same struct back while the
> first is still live: sys_off_cb and list get overwritten, and the
> same notifier_block is registered into a second chain. A
> notifier_block has one next pointer, so both chains end up wrong.
> 
> register_platform_power_off() always passes the power off callback as
> cb_data, which is why this held up when the static handler was added.
> Callers using register_sys_off_handler() directly have no such rule.
> 
> Test sys_off_cb instead. Every handler has one, it is what the
> callback path actually needs, and it is set for as long as the
> handler is registered.
> 
> Fixes: 587b9bfe0668 ("kernel/reboot: Use static handler for register_platform_power_off()")

Please do try to hunt down the people who are best situated to review
proposed changes.  `git show 587b9bfe0668' ain't hard!

I assume you saw the possible pre-existing thing:
	https://sashiko.dev/#/patchset/20260726225541.13304-1-include@grrlz.net

>
> ...
>
> --- a/kernel/reboot.c
> +++ b/kernel/reboot.c
> @@ -366,7 +366,7 @@ static struct sys_off_handler *alloc_sys_off_handler(int priority)
>  	 */
>  	if (priority == SYS_OFF_PRIO_PLATFORM) {
>  		handler = &platform_sys_off_handler;
> -		if (handler->cb_data)
> +		if (handler->sys_off_cb)
>  			return ERR_PTR(-EBUSY);
>  	} else {
>  		if (system_state > SYSTEM_RUNNING)
> -- 
> 2.47.3

      reply	other threads:[~2026-07-27 23:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-26 22:55 Bradley Morgan
2026-07-27 23:07 ` Andrew Morton [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=20260727160753.57df153ccc25cb5273ac4a8d@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dmitry.osipenko@collabora.com \
    --cc=geert@linux-m68k.org \
    --cc=include@grrlz.net \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    /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®