lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <69ed92fde951b20a9b976d48803fe9b5daaa9eea.camel@huaweicloud.com>
Date: Wed, 09 Oct 2024 17:43:20 +0200
From: Roberto Sassu <roberto.sassu@...weicloud.com>
To: Paul Moore <paul@...l-moore.com>
Cc: zohar@...ux.ibm.com, dmitry.kasatkin@...il.com,
 eric.snowberg@...cle.com,  jmorris@...ei.org, serge@...lyn.com,
 linux-integrity@...r.kernel.org,  linux-security-module@...r.kernel.org,
 linux-kernel@...r.kernel.org,  bpf@...r.kernel.org,
 ebpqwerty472123@...il.com, Roberto Sassu <roberto.sassu@...wei.com>
Subject: Re: [PATCH 2/3] ima: Ensure lock is held when setting iint pointer
 in inode security blob

On Wed, 2024-10-09 at 11:41 -0400, Paul Moore wrote:
> On Tue, Oct 8, 2024 at 12:57 PM Roberto Sassu
> <roberto.sassu@...weicloud.com> wrote:
> > 
> > From: Roberto Sassu <roberto.sassu@...wei.com>
> > 
> > IMA stores a pointer of the ima_iint_cache structure, containing integrity
> > metadata, in the inode security blob. However, check and assignment of this
> > pointer is not atomic, and it might happen that two tasks both see that the
> > iint pointer is NULL and try to set it, causing a memory leak.
> > 
> > Ensure that the iint check and assignment is guarded, by adding a lockdep
> > assertion in ima_inode_get().
> > 
> > Consequently, guard the remaining ima_inode_get() calls, in
> > ima_post_create_tmpfile() and ima_post_path_mknod(), to avoid the lockdep
> > warnings.
> > 
> > Signed-off-by: Roberto Sassu <roberto.sassu@...wei.com>
> > ---
> >  security/integrity/ima/ima_iint.c |  5 +++++
> >  security/integrity/ima/ima_main.c | 14 ++++++++++++--
> >  2 files changed, 17 insertions(+), 2 deletions(-)
> > 
> > diff --git a/security/integrity/ima/ima_iint.c b/security/integrity/ima/ima_iint.c
> > index c176fd0faae7..fe676ccec32f 100644
> > --- a/security/integrity/ima/ima_iint.c
> > +++ b/security/integrity/ima/ima_iint.c
> > @@ -87,8 +87,13 @@ static void ima_iint_free(struct ima_iint_cache *iint)
> >   */
> >  struct ima_iint_cache *ima_inode_get(struct inode *inode)
> >  {
> > +       struct ima_iint_cache_lock *iint_lock;
> >         struct ima_iint_cache *iint;
> > 
> > +       iint_lock = ima_inode_security(inode->i_security);
> > +       if (iint_lock)
> > +               lockdep_assert_held(&iint_lock->mutex);
> > +
> >         iint = ima_iint_find(inode);
> >         if (iint)
> >                 return iint;
> 
> Can you avoid the ima_iint_find() call here and just do the following?
> 
>   /* not sure if you need to check !iint_lock or not? */
>   if (!iint_lock)
>     return NULL;
>   iint = iint_lock->iint;
>   if (!iint)
>     return NULL;

Yes, I also like it much more.

Thanks

Roberto



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ