summaryrefslogtreecommitdiff
path: root/memfd.c
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2013-12-08 03:42:35 +0100
committerKay Sievers <kay@vrfy.org>2013-12-08 03:42:35 +0100
commiteb814dbda3c05bce8fa70482c7221e2181a2690a (patch)
tree384eb7412675c0aa577639018ca8e1c642e9bd8f /memfd.c
parent533182b03d5a795a9c48b5e9b8b614f1bfe51c2f (diff)
downloadkdbus-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.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/memfd.c b/memfd.c
index 5998359e9b5..d9d92d95d88 100644
--- a/memfd.c
+++ b/memfd.c
@@ -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 */