Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp845816ybi; Thu, 30 May 2019 07:38:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4mRU7r+rR3RtJgPKLtoLCqbS84Oprdl0JlLbIbGVEtDpccAuePg9ae4VU6DCVUqTaWOWg X-Received: by 2002:aa7:82d7:: with SMTP id f23mr4027901pfn.138.1559227092767; Thu, 30 May 2019 07:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559227092; cv=none; d=google.com; s=arc-20160816; b=rxwgPUKiybAgrmBorxgiEHg8yLYalpGZOnY25wwHHjnDB3asxC/oPyRcd9dK0ZX7+x hdNAlsOjmcloIaavQp/HLrRYUfDJRoYkPL5iqyduwL3Avh9vRS4JqiujPKxaivk7t5+F Z9kIdoopT5N+g0hR1UaMr8WeslxuIcm3opvzykMipLv9Uqh1/qBshl2KFEO5oCdaVkXh d0XyUQ/sup6MuSJQoTjrS4P0jUw92QQSwpAQ+OHeEcCzyx7YAF351fQ7MndNJyIzw/5H fmeRQgtCpdKuDBFiFpmXD/wF+4/a7xu5BH/SesC4dX8dZoGCP1ONA72lZOwD2x4r/EZO y45A== 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=BnDbzkkNEs3+qCAYM6PlcBSJ9muruAbc6zh0yrmMscI=; b=Fb+6VvhOnLdRQgzdRi9MUUGHfc6+KUDIN94kNrp1GGhKNghH2X434Qkpkh1+NdHx7j C4/qWTSAtbF7V7MRbVOa+sugd7rajhD+e4j8vbaWX4nDH6yy4qf/NmfxmgpRVZIsy+/5 4D1G1GsSDBwf8w0EZnDwMl7zI4/dzOtBTb+Nu0uoY49Z57U9f7tjnpkQhXCUpRuvG/uJ XKTjrB/uyn6SOyc4LYzKjZAsaCGXQH8BjI75jxjrrUCWQdXfiFRG5U043KsW2JYbD2F0 J+gZZFXs54ogqhoRI65AojEZ0yUjbTljtVpgNFbMe703SJpb3Dl+wmDmCoizM2A+krIc xW2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=GWJCSp8E; 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 q43si3272332pjb.30.2019.05.30.07.37.53; Thu, 30 May 2019 07:38:12 -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=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=GWJCSp8E; 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 S1727109AbfE3OfD (ORCPT + 99 others); Thu, 30 May 2019 10:35:03 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36236 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbfE3OfD (ORCPT ); Thu, 30 May 2019 10:35:03 -0400 Received: by mail-lf1-f68.google.com with SMTP id q26so5229786lfc.3 for ; Thu, 30 May 2019 07:35:01 -0700 (PDT) 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=BnDbzkkNEs3+qCAYM6PlcBSJ9muruAbc6zh0yrmMscI=; b=GWJCSp8Ea5nLSw4PQsmUexLPU9ilEqisyppKzq55gGe0EXTU1gK81I2OupZcNpEfBp FEt6cP3ID92EWi+7AOnBYGA0Ks7kMMHmIwuCOXSTnoWyt9G0QUg/qPKTyCr++U1Vj81z OBD9bVbRccfpHrJSutlT+QxN7HGtO6iu7CDa5SLnoPR89ac3mi2LAiNOoxPv0PDN/hp4 l40+0DaiA/QQzBIUYu0FZHnaSsQni3VmtD1j1Ni4uJrquQC2ecy5KN+HQxdP9IoLrIqB NQaPK9NrzK6KSr1mQCUVyOMXunHba1wxDCzenzD+grV8InLlZw+DV7yqW3qc0uFM5f2z aTnQ== 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=BnDbzkkNEs3+qCAYM6PlcBSJ9muruAbc6zh0yrmMscI=; b=FJKcwyzGIGkDUYG00AeX2xQUxaLgvoH1bAYx+1zfWSNPrlot8kNUDnz+GhId67BjYA afs/YFNs9pRylsCxaM8meZD4cv3ge2v0J/FCtQcLxJBGkhm6aaaajFdu2IDZmUe5EA9v m9SfuFiu+P7oipWT1DFR4Vt4KS+lslDTFzvYoznuuWUGhgwwKjHsNvaYMg4EovgqB9/Y ImFGfuRa249AkoGXrBb4aSdfn4EALUkIKoaep804GPKsVyhMNczzGz7aRZCie0woFLQm gv+3Sh3xPq52ijiAIzibWB4mzsbPT+RnCH2YgrPMN1kTWvQZsL2YB2qAXb+rvkov4eQV tJhA== X-Gm-Message-State: APjAAAUiIL6zqJp+adPELSYGEEhm6gz1UrMKx+CWrWrauW69HD2v2wd0 +S83LQByPWLW513a1JUKqS1M2TbUmv/KkgxbJtez X-Received: by 2002:ac2:410a:: with SMTP id b10mr2250887lfi.175.1559226900658; Thu, 30 May 2019 07:35:00 -0700 (PDT) MIME-Version: 1.0 References: <0785ee2644804f3ec6af1243cc0dcf89709c1fd4.1554732921.git.rgb@redhat.com> <20190530141951.iofimovrndap4npq@madcap2.tricolour.ca> In-Reply-To: <20190530141951.iofimovrndap4npq@madcap2.tricolour.ca> From: Paul Moore Date: Thu, 30 May 2019 10:34:49 -0400 Message-ID: Subject: Re: [PATCH ghak90 V6 08/10] audit: add containerid filtering To: Richard Guy Briggs Cc: 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, nhorman@tuxdriver.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, May 30, 2019 at 10:20 AM Richard Guy Briggs wrote: > > On 2019-05-29 18:16, Paul Moore wrote: > > On Mon, Apr 8, 2019 at 11:41 PM Richard Guy Briggs wrote: > > > > > > Implement audit container identifier filtering using the AUDIT_CONTID > > > field name to send an 8-character string representing a u64 since the > > > value field is only u32. > > > > > > Sending it as two u32 was considered, but gathering and comparing two > > > fields was more complex. > > > > > > The feature indicator is AUDIT_FEATURE_BITMAP_CONTAINERID. > > > > > > Please see the github audit kernel issue for the contid filter feature: > > > https://github.com/linux-audit/audit-kernel/issues/91 > > > Please see the github audit userspace issue for filter additions: > > > https://github.com/linux-audit/audit-userspace/issues/40 > > > Please see the github audit testsuiite issue for the test case: > > > https://github.com/linux-audit/audit-testsuite/issues/64 > > > Please see the github audit wiki for the feature overview: > > > https://github.com/linux-audit/audit-kernel/wiki/RFE-Audit-Container-ID > > > Signed-off-by: Richard Guy Briggs > > > Acked-by: Serge Hallyn > > > Acked-by: Neil Horman > > > Reviewed-by: Ondrej Mosnacek > > > --- > > > include/linux/audit.h | 1 + > > > include/uapi/linux/audit.h | 5 ++++- > > > kernel/audit.h | 1 + > > > kernel/auditfilter.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ > > > kernel/auditsc.c | 4 ++++ > > > 5 files changed, 57 insertions(+), 1 deletion(-) > > > > ... > > > > > diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c > > > index 63f8b3f26fab..407b5bb3b4c6 100644 > > > --- a/kernel/auditfilter.c > > > +++ b/kernel/auditfilter.c > > > @@ -1206,6 +1224,31 @@ int audit_comparator(u32 left, u32 op, u32 right) > > > } > > > } > > > > > > +int audit_comparator64(u64 left, u32 op, u64 right) > > > +{ > > > + switch (op) { > > > + case Audit_equal: > > > + return (left == right); > > > + case Audit_not_equal: > > > + return (left != right); > > > + case Audit_lt: > > > + return (left < right); > > > + case Audit_le: > > > + return (left <= right); > > > + case Audit_gt: > > > + return (left > right); > > > + case Audit_ge: > > > + return (left >= right); > > > + case Audit_bitmask: > > > + return (left & right); > > > + case Audit_bittest: > > > + return ((left & right) == right); > > > + default: > > > + BUG(); > > > > A little birdy mentioned the BUG() here as a potential issue and while > > I had ignored it in earlier patches because this is likely a > > cut-n-paste from another audit comparator function, I took a closer > > look this time. It appears as though we will never have an invalid op > > value as audit_data_to_entry()/audit_to_op() ensure that the op value > > is a a known good value. Removing the BUG() from all the audit > > comparators is a separate issue, but I think it would be good to > > remove it from this newly added comparator; keeping it so that we > > return "0" in the default case seems reasoanble. > > Fair enough. That BUG(); can be removed. Please send a fixup patch for this. -- paul moore www.paul-moore.com