Skip to content

Commit 2d9c133

Browse files
committed
Merge tag 'pull-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
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
2 parents 8297b79 + 93c73ab commit 2d9c133

5 files changed

Lines changed: 11 additions & 21 deletions

File tree

drivers/android/binder.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5384,10 +5384,9 @@ static int binder_ioctl_write_read(struct file *filp, unsigned long arg,
53845384
void __user *ubuf = (void __user *)arg;
53855385
struct binder_write_read bwr;
53865386

5387-
if (copy_from_user(&bwr, ubuf, sizeof(bwr))) {
5388-
ret = -EFAULT;
5389-
goto out;
5390-
}
5387+
if (copy_from_user(&bwr, ubuf, sizeof(bwr)))
5388+
return -EFAULT;
5389+
53915390
binder_debug(BINDER_DEBUG_READ_WRITE,
53925391
"%d:%d write %lld at %016llx, read %lld at %016llx\n",
53935392
proc->pid, thread->pid,
@@ -5402,8 +5401,6 @@ static int binder_ioctl_write_read(struct file *filp, unsigned long arg,
54025401
trace_binder_write_done(ret);
54035402
if (ret < 0) {
54045403
bwr.read_consumed = 0;
5405-
if (copy_to_user(ubuf, &bwr, sizeof(bwr)))
5406-
ret = -EFAULT;
54075404
goto out;
54085405
}
54095406
}
@@ -5417,22 +5414,17 @@ static int binder_ioctl_write_read(struct file *filp, unsigned long arg,
54175414
if (!binder_worklist_empty_ilocked(&proc->todo))
54185415
binder_wakeup_proc_ilocked(proc);
54195416
binder_inner_proc_unlock(proc);
5420-
if (ret < 0) {
5421-
if (copy_to_user(ubuf, &bwr, sizeof(bwr)))
5422-
ret = -EFAULT;
5417+
if (ret < 0)
54235418
goto out;
5424-
}
54255419
}
54265420
binder_debug(BINDER_DEBUG_READ_WRITE,
54275421
"%d:%d wrote %lld of %lld, read return %lld of %lld\n",
54285422
proc->pid, thread->pid,
54295423
(u64)bwr.write_consumed, (u64)bwr.write_size,
54305424
(u64)bwr.read_consumed, (u64)bwr.read_size);
5431-
if (copy_to_user(ubuf, &bwr, sizeof(bwr))) {
5432-
ret = -EFAULT;
5433-
goto out;
5434-
}
54355425
out:
5426+
if (copy_to_user(ubuf, &bwr, sizeof(bwr)))
5427+
ret = -EFAULT;
54365428
return ret;
54375429
}
54385430

drivers/staging/gpib/common/gpib_os.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ int ibclose(struct inode *inode, struct file *filep)
610610

611611
long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg)
612612
{
613-
unsigned int minor = iminor(filep->f_path.dentry->d_inode);
613+
unsigned int minor = iminor(file_inode(filep));
614614
struct gpib_board *board;
615615
struct gpib_file_private *file_priv = filep->private_data;
616616
long retval = -ENOTTY;

mm/secretmem.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static struct file *secretmem_file_create(unsigned long flags)
201201
return ERR_CAST(inode);
202202

203203
file = alloc_file_pseudo(inode, secretmem_mnt, "secretmem",
204-
O_RDWR, &secretmem_fops);
204+
O_RDWR | O_LARGEFILE, &secretmem_fops);
205205
if (IS_ERR(file))
206206
goto err_free_inode;
207207

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

218+
atomic_inc(&secretmem_users);
219+
218220
return file;
219221

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

251-
file->f_flags |= O_LARGEFILE;
252-
253-
atomic_inc(&secretmem_users);
254253
fd_install(fd, file);
255254
return fd;
256255

security/apparmor/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ int aa_file_perm(const char *op, const struct cred *subj_cred,
604604
rcu_read_unlock();
605605
/* TODO: label cross check */
606606

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

security/landlock/syscalls.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ static int get_path_from_fd(const s32 fd, struct path *const path)
303303
if ((fd_file(f)->f_op == &ruleset_fops) ||
304304
(fd_file(f)->f_path.mnt->mnt_flags & MNT_INTERNAL) ||
305305
(fd_file(f)->f_path.dentry->d_sb->s_flags & SB_NOUSER) ||
306-
d_is_negative(fd_file(f)->f_path.dentry) ||
307306
IS_PRIVATE(d_backing_inode(fd_file(f)->f_path.dentry)))
308307
return -EBADFD;
309308

0 commit comments

Comments
 (0)