Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp32807560rwd; Fri, 7 Jul 2023 22:45:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlGhUjoA09/k/tn2ctVMaJuJTDpYEfn+8SHVJqlP77BZ/omM7jjxSBQRjfNgr2zXae4LIBM+ X-Received: by 2002:a17:902:f68f:b0:1ae:6cf0:94eb with SMTP id l15-20020a170902f68f00b001ae6cf094ebmr6865270plg.5.1688795150044; Fri, 07 Jul 2023 22:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688795150; cv=none; d=google.com; s=arc-20160816; b=lXF54x4mEOXIIuhY7Z+Du98kcOkNXkcK3xF0Y6ksfLWShrT8BOhImWHaTwjXZ+B94R FWGYHU+trfRWVm5yyGt/X4CPSsT0hmzdOhygBG6q4pcDhFJ06aZbmMut2wJZo6CJSUl0 POesBEOI399V5A4Jrb2DCWNG7vgBcOI9O5KJD7Ofye3K5Kb+DzH2Mqk8FjVCHitfWams HC5J8YLyWU12tdHD4twbO1t4Q4LwiFRiv89EIJJtF6KqkLcxSiA2sWaZh5wjA8POBc73 as/1ouS3pCrpgNgUzJ7kc/WNgDShlHBLiQqVoSgRcJh0PzTqpD0EGsMd/G9ldDyNwflS DWrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:subject:cc:to:from :message-id:date:dkim-signature; bh=Z6/SL5QIc9OziszvZ8u03wi1DZHVgI7E++JsfeAk1ow=; fh=Vmgb78f+UWtIut1Oluhwx2oDAe4UZFJl5iee0zHKAXI=; b=AnPge5QlcVWO5xrpbA1ByMw5z1rCxnain6H/kCqehr/cl66zz8XdgALa1tuHl/RnAS ynVx/LabE29/XQ4fBCUNh3YZwn5zNJ2sa6jGuHEd8O1pQrhgANR6sJgd6U0iyTCC8eGT Mtw5JbIclI57OrSaeiYGiFf5tUHoEyrehqAJrh9oNoX5cMQdhISV4OArWc/2Ld4RBJTu nQFr1IycbTc7lQZpZtCnPnkQ98sFVEGEYnQ3+rLm325Rm64T0BZEWLuC/N/zlydDOKC4 haxuCH9QOg3z/eBm4fBDfAGsRZk6vgS4mzkc3YflRU+RVMCxV2xZp4d/8BtBdFwXmvSy Lc9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=N3GcVG1F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w16-20020a170902e89000b001b678455766si128671plg.650.2023.07.07.22.45.38; Fri, 07 Jul 2023 22:45:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=N3GcVG1F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233051AbjGHFic (ORCPT + 99 others); Sat, 8 Jul 2023 01:38:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232954AbjGHFhd (ORCPT ); Sat, 8 Jul 2023 01:37:33 -0400 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3733E26AA for ; Fri, 7 Jul 2023 22:37:03 -0700 (PDT) Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-6355e774d0aso16489326d6.1 for ; Fri, 07 Jul 2023 22:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1688794622; x=1691386622; h=in-reply-to:references:subject:cc:to:from:message-id:date:from:to :cc:subject:date:message-id:reply-to; bh=Z6/SL5QIc9OziszvZ8u03wi1DZHVgI7E++JsfeAk1ow=; b=N3GcVG1FDP/U4zI33j/s/ZPDElJlG1FTWT2qAeOAqZZcIpJGqcLEQFLywR9QELr4tx hEZ42jpKvn99UxuTEx85166xgkvcrhd7sW+0CAjhCYUI0KBK4kPHsnl5fjy2K8iPOK9Y 1Az8rufTzbfjqSl7326GH2mwzXNmtFdOsx0+mWv+TVL9tyX3bi5OYiZ5L4g3BwY2rNJZ iVybNFziEHZGs5Gw81G2muX9prmr7V1Z2N4WUDN45w6np73MhBdQOnODt5WE99Qc0YhR TuiwwrSDA7qlZfarpBEUkFtaYBCD+zjdJ0qb+ym09wRq7D2QHTSGgOWH0k8L/zi7c9Lv vmUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688794622; x=1691386622; h=in-reply-to:references:subject:cc:to:from:message-id:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Z6/SL5QIc9OziszvZ8u03wi1DZHVgI7E++JsfeAk1ow=; b=WuBxjN2NgfLffxJu7keItaf0Ccmy21Ef95508CH8zgl3i1en9PqzV+gifYJD9tc13g UuFZhRgVftms8hxLGNINGs6qtDXhWqhGoIXNX6fWHR2Hjn/bkjtBoD8CD4PmzLElX6bu GnlWt4lYshe1bckbjuHtKA6Yd1RcAmAPKzK94K17GsK9vKU2RSo/hTcSk3UI4gfN3zy2 UsGiId1WHTK77CE45xaT6xFoPOZOGwJKH1NcDi7RvqoIK3kgjP3Bn9GfKr1Kes47m7+A ABtiESopyLMG3PHNEN47L3qqRgPiMbpaRcfF3O2ExGSV4Ar4AZtHNAfdDvgiTGJzWFQh F+Pg== X-Gm-Message-State: ABy/qLaOzI5X0t9yCWXS95r1RATwLy5Fhc+7h2pnkFGWdqHho7GskKAi a1dzc/uQwbSdFFwUFrtl/u0a X-Received: by 2002:a0c:da14:0:b0:636:e4f:6b9a with SMTP id x20-20020a0cda14000000b006360e4f6b9amr6374783qvj.17.1688794621936; Fri, 07 Jul 2023 22:37:01 -0700 (PDT) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id m6-20020a0cdb86000000b006362c5760f8sm2952651qvk.139.2023.07.07.22.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 22:37:01 -0700 (PDT) Date: Sat, 08 Jul 2023 01:37:01 -0400 Message-ID: From: Paul Moore To: Fan Wu , corbet@lwn.net, zohar@linux.ibm.com, jmorris@namei.org, serge@hallyn.com, tytso@mit.edu, ebiggers@kernel.org, axboe@kernel.dk, agk@redhat.com, snitzer@kernel.org, eparis@redhat.com Cc: linux-doc@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, audit@vger.kernel.org, roberto.sassu@huawei.com, linux-kernel@vger.kernel.org, Deven Bowers , Fan Wu Subject: Re: [PATCH RFC v10 9/17] ipe: add permissive toggle References: <1687986571-16823-10-git-send-email-wufan@linux.microsoft.com> In-Reply-To: <1687986571-16823-10-git-send-email-wufan@linux.microsoft.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Jun 28, 2023 Fan Wu wrote: > > IPE, like SELinux, supports a permissive mode. This mode allows policy > authors to test and evaluate IPE policy without it effecting their > programs. When the mode is changed, a 1404 AUDIT_MAC_STATUS > be reported. > > This patch adds the following audit records: > > audit: MAC_STATUS enforcing=0 old_enforcing=1 auid=4294967295 > ses=4294967295 enabled=1 old-enabled=1 lsm=ipe res=1 > audit: MAC_STATUS enforcing=1 old_enforcing=0 auid=4294967295 > ses=4294967295 enabled=1 old-enabled=1 lsm=ipe res=1 > > The audit record only emit when the value from the user input is > different from the current enforce value. > > Signed-off-by: Deven Bowers > Signed-off-by: Fan Wu > --- > security/ipe/audit.c | 22 ++++++++++++++ > security/ipe/audit.h | 1 + > security/ipe/eval.c | 9 ++++++ > security/ipe/eval.h | 1 + > security/ipe/fs.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ > 5 files changed, 102 insertions(+) ... > diff --git a/security/ipe/fs.c b/security/ipe/fs.c > index 6bd2aa84831b..1761d39e4d04 100644 > --- a/security/ipe/fs.c > +++ b/security/ipe/fs.c > @@ -16,6 +16,7 @@ static struct dentry *np __ro_after_init; > static struct dentry *root __ro_after_init; > struct dentry *policy_root __ro_after_init; > static struct dentry *audit_node __ro_after_init; > +static struct dentry *enforce_node __ro_after_init; > > /** > * setaudit - Write handler for the securityfs node, "ipe/success_audit" > @@ -68,6 +69,61 @@ static ssize_t getaudit(struct file *f, char __user *data, > return simple_read_from_buffer(data, len, offset, result, 1); > } > > +/** > + * setenforce - Write handler for the securityfs node, "ipe/enforce" > + * @f: Supplies a file structure representing the securityfs node. > + * @data: Supplies a buffer passed to the write syscall. > + * @len: Supplies the length of @data. > + * @offset: unused. > + * > + * Return: > + * * >0 - Success, Length of buffer written > + * * <0 - Error > + */ > +static ssize_t setenforce(struct file *f, const char __user *data, > + size_t len, loff_t *offset) > +{ > + int rc = 0; > + bool new_value, old_value; > + > + if (!file_ns_capable(f, &init_user_ns, CAP_MAC_ADMIN)) > + return -EPERM; > + > + old_value = READ_ONCE(enforce); > + new_value = old_value; Why set @new_value equal to @old_value here? > + rc = kstrtobool_from_user(data, len, &new_value); > + if (rc) > + return rc; > + > + if (new_value != old_value) { > + ipe_audit_enforce(new_value, old_value); > + WRITE_ONCE(enforce, new_value); > + } > + > + return len; > +} -- paul-moore.com