Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1630671pxk; Sun, 13 Sep 2020 10:00:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaePo7tJ3jQE2X38YxVL3TYd+nmwq5Bk7Xvh/AUd6Dp7CQnbW8UYwYVtrWwzVJvYiPy9az X-Received: by 2002:a50:cf46:: with SMTP id d6mr13641059edk.339.1600016425003; Sun, 13 Sep 2020 10:00:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600016424; cv=none; d=google.com; s=arc-20160816; b=0OmiB/fUsXnD9FzzzJ74XI6WaLlJRPgokmckKYW5x8u9wiq2OPif3nuuV7cE6j99AF N1cM+qc0HKjiWafyXNUb0EyVtaX8uZ3oQUK/gMgGfY5IvlHVeyEGVnEppQif+dQIeiKj 9OU0YjnsPqkzHo2sByRF41efNHnYlETH3rOhWywSz71IjgXMKVdlD4M3gek6MuQRI3ww Fh989H4UNK8C1UyQmJR6fU6zfAmcVxIsrGBJyFCs4mgYCYYRzeKo7PLAH6Sm6kbGw2rn MMxIV6LdASKWxZlvuUMD8UpE3aELuEd1mGcPT1Mgt/P6xfxKma8m0KoAy/Ar93uyttJ5 if6g== 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=YI3T0dqqtT9ARDgkalYI0FdpACNBQXyrrpqtrkamqDQ=; b=OlFehsoTB1+0+J89xK2O7hcMjZJnC4Tkz15gyFTgSdc3GsQUtk3lRyInMf7h9SAf2q wzI8VjKnjc1u6x1WM5ys4XI6cfSWwwxEQFXc7FEW8p0OC+cUHcU8wdsxetPu1RxEFN+N 5F+cZL6wQodf6MFsmX/umjrfjKcSSXzfEzVw2EcJzJ2OOp4IgKb1u6e0Xye+5nBe9Cr9 5yllBAyegTI8FgSS5MT0sAeVts6zXFhUXFidpxVO2SgEkLxqlAFSL4ym7+JmqyDSbGez IORB8ql0d5zR4Qp/f2xe70g345vOge0GfxvRv+8Pcb9SuEXMM8eMRcCiNzVVzNbs7/CK 1dKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=Zc6U28Ka; 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 ng3si5469543ejb.720.2020.09.13.10.00.02; Sun, 13 Sep 2020 10:00:24 -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=Zc6U28Ka; 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 S1725972AbgIMQ5z (ORCPT + 99 others); Sun, 13 Sep 2020 12:57:55 -0400 Received: from mout.gmx.net ([212.227.15.15]:43001 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbgIMQ5v (ORCPT ); Sun, 13 Sep 2020 12:57:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1600016191; bh=2UfjObndGtW0Xq6W1Y2m5K5jmrf7PALFEYSIFTj3SRk=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=Zc6U28KaEBYWrmUQ6T5i0/2G23L9udYWFnuge/OPiC8b9IfDTCU017y3rmUXYVxq0 kajCBw4nHacTh623DsBzar7JounEuziC0XpshmEWy8tQ1iRCEChC2G7oJueREwAIff T9MBF+wDx6bYCnRsHxYmSSIbhLAoWxAjlFSktvPQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from ubuntu ([79.150.73.70]) by mail.gmx.com (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MG9kM-1kIdsZ0fZU-00Gaaf; Sun, 13 Sep 2020 18:56:31 +0200 Date: Sun, 13 Sep 2020 18:56:12 +0200 From: John Wood To: Jann Horn , Kees Cook Cc: Kernel Hardening , John Wood , 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: <20200913152724.GB2873@ubuntu> References: <20200910202107.3799376-1-keescook@chromium.org> <20200910202107.3799376-6-keescook@chromium.org> <202009101634.52ED6751AD@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:fFhuJz0gvsAKhyXIL51o/azcshQRL7L+66gcb+DURq+rQrGIfh5 yGkKJ/8c9JYhC2pJjV5T/ERRgDmRmiBJ63C8lyiY2/w7LiCL/JkSkacipHQhE85+cpPDTRO eOmkxxwjRIo00I747W9FNP+lUDa+J7oVW4wVTRoysdyrtRTZaVEE9FcLtrcEYR3PHTyXTF2 Z8jrzms0p4mPTKb94KV3A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:9JDcq2+UbDI=:GRnECanaZF7QfeOPwoBV1a nO6OdYi+PZexCJ2o7AARPY2a6ebH5Ihvx642+JprXJAnuYC/BRiMMxIqEWoscM2svFEfjNmov +VXn1ahL3Z5KOa5+fnVBALBFGjftZPL4E5AG2s1vp6sLd9yuypx0hR6eyhMCwAh+xUACGpvpw BS8akPE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IHDf+EZffSbzZ2 Ox4mBFjRtTEQhJN8P7RoFK4ho+VRVaYeEHPQYAw== 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 Fri, Sep 11, 2020 at 02:01:56AM +0200, Jann Horn wrote: > On Fri, Sep 11, 2020 at 1:49 AM Kees Cook wrote: > > On Thu, Sep 10, 2020 at 01:21:06PM -0700, Kees Cook wrote: > > > diff --git a/fs/coredump.c b/fs/coredump.c > > > index 76e7c10edfc0..d4ba4e1828d5 100644 > > > --- a/fs/coredump.c > > > +++ b/fs/coredump.c > > > @@ -51,6 +51,7 @@ > > > #include "internal.h" > > > > > > #include > > > +#include > > > > > > int core_uses_pid; > > > unsigned int core_pipe_limit; > > > @@ -825,6 +826,7 @@ void do_coredump(const kernel_siginfo_t *siginfo= ) > > > fail_creds: > > > put_cred(cred); > > > fail: > > > + fbfam_handle_attack(siginfo->si_signo); > > > > 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 t= he > > 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 probably > > 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 you > said, it's not really semantically about core dumping, maybe it should > be named task_fatal_signal or something like that. If I understand correctly you propose to add a new LSM hook without return value and place it here: diff --git a/kernel/signal.c b/kernel/signal.c index a38b3edc6851..074492d23e98 100644 =2D-- 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. */ Thanks, John Wood