-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEq1nRK9aeMoq1VSgcnJ2qBz9kQNkFAlv/mEEACgkQnJ2qBz9k
 QNm0kggA8SckBccdUZqpjxohASx9crp+jJeor2TRYCwyVfqdbDjkCOfv9k7+ddD4
 D1qN/AEudQXPzr/DrjI0W9fnFG957FLo60RQ0aGwsq/3wfmzfMJ0qXIw2tyoqjIH
 VxFecL2f3TKMr5zU9N1QoxJVAMAo5LOGbXO+qNYgTaOJ0EBpw9kxK14ib9JOi+pQ
 CItZkAv4eOWMsA/AaRsWN7AGmsziwcMdoAZYRT2wiWdTmubYn66Negnffq2jVHjP
 /kYlFjNcgpsuTg1AiTM+JlBwctEeLm37PUyimip3cdYwu6HcfNmCHDjEIzN2YphJ
 twzAauTEr0bjNFiNWYraUPVHEcspNw==
 =kKDs
 -----END PGP SIGNATURE-----

Merge tag 'fixes_for_v4.20-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

Pull ext2 and udf fixes from Jan Kara:
 "Three small ext2 and udf fixes"

* tag 'fixes_for_v4.20-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  ext2: fix potential use after free
  ext2: initialize opts.s_mount_opt as zero before using it
  udf: Allow mounting volumes with incorrect identification strings
This commit is contained in:
Linus Torvalds 2018-11-29 09:56:00 -08:00
commit 9af33b5745
4 changed files with 23 additions and 10 deletions

View file

@ -892,6 +892,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if (sb->s_magic != EXT2_SUPER_MAGIC) if (sb->s_magic != EXT2_SUPER_MAGIC)
goto cantfind_ext2; goto cantfind_ext2;
opts.s_mount_opt = 0;
/* Set defaults before we parse the mount options */ /* Set defaults before we parse the mount options */
def_mount_opts = le32_to_cpu(es->s_default_mount_opts); def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
if (def_mount_opts & EXT2_DEFM_DEBUG) if (def_mount_opts & EXT2_DEFM_DEBUG)

View file

@ -612,9 +612,9 @@ bad_block: ext2_error(sb, "ext2_xattr_set",
} }
cleanup: cleanup:
brelse(bh);
if (!(bh && header == HDR(bh))) if (!(bh && header == HDR(bh)))
kfree(header); kfree(header);
brelse(bh);
up_write(&EXT2_I(inode)->xattr_sem); up_write(&EXT2_I(inode)->xattr_sem);
return error; return error;

View file

@ -827,16 +827,20 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
ret = udf_dstrCS0toChar(sb, outstr, 31, pvoldesc->volIdent, 32); ret = udf_dstrCS0toChar(sb, outstr, 31, pvoldesc->volIdent, 32);
if (ret < 0) if (ret < 0) {
goto out_bh; strcpy(UDF_SB(sb)->s_volume_ident, "InvalidName");
pr_warn("incorrect volume identification, setting to "
strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret); "'InvalidName'\n");
} else {
strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret);
}
udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident); udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident);
ret = udf_dstrCS0toChar(sb, outstr, 127, pvoldesc->volSetIdent, 128); ret = udf_dstrCS0toChar(sb, outstr, 127, pvoldesc->volSetIdent, 128);
if (ret < 0) if (ret < 0) {
ret = 0;
goto out_bh; goto out_bh;
}
outstr[ret] = 0; outstr[ret] = 0;
udf_debug("volSetIdent[] = '%s'\n", outstr); udf_debug("volSetIdent[] = '%s'\n", outstr);

View file

@ -351,6 +351,11 @@ static int udf_name_to_CS0(struct super_block *sb,
return u_len; return u_len;
} }
/*
* Convert CS0 dstring to output charset. Warning: This function may truncate
* input string if it is too long as it is used for informational strings only
* and it is better to truncate the string than to refuse mounting a media.
*/
int udf_dstrCS0toChar(struct super_block *sb, uint8_t *utf_o, int o_len, int udf_dstrCS0toChar(struct super_block *sb, uint8_t *utf_o, int o_len,
const uint8_t *ocu_i, int i_len) const uint8_t *ocu_i, int i_len)
{ {
@ -359,9 +364,12 @@ int udf_dstrCS0toChar(struct super_block *sb, uint8_t *utf_o, int o_len,
if (i_len > 0) { if (i_len > 0) {
s_len = ocu_i[i_len - 1]; s_len = ocu_i[i_len - 1];
if (s_len >= i_len) { if (s_len >= i_len) {
pr_err("incorrect dstring lengths (%d/%d)\n", pr_warn("incorrect dstring lengths (%d/%d),"
s_len, i_len); " truncating\n", s_len, i_len);
return -EINVAL; s_len = i_len - 1;
/* 2-byte encoding? Need to round properly... */
if (ocu_i[0] == 16)
s_len -= (s_len - 1) & 2;
} }
} }