Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp973935rwe; Wed, 31 Aug 2022 14:39:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR4vzPC37nwZ1/BZVRkP4PGp4dROXetb6yiZPg+sjVyD5cFp4JuHqVt5y5JGXzuedQfjMehK X-Received: by 2002:a17:902:ef50:b0:171:516d:d2ce with SMTP id e16-20020a170902ef5000b00171516dd2cemr26567323plx.171.1661981980184; Wed, 31 Aug 2022 14:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661981980; cv=none; d=google.com; s=arc-20160816; b=ej+l1WogUlfkpREF/vDdUPcQMw4OBcsw2xYedntlXUKxC+gWJvNr7lLLF7rO4N08bC bQD5BY10vo8y0zUBMBOTNCcDQUvjPPGmQbt5iyxWjjyt6tieWaL/LrnmL29hN0sufeK5 rcX3WU3wrEJvdo71mg6UNjS0+DhW9NeDEBg4g3+R6brfvpvOH+ewH71O9U81cjl6mg1A xzfMiYtM2DbVkoeqamXFImpuV3yDddO5R+FJhH80Nn1bY3PxrTRER6kPn7YPGCcoUrZX 3NZIxYevny6mHxU8KSq7vHIF1gaxaHTS3BM95gCksjoV0D1u3AkAuFbYH1RgpobL9ujf ncDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=N5G7tx6XzS2Mm25xM7iRQx+nrJ0/jmqysbh8SULQiRc=; b=vgG836iVsJgFkKXLuCspO1d1bysRHetwbrzmlqnfJKOzGBStIPli+MHSMMW1bBOzof lbluUIvca99JTS6WQT5izS2GglGFFlywCbDVwEyP0WzjkxLvCSTjthnfOchQKa/IPtAJ Bxg1UpmoSHXkaG/uzQxvZL7lsKG385XiOeEobZPiTgujxjmI6U5Tpcd7aomA7OvuIsZv w1LbGBmCMbQ6cQg2xkZEvUi2cmZOUcEc+UEyaUFq6yF8WUQBRfnKTTmxOAgU4+1ekFEi qUPpHg/D/UPVurWGMN0Ns7rObCWCQuZOL5TZ/VFKTFExYLNo3g5BnY+zFtuFAih4Gzwe t7Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IZ6KdLm5; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x1-20020a17090a970100b001efbff1c4a3si2659582pjo.76.2022.08.31.14.39.28; Wed, 31 Aug 2022 14:39:40 -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=@redhat.com header.s=mimecast20190719 header.b=IZ6KdLm5; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230179AbiHaVHg (ORCPT + 99 others); Wed, 31 Aug 2022 17:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbiHaVHe (ORCPT ); Wed, 31 Aug 2022 17:07:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22AEAF3252 for ; Wed, 31 Aug 2022 14:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661980052; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=N5G7tx6XzS2Mm25xM7iRQx+nrJ0/jmqysbh8SULQiRc=; b=IZ6KdLm5jl3W/qXZnkD/F68ixRF3KW0tz4AoTV1Itw0ZGIyEozt0XvfoW8jlt8J90E9/xS GGTsCC25FNndlUz7F6nYg4sShsccTBK/YFZwmG2FvrGhn6EpMLqsf/hLXqBwLc2Lo1Cr1l ypTSnCoiXVVJcGxVZz1uT+g94bJr1sI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-208-3iRI4zIvNiSrYMFsG6jm1w-1; Wed, 31 Aug 2022 17:07:30 -0400 X-MC-Unique: 3iRI4zIvNiSrYMFsG6jm1w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A813B8039BC; Wed, 31 Aug 2022 21:07:28 +0000 (UTC) Received: from madcap2.tricolour.ca (unknown [10.22.48.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 383E31415138; Wed, 31 Aug 2022 21:07:27 +0000 (UTC) Date: Wed, 31 Aug 2022 17:07:25 -0400 From: Richard Guy Briggs To: Steve Grubb , Paul Moore Cc: Linux-Audit Mailing List , LKML , linux-fsdevel@vger.kernel.org, Eric Paris , Jan Kara , Amir Goldstein Subject: Re: [PATCH v4 3/4] fanotify,audit: Allow audit to use the full permission event response Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 2022-08-15 20:22, Paul Moore wrote: > On Tue, Aug 9, 2022 at 1:23 PM Richard Guy Briggs wrote: > > > > This patch passes the full value so that the audit function can use all > > of it. The audit function was updated to log the additional information in > > the AUDIT_FANOTIFY record. The following is an example of the new record > > format: > > > > type=FANOTIFY msg=audit(1600385147.372:590): resp=2 fan_type=1 fan_info=17 > > > > Suggested-by: Steve Grubb > > Link: https://lore.kernel.org/r/3075502.aeNJFYEL58@x2 > > Signed-off-by: Richard Guy Briggs > > --- > > fs/notify/fanotify/fanotify.c | 3 ++- > > include/linux/audit.h | 9 +++++---- > > kernel/auditsc.c | 31 ++++++++++++++++++++++++++++--- > > 3 files changed, 35 insertions(+), 8 deletions(-) > > You've hopefully already seen the kernel test robot build warning, so > I won't bring that up again, but a few comments below ... Yes, dealt with... ... > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > > index 433418d73584..f000fec52360 100644 > > --- a/kernel/auditsc.c > > +++ b/kernel/auditsc.c > > @@ -64,6 +64,7 @@ > > #include > > #include > > #include // struct open_how > > +#include > > > > #include "audit.h" > > > > @@ -2899,10 +2900,34 @@ void __audit_log_kern_module(char *name) > > context->type = AUDIT_KERN_MODULE; > > } > > > > -void __audit_fanotify(u32 response) > > +void __audit_fanotify(u32 response, size_t len, char *buf) > > { > > - audit_log(audit_context(), GFP_KERNEL, > > - AUDIT_FANOTIFY, "resp=%u", response); > > + struct fanotify_response_info_audit_rule *friar; > > + size_t c = len; > > + char *ib = buf; > > + > > + if (!(len && buf)) { > > + audit_log(audit_context(), GFP_KERNEL, AUDIT_FANOTIFY, > > + "resp=%u fan_type=0 fan_info=?", response); > > + return; > > + } > > + while (c >= sizeof(struct fanotify_response_info_header)) { > > + friar = (struct fanotify_response_info_audit_rule *)buf; > > Since the only use of this at the moment is the > fanotify_response_info_rule, why not pass the > fanotify_response_info_rule struct directly into this function? We > can always change it if we need to in the future without affecting > userspace, and it would simplify the code. Steve, would it make any sense for there to be more than one FAN_RESPONSE_INFO_AUDIT_RULE header in a message? Could there be more than one rule that contributes to a notify reason? If not, would it be reasonable to return -EINVAL if there is more than one? > > + switch (friar->hdr.type) { > > + case FAN_RESPONSE_INFO_AUDIT_RULE: > > + if (friar->hdr.len < sizeof(*friar)) { > > + audit_log(audit_context(), GFP_KERNEL, AUDIT_FANOTIFY, > > + "resp=%u fan_type=%u fan_info=(incomplete)", > > + response, friar->hdr.type); > > + return; > > + } > > + audit_log(audit_context(), GFP_KERNEL, AUDIT_FANOTIFY, > > + "resp=%u fan_type=%u fan_info=%u", > > + response, friar->hdr.type, friar->audit_rule); > > + } > > + c -= friar->hdr.len; > > + ib += friar->hdr.len; > > + } > > } > > > > void __audit_tk_injoffset(struct timespec64 offset) > > paul-moore.com - 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