From 0d5cadb87e0fa764db7fa0b78d8a6f173cb475a1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 4 May 2013 14:40:51 -0400 Subject: [PATCH 01/16] do_mount(): fix a leak introduced in 3.9 ("mount: consolidate permission checks") Cc: stable@vger.kernel.org Bisected-by: Michael Leun Signed-off-by: Al Viro --- fs/namespace.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index b4f96a5230a3..b68eef2d592a 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2284,12 +2284,11 @@ long do_mount(const char *dev_name, const char *dir_name, retval = security_sb_mount(dev_name, &path, type_page, flags, data_page); + if (!retval && !may_mount()) + retval = -EPERM; if (retval) goto dput_out; - if (!may_mount()) - return -EPERM; - /* Default to relatime unless overriden */ if (!(flags & MS_NOATIME)) mnt_flags |= MNT_RELATIME; From e86d35c38e37eb64cb5d11933c42a2a72f16ce23 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 4 May 2013 14:45:54 -0400 Subject: [PATCH 02/16] do_coredump(): don't wait for thaw if coredump has already been interrupted Signed-off-by: Al Viro --- fs/coredump.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/coredump.c b/fs/coredump.c index a9abe313e8d5..dafafbafa731 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -654,10 +654,11 @@ void do_coredump(siginfo_t *siginfo) goto close_fail; if (displaced) put_files_struct(displaced); - file_start_write(cprm.file); - core_dumped = !dump_interrupted() && binfmt->core_dump(&cprm); - file_end_write(cprm.file); - + if (!dump_interrupted()) { + file_start_write(cprm.file); + core_dumped = binfmt->core_dump(&cprm); + file_end_write(cprm.file); + } if (ispipe && core_pipe_limit) wait_for_dump_helpers(cprm.file); close_fail: From 60b7bf4e61dd45e2fe06bd16ba04984405b564f1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 4 May 2013 14:46:28 -0400 Subject: [PATCH 03/16] more mode_t whack-a-mole... Signed-off-by: Al Viro --- drivers/hwmon/abx500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/abx500.c b/drivers/hwmon/abx500.c index b4ad87b31a37..eee1134274c8 100644 --- a/drivers/hwmon/abx500.c +++ b/drivers/hwmon/abx500.c @@ -260,7 +260,7 @@ static ssize_t show_max_alarm(struct device *dev, return sprintf(buf, "%d\n", data->max_alarm[attr->index]); } -static mode_t abx500_attrs_visible(struct kobject *kobj, +static umode_t abx500_attrs_visible(struct kobject *kobj, struct attribute *attr, int n) { struct device *dev = container_of(kobj, struct device, kobj); From e765acb4673f377c53505c01279c040906bd706e Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 3 May 2013 22:20:38 +0200 Subject: [PATCH 04/16] nubus: Kill nubus_proc_detach_device() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 59d8053f1e16904d54ed7469d4b36801ea6b8f2c ("proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h") broke Apple NuBus support: drivers/nubus/proc.c: In function ‘nubus_proc_detach_device’: drivers/nubus/proc.c:156: error: dereferencing pointer to incomplete type drivers/nubus/proc.c:158: error: dereferencing pointer to incomplete type Fortunately nubus_proc_detach_device() is unused, and appears to have never been used, so just remove it. Signed-off-by: Geert Uytterhoeven Signed-off-by: Al Viro --- drivers/nubus/proc.c | 15 --------------- include/linux/nubus.h | 1 - 2 files changed, 16 deletions(-) diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c index b8286ed65919..5371b374f1fe 100644 --- a/drivers/nubus/proc.c +++ b/drivers/nubus/proc.c @@ -147,21 +147,6 @@ int nubus_proc_attach_device(struct nubus_dev *dev) } EXPORT_SYMBOL(nubus_proc_attach_device); -/* FIXME: this is certainly broken! */ -int nubus_proc_detach_device(struct nubus_dev *dev) -{ - struct proc_dir_entry *e; - - if ((e = dev->procdir)) { - if (atomic_read(&e->count)) - return -EBUSY; - remove_proc_entry(e->name, proc_bus_nubus_dir); - dev->procdir = NULL; - } - return 0; -} -EXPORT_SYMBOL(nubus_proc_detach_device); - /* * /proc/nubus stuff */ diff --git a/include/linux/nubus.h b/include/linux/nubus.h index b3740527571a..6165b2c62040 100644 --- a/include/linux/nubus.h +++ b/include/linux/nubus.h @@ -87,7 +87,6 @@ static inline void nubus_proc_init(void) {} #endif int get_nubus_list(char *buf); int nubus_proc_attach_device(struct nubus_dev *dev); -int nubus_proc_detach_device(struct nubus_dev *dev); /* If we need more precision we can add some more of these */ struct nubus_dev* nubus_find_device(unsigned short category, unsigned short type, From 9dcc26cf67fb7db7613290e62eeed6c4276c75ce Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 10 Apr 2013 13:52:09 +0200 Subject: [PATCH 05/16] sun3_scsi: add ->show_info() Based on Al's changes to atari_scsi. Signed-off-by: Geert Uytterhoeven Signed-off-by: Al Viro --- drivers/scsi/sun3_NCR5380.c | 183 +++++++++++++++--------------------- drivers/scsi/sun3_scsi.c | 1 + drivers/scsi/sun3_scsi.h | 2 +- 3 files changed, 80 insertions(+), 106 deletions(-) diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index 7e12a2e4e0a3..636bbe0ea84c 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c @@ -661,122 +661,95 @@ static void __init NCR5380_print_options (struct Scsi_Host *instance) * Inputs : instance, pointer to this instance. */ -static void NCR5380_print_status (struct Scsi_Host *instance) +static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd) { - char *pr_bfr; - char *start; - int len; - - NCR_PRINT(NDEBUG_ANY); - NCR_PRINT_PHASE(NDEBUG_ANY); - - pr_bfr = (char *) __get_free_page(GFP_ATOMIC); - if (!pr_bfr) { - printk("NCR5380_print_status: no memory for print buffer\n"); - return; - } - len = NCR5380_proc_info(instance, pr_bfr, &start, 0, PAGE_SIZE, 0); - pr_bfr[len] = 0; - printk("\n%s\n", pr_bfr); - free_page((unsigned long) pr_bfr); + int i, s; + unsigned char *command; + printk("scsi%d: destination target %d, lun %d\n", + H_NO(cmd), cmd->device->id, cmd->device->lun); + printk(KERN_CONT " command = "); + command = cmd->cmnd; + printk(KERN_CONT "%2d (0x%02x)", command[0], command[0]); + for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) + printk(KERN_CONT " %02x", command[i]); + printk("\n"); } - -/******************************************/ -/* - * /proc/scsi/[dtc pas16 t128 generic]/[0-ASC_NUM_BOARD_SUPPORTED] - * - * *buffer: I/O buffer - * **start: if inout == FALSE pointer into buffer where user read should start - * offset: current offset - * length: length of buffer - * hostno: Scsi_Host host_no - * inout: TRUE - user is writing; FALSE - user is reading - * - * Return the number of bytes read from or written -*/ - -#undef SPRINTF -#define SPRINTF(fmt,args...) \ - do { if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \ - pos += sprintf(pos, fmt , ## args); } while(0) -static -char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer, - int length); - -static int NCR5380_proc_info(struct Scsi_Host *instance, char *buffer, - char **start, off_t offset, int length, int inout) +static void NCR5380_print_status(struct Scsi_Host *instance) { - char *pos = buffer; - struct NCR5380_hostdata *hostdata; - struct scsi_cmnd *ptr; - unsigned long flags; - off_t begin = 0; -#define check_offset() \ - do { \ - if (pos - buffer < offset - begin) { \ - begin += pos - buffer; \ - pos = buffer; \ - } \ - } while (0) + struct NCR5380_hostdata *hostdata; + Scsi_Cmnd *ptr; + unsigned long flags; - hostdata = (struct NCR5380_hostdata *)instance->hostdata; + NCR_PRINT(NDEBUG_ANY); + NCR_PRINT_PHASE(NDEBUG_ANY); - if (inout) { /* Has data been written to the file ? */ - return(-ENOSYS); /* Currently this is a no-op */ - } - SPRINTF("NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); - check_offset(); - local_irq_save(flags); - SPRINTF("NCR5380: coroutine is%s running.\n", main_running ? "" : "n't"); - check_offset(); - if (!hostdata->connected) - SPRINTF("scsi%d: no currently connected command\n", HOSTNO); - else - pos = lprint_Scsi_Cmnd ((struct scsi_cmnd *) hostdata->connected, - pos, buffer, length); - SPRINTF("scsi%d: issue_queue\n", HOSTNO); - check_offset(); - for (ptr = (struct scsi_cmnd *) hostdata->issue_queue; ptr; ptr = NEXT(ptr)) - { - pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); - check_offset(); - } + hostdata = (struct NCR5380_hostdata *)instance->hostdata; - SPRINTF("scsi%d: disconnected_queue\n", HOSTNO); - check_offset(); - for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr; - ptr = NEXT(ptr)) { - pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); - check_offset(); - } + printk("\nNCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); + local_irq_save(flags); + printk("NCR5380: coroutine is%s running.\n", + main_running ? "" : "n't"); + if (!hostdata->connected) + printk("scsi%d: no currently connected command\n", HOSTNO); + else + lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected); + printk("scsi%d: issue_queue\n", HOSTNO); + for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) + lprint_Scsi_Cmnd(ptr); - local_irq_restore(flags); - *start = buffer + (offset - begin); - if (pos - buffer < offset - begin) + printk("scsi%d: disconnected_queue\n", HOSTNO); + for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; + ptr = NEXT(ptr)) + lprint_Scsi_Cmnd(ptr); + + local_irq_restore(flags); + printk("\n"); +} + +static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m) +{ + int i, s; + unsigned char *command; + seq_printf(m, "scsi%d: destination target %d, lun %d\n", + H_NO(cmd), cmd->device->id, cmd->device->lun); + seq_printf(m, " command = "); + command = cmd->cmnd; + seq_printf(m, "%2d (0x%02x)", command[0], command[0]); + for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) + seq_printf(m, " %02x", command[i]); + seq_printf(m, "\n"); +} + +static int NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance) +{ + struct NCR5380_hostdata *hostdata; + Scsi_Cmnd *ptr; + unsigned long flags; + + hostdata = (struct NCR5380_hostdata *)instance->hostdata; + + seq_printf(m, "NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); + local_irq_save(flags); + seq_printf(m, "NCR5380: coroutine is%s running.\n", + main_running ? "" : "n't"); + if (!hostdata->connected) + seq_printf(m, "scsi%d: no currently connected command\n", HOSTNO); + else + show_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m); + seq_printf(m, "scsi%d: issue_queue\n", HOSTNO); + for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) + show_Scsi_Cmnd(ptr, m); + + seq_printf(m, "scsi%d: disconnected_queue\n", HOSTNO); + for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; + ptr = NEXT(ptr)) + show_Scsi_Cmnd(ptr, m); + + local_irq_restore(flags); return 0; - else if (pos - buffer - (offset - begin) < length) - return pos - buffer - (offset - begin); - return length; } -static char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer, - int length) -{ - int i, s; - unsigned char *command; - SPRINTF("scsi%d: destination target %d, lun %d\n", - H_NO(cmd), cmd->device->id, cmd->device->lun); - SPRINTF(" command = "); - command = cmd->cmnd; - SPRINTF("%2d (0x%02x)", command[0], command[0]); - for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) - SPRINTF(" %02x", command[i]); - SPRINTF("\n"); - return pos; -} - - /* * Function : void NCR5380_init (struct Scsi_Host *instance) * diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c index 6e25889db9d4..e2c009b033ce 100644 --- a/drivers/scsi/sun3_scsi.c +++ b/drivers/scsi/sun3_scsi.c @@ -626,6 +626,7 @@ static int sun3scsi_dma_finish(int write_flag) #include "sun3_NCR5380.c" static struct scsi_host_template driver_template = { + .show_info = sun3scsi_show_info, .name = SUN3_SCSI_NAME, .detect = sun3scsi_detect, .release = sun3scsi_release, diff --git a/drivers/scsi/sun3_scsi.h b/drivers/scsi/sun3_scsi.h index bcefd8458e65..a8da9c710fea 100644 --- a/drivers/scsi/sun3_scsi.h +++ b/drivers/scsi/sun3_scsi.h @@ -100,7 +100,7 @@ static int sun3scsi_release (struct Scsi_Host *); #define NCR5380_queue_command sun3scsi_queue_command #define NCR5380_bus_reset sun3scsi_bus_reset #define NCR5380_abort sun3scsi_abort -#define NCR5380_proc_info sun3scsi_proc_info +#define NCR5380_show_info sun3scsi_show_info #define NCR5380_dma_xfer_len(i, cmd, phase) \ sun3scsi_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1) From 5ae98f1589e076e4b314fc54ae2beac58842ddc2 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Sat, 4 May 2013 00:11:23 +0200 Subject: [PATCH 06/16] fs: Fix hang with BSD accounting on frozen filesystem When BSD process accounting is enabled and logs information to a filesystem which gets frozen, system easily becomes unusable because each attempt to account process information blocks. Thus e.g. every task gets blocked in exit. It seems better to drop accounting information (which can already happen when filesystem is running out of space) instead of locking system up. So we just skip the write if the filesystem is frozen. Reported-by: Nikola Ciprich Signed-off-by: Jan Kara Signed-off-by: Al Viro --- include/linux/fs.h | 7 +++++++ kernel/acct.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index e8cd6b839675..b5a24ba83b6f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2227,6 +2227,13 @@ static inline void file_start_write(struct file *file) __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true); } +static inline bool file_start_write_trylock(struct file *file) +{ + if (!S_ISREG(file_inode(file)->i_mode)) + return true; + return __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, false); +} + static inline void file_end_write(struct file *file) { if (!S_ISREG(file_inode(file)->i_mode)) diff --git a/kernel/acct.c b/kernel/acct.c index 85389fe2abd0..8d6e145138bb 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -539,11 +539,16 @@ static void do_acct_process(struct bsd_acct_struct *acct, ac.ac_rw = encode_comp_t(ac.ac_io / 1024); ac.ac_swaps = encode_comp_t(0); + /* + * Get freeze protection. If the fs is frozen, just skip the write + * as we could deadlock the system otherwise. + */ + if (!file_start_write_trylock(file)) + goto out; /* * Kernel segment override to datasegment and write it * to the accounting file. */ - file_start_write(file); fs = get_fs(); set_fs(KERNEL_DS); /* From c0bd14af51a470895448f88edd1315c4fa0b0d27 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 4 May 2013 15:00:54 -0400 Subject: [PATCH 07/16] kill fs/read_write.h fs/compat.c doesn't need it anymore, so let's just move the remaining contents (two typedefs) into fs/read_write.c Signed-off-by: Al Viro --- fs/compat.c | 2 -- fs/read_write.c | 5 ++++- fs/read_write.h | 9 --------- 3 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 fs/read_write.h diff --git a/fs/compat.c b/fs/compat.c index d0560c93973d..93f7d021b716 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -67,8 +67,6 @@ int compat_printk(const char *fmt, ...) return ret; } -#include "read_write.h" - /* * Not all architectures have sys_utime, so implement this in terms * of sys_utimes. diff --git a/fs/read_write.c b/fs/read_write.c index 605dbbcb1973..90ba3b350e50 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -16,12 +16,15 @@ #include #include #include -#include "read_write.h" #include "internal.h" #include #include +typedef ssize_t (*io_fn_t)(struct file *, char __user *, size_t, loff_t *); +typedef ssize_t (*iov_fn_t)(struct kiocb *, const struct iovec *, + unsigned long, loff_t); + const struct file_operations generic_ro_fops = { .llseek = generic_file_llseek, .read = do_sync_read, diff --git a/fs/read_write.h b/fs/read_write.h deleted file mode 100644 index 0ec530d9305b..000000000000 --- a/fs/read_write.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * This file is only for sharing some helpers from read_write.c with compat.c. - * Don't use anywhere else. - */ - - -typedef ssize_t (*io_fn_t)(struct file *, char __user *, size_t, loff_t *); -typedef ssize_t (*iov_fn_t)(struct kiocb *, const struct iovec *, - unsigned long, loff_t); From 6b13eb1baa17b8746f96bd536d2897ec86e823d9 Mon Sep 17 00:00:00 2001 From: Han Shen Date: Fri, 12 Apr 2013 16:26:58 -0700 Subject: [PATCH 08/16] Removed unused typedef to avoid "unused local typedef" warnings. Fix warnings about unused local typedefs (reported by gcc 4.8). Signed-off-by: Han Shen (shenhan@google.com) Change-Id: I4bccc234f1390daa808d2b309ed112e20c0ac096 Signed-off-by: Al Viro --- fs/compat_ioctl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 3ced75f765ca..996cdc5abb85 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -608,7 +608,6 @@ struct serial_struct32 { static int serial_struct_ioctl(unsigned fd, unsigned cmd, struct serial_struct32 __user *ss32) { - typedef struct serial_struct SS; typedef struct serial_struct32 SS32; int err; struct serial_struct ss; From 61572bb1f40b9bec0acbb4d7bc0f5b33739f1ab1 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Mon, 15 Apr 2013 14:13:21 +0800 Subject: [PATCH 09/16] fs: remove dentry_lru_prune() When pruning a dentry, its ancestor dentry can also be pruned. But the ancestor dentry does not go through dput(), so it does not get put on the dentry LRU. Hence associating d_prune with removing the dentry from the LRU is the wrong. The fix is remove dentry_lru_prune(). Call file system's d_prune() callback directly when pruning dentries. Signed-off-by: Yan, Zheng Signed-off-by: Al Viro --- fs/dcache.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index e689268046c3..a161ebcab9d2 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -337,23 +337,6 @@ static void dentry_lru_del(struct dentry *dentry) } } -/* - * Remove a dentry that is unreferenced and about to be pruned - * (unhashed and destroyed) from the LRU, and inform the file system. - * This wrapper should be called _prior_ to unhashing a victim dentry. - */ -static void dentry_lru_prune(struct dentry *dentry) -{ - if (!list_empty(&dentry->d_lru)) { - if (dentry->d_flags & DCACHE_OP_PRUNE) - dentry->d_op->d_prune(dentry); - - spin_lock(&dcache_lru_lock); - __dentry_lru_del(dentry); - spin_unlock(&dcache_lru_lock); - } -} - static void dentry_lru_move_list(struct dentry *dentry, struct list_head *list) { spin_lock(&dcache_lru_lock); @@ -486,11 +469,13 @@ relock: if (ref) dentry->d_count--; /* - * if dentry was on the d_lru list delete it from there. * inform the fs via d_prune that this dentry is about to be * unhashed and destroyed. */ - dentry_lru_prune(dentry); + if (dentry->d_flags & DCACHE_OP_PRUNE) + dentry->d_op->d_prune(dentry); + + dentry_lru_del(dentry); /* if it was on the hash then remove it */ __d_drop(dentry); return d_kill(dentry, parent); @@ -919,11 +904,13 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry) struct inode *inode; /* - * remove the dentry from the lru, and inform - * the fs that this dentry is about to be + * inform the fs that this dentry is about to be * unhashed and destroyed. */ - dentry_lru_prune(dentry); + if (dentry->d_flags & DCACHE_OP_PRUNE) + dentry->d_op->d_prune(dentry); + + dentry_lru_del(dentry); __d_shrink(dentry); if (dentry->d_count != 0) { From b1983cd897ec06080ec4884989c6a3f1e7ee7dce Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 4 May 2013 15:18:53 -0400 Subject: [PATCH 10/16] create_mnt_ns: unidiomatic use of list_add() while list_add(A, B) and list_add(B, A) are equivalent when both A and B are guaranteed to be empty, the usual idiom is list_add(what, where), not the other way round... Not a bug per se, but only by accident and it makes RTFS harder for no good reason. Spotted-by: Rajat Sharma Signed-off-by: Al Viro --- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index b68eef2d592a..7b1ca9ba0b0a 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2463,7 +2463,7 @@ static struct mnt_namespace *create_mnt_ns(struct vfsmount *m) struct mount *mnt = real_mount(m); mnt->mnt_ns = new_ns; new_ns->root = mnt; - list_add(&new_ns->list, &mnt->mnt_list); + list_add(&mnt->mnt_list, &new_ns->list); } else { mntput(m); } From 75fc0cf6af45e5de251caa9421b3c3d1bdc273c8 Mon Sep 17 00:00:00 2001 From: Syam Sidhardhan Date: Fri, 15 Feb 2013 02:24:32 +0530 Subject: [PATCH 11/16] proc_devtree: Replace include linux/module.h with linux/export.h Since it uses only THIS_MODULE macro, include is the right to go here. Signed-off-by: Syam Sidhardhan Signed-off-by: Al Viro --- fs/proc/proc_devtree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c index 505afc950e0a..106a83570630 100644 --- a/fs/proc/proc_devtree.c +++ b/fs/proc/proc_devtree.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include From 9ed53b12a9a60f4d52228335e76cbbdf0c7e37fb Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 12 Mar 2013 00:10:50 +0800 Subject: [PATCH 12/16] vfs: use list_move instead of list_del/list_add Using list_move() instead of list_del() + list_add(). Signed-off-by: Wei Yongjun Signed-off-by: Al Viro --- fs/dcache.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index a161ebcab9d2..f09b9085f7d8 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2397,8 +2397,7 @@ static void __d_materialise_dentry(struct dentry *dentry, struct dentry *anon) dentry->d_parent = dentry; list_del_init(&dentry->d_u.d_child); anon->d_parent = dparent; - list_del(&anon->d_u.d_child); - list_add(&anon->d_u.d_child, &dparent->d_subdirs); + list_move(&anon->d_u.d_child, &dparent->d_subdirs); write_seqcount_end(&dentry->d_seq); write_seqcount_end(&anon->d_seq); From 9dcc5e8a4635d6a0b20273e3db21507ff02764ea Mon Sep 17 00:00:00 2001 From: James Hogan Date: Wed, 27 Mar 2013 10:47:12 +0000 Subject: [PATCH 13/16] hostfs: remove "will unlock" comment A "will unlock" comment was added to hostfs in the following commit, along with a spinlock: Commit e9193059b1b3733695d5b80e667778311695aa73 ("hostfs: fix races in dentry_name() and inode_name()"). But the spinlock was subsequently removed in the following commit: Commit ec2447c278ee973d35f38e53ca16ba7f965ae33d ("hostfs: simplify locking"). Since the comment is no longer applicable, remove it. Reported-by: Al Viro Signed-off-by: James Hogan Cc: Nick Piggin Signed-off-by: Al Viro --- fs/hostfs/hostfs_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 0f6e52d22b84..95b9c87cb24a 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -121,7 +121,7 @@ static char *dentry_name(struct dentry *dentry) if (!name) return NULL; - return __dentry_name(dentry, name); /* will unlock */ + return __dentry_name(dentry, name); } static char *inode_name(struct inode *ino) From 2b3b9bb03a9fb1e4c72947cc235771c6455ec7c9 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Wed, 27 Mar 2013 10:47:13 +0000 Subject: [PATCH 14/16] hostfs: move HOSTFS_SUPER_MAGIC to Move HOSTFS_SUPER_MAGIC to to be with it's magical friends from other file systems. Reported-by: Al Viro Signed-off-by: James Hogan Signed-off-by: Al Viro --- fs/hostfs/hostfs_kern.c | 3 +-- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 95b9c87cb24a..f2372ef80850 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -45,8 +46,6 @@ static const struct dentry_operations hostfs_dentry_ops = { static char *root_ino = ""; static int append = 0; -#define HOSTFS_SUPER_MAGIC 0x00c0ffee - static const struct inode_operations hostfs_iops; static const struct inode_operations hostfs_dir_iops; static const struct inode_operations hostfs_link_iops; diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 249df3720be2..2944278a8ba7 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -30,6 +30,7 @@ #define JFFS2_SUPER_MAGIC 0x72b6 #define PSTOREFS_MAGIC 0x6165676C #define EFIVARFS_MAGIC 0xde5e81e4 +#define HOSTFS_SUPER_MAGIC 0x00c0ffee #define MINIX_SUPER_MAGIC 0x137F /* minix v1 fs, 14 char names */ #define MINIX_SUPER_MAGIC2 0x138F /* minix v1 fs, 30 char names */ From 371fdab10033528c42f64fc244c30d67b15e529d Mon Sep 17 00:00:00 2001 From: James Hogan Date: Wed, 27 Mar 2013 10:47:14 +0000 Subject: [PATCH 15/16] hostfs: use kmalloc instead of kzalloc The inode info structure is zeroed at allocation with kzalloc, and then all but one of the fields (including the largest, vfs_inode) are initialised explicitly. Switch to using kmalloc and initialise the remaining field too. Reported-by: Al Viro Signed-off-by: James Hogan Signed-off-by: Al Viro --- fs/hostfs/hostfs_kern.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index f2372ef80850..32f35f187989 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -228,10 +228,11 @@ static struct inode *hostfs_alloc_inode(struct super_block *sb) { struct hostfs_inode_info *hi; - hi = kzalloc(sizeof(*hi), GFP_KERNEL); + hi = kmalloc(sizeof(*hi), GFP_KERNEL); if (hi == NULL) return NULL; hi->fd = -1; + hi->mode = 0; inode_init_once(&hi->vfs_inode); return &hi->vfs_inode; } From 4fe56e80825b47083100b2a98843df98fc7d4f07 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 4 May 2013 16:00:50 -0400 Subject: [PATCH 16/16] xtensa simdisk: fix braino in "xtensa simdisk: switch to proc_create_data()" Signed-off-by: Al Viro --- arch/xtensa/platforms/iss/simdisk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/xtensa/platforms/iss/simdisk.c b/arch/xtensa/platforms/iss/simdisk.c index 4a06d70ddf5e..88608cc11b8c 100644 --- a/arch/xtensa/platforms/iss/simdisk.c +++ b/arch/xtensa/platforms/iss/simdisk.c @@ -231,7 +231,7 @@ static ssize_t proc_read_simdisk(struct file *file, char __user *buf, } static ssize_t proc_write_simdisk(struct file *file, const char __user *buf, - size_t size, loff_t *ppos) + size_t count, loff_t *ppos) { char *tmp = kmalloc(count + 1, GFP_KERNEL); struct simdisk *dev = PDE_DATA(file_inode(file));