Skip to content

Commit 8ef9c29

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs fixes from Al Viro. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: vfs: add missing check for __O_TMPFILE in fcntl_init() fs: Allow unprivileged linkat(..., AT_EMPTY_PATH) aka flink fs: Fix file mode for O_TMPFILE reiserfs: fix deadlock in umount
2 parents e4ef108 + 3d62c45 commit 8ef9c29

File tree

5 files changed

+26
-92
lines changed

5 files changed

+26
-92
lines changed

fs/fcntl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,14 +730,14 @@ static int __init fcntl_init(void)
730730
* Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY
731731
* is defined as O_NONBLOCK on some platforms and not on others.
732732
*/
733-
BUILD_BUG_ON(19 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
733+
BUILD_BUG_ON(20 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
734734
O_RDONLY | O_WRONLY | O_RDWR |
735735
O_CREAT | O_EXCL | O_NOCTTY |
736736
O_TRUNC | O_APPEND | /* O_NONBLOCK | */
737737
__O_SYNC | O_DSYNC | FASYNC |
738738
O_DIRECT | O_LARGEFILE | O_DIRECTORY |
739739
O_NOFOLLOW | O_NOATIME | O_CLOEXEC |
740-
__FMODE_EXEC | O_PATH
740+
__FMODE_EXEC | O_PATH | __O_TMPFILE
741741
));
742742

743743
fasync_cache = kmem_cache_create("fasync_cache",

fs/namei.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,15 +3671,11 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
36713671
if ((flags & ~(AT_SYMLINK_FOLLOW | AT_EMPTY_PATH)) != 0)
36723672
return -EINVAL;
36733673
/*
3674-
* To use null names we require CAP_DAC_READ_SEARCH
3675-
* This ensures that not everyone will be able to create
3676-
* handlink using the passed filedescriptor.
3674+
* Using empty names is equivalent to using AT_SYMLINK_FOLLOW
3675+
* on /proc/self/fd/<fd>.
36773676
*/
3678-
if (flags & AT_EMPTY_PATH) {
3679-
if (!capable(CAP_DAC_READ_SEARCH))
3680-
return -ENOENT;
3677+
if (flags & AT_EMPTY_PATH)
36813678
how = LOOKUP_EMPTY;
3682-
}
36833679

36843680
if (flags & AT_SYMLINK_FOLLOW)
36853681
how |= LOOKUP_FOLLOW;

fs/open.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
823823
int lookup_flags = 0;
824824
int acc_mode;
825825

826-
if (flags & O_CREAT)
826+
if (flags & (O_CREAT | __O_TMPFILE))
827827
op->mode = (mode & S_IALLUGO) | S_IFREG;
828828
else
829829
op->mode = 0;

fs/reiserfs/procfs.c

Lines changed: 19 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
/*
2020
* LOCKING:
2121
*
22-
* We rely on new Alexander Viro's super-block locking.
22+
* These guys are evicted from procfs as the very first step in ->kill_sb().
2323
*
2424
*/
2525

26-
static int show_version(struct seq_file *m, struct super_block *sb)
26+
static int show_version(struct seq_file *m, void *unused)
2727
{
28+
struct super_block *sb = m->private;
2829
char *format;
2930

3031
if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) {
@@ -66,8 +67,9 @@ static int show_version(struct seq_file *m, struct super_block *sb)
6667
#define DJP( x ) le32_to_cpu( jp -> x )
6768
#define JF( x ) ( r -> s_journal -> x )
6869

69-
static int show_super(struct seq_file *m, struct super_block *sb)
70+
static int show_super(struct seq_file *m, void *unused)
7071
{
72+
struct super_block *sb = m->private;
7173
struct reiserfs_sb_info *r = REISERFS_SB(sb);
7274

7375
seq_printf(m, "state: \t%s\n"
@@ -128,8 +130,9 @@ static int show_super(struct seq_file *m, struct super_block *sb)
128130
return 0;
129131
}
130132

131-
static int show_per_level(struct seq_file *m, struct super_block *sb)
133+
static int show_per_level(struct seq_file *m, void *unused)
132134
{
135+
struct super_block *sb = m->private;
133136
struct reiserfs_sb_info *r = REISERFS_SB(sb);
134137
int level;
135138

@@ -186,8 +189,9 @@ static int show_per_level(struct seq_file *m, struct super_block *sb)
186189
return 0;
187190
}
188191

189-
static int show_bitmap(struct seq_file *m, struct super_block *sb)
192+
static int show_bitmap(struct seq_file *m, void *unused)
190193
{
194+
struct super_block *sb = m->private;
191195
struct reiserfs_sb_info *r = REISERFS_SB(sb);
192196

193197
seq_printf(m, "free_block: %lu\n"
@@ -218,8 +222,9 @@ static int show_bitmap(struct seq_file *m, struct super_block *sb)
218222
return 0;
219223
}
220224

221-
static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
225+
static int show_on_disk_super(struct seq_file *m, void *unused)
222226
{
227+
struct super_block *sb = m->private;
223228
struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
224229
struct reiserfs_super_block *rs = sb_info->s_rs;
225230
int hash_code = DFL(s_hash_function_code);
@@ -261,8 +266,9 @@ static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
261266
return 0;
262267
}
263268

264-
static int show_oidmap(struct seq_file *m, struct super_block *sb)
269+
static int show_oidmap(struct seq_file *m, void *unused)
265270
{
271+
struct super_block *sb = m->private;
266272
struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
267273
struct reiserfs_super_block *rs = sb_info->s_rs;
268274
unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);
@@ -291,8 +297,9 @@ static int show_oidmap(struct seq_file *m, struct super_block *sb)
291297
return 0;
292298
}
293299

294-
static int show_journal(struct seq_file *m, struct super_block *sb)
300+
static int show_journal(struct seq_file *m, void *unused)
295301
{
302+
struct super_block *sb = m->private;
296303
struct reiserfs_sb_info *r = REISERFS_SB(sb);
297304
struct reiserfs_super_block *rs = r->s_rs;
298305
struct journal_params *jp = &rs->s_v1.s_journal;
@@ -383,92 +390,24 @@ static int show_journal(struct seq_file *m, struct super_block *sb)
383390
return 0;
384391
}
385392

386-
/* iterator */
387-
static int test_sb(struct super_block *sb, void *data)
388-
{
389-
return data == sb;
390-
}
391-
392-
static int set_sb(struct super_block *sb, void *data)
393-
{
394-
return -ENOENT;
395-
}
396-
397-
struct reiserfs_seq_private {
398-
struct super_block *sb;
399-
int (*show) (struct seq_file *, struct super_block *);
400-
};
401-
402-
static void *r_start(struct seq_file *m, loff_t * pos)
403-
{
404-
struct reiserfs_seq_private *priv = m->private;
405-
loff_t l = *pos;
406-
407-
if (l)
408-
return NULL;
409-
410-
if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, 0, priv->sb)))
411-
return NULL;
412-
413-
up_write(&priv->sb->s_umount);
414-
return priv->sb;
415-
}
416-
417-
static void *r_next(struct seq_file *m, void *v, loff_t * pos)
418-
{
419-
++*pos;
420-
if (v)
421-
deactivate_super(v);
422-
return NULL;
423-
}
424-
425-
static void r_stop(struct seq_file *m, void *v)
426-
{
427-
if (v)
428-
deactivate_super(v);
429-
}
430-
431-
static int r_show(struct seq_file *m, void *v)
432-
{
433-
struct reiserfs_seq_private *priv = m->private;
434-
return priv->show(m, v);
435-
}
436-
437-
static const struct seq_operations r_ops = {
438-
.start = r_start,
439-
.next = r_next,
440-
.stop = r_stop,
441-
.show = r_show,
442-
};
443-
444393
static int r_open(struct inode *inode, struct file *file)
445394
{
446-
struct reiserfs_seq_private *priv;
447-
int ret = seq_open_private(file, &r_ops,
448-
sizeof(struct reiserfs_seq_private));
449-
450-
if (!ret) {
451-
struct seq_file *m = file->private_data;
452-
priv = m->private;
453-
priv->sb = proc_get_parent_data(inode);
454-
priv->show = PDE_DATA(inode);
455-
}
456-
return ret;
395+
return single_open(file, PDE_DATA(inode),
396+
proc_get_parent_data(inode));
457397
}
458398

459399
static const struct file_operations r_file_operations = {
460400
.open = r_open,
461401
.read = seq_read,
462402
.llseek = seq_lseek,
463-
.release = seq_release_private,
464-
.owner = THIS_MODULE,
403+
.release = single_release,
465404
};
466405

467406
static struct proc_dir_entry *proc_info_root = NULL;
468407
static const char proc_info_root_name[] = "fs/reiserfs";
469408

470409
static void add_file(struct super_block *sb, char *name,
471-
int (*func) (struct seq_file *, struct super_block *))
410+
int (*func) (struct seq_file *, void *))
472411
{
473412
proc_create_data(name, 0, REISERFS_SB(sb)->procdir,
474413
&r_file_operations, func);

fs/reiserfs/super.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ int remove_save_link(struct inode *inode, int truncate)
499499
static void reiserfs_kill_sb(struct super_block *s)
500500
{
501501
if (REISERFS_SB(s)) {
502+
reiserfs_proc_info_done(s);
502503
/*
503504
* Force any pending inode evictions to occur now. Any
504505
* inodes to be removed that have extended attributes
@@ -554,8 +555,6 @@ static void reiserfs_put_super(struct super_block *s)
554555
REISERFS_SB(s)->reserved_blocks);
555556
}
556557

557-
reiserfs_proc_info_done(s);
558-
559558
reiserfs_write_unlock(s);
560559
mutex_destroy(&REISERFS_SB(s)->lock);
561560
kfree(s->s_fs_info);

0 commit comments

Comments
 (0)