lkml.org 
[lkml]   [2022]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH RFC v2 1/2] selinux: Fix selinux_sb_mnt_opts_compat()
On Tue, 25 Jan 2022, Paul Moore wrote:

> On Tue, Jan 25, 2022 at 12:31 PM Scott Mayhew <smayhew@redhat.com> wrote:
> > On Mon, 24 Jan 2022, Paul Moore wrote:
> > > On Thu, Jan 20, 2022 at 4:50 PM Scott Mayhew <smayhew@redhat.com> wrote:
> > > >
> > > > selinux_sb_mnt_opts_compat() is called under the sb_lock spinlock and
> > > > shouldn't be performing any memory allocations. Fix this by parsing the
> > > > sids at the same time we're chopping up the security mount options
> > > > string and then using the pre-parsed sids when doing the comparison.
> > > >
> > > > Fixes: cc274ae7763d ("selinux: fix sleeping function called from invalid context")
> > > > Fixes: 69c4a42d72eb ("lsm,selinux: add new hook to compare new mount to an existing mount")
> > > > Signed-off-by: Scott Mayhew <smayhew@redhat.com>
> > > > ---
> > > > security/selinux/hooks.c | 112 ++++++++++++++++++++++++++-------------
> > > > 1 file changed, 76 insertions(+), 36 deletions(-)
>
> ...
>
> > > > switch (token) {
> > > > case Opt_context:
> > > > if (opts->context || opts->defcontext)
> > > > goto err;
> > > > opts->context = s;
> > > > + if (preparse_sid) {
> > > > + rc = parse_sid(NULL, s, &sid);
> > > > + if (rc == 0) {
> > > > + opts->context_sid = sid;
> > > > + opts->preparsed |= CONTEXT_MNT;
> > > > + }
> > > > + }
> > >
> > > Is there a reason why we need a dedicated sid variable as opposed to
> > > passing opt->context_sid as the parameter? For example:
> > >
> > > rc = parse_sid(NULL, s, &opts->context_sid);
> >
> > We don't need a dedicated sid variable. Should I make similar changes
> > in the second patch (get rid of the local sid variable in
> > selinux_sb_remount() and the *context_sid variables in
> > selinux_set_mnt_opts())?
>
> Yes please, I should have explicitly mentioned that.

Actually, delayed_superblock_init() calls selinux_set_mnt_opts() with
mnt_opts == NULL, so there would have to be a lot of checks like

if (opts && opts->fscontext_sid) {

in the later parts of that function, which is kind of clunky. I can
still do it if you want though.

-Scott

>
> Thanks.
>
> --
> paul moore
> paul-moore.com
>

\
 
 \ /
  Last update: 2022-01-25 20:02    [W:0.155 / U:0.360 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site