Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6900547ybi; Wed, 29 May 2019 15:19:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyL8dgboVedNsNmHnfFZKkzpPadMmLsLqzMfFgkR8Sus53rIOrTJzt+MoJACNEZee7kc5PX X-Received: by 2002:aa7:81ca:: with SMTP id c10mr34026849pfn.163.1559168340247; Wed, 29 May 2019 15:19:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559168340; cv=none; d=google.com; s=arc-20160816; b=nLfCh50lLB+uBIbL0FXY2b3KGzlDl3rgMM+mzNktztS8LEuUypDqXkE+Sbajydwb7k GcWPXhDeJ7gV5AQ3lz29nQLd+IzFrdoMP+r9n7GAO66iL0+op5rwNtL92qETdeJqRTJR vRR2ruziZbSomX7+ScCNXZZIcvCmtAXMNi5Ih6J3v+4BrlkQc03ehASwJ4CrsnVdSG/f FbagOY57ipMkqaJArhe22sUen7B2AiQ/Ycg67FgXpfAiF2M0I28FnZw4nRIpm47rOmTk bGSlrrVJJ55BpUEYdpEqwNtAxegeXnW8z7ffuGl6Eq5/s0pcEdMDInEeAOvuFPnqoNWB 7pLQ== 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=Oz7cGsD/P4AYjrQuzbhSqhrqwPvDYoZyUjrCxUd5apo=; b=0h9Kddm54UvCjGMbLFyPhe5Gp5ekp3g3kBCQo4oYPU0b6OIqy+/AeUpqN1G0gOyEs3 TTPWwVI5i5PogS8nChHsd19w2I+RUTj6h7MmmMoNMJxfbWfr/1EQRhovQ6xqkfVJAeIB BBvUGY6YpuKMrH9/uVuR5CHzhTc8GO4jFg/EXkwTijYRxz2EYPh12JzzRUhM8+KG2j5G SxVgKo7p6cWvWtG48W6XFD6uP0bgBc9OyO3FV2lNbMdeCNj/AP9ULR2CURJiw5oJVxK6 PREROmWVt+q8ZhnoMVZ6hz+35DiOVCLZC7V8YsXnfVzblJrLwddmrmlkql9C1OCScHHI qoug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=W488NziP; 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 z14si1014171pgv.128.2019.05.29.15.18.43; Wed, 29 May 2019 15:19:00 -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=W488NziP; 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 S1726816AbfE2WQc (ORCPT + 99 others); Wed, 29 May 2019 18:16:32 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40363 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726613AbfE2WQb (ORCPT ); Wed, 29 May 2019 18:16:31 -0400 Received: by mail-lj1-f195.google.com with SMTP id q62so4085648ljq.7 for ; Wed, 29 May 2019 15:16:29 -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=Oz7cGsD/P4AYjrQuzbhSqhrqwPvDYoZyUjrCxUd5apo=; b=W488NziPak7bX8NLwk8X91sVgaISEiHHggxPCEy5FTn4IJfjT1bBLLNUdZubDFWtPH 7KoVKeHGWUJXYe/3LbLZBn7H5JwyXSUSceIdUccTOeecjr9Rha/esMd2v5J0QgIJpV+r w04dPFkQRPrhrAhVz6CVOLfdZR28+WrUYuPXRMr/nyIluc9YhOFeRWVGdDt44wALPWrq PIABiusmnwb5q3e6jTuVcyQq9WGF/T14PHNRDSG8TQJ0AL3qJIxSz6hon1W/8m1HgZoD RpTG7XBD0QK5YboiITTVwFV0joTjp8gpqwSWpkPmVhJkcpSP6IsYCYIr59Rl1ujOgBWb A8AA== 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=Oz7cGsD/P4AYjrQuzbhSqhrqwPvDYoZyUjrCxUd5apo=; b=p+gGTHxFuJo0H71f/lpH1lH9LXZr4TcV/gZra59Igmjyc2biSFzmI012k8erjaWJS6 IpOMiQU5WFlCQywDYGxlVzQTwEkKEetc5OkLvcTsOY5WIK/FY44mhE6vTNWype24BXjL /yM/henTS+47JmQiywGQy+qtERXuYlA05Xv+YYW9sXn565WkPXs/PkfnWnQlaifPlIXO 8f+CepacuVpHLjsMVbm/2nQ0OX4/LsOE8DrD/v9iaaKTgFriS9GRpTenSe2+y6RMSelk zds0EezPZStuAPUe978Gva36KQmUo4tDQZxG0d5WyK7VuxV6NC7OKssb+wg2KIv9jksQ sgtg== X-Gm-Message-State: APjAAAVAIH4CpJY+u1SJ8TBr4ItVjSuogHxC1MHXIIm72Ab6ZajEd1IS rLeegqNFkBQ4CrGXqEqF9S0IZyQNlQKGsHUVzyagzY4= X-Received: by 2002:a2e:3e14:: with SMTP id l20mr137436lja.40.1559168188869; Wed, 29 May 2019 15:16:28 -0700 (PDT) MIME-Version: 1.0 References: <0785ee2644804f3ec6af1243cc0dcf89709c1fd4.1554732921.git.rgb@redhat.com> In-Reply-To: <0785ee2644804f3ec6af1243cc0dcf89709c1fd4.1554732921.git.rgb@redhat.com> From: Paul Moore Date: Wed, 29 May 2019 18:16:18 -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 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. > + return 0; > + } > +} -- paul moore www.paul-moore.com