Received: by 10.192.165.156 with SMTP id m28csp715954imm; Mon, 16 Apr 2018 07:36:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+3ELcCb6c/nqEy5e34+SYzYWUpT4qZFKX9W6KT9C6PbYARi+eqwHQJdOtMNbLN4Q6IL7wH X-Received: by 2002:a17:902:ba88:: with SMTP id k8-v6mr15311038pls.305.1523889396565; Mon, 16 Apr 2018 07:36:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523889396; cv=none; d=google.com; s=arc-20160816; b=MIKGXX1a1zqFYWyE8kep4B2cxVSHkK/uo4G0d2TP3kih143tRy8FLFX8KcjvQwDNqo sOx+8Ngs9Phu9qAXiU8qh3F76WDs4gkbuMYTRL6O3NvR2j2j9+Co6EsDwNFt1j4dsnPE JJej/HWcotf7/gJkD+elwN1ZaSI6ejj7onjLJmh4FvPI05NZ+5GIPPV9e3wPRqJRuFt+ Th1PZ5tbHyVWGa5dniCrS0/Y+EhJxf2IUJPqt+q/2T2SxxnBxqxFd+srBIMiSMdg6vRe L26A/7jI3e3bao+AuYOZCWOArZYAVdl+XxdqW+osLkkhRtcndN7DGhnH0OoiDPXxcb4d IqTA== 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 :references:in-reply-to:mime-version:arc-authentication-results; bh=IMNfPkEAzhNjJAVujas/GRw8XIxggmwvzm5K1AhxFAE=; b=WsJFKJvxDo6FqGd3zL422RJwjt6YcNs8L1j8JGXQ1Ut14EZu+7xkg67r1xzgMZ0dJN hxsf64p5dSrW8lbU/FgwcWSnlyX+ht/k2VWHda/9VDLfadMUYEWZ8HwtkZq/L+K25uEf sAAhkgW04O/EB5b4yqC9C5664+tkmZhuPouf5zpBKnAl0B3FT0aQ3JXa0rzWHzD+a6J3 McyBsjuS8CxsFFWLvgMKSe4fModfPGBCD5jKYiYDxAv4aZwx9kdagiVourLyMFQfT2WD vL6gQ3GjNimfJHFkkfklCens31h+c5JqbsVwhqIWqLt++8Wfvy252q1CSERLX26eEzPu oXKQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 y11-v6si12092985plk.197.2018.04.16.07.36.22; Mon, 16 Apr 2018 07:36:36 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755455AbeDPOZi (ORCPT + 99 others); Mon, 16 Apr 2018 10:25:38 -0400 Received: from mail-ot0-f196.google.com ([74.125.82.196]:44513 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755291AbeDPOZf (ORCPT ); Mon, 16 Apr 2018 10:25:35 -0400 Received: by mail-ot0-f196.google.com with SMTP id p33-v6so17535023otp.11 for ; Mon, 16 Apr 2018 07:25:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=IMNfPkEAzhNjJAVujas/GRw8XIxggmwvzm5K1AhxFAE=; b=nPiMSw6zlS/yJzufxM3zAVdEHEgXQkXalH4j4UVNsR1fVnmTHBBhNU88rPxs7T+Ob/ AhMjyAMc1l7GUwvmIEgKt8JzfNDyWNKC0JcKK+iZLu9s36Ydk4PXxqr38zCAjpysl6eb MjNdQiXdIv7sPoeuRbcjeOQuwiXp6Tw83jzFsrofTRWVfPoa7RCRIyWT7JIk+XeXKSp2 aWWQyQ7LPem+GhaKLSt6zKKDMhgCzdSkn/LERMqxuMFjizZC+AyD7QPVkTMPD5EE66Y3 WftjEKcNC7/DeQIaTxAhoVjbDvZAxKZtRTn4lgIfDUarY2+CtVpQvVJgfhtTbR1nUhZF UROQ== X-Gm-Message-State: ALQs6tDJsy/XDOvyFL6Si+SfvR2ckqHm2cE6QxczV86uowrLnY+LhBZg byTnZ7aipL3DTRv4H96vwHc3wlbYXWEStTdK3Y4uug== X-Received: by 2002:a9d:5384:: with SMTP id w4-v6mr5573482otg.244.1523888734998; Mon, 16 Apr 2018 07:25:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.154.70 with HTTP; Mon, 16 Apr 2018 07:25:19 -0700 (PDT) In-Reply-To: <20180416141101.zcovkknupxcgiwf2@madcap2.tricolour.ca> References: <6b939250a519668af109adf877d85ff018b217d7.1523316267.git.rgb@redhat.com> <20180416141101.zcovkknupxcgiwf2@madcap2.tricolour.ca> From: Ondrej Mosnacek Date: Mon, 16 Apr 2018 16:25:19 +0200 Message-ID: Subject: Re: [PATCH ghak46 V1] audit: normalize MAC_STATUS record To: Richard Guy Briggs Cc: Linux-Audit Mailing List , LKML , SElinux list , Linux Security Module list 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 2018-04-16 16:11 GMT+02:00 Richard Guy Briggs : > On 2018-04-16 09:26, Ondrej Mosnacek wrote: >> 2018-04-10 1:34 GMT+02:00 Richard Guy Briggs : >> > There were two formats of the audit MAC_STATUS record, one of which was more >> > standard than the other. One listed enforcing status changes and the >> > other listed enabled status changes with a non-standard label. In >> > addition, the record was missing information about which LSM was >> > responsible and the operation's completion status. While this record is >> > only issued on success, the parser expects the res= field to be present. >> > >> > old enforcing/permissive: >> > type=MAC_STATUS msg=audit(1523312831.378:24514): enforcing=0 old_enforcing=1 auid=0 ses=1 >> > old enable/disable: >> > type=MAC_STATUS msg=audit(1523312831.378:24514): selinux=0 auid=0 ses=1 >> > >> > List both sets of status and old values and add the lsm= field and the >> > res= field. >> > >> > Here is the new format: >> > type=MAC_STATUS msg=audit(1523293828.657:891): enforcing=0 old_enforcing=1 auid=0 ses=1 enabled=1 old-enabled=1 lsm=selinux res=1 >> > >> > This record already accompanied a SYSCALL record. >> > >> > See: https://github.com/linux-audit/audit-kernel/issues/46 >> > Signed-off-by: Richard Guy Briggs >> > --- >> > security/selinux/selinuxfs.c | 11 +++++++---- >> > 1 file changed, 7 insertions(+), 4 deletions(-) >> > >> > diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c >> > index 00eed84..00b21b2 100644 >> > --- a/security/selinux/selinuxfs.c >> > +++ b/security/selinux/selinuxfs.c >> > @@ -145,10 +145,11 @@ static ssize_t sel_write_enforce(struct file *file, const char __user *buf, >> > if (length) >> > goto out; >> > audit_log(current->audit_context, GFP_KERNEL, AUDIT_MAC_STATUS, >> > - "enforcing=%d old_enforcing=%d auid=%u ses=%u", >> > + "enforcing=%d old_enforcing=%d auid=%u ses=%u" >> > + " enabled=%d old-enabled=%d lsm=selinux res=1", >> >> This is just a tiny nit but why does "old_enforcing" use an underscore >> and "old-enabled" a dash? Shouldn't the style be consistent across >> fields? > > Yes, but my understanding is a preference for underscore, and not to > change existing field names. Ah, I just noticed that the field is already used elsewhere in the code, so it makes sense to keep it the same. I thought at first that it is just a typo. > > Steve? > >> Just my two cents... > > These details are worth noticing, thank you. > >> > new_value, selinux_enforcing, >> > from_kuid(&init_user_ns, audit_get_loginuid(current)), >> > - audit_get_sessionid(current)); >> > + audit_get_sessionid(current), selinux_enabled, selinux_enabled); >> > selinux_enforcing = new_value; >> > if (selinux_enforcing) >> > avc_ss_reset(0); >> > @@ -272,9 +273,11 @@ static ssize_t sel_write_disable(struct file *file, const char __user *buf, >> > if (length) >> > goto out; >> > audit_log(current->audit_context, GFP_KERNEL, AUDIT_MAC_STATUS, >> > - "selinux=0 auid=%u ses=%u", >> > + "enforcing=%d old_enforcing=%d auid=%u ses=%u" >> > + " enabled=%d old-enabled=%d lsm=selinux res=1", >> > + selinux_enforcing, selinux_enforcing, >> >> ^ also here >> >> > from_kuid(&init_user_ns, audit_get_loginuid(current)), >> > - audit_get_sessionid(current)); >> > + audit_get_sessionid(current), 0, 1); >> > } >> > >> > length = count; >> >> Ondrej Mosnacek > > - 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 -- Ondrej Mosnacek Associate Software Engineer, Security Technologies Red Hat, Inc.