From nobody Thu Nov 28 10:49:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1670455498; cv=none; d=zohomail.com; s=zohoarc; b=nfdGDQrmt+Jy/ZO905uRK2hN3jfb5VmUePc2wEkPsrI6aIbQQ2repRo28tPK0MKGYxRjflfWDiAD/WBdqDwVUBsHk13+fkmIa06bCHSVWczAg6UTVJ7URfKyLVAC9rYhMjHatFskvawGoS+G9XIkQcYCl5CYegv9MMqR84iI4vo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670455498; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=VROVe/5mX/RFa90/m2UQfEGVCosXVPH0jzcKQBG08h4=; b=hx6QS7HAgwkyjQbuxT33b9tcIVfpkeoB1ykH/gXaI4OdoMqAYn2nSPwed++rWmgZJLaiZde9jX2RJCsqH7koIfylVm0nanGivxHWJMrWKhx2/nwYVelSYzkj52SHAl7lTcDSjb2ROx9MOu6On5s9gNMWdlFqn3aa6WQipKsAnpA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1670455498790704.3682516119768; Wed, 7 Dec 2022 15:24:58 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.456716.714507 (Exim 4.92) (envelope-from ) id 1p33mC-0004Kc-22; Wed, 07 Dec 2022 23:24:32 +0000 Received: by outflank-mailman (output) from mailman id 456716.714507; Wed, 07 Dec 2022 23:24:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p33mB-0004KV-Vh; Wed, 07 Dec 2022 23:24:31 +0000 Received: by outflank-mailman (input) for mailman id 456716; Wed, 07 Dec 2022 23:24:30 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p33mA-0004KP-La for xen-devel@lists.xenproject.org; Wed, 07 Dec 2022 23:24:30 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4b2a8b5d-7686-11ed-8fd2-01056ac49cbb; Thu, 08 Dec 2022 00:24:28 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5700761CE0; Wed, 7 Dec 2022 23:24:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05975C433D6; Wed, 7 Dec 2022 23:24:25 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4b2a8b5d-7686-11ed-8fd2-01056ac49cbb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670455466; bh=WAqWB3t5CnIwaEbiZi19UdDQY/tdq/ds7+fkA0hfB9M=; h=Date:From:To:cc:Subject:From; b=olqwGsYJgdpy5HjTu8W8cL2qlr8tYSho7a8aU1EXQrMxa2sJ2+/D94hiTg618Eyw+ p0HtGXh5KC+ZQ4VpKD7GDGMrP2Z2AR7F9F9JlA2MltqsU6iAqfPfE8jw2rboe3bQ3g k+eWrK/r+l49c3T21SR6eXUgivuIuclt5Nu1jU6ud7p9HbKzxZhWVm3OV47lVprMCD s/tH6RkXJy1F3xQD5YEUsYJaBu/nznBFNXfhO0iadfinH3G99BFHqUsZbJWKahmK0a 56K/wNUm2aKEpY6bQrZt7YbdALVTP34+E0fnW/muhY+bC50T+4H6r/evEwHyG2czrO FvOiN90bv8FHw== Date: Wed, 7 Dec 2022 15:24:24 -0800 (PST) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: xen-devel@lists.xenproject.org cc: sstabellini@kernel.org, dpsmith@apertussolutions.com, jbeulich@suse.com, michal.orzel@amd.com Subject: [PATCH v2] xsm/flask: misra rule 8.4 fix Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1670455499955100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fix several MISRA Issues Rule 8.4 ("A compatible declaration shall be visible when an object or function with external linkage is defined") found by cppcheck affecting xen/xsm/flask. - policydb_loaded_version is not declared; removed it because it is unused - move ss_initialized declaration to xen/xsm/flask/include/conditional.h - #include (which is xen/xsm/flask/include/conditional.h) in xen/xsm/flask/ss/policydb.c so that policydb.c also gets the declaration of ss_initialized - #include in xen/xsm/flask/ss/services.c to declare security_*_bools functions that services.c is defining and using This patch solves all the Rule 8.4 violations found by cppcheck on xsm/ Signed-off-by: Stefano Stabellini diff --git a/xen/xsm/flask/flask_op.c b/xen/xsm/flask/flask_op.c index d319466c6b..b866e8d05f 100644 Reviewed-by: Jan Beulich --- a/xen/xsm/flask/flask_op.c +++ b/xen/xsm/flask/flask_op.c @@ -56,8 +56,6 @@ static int bool_num =3D 0; static int *bool_pending_values =3D NULL; static int flask_security_make_bools(void); =20 -extern int ss_initialized; - static int __init cf_check parse_flask_param(const char *s) { if ( !strcmp(s, "enforcing") ) diff --git a/xen/xsm/flask/include/conditional.h b/xen/xsm/flask/include/co= nditional.h index 90553405b0..879d40e147 100644 --- a/xen/xsm/flask/include/conditional.h +++ b/xen/xsm/flask/include/conditional.h @@ -24,4 +24,6 @@ int security_find_bool(const char *name); char *security_get_bool_name(unsigned int b); int security_get_bool_value(unsigned int b); =20 +extern int ss_initialized; + #endif diff --git a/xen/xsm/flask/ss/policydb.c b/xen/xsm/flask/ss/policydb.c index 162470bbbd..7f232f92fa 100644 --- a/xen/xsm/flask/ss/policydb.c +++ b/xen/xsm/flask/ss/policydb.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "security.h" =20 #include "policydb.h" @@ -1730,8 +1731,6 @@ static int policydb_bounds_sanity_check(struct policy= db *p) return 0; } =20 -extern int ss_initialized; - /* * Read the configuration data from a policy database binary * representation file into a policy database structure. diff --git a/xen/xsm/flask/ss/services.c b/xen/xsm/flask/ss/services.c index dab07b5f60..35ad1034ca 100644 --- a/xen/xsm/flask/ss/services.c +++ b/xen/xsm/flask/ss/services.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "flask.h" #include "avc.h" #include "avc_ss.h" @@ -53,8 +54,6 @@ #include "conditional.h" #include "mls.h" =20 -unsigned int policydb_loaded_version; - static DEFINE_RWLOCK(policy_rwlock); #define POLICY_RDLOCK read_lock(&policy_rwlock) #define POLICY_WRLOCK write_lock(&policy_rwlock) @@ -1388,7 +1387,6 @@ int security_load_policy(const void *data, size_t len) policydb_destroy(&policydb); return -EINVAL; } - policydb_loaded_version =3D policydb.policyvers; ss_initialized =3D 1; seqno =3D ++latest_granting; LOAD_UNLOCK; @@ -1447,7 +1445,6 @@ int security_load_policy(const void *data, size_t len) memcpy(&policydb, &newpolicydb, sizeof policydb); sidtab_set(&sidtab, &newsidtab); seqno =3D ++latest_granting; - policydb_loaded_version =3D policydb.policyvers; POLICY_WRUNLOCK; LOAD_UNLOCK;