Linux-Security-Module Archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: "Dmitry V. Levin" <ldv@strace.io>
Cc: "Casey Schaufler" <casey@schaufler-ca.com>,
	"LSM List" <linux-security-module@vger.kernel.org>,
	"Linux kernel mailing list" <linux-kernel@vger.kernel.org>,
	linux-api@vger.kernel.org, "Mickaël Salaün" <mic@digikod.net>,
	"James Morris" <jmorris@namei.org>,
	"Serge Hallyn" <serge@hallyn.com>,
	"John Johansen" <john.johansen@canonical.com>,
	"Tetsuo Handa" <penguin-kernel@i-love.sakura.ne.jp>,
	"Stephen Smalley" <stephen.smalley.work@gmail.com>
Subject: Re: [PATCH v3] LSM: use 32 bit compatible data types in LSM syscalls.
Date: Thu, 14 Mar 2024 14:18:27 -0400	[thread overview]
Message-ID: <CAHC9VhTyg1aX-GEuZb2n3BjctH3_fCpz7W4i0WoLoMzbSnPCZA@mail.gmail.com> (raw)
In-Reply-To: <20240314180143.GA26431@altlinux.org>

On Thu, Mar 14, 2024 at 2:01 PM Dmitry V. Levin <ldv@strace.io> wrote:
> On Thu, Mar 14, 2024 at 11:30:53AM -0400, Paul Moore wrote:
> > On Wed, Mar 13, 2024 at 4:07 PM Paul Moore <paul@paul-moore.com> wrote:
> > > On Mar 13, 2024 Casey Schaufler <casey@schaufler-ca.com> wrote:
> > > >
> > > > LSM: use 32 bit compatible data types in LSM syscalls.
> > > >
> > > > Change the size parameters in lsm_list_modules(), lsm_set_self_attr()
> > > > and lsm_get_self_attr() from size_t to u32. This avoids the need to
> > > > have different interfaces for 32 and 64 bit systems.
> > > >
> > > > Cc: stable@vger.kernel.org
> > > > Fixes: a04a1198088a: ("LSM: syscalls for current process attributes")
> > > > Fixes: ad4aff9ec25f: ("LSM: Create lsm_list_modules system call")
> > > > Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
> > > > Reported-and-reviewed-by: Dmitry V. Levin <ldv@strace.io>
> > > > ---
> > > >  include/linux/lsm_hook_defs.h                        |  4 ++--
> > > >  include/linux/security.h                             |  8 ++++----
> > > >  security/apparmor/lsm.c                              |  4 ++--
> > > >  security/lsm_syscalls.c                              | 10 +++++-----
> > > >  security/security.c                                  | 12 ++++++------
> > > >  security/selinux/hooks.c                             |  4 ++--
> > > >  security/smack/smack_lsm.c                           |  4 ++--
> > > >  tools/testing/selftests/lsm/common.h                 |  6 +++---
> > > >  tools/testing/selftests/lsm/lsm_get_self_attr_test.c | 10 +++++-----
> > > >  tools/testing/selftests/lsm/lsm_list_modules_test.c  |  8 ++++----
> > > >  tools/testing/selftests/lsm/lsm_set_self_attr_test.c |  6 +++---
> > > >  11 files changed, 38 insertions(+), 38 deletions(-)
> > >
> > > Okay, this looks better, I'm going to merge this into lsm/stable-6.9
> > > and put it through the usual automated testing as well as a kselftest
> > > run to make sure everything there is still okay.  Assuming all goes
> > > well and no one raises any objections, I'll likely send this up to
> > > Linus tomorrow.
> >
> > I had to squash the code snippet below into the patch to address a
> > build problem identified by the kernel build robot.  I'm going to keep
> > Casey's sign-off and Dmitry's reported-reviewed tag as I feel this
> > change is minor, but if anyone has any objections please let me know
> > soon.
> >
> > [NOTE: cut-n-paste'd into email, likely whitespace damage, but you get the idea]
> >
> > diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
> > index 77eb9b0e7685..e619ac10cd23 100644
> > --- a/include/linux/syscalls.h
> > +++ b/include/linux/syscalls.h
> > @@ -960,10 +960,10 @@ asmlinkage long sys_cachestat(unsigned int fd,
> >                struct cachestat __user *cstat, unsigned int flags);
> > asmlinkage long sys_map_shadow_stack(unsigned long addr, unsigned long size, un
> > signed int flags);
> > asmlinkage long sys_lsm_get_self_attr(unsigned int attr, struct lsm_ctx *ctx,
> > -                                     size_t *size, __u32 flags);
> > +                                     u32 *size, u32 flags);
> > asmlinkage long sys_lsm_set_self_attr(unsigned int attr, struct lsm_ctx *ctx,
> > -                                     size_t size, __u32 flags);
> > -asmlinkage long sys_lsm_list_modules(u64 *ids, size_t *size, u32 flags);
> > +                                     u32 size, u32 flags);
> > +asmlinkage long sys_lsm_list_modules(u64 *ids, u32 *size, u32 flags);
>
> Fine with me, thanks.
>
> btw, with the change above, u32 will become about twice more popular
> in include/linux/syscalls.h than __u32.

I was looking at that when I was putting the patch together this
morning, trying to decide which was the "correct" choice between 'u32'
and '__u32' and wasn't able to find a good explanation of which is the
"right" option in this file.  Ultimately I went with 'u32' as I tend
to follow some old guidance of: '__u32' for userspace headers, 'u32'
for kernel headers.

If it should be the other way, please let me know.  I just want to
keep it consistent across the LSM syscalls.

-- 
paul-moore.com

      reply	other threads:[~2024-03-14 18:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <00734a64-a5fe-420c-bf6e-bee27c9d83be.ref@schaufler-ca.com>
2024-03-12 22:13 ` [PATCH] LSM: use 32 bit compatible data types in LSM syscalls Casey Schaufler
2024-03-13 15:56 ` [PATCH v2] " Casey Schaufler
2024-03-13 18:46   ` Paul Moore
2024-03-13 18:57     ` Casey Schaufler
2024-03-13 19:32 ` [PATCH v3] " Casey Schaufler
2024-03-13 19:42   ` Dmitry V. Levin
2024-03-13 20:07   ` Paul Moore
2024-03-13 22:37     ` Paul Moore
2024-03-13 22:48       ` Casey Schaufler
2024-03-14  1:44         ` Paul Moore
2024-03-14  2:25           ` Paul Moore
2024-03-14 15:30     ` Paul Moore
2024-03-14 15:45       ` Casey Schaufler
2024-03-14 18:01       ` Dmitry V. Levin
2024-03-14 18:18         ` Paul Moore [this message]

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=CAHC9VhTyg1aX-GEuZb2n3BjctH3_fCpz7W4i0WoLoMzbSnPCZA@mail.gmail.com \
    --to=paul@paul-moore.com \
    --cc=casey@schaufler-ca.com \
    --cc=jmorris@namei.org \
    --cc=john.johansen@canonical.com \
    --cc=ldv@strace.io \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=serge@hallyn.com \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).