diff options
author | Kay Sievers <kay@vrfy.org> | 2013-12-08 03:42:35 +0100 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2013-12-08 03:42:35 +0100 |
commit | eb814dbda3c05bce8fa70482c7221e2181a2690a (patch) | |
tree | 384eb7412675c0aa577639018ca8e1c642e9bd8f /memfd.c | |
parent | 533182b03d5a795a9c48b5e9b8b614f1bfe51c2f (diff) | |
download | kdbus-bus-eb814dbda3c05bce8fa70482c7221e2181a2690a.tar.gz kdbus-bus-eb814dbda3c05bce8fa70482c7221e2181a2690a.tar.bz2 kdbus-bus-eb814dbda3c05bce8fa70482c7221e2181a2690a.zip |
memfd: update inode size during mmap()
Diffstat (limited to 'memfd.c')
-rw-r--r-- | memfd.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -227,6 +227,7 @@ static int kdbus_memfd_mmap(struct file *file, struct vm_area_struct *vma) if (vma->vm_flags & VM_WRITE) { size_t size; + struct inode *inode; /* * Deny a writable mapping to a sealed file. @@ -244,11 +245,9 @@ static int kdbus_memfd_mmap(struct file *file, struct vm_area_struct *vma) /* extend the size of the shmem file to the size of the mapping */ size = (vma->vm_end - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); - if (size > PAGE_ALIGN(i_size_read(file_inode(mf->fp)))) { - ret = vfs_truncate(&mf->fp->f_path, size); - if (ret < 0) - goto exit; - } + inode = file_inode(mf->fp); + if (size > PAGE_ALIGN(i_size_read(inode))) + i_size_write(inode, size); } /* replace the anoymous inode file with our shmem file */ |