From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EFCCC433E2 for ; Sun, 13 Sep 2020 16:58:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CD6D207C3 for ; Sun, 13 Sep 2020 16:58:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="Zc6U28Ka" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725975AbgIMQ6A (ORCPT ); Sun, 13 Sep 2020 12:58:00 -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-UI-Out-Filterresults: notjunk:1;V03:K0:9JDcq2+UbDI=:GRnECanaZF7QfeOPwoBV1a nO6OdYi+PZexCJ2o7AARPY2a6ebH5Ihvx642+JprXJAnuYC/BRiMMxIqEWoscM2svFEfjNmov +VXn1ahL3Z5KOa5+fnVBALBFGjftZPL4E5AG2s1vp6sLd9yuypx0hR6eyhMCwAh+xUACGpvpw BS8akP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wIHDf+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