qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 01/12] mm/shmem: Introduce F_SEAL_INACCESSIBLE


From: Chao Peng
Subject: Re: [PATCH v4 01/12] mm/shmem: Introduce F_SEAL_INACCESSIBLE
Date: Thu, 17 Feb 2022 20:56:57 +0800
User-agent: Mutt/1.9.4 (2018-02-28)

On Mon, Feb 07, 2022 at 01:24:42PM +0100, Vlastimil Babka wrote:
> On 1/18/22 14:21, Chao Peng wrote:
> > From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> > 
> >  /*
> > diff --git a/mm/shmem.c b/mm/shmem.c
> > index 18f93c2d68f1..72185630e7c4 100644
> > --- a/mm/shmem.c
> > +++ b/mm/shmem.c
> > @@ -1098,6 +1098,13 @@ static int shmem_setattr(struct user_namespace 
> > *mnt_userns,
> >                 (newsize > oldsize && (info->seals & F_SEAL_GROW)))
> >                     return -EPERM;
> >  
> > +           if (info->seals & F_SEAL_INACCESSIBLE) {
> > +                   if(i_size_read(inode))
> 
> Is this needed? The rest of the function seems to trust oldsize obtained by
> plain reading inode->i_size well enough, so why be suddenly paranoid here?

oldsize sounds enough here, unless kirill has different mind.

> 
> > +                           return -EPERM;
> > +                   if (newsize & ~PAGE_MASK)
> > +                           return -EINVAL;
> > +           }
> > +
> >             if (newsize != oldsize) {
> >                     error = shmem_reacct_size(SHMEM_I(inode)->flags,
> > +           if ((info->seals & F_SEAL_INACCESSIBLE) &&
> > +               (offset & ~PAGE_MASK || len & ~PAGE_MASK)) {
> 
> Could we use PAGE_ALIGNED()?

Yes, definitely, thanks.

Chao
> 
> > +                   error = -EINVAL;
> > +                   goto out;
> > +           }
> > +
> >             shmem_falloc.waitq = &shmem_falloc_waitq;
> >             shmem_falloc.start = (u64)unmap_start >> PAGE_SHIFT;
> >             shmem_falloc.next = (unmap_end + 1) >> PAGE_SHIFT;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]