Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3164707pxk; Tue, 15 Sep 2020 11:42:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2jI39Kvo4D0/68azfyLXOyZWI//r1YRugHR2S49Ss3nBn4V5tqJEWAl59lPOJaDLOPFm0 X-Received: by 2002:a17:906:d787:: with SMTP id pj7mr20668478ejb.340.1600195365400; Tue, 15 Sep 2020 11:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600195365; cv=none; d=google.com; s=arc-20160816; b=L9eMTLua2okArp3XEmQ3Wop6vdMoo7jcN5qqiwhcstOoz9gDaRnNZ+nBuPEo4U4nbM 0wjc15ZZxKACOQ6UWQ9mkryykxPzPQIcm0X0jDTLVNSW7M55o5Crj9lsOgMs3nfTBMuF w6OsASjzKcd6Hw16nz3u1bHo0E2ryMKmbuw+ablC0U3ZCGRGY6QPU9nu2Hxmx+uAWduS PMsLtgqc+lnivoBZ/EsLkXZ+6yk1Qh26uUZroBC5/f/8M+vyoJSgmT7v9JiB10z6+J+I nE1IXJ4iy82+X1WH1lIiQ24aMymrtu0Kmj1Hh2Moqb+rHSdxzv36P4BAGyR5WkcJmE2s RMAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=uLdis5s+ATcfL8pCi04J90jZxLXt+irfMxzVZ84wZmQ=; b=fIycLDKg/HSqjSoaaqjdu3wQVlXWVOuzy66+E3ulOOALy1+d3c8H848N9MkBkLmwYU vYi8gXOSmlht4MEGZ1eqWvFamZkXyjVsxB/F7dBNW0d3Rbeo3Vpazbxunn2hROgW7p4P LBq6DsHgIg5f3FygMzehUhtARhEdz451sdVhHE+Sm5OPNXfsjUpm05kMcyvXalmwMjl2 NpEf0lTljj3k4pep6g3qsbC9j3PqvU25TViOC+skrjRVVnplI9No/H36P7mZn70/m9V2 UpHTqtbhYdsNFwu0mZdeHtVatVaoah1mCtaXjSITZzHr5WG3fH7FHwDI0OaX/xjfLdDb yvPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=eeQDvAac; 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 c25si10264916eds.548.2020.09.15.11.42.22; Tue, 15 Sep 2020 11:42:45 -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=@gmx.net header.s=badeba3b8450 header.b=eeQDvAac; 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 S1727537AbgIOSjb (ORCPT + 99 others); Tue, 15 Sep 2020 14:39:31 -0400 Received: from mout.gmx.net ([212.227.17.20]:50887 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727941AbgIORjc (ORCPT ); Tue, 15 Sep 2020 13:39:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1600191432; bh=NJ6O5rFyFRlQXoAS3XFVS8BQi/rApnd7lWRwhfK2Xlg=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=eeQDvAacH1VlXwy4iH3Fxv2qyTjt32iVfeKBKyzgI7+LGScpg5JNVDryxc0pkFL7N zqoJ1hZ3D0VN3JGismE3Z9ckMhtWuP06kvJvEVLGhRUkTahazF+9UvM7UneJRJLpW9 Z5eKxS0WNWMmopdQzAW4AkXHnNEFwNzlLAhdqHfM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from ubuntu ([79.150.73.70]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MEUz4-1kGWkE0klW-00G08s; Tue, 15 Sep 2020 19:37:12 +0200 Date: Tue, 15 Sep 2020 19:36:27 +0200 From: John Wood To: Jann Horn Cc: John Wood , Kees Cook , Kernel Hardening , Matthew Wilcox , Jonathan Corbet , Alexander Viro , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Luis Chamberlain , Iurii Zaikin , James Morris , "Serge E. Hallyn" , linux-doc@vger.kernel.org, kernel list , linux-fsdevel , linux-security-module Subject: Re: [RFC PATCH 5/6] security/fbfam: Detect a fork brute force attack Message-ID: <20200915173627.GA2900@ubuntu> References: <20200910202107.3799376-1-keescook@chromium.org> <20200910202107.3799376-6-keescook@chromium.org> <202009101634.52ED6751AD@keescook> <20200913152724.GB2873@ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:+Tv9EY0th3c1INR7wYqsaQT1v7XmqULQmf1mCMF8tBv7us+6tmw 383m5XxCtjIbCae841iMOqJ2Kb5mfB5OzM0d7bWnQ/N2gDAhnuzMcocEglMiEwyJSk3JQJY A8urH8HcByeEI58owhYnERH7vdI+cm29w8O8VDx8RuXDp3riBg1FpBliC3UfpGBZw8KurB1 T/YoWfU4tpzRllQytfgJQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:4Yu2qoJjF0U=:HHZzV9mfG2ygAGqXu5SlIO b6fw//682jHONr9ldrDNb1XyJothxmBz6Vmqu5LRz+VzKi+Iobvg71yk1utVXXrr4ydn7w1i4 Bo8DAIv8PN4nGmuQR0RWyRtNXdKVtbVhLrZ0aZNjY74rEbgcOZ5GvhU03dXUlp6uiVNW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/52Tfoke+fdGEv7LLWDUZxPoEN1TX 78MvWsWqHA0c669IvrfXYcskGlGCPN7xB8N4Bfg== Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, Sep 14, 2020 at 09:39:10PM +0200, Jann Horn wrote: > On Sun, Sep 13, 2020 at 6:56 PM John Wood wrote: > > On Fri, Sep 11, 2020 at 02:01:56AM +0200, Jann Horn wrote: > > > On Fri, Sep 11, 2020 at 1:49 AM Kees Cook wr= ote: > > > > On Thu, Sep 10, 2020 at 01:21:06PM -0700, Kees Cook wrote: > > > > [...] > > > > I don't think this is the right place for detecting a crash -- isn= 't > > > > this only for the "dumping core" condition? In other words, don't = you > > > > want to do this in get_signal()'s "fatal" block? (i.e. very close = to the > > > > do_coredump, but without the "should I dump?" check?) > > > > > > > > Hmm, but maybe I'm wrong? It looks like you're looking at noticing= the > > > > process taking a signal from SIG_KERNEL_COREDUMP_MASK ? > > > > > > > > (Better yet: what are fatal conditions that do NOT match > > > > SIG_KERNEL_COREDUMP_MASK, and should those be covered?) > > > > > > > > Regardless, *this* looks like the only place without an LSM hook. = And it > > > > doesn't seem unreasonable to add one here. I assume it would proba= bly > > > > just take the siginfo pointer, which is also what you're checking. > > > > > > Good point, making this an LSM might be a good idea. > > > > > > > e.g. for include/linux/lsm_hook_defs.h: > > > > > > > > LSM_HOOK(int, 0, task_coredump, const kernel_siginfo_t *siginfo); > > > > > > I guess it should probably be an LSM_RET_VOID hook? And since, as yo= u > > > said, it's not really semantically about core dumping, maybe it shou= ld > > > be named task_fatal_signal or something like that. > > > > If I understand correctly you propose to add a new LSM hook without re= turn > > value and place it here: > > > > diff --git a/kernel/signal.c b/kernel/signal.c > > index a38b3edc6851..074492d23e98 100644 > > --- a/kernel/signal.c > > +++ b/kernel/signal.c > > @@ -2751,6 +2751,8 @@ bool get_signal(struct ksignal *ksig) > > do_coredump(&ksig->info); > > } > > > > + // Add the new LSM hook here > > + > > /* > > * Death signals, no core dump. > > */ > > It should probably be in the "if (sig_kernel_coredump(signr)) {" > branch. And I'm not sure whether it should be before or after > do_coredump() - if you do it after do_coredump(), the hook will have > to wait until the core dump file has been written, which may take a > little bit of time. But if the LSM hook is placed in the "if (sig_kernel_coredump(signr)) {" branch, then only the following signals will be passed to it. SIGQUIT, SIGILL, SIGTRAP, SIGABRT, SIGFPE, SIGSEGV, SIGBUS, SIGSYS, SIGXCPU, SIGXFSZ, SIGEMT The above signals are extracted from SIG_KERNEL_COREDUMP_MASK macro, and are only related to coredump. So, if we add a new LSM hook (named task_fatal_signal) to detect a fatal signal it would be better to place it just above the if statement. diff --git a/kernel/signal.c b/kernel/signal.c index a38b3edc6851..406af87f2f96 100644 =2D-- a/kernel/signal.c +++ b/kernel/signal.c @@ -2736,6 +2736,8 @@ bool get_signal(struct ksignal *ksig) */ current->flags |=3D PF_SIGNALED; + // Place the new LSM hook here + if (sig_kernel_coredump(signr)) { if (print_fatal_signals) print_fatal_signal(ksig->info.si_signo); This way all the fatal signals are caught and we also avoid the commented delay if a core dump is necessary. Thanks, John Wood