From: Andrew Morton <akpm@linux-foundation.org>
To: Bradley Morgan <bradley.morgan@linux.dev>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
Dmitry Osipenko <dmitry.osipenko@collabora.com>,
Max Filippov <jcmvbkbc@gmail.com>,
Chris Zankel <chris@zankel.net>, Andrew Davis <afd@ti.com>,
Oleg Nesterov <oleg@redhat.com>, Petr Mladek <pmladek@suse.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] reboot: fix platform sys_off handler reuse with NULL cb_data
Date: Wed, 2 Dec 2026 21:50:35 -0800 [thread overview]
Message-ID: <20261202215035.d1fd85e7da5b4f9071e84dcb@linux-foundation.org> (raw)
In-Reply-To: <20261126214754.3630965-2-bradley.morgan@linux.dev>
On Thu, 26 Nov 2026 21:47:53 +0000 Bradley Morgan <bradley.morgan@linux.dev> wrote:
> In alloc_sys_off_handler(), the check for whether the static
> platform_sys_off_handler is already in use checks handler->cb_data,
> which is a weird assumption since cb_data is optional and callers can
> just pass NULL. If a caller registers at SYS_OFF_PRIO_PLATFORM with
> NULL cb_data, a second SYS_OFF_PRIO_PLATFORM registration gets the same
> struct back, overwrites its fields, and links the same notifier_block
> into another chain while it is still on the first one. For example, on
> xtensa ISS platform_setup() registers iss_restart and iss_power_off
> this way, so restarting calls iss_power_off() instead and splices the
> two lists together if any lower priority poweroff handler is around.
>
> To fix this, resolve the mode and list first, keep one static handler
> per mode in platform_sys_off_handlers[], and check handler->list instead
> of handler->cb_data so a NULL cb_data cannot slip past -EBUSY.
>
> ...
>
> --- a/kernel/reboot.c
> +++ b/kernel/reboot.c
> @@ -394,7 +396,9 @@ static struct sys_off_handler *alloc_sys_off_handler(int priority)
>
> static void free_sys_off_handler(struct sys_off_handler *handler)
> {
> - if (handler == &platform_sys_off_handler)
> + if (handler >= platform_sys_off_handlers &&
> + handler < platform_sys_off_handlers +
> + ARRAY_SIZE(platform_sys_off_handlers))
But `handler' can be allocated with kzalloc_obj(), so comparing that
pointer with the statically allocated array members isn't meaningful?
next prev parent reply other threads:[~2026-12-03 5:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 21:47 [PATCH 0/2] Fix a few snafus in the reboot code Bradley Morgan
2026-11-26 21:47 ` [PATCH 1/2] reboot: fix platform sys_off handler reuse with NULL cb_data Bradley Morgan
2026-12-03 5:50 ` Andrew Morton [this message]
2026-12-03 5:53 ` Andrew Morton
2026-11-26 21:47 ` [PATCH 2/2] reboot: register legacy pm_power_off once at boot Bradley Morgan
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=20261202215035.d1fd85e7da5b4f9071e84dcb@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=afd@ti.com \
--cc=bradley.morgan@linux.dev \
--cc=chris@zankel.net \
--cc=dmitry.osipenko@collabora.com \
--cc=jcmvbkbc@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=pmladek@suse.com \
--cc=rafael@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®