Commit 2d9c1336 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull misc VFS updates from Al Viro:
 "VFS-related cleanups in various places (mostly of the "that really
  can't happen" or "there's a better way to do it" variety)"

* tag 'pull-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  gpib: use file_inode()
  binder_ioctl_write_read(): simplify control flow a bit
  secretmem: move setting O_LARGEFILE and bumping users' count to the place where we create the file
  apparmor: file never has NULL f_path.mnt
  landlock: opened file never has a negative dentry
parents 8297b790 93c73ab1
Loading
Loading
Loading
Loading
+6 −14
Original line number Diff line number Diff line
@@ -5384,10 +5384,9 @@ static int binder_ioctl_write_read(struct file *filp, unsigned long arg,
	void __user *ubuf = (void __user *)arg;
	struct binder_write_read bwr;

	if (copy_from_user(&bwr, ubuf, sizeof(bwr))) {
		ret = -EFAULT;
		goto out;
	}
	if (copy_from_user(&bwr, ubuf, sizeof(bwr)))
		return -EFAULT;

	binder_debug(BINDER_DEBUG_READ_WRITE,
		     "%d:%d write %lld at %016llx, read %lld at %016llx\n",
		     proc->pid, thread->pid,
@@ -5402,8 +5401,6 @@ static int binder_ioctl_write_read(struct file *filp, unsigned long arg,
		trace_binder_write_done(ret);
		if (ret < 0) {
			bwr.read_consumed = 0;
			if (copy_to_user(ubuf, &bwr, sizeof(bwr)))
				ret = -EFAULT;
			goto out;
		}
	}
@@ -5417,22 +5414,17 @@ static int binder_ioctl_write_read(struct file *filp, unsigned long arg,
		if (!binder_worklist_empty_ilocked(&proc->todo))
			binder_wakeup_proc_ilocked(proc);
		binder_inner_proc_unlock(proc);
		if (ret < 0) {
			if (copy_to_user(ubuf, &bwr, sizeof(bwr)))
				ret = -EFAULT;
		if (ret < 0)
			goto out;
	}
	}
	binder_debug(BINDER_DEBUG_READ_WRITE,
		     "%d:%d wrote %lld of %lld, read return %lld of %lld\n",
		     proc->pid, thread->pid,
		     (u64)bwr.write_consumed, (u64)bwr.write_size,
		     (u64)bwr.read_consumed, (u64)bwr.read_size);
	if (copy_to_user(ubuf, &bwr, sizeof(bwr))) {
		ret = -EFAULT;
		goto out;
	}
out:
	if (copy_to_user(ubuf, &bwr, sizeof(bwr)))
		ret = -EFAULT;
	return ret;
}

+1 −1
Original line number Diff line number Diff line
@@ -610,7 +610,7 @@ int ibclose(struct inode *inode, struct file *filep)

long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
	unsigned int minor = iminor(filep->f_path.dentry->d_inode);
	unsigned int minor = iminor(file_inode(filep));
	struct gpib_board *board;
	struct gpib_file_private *file_priv = filep->private_data;
	long retval = -ENOTTY;
+3 −4
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ static struct file *secretmem_file_create(unsigned long flags)
		return ERR_CAST(inode);

	file = alloc_file_pseudo(inode, secretmem_mnt, "secretmem",
				 O_RDWR, &secretmem_fops);
				 O_RDWR | O_LARGEFILE, &secretmem_fops);
	if (IS_ERR(file))
		goto err_free_inode;

@@ -215,6 +215,8 @@ static struct file *secretmem_file_create(unsigned long flags)
	inode->i_mode |= S_IFREG;
	inode->i_size = 0;

	atomic_inc(&secretmem_users);

	return file;

err_free_inode:
@@ -248,9 +250,6 @@ SYSCALL_DEFINE1(memfd_secret, unsigned int, flags)
		goto err_put_fd;
	}

	file->f_flags |= O_LARGEFILE;

	atomic_inc(&secretmem_users);
	fd_install(fd, file);
	return fd;

+1 −1
Original line number Diff line number Diff line
@@ -604,7 +604,7 @@ int aa_file_perm(const char *op, const struct cred *subj_cred,
	rcu_read_unlock();
	/* TODO: label cross check */

	if (file->f_path.mnt && path_mediated_fs(file->f_path.dentry))
	if (path_mediated_fs(file->f_path.dentry))
		error = __file_path_perm(op, subj_cred, label, flabel, file,
					 request, denied, in_atomic);

+0 −1
Original line number Diff line number Diff line
@@ -303,7 +303,6 @@ static int get_path_from_fd(const s32 fd, struct path *const path)
	if ((fd_file(f)->f_op == &ruleset_fops) ||
	    (fd_file(f)->f_path.mnt->mnt_flags & MNT_INTERNAL) ||
	    (fd_file(f)->f_path.dentry->d_sb->s_flags & SB_NOUSER) ||
	    d_is_negative(fd_file(f)->f_path.dentry) ||
	    IS_PRIVATE(d_backing_inode(fd_file(f)->f_path.dentry)))
		return -EBADFD;