Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4016302ybg; Fri, 25 Oct 2019 12:08:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhLeexYt06pV+6A/1nQucR7lXKvyWsjzhpmHvxZIRE0n5jR5wN92EXI62yoayhBD9bZunM X-Received: by 2002:aa7:d44d:: with SMTP id q13mr5863106edr.48.1572030494678; Fri, 25 Oct 2019 12:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572030494; cv=none; d=google.com; s=arc-20160816; b=H6uuaQSNGBc2ngzE80y5Fmj3LB0eltBbsuHXATgXzgLZlVnKVMTJAujEXNFgByloxA IWY+qugGAeycLVUhwHVOMye+oHxPr05SouUetM0MhPjDebHDaaep2sx4+H+PxENQIhzT dv6w8+/MSd4RtCtkmneiGZ+T8c937YzRs5M8nMV8I32DupdG/C3vVwPzzcBMkwOVWMv/ W1p0yGfvA1otXBFhqqUBCEnZ1DNfLbhstnFInk3IU7lwPTzDoR/AFki6l6HKtZhemBPk kJpnRWemvFTIatrpE2qnvgJmcUxgdvKOLgAdijUe+qQDQDUuQhFkuGQ0xLqoIjNi6683 ab0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FrgDI2gW2aiugtgpqG1ZL6sF4tooWRGmsSjSW32gsYw=; b=CqRaOT9CBg6LnSbY2aWwK1ZCKgcUw1kiGTwNdJ/Z4Zz82jbVK4yOFkaIIMNkoI78IN aFFSbLsfCOnQGQPMiagkBdY5CNJlV0RF/RjoHCaO4V7lQt4lUt8k/Ypwi3PClSvmbrSQ PZBq+AS8LEVpBXas6/83UI8AJBp1WlcXDxtryZ6gQt3a5c0wThiXXwm+DZqjOq8w1d33 m+dWfThybSWjuAxuHWbxnBHeXsK0MiV0LrPYmlblJjyxfAWYpDdakSheZO+Ri09JYoZ+ 3JDGZGEchBV4NYGfsEu18Tink5LbepA67uuMTgR6Up5qAFPzOQPYL/7wApjwRck8TQst ZwoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bmWL0fM9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si2071506edb.226.2019.10.25.12.07.50; Fri, 25 Oct 2019 12:08:14 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=bmWL0fM9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729021AbfJXVYA (ORCPT + 99 others); Thu, 24 Oct 2019 17:24:00 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:52332 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727838AbfJXVX7 (ORCPT ); Thu, 24 Oct 2019 17:23:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571952237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FrgDI2gW2aiugtgpqG1ZL6sF4tooWRGmsSjSW32gsYw=; b=bmWL0fM9TfiU0L3s6Q7hPUVkQwlrUGJa7P7YCgHqiFrezv/LfumiMZFk9ogXYOr7L12VZr j62BKLaDzYK+Kk8WOPP33//lis/5sGUTiBb6ukG/u0AUCaDtmmHO+dqYb2jDoTMfub+svE o5CcXu7NAAXja6niON+bYvy4SSe/1iM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-312-PWtRXmUyOIOZMecadsE0tQ-1; Thu, 24 Oct 2019 17:23:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C68E7476; Thu, 24 Oct 2019 21:23:51 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-19.phx2.redhat.com [10.3.112.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13D9D600C6; Thu, 24 Oct 2019 21:23:37 +0000 (UTC) Date: Thu, 24 Oct 2019 17:23:35 -0400 From: Richard Guy Briggs To: Paul Moore 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 Subject: Re: [PATCH ghak90 V7 06/21] audit: contid limit of 32k imposed to avoid DoS Message-ID: <20191024212335.y4ou7g4tsxnotvnk@madcap2.tricolour.ca> References: <230e91cd3e50a3d8015daac135c24c4c58cf0a21.1568834524.git.rgb@redhat.com> <20190927125142.GA25764@hmswarspite.think-freely.org> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: PWtRXmUyOIOZMecadsE0tQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 t= o > > > 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 >=20 > ... >=20 > > > @@ -2465,6 +2472,7 @@ int audit_set_contid(struct task_struct *task, = u64 contid) > > > newcont->owner =3D current; > > > refcount_set(&newcont->refcount, 1); > > > list_add_rcu(&newcont->list, &audit_con= tid_hash[h]); > > > + audit_contid_count++; > > > } else { > > > rc =3D -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 a= s > > 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 concerne= d > > 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. >=20 > 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? 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. 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? > paul moore - RGB -- Richard Guy Briggs Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635