Richard Weinberger <richard@xxxxxx> writes: >> Well, anyway, I don't object like that simple patch. >> >> My worry is, I feel we need something like online-fsck finally if we >> tackled fully to avoid issues (I still didn't analyze about this issue >> seriously and fully), and measurable overheads. >> >> And I myself have interest to online/runtime-fsck (i.e. detect and fix) >> though, I don't have interest to make it generic operations, and I would >> not have interest to tackle for all FSes... >> > > What about this one? Looks like strange. If we want to tackle this at per-FS. We should not return double linked dir at first. Since double linked breaks dir hierarchy, even if this one can avoid that Oops, double linked can be easily the cause of another Oops, deadlock, etc. Well, this patch is untested though. For example, somethings like following. But, again, this fixes only one of cases in double linked. (And to fix fully, my mind was already talked.) Signed-off-by: OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx> --- fs/fat/namei_msdos.c | 9 +++++++++ fs/fat/namei_vfat.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff -puN fs/fat/namei_vfat.c~vfat-detect-dir-loop fs/fat/namei_vfat.c --- linux-tux3/fs/fat/namei_vfat.c~vfat-detect-dir-loop 2014-10-20 17:44:17.874542711 +0900 +++ linux-tux3-hirofumi/fs/fat/namei_vfat.c 2014-10-20 17:42:24.494864616 +0900 @@ -735,6 +735,15 @@ static struct dentry *vfat_lookup(struct goto error; } + /* Simple sanity check to avoid Oops. */ + if (inode == dentry->d_parent->d_inode) { + fat_fs_error(sb, "%s: detected directory loop (i_pos %lld)", + __func__, MSDOS_I(inode)->i_pos); + iput(inode); + err = -EIO; + goto error; + } + alias = d_find_alias(inode); if (alias && !vfat_d_anon_disconn(alias)) { /* diff -puN fs/fat/namei_msdos.c~vfat-detect-dir-loop fs/fat/namei_msdos.c --- linux-tux3/fs/fat/namei_msdos.c~vfat-detect-dir-loop 2014-10-20 17:44:25.858520043 +0900 +++ linux-tux3-hirofumi/fs/fat/namei_msdos.c 2014-10-20 17:45:42.654302012 +0900 @@ -215,6 +215,15 @@ static struct dentry *msdos_lookup(struc case 0: inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); brelse(sinfo.bh); + + /* Simple sanity check to avoid Oops. */ + if (inode == dentry->d_parent->d_inode) { + fat_fs_error(sb, + "%s: detected directory loop (i_pos %lld)", + __func__, MSDOS_I(inode)->i_pos); + iput(inode); + inode = ERR_PTR(-EIO); + } break; default: inode = ERR_PTR(err); _ -- OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx> -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html