[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f2e41cc77e8a0d69f6e2bbe98455437a64b93129.camel@huaweicloud.com>
Date: Fri, 18 Oct 2024 13:56:39 +0200
From: Roberto Sassu <roberto.sassu@...weicloud.com>
To: "Kirill A. Shutemov" <kirill@...temov.name>
Cc: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, Paul Moore
<paul@...l-moore.com>, ebpqwerty472123@...il.com,
kirill.shutemov@...ux.intel.com, 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, Roberto Sassu <roberto.sassu@...wei.com>,
linux-mm@...ck.org, akpm@...ux-foundation.org, vbabka@...e.cz,
linux-fsdevel@...r.kernel.org, Liam Howlett <liam.howlett@...cle.com>, Jann
Horn <jannh@...gle.com>
Subject: Re: [PATCH 1/3] ima: Remove inode lock
On Fri, 2024-10-18 at 14:54 +0300, Kirill A. Shutemov wrote:
> On Fri, Oct 18, 2024 at 01:22:35PM +0200, Roberto Sassu wrote:
> > On Fri, 2024-10-18 at 14:05 +0300, Kirill A. Shutemov wrote:
> > > On Fri, Oct 18, 2024 at 12:00:22PM +0100, Lorenzo Stoakes wrote:
> > > > + Liam, Jann
> > > >
> > > > On Fri, Oct 18, 2024 at 01:49:06PM +0300, Kirill A. Shutemov wrote:
> > > > > On Fri, Oct 18, 2024 at 11:24:06AM +0200, Roberto Sassu wrote:
> > > > > > Probably it is hard, @Kirill would there be any way to safely move
> > > > > > security_mmap_file() out of the mmap_lock lock?
> > > > >
> > > > > What about something like this (untested):
> > > > >
> > > > > diff --git a/mm/mmap.c b/mm/mmap.c
> > > > > index dd4b35a25aeb..03473e77d356 100644
> > > > > --- a/mm/mmap.c
> > > > > +++ b/mm/mmap.c
> > > > > @@ -1646,6 +1646,26 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
> > > > > if (pgoff + (size >> PAGE_SHIFT) < pgoff)
> > > > > return ret;
> > > > >
> > > > > + if (mmap_read_lock_killable(mm))
> > > > > + return -EINTR;
> > > > > +
> > > > > + vma = vma_lookup(mm, start);
> > > > > +
> > > > > + if (!vma || !(vma->vm_flags & VM_SHARED)) {
> > > > > + mmap_read_unlock(mm);
> > > > > + return -EINVAL;
> > > > > + }
> > > > > +
> > > > > + file = get_file(vma->vm_file);
> > > > > +
> > > > > + mmap_read_unlock(mm);
> > > > > +
> > > > > + ret = security_mmap_file(vma->vm_file, prot, flags);
> > > >
> > > > Accessing VMA fields without any kind of lock is... very much not advised.
> > > >
> > > > I'm guessing you meant to say:
> > > >
> > > > ret = security_mmap_file(file, prot, flags);
> > > >
> > > > Here? :)
> > >
> > > Sure. My bad.
> > >
> > > Patch with all fixups:
> >
> > Thanks a lot! Let's wait a bit until the others have a chance to
> > comment. Meanwhile, I will test it.
> >
> > Do you want me to do the final patch, or will you be proposing it?
>
> You can post it if it works:
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
Thanks! Ok.
Roberto
Powered by blists - more mailing lists