From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C47AC433F5 for ; Tue, 19 Oct 2021 14:51:42 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 327196113B for ; Tue, 19 Oct 2021 14:51:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 327196113B Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634655101; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sogDjzrcyYnFyOKfYqJ77t6xoB0tA+b6fwoeU6Bk+K4=; b=Tlsv1+MWk6CMrq2RJoUuDS68JtJUmWqk816zSmxbDN/DtteZvI10u5XJYGMMk+0eo1ei5A wrBWHuo8+O3X24Aq2DhlwFFcaf3rcm2daPgtuca+NNdzYFQgTjmSCjguycz1Yai2jU9YwZ UPea4CZsK6h7zxcya78H7aCI/AAwock= 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-104-zmuOTGfYOECQoC_P1LWcdw-1; Tue, 19 Oct 2021 10:51:37 -0400 X-MC-Unique: zmuOTGfYOECQoC_P1LWcdw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF0541B2C981; Tue, 19 Oct 2021 14:51:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09A9E60C5F; Tue, 19 Oct 2021 14:51:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D38511801241; Tue, 19 Oct 2021 14:51:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19JEpRSH001598 for ; Tue, 19 Oct 2021 10:51:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 27DA45BB06; Tue, 19 Oct 2021 14:51:27 +0000 (UTC) Received: from x2.localnet (unknown [10.22.33.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58D9C7092D; Tue, 19 Oct 2021 14:51:01 +0000 (UTC) From: Steve Grubb To: paul@paul-moore.com, eparis@redhat.com, rgb@redhat.com, linux-audit@redhat.com Subject: Re: [PATCH -next, v3 2/2] audit: return early if the rule has a lower priority Date: Tue, 19 Oct 2021 10:51:00 -0400 Message-ID: <5543735.DvuYhMxLoT@x2> Organization: Red Hat In-Reply-To: <20211016072351.237745-3-cuigaosheng1@huawei.com> References: <20211016072351.237745-1-cuigaosheng1@huawei.com> <20211016072351.237745-3-cuigaosheng1@huawei.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: linux-audit@redhat.com Cc: wangweiyang2@huawei.com, linux-audit@redhat.com, linux-kernel@vger.kernel.org, Gaosheng Cui X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=linux-audit-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello, On Saturday, October 16, 2021 3:23:51 AM EDT Gaosheng Cui wrote: > It is not necessary for audit_filter_rules() functions to check > audit fileds of the rule with a lower priority, and if we did, > there might be some unintended effects, such as the ctx->ppid > may be changed unexpectedly, so return early if the rule has > a lower priority. > > Signed-off-by: Gaosheng Cui > --- > kernel/auditsc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > index 42d4a4320526..b517947bfa48 100644 > --- a/kernel/auditsc.c > +++ b/kernel/auditsc.c > @@ -470,6 +470,9 @@ static int audit_filter_rules(struct task_struct *tsk, > u32 sid; > unsigned int sessionid; > > + if (ctx && rule->prio <= ctx->prio) > + return 0; > + Just wondering something... If the first thing we do is to decide to return, should we have called the function in the first place? I wonder if this test should be used to break out of the rule iteration loops so that we don't keep calling only to return ? -Steve > cred = rcu_dereference_check(tsk->cred, tsk == current || task_creation); > > for (i = 0; i < rule->field_count; i++) { > @@ -737,8 +740,6 @@ static int audit_filter_rules(struct task_struct *tsk, > } > > if (ctx) { > - if (rule->prio <= ctx->prio) > - return 0; > if (rule->filterkey) { > kfree(ctx->filterkey); > ctx->filterkey = kstrdup(rule->filterkey, GFP_ATOMIC); -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit