Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6186915rwb; Tue, 9 Aug 2022 10:31:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR7r4i53NknIJ9MAAfwt/rh+6dJiiH8A9DPqRCbRhY04CekwdyzeEWOLu969RNs0OB7KikIK X-Received: by 2002:a17:907:2896:b0:730:983c:4621 with SMTP id em22-20020a170907289600b00730983c4621mr18252847ejc.502.1660066263454; Tue, 09 Aug 2022 10:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660066263; cv=none; d=google.com; s=arc-20160816; b=bNlnr7f4Hf9bPTg3UdJML6KE6TSb7eief3JknhYYPevCzYlJzILQIDtN9nvaDO7MsH 5ghNc/RcFiNVak5XgfT4CshFf6Xnm6VgmCIxTKzL54g/szhUG0gNF6mT8Wo6Wdv3nHZ8 hbKFR4ZvUuclOEjYd3veCNScJkJXGsnjL0ZF7TPkFpJhQ+PRB/H5xfZMhnYhQxtV40Y2 YB9KeVLi97H4rv7XqJhflR4BnjdLfLq/KlEyf75D1+KLA0g05dy19I6B+GWp3Dio3Ezj ibxFU1KpYVPUNacmvDl/PM2K+3L6Eg92+a1/kyW5G1jc3lSLqr9nruuTgrpqSthwvtPx eDkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qPbho2+c8dAkqKWuFGRj6nlv+UYf9Vv/Uh5Ehbs5Rkg=; b=O4WQasKqm9x6aep8tGJzoB3QCJ2e7rcplTHI6wCnbKglgGLGSQbMIOTLJWycDTtkSz gmhPY1u5S0Ql8B3G1Ttbvy8S7DBA/ENAlxXdVx9z9uT89Ck3bC2EvvI4gz9yGyQ5A6jt rOfw7TeshcSri7T0okkIR4tMCQuJRvqe38I3lLf3gNEdAlDkOZ1tEQROu0ff4kpgu8gc J3fOUzV83RRq7ioXFvKvnGQA8vsgw08BupKVNn0EjacJb93c97QQaxSOhUAUkZ9MapZK BbLbXjpABfVLQC/n9BOy4gZ5tpY0bnrA+ur1WYy4fwadKELkU+D5V/anvBoaHacTJGxR iRjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=grjxGmX0; 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 i18-20020a05640242d200b0043b0e7cf010si10457628edc.331.2022.08.09.10.30.34; Tue, 09 Aug 2022 10:31:03 -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=grjxGmX0; 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 S245306AbiHIRXx (ORCPT + 99 others); Tue, 9 Aug 2022 13:23:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245223AbiHIRXa (ORCPT ); Tue, 9 Aug 2022 13:23:30 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 12BD8252A3 for ; Tue, 9 Aug 2022 10:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660065801; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qPbho2+c8dAkqKWuFGRj6nlv+UYf9Vv/Uh5Ehbs5Rkg=; b=grjxGmX0AEUPfeKVhVbxpJzzxYigzNjhq4kr4amc8iN+ub1dUOU84xcaIO8/hLyvaxoR1w h+jOfqnoCjFc5BfU13m8cGyFTogApc19Mv5DdfeCeDqWv+xKaUzLtcoxXFI3qcz1K/s4KT vXpXBgLfDVl0AUtEAlMPTRiaDBFGPa8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-319-8YK0xgFjP5S1HHOFkibRIw-1; Tue, 09 Aug 2022 13:23:17 -0400 X-MC-Unique: 8YK0xgFjP5S1HHOFkibRIw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 184C63800C44; Tue, 9 Aug 2022 17:23:17 +0000 (UTC) Received: from madcap2.tricolour.com (unknown [10.22.48.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4523945D2; Tue, 9 Aug 2022 17:23:15 +0000 (UTC) From: Richard Guy Briggs To: Linux-Audit Mailing List , LKML , linux-fsdevel@vger.kernel.org Cc: Paul Moore , Eric Paris , Steve Grubb , Richard Guy Briggs , Jan Kara , Amir Goldstein Subject: [PATCH v4 4/4] fanotify,audit: deliver fan_info as a hex-encoded string Date: Tue, 9 Aug 2022 13:22:55 -0400 Message-Id: <2d8159cec4392029dabfc39b55ac5fbd0faa9fbd.1659996830.git.rgb@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, 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 Currently the only type of fanotify info that is defined is an audit rule number, but convert it to hex encoding to future-proof the field. Sample record: type=FANOTIFY msg=audit(1659730979.839:284): resp=1 fan_type=0 fan_info=3F Suggested-by: Paul Moore Signed-off-by: Richard Guy Briggs --- kernel/auditsc.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index f000fec52360..0f747015c577 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2908,22 +2908,36 @@ void __audit_fanotify(u32 response, size_t len, char *buf) if (!(len && buf)) { audit_log(audit_context(), GFP_KERNEL, AUDIT_FANOTIFY, - "resp=%u fan_type=0 fan_info=?", response); + "resp=%u fan_type=0 fan_info=3F", response); /* "?" */ return; } while (c >= sizeof(struct fanotify_response_info_header)) { + struct audit_context *ctx = audit_context(); + struct audit_buffer *ab; + friar = (struct fanotify_response_info_audit_rule *)buf; 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); + ab = audit_log_start(ctx, GFP_KERNEL, AUDIT_FANOTIFY); + if (ab) { + audit_log_format(ab, "resp=%u fan_type=%u fan_info=", + response, friar->hdr.type); +#define INCOMPLETE "(incomplete)" + audit_log_n_hex(ab, INCOMPLETE, sizeof(INCOMPLETE)); + audit_log_end(ab); + } return; } - audit_log(audit_context(), GFP_KERNEL, AUDIT_FANOTIFY, - "resp=%u fan_type=%u fan_info=%u", - response, friar->hdr.type, friar->audit_rule); + ab = audit_log_start(ctx, GFP_KERNEL, AUDIT_FANOTIFY); + if (ab) { + audit_log_format(ab, "resp=%u fan_type=%u fan_info=", + response, friar->hdr.type); + audit_log_n_hex(ab, (char *)&friar->audit_rule, + sizeof(friar->audit_rule)); + audit_log_end(ab); + + } } c -= friar->hdr.len; ib += friar->hdr.len; -- 2.27.0