From: Casey Schaufler <casey@schaufler-ca.com>
To: Austin Kim <austindh.kim@gmail.com>, jmorris@namei.org, serge@hallyn.com
Cc: linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-team@lge.com,
Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: [PATCH] smack: clean up smack_enabled to be more readable
Date: Wed, 3 Nov 2021 09:01:00 -0700 [thread overview]
Message-ID: <79835dce-7e15-38e2-5341-2fb246a445e7@schaufler-ca.com> (raw)
In-Reply-To: <20211103073131.GA15173@raspberrypi>
On 11/3/2021 12:31 AM, Austin Kim wrote:
> The smack_enabled is only set to 0, 1. So changing type of smack_enabled
> as bool may make relevant routine be more readable.
>
> Signed-off-by: Austin Kim <austindh.kim@gmail.com>
A couple of changes below.
> ---
> security/smack/smack.h | 2 +-
> security/smack/smack_lsm.c | 4 ++--
> security/smack/smack_netfilter.c | 2 +-
> security/smack/smackfs.c | 2 +-
> 4 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/security/smack/smack.h b/security/smack/smack.h
> index 99c3422596ab..dc1726f5953f 100644
> --- a/security/smack/smack.h
> +++ b/security/smack/smack.h
> @@ -302,7 +302,7 @@ int smack_populate_secattr(struct smack_known *skp);
> /*
> * Shared data.
> */
> -extern int smack_enabled __initdata;
> +extern bool smack_enabled __initdata;
> extern int smack_cipso_direct;
> extern int smack_cipso_mapped;
> extern struct smack_known *smack_net_ambient;
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index efd35b07c7f8..ba3b46bd2ceb 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -56,7 +56,7 @@ static DEFINE_MUTEX(smack_ipv6_lock);
> static LIST_HEAD(smk_ipv6_port_list);
> #endif
> struct kmem_cache *smack_rule_cache;
> -int smack_enabled __initdata;
> +bool smack_enabled __initdata;
>
> #define A(s) {"smack"#s, sizeof("smack"#s) - 1, Opt_##s}
> static struct {
> @@ -4953,7 +4953,7 @@ static __init int smack_init(void)
> * Register with LSM
> */
> security_add_hooks(smack_hooks, ARRAY_SIZE(smack_hooks), "smack");
> - smack_enabled = 1;
> + smack_enabled = true;
>
> pr_info("Smack: Initializing.\n");
> #ifdef CONFIG_SECURITY_SMACK_NETFILTER
> diff --git a/security/smack/smack_netfilter.c b/security/smack/smack_netfilter.c
> index b945c1d3a743..82092d9387a3 100644
> --- a/security/smack/smack_netfilter.c
> +++ b/security/smack/smack_netfilter.c
> @@ -70,7 +70,7 @@ static struct pernet_operations smack_net_ops = {
>
> static int __init smack_nf_ip_init(void)
> {
> - if (smack_enabled == 0)
> + if (smack_enabled == false)
If you want to use a bool you should use it fully.
+ if (!smack_enabled)
> return 0;
>
> printk(KERN_DEBUG "Smack: Registering netfilter hooks\n");
> diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
> index 658eab05599e..7649ad8cc335 100644
> --- a/security/smack/smackfs.c
> +++ b/security/smack/smackfs.c
> @@ -2993,7 +2993,7 @@ static int __init init_smk_fs(void)
> int err;
> int rc;
>
> - if (smack_enabled == 0)
> + if (smack_enabled == false)
Same here.
> return 0;
>
> err = smk_init_sysfs();
next prev parent reply other threads:[~2021-11-03 16:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-03 7:31 Austin Kim
2021-11-03 16:01 ` Casey Schaufler [this message]
2021-11-03 22:24 ` Austin Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=79835dce-7e15-38e2-5341-2fb246a445e7@schaufler-ca.com \
--to=casey@schaufler-ca.com \
--cc=austindh.kim@gmail.com \
--cc=jmorris@namei.org \
--cc=kernel-team@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=serge@hallyn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®