Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1111696pxb; Wed, 29 Sep 2021 17:36:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9SQJQcDDDJt4tFOoBxHgQzN8Vye0n31gft7fwyeJ6sXHBeowUfMf67bf4wSYdNWVJbQPP X-Received: by 2002:a50:bf08:: with SMTP id f8mr3514838edk.400.1632962208934; Wed, 29 Sep 2021 17:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632962208; cv=none; d=google.com; s=arc-20160816; b=A1SBkwe7ukBNLDWNQx8UCoIMfifiVEEbdyA0uTBoogCDK3+yUtlfdSw53sKMmr5OcS LdxjLjO+AsYMj3o8r9gdYm2E1G93obeGJSqP4o4ZYdO0huAzIza/GtX955ID0d1iu3Jn zLory2Z9BuMU4mRIKzSZy1jLElrkgETiaUQDPC2TewbgkQsmoRu5sh29SzZ8dqWo0zpG pc85m2+FB6maldx2Z9j2Q4yzclEzb/YcdHFN38pRyQOvxGUkfnizPXxsTm2A1Vzk6DpY WXsgfvzEQOJ/EfoRaA7EFtDNBupskmq9MZ44pXNvHobHyN5Jndk1gY5viM6UC9cpOBDk ePPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=07vW886xjSPcLxx0r7Kkb1nrWxrZM98WUaFBhCtRO/Q=; b=FtCggMLg6xxZQ//3je8BvijvjRtsrqsy8dqQw740os9djKPrqZoEZYwm2oeoZIk5ME 7yvz3oENcHMWtoeX9ny2a0dNAZMj46Eks43Lj2UbOkF3aUnecYvveYffLXPHQkx8jv9T 8kBnhbdodCLt1HO7m5ZCqIlDQNN8CUug0PzhrkwgSgOlE0QBxFJcg/ABnh9EqEtorNn5 4LDC/4NIByxDF50VwcruLaIIJiZAAT87AfAeuK6xrGlB3jzroagkaFz3DHk58/bk+Vd5 5sz8OA3Rh2eMEzjpMLjrPISb4ggaZSl+y785hqXvUUAsdHNJzCQrCqeJvik3VCcxqnzb O7ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=NN3ijR4T; 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 w3si1667374ejv.301.2021.09.29.17.36.24; Wed, 29 Sep 2021 17:36:48 -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; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=NN3ijR4T; 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 S1347582AbhI2Xd1 (ORCPT + 99 others); Wed, 29 Sep 2021 19:33:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:50234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345134AbhI2Xd0 (ORCPT ); Wed, 29 Sep 2021 19:33:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F2E116135D; Wed, 29 Sep 2021 23:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1632958305; bh=gDC8FeyWEK+m6y1oljAXM/J6NEZQW93X8rLKfj3knFM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NN3ijR4TISmoUJq81Zy37jY9PjgUYWr1BP/sBn1OfDNimXfNczZOTVlBRFYi7KdEr RW3FtjLpG7VUwM3JHrL8iT/N71iEhCjuMHpQ9p1+bEiLpk/Yb7F3BjkQeuutBDFOuo 4y8StbCdPsAQAqoV6S/9tsLkZcjUHrmh5gA8n9kA= Date: Wed, 29 Sep 2021 16:31:43 -0700 From: Andrew Morton To: alex.popov@linux.com Cc: Jonathan Corbet , Paul McKenney , Thomas Gleixner , Peter Zijlstra , Joerg Roedel , Maciej Rozycki , Muchun Song , Viresh Kumar , Robin Murphy , Randy Dunlap , Lu Baolu , Petr Mladek , 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 , Thomas Garnier , Will Deacon , Ard Biesheuvel , Laura Abbott , 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 Subject: Re: [PATCH] Introduce the pkill_on_warn boot parameter Message-Id: <20210929163143.aa8b70ac9d5cf0b628823370@linux-foundation.org> In-Reply-To: References: <20210929185823.499268-1-alex.popov@linux.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 Sep 2021 22:01:33 +0300 Alexander Popov wrote: > On 29.09.2021 21:58, Alexander Popov wrote: > > Currently, the Linux kernel provides two types of reaction to kernel > > warnings: > > 1. Do nothing (by default), > > 2. Call panic() if panic_on_warn is set. That's a very strong reaction, > > so panic_on_warn is usually disabled on production systems. > > > > From a safety point of view, the Linux kernel misses a middle way of > > handling kernel warnings: > > - The kernel should stop the activity that provokes a warning, > > - But the kernel should avoid complete denial of service. > > > > From a security point of view, kernel warning messages provide a lot of > > useful information for attackers. Many GNU/Linux distributions allow > > unprivileged users to read the kernel log, so attackers use kernel > > warning infoleak in vulnerability exploits. See the examples: > > https://a13xp0p0v.github.io/2020/02/15/CVE-2019-18683.html > > https://a13xp0p0v.github.io/2021/02/09/CVE-2021-26708.html > > > > Let's introduce the pkill_on_warn boot parameter. > > If this parameter is set, the kernel kills all threads in a process > > that provoked a kernel warning. This behavior is reasonable from a safety > > point of view described above. It is also useful for kernel security > > hardening because the system kills an exploit process that hits a > > kernel warning. > > > > Signed-off-by: Alexander Popov > > 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. Why do we need a boot parameter? Isn't a sysctl all we need for this feature? Also, if (pkill_on_warn && system_state >= SYSTEM_RUNNING) do_group_exit(SIGKILL); - why do we care about system_state? An explanatory code comment seems appropriate. - do we really want to do this in states > SYSTEM_RUNNING? If so, why?