-
Phillip Potter authored
Many file systems use a copy&paste implementation of dirent to on-disk file type conversions. Furthermore the current ext2 implementation that gets copy&pasted has a lurking out-of-bounds access bug to the ext2_type_by_mode array. The array is defined with size S_IFMT >> S_SHIFT, so 15. This means that a corrupted inode with mode == S_IFMT will result in access beyond the end of the array as the array is always accessed with: ext2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; Create a common implementation to be used by file systems with some useful conversion helpers to reduce open coded file type conversions in file system code. Since the type ids are part of on-disk format of each filesystem, conversion of each filesystem will take care to build-assert that on-disk format type ids defined by the generic header match the filesystem defined ones. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Phillip Potter <phil@philpotter.co.uk> Signed-off-by: Jan Kara <jack@suse.cz>
d44170a7