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 69677C433EF for ; Wed, 13 Oct 2021 21:17:04 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.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 D60F961152 for ; Wed, 13 Oct 2021 21:17:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D60F961152 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=paul-moore.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=redhat.com 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-429-pLOaHTgKOH--gXT0uFaN3Q-1; Wed, 13 Oct 2021 17:17:01 -0400 X-MC-Unique: pLOaHTgKOH--gXT0uFaN3Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24808801AFC; Wed, 13 Oct 2021 21:16:58 +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 E87DF1037F38; Wed, 13 Oct 2021 21:16:57 +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 64DF01806D00; Wed, 13 Oct 2021 21:16:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19DLFi2t029607 for ; Wed, 13 Oct 2021 17:15:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD4D96D9D9; Wed, 13 Oct 2021 21:15:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C71866D9D6 for ; Wed, 13 Oct 2021 21:15:42 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 151CD8007B1 for ; Wed, 13 Oct 2021 21:15:42 +0000 (UTC) Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-480-7y7PXYYYMpumfmML6xwwvA-1; Wed, 13 Oct 2021 17:15:40 -0400 X-MC-Unique: 7y7PXYYYMpumfmML6xwwvA-1 Received: by mail-ed1-f54.google.com with SMTP id w14so15513852edv.11 for ; Wed, 13 Oct 2021 14:15:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TQq8IvaJAjyAgsNLQVRIoKAyd4/0gIAn1tmOmUFhanE=; b=epVe3yyOryp6e3thmOVcCPdTZIcLmVbsbqobF32t9HAqpJfSLlUgrFs0QDhQ6QPvtv T+8vJL6J6M5oQY+toQ2pG3cpFA5vmBeFFHRrLTy0JAe2OhRbZ9hOspjFZr122ygYeL8t WWBimwOn3Mm/FjqyTacYEGl+zDNFtelTLJuZYtn8KjOTc0LVdxdQJUzPnxK6iVY81BYG OsFkfPc/gcrm1nx6jrKorTOHKc9ZP3OIkY+r681q87byZaWuYuCW7PzVZuoasVzKSCl3 5VSOMQk86Z0rQ/7GuABIATSh+SSfb50Gt2GJjyt+LhEivT9zFMPT4Zz3PYZj+v+QrlPH f5Gw== X-Gm-Message-State: AOAM532euTvJmn3X+P6MCUI+FCzglqlVAYCeGoxAAD3cyCU28T40+JD4 aPbyzVSaYvnoZ/XP/XI4EUe8c3nD82fQWbi6Zy2O X-Google-Smtp-Source: ABdhPJzKrEknnA5r7cZyO5mtn9/niWqr5UyZx2uYLQKgqXHcUiyW63KeZe8TQp1bIfb7b4dFe6xUsZLnSjMCzfAOGtw= X-Received: by 2002:a50:e1cd:: with SMTP id m13mr2653217edl.93.1634159739020; Wed, 13 Oct 2021 14:15:39 -0700 (PDT) MIME-Version: 1.0 References: <20211013091208.36209-1-cuigaosheng1@huawei.com> <20211013091208.36209-3-cuigaosheng1@huawei.com> In-Reply-To: <20211013091208.36209-3-cuigaosheng1@huawei.com> From: Paul Moore Date: Wed, 13 Oct 2021 17:15:28 -0400 Message-ID: Subject: Re: [PATCH -next, v2 2/2] audit: return early if the rule has a lower priority To: Gaosheng Cui X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: linux-audit@redhat.com Cc: xiujianfeng@huawei.com, wangweiyang2@huawei.com, linux-audit@redhat.com, linux-kernel@vger.kernel.org, Eric Paris 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.84 on 10.5.11.22 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 On Wed, Oct 13, 2021 at 5:10 AM 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(-) Thanks for this patch, it looks reasonable to me but have you done any testing with this patch? If so, what have you done? As a FYI, the audit-testsuite project lives here: * https://github.com/linux-audit/audit-testsuite > 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; > + > 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); > -- > 2.30.0 -- paul moore www.paul-moore.com -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit