From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from latitanza.investici.org (latitanza.investici.org [185.218.207.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 397A32E739B for ; Sun, 26 Jul 2026 22:55:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.218.207.228 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785106552; cv=none; b=O7nKKVIPCBiriRM9+HJlLVp46h30053l9nGjGQNBQ1FbdDc8HPaJkrSSSFQzQQfJGkbXtbI0OUUHmaqerwFzzTq6jD45O4nHc7qo/bIhFYJg1OpEWjKiudrZ60mH/mzYBrdHuOF4ZbKVw2UcjHB9QncfDvs1HEv/prUnLnXL504= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785106552; c=relaxed/simple; bh=ONlbu2gfIyFFlQaC4lVN4taSXCHs1IUL788p/uZI8gY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nPOKyHYarAQInnJ60TnC/pub9e82duDGYhWOWWPz7Ganx2lVLEVADHDG6ZL7zFOgjdl4YsHl7XKVPHqosB5yRTH7lGd7dOPsI49lw5g4+G5Ts0RlgGBgEl7UAp02TG+7VJ/TbHoXfAcXxwlPV7Kny4OyLfTwo1DZ5jka9l/v/3g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net; spf=pass smtp.mailfrom=grrlz.net; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b=U9u8j61q; arc=none smtp.client-ip=185.218.207.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=grrlz.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b="U9u8j61q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grrlz.net; s=stigmate; t=1785106540; bh=iB+kAN4UqDSVy26evTkO8LmtXHjnmhTby3BK2PKeyxc=; h=From:To:Cc:Subject:Date:From; b=U9u8j61qPG+EiGzMa8ZG8GN2MxI5YP+3/UJkndOSHmXqiooBxYfM7vWIg4lOP3YS5 t4Kbe7YQL/GSl4W+/RuWiEC9L6JvnssYrDCHVq7b8ZNlhE5N3pMXg3ANxNaeuKhDyS 00LeTvjEaBCJWOUM3MPge70A1SKbMHYi7wqLaOnA= Received: from mx3.investici.org (unknown [127.0.0.1]) by latitanza.investici.org (Postfix) with ESMTP id 4h7cWw4l5rzGpLd; Sun, 26 Jul 2026 22:55:40 +0000 (UTC) Received: by mx3.investici.org (Postfix) id 4h7cWw2mVLzGpLX; Sun, 26 Jul 2026 22:55:40 +0000 (UTC) From: Bradley Morgan To: Andrew Morton Cc: Kees Cook , linux-kernel@vger.kernel.org, Bradley Morgan Subject: [PATCH] reboot: don't use cb_data to tell if the static sys-off handler is free Date: Sun, 26 Jul 2026 22:55:41 +0000 Message-ID: <20260726225541.13304-1-include@grrlz.net> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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()") Signed-off-by: Bradley Morgan --- kernel/reboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/reboot.c b/kernel/reboot.c index f070c5c1103a..42fe2708f5d9 100644 --- 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