Skip to content

Commit ca5b857

Browse files
committedNov 17, 2017
Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc vfs updates from Al Viro: "Assorted stuff, really no common topic here" * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: vfs: grab the lock instead of blocking in __fd_install during resizing vfs: stop clearing close on exec when closing a fd include/linux/fs.h: fix comment about struct address_space fs: make fiemap work from compat_ioctl coda: fix 'kernel memory exposure attempt' in fsync pstore: remove unneeded unlikely() vfs: remove unneeded unlikely() stubs for mount_bdev() and kill_block_super() in !CONFIG_BLOCK case make vfs_ustat() static do_handle_open() should be static elf_fdpic: fix unused variable warning fold destroy_super() into __put_super() new helper: destroy_unused_super() fix address space warnings in ipc/ acct.h: get rid of detritus
2 parents a0e136e + c02b1a9 commit ca5b857

File tree

16 files changed

+60
-52
lines changed

16 files changed

+60
-52
lines changed
 

‎Documentation/filesystems/porting

-4
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,6 @@ in your dentry operations instead.
501501
is non-NULL. Note that link body isn't available anymore, so if you need it,
502502
store it as cookie.
503503
--
504-
[mandatory]
505-
__fd_install() & fd_install() can now sleep. Callers should not
506-
hold a spinlock or other resources that do not allow a schedule.
507-
--
508504
[mandatory]
509505
any symlink that might use page_follow_link_light/page_put_link() must
510506
have inode_nohighmem(inode) called before anything might start playing with

‎fs/binfmt_elf_fdpic.c

+2
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,9 @@ static bool elf_fdpic_dump_segments(struct coredump_params *cprm)
14981498
struct vm_area_struct *vma;
14991499

15001500
for (vma = current->mm->mmap; vma; vma = vma->vm_next) {
1501+
#ifdef CONFIG_MMU
15011502
unsigned long addr;
1503+
#endif
15021504

15031505
if (!maydump(vma, cprm->mm_flags))
15041506
continue;

‎fs/coda/upcall.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,7 @@ int venus_fsync(struct super_block *sb, struct CodaFid *fid)
447447
UPARG(CODA_FSYNC);
448448

449449
inp->coda_fsync.VFid = *fid;
450-
error = coda_upcall(coda_vcp(sb), sizeof(union inputArgs),
451-
&outsize, inp);
450+
error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
452451

453452
CODA_FREE(inp, insize);
454453
return error;

‎fs/compat_ioctl.c

+1
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,7 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
14581458
case FICLONE:
14591459
case FICLONERANGE:
14601460
case FIDEDUPERANGE:
1461+
case FS_IOC_FIEMAP:
14611462
goto do_ioctl;
14621463

14631464
case FIBMAP:

‎fs/fhandle.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh,
213213
return retval;
214214
}
215215

216-
long do_handle_open(int mountdirfd,
217-
struct file_handle __user *ufh, int open_flag)
216+
static long do_handle_open(int mountdirfd, struct file_handle __user *ufh,
217+
int open_flag)
218218
{
219219
long retval = 0;
220220
struct path path;

‎fs/file.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -593,13 +593,16 @@ void __fd_install(struct files_struct *files, unsigned int fd,
593593
{
594594
struct fdtable *fdt;
595595

596-
might_sleep();
597596
rcu_read_lock_sched();
598597

599-
while (unlikely(files->resize_in_progress)) {
598+
if (unlikely(files->resize_in_progress)) {
600599
rcu_read_unlock_sched();
601-
wait_event(files->resize_wait, !files->resize_in_progress);
602-
rcu_read_lock_sched();
600+
spin_lock(&files->file_lock);
601+
fdt = files_fdtable(files);
602+
BUG_ON(fdt->fd[fd] != NULL);
603+
rcu_assign_pointer(fdt->fd[fd], file);
604+
spin_unlock(&files->file_lock);
605+
return;
603606
}
604607
/* coupled with smp_wmb() in expand_fdtable() */
605608
smp_rmb();
@@ -632,7 +635,6 @@ int __close_fd(struct files_struct *files, unsigned fd)
632635
if (!file)
633636
goto out_unlock;
634637
rcu_assign_pointer(fdt->fd[fd], NULL);
635-
__clear_close_on_exec(fd, fdt);
636638
__put_unused_fd(files, fd);
637639
spin_unlock(&files->file_lock);
638640
return filp_close(file, files);

‎fs/namei.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3459,7 +3459,7 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags,
34593459
goto out;
34603460
child = vfs_tmpfile(path.dentry, op->mode, op->open_flag);
34613461
error = PTR_ERR(child);
3462-
if (unlikely(IS_ERR(child)))
3462+
if (IS_ERR(child))
34633463
goto out2;
34643464
dput(path.dentry);
34653465
path.dentry = child;

‎fs/pstore/platform.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ static int pstore_write_user_compat(struct pstore_record *record,
651651
return -EINVAL;
652652

653653
record->buf = memdup_user(buf, record->size);
654-
if (unlikely(IS_ERR(record->buf))) {
654+
if (IS_ERR(record->buf)) {
655655
ret = PTR_ERR(record->buf);
656656
goto out;
657657
}

‎fs/statfs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, size_t, sz, struct statfs64 __user
217217
return error;
218218
}
219219

220-
int vfs_ustat(dev_t dev, struct kstatfs *sbuf)
220+
static int vfs_ustat(dev_t dev, struct kstatfs *sbuf)
221221
{
222222
struct super_block *s = user_get_super(dev);
223223
int err;

‎fs/super.c

+21-25
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,19 @@ static void destroy_super_rcu(struct rcu_head *head)
155155
schedule_work(&s->destroy_work);
156156
}
157157

158-
/**
159-
* destroy_super - frees a superblock
160-
* @s: superblock to free
161-
*
162-
* Frees a superblock.
163-
*/
164-
static void destroy_super(struct super_block *s)
158+
/* Free a superblock that has never been seen by anyone */
159+
static void destroy_unused_super(struct super_block *s)
165160
{
161+
if (!s)
162+
return;
163+
up_write(&s->s_umount);
166164
list_lru_destroy(&s->s_dentry_lru);
167165
list_lru_destroy(&s->s_inode_lru);
168166
security_sb_free(s);
169-
WARN_ON(!list_empty(&s->s_mounts));
170167
put_user_ns(s->s_user_ns);
171168
kfree(s->s_subtype);
172-
call_rcu(&s->rcu, destroy_super_rcu);
169+
/* no delays needed */
170+
destroy_super_work(&s->destroy_work);
173171
}
174172

175173
/**
@@ -257,7 +255,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
257255
return s;
258256

259257
fail:
260-
destroy_super(s);
258+
destroy_unused_super(s);
261259
return NULL;
262260
}
263261

@@ -266,11 +264,17 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
266264
/*
267265
* Drop a superblock's refcount. The caller must hold sb_lock.
268266
*/
269-
static void __put_super(struct super_block *sb)
267+
static void __put_super(struct super_block *s)
270268
{
271-
if (!--sb->s_count) {
272-
list_del_init(&sb->s_list);
273-
destroy_super(sb);
269+
if (!--s->s_count) {
270+
list_del_init(&s->s_list);
271+
WARN_ON(s->s_dentry_lru.node);
272+
WARN_ON(s->s_inode_lru.node);
273+
WARN_ON(!list_empty(&s->s_mounts));
274+
security_sb_free(s);
275+
put_user_ns(s->s_user_ns);
276+
kfree(s->s_subtype);
277+
call_rcu(&s->rcu, destroy_super_rcu);
274278
}
275279
}
276280

@@ -485,19 +489,12 @@ struct super_block *sget_userns(struct file_system_type *type,
485489
continue;
486490
if (user_ns != old->s_user_ns) {
487491
spin_unlock(&sb_lock);
488-
if (s) {
489-
up_write(&s->s_umount);
490-
destroy_super(s);
491-
}
492+
destroy_unused_super(s);
492493
return ERR_PTR(-EBUSY);
493494
}
494495
if (!grab_super(old))
495496
goto retry;
496-
if (s) {
497-
up_write(&s->s_umount);
498-
destroy_super(s);
499-
s = NULL;
500-
}
497+
destroy_unused_super(s);
501498
return old;
502499
}
503500
}
@@ -512,8 +509,7 @@ struct super_block *sget_userns(struct file_system_type *type,
512509
err = set(s, data);
513510
if (err) {
514511
spin_unlock(&sb_lock);
515-
up_write(&s->s_umount);
516-
destroy_super(s);
512+
destroy_unused_super(s);
517513
return ERR_PTR(err);
518514
}
519515
s->s_type = type;

‎include/linux/acct.h

-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020

2121

2222
#ifdef CONFIG_BSD_PROCESS_ACCT
23-
struct vfsmount;
24-
struct super_block;
25-
struct pacct_struct;
2623
struct pid_namespace;
2724
extern int acct_parm[]; /* for sysctl */
2825
extern void acct_collect(long exitcode, int group_dead);

‎include/linux/fs.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -2098,9 +2098,18 @@ struct file_system_type {
20982098
extern struct dentry *mount_ns(struct file_system_type *fs_type,
20992099
int flags, void *data, void *ns, struct user_namespace *user_ns,
21002100
int (*fill_super)(struct super_block *, void *, int));
2101+
#ifdef CONFIG_BLOCK
21012102
extern struct dentry *mount_bdev(struct file_system_type *fs_type,
21022103
int flags, const char *dev_name, void *data,
21032104
int (*fill_super)(struct super_block *, void *, int));
2105+
#else
2106+
static inline struct dentry *mount_bdev(struct file_system_type *fs_type,
2107+
int flags, const char *dev_name, void *data,
2108+
int (*fill_super)(struct super_block *, void *, int))
2109+
{
2110+
return ERR_PTR(-ENODEV);
2111+
}
2112+
#endif
21042113
extern struct dentry *mount_single(struct file_system_type *fs_type,
21052114
int flags, void *data,
21062115
int (*fill_super)(struct super_block *, void *, int));
@@ -2109,7 +2118,14 @@ extern struct dentry *mount_nodev(struct file_system_type *fs_type,
21092118
int (*fill_super)(struct super_block *, void *, int));
21102119
extern struct dentry *mount_subtree(struct vfsmount *mnt, const char *path);
21112120
void generic_shutdown_super(struct super_block *sb);
2121+
#ifdef CONFIG_BLOCK
21122122
void kill_block_super(struct super_block *sb);
2123+
#else
2124+
static inline void kill_block_super(struct super_block *sb)
2125+
{
2126+
BUG();
2127+
}
2128+
#endif
21132129
void kill_anon_super(struct super_block *sb);
21142130
void kill_litter_super(struct super_block *sb);
21152131
void deactivate_super(struct super_block *sb);
@@ -2173,7 +2189,6 @@ extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
21732189
extern int vfs_statfs(const struct path *, struct kstatfs *);
21742190
extern int user_statfs(const char __user *, struct kstatfs *);
21752191
extern int fd_statfs(int, struct kstatfs *);
2176-
extern int vfs_ustat(dev_t, struct kstatfs *);
21772192
extern int freeze_super(struct super_block *super);
21782193
extern int thaw_super(struct super_block *super);
21792194
extern bool our_mnt(struct vfsmount *mnt);

‎ipc/msg.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -591,13 +591,13 @@ static int copy_compat_msqid_from_user(struct msqid64_ds *out, void __user *buf,
591591
{
592592
memset(out, 0, sizeof(*out));
593593
if (version == IPC_64) {
594-
struct compat_msqid64_ds *p = buf;
594+
struct compat_msqid64_ds __user *p = buf;
595595
if (get_compat_ipc64_perm(&out->msg_perm, &p->msg_perm))
596596
return -EFAULT;
597597
if (get_user(out->msg_qbytes, &p->msg_qbytes))
598598
return -EFAULT;
599599
} else {
600-
struct compat_msqid_ds *p = buf;
600+
struct compat_msqid_ds __user *p = buf;
601601
if (get_compat_ipc_perm(&out->msg_perm, &p->msg_perm))
602602
return -EFAULT;
603603
if (get_user(out->msg_qbytes, &p->msg_qbytes))

‎ipc/sem.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1637,10 +1637,10 @@ static int copy_compat_semid_from_user(struct semid64_ds *out, void __user *buf,
16371637
{
16381638
memset(out, 0, sizeof(*out));
16391639
if (version == IPC_64) {
1640-
struct compat_semid64_ds *p = buf;
1640+
struct compat_semid64_ds __user *p = buf;
16411641
return get_compat_ipc64_perm(&out->sem_perm, &p->sem_perm);
16421642
} else {
1643-
struct compat_semid_ds *p = buf;
1643+
struct compat_semid_ds __user *p = buf;
16441644
return get_compat_ipc_perm(&out->sem_perm, &p->sem_perm);
16451645
}
16461646
}

‎ipc/shm.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1194,10 +1194,10 @@ static int copy_compat_shmid_from_user(struct shmid64_ds *out, void __user *buf,
11941194
{
11951195
memset(out, 0, sizeof(*out));
11961196
if (version == IPC_64) {
1197-
struct compat_shmid64_ds *p = buf;
1197+
struct compat_shmid64_ds __user *p = buf;
11981198
return get_compat_ipc64_perm(&out->shm_perm, &p->shm_perm);
11991199
} else {
1200-
struct compat_shmid_ds *p = buf;
1200+
struct compat_shmid_ds __user *p = buf;
12011201
return get_compat_ipc_perm(&out->shm_perm, &p->shm_perm);
12021202
}
12031203
}

‎ipc/syscall.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
172172
COMPAT_SHMLBA);
173173
if (err < 0)
174174
return err;
175-
return put_user(raddr, (compat_ulong_t *)compat_ptr(third));
175+
return put_user(raddr, (compat_ulong_t __user *)compat_ptr(third));
176176
}
177177
case SHMDT:
178178
return sys_shmdt(compat_ptr(ptr));

0 commit comments

Comments
 (0)