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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A98F9C433EF for ; Fri, 11 Mar 2022 10:48:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346011AbiCKKt7 (ORCPT ); Fri, 11 Mar 2022 05:49:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238713AbiCKKt4 (ORCPT ); Fri, 11 Mar 2022 05:49:56 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F412182BC0; Fri, 11 Mar 2022 02:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646995732; x=1678531732; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=3q2RXnw3ENJ9hR2e3HJcmwGSdFSeyoDplqjI07wWEkE=; b=EQY7RCxwaQog7FcOOxbg8aZEv8+Yt39ockNWxTPGLdZ5VNeREVHu/jz/ 6Mr/ZDdOKTw/a5Afxa0IgUr4CJMh0DQ5JysUz7ME9DgMGk1rJ/U2XMVsq uMTCKudBNhtuV+8jjDQqbPFCy2xMQOa8bAcfGNoY/RUtjAb4GMaqiG4/C Sz/GY7UYIyKy/8zg2pQV4DG876iFOzcxtrcSS68Jb/cQraaTlyDuu5Awg c9huEYq3U+JwfW7x3W6nhQvfIeGPGWFaOgl3WJUw7I1t6XlCie/EWH4tR /aRgq9OE8L/Q9bW3r0JuK32yS4wGKlwyr4LwYvpkwjmGVOLvZ+VEBjR+/ g==; X-IronPort-AV: E=McAfee;i="6200,9189,10282"; a="237723039" X-IronPort-AV: E=Sophos;i="5.90,173,1643702400"; d="scan'208";a="237723039" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2022 02:48:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,173,1643702400"; d="scan'208";a="579251273" Received: from lkp-server02.sh.intel.com (HELO 89b41b6ae01c) ([10.239.97.151]) by orsmga001.jf.intel.com with ESMTP; 11 Mar 2022 02:48:49 -0800 Received: from kbuild by 89b41b6ae01c with local (Exim 4.92) (envelope-from ) id 1nScpE-0006Gx-A9; Fri, 11 Mar 2022 10:48:48 +0000 Date: Fri, 11 Mar 2022 18:48:36 +0800 From: kernel test robot To: Casey Schaufler , casey.schaufler@intel.com, jmorris@namei.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Cc: kbuild-all@lists.01.org, casey@schaufler-ca.com, linux-audit@redhat.com, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, paul@paul-moore.com, stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v33 01/29] integrity: disassociate ima_filter_rule from security_audit_rule Message-ID: <202203111810.oPf2VNfH-lkp@intel.com> References: <20220310234632.16194-2-casey@schaufler-ca.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220310234632.16194-2-casey@schaufler-ca.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Casey, I love your patch! Yet something to improve: [auto build test ERROR on pcmoore-audit/next] [also build test ERROR on pcmoore-selinux/next linus/master jmorris-security/next-testing v5.17-rc7 next-20220310] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Casey-Schaufler/integrity-disassociate-ima_filter_rule-from-security_audit_rule/20220311-084644 base: https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit.git next config: arc-buildonly-randconfig-r006-20220310 (https://download.01.org/0day-ci/archive/20220311/202203111810.oPf2VNfH-lkp@intel.com/config) compiler: arc-elf-gcc (GCC) 11.2.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/2796a69611ebb559eacf03666a3ae2fbd48e0c12 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Casey-Schaufler/integrity-disassociate-ima_filter_rule-from-security_audit_rule/20220311-084644 git checkout 2796a69611ebb559eacf03666a3ae2fbd48e0c12 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): security/integrity/ima/ima_policy.c: In function 'ima_lsm_free_rule': >> security/integrity/ima/ima_policy.c:360:17: error: implicit declaration of function 'ima_filter_rule_free'; did you mean 'ima_file_free'? [-Werror=implicit-function-declaration] 360 | ima_filter_rule_free(entry->lsm[i].rule); | ^~~~~~~~~~~~~~~~~~~~ | ima_file_free security/integrity/ima/ima_policy.c: In function 'ima_lsm_copy_rule': >> security/integrity/ima/ima_policy.c:409:17: error: implicit declaration of function 'ima_filter_rule_init' [-Werror=implicit-function-declaration] 409 | ima_filter_rule_init(nentry->lsm[i].type, Audit_equal, | ^~~~~~~~~~~~~~~~~~~~ security/integrity/ima/ima_policy.c: In function 'ima_match_rules': >> security/integrity/ima/ima_policy.c:625:30: error: implicit declaration of function 'ima_filter_rule_match' [-Werror=implicit-function-declaration] 625 | rc = ima_filter_rule_match(osid, rule->lsm[i].type, | ^~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors vim +360 security/integrity/ima/ima_policy.c 176377d97d6a3f Tyler Hicks 2020-08-11 354 b169424551930a Janne Karhunen 2019-06-14 355 static void ima_lsm_free_rule(struct ima_rule_entry *entry) b169424551930a Janne Karhunen 2019-06-14 356 { b169424551930a Janne Karhunen 2019-06-14 357 int i; b169424551930a Janne Karhunen 2019-06-14 358 b169424551930a Janne Karhunen 2019-06-14 359 for (i = 0; i < MAX_LSM_RULES; i++) { b8867eedcf76ca Tyler Hicks 2020-07-10 @360 ima_filter_rule_free(entry->lsm[i].rule); b169424551930a Janne Karhunen 2019-06-14 361 kfree(entry->lsm[i].args_p); b169424551930a Janne Karhunen 2019-06-14 362 } 465aee77aae857 Tyler Hicks 2020-07-09 363 } 465aee77aae857 Tyler Hicks 2020-07-09 364 465aee77aae857 Tyler Hicks 2020-07-09 365 static void ima_free_rule(struct ima_rule_entry *entry) 465aee77aae857 Tyler Hicks 2020-07-09 366 { 465aee77aae857 Tyler Hicks 2020-07-09 367 if (!entry) 465aee77aae857 Tyler Hicks 2020-07-09 368 return; 465aee77aae857 Tyler Hicks 2020-07-09 369 465aee77aae857 Tyler Hicks 2020-07-09 370 /* 465aee77aae857 Tyler Hicks 2020-07-09 371 * entry->template->fields may be allocated in ima_parse_rule() but that 465aee77aae857 Tyler Hicks 2020-07-09 372 * reference is owned by the corresponding ima_template_desc element in 465aee77aae857 Tyler Hicks 2020-07-09 373 * the defined_templates list and cannot be freed here 465aee77aae857 Tyler Hicks 2020-07-09 374 */ 465aee77aae857 Tyler Hicks 2020-07-09 375 kfree(entry->fsname); 176377d97d6a3f Tyler Hicks 2020-08-11 376 ima_free_rule_opt_list(entry->keyrings); 465aee77aae857 Tyler Hicks 2020-07-09 377 ima_lsm_free_rule(entry); b169424551930a Janne Karhunen 2019-06-14 378 kfree(entry); b169424551930a Janne Karhunen 2019-06-14 379 } b169424551930a Janne Karhunen 2019-06-14 380 b169424551930a Janne Karhunen 2019-06-14 381 static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry) b169424551930a Janne Karhunen 2019-06-14 382 { b169424551930a Janne Karhunen 2019-06-14 383 struct ima_rule_entry *nentry; 483ec26eed42bf Janne Karhunen 2020-01-15 384 int i; b169424551930a Janne Karhunen 2019-06-14 385 b169424551930a Janne Karhunen 2019-06-14 386 /* b169424551930a Janne Karhunen 2019-06-14 387 * Immutable elements are copied over as pointers and data; only b169424551930a Janne Karhunen 2019-06-14 388 * lsm rules can change b169424551930a Janne Karhunen 2019-06-14 389 */ f60c826d031817 Alex Dewar 2020-09-09 390 nentry = kmemdup(entry, sizeof(*nentry), GFP_KERNEL); f60c826d031817 Alex Dewar 2020-09-09 391 if (!nentry) f60c826d031817 Alex Dewar 2020-09-09 392 return NULL; f60c826d031817 Alex Dewar 2020-09-09 393 c593642c8be046 Pankaj Bharadiya 2019-12-09 394 memset(nentry->lsm, 0, sizeof_field(struct ima_rule_entry, lsm)); b169424551930a Janne Karhunen 2019-06-14 395 b169424551930a Janne Karhunen 2019-06-14 396 for (i = 0; i < MAX_LSM_RULES; i++) { 483ec26eed42bf Janne Karhunen 2020-01-15 397 if (!entry->lsm[i].args_p) b169424551930a Janne Karhunen 2019-06-14 398 continue; b169424551930a Janne Karhunen 2019-06-14 399 b169424551930a Janne Karhunen 2019-06-14 400 nentry->lsm[i].type = entry->lsm[i].type; 39e5993d0d452b Tyler Hicks 2020-07-09 401 nentry->lsm[i].args_p = entry->lsm[i].args_p; 39e5993d0d452b Tyler Hicks 2020-07-09 402 /* 39e5993d0d452b Tyler Hicks 2020-07-09 403 * Remove the reference from entry so that the associated 39e5993d0d452b Tyler Hicks 2020-07-09 404 * memory will not be freed during a later call to 39e5993d0d452b Tyler Hicks 2020-07-09 405 * ima_lsm_free_rule(entry). 39e5993d0d452b Tyler Hicks 2020-07-09 406 */ 39e5993d0d452b Tyler Hicks 2020-07-09 407 entry->lsm[i].args_p = NULL; b169424551930a Janne Karhunen 2019-06-14 408 b8867eedcf76ca Tyler Hicks 2020-07-10 @409 ima_filter_rule_init(nentry->lsm[i].type, Audit_equal, b169424551930a Janne Karhunen 2019-06-14 410 nentry->lsm[i].args_p, b169424551930a Janne Karhunen 2019-06-14 411 &nentry->lsm[i].rule); 483ec26eed42bf Janne Karhunen 2020-01-15 412 if (!nentry->lsm[i].rule) 483ec26eed42bf Janne Karhunen 2020-01-15 413 pr_warn("rule for LSM \'%s\' is undefined\n", aa0c0227d33171 Tyler Hicks 2020-07-09 414 nentry->lsm[i].args_p); b169424551930a Janne Karhunen 2019-06-14 415 } b169424551930a Janne Karhunen 2019-06-14 416 return nentry; b169424551930a Janne Karhunen 2019-06-14 417 } b169424551930a Janne Karhunen 2019-06-14 418 --- 0-DAY CI Kernel Test Service https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DCBDC433EF for ; Fri, 11 Mar 2022 13:16:30 +0000 (UTC) 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-77-mtLtwp7UOBK7LmYi3VPS6w-1; Fri, 11 Mar 2022 08:16:28 -0500 X-MC-Unique: mtLtwp7UOBK7LmYi3VPS6w-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 DEC26802319; Fri, 11 Mar 2022 13:16:26 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0029A76EE; Fri, 11 Mar 2022 13:16:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BB7D91940341; Fri, 11 Mar 2022 13:16:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0604D1949762 for ; Fri, 11 Mar 2022 10:48:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E48D740C1244; Fri, 11 Mar 2022 10:48:55 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E08E440C1242 for ; Fri, 11 Mar 2022 10:48:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 C80BB1C05AA6 for ; Fri, 11 Mar 2022 10:48:55 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-488-G4E3x3OFPoC_m5pTI00RYQ-1; Fri, 11 Mar 2022 05:48:53 -0500 X-MC-Unique: G4E3x3OFPoC_m5pTI00RYQ-1 X-IronPort-AV: E=McAfee;i="6200,9189,10282"; a="237723040" X-IronPort-AV: E=Sophos;i="5.90,173,1643702400"; d="scan'208";a="237723040" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2022 02:48:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,173,1643702400"; d="scan'208";a="579251273" Received: from lkp-server02.sh.intel.com (HELO 89b41b6ae01c) ([10.239.97.151]) by orsmga001.jf.intel.com with ESMTP; 11 Mar 2022 02:48:49 -0800 Received: from kbuild by 89b41b6ae01c with local (Exim 4.92) (envelope-from ) id 1nScpE-0006Gx-A9; Fri, 11 Mar 2022 10:48:48 +0000 Date: Fri, 11 Mar 2022 18:48:36 +0800 From: kernel test robot To: Casey Schaufler , casey.schaufler@intel.com, jmorris@namei.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Subject: Re: [PATCH v33 01/29] integrity: disassociate ima_filter_rule from security_audit_rule Message-ID: <202203111810.oPf2VNfH-lkp@intel.com> References: <20220310234632.16194-2-casey@schaufler-ca.com> MIME-Version: 1.0 In-Reply-To: <20220310234632.16194-2-casey@schaufler-ca.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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.84 on 10.11.54.2 X-Mailman-Approved-At: Fri, 11 Mar 2022 13:16:25 +0000 X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: john.johansen@canonical.com, kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, linux-audit@redhat.com Errors-To: linux-audit-bounces@redhat.com Sender: "Linux-audit" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Casey, I love your patch! Yet something to improve: [auto build test ERROR on pcmoore-audit/next] [also build test ERROR on pcmoore-selinux/next linus/master jmorris-security/next-testing v5.17-rc7 next-20220310] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Casey-Schaufler/integrity-disassociate-ima_filter_rule-from-security_audit_rule/20220311-084644 base: https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit.git next config: arc-buildonly-randconfig-r006-20220310 (https://download.01.org/0day-ci/archive/20220311/202203111810.oPf2VNfH-lkp@intel.com/config) compiler: arc-elf-gcc (GCC) 11.2.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/2796a69611ebb559eacf03666a3ae2fbd48e0c12 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Casey-Schaufler/integrity-disassociate-ima_filter_rule-from-security_audit_rule/20220311-084644 git checkout 2796a69611ebb559eacf03666a3ae2fbd48e0c12 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): security/integrity/ima/ima_policy.c: In function 'ima_lsm_free_rule': >> security/integrity/ima/ima_policy.c:360:17: error: implicit declaration of function 'ima_filter_rule_free'; did you mean 'ima_file_free'? [-Werror=implicit-function-declaration] 360 | ima_filter_rule_free(entry->lsm[i].rule); | ^~~~~~~~~~~~~~~~~~~~ | ima_file_free security/integrity/ima/ima_policy.c: In function 'ima_lsm_copy_rule': >> security/integrity/ima/ima_policy.c:409:17: error: implicit declaration of function 'ima_filter_rule_init' [-Werror=implicit-function-declaration] 409 | ima_filter_rule_init(nentry->lsm[i].type, Audit_equal, | ^~~~~~~~~~~~~~~~~~~~ security/integrity/ima/ima_policy.c: In function 'ima_match_rules': >> security/integrity/ima/ima_policy.c:625:30: error: implicit declaration of function 'ima_filter_rule_match' [-Werror=implicit-function-declaration] 625 | rc = ima_filter_rule_match(osid, rule->lsm[i].type, | ^~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors vim +360 security/integrity/ima/ima_policy.c 176377d97d6a3f Tyler Hicks 2020-08-11 354 b169424551930a Janne Karhunen 2019-06-14 355 static void ima_lsm_free_rule(struct ima_rule_entry *entry) b169424551930a Janne Karhunen 2019-06-14 356 { b169424551930a Janne Karhunen 2019-06-14 357 int i; b169424551930a Janne Karhunen 2019-06-14 358 b169424551930a Janne Karhunen 2019-06-14 359 for (i = 0; i < MAX_LSM_RULES; i++) { b8867eedcf76ca Tyler Hicks 2020-07-10 @360 ima_filter_rule_free(entry->lsm[i].rule); b169424551930a Janne Karhunen 2019-06-14 361 kfree(entry->lsm[i].args_p); b169424551930a Janne Karhunen 2019-06-14 362 } 465aee77aae857 Tyler Hicks 2020-07-09 363 } 465aee77aae857 Tyler Hicks 2020-07-09 364 465aee77aae857 Tyler Hicks 2020-07-09 365 static void ima_free_rule(struct ima_rule_entry *entry) 465aee77aae857 Tyler Hicks 2020-07-09 366 { 465aee77aae857 Tyler Hicks 2020-07-09 367 if (!entry) 465aee77aae857 Tyler Hicks 2020-07-09 368 return; 465aee77aae857 Tyler Hicks 2020-07-09 369 465aee77aae857 Tyler Hicks 2020-07-09 370 /* 465aee77aae857 Tyler Hicks 2020-07-09 371 * entry->template->fields may be allocated in ima_parse_rule() but that 465aee77aae857 Tyler Hicks 2020-07-09 372 * reference is owned by the corresponding ima_template_desc element in 465aee77aae857 Tyler Hicks 2020-07-09 373 * the defined_templates list and cannot be freed here 465aee77aae857 Tyler Hicks 2020-07-09 374 */ 465aee77aae857 Tyler Hicks 2020-07-09 375 kfree(entry->fsname); 176377d97d6a3f Tyler Hicks 2020-08-11 376 ima_free_rule_opt_list(entry->keyrings); 465aee77aae857 Tyler Hicks 2020-07-09 377 ima_lsm_free_rule(entry); b169424551930a Janne Karhunen 2019-06-14 378 kfree(entry); b169424551930a Janne Karhunen 2019-06-14 379 } b169424551930a Janne Karhunen 2019-06-14 380 b169424551930a Janne Karhunen 2019-06-14 381 static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry) b169424551930a Janne Karhunen 2019-06-14 382 { b169424551930a Janne Karhunen 2019-06-14 383 struct ima_rule_entry *nentry; 483ec26eed42bf Janne Karhunen 2020-01-15 384 int i; b169424551930a Janne Karhunen 2019-06-14 385 b169424551930a Janne Karhunen 2019-06-14 386 /* b169424551930a Janne Karhunen 2019-06-14 387 * Immutable elements are copied over as pointers and data; only b169424551930a Janne Karhunen 2019-06-14 388 * lsm rules can change b169424551930a Janne Karhunen 2019-06-14 389 */ f60c826d031817 Alex Dewar 2020-09-09 390 nentry = kmemdup(entry, sizeof(*nentry), GFP_KERNEL); f60c826d031817 Alex Dewar 2020-09-09 391 if (!nentry) f60c826d031817 Alex Dewar 2020-09-09 392 return NULL; f60c826d031817 Alex Dewar 2020-09-09 393 c593642c8be046 Pankaj Bharadiya 2019-12-09 394 memset(nentry->lsm, 0, sizeof_field(struct ima_rule_entry, lsm)); b169424551930a Janne Karhunen 2019-06-14 395 b169424551930a Janne Karhunen 2019-06-14 396 for (i = 0; i < MAX_LSM_RULES; i++) { 483ec26eed42bf Janne Karhunen 2020-01-15 397 if (!entry->lsm[i].args_p) b169424551930a Janne Karhunen 2019-06-14 398 continue; b169424551930a Janne Karhunen 2019-06-14 399 b169424551930a Janne Karhunen 2019-06-14 400 nentry->lsm[i].type = entry->lsm[i].type; 39e5993d0d452b Tyler Hicks 2020-07-09 401 nentry->lsm[i].args_p = entry->lsm[i].args_p; 39e5993d0d452b Tyler Hicks 2020-07-09 402 /* 39e5993d0d452b Tyler Hicks 2020-07-09 403 * Remove the reference from entry so that the associated 39e5993d0d452b Tyler Hicks 2020-07-09 404 * memory will not be freed during a later call to 39e5993d0d452b Tyler Hicks 2020-07-09 405 * ima_lsm_free_rule(entry). 39e5993d0d452b Tyler Hicks 2020-07-09 406 */ 39e5993d0d452b Tyler Hicks 2020-07-09 407 entry->lsm[i].args_p = NULL; b169424551930a Janne Karhunen 2019-06-14 408 b8867eedcf76ca Tyler Hicks 2020-07-10 @409 ima_filter_rule_init(nentry->lsm[i].type, Audit_equal, b169424551930a Janne Karhunen 2019-06-14 410 nentry->lsm[i].args_p, b169424551930a Janne Karhunen 2019-06-14 411 &nentry->lsm[i].rule); 483ec26eed42bf Janne Karhunen 2020-01-15 412 if (!nentry->lsm[i].rule) 483ec26eed42bf Janne Karhunen 2020-01-15 413 pr_warn("rule for LSM \'%s\' is undefined\n", aa0c0227d33171 Tyler Hicks 2020-07-09 414 nentry->lsm[i].args_p); b169424551930a Janne Karhunen 2019-06-14 415 } b169424551930a Janne Karhunen 2019-06-14 416 return nentry; b169424551930a Janne Karhunen 2019-06-14 417 } b169424551930a Janne Karhunen 2019-06-14 418 --- 0-DAY CI Kernel Test Service https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit