Skip to content

Commit

Permalink
FROMLIST: Revert "fat: add simple validation for directory inode"
Browse files Browse the repository at this point in the history
This reverts commit a3082d5.

The reverted commit adds check for FAT images. However, the tools used
for creating images for the Lego Mindstrom EV3 are not adding '.' and
'..' entry in the 'Projects' directory.
Without this fix, the kernel can not fill the inode structure for
'Projects' directory.

See microsoft/pxt-ev3#980
And microsoft/uf2-linux#6

With the patch reverted, we can mount an image copied from the EV3

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
(am from https://lore.kernel.org/r/20220204062232.3410036-1-gwendal@chromium.org)

BUG=b:205899437
TEST=With the patch reverted, we can mount an image copied from
the EV3

Change-Id: I731be37a6305e4d5378ac4d31817adcbd43e9c62
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3430762
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Daniil Lunev <dlunev@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
(cherry picked from commit f67697eb16412d5a1b5a633b619e129425afcec0)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3498707
  • Loading branch information
gwendalcr authored and Lukasz Majczak committed Jun 13, 2022
1 parent a246c4c commit fb8c6bf
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions fs/fat/inode.c
Expand Up @@ -495,24 +495,6 @@ static int fat_calc_dir_size(struct inode *inode)
return 0;
}

static int fat_validate_dir(struct inode *dir)
{
struct super_block *sb = dir->i_sb;

if (dir->i_nlink < 2) {
/* Directory should have "."/".." entries at least. */
fat_fs_error(sb, "corrupted directory (invalid entries)");
return -EIO;
}
if (MSDOS_I(dir)->i_start == 0 ||
MSDOS_I(dir)->i_start == MSDOS_SB(sb)->root_cluster) {
/* Directory should point valid cluster. */
fat_fs_error(sb, "corrupted directory (invalid i_start)");
return -EIO;
}
return 0;
}

/* doesn't deal with root inode */
int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
{
Expand All @@ -539,10 +521,6 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
MSDOS_I(inode)->mmu_private = inode->i_size;

set_nlink(inode, fat_subdirs(inode));

error = fat_validate_dir(inode);
if (error < 0)
return error;
} else { /* not a directory */
inode->i_generation |= 1;
inode->i_mode = fat_make_mode(sbi, de->attr,
Expand Down

0 comments on commit fb8c6bf

Please sign in to comment.