Skip to content

Commit

Permalink
staging: erofs: refuse to mount images with malformed volume name
Browse files Browse the repository at this point in the history
As Richard reminder [1], A valid volume name should be
ended in NIL terminator within the length of volume_name.

Since this field currently isn't really used, let's fix
it to avoid potential bugs in the future.

[1] https://lore.kernel.org/r/1133002215.69049.1566119033047.JavaMail.zimbra@nod.at/

Reported-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Link: https://lore.kernel.org/r/20190818102824.22330-1-hsiangkao@aol.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Gao Xiang authored and Greg Kroah-Hartman committed Aug 21, 2019
1 parent c6d6832 commit a64d949
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/staging/erofs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,14 @@ static int superblock_read(struct super_block *sb)
sbi->build_time_nsec = le32_to_cpu(layout->build_time_nsec);

memcpy(&sb->s_uuid, layout->uuid, sizeof(layout->uuid));
memcpy(sbi->volume_name, layout->volume_name,
sizeof(layout->volume_name));

ret = strscpy(sbi->volume_name, layout->volume_name,
sizeof(layout->volume_name));
if (ret < 0) { /* -E2BIG */
errln("bad volume name without NIL terminator");
ret = -EFSCORRUPTED;
goto out;
}
ret = 0;
out:
brelse(bh);
Expand Down

0 comments on commit a64d949

Please sign in to comment.