From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A512AE95A91 for ; Mon, 9 Oct 2023 15:30:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376536AbjJIPaw convert rfc822-to-8bit (ORCPT ); Mon, 9 Oct 2023 11:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376424AbjJIPat (ORCPT ); Mon, 9 Oct 2023 11:30:49 -0400 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49EB2A3 for ; Mon, 9 Oct 2023 08:30:47 -0700 (PDT) Received: from in01.mta.xmission.com ([166.70.13.51]:38198) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1qpsDU-0060Yb-3i; Mon, 09 Oct 2023 09:30:44 -0600 Received: from ip68-227-168-167.om.om.cox.net ([68.227.168.167]:38624 helo=email.froward.int.ebiederm.org.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1qpsDQ-007a4Q-RL; Mon, 09 Oct 2023 09:30:43 -0600 From: "Eric W. Biederman" To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, Steven Rostedt , Ricardo Ribalda , Ross Zwisler , Rob Clark , Linus Torvalds , kexec@lists.infradead.org References: <20230929021213.2364883-1-joel@joelfernandes.org> <87bkdl55qm.fsf@email.froward.int.ebiederm.org> Date: Mon, 09 Oct 2023 10:21:04 -0500 In-Reply-To: (Joel Fernandes's message of "Sat, 7 Oct 2023 21:30:42 -0400") Message-ID: <87il7fzusf.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-XM-SPF: eid=1qpsDQ-007a4Q-RL;;;mid=<87il7fzusf.fsf@email.froward.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.227.168.167;;;frm=ebiederm@xmission.com;;;spf=pass X-XM-AID: U2FsdGVkX1/05uh69me2MdpVapboGWSZ9mJiUasho74= X-SA-Exim-Connect-IP: 68.227.168.167 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH] kexec: Fix reboot race during device_shutdown() X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Joel Fernandes writes: > On Mon, Oct 2, 2023 at 2:18 PM Joel Fernandes wrote: > [..] >> > > Such freezing is already being done if kernel supports KEXEC_JUMP and >> > > kexec_image->preserve_context is true. However, doing it if either of these are >> > > not true prevents crashes/races. >> > >> > The KEXEC_JUMP case is something else entirely. It is supposed to work >> > like suspend to RAM. Maybe reboot should as well, but I am >> > uncomfortable making a generic device fix kexec specific. >> >> I see your point of view. I think regular reboot should also be fixed >> to avoid similar crash possibilities. I am happy to make a change for >> that similar to this patch if we want to proceed that way. >> >> Thoughts? > > Just checking how we want to proceed, is the consensus that we should > prevent kernel crashes without relying on userspace stopping all > processes? Should we fix regular reboot syscall as well and not just > kexec reboot? It just occurred to me there is something very fishy about all of this. What userspace do you have using kexec (not kexec on panic) that doesn't preform the same userspace shutdown as a normal reboot? Quite frankly such a userspace is buggy, and arguably that is where you should start fixing things. That way you can get the orderly shutdown of userspace daemons/services along with an orderly shutdown of everything the kernel is responsible for. At the kernel level a kexec reboot and a normal reboot have been deliberately kept as close as possible. Which is why I say we should fix it in reboot. Eric