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.20-rc7' of git://git.infradead.org/linux-ubifs

Pull UBI/UBIFS fixes from Richard Weinberger:

- Kconfig dependency fixes for our new auth feature

- Fix for selecting the right compressor when creating a fs

- Bugfix for a bug in UBIFS's O_TMPFILE implementation

- Refcounting fixes for UBI

* tag 'upstream-4.20-rc7' of git://git.infradead.org/linux-ubifs:
ubifs: Handle re-linking of inodes correctly while recovery
ubi: Do not drop UBI device reference before using
ubi: Put MTD device after it is not used
ubifs: Fix default compression selection in ubifs
ubifs: Fix memory leak on error condition
ubifs: auth: Add CONFIG_KEYS dependency
ubifs: CONFIG_UBIFS_FS_AUTHENTICATION should depend on UBIFS_FS
ubifs: replay: Fix high stack usage

+89 -28
+1 -1
drivers/mtd/ubi/build.c
··· 1101 1101 ubi_wl_close(ubi); 1102 1102 ubi_free_internal_volumes(ubi); 1103 1103 vfree(ubi->vtbl); 1104 - put_mtd_device(ubi->mtd); 1105 1104 vfree(ubi->peb_buf); 1106 1105 vfree(ubi->fm_buf); 1107 1106 ubi_msg(ubi, "mtd%d is detached", ubi->mtd->index); 1107 + put_mtd_device(ubi->mtd); 1108 1108 put_device(&ubi->dev); 1109 1109 return 0; 1110 1110 }
+1 -1
drivers/mtd/ubi/kapi.c
··· 227 227 out_free: 228 228 kfree(desc); 229 229 out_put_ubi: 230 - ubi_put_device(ubi); 231 230 ubi_err(ubi, "cannot open device %d, volume %d, error %d", 232 231 ubi_num, vol_id, err); 232 + ubi_put_device(ubi); 233 233 return ERR_PTR(err); 234 234 } 235 235 EXPORT_SYMBOL_GPL(ubi_open_volume);
+8 -8
fs/ubifs/Kconfig
··· 12 12 help 13 13 UBIFS is a file system for flash devices which works on top of UBI. 14 14 15 + if UBIFS_FS 16 + 15 17 config UBIFS_FS_ADVANCED_COMPR 16 18 bool "Advanced compression options" 17 - depends on UBIFS_FS 18 19 help 19 20 This option allows to explicitly choose which compressions, if any, 20 21 are enabled in UBIFS. Removing compressors means inability to read ··· 25 24 26 25 config UBIFS_FS_LZO 27 26 bool "LZO compression support" if UBIFS_FS_ADVANCED_COMPR 28 - depends on UBIFS_FS 29 27 default y 30 28 help 31 29 LZO compressor is generally faster than zlib but compresses worse. ··· 32 32 33 33 config UBIFS_FS_ZLIB 34 34 bool "ZLIB compression support" if UBIFS_FS_ADVANCED_COMPR 35 - depends on UBIFS_FS 36 35 default y 37 36 help 38 37 Zlib compresses better than LZO but it is slower. Say 'Y' if unsure. 39 38 40 39 config UBIFS_ATIME_SUPPORT 41 - bool "Access time support" if UBIFS_FS 42 - depends on UBIFS_FS 40 + bool "Access time support" 43 41 default n 44 42 help 45 43 Originally UBIFS did not support atime, because it looked like a bad idea due ··· 52 54 53 55 config UBIFS_FS_XATTR 54 56 bool "UBIFS XATTR support" 55 - depends on UBIFS_FS 56 57 default y 57 58 help 58 59 Saying Y here includes support for extended attributes (xattrs). ··· 62 65 63 66 config UBIFS_FS_ENCRYPTION 64 67 bool "UBIFS Encryption" 65 - depends on UBIFS_FS && UBIFS_FS_XATTR && BLOCK 68 + depends on UBIFS_FS_XATTR && BLOCK 66 69 select FS_ENCRYPTION 67 70 default n 68 71 help ··· 73 76 74 77 config UBIFS_FS_SECURITY 75 78 bool "UBIFS Security Labels" 76 - depends on UBIFS_FS && UBIFS_FS_XATTR 79 + depends on UBIFS_FS_XATTR 77 80 default y 78 81 help 79 82 Security labels provide an access control facility to support Linux ··· 86 89 87 90 config UBIFS_FS_AUTHENTICATION 88 91 bool "UBIFS authentication support" 92 + depends on KEYS 89 93 select CRYPTO_HMAC 90 94 help 91 95 Enable authentication support for UBIFS. This feature offers protection ··· 94 96 If you say yes here you should also select a hashing algorithm such as 95 97 sha256, these are not selected automatically since there are many 96 98 different options. 99 + 100 + endif # UBIFS_FS
+6 -6
fs/ubifs/lpt.c
··· 1675 1675 if (!ubifs_authenticated(c)) 1676 1676 return 0; 1677 1677 1678 + if (!c->nroot) { 1679 + err = ubifs_read_nnode(c, NULL, 0); 1680 + if (err) 1681 + return err; 1682 + } 1683 + 1678 1684 desc = ubifs_hash_get_desc(c); 1679 1685 if (IS_ERR(desc)) 1680 1686 return PTR_ERR(desc); ··· 1689 1683 if (!buf) { 1690 1684 err = -ENOMEM; 1691 1685 goto out; 1692 - } 1693 - 1694 - if (!c->nroot) { 1695 - err = ubifs_read_nnode(c, NULL, 0); 1696 - if (err) 1697 - return err; 1698 1686 } 1699 1687 1700 1688 cnode = (struct ubifs_cnode *)c->nroot;
+61 -11
fs/ubifs/replay.c
··· 213 213 } 214 214 215 215 /** 216 + * inode_still_linked - check whether inode in question will be re-linked. 217 + * @c: UBIFS file-system description object 218 + * @rino: replay entry to test 219 + * 220 + * O_TMPFILE files can be re-linked, this means link count goes from 0 to 1. 221 + * This case needs special care, otherwise all references to the inode will 222 + * be removed upon the first replay entry of an inode with link count 0 223 + * is found. 224 + */ 225 + static bool inode_still_linked(struct ubifs_info *c, struct replay_entry *rino) 226 + { 227 + struct replay_entry *r; 228 + 229 + ubifs_assert(c, rino->deletion); 230 + ubifs_assert(c, key_type(c, &rino->key) == UBIFS_INO_KEY); 231 + 232 + /* 233 + * Find the most recent entry for the inode behind @rino and check 234 + * whether it is a deletion. 235 + */ 236 + list_for_each_entry_reverse(r, &c->replay_list, list) { 237 + ubifs_assert(c, r->sqnum >= rino->sqnum); 238 + if (key_inum(c, &r->key) == key_inum(c, &rino->key)) 239 + return r->deletion == 0; 240 + 241 + } 242 + 243 + ubifs_assert(c, 0); 244 + return false; 245 + } 246 + 247 + /** 216 248 * apply_replay_entry - apply a replay entry to the TNC. 217 249 * @c: UBIFS file-system description object 218 250 * @r: replay entry to apply ··· 270 238 case UBIFS_INO_KEY: 271 239 { 272 240 ino_t inum = key_inum(c, &r->key); 241 + 242 + if (inode_still_linked(c, r)) { 243 + err = 0; 244 + break; 245 + } 273 246 274 247 err = ubifs_tnc_remove_ino(c, inum); 275 248 break; ··· 570 533 return data == 0xFFFFFFFF; 571 534 } 572 535 536 + /* authenticate_sleb_hash and authenticate_sleb_hmac are split out for stack usage */ 537 + static int authenticate_sleb_hash(struct ubifs_info *c, struct shash_desc *log_hash, u8 *hash) 538 + { 539 + SHASH_DESC_ON_STACK(hash_desc, c->hash_tfm); 540 + 541 + hash_desc->tfm = c->hash_tfm; 542 + hash_desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; 543 + 544 + ubifs_shash_copy_state(c, log_hash, hash_desc); 545 + return crypto_shash_final(hash_desc, hash); 546 + } 547 + 548 + static int authenticate_sleb_hmac(struct ubifs_info *c, u8 *hash, u8 *hmac) 549 + { 550 + SHASH_DESC_ON_STACK(hmac_desc, c->hmac_tfm); 551 + 552 + hmac_desc->tfm = c->hmac_tfm; 553 + hmac_desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; 554 + 555 + return crypto_shash_digest(hmac_desc, hash, c->hash_len, hmac); 556 + } 557 + 573 558 /** 574 559 * authenticate_sleb - authenticate one scan LEB 575 560 * @c: UBIFS file-system description object ··· 633 574 634 575 if (snod->type == UBIFS_AUTH_NODE) { 635 576 struct ubifs_auth_node *auth = snod->node; 636 - SHASH_DESC_ON_STACK(hash_desc, c->hash_tfm); 637 - SHASH_DESC_ON_STACK(hmac_desc, c->hmac_tfm); 638 577 639 - hash_desc->tfm = c->hash_tfm; 640 - hash_desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; 641 - 642 - ubifs_shash_copy_state(c, log_hash, hash_desc); 643 - err = crypto_shash_final(hash_desc, hash); 578 + err = authenticate_sleb_hash(c, log_hash, hash); 644 579 if (err) 645 580 goto out; 646 581 647 - hmac_desc->tfm = c->hmac_tfm; 648 - hmac_desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; 649 - err = crypto_shash_digest(hmac_desc, hash, c->hash_len, 650 - hmac); 582 + err = authenticate_sleb_hmac(c, hash, hmac); 651 583 if (err) 652 584 goto out; 653 585
+12 -1
fs/ubifs/sb.c
··· 63 63 /* Default time granularity in nanoseconds */ 64 64 #define DEFAULT_TIME_GRAN 1000000000 65 65 66 + static int get_default_compressor(struct ubifs_info *c) 67 + { 68 + if (ubifs_compr_present(c, UBIFS_COMPR_LZO)) 69 + return UBIFS_COMPR_LZO; 70 + 71 + if (ubifs_compr_present(c, UBIFS_COMPR_ZLIB)) 72 + return UBIFS_COMPR_ZLIB; 73 + 74 + return UBIFS_COMPR_NONE; 75 + } 76 + 66 77 /** 67 78 * create_default_filesystem - format empty UBI volume. 68 79 * @c: UBIFS file-system description object ··· 218 207 if (c->mount_opts.override_compr) 219 208 sup->default_compr = cpu_to_le16(c->mount_opts.compr_type); 220 209 else 221 - sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO); 210 + sup->default_compr = cpu_to_le16(get_default_compressor(c)); 222 211 223 212 generate_random_uuid(sup->uuid); 224 213