Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp395738rdg; Tue, 10 Oct 2023 13:37:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeiY3FHj/Hvy7YqfTSKrnVVXgtx8h4qjFJO3lULXGUSwRZeUNC4GMBXlrcZSdEGoIoiJGC X-Received: by 2002:a17:902:7682:b0:1c1:e380:b128 with SMTP id m2-20020a170902768200b001c1e380b128mr16702830pll.60.1696970278211; Tue, 10 Oct 2023 13:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696970278; cv=none; d=google.com; s=arc-20160816; b=SbsChFZg2JCLoNYiMT31GRphbEgz1x8GVtwzFeDzKwz+QrbRdPrCtsOt9Bwec9Xnim iIbwYpIKsi5REzzbyvbpbzK59BkJD4/2uLdSlRJ1sGITn4LXilUI+1rfqQH94ZvA5Pfj 01pIYGbPzKFSYaL3tEbC9iikgigSBYlXJJ1NSFya4vaB5EVs2I6tUacEQvW3lm6qjw9f fSs1JKleMelAC1nLAsCskc2Hy2JrWjvNlbLEzbP1pYlvjJ5CSNOODsf2joTfKMmcvqKQ SavoXb3WQACJEgcRrOGKoRXkhP1C/LsH1em+VuhVtiykhdX5UITsfNjQQ5cBHB/cytty 4OQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=P3GSefbd6ENM7iA2f/vLjLRcW91rVVOQzMA/Obez7bs=; fh=EK5j4NE3tdK2qtiZ4GqEgPMWRvXaVAEy+Qf+/JiMopo=; b=hrbBn52GxoaNWrlxOV5aQX2pL7LFhPoGPiEzVPjojILcSjN8o+XyiUS6MlpBaF8l6w CmaqE8gkWBgdbWn7NlN2egRAoV1e/liD0R2QWAR0svfRHOpKvcoL16bR3wph6xV/UkXd 25kjyU4CNB9/WKk8jP1CN3yAb6ysngEIFC4ZTiWkhAFK6IKdALyi1samIwabII6KygHx EUkBszeCRS663F5EkHRN++uu3r7Qn4w7iy/uWMy+MqIBjT4Umo2acSsgBA5Rk0YRMZwa MKJg5otUJduEtDM0p2mdVdR3Ia0QuBZ0BULxYV9cceLO5oVu7cqwv0cnYC7Nd3s5H+BL M3Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=IDWLL8dK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f10-20020a170902684a00b001c9bf39a60fsi1315253pln.629.2023.10.10.13.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 13:37:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=IDWLL8dK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C0103807E452; Tue, 10 Oct 2023 13:37:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230182AbjJJUhq (ORCPT + 99 others); Tue, 10 Oct 2023 16:37:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjJJUhp (ORCPT ); Tue, 10 Oct 2023 16:37:45 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE72F8E for ; Tue, 10 Oct 2023 13:37:42 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2c3e23a818bso2934761fa.0 for ; Tue, 10 Oct 2023 13:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1696970261; x=1697575061; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=P3GSefbd6ENM7iA2f/vLjLRcW91rVVOQzMA/Obez7bs=; b=IDWLL8dKiqnLLeO+EYj7BivNrXbu9u3hB4I+sgBpCFkTOlhN8kGQeShNFvcEiONGQG bnWIstXaNac5x/QlsitN+NTP9sAsNTE2QyGXf/JSVbsnblVklmUc+XCpJlas5AxUUXCw b9qfSzba5P080QrYHRkW+x5XZ/mk7JLWKF0Jo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696970261; x=1697575061; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P3GSefbd6ENM7iA2f/vLjLRcW91rVVOQzMA/Obez7bs=; b=MAT+CR5jtLqNm+myxyLzMvYKhfboCvtezBkRAE6mom3OtZSpv4x0ckEOISaljfZFCT qr4oKHR8J36vqwQusKTVZIcGLvvP5HHptAaXIJvW5xS0fGbcnaVIPSsZRHd/HKF9gWJ0 hS1v8mftm2XhOzguM5hN+/JBbOayQS+ZAI4zoGfIaB6Q8YbxJADd/DKElF5ipf7/aiRD b6bVpdQuJxU7So+hrETN7g9rbRcsVnjWMqZeBGXbX2EQiYuUkPCDeo/zADbqF36viG6t g+yT7pHTE1ey5Ru+s0WhZ1PyibpTvUkh+vuiX/DRZjALfPC4xlYI8cN6S0NZwUkMdLJN RFlg== X-Gm-Message-State: AOJu0YxzGvG86RUc2i3Wc1yqq0lbgPEa43Q2KtnyABInqQXvO4hdu0Np X62QsBvp7YJCEvJIznsgkOGjhfW9QrzjboUwUNvqew== X-Received: by 2002:a2e:9347:0:b0:2c0:7d6:570b with SMTP id m7-20020a2e9347000000b002c007d6570bmr10671343ljh.26.1696970260872; Tue, 10 Oct 2023 13:37:40 -0700 (PDT) MIME-Version: 1.0 References: <20230929021213.2364883-1-joel@joelfernandes.org> <87bkdl55qm.fsf@email.froward.int.ebiederm.org> <87il7fzusf.fsf@email.froward.int.ebiederm.org> In-Reply-To: <87il7fzusf.fsf@email.froward.int.ebiederm.org> From: Joel Fernandes Date: Tue, 10 Oct 2023 16:37:30 -0400 Message-ID: Subject: Re: [PATCH] kexec: Fix reboot race during device_shutdown() To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, Steven Rostedt , Ricardo Ribalda , Ross Zwisler , Rob Clark , Linus Torvalds , kexec@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 10 Oct 2023 13:37:55 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 9, 2023 at 11:30=E2=80=AFAM Eric W. Biederman wrote: > > Joel Fernandes writes: > > > On Mon, Oct 2, 2023 at 2:18=E2=80=AFPM 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 w= ork > >> > 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. It is a simple unit test that tests kexec support by kexec-rebooting the kernel. I don't think SIGSTOP/SIGKILL'ing during kexec-reboot is ideal because in a real panic-on-kexec type crash, that may not happen and so does not emulate the real world that well. I think we want the kexec-reboot to do a *reboot* without crashing the kernel while doing so. Ricardo/Steve can chime on what they feel as well. > That way you can get the orderly shutdown > of userspace daemons/services along with an orderly shutdown of > everything the kernel is responsible for. Fixing in userspace is an option but people are not happy that the kernel can crash like that. > 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. You mean fix it in userspace? thanks, - Joel