Lines Matching full:file

2  * memfd_create system call and file sealing support
7 * This file is released under the GPL.
13 #include <linux/file.h>
136 static unsigned int *memfd_file_seals_ptr(struct file *file) in memfd_file_seals_ptr() argument
138 if (shmem_file(file)) in memfd_file_seals_ptr()
139 return &SHMEM_I(file_inode(file))->seals; in memfd_file_seals_ptr()
142 if (is_file_hugepages(file)) in memfd_file_seals_ptr()
143 return &HUGETLBFS_I(file_inode(file))->seals; in memfd_file_seals_ptr()
155 static int memfd_add_seals(struct file *file, unsigned int seals) in memfd_add_seals() argument
157 struct inode *inode = file_inode(file); in memfd_add_seals()
163 * Sealing allows multiple parties to share a tmpfs or hugetlbfs file in memfd_add_seals()
164 * but restrict access to a specific subset of file operations. Seals in memfd_add_seals()
172 * may prevent some kinds of access to the file. Currently, the in memfd_add_seals()
174 * SEAL_SEAL: Prevent further seals from being set on this file in memfd_add_seals()
175 * SEAL_SHRINK: Prevent the file from shrinking in memfd_add_seals()
176 * SEAL_GROW: Prevent the file from growing in memfd_add_seals()
177 * SEAL_WRITE: Prevent write access to the file in memfd_add_seals()
180 * must prevent seals from being removed. Therefore, sealing a file in memfd_add_seals()
181 * only adds a given set of seals to the file, it never touches in memfd_add_seals()
189 * no plan to support it on other file types. in memfd_add_seals()
192 if (!(file->f_mode & FMODE_WRITE)) in memfd_add_seals()
199 file_seals = memfd_file_seals_ptr(file); in memfd_add_seals()
211 error = mapping_deny_writable(file->f_mapping); in memfd_add_seals()
215 error = memfd_wait_for_pins(file->f_mapping); in memfd_add_seals()
217 mapping_allow_writable(file->f_mapping); in memfd_add_seals()
230 static int memfd_get_seals(struct file *file) in memfd_get_seals() argument
232 unsigned int *seals = memfd_file_seals_ptr(file); in memfd_get_seals()
237 long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg) in memfd_fcntl() argument
247 error = memfd_add_seals(file, arg); in memfd_fcntl()
250 error = memfd_get_seals(file); in memfd_fcntl()
271 struct file *file; in SYSCALL_DEFINE2() local
316 file = hugetlb_file_setup(name, 0, VM_NORESERVE, in SYSCALL_DEFINE2()
321 file = shmem_file_setup(name, 0, VM_NORESERVE); in SYSCALL_DEFINE2()
322 if (IS_ERR(file)) { in SYSCALL_DEFINE2()
323 error = PTR_ERR(file); in SYSCALL_DEFINE2()
326 file->f_mode |= FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE; in SYSCALL_DEFINE2()
327 file->f_flags |= O_LARGEFILE; in SYSCALL_DEFINE2()
330 file_seals = memfd_file_seals_ptr(file); in SYSCALL_DEFINE2()
334 fd_install(fd, file); in SYSCALL_DEFINE2()