lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cf6ada34-9854-b7ad-f671-52186da5abd0@linux.com>
Date:   Thu, 30 Sep 2021 16:55:37 +0300
From:   Alexander Popov <alex.popov@...ux.com>
To:     Kees Cook <keescook@...omium.org>,
        Dave Hansen <dave.hansen@...el.com>,
        Peter Zijlstra <peterz@...radead.org>
Cc:     Jonathan Corbet <corbet@....net>,
        Paul McKenney <paulmck@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Joerg Roedel <jroedel@...e.de>,
        Maciej Rozycki <macro@...am.me.uk>,
        Muchun Song <songmuchun@...edance.com>,
        Viresh Kumar <viresh.kumar@...aro.org>,
        Robin Murphy <robin.murphy@....com>,
        Randy Dunlap <rdunlap@...radead.org>,
        Lu Baolu <baolu.lu@...ux.intel.com>,
        Petr Mladek <pmladek@...e.com>,
        Luis Chamberlain <mcgrof@...nel.org>, Wei Liu <wl@....org>,
        John Ogness <john.ogness@...utronix.de>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Alexey Kardashevskiy <aik@...abs.ru>,
        Christophe Leroy <christophe.leroy@...roup.eu>,
        Jann Horn <jannh@...gle.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Mark Rutland <mark.rutland@....com>,
        Andy Lutomirski <luto@...nel.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Will Deacon <will.deacon@....com>,
        David S Miller <davem@...emloft.net>,
        Borislav Petkov <bp@...en8.de>,
        kernel-hardening@...ts.openwall.com,
        linux-hardening@...r.kernel.org, linux-doc@...r.kernel.org,
        linux-kernel@...r.kernel.org, notify@...nel.org
Subject: Re: [PATCH] Introduce the pkill_on_warn boot parameter

On 29.09.2021 23:06, Kees Cook wrote:
> On Wed, Sep 29, 2021 at 12:03:36PM -0700, Dave Hansen wrote:
>> On 9/29/21 11:58 AM, Alexander Popov wrote:
>>> --- a/kernel/panic.c
>>> +++ b/kernel/panic.c
>>> @@ -53,6 +53,7 @@ static int pause_on_oops_flag;
>>>  static DEFINE_SPINLOCK(pause_on_oops_lock);
>>>  bool crash_kexec_post_notifiers;
>>>  int panic_on_warn __read_mostly;
>>> +int pkill_on_warn __read_mostly;
> 
> I like this idea. I can't tell if Linus would tolerate it, though. But I
> really have wanted a middle ground like BUG(). Having only WARN() and
> panic() is not very friendly. :(

Ok, let's see.

Kees, could you also share your thoughts on the good questions by Petr Mladek in
this thread?

>>>  unsigned long panic_on_taint;
>>>  bool panic_on_taint_nousertaint = false;
>>>  
>>> @@ -610,6 +611,9 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
>>>  
>>>  	print_oops_end_marker();
>>>  
>>> +	if (pkill_on_warn && system_state >= SYSTEM_RUNNING)
>>> +		do_group_exit(SIGKILL);
>>> +
>>>  	/* Just a warning, don't kill lockdep. */
>>>  	add_taint(taint, LOCKDEP_STILL_OK);
>>>  }
>>
>> Doesn't this tie into the warning *printing* code?  That's better than
>> nothing, for sure.  But, if we're doing this for hardening, I think we
>> would want to kill anyone provoking a warning, not just the first one
>> that triggered *printing* the warning.
> 
> Right, this needs to be moved into the callers of __warn() (i.e.
> report_bug(), and warn_slowpath_fmt()), likely with some small
> refactoring in report_bug().

Yes, I see now. Thanks, Dave, Peter and Kees.
The kernel can hit warning and omit calling __warn() that prints the message.
But pkill_on_warn action should be taken each time.

As I can understand now, include/asm-generic/bug.h defines three warning
implementations:
 1. CONFIG_BUG=y and the arch provides __WARN_FLAGS. In that case pkill_on_warn
should be checked in report_bug() that you mention.
 2. CONFIG_BUG=y and the arch doesn't have __WARN_FLAGS. In that case
pkill_on_warn should be checked in warn_slowpath_fmt().
 3. CONFIG_BUG is not set. In that case pkill_on_warn should not be considered.

Please, correct me if needed.

Best regards,
Alexander

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ