aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-20 23:00:43 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-20 23:00:43 -0500
commit4c9a44aebeaef35570a67aed17b72a2cf8d0b219 (patch)
treeabb874fe7f50671627b282f6c7fb58db5e75a2e3 /fs
parent1f0377ff088ed2971c57debc9b0c3b846ec431fd (diff)
parentcfde819088422503b5c69e03ab7bb90f87121d4d (diff)
Merge branch 'akpm' (Andrew's patch-bomb)
Merge the rest of Andrew's patches for -rc1: "A bunch of fixes and misc missed-out-on things. That'll do for -rc1. I still have a batch of IPC patches which still have a possible bug report which I'm chasing down." * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (25 commits) keys: use keyring_alloc() to create module signing keyring keys: fix unreachable code sendfile: allows bypassing of notifier events SGI-XP: handle non-fatal traps fat: fix incorrect function comment Documentation: ABI: remove testing/sysfs-devices-node proc: fix inconsistent lock state linux/kernel.h: fix DIV_ROUND_CLOSEST with unsigned divisors memcg: don't register hotcpu notifier from ->css_alloc() checkpatch: warn on uapi #includes that #include <uapi/... revert "rtc: recycle id when unloading a rtc driver" mm: clean up transparent hugepage sysfs error messages hfsplus: add error message for the case of failure of sync fs in delayed_sync_fs() method hfsplus: rework processing of hfs_btree_write() returned error hfsplus: rework processing errors in hfsplus_free_extents() hfsplus: avoid crash on failed block map free kcmp: include linux/ptrace.h drivers/rtc/rtc-imxdi.c: must include <linux/spinlock.h> mm: cma: WARN if freed memory is still in use exec: do not leave bprm->interp on stack ...
Diffstat (limited to 'fs')
-rw-r--r--fs/binfmt_misc.c5
-rw-r--r--fs/binfmt_script.c4
-rw-r--r--fs/exec.c15
-rw-r--r--fs/fat/dir.c5
-rw-r--r--fs/fat/inode.c2
-rw-r--r--fs/fat/misc.c4
-rw-r--r--fs/hfsplus/bitmap.c13
-rw-r--r--fs/hfsplus/btree.c5
-rw-r--r--fs/hfsplus/extents.c24
-rw-r--r--fs/hfsplus/hfsplus_fs.h2
-rw-r--r--fs/hfsplus/super.c15
-rw-r--r--fs/proc/generic.c12
-rw-r--r--fs/read_write.c2
13 files changed, 85 insertions, 23 deletions
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 9be335fb8a7..0c8869fdd14 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -172,7 +172,10 @@ static int load_misc_binary(struct linux_binprm *bprm)
172 goto _error; 172 goto _error;
173 bprm->argc ++; 173 bprm->argc ++;
174 174
175 bprm->interp = iname; /* for binfmt_script */ 175 /* Update interp in case binfmt_script needs it. */
176 retval = bprm_change_interp(iname, bprm);
177 if (retval < 0)
178 goto _error;
176 179
177 interp_file = open_exec (iname); 180 interp_file = open_exec (iname);
178 retval = PTR_ERR (interp_file); 181 retval = PTR_ERR (interp_file);
diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c
index 1610a91637e..5027a3e1492 100644
--- a/fs/binfmt_script.c
+++ b/fs/binfmt_script.c
@@ -80,7 +80,9 @@ static int load_script(struct linux_binprm *bprm)
80 retval = copy_strings_kernel(1, &i_name, bprm); 80 retval = copy_strings_kernel(1, &i_name, bprm);
81 if (retval) return retval; 81 if (retval) return retval;
82 bprm->argc++; 82 bprm->argc++;
83 bprm->interp = interp; 83 retval = bprm_change_interp(interp, bprm);
84 if (retval < 0)
85 return retval;
84 86
85 /* 87 /*
86 * OK, now restart the process with the interpreter's dentry. 88 * OK, now restart the process with the interpreter's dentry.
diff --git a/fs/exec.c b/fs/exec.c
index af8ec80f816..18c45cac368 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1175,9 +1175,24 @@ void free_bprm(struct linux_binprm *bprm)
1175 mutex_unlock(&current->signal->cred_guard_mutex); 1175 mutex_unlock(&current->signal->cred_guard_mutex);
1176 abort_creds(bprm->cred); 1176 abort_creds(bprm->cred);
1177 } 1177 }
1178 /* If a binfmt changed the interp, free it. */
1179 if (bprm->interp != bprm->filename)
1180 kfree(bprm->interp);
1178 kfree(bprm); 1181 kfree(bprm);
1179} 1182}
1180 1183
1184int bprm_change_interp(char *interp, struct linux_binprm *bprm)
1185{
1186 /* If a binfmt changed the interp, free it first. */
1187 if (bprm->interp != bprm->filename)
1188 kfree(bprm->interp);
1189 bprm->interp = kstrdup(interp, GFP_KERNEL);
1190 if (!bprm->interp)
1191 return -ENOMEM;
1192 return 0;
1193}
1194EXPORT_SYMBOL(bprm_change_interp);
1195
1181/* 1196/*
1182 * install the new credentials for this executable 1197 * install the new credentials for this executable
1183 */ 1198 */
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 2a182342442..58bf744dbf3 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -461,8 +461,7 @@ static int fat_parse_short(struct super_block *sb,
461} 461}
462 462
463/* 463/*
464 * Return values: negative -> error, 0 -> not found, positive -> found, 464 * Return values: negative -> error/not found, 0 -> found.
465 * value is the total amount of slots, including the shortname entry.
466 */ 465 */
467int fat_search_long(struct inode *inode, const unsigned char *name, 466int fat_search_long(struct inode *inode, const unsigned char *name,
468 int name_len, struct fat_slot_info *sinfo) 467 int name_len, struct fat_slot_info *sinfo)
@@ -1255,7 +1254,7 @@ int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
1255 1254
1256 sinfo->nr_slots = nr_slots; 1255 sinfo->nr_slots = nr_slots;
1257 1256
1258 /* First stage: search free direcotry entries */ 1257 /* First stage: search free directory entries */
1259 free_slots = nr_bhs = 0; 1258 free_slots = nr_bhs = 0;
1260 bh = prev = NULL; 1259 bh = prev = NULL;
1261 pos = 0; 1260 pos = 0;
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 35806813ea4..f8f491677a4 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1344,7 +1344,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
1344 sbi->dir_entries = get_unaligned_le16(&b->dir_entries); 1344 sbi->dir_entries = get_unaligned_le16(&b->dir_entries);
1345 if (sbi->dir_entries & (sbi->dir_per_block - 1)) { 1345 if (sbi->dir_entries & (sbi->dir_per_block - 1)) {
1346 if (!silent) 1346 if (!silent)
1347 fat_msg(sb, KERN_ERR, "bogus directroy-entries per block" 1347 fat_msg(sb, KERN_ERR, "bogus directory-entries per block"
1348 " (%u)", sbi->dir_entries); 1348 " (%u)", sbi->dir_entries);
1349 brelse(bh); 1349 brelse(bh);
1350 goto out_invalid; 1350 goto out_invalid;
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index 5eb600dc43a..359d307b550 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -135,6 +135,10 @@ int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster)
135 } 135 }
136 if (ret < 0) 136 if (ret < 0)
137 return ret; 137 return ret;
138 /*
139 * FIXME:Although we can add this cache, fat_cache_add() is
140 * assuming to be called after linear search with fat_cache_id.
141 */
138// fat_cache_add(inode, new_fclus, new_dclus); 142// fat_cache_add(inode, new_fclus, new_dclus);
139 } else { 143 } else {
140 MSDOS_I(inode)->i_start = new_dclus; 144 MSDOS_I(inode)->i_start = new_dclus;
diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c
index 4cfbe2edd29..6feefc0cb48 100644
--- a/fs/hfsplus/bitmap.c
+++ b/fs/hfsplus/bitmap.c
@@ -176,12 +176,14 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
176 dprint(DBG_BITMAP, "block_free: %u,%u\n", offset, count); 176 dprint(DBG_BITMAP, "block_free: %u,%u\n", offset, count);
177 /* are all of the bits in range? */ 177 /* are all of the bits in range? */
178 if ((offset + count) > sbi->total_blocks) 178 if ((offset + count) > sbi->total_blocks)
179 return -2; 179 return -ENOENT;
180 180
181 mutex_lock(&sbi->alloc_mutex); 181 mutex_lock(&sbi->alloc_mutex);
182 mapping = sbi->alloc_file->i_mapping; 182 mapping = sbi->alloc_file->i_mapping;
183 pnr = offset / PAGE_CACHE_BITS; 183 pnr = offset / PAGE_CACHE_BITS;
184 page = read_mapping_page(mapping, pnr, NULL); 184 page = read_mapping_page(mapping, pnr, NULL);
185 if (IS_ERR(page))
186 goto kaboom;
185 pptr = kmap(page); 187 pptr = kmap(page);
186 curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32; 188 curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32;
187 end = pptr + PAGE_CACHE_BITS / 32; 189 end = pptr + PAGE_CACHE_BITS / 32;
@@ -214,6 +216,8 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
214 set_page_dirty(page); 216 set_page_dirty(page);
215 kunmap(page); 217 kunmap(page);
216 page = read_mapping_page(mapping, ++pnr, NULL); 218 page = read_mapping_page(mapping, ++pnr, NULL);
219 if (IS_ERR(page))
220 goto kaboom;
217 pptr = kmap(page); 221 pptr = kmap(page);
218 curr = pptr; 222 curr = pptr;
219 end = pptr + PAGE_CACHE_BITS / 32; 223 end = pptr + PAGE_CACHE_BITS / 32;
@@ -232,4 +236,11 @@ out:
232 mutex_unlock(&sbi->alloc_mutex); 236 mutex_unlock(&sbi->alloc_mutex);
233 237
234 return 0; 238 return 0;
239
240kaboom:
241 printk(KERN_CRIT "hfsplus: unable to mark blocks free: error %ld\n",
242 PTR_ERR(page));
243 mutex_unlock(&sbi->alloc_mutex);
244
245 return -EIO;
235} 246}
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index 21023d9f8ff..685d07d0ed1 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -159,7 +159,7 @@ void hfs_btree_close(struct hfs_btree *tree)
159 kfree(tree); 159 kfree(tree);
160} 160}
161 161
162void hfs_btree_write(struct hfs_btree *tree) 162int hfs_btree_write(struct hfs_btree *tree)
163{ 163{
164 struct hfs_btree_header_rec *head; 164 struct hfs_btree_header_rec *head;
165 struct hfs_bnode *node; 165 struct hfs_bnode *node;
@@ -168,7 +168,7 @@ void hfs_btree_write(struct hfs_btree *tree)
168 node = hfs_bnode_find(tree, 0); 168 node = hfs_bnode_find(tree, 0);
169 if (IS_ERR(node)) 169 if (IS_ERR(node))
170 /* panic? */ 170 /* panic? */
171 return; 171 return -EIO;
172 /* Load the header */ 172 /* Load the header */
173 page = node->page[0]; 173 page = node->page[0];
174 head = (struct hfs_btree_header_rec *)(kmap(page) + 174 head = (struct hfs_btree_header_rec *)(kmap(page) +
@@ -186,6 +186,7 @@ void hfs_btree_write(struct hfs_btree *tree)
186 kunmap(page); 186 kunmap(page);
187 set_page_dirty(page); 187 set_page_dirty(page);
188 hfs_bnode_put(node); 188 hfs_bnode_put(node);
189 return 0;
189} 190}
190 191
191static struct hfs_bnode *hfs_bmap_new_bmap(struct hfs_bnode *prev, u32 idx) 192static struct hfs_bnode *hfs_bmap_new_bmap(struct hfs_bnode *prev, u32 idx)
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index 5849e3ef35c..eba76eab6d6 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -329,6 +329,7 @@ static int hfsplus_free_extents(struct super_block *sb,
329{ 329{
330 u32 count, start; 330 u32 count, start;
331 int i; 331 int i;
332 int err = 0;
332 333
333 hfsplus_dump_extent(extent); 334 hfsplus_dump_extent(extent);
334 for (i = 0; i < 8; extent++, i++) { 335 for (i = 0; i < 8; extent++, i++) {
@@ -345,18 +346,33 @@ found:
345 for (;;) { 346 for (;;) {
346 start = be32_to_cpu(extent->start_block); 347 start = be32_to_cpu(extent->start_block);
347 if (count <= block_nr) { 348 if (count <= block_nr) {
348 hfsplus_block_free(sb, start, count); 349 err = hfsplus_block_free(sb, start, count);
350 if (err) {
351 printk(KERN_ERR "hfs: can't free extent\n");
352 dprint(DBG_EXTENT, " start: %u count: %u\n",
353 start, count);
354 }
349 extent->block_count = 0; 355 extent->block_count = 0;
350 extent->start_block = 0; 356 extent->start_block = 0;
351 block_nr -= count; 357 block_nr -= count;
352 } else { 358 } else {
353 count -= block_nr; 359 count -= block_nr;
354 hfsplus_block_free(sb, start + count, block_nr); 360 err = hfsplus_block_free(sb, start + count, block_nr);
361 if (err) {
362 printk(KERN_ERR "hfs: can't free extent\n");
363 dprint(DBG_EXTENT, " start: %u count: %u\n",
364 start, count);
365 }
355 extent->block_count = cpu_to_be32(count); 366 extent->block_count = cpu_to_be32(count);
356 block_nr = 0; 367 block_nr = 0;
357 } 368 }
358 if (!block_nr || !i) 369 if (!block_nr || !i) {
359 return 0; 370 /*
371 * Try to free all extents and
372 * return only last error
373 */
374 return err;
375 }
360 i--; 376 i--;
361 extent--; 377 extent--;
362 count = be32_to_cpu(extent->block_count); 378 count = be32_to_cpu(extent->block_count);
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index c571de224b1..a6da86b1b4c 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -335,7 +335,7 @@ int hfsplus_block_free(struct super_block *, u32, u32);
335/* btree.c */ 335/* btree.c */
336struct hfs_btree *hfs_btree_open(struct super_block *, u32); 336struct hfs_btree *hfs_btree_open(struct super_block *, u32);
337void hfs_btree_close(struct hfs_btree *); 337void hfs_btree_close(struct hfs_btree *);
338void hfs_btree_write(struct hfs_btree *); 338int hfs_btree_write(struct hfs_btree *);
339struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *); 339struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *);
340void hfs_bmap_free(struct hfs_bnode *); 340void hfs_bmap_free(struct hfs_bnode *);
341 341
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 811a84d2d96..796198d2655 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -127,8 +127,14 @@ static int hfsplus_system_write_inode(struct inode *inode)
127 hfsplus_mark_mdb_dirty(inode->i_sb); 127 hfsplus_mark_mdb_dirty(inode->i_sb);
128 } 128 }
129 hfsplus_inode_write_fork(inode, fork); 129 hfsplus_inode_write_fork(inode, fork);
130 if (tree) 130 if (tree) {
131 hfs_btree_write(tree); 131 int err = hfs_btree_write(tree);
132 if (err) {
133 printk(KERN_ERR "hfs: b-tree write err: %d, ino %lu\n",
134 err, inode->i_ino);
135 return err;
136 }
137 }
132 return 0; 138 return 0;
133} 139}
134 140
@@ -226,6 +232,7 @@ out:
226 232
227static void delayed_sync_fs(struct work_struct *work) 233static void delayed_sync_fs(struct work_struct *work)
228{ 234{
235 int err;
229 struct hfsplus_sb_info *sbi; 236 struct hfsplus_sb_info *sbi;
230 237
231 sbi = container_of(work, struct hfsplus_sb_info, sync_work.work); 238 sbi = container_of(work, struct hfsplus_sb_info, sync_work.work);
@@ -234,7 +241,9 @@ static void delayed_sync_fs(struct work_struct *work)
234 sbi->work_queued = 0; 241 sbi->work_queued = 0;
235 spin_unlock(&sbi->work_lock); 242 spin_unlock(&sbi->work_lock);
236 243
237 hfsplus_sync_fs(sbi->alloc_file->i_sb, 1); 244 err = hfsplus_sync_fs(sbi->alloc_file->i_sb, 1);
245 if (err)
246 printk(KERN_ERR "hfs: delayed sync fs err %d\n", err);
238} 247}
239 248
240void hfsplus_mark_mdb_dirty(struct super_block *sb) 249void hfsplus_mark_mdb_dirty(struct super_block *sb)
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 2e4ed13b9ee..e064f562b1f 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -352,18 +352,18 @@ retry:
352 if (!ida_pre_get(&proc_inum_ida, GFP_KERNEL)) 352 if (!ida_pre_get(&proc_inum_ida, GFP_KERNEL))
353 return -ENOMEM; 353 return -ENOMEM;
354 354
355 spin_lock(&proc_inum_lock); 355 spin_lock_bh(&proc_inum_lock);
356 error = ida_get_new(&proc_inum_ida, &i); 356 error = ida_get_new(&proc_inum_ida, &i);
357 spin_unlock(&proc_inum_lock); 357 spin_unlock_bh(&proc_inum_lock);
358 if (error == -EAGAIN) 358 if (error == -EAGAIN)
359 goto retry; 359 goto retry;
360 else if (error) 360 else if (error)
361 return error; 361 return error;
362 362
363 if (i > UINT_MAX - PROC_DYNAMIC_FIRST) { 363 if (i > UINT_MAX - PROC_DYNAMIC_FIRST) {
364 spin_lock(&proc_inum_lock); 364 spin_lock_bh(&proc_inum_lock);
365 ida_remove(&proc_inum_ida, i); 365 ida_remove(&proc_inum_ida, i);
366 spin_unlock(&proc_inum_lock); 366 spin_unlock_bh(&proc_inum_lock);
367 return -ENOSPC; 367 return -ENOSPC;
368 } 368 }
369 *inum = PROC_DYNAMIC_FIRST + i; 369 *inum = PROC_DYNAMIC_FIRST + i;
@@ -372,9 +372,9 @@ retry:
372 372
373void proc_free_inum(unsigned int inum) 373void proc_free_inum(unsigned int inum)
374{ 374{
375 spin_lock(&proc_inum_lock); 375 spin_lock_bh(&proc_inum_lock);
376 ida_remove(&proc_inum_ida, inum - PROC_DYNAMIC_FIRST); 376 ida_remove(&proc_inum_ida, inum - PROC_DYNAMIC_FIRST);
377 spin_unlock(&proc_inum_lock); 377 spin_unlock_bh(&proc_inum_lock);
378} 378}
379 379
380static void *proc_follow_link(struct dentry *dentry, struct nameidata *nd) 380static void *proc_follow_link(struct dentry *dentry, struct nameidata *nd)
diff --git a/fs/read_write.c b/fs/read_write.c
index 1edaf099ddd..bb34af31528 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -935,6 +935,8 @@ ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, size_t count,
935 if (retval > 0) { 935 if (retval > 0) {
936 add_rchar(current, retval); 936 add_rchar(current, retval);
937 add_wchar(current, retval); 937 add_wchar(current, retval);
938 fsnotify_access(in.file);
939 fsnotify_modify(out.file);
938 } 940 }
939 941
940 inc_syscr(current); 942 inc_syscr(current);