[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9b031aaa-08f8-3b99-64f8-a4ecadb3f7e8@schaufler-ca.com>
Date: Wed, 11 Jan 2023 16:37:54 -0800
From: Casey Schaufler <casey@...aufler-ca.com>
To: Paul Moore <paul@...l-moore.com>
Cc: casey.schaufler@...el.com, linux-security-module@...r.kernel.org,
jmorris@...ei.org, keescook@...omium.org,
john.johansen@...onical.com, penguin-kernel@...ove.sakura.ne.jp,
stephen.smalley.work@...il.com, linux-kernel@...r.kernel.org,
linux-api@...r.kernel.org, mic@...ikod.net,
linux-fsdevel@...r.kernel.org, casey@...aufler-ca.com
Subject: Re: [PATCH v5 3/8] proc: Use lsmids instead of lsm names for attrs
On 1/11/2023 1:01 PM, Paul Moore wrote:
> On Mon, Jan 9, 2023 at 1:09 PM Casey Schaufler <casey@...aufler-ca.com> wrote:
>> Use the LSM ID number instead of the LSM name to identify which
>> security module's attibute data should be shown in /proc/self/attr.
>> The security_[gs]etprocattr() functions have been changed to expect
>> the LSM ID. The change from a string comparison to an integer comparison
>> in these functions will provide a minor performance improvement.
>>
>> Signed-off-by: Casey Schaufler <casey@...aufler-ca.com>
>> Cc: linux-fsdevel@...r.kernel.org
>> ---
>> fs/proc/base.c | 29 +++++++++++++++--------------
>> fs/proc/internal.h | 2 +-
>> include/linux/security.h | 11 +++++------
>> security/security.c | 11 +++++------
>> 4 files changed, 26 insertions(+), 27 deletions(-)
> ..
>
>> diff --git a/fs/proc/base.c b/fs/proc/base.c
>> index 9e479d7d202b..9328b6b07dfc 100644
>> --- a/fs/proc/base.c
>> +++ b/fs/proc/base.c
>> @@ -2837,27 +2838,27 @@ static const struct inode_operations proc_##LSM##_attr_dir_inode_ops = { \
>>
>> #ifdef CONFIG_SECURITY_SMACK
>> static const struct pid_entry smack_attr_dir_stuff[] = {
>> - ATTR("smack", "current", 0666),
>> + ATTR(LSM_ID_SMACK, "current", 0666),
>> };
>> LSM_DIR_OPS(smack);
>> #endif
>>
>> #ifdef CONFIG_SECURITY_APPARMOR
>> static const struct pid_entry apparmor_attr_dir_stuff[] = {
>> - ATTR("apparmor", "current", 0666),
>> - ATTR("apparmor", "prev", 0444),
>> - ATTR("apparmor", "exec", 0666),
>> + ATTR(LSM_ID_APPARMOR, "current", 0666),
>> + ATTR(LSM_ID_APPARMOR, "prev", 0444),
>> + ATTR(LSM_ID_APPARMOR, "exec", 0666),
>> };
>> LSM_DIR_OPS(apparmor);
>> #endif
>>
>> static const struct pid_entry attr_dir_stuff[] = {
>> - ATTR(NULL, "current", 0666),
>> - ATTR(NULL, "prev", 0444),
>> - ATTR(NULL, "exec", 0666),
>> - ATTR(NULL, "fscreate", 0666),
>> - ATTR(NULL, "keycreate", 0666),
>> - ATTR(NULL, "sockcreate", 0666),
>> + ATTR(0, "current", 0666),
>> + ATTR(0, "prev", 0444),
>> + ATTR(0, "exec", 0666),
>> + ATTR(0, "fscreate", 0666),
>> + ATTR(0, "keycreate", 0666),
>> + ATTR(0, "sockcreate", 0666),
> See the discussion in patch 1/8, we should use a macro instead of a 0
> here (although the exact macro definition is very much up for
> discussion):
>
> ATTR(LSM_ID_UNDEF, "current", 0666),
Or LSM_ID_NALSMID, or whatever. Agreed.
>
> --
> paul-moore.com
Powered by blists - more mailing lists