Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'upstream-4.12-rc1' of git://git.infradead.org/linux-ubifs

Pull UBI/UBIFS updates from Richard Weinberger:

- new config option CONFIG_UBIFS_FS_SECURITY

- minor improvements

- random fixes

* tag 'upstream-4.12-rc1' of git://git.infradead.org/linux-ubifs:
ubi: Add debugfs file for tracking PEB state
ubifs: Fix a typo in comment of ioctl2ubifs & ubifs2ioctl
ubifs: Remove unnecessary assignment
ubifs: Fix cut and paste error on sb type comparisons
ubi: fastmap: Fix slab corruption
ubifs: Add CONFIG_UBIFS_FS_SECURITY to disable/enable security labels
ubi: Make mtd parameter readable
ubi: Fix section mismatch

+195 -18
+5 -5
drivers/mtd/ubi/build.c
··· 74 74 }; 75 75 76 76 /* Numbers of elements set in the @mtd_dev_param array */ 77 - static int __initdata mtd_devs; 77 + static int mtd_devs; 78 78 79 79 /* MTD devices specification parameters */ 80 - static struct mtd_dev_param __initdata mtd_dev_param[UBI_MAX_DEVICES]; 80 + static struct mtd_dev_param mtd_dev_param[UBI_MAX_DEVICES]; 81 81 #ifdef CONFIG_MTD_UBI_FASTMAP 82 82 /* UBI module parameter to enable fastmap automatically on non-fastmap images */ 83 83 static bool fm_autoconvert; ··· 1294 1294 * This function returns positive resulting integer in case of success and a 1295 1295 * negative error code in case of failure. 1296 1296 */ 1297 - static int __init bytes_str_to_int(const char *str) 1297 + static int bytes_str_to_int(const char *str) 1298 1298 { 1299 1299 char *endp; 1300 1300 unsigned long result; ··· 1332 1332 * This function returns zero in case of success and a negative error code in 1333 1333 * case of error. 1334 1334 */ 1335 - static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp) 1335 + static int ubi_mtd_param_parse(const char *val, struct kernel_param *kp) 1336 1336 { 1337 1337 int i, len; 1338 1338 struct mtd_dev_param *p; ··· 1413 1413 return 0; 1414 1414 } 1415 1415 1416 - module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000); 1416 + module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 0400); 1417 1417 MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num]]].\n" 1418 1418 "Multiple \"mtd\" parameters may be specified.\n" 1419 1419 "MTD devices may be specified by their number, name, or path to the MTD character device node.\n"
+125 -1
drivers/mtd/ubi/debug.c
··· 22 22 #include <linux/debugfs.h> 23 23 #include <linux/uaccess.h> 24 24 #include <linux/module.h> 25 + #include <linux/seq_file.h> 25 26 26 27 27 28 /** ··· 387 386 return count; 388 387 } 389 388 390 - /* File operations for all UBI debugfs files */ 389 + /* File operations for all UBI debugfs files except 390 + * detailed_erase_block_info 391 + */ 391 392 static const struct file_operations dfs_fops = { 392 393 .read = dfs_file_read, 393 394 .write = dfs_file_write, 394 395 .open = simple_open, 395 396 .llseek = no_llseek, 396 397 .owner = THIS_MODULE, 398 + }; 399 + 400 + /* As long as the position is less then that total number of erase blocks, 401 + * we still have more to print. 402 + */ 403 + static void *eraseblk_count_seq_start(struct seq_file *s, loff_t *pos) 404 + { 405 + struct ubi_device *ubi = s->private; 406 + 407 + if (*pos == 0) 408 + return SEQ_START_TOKEN; 409 + 410 + if (*pos < ubi->peb_count) 411 + return pos; 412 + 413 + return NULL; 414 + } 415 + 416 + /* Since we are using the position as the iterator, we just need to check if we 417 + * are done and increment the position. 418 + */ 419 + static void *eraseblk_count_seq_next(struct seq_file *s, void *v, loff_t *pos) 420 + { 421 + struct ubi_device *ubi = s->private; 422 + 423 + if (v == SEQ_START_TOKEN) 424 + return pos; 425 + (*pos)++; 426 + 427 + if (*pos < ubi->peb_count) 428 + return pos; 429 + 430 + return NULL; 431 + } 432 + 433 + static void eraseblk_count_seq_stop(struct seq_file *s, void *v) 434 + { 435 + } 436 + 437 + static int eraseblk_count_seq_show(struct seq_file *s, void *iter) 438 + { 439 + struct ubi_device *ubi = s->private; 440 + struct ubi_wl_entry *wl; 441 + int *block_number = iter; 442 + int erase_count = -1; 443 + int err; 444 + 445 + /* If this is the start, print a header */ 446 + if (iter == SEQ_START_TOKEN) { 447 + seq_puts(s, 448 + "physical_block_number\terase_count\tblock_status\tread_status\n"); 449 + return 0; 450 + } 451 + 452 + err = ubi_io_is_bad(ubi, *block_number); 453 + if (err) 454 + return err; 455 + 456 + spin_lock(&ubi->wl_lock); 457 + 458 + wl = ubi->lookuptbl[*block_number]; 459 + if (wl) 460 + erase_count = wl->ec; 461 + 462 + spin_unlock(&ubi->wl_lock); 463 + 464 + if (erase_count < 0) 465 + return 0; 466 + 467 + seq_printf(s, "%-22d\t%-11d\n", *block_number, erase_count); 468 + 469 + return 0; 470 + } 471 + 472 + static const struct seq_operations eraseblk_count_seq_ops = { 473 + .start = eraseblk_count_seq_start, 474 + .next = eraseblk_count_seq_next, 475 + .stop = eraseblk_count_seq_stop, 476 + .show = eraseblk_count_seq_show 477 + }; 478 + 479 + static int eraseblk_count_open(struct inode *inode, struct file *f) 480 + { 481 + struct seq_file *s; 482 + int err; 483 + 484 + err = seq_open(f, &eraseblk_count_seq_ops); 485 + if (err) 486 + return err; 487 + 488 + s = f->private_data; 489 + s->private = ubi_get_device((unsigned long)inode->i_private); 490 + 491 + if (!s->private) 492 + return -ENODEV; 493 + else 494 + return 0; 495 + } 496 + 497 + static int eraseblk_count_release(struct inode *inode, struct file *f) 498 + { 499 + struct seq_file *s = f->private_data; 500 + struct ubi_device *ubi = s->private; 501 + 502 + ubi_put_device(ubi); 503 + 504 + return seq_release(inode, f); 505 + } 506 + 507 + static const struct file_operations eraseblk_count_fops = { 508 + .owner = THIS_MODULE, 509 + .open = eraseblk_count_open, 510 + .read = seq_read, 511 + .llseek = seq_lseek, 512 + .release = eraseblk_count_release, 397 513 }; 398 514 399 515 /** ··· 608 490 if (IS_ERR_OR_NULL(dent)) 609 491 goto out_remove; 610 492 d->dfs_power_cut_max = dent; 493 + 494 + fname = "detailed_erase_block_info"; 495 + dent = debugfs_create_file(fname, S_IRUSR, d->dfs_dir, (void *)ubi_num, 496 + &eraseblk_count_fops); 497 + if (IS_ERR_OR_NULL(dent)) 498 + goto out_remove; 611 499 612 500 return 0; 613 501
+29 -4
drivers/mtd/ubi/fastmap.c
··· 828 828 return ret; 829 829 } 830 830 831 + static struct ubi_ainf_peb *clone_aeb(struct ubi_attach_info *ai, 832 + struct ubi_ainf_peb *old) 833 + { 834 + struct ubi_ainf_peb *new; 835 + 836 + new = ubi_alloc_aeb(ai, old->pnum, old->ec); 837 + if (!new) 838 + return NULL; 839 + 840 + new->vol_id = old->vol_id; 841 + new->sqnum = old->sqnum; 842 + new->lnum = old->lnum; 843 + new->scrub = old->scrub; 844 + new->copy_flag = old->copy_flag; 845 + 846 + return new; 847 + } 848 + 831 849 /** 832 850 * ubi_scan_fastmap - scan the fastmap. 833 851 * @ubi: UBI device object ··· 865 847 struct ubi_vid_hdr *vh; 866 848 struct ubi_ec_hdr *ech; 867 849 struct ubi_fastmap_layout *fm; 868 - struct ubi_ainf_peb *tmp_aeb, *aeb; 850 + struct ubi_ainf_peb *aeb; 869 851 int i, used_blocks, pnum, fm_anchor, ret = 0; 870 852 size_t fm_size; 871 853 __be32 crc, tmp_crc; ··· 875 857 if (fm_anchor < 0) 876 858 return UBI_NO_FASTMAP; 877 859 878 - /* Move all (possible) fastmap blocks into our new attach structure. */ 879 - list_for_each_entry_safe(aeb, tmp_aeb, &scan_ai->fastmap, u.list) 880 - list_move_tail(&aeb->u.list, &ai->fastmap); 860 + /* Copy all (possible) fastmap blocks into our new attach structure. */ 861 + list_for_each_entry(aeb, &scan_ai->fastmap, u.list) { 862 + struct ubi_ainf_peb *new; 863 + 864 + new = clone_aeb(ai, aeb); 865 + if (!new) 866 + return -ENOMEM; 867 + 868 + list_add(&new->u.list, &ai->fastmap); 869 + } 881 870 882 871 down_write(&ubi->fm_protect); 883 872 memset(ubi->fm_buf, 0, ubi->fm_size);
+13
fs/ubifs/Kconfig
··· 61 61 feature is similar to ecryptfs, but it is more memory 62 62 efficient since it avoids caching the encrypted and 63 63 decrypted pages in the page cache. 64 + 65 + config UBIFS_FS_SECURITY 66 + bool "UBIFS Security Labels" 67 + depends on UBIFS_FS 68 + default y 69 + help 70 + Security labels provide an access control facility to support Linux 71 + Security Models (LSMs) accepted by AppArmor, SELinux, Smack and TOMOYO 72 + Linux. This option enables an extended attribute handler for file 73 + security labels in the ubifs filesystem, so that it requires enabling 74 + the extended attribute support in advance. 75 + 76 + If you are not using a security module, say N.
+2 -2
fs/ubifs/debug.c
··· 2391 2391 ubifs_dump_node(c, sa->node); 2392 2392 return -EINVAL; 2393 2393 } 2394 - if (sa->type != UBIFS_INO_NODE && sa->type != UBIFS_DENT_NODE && 2395 - sa->type != UBIFS_XENT_NODE) { 2394 + if (sb->type != UBIFS_INO_NODE && sb->type != UBIFS_DENT_NODE && 2395 + sb->type != UBIFS_XENT_NODE) { 2396 2396 ubifs_err(c, "bad node type %d", sb->type); 2397 2397 ubifs_dump_node(c, sb->node); 2398 2398 return -EINVAL;
+3 -3
fs/ubifs/ioctl.c
··· 53 53 * ioctl2ubifs - convert ioctl inode flags to UBIFS inode flags. 54 54 * @ioctl_flags: flags to convert 55 55 * 56 - * This function convert ioctl flags (@FS_COMPR_FL, etc) to UBIFS inode flags 56 + * This function converts ioctl flags (@FS_COMPR_FL, etc) to UBIFS inode flags 57 57 * (@UBIFS_COMPR_FL, etc). 58 58 */ 59 59 static int ioctl2ubifs(int ioctl_flags) ··· 78 78 * ubifs2ioctl - convert UBIFS inode flags to ioctl inode flags. 79 79 * @ubifs_flags: flags to convert 80 80 * 81 - * This function convert UBIFS (@UBIFS_COMPR_FL, etc) to ioctl flags 82 - * (@FS_COMPR_FL, etc). 81 + * This function converts UBIFS inode flags (@UBIFS_COMPR_FL, etc) to ioctl 82 + * flags (@FS_COMPR_FL, etc). 83 83 */ 84 84 static int ubifs2ioctl(int ubifs_flags) 85 85 {
-1
fs/ubifs/recovery.c
··· 442 442 { 443 443 int empty_offs, pad_len; 444 444 445 - lnum = lnum; 446 445 dbg_rcvry("cleaning corruption at %d:%d", lnum, *offs); 447 446 448 447 ubifs_assert(!(*offs & 7));
+12 -2
fs/ubifs/ubifs.h
··· 1753 1753 /* xattr.c */ 1754 1754 extern const struct xattr_handler *ubifs_xattr_handlers[]; 1755 1755 ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size); 1756 - int ubifs_init_security(struct inode *dentry, struct inode *inode, 1757 - const struct qstr *qstr); 1758 1756 int ubifs_xattr_set(struct inode *host, const char *name, const void *value, 1759 1757 size_t size, int flags); 1760 1758 ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf, 1761 1759 size_t size); 1760 + 1761 + #ifdef CONFIG_UBIFS_FS_SECURITY 1762 + extern int ubifs_init_security(struct inode *dentry, struct inode *inode, 1763 + const struct qstr *qstr); 1764 + #else 1765 + static inline int ubifs_init_security(struct inode *dentry, 1766 + struct inode *inode, const struct qstr *qstr) 1767 + { 1768 + return 0; 1769 + } 1770 + #endif 1771 + 1762 1772 1763 1773 /* super.c */ 1764 1774 struct inode *ubifs_iget(struct super_block *sb, unsigned long inum);
+6
fs/ubifs/xattr.c
··· 559 559 return err; 560 560 } 561 561 562 + #ifdef CONFIG_UBIFS_FS_SECURITY 562 563 static int init_xattrs(struct inode *inode, const struct xattr *xattr_array, 563 564 void *fs_info) 564 565 { ··· 600 599 } 601 600 return err; 602 601 } 602 + #endif 603 603 604 604 static int xattr_get(const struct xattr_handler *handler, 605 605 struct dentry *dentry, struct inode *inode, ··· 641 639 .set = xattr_set, 642 640 }; 643 641 642 + #ifdef CONFIG_UBIFS_FS_SECURITY 644 643 static const struct xattr_handler ubifs_security_xattr_handler = { 645 644 .prefix = XATTR_SECURITY_PREFIX, 646 645 .get = xattr_get, 647 646 .set = xattr_set, 648 647 }; 648 + #endif 649 649 650 650 const struct xattr_handler *ubifs_xattr_handlers[] = { 651 651 &ubifs_user_xattr_handler, 652 652 &ubifs_trusted_xattr_handler, 653 + #ifdef CONFIG_UBIFS_FS_SECURITY 653 654 &ubifs_security_xattr_handler, 655 + #endif 654 656 NULL 655 657 };