[CHECKER] warning in 2.4.19/fs/ext2/dir.c:ext2_find_entry where adir may contain two entries with identical names

From: Junfeng Yang
Date: Mon Feb 23 2004 - 19:54:37 EST



The two bugs reported here appears to cause a dir to have more than one
entries with identical names.

-Junfeng

----------------------------------------------------------------------------
[BUG] A dir may contain two dir entries with identical names. This is
because ext2_find_entry returns NULL either the entry to create doesn't
exist or ext2_get_page fails.

Detailed explanation:

The call-chain is sys_open --> filp_open --> open_namei.

(1) open_namei calls lookup_hash on the parent dir, to see if there's an
dir entry with the same name.

(2) lookup_hash calls cached_lookup to try to find the dentry from the
dcache, if it can not find the target in the dcache, it will invoke
ext2_lookup to look it up on disk.

(3) ext2_lookup calls ext2_inode_by_name, which calls ext2_find_entry to
lookup the dir entry.

(4) ext2_find_entry calls ext2_get_page to get the dir page. If
ext2_get_page fails by returning ERR_PTR(-ENOMEM), ext2_find_entry
will return NULL.

(5) ext2_inode_by_name returns NULL when ext2_find_entry returns NULL.
This causes ext2_lookup to return NULL, falsely indicating that the
target file or dir doesn't exist in the parent dir.

(6) open_namei calls vfs_create to create the file/dir on disk. For ext2
fs, the new dir entry will be placed in the first dir slot that fits.

if at step (4) ext2_get_page fails, a dir may contains more than one
entries with identical names.

ERROR: System call (sys_creat("2")) succeeds but read_cache_page failed at 'dir.c:ext2_get_page:154 dir.c:ext2_find_entry:325 dir.c:ext2_inode_by_name:366 '

============= Filesystem Image Before System Call ===================
1 files, 1 dirs, 3 nodes
[0:D]
[1:D]
============= Filesystem Image After System Call ===================
1 files, 1 dirs, 3 nodes
[0:D]
[1:D]
[2:F]

----------------------------------------------------------------------------
[BUG] similar bug on sys_mkdir. ext2_lookup can fail either because the
dir entry doesn't exist, or ext2_get_page fails to get memory.

ERROR: System call (sys_mkdir("2")) succeeds but read_cache_page failed at 'dir.c:ext2_get_page:154 dir.c:ext2_find_entry:325 dir.c:ext2_inode_by_name:366 '

============= Filesystem Image Before System Call ===================
1 files, 1 dirs, 3 nodes
[0:D]
[1:D]
============= Filesystem Image After System Call ===================
0 files, 2 dirs, 3 nodes
[0:D]
[1:D]
[2:D]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/