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
| ||
|
Message-ID: <diqzzga0fv96.fsf@ackerleytng-cloudtop-sg.c.googlers.com> Date: Mon, 30 Jan 2023 05:26:29 +0000 From: Ackerley Tng <ackerleytng@...gle.com> To: Chao Peng <chao.p.peng@...ux.intel.com> Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org, linux-mm@...ck.org, linux-fsdevel@...r.kernel.org, linux-arch@...r.kernel.org, linux-api@...r.kernel.org, linux-doc@...r.kernel.org, qemu-devel@...gnu.org, pbonzini@...hat.com, corbet@....net, seanjc@...gle.com, vkuznets@...hat.com, wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, arnd@...db.de, naoya.horiguchi@....com, linmiaohe@...wei.com, x86@...nel.org, hpa@...or.com, hughd@...gle.com, jlayton@...nel.org, bfields@...ldses.org, akpm@...ux-foundation.org, shuah@...nel.org, rppt@...nel.org, steven.price@....com, mail@...iej.szmigiero.name, vbabka@...e.cz, vannapurve@...gle.com, yu.c.zhang@...ux.intel.com, chao.p.peng@...ux.intel.com, kirill.shutemov@...ux.intel.com, luto@...nel.org, jun.nakajima@...el.com, dave.hansen@...el.com, ak@...ux.intel.com, david@...hat.com, aarcange@...hat.com, ddutile@...hat.com, dhildenb@...hat.com, qperret@...gle.com, tabba@...gle.com, michael.roth@....com, mhocko@...e.com, wei.w.wang@...el.com Subject: Re: [PATCH v10 1/9] mm: Introduce memfd_restricted system call to create restricted user memory > +static int restrictedmem_getattr(struct user_namespace *mnt_userns, > + const struct path *path, struct kstat *stat, > + u32 request_mask, unsigned int query_flags) > +{ > + struct inode *inode = d_inode(path->dentry); > + struct restrictedmem_data *data = inode->i_mapping->private_data; > + struct file *memfd = data->memfd; > + > + return memfd->f_inode->i_op->getattr(mnt_userns, path, stat, > + request_mask, query_flags); Instead of calling shmem's getattr() with path, we should be using the the memfd's path. Otherwise, shmem's getattr() will use restrictedmem's inode instead of shmem's inode. The private fields will be of the wrong type, and the host will crash when shmem_is_huge() does SHMEM_SB(inode->i_sb)->huge), since inode->i_sb->s_fs_info is NULL for the restrictedmem's superblock. Here's the patch: diff --git a/mm/restrictedmem.c b/mm/restrictedmem.c index 37191cd9eed1..06b72d593bd8 100644 --- a/mm/restrictedmem.c +++ b/mm/restrictedmem.c @@ -84,7 +84,7 @@ static int restrictedmem_getattr(struct user_namespace *mnt_userns, struct restrictedmem *rm = inode->i_mapping->private_data; struct file *memfd = rm->memfd; - return memfd->f_inode->i_op->getattr(mnt_userns, path, stat, + return memfd->f_inode->i_op->getattr(mnt_userns, &memfd->f_path, stat, request_mask, query_flags); } > +} > + > +static int restrictedmem_setattr(struct user_namespace *mnt_userns, > + struct dentry *dentry, struct iattr *attr) > +{ > + struct inode *inode = d_inode(dentry); > + struct restrictedmem_data *data = inode->i_mapping->private_data; > + struct file *memfd = data->memfd; > + int ret; > + > + if (attr->ia_valid & ATTR_SIZE) { > + if (memfd->f_inode->i_size) > + return -EPERM; > + > + if (!PAGE_ALIGNED(attr->ia_size)) > + return -EINVAL; > + } > + > + ret = memfd->f_inode->i_op->setattr(mnt_userns, > + file_dentry(memfd), attr); > + return ret; > +} > + > +static const struct inode_operations restrictedmem_iops = { > + .getattr = restrictedmem_getattr, > + .setattr = restrictedmem_setattr, > +};
Powered by blists - more mailing lists