Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1942122pxb; Fri, 22 Oct 2021 10:31:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFJ0YkNpES4uxEVjfwZnpMHN3GxJvRJUgP4/DswkbqUnLQYiI1fBAGLV0ncHeoI7Jzlo6l X-Received: by 2002:a17:90a:7607:: with SMTP id s7mr1396929pjk.59.1634923897443; Fri, 22 Oct 2021 10:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634923897; cv=none; d=google.com; s=arc-20160816; b=MSqtOTN8bks3zkjxRqObRYuVr3ANzWQL7sWrGsGpc1LqhsMDusZ6iArsJDg6CC2701 /j8tDz5wbq001oBP71uY7U+bkIkNbTT9HcBjIQJKbQBmjOHpvq2qc8bs6ooQnC1aO882 8d1W+U3mRZm9tRNsuS95EbE/+Bmuk9LeL6tm/pJKDo1Sv39F+CzzslszqUDQpH596Qz/ PgQ8k5UD/zWs1zVLCTUH9lHmKyQt0E6RqspyAguBQmbhAdWo+DDAXy8Y/3pa2ffhR2Oy FyFs7TWqPv2tmVVpsZG54MZH6AldGqr53y5c7ZXK4/dzRlADxLRekWsuDw7kDiIAsQgt NRjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:reply-to:user-agent :mime-version:date:message-id; bh=yhmb7SMolTFSFPkuCtUT1R9/SpbKWVlxH0z/5kxG25Q=; b=FD0UD4Wc39zvMWBe7kiqedbYRysZLWC23MA+uuRmkWzG7vhRIkoA7blO1XkI3aOksW 1de4DohQYuguF1HJWNIOnjMitcRjqSBKHyOD3aJVBltYSVSG8MYmioLc8i0MhyoIYzff sC6VH8bGq1c2zLgC8QEIWKWOaw08M8+lPxj70B5Blu0ByjwBasAqV/KQ4d3y8m5a93Cp DnfdsXPg+v564RvClrIstqeqXzxaih4TFnvoND9Whgk0fi4/ThsWWtIhGEZJNjJJd83H DvxVSI6NqzvDbddGdXt37VjQNnRkCzU5Vqninq2+ylwJQb3PCQF/eZ4Uce6wWahWJto6 MbDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pc8si13882095pjb.18.2021.10.22.10.31.23; Fri, 22 Oct 2021 10:31:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231453AbhJVRcp (ORCPT + 99 others); Fri, 22 Oct 2021 13:32:45 -0400 Received: from mail-wm1-f45.google.com ([209.85.128.45]:54199 "EHLO mail-wm1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233742AbhJVRcl (ORCPT ); Fri, 22 Oct 2021 13:32:41 -0400 Received: by mail-wm1-f45.google.com with SMTP id j205so2902008wmj.3; Fri, 22 Oct 2021 10:30:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:reply-to :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=yhmb7SMolTFSFPkuCtUT1R9/SpbKWVlxH0z/5kxG25Q=; b=gx9RYd739rwDE8H2BtLeK7l794eveXI+lWT7Atwl/VxgEB5uL38/MYzcqROJTcPsI7 KPOIjC0Jo688kY8f1CdcaqN/oyevKzi1CIRWxvRAvzqQCLeTvuq1hxsXgtKpk94Jw7nM nc29OZh/FtOMuccsnuOLMveQuTo+eNfq5ECbrXE65QKIGZC0X+e0pTjSlMFguai602vh xywiERUh1Y4jxKQvpqHd1OISlgdMSaRKs/OEwoLf+xEq9Vi3nxWEcSct8cnlTBw7yUc0 7WQoH76U7P9CQVklJPgVZ5UXmgtgUrsWvw77RaKcPQqqokrRW3Ve9MYsVGyiuigJg3Di IWnA== X-Gm-Message-State: AOAM532MFxn+Rtml3ND7wRjTP48ZBuRy9KVVJD325Jbux8m6Smq/+JW5 vyXeFUCMK4v35srENqhEbKGbmbKpHpU= X-Received: by 2002:a05:600c:4111:: with SMTP id j17mr30439519wmi.59.1634923822289; Fri, 22 Oct 2021 10:30:22 -0700 (PDT) Received: from [10.9.0.26] ([46.166.133.199]) by smtp.gmail.com with ESMTPSA id g7sm4289321wrd.81.2021.10.22.10.30.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Oct 2021 10:30:21 -0700 (PDT) Message-ID: <23abb989-c20c-0dc0-019c-272beca8cee6@linux.com> Date: Fri, 22 Oct 2021 20:30:09 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Reply-To: alex.popov@linux.com Subject: Re: [PATCH] Introduce the pkill_on_warn boot parameter Content-Language: en-US To: "Eric W. Biederman" Cc: Linus Torvalds , Petr Mladek , "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 , linux-hardening@vger.kernel.org, "open list:DOCUMENTATION" , Linux Kernel Mailing List , notify@kernel.org References: <20210929185823.499268-1-alex.popov@linux.com> <20210929194924.GA880162@paulmck-ThinkPad-P17-Gen-1> <0e847d7f-7bf0-cdd4-ba6e-a742ce877a38@linux.com> <87zgrnqmlc.fsf@disp2133> From: Alexander Popov In-Reply-To: <87zgrnqmlc.fsf@disp2133> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05.10.2021 22:48, Eric W. Biederman wrote: > Especially as calling do_group_exit(SIGKILL) from a random location is > not a clean way to kill a process. Strictly speaking it is not even > killing the process. > > Partly this is just me seeing the introduction of a > do_group_exit(SIGKILL) call and not likely the maintenance that will be > needed. I am still sorting out the problems with other randomly placed > calls to do_group_exit(SIGKILL) and interactions with ptrace and > PTRACE_EVENT_EXIT in particular. > > Which is a long winded way of saying if I can predictably trigger a > warning that calls do_group_exit(SIGKILL), on some architectures I can > use ptrace and can convert that warning into a way to manipulate the > kernel stack to have the contents of my choice. > > If anyone goes forward with this please use the existing oops > infrastructure so the ptrace interactions and anything else that comes > up only needs to be fixed once. Hello Eric, hello everyone. I learned the oops infrastructure and see that it's arch-specific. The architectures have separate implementations of the die() function with different prototypes. I don't see how to use the oops infrastructure for killing all threads in a process that hits a kernel warning. What do you think about doing the same as the oom_killer (and some other subsystems)? It kills all threads in a process this way: do_send_sig_info(SIGKILL, SEND_SIG_PRIV, current, PIDTYPE_TGID). The oom_killer also shows a nice way to avoid killing init and kthreads: static bool oom_unkillable_task(struct task_struct *p) { if (is_global_init(p)) return true; if (p->flags & PF_KTHREAD) return true; return false; } I want to do something similar. I would appreciate your comments. Best regards, Alexander