mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: Paul Moore <paul@paul-moore.com>, linux-security-module@vger.kernel.org
Cc: jmorris@namei.org, keescook@chromium.org,
	john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp,
	stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org,
	linux-api@vger.kernel.org, mic@digikod.net,
	selinux@vger.kernel.org, Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: [PATCH v10 10/11] SELinux: Add selfattr hooks
Date: Wed, 7 Jun 2023 16:39:55 -0700	[thread overview]
Message-ID: <3319126a-c5b5-c9db-dddb-7ed169ac7e83@schaufler-ca.com> (raw)
In-Reply-To: <b09b591926e0f297fe0a3e9d8fcf3a6a.paul@paul-moore.com>

On 6/7/2023 3:32 PM, Paul Moore wrote:
> On Apr 28, 2023 Casey Schaufler <casey@schaufler-ca.com> wrote:
>> Add hooks for setselfattr and getselfattr. These hooks are not very
>> different from their setprocattr and getprocattr equivalents, and
>> much of the code is shared.
>>
>> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
>> Cc: selinux@vger.kernel.org
>> Cc: Paul Moore <paul@paul-moore.com>
>> ---
>>  security/selinux/hooks.c | 154 +++++++++++++++++++++++++++++++--------
>>  1 file changed, 124 insertions(+), 30 deletions(-)
>>
>> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
>> index 2ee92d3fb79d..e78b955e04f8 100644
>> --- a/security/selinux/hooks.c
>> +++ b/security/selinux/hooks.c
>> @@ -6542,6 +6559,81 @@ static int selinux_setprocattr(const char *name, void *value, size_t size)
>>  	return error;
>>  }
>>  
>> +static int selinux_getselfattr(unsigned int attr, struct lsm_ctx __user *ctx,
>> +			       size_t *size, u32 flags)
>> +{
>> +	char *value;
>> +	size_t total_len;
>> +	int len;
>> +	int rc;
>> +
>> +	len = selinux_lsm_getattr(attr, current, &value);
>> +	if (len < 0)
>> +		return len;
>> +
>> +	total_len = ALIGN(struct_size(ctx, ctx, len), 8);
>> +
>> +	if (total_len > *size)
>> +		rc = -E2BIG;
> Hmm.  Since we need to calculate the aligned @total_len value in the
> LSM specific code, perhaps it doesn't make sense to also do the
> alignment in lsm_fill_user_ctx().  My apologies, I know I was the one
> who suggested doing the alignment in a common place previously.

Some future user of lsm_fill_user_ctx() may not need to do the
calculation, so I would be inclined to leave it here. I'm thinking
SO_PEERCONTEXT, or the like. But I'll go with whatever gets the
patchset moving forward.

>
>> +	else if (ctx)
>> +		rc = lsm_fill_user_ctx(ctx, value, len, LSM_ID_SELINUX, 0);
>> +	else
>> +		rc = 1;
>> +
>> +	*size = total_len;
>> +	if (rc < 0)
>> +		return rc;
>> +	return 1;
>> +}
> --
> paul-moore.com

  reply	other threads:[~2023-06-07 23:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230428203417.159874-1-casey.ref@schaufler-ca.com>
2023-04-28 20:34 ` [PATCH v10 00/11] LSM: Three basic syscalls Casey Schaufler
2023-04-28 20:34   ` [PATCH v10 01/11] LSM: Identify modules by more than name Casey Schaufler
2023-04-28 20:34   ` [PATCH v10 02/11] LSM: Maintain a table of LSM attribute data Casey Schaufler
2023-04-28 20:34   ` [PATCH v10 03/11] proc: Use lsmids instead of lsm names for attrs Casey Schaufler
2023-06-13 18:35     ` Serge Hallyn
2023-04-28 20:34   ` [PATCH v10 04/11] LSM: syscalls for current process attributes Casey Schaufler
2023-06-07 22:32     ` [PATCH v10 4/11] " Paul Moore
2023-06-07 23:26       ` Casey Schaufler
2023-06-13 18:54     ` [PATCH v10 04/11] " Serge Hallyn
2023-04-28 20:34   ` [PATCH v10 05/11] LSM: Create lsm_list_modules system call Casey Schaufler
2023-06-13 19:02     ` Serge Hallyn
2023-04-28 20:34   ` [PATCH v10 06/11] LSM: wireup Linux Security Module syscalls Casey Schaufler
2023-04-28 20:34   ` [PATCH v10 07/11] LSM: Helpers for attribute names and filling lsm_ctx Casey Schaufler
2023-04-29  1:06     ` kernel test robot
2023-04-29  2:37     ` kernel test robot
2023-06-07 22:32     ` [PATCH v10 7/11] " Paul Moore
2023-06-15 13:19     ` [PATCH v10 07/11] " Serge Hallyn
2023-06-15 13:27     ` Serge Hallyn
2023-04-28 20:34   ` [PATCH v10 08/11] Smack: implement setselfattr and getselfattr hooks Casey Schaufler
2023-06-15 15:29     ` Serge Hallyn
2023-04-28 20:34   ` [PATCH v10 09/11] AppArmor: Add selfattr hooks Casey Schaufler
2023-04-28 20:34   ` [PATCH v10 10/11] SELinux: " Casey Schaufler
2023-06-07 22:32     ` Paul Moore
2023-06-07 23:39       ` Casey Schaufler [this message]
2023-04-28 20:34   ` [PATCH v10 11/11] LSM: selftests for Linux Security Module syscalls Casey Schaufler
2023-04-28 20:26 [PATCH v10 00/11] LSM: Three basic syscalls Casey Schaufler
2023-04-28 20:26 ` [PATCH v10 10/11] SELinux: Add selfattr hooks Casey Schaufler

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=3319126a-c5b5-c9db-dddb-7ed169ac7e83@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=jmorris@namei.org \
    --cc=john.johansen@canonical.com \
    --cc=keescook@chromium.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=paul@paul-moore.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=selinux@vger.kernel.org \
    --cc=stephen.smalley.work@gmail.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®