From patchwork Thu May 24 20:11:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 10425445 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 69CB76019D for ; Thu, 24 May 2018 20:13:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 696CF28847 for ; Thu, 24 May 2018 20:13:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67F2528BF5; Thu, 24 May 2018 20:13:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF4432970F for ; Thu, 24 May 2018 20:13:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968965AbeEXUMg (ORCPT ); Thu, 24 May 2018 16:12:36 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40634 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968878AbeEXULR (ORCPT ); Thu, 24 May 2018 16:11:17 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4OK5wrX102602 for ; Thu, 24 May 2018 16:11:17 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j63ruh0ua-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 24 May 2018 16:11:17 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 24 May 2018 16:11:15 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 24 May 2018 16:11:13 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4OKBCHY18743620; Thu, 24 May 2018 20:11:12 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D237AAC0E6; Thu, 24 May 2018 16:12:41 -0400 (EDT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id C503EAC0E5; Thu, 24 May 2018 16:12:41 -0400 (EDT) From: Stefan Berger To: zohar@linux.vnet.ibm.com, sgrubb@redhat.com Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-audit@redhat.com, Stefan Berger Subject: [PATCH 6/8] integrity: Factor out common part of integrity_audit_msg() Date: Thu, 24 May 2018 16:11:03 -0400 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180524201105.3179904-1-stefanb@linux.vnet.ibm.com> References: <20180524201105.3179904-1-stefanb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18052420-0040-0000-0000-000004317D4B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009065; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000261; SDB=6.01036001; UDB=6.00529949; IPR=6.00815130; MB=3.00021234; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-24 20:11:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052420-0041-0000-0000-000008379AE8 Message-Id: <20180524201105.3179904-7-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-24_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805240228 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Factor out a common part of integrity_audit_msg() that others can also call. Signed-off-by: Stefan Berger --- security/integrity/integrity.h | 16 ++++++++++++++++ security/integrity/integrity_audit.c | 24 ++++++++++++++++-------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h index 5e58e02ba8dc..9f2924cafa53 100644 --- a/security/integrity/integrity.h +++ b/security/integrity/integrity.h @@ -15,6 +15,7 @@ #include #include #include +#include /* iint action cache flags */ #define IMA_MEASURE 0x00000001 @@ -197,6 +198,11 @@ static inline void evm_load_x509(void) void integrity_audit_msg(int audit_msgno, struct inode *inode, const unsigned char *fname, const char *op, const char *cause, int result, int info); + +void integrity_audit_msg_common(struct audit_buffer *ab, struct inode *inode, + const unsigned char *fname, const char *op, + const char *cause, int result); + #else static inline void integrity_audit_msg(int audit_msgno, struct inode *inode, const unsigned char *fname, @@ -204,4 +210,14 @@ static inline void integrity_audit_msg(int audit_msgno, struct inode *inode, int result, int info) { } + +static inline void integrity_audit_msg_common(struct audit_buffer *ab, + struct inode *inode, + const unsigned char *fname, + const char *op, + const char *cause, + int result) +{ +} + #endif diff --git a/security/integrity/integrity_audit.c b/security/integrity/integrity_audit.c index 8d25d3c4dcca..8f80b7c042a7 100644 --- a/security/integrity/integrity_audit.c +++ b/security/integrity/integrity_audit.c @@ -28,17 +28,12 @@ static int __init integrity_audit_setup(char *str) } __setup("integrity_audit=", integrity_audit_setup); -void integrity_audit_msg(int audit_msgno, struct inode *inode, - const unsigned char *fname, const char *op, - const char *cause, int result, int audit_info) +void integrity_audit_msg_common(struct audit_buffer *ab, struct inode *inode, + const unsigned char *fname, const char *op, + const char *cause, int result) { - struct audit_buffer *ab; char name[TASK_COMM_LEN]; - if (!integrity_audit_info && audit_info == 1) /* Skip info messages */ - return; - - ab = audit_log_start(current->audit_context, GFP_KERNEL, audit_msgno); audit_log_format(ab, "pid=%d uid=%u auid=%u ses=%u", task_pid_nr(current), from_kuid(&init_user_ns, current_cred()->uid), @@ -59,5 +54,18 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode, audit_log_d_path_exe(ab, current->mm); audit_log_tty(ab, current); audit_log_format(ab, " res=%d", !result); +} + +void integrity_audit_msg(int audit_msgno, struct inode *inode, + const unsigned char *fname, const char *op, + const char *cause, int result, int audit_info) +{ + struct audit_buffer *ab; + + if (!integrity_audit_info && audit_info == 1) /* Skip info messages */ + return; + + ab = audit_log_start(current->audit_context, GFP_KERNEL, audit_msgno); + integrity_audit_msg_common(ab, inode, fname, op, cause, result); audit_log_end(ab); }