Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2415421pxk; Mon, 14 Sep 2020 12:43:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaofUsesZ62CgjT6FDepCAIAZW/+tvvhsCoVWjslHEH4wxJqaSTcKbJiEKSbcnYFe3tn++ X-Received: by 2002:a05:6402:456:: with SMTP id p22mr18614452edw.177.1600112591224; Mon, 14 Sep 2020 12:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600112591; cv=none; d=google.com; s=arc-20160816; b=TG3rGv4ZFcql8r312UujH5qJ07IpMPcEwsM9iHcFFnAtzc3ikHfwagDOGDjmkIweBL jNPuvY4g/6i63iEdNWiR3ETfF0lnj0ez5qp4fNPwoK8YgDdmWFLGLIHu76pvku2t32vc /niRgxqy/PtkhrQ0cM7fuQ5HtrpQp3336qh1aD6Z1A0iJWA4gHxq1SwWy9RWDuc2eK6C dwLU2DyTJkQlSaOHF8tIl8X6GcKplgHxBJFhwZh//yLQPbP32fS0pH41OUJP3+M8HqNk Gnkv1O98viZCQlKFqO6XUChf2MBiHecFx4vp4ZVErvqEuR4ap3cMWq7zYMZO6j2/Q6q5 xXnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=lG5XGf95bwNJOiL8PcjSLhdHd8W32J8QXR/kZviOKdg=; b=vW/TzRjtjSFPUA6lfbbpp7YjW5p6s0VRSdc55KwsnP1J9rVXoArRy97W6zcHFQPYl5 q9EAwX19pdApCWL5y96m/qEtyCteW825U3cImaTA94eyqCTDMMolJHH8zqcglyfFf9nE uhbNTsgK7R91TbZ215SlHr0ytAPZf5yNxBs6IXyI5mtBJVEwdnn0uvDVd0/sVPA7jh2H flWGp6geLGRYUPRV6n9MFZCBffEQ3WCFwDZxbKi9Rd2ptoARWU4I2ELUv5SeWRsf0+cT zLDnbha4HbdyhReEW6S7/ceerc4jq+Zi8mriZOy53+hMLEmEfry/i1KWZALBLF0itTzE UcFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KMb8YL82; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e3si8213545ejq.508.2020.09.14.12.42.48; Mon, 14 Sep 2020 12:43:11 -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=@google.com header.s=20161025 header.b=KMb8YL82; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725964AbgINTjk (ORCPT + 99 others); Mon, 14 Sep 2020 15:39:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbgINTji (ORCPT ); Mon, 14 Sep 2020 15:39:38 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DA7AC06174A for ; Mon, 14 Sep 2020 12:39:38 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id b12so712244edz.11 for ; Mon, 14 Sep 2020 12:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lG5XGf95bwNJOiL8PcjSLhdHd8W32J8QXR/kZviOKdg=; b=KMb8YL82jYt+MdR+06nAv1SDjyBvY4xZgeT/ZSDzaA/sIk4BMgBJiDBRB+e1bufy3+ 8ZUWjMH8ilySI8ll0tpW9SGHNcwfcXvuO/ogAr+JiAJ+gLYB2oFiAISVMsXaZiFZKhG6 rNV9jXE4AzKiGnJtbZ01dTfsAaRXm01QgaG5C8WCbA0mkKFr6J1uj1+DZPrJ9hzkpFLt 7CafX7kXEWTa72gmB4FzIyzXC1KrE0sLckGmAtvfbSZqoUxrNCh+knJSNyZnBMhxAxTx dNPT5gnmXVGLWsSSXLj6HwJ+ZnTlIAmp/gH/hWa2wQfaMmrOBh6HBlLkbN6H+zlGsjQ8 UTIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lG5XGf95bwNJOiL8PcjSLhdHd8W32J8QXR/kZviOKdg=; b=QmmJuz3vFGdWC9AJEgauqoX481GHClD0j4tnZHr18AHBQ5QO9zZ5mRaA2PVKMowrS/ lG7ieufcnqKYnCPjf/2D3UlFz7zzYd+g//1H17oI31RjgSJCrPYgLj7BsRTz6C09Mcak MeJfDpbTrMhSM/GFmReOTnbDdA8QA4bq4/SHdGfdZ49JhpQ49Jiy6quembivzouqsYnc TwlmpmESZZYwITze1OqoP22QRIfrHK57bPVTDNrkJRXxGs6RCYcJEGww7gHDwL2L0n6U dL2OFELYlqkEU4E623HdCo3z9Ieos8ylOct9xyghmvq+DeHFYuH+4yWCyLP+yZ9n2iyV P1LA== X-Gm-Message-State: AOAM533nS983c5P8lqhLMIbEm0MRGRJ6x1avP9RMZ4qugfeOCFPCLoyj KyKenxNJIBvgWOHXo9kjd7mxP30ufu5uEXNo3au6Ug== X-Received: by 2002:a50:e807:: with SMTP id e7mr19255309edn.84.1600112376719; Mon, 14 Sep 2020 12:39:36 -0700 (PDT) MIME-Version: 1.0 References: <20200910202107.3799376-1-keescook@chromium.org> <20200910202107.3799376-6-keescook@chromium.org> <202009101634.52ED6751AD@keescook> <20200913152724.GB2873@ubuntu> In-Reply-To: <20200913152724.GB2873@ubuntu> From: Jann Horn Date: Mon, 14 Sep 2020 21:39:10 +0200 Message-ID: Subject: Re: [RFC PATCH 5/6] security/fbfam: Detect a fork brute force attack To: John Wood Cc: 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 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 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 > --- 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.