Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2826999ybx; Fri, 8 Nov 2019 09:51:52 -0800 (PST) X-Google-Smtp-Source: APXvYqwPY6vT5UXG+t/Ius02m7KD/KnMoZulmVCf9outs9PeXmBdPvZUvXCo+j16kXy6ZuSl6Dnf X-Received: by 2002:a17:906:4096:: with SMTP id u22mr9935091ejj.264.1573235512493; Fri, 08 Nov 2019 09:51:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573235512; cv=none; d=google.com; s=arc-20160816; b=iacBzIH5XNCHq+zh1c0Qv799rLa/M0Kdnj3rq/XipxXYKdmFvTBJS+ZpFJHPsOFi1k xy6b0txlJw8h6q+tmsOaBEZF3kSPfDbmw0RwNSiC/CY3SVhj8GrxJauJr5O1cJycn01I lXOvSAliiQY3itq6f/oVzHTa+mTJqDBbJMka78LnJ1M/26y1yLL7/1+SrpcYl0Ydct8r A/HCAB5bCY9E36wixlQiQDF9yrAH+0B6ohx3Sg8RBaC3x+OTXocI3gjw9V9EYWoyK37e QfRQHFzvmhzAqrIN/AEzCOl/BTl0yezx4/w25NtDmPaJqv/Suuk2yPoAV4ZmfO1k1mKN Epmw== 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=UVAbz2qNISBamKJ8aYyWKPdYYFUtEofFZoGab/xVx6Q=; b=bJoUG4lvFb/z2AwdtsiahYODpJ3pOytSgnPzHGfbde2mnRIyEpsRhTVQpVG/hdiRu4 ARO+Lko3b0NyUszatQSklHQHR6jxR+c7m5JhGdcTb14Fk2F8ZN/4zSePtNUqpGXCvFhO 1umvhltdo9Ujf1A4iEX8+7PmNJRwJZiHWONkZ9qM7E8cWJaTPihTwInyQTAEKX9eyGDw szQjqCcrtIdzNuqJEKlQx4lZvRhXqgQwA3kXiCMVlw3YqFFm6guFf8B8dK4iNQq4tsdk 27sQAfrD0Mv1qUly7SROAlWY7yYPJa2/4C1pWg7RnNK8rgTDhKQtL9y5cXjqYkpL1M5M Lmmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=jVdpzmol; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ck4si4168265ejb.29.2019.11.08.09.51.28; Fri, 08 Nov 2019 09:51:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=jVdpzmol; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730851AbfKHRtk (ORCPT + 99 others); Fri, 8 Nov 2019 12:49:40 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:33275 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730733AbfKHRtj (ORCPT ); Fri, 8 Nov 2019 12:49:39 -0500 Received: by mail-lj1-f196.google.com with SMTP id t5so7142358ljk.0 for ; Fri, 08 Nov 2019 09:49:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UVAbz2qNISBamKJ8aYyWKPdYYFUtEofFZoGab/xVx6Q=; b=jVdpzmol350RlxFDs+MLHaRNphUMUP4OvQ5IAPmY8hbKQPQsDF4LD+P6ahIMsJ6Rpl pUMnnGgEWZthCUvXmMqrer+tYk1QstqZ5L0VsSYXs5AIM8mttK7vKXNfkyoZk7SM78xu uJTmzg7POCfLqH9zCG0s8CXDWcSswJF62aIKCvOlPVqevsasjpkz/5ZlbLdOMn0zCJ2j C+dzIMZdnOFJ/mIbpTFmYjSGcDA/erk2dg8nzNoUV87zX7xBouMWtvkTjVmXM1YMpm38 Yi5lTSuQ/2AQzOGEB52mqbr8QWFQ7v6EjkHjKgKiTdFpkCcRJpUQpeBRrW2MOz6NXS1x /4EQ== 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=UVAbz2qNISBamKJ8aYyWKPdYYFUtEofFZoGab/xVx6Q=; b=mpZwFJ7QNyclYtzkrRy6pDKwKJ3OlkHndZWzdZSZoOlIJH+p8Unp0UqhMg+A89vYF6 pQz1rb6md1anQPP+CzZt/E+i0YpKB70QdSo3Y+Vvc4+IR7+E2vIUPOsQ07tMo5/xYwea 5RUWsH2J1xrjGhb0SgDtNpautJxFVnkmF3E+Oe0W5J/Y+IXTgyvYE0JiJJb167lRZGcE yXJHzKmRtzddgdPcnMv//T+HDR8QRoUQ/swbt30Ar3JDvUZ7/n8ypC7cR4KdP+pfryna UdfjAM43u004UnJuSTmBFXuFujZMnSvUjxX3gPWM5Phqkd7pJvnF9jRY2ZgONfh8FRq7 x6ig== X-Gm-Message-State: APjAAAUtABs8CMtEGZ1BgtzgBd9QtqPrTIJQ5Jxx918tVuM5mdEigI7P alekQzCz+wfx+gCJ+wjpTv/1RjgsbhdR12kPQTAF X-Received: by 2002:a2e:898d:: with SMTP id c13mr7895602lji.54.1573235374890; Fri, 08 Nov 2019 09:49:34 -0800 (PST) MIME-Version: 1.0 References: <230e91cd3e50a3d8015daac135c24c4c58cf0a21.1568834524.git.rgb@redhat.com> <20190927125142.GA25764@hmswarspite.think-freely.org> <20191024212335.y4ou7g4tsxnotvnk@madcap2.tricolour.ca> In-Reply-To: <20191024212335.y4ou7g4tsxnotvnk@madcap2.tricolour.ca> From: Paul Moore Date: Fri, 8 Nov 2019 12:49:23 -0500 Message-ID: Subject: Re: [PATCH ghak90 V7 06/21] audit: contid limit of 32k imposed to avoid DoS To: Richard Guy Briggs Cc: Neil Horman , containers@lists.linux-foundation.org, linux-api@vger.kernel.org, Linux-Audit Mailing List , linux-fsdevel@vger.kernel.org, LKML , netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, sgrubb@redhat.com, omosnace@redhat.com, dhowells@redhat.com, simo@redhat.com, Eric Paris , Serge Hallyn , ebiederm@xmission.com, Dan Walsh , mpatel@redhat.com 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 Thu, Oct 24, 2019 at 5:23 PM Richard Guy Briggs wrote: > On 2019-10-10 20:38, Paul Moore wrote: > > On Fri, Sep 27, 2019 at 8:52 AM Neil Horman wrote: > > > On Wed, Sep 18, 2019 at 09:22:23PM -0400, Richard Guy Briggs wrote: > > > > Set an arbitrary limit on the number of audit container identifiers to > > > > limit abuse. > > > > > > > > Signed-off-by: Richard Guy Briggs > > > > --- > > > > kernel/audit.c | 8 ++++++++ > > > > kernel/audit.h | 4 ++++ > > > > 2 files changed, 12 insertions(+) > > > > > > > > diff --git a/kernel/audit.c b/kernel/audit.c > > > > index 53d13d638c63..329916534dd2 100644 > > > > --- a/kernel/audit.c > > > > +++ b/kernel/audit.c > > > > ... > > > > > > @@ -2465,6 +2472,7 @@ int audit_set_contid(struct task_struct *task, u64 contid) > > > > newcont->owner = current; > > > > refcount_set(&newcont->refcount, 1); > > > > list_add_rcu(&newcont->list, &audit_contid_hash[h]); > > > > + audit_contid_count++; > > > > } else { > > > > rc = -ENOMEM; > > > > goto conterror; > > > > diff --git a/kernel/audit.h b/kernel/audit.h > > > > index 162de8366b32..543f1334ba47 100644 > > > > --- a/kernel/audit.h > > > > +++ b/kernel/audit.h > > > > @@ -219,6 +219,10 @@ static inline int audit_hash_contid(u64 contid) > > > > return (contid & (AUDIT_CONTID_BUCKETS-1)); > > > > } > > > > > > > > +extern int audit_contid_count; > > > > + > > > > +#define AUDIT_CONTID_COUNT 1 << 16 > > > > + > > > > > > Just to ask the question, since it wasn't clear in the changelog, what > > > abuse are you avoiding here? Ostensibly you should be able to create as > > > many container ids as you have space for, and the simple creation of > > > container ids doesn't seem like the resource strain I would be concerned > > > about here, given that an orchestrator can still create as many > > > containers as the system will otherwise allow, which will consume > > > significantly more ram/disk/etc. > > > > I've got a similar question. Up to this point in the patchset, there > > is a potential issue of hash bucket chain lengths and traversing them > > with a spinlock held, but it seems like we shouldn't be putting an > > arbitrary limit on audit container IDs unless we have a good reason > > for it. If for some reason we do want to enforce a limit, it should > > probably be a tunable value like a sysctl, or similar. > > Can you separate and clarify the concerns here? "Why are you doing this?" is about as simple as I can pose the question. > I plan to move this patch to the end of the patchset and make it > optional, possibly adding a tuning mechanism. Like the migration from > /proc to netlink for loginuid/sessionid/contid/capcontid, this was Eric > Biederman's concern and suggested mitigation. Okay, let's just drop it. I *really* don't like this approach of tossing questionable stuff at the end of the patchset; I get why you are doing it, but I think we really need to focus on keeping this changeset small. If the number of ACIDs (heh) become unwieldy the right solution is to improve the algorithms/structures, if we can't do that for some reason, *then* we can fall back to a limiting knob in a latter release. > As for the first issue of the bucket chain length traversal while > holding the list spin-lock, would you prefer to use the rcu lock to > traverse the list and then only hold the spin-lock when modifying the > list, and possibly even make the spin-lock more fine-grained per list? Until we have a better idea of how this is going to be used, I think it's okay for now. It's also internal to the kernel so we can change it at any time. My comments about the locking/structs was only to try and think of some reason why one might want to limit the number of ACIDs since neither you or Eric provided any reasoning that I could see. -- paul moore www.paul-moore.com