Commit 8e62dec3 authored by Ernesto A. Fernández's avatar Ernesto A. Fernández Committed by Kleber Sacilotto de Souza

hfsplus: fix NULL dereference in hfsplus_lookup()

BugLink: https://bugs.launchpad.net/bugs/1797563

[ Upstream commit a7ec7a41 ]

An HFS+ filesystem can be mounted read-only without having a metadata
directory, which is needed to support hardlinks.  But if the catalog
data is corrupted, a directory lookup may still find dentries claiming
to be hardlinks.

hfsplus_lookup() does check that ->hidden_dir is not NULL in such a
situation, but mistakenly does so after dereferencing it for the first
time.  Reorder this check to prevent a crash.

This happens when looking up corrupted catalog data (dentry) on a
filesystem with no metadata directory (this could only ever happen on a
read-only mount).  Wen Xu sent the replication steps in detail to the
fsdevel list: https://bugzilla.kernel.org/show_bug.cgi?id=200297

Link: http://lkml.kernel.org/r/20180712215344.q44dyrhymm4ajkao@eafSigned-off-by: default avatarErnesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Reported-by: default avatarWen Xu <wen.xu@gatech.edu>
Cc: Viacheslav Dubeyko <slava@dubeyko.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent b8b5921d
...@@ -77,13 +77,13 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry, ...@@ -77,13 +77,13 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
cpu_to_be32(HFSP_HARDLINK_TYPE) && cpu_to_be32(HFSP_HARDLINK_TYPE) &&
entry.file.user_info.fdCreator == entry.file.user_info.fdCreator ==
cpu_to_be32(HFSP_HFSPLUS_CREATOR) && cpu_to_be32(HFSP_HFSPLUS_CREATOR) &&
HFSPLUS_SB(sb)->hidden_dir &&
(entry.file.create_date == (entry.file.create_date ==
HFSPLUS_I(HFSPLUS_SB(sb)->hidden_dir)-> HFSPLUS_I(HFSPLUS_SB(sb)->hidden_dir)->
create_date || create_date ||
entry.file.create_date == entry.file.create_date ==
HFSPLUS_I(d_inode(sb->s_root))-> HFSPLUS_I(d_inode(sb->s_root))->
create_date) && create_date)) {
HFSPLUS_SB(sb)->hidden_dir) {
struct qstr str; struct qstr str;
char name[32]; char name[32];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment