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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D46FAC433EF for ; Fri, 1 Oct 2021 12:23:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7F846136A for ; Fri, 1 Oct 2021 12:23:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231378AbhJAMZl (ORCPT ); Fri, 1 Oct 2021 08:25:41 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:56636 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231186AbhJAMZe (ORCPT ); Fri, 1 Oct 2021 08:25:34 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 0E7CB22644; Fri, 1 Oct 2021 12:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1633091029; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wtBZ7U5ewDlKJ28ZtqZTNSvN7kEYRmILRT2iVxUTj2c=; b=m/wphk5uR59ODqBgPtgUELkhpG+snjW4Ik51wxuXL7I+dgCA/YWVS6i8kfqV3u/+B2rFRf nuk6zDSKvhAs2QhrlRxWlDH53/17tz18jDnmmyRctW1FYjWNFKCdFZkZjrQGIpTzSWjafn dUFZjBihk0jDWceRW3LSio4aswzbFdw= Received: from suse.cz (pathway.suse.cz [10.100.12.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 799EFA3B81; Fri, 1 Oct 2021 12:23:48 +0000 (UTC) Date: Fri, 1 Oct 2021 14:23:48 +0200 From: Petr Mladek To: Alexander Popov Cc: "Paul E. McKenney" , Jonathan Corbet , Andrew Morton , Thomas Gleixner , Peter Zijlstra , Joerg Roedel , Maciej Rozycki , Muchun Song , Viresh Kumar , Robin Murphy , Randy Dunlap , Lu Baolu , Kees Cook , Luis Chamberlain , Wei Liu , John Ogness , Andy Shevchenko , Alexey Kardashevskiy , Christophe Leroy , Jann Horn , Greg Kroah-Hartman , Mark Rutland , Andy Lutomirski , Dave Hansen , Steven Rostedt , Will Deacon , David S Miller , Borislav Petkov , kernel-hardening@lists.openwall.com, linux-hardening@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, notify@kernel.org, Linus Torvalds , Dmitry Vyukov Subject: Re: [PATCH] Introduce the pkill_on_warn boot parameter Message-ID: <20211001122348.GB965@pathway.suse.cz> References: <20210929185823.499268-1-alex.popov@linux.com> <20210929194924.GA880162@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2021-09-30 18:05:54, Alexander Popov wrote: > On 30.09.2021 12:15, Petr Mladek wrote: > > On Wed 2021-09-29 12:49:24, Paul E. McKenney wrote: > >> On Wed, Sep 29, 2021 at 10:01:33PM +0300, Alexander Popov wrote: > >>> This patch was tested using CONFIG_LKDTM. > >>> The kernel kills a process that performs this: > >>> echo WARNING > /sys/kernel/debug/provoke-crash/DIRECT > >>> > >>> If you are fine with this approach, I will prepare a patch adding the > >>> pkill_on_warn sysctl. > >> > >> I suspect that you need a list of kthreads for which you are better > >> off just invoking panic(). RCU's various kthreads, for but one set > >> of examples. > > > > I wonder if kernel could survive killing of any kthread. I have never > > seen a code that would check whether a kthread was killed and > > restart it. > > The do_group_exit() function calls do_exit() from kernel/exit.c, which is also > called during a kernel oops. This function cares about a lot of special cases > depending on the current task_struct. Is it fine? IMHO, the bigger problem is that nobody will start the kthreads again. As a result, some kernel functionality will not longer work. User space threads are different. The user/admin typically have a chance to start them again. We might get inspiration in OOM killer. It never kills kthreads and the init process, see oom_unkillable_task(). It would be better to panic() when WARN() is called from a kthread or the init process. Best Regards, Petr