lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 2 Oct 2018 03:28:14 +0100
From:   Al Viro <viro@...IV.linux.org.uk>
To:     Phillip Potter <phil@...lpotter.co.uk>
Cc:     dushistov@...l.ru, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fs: ufs: Convert ufs_set_de_type to use lookup table

On Mon, Oct 01, 2018 at 04:33:10PM +0100, Phillip Potter wrote:
> Modify ufs_set_de_type function in fs/ufs/util.h to use a lookup
> table rather than a switch statement, as per the TODO comment.

Brittle, that...   Something like fs/ext2/dir.c approach (that is,
#define S_SHIFT 12
static unsigned char ext2_type_by_mode[S_IFMT >> S_SHIFT] = {
        [S_IFREG >> S_SHIFT]    = EXT2_FT_REG_FILE,
        [S_IFDIR >> S_SHIFT]    = EXT2_FT_DIR,
        [S_IFCHR >> S_SHIFT]    = EXT2_FT_CHRDEV,
        [S_IFBLK >> S_SHIFT]    = EXT2_FT_BLKDEV,
        [S_IFIFO >> S_SHIFT]    = EXT2_FT_FIFO,
        [S_IFSOCK >> S_SHIFT]   = EXT2_FT_SOCK,
        [S_IFLNK >> S_SHIFT]    = EXT2_FT_SYMLINK,
};
in there) would be saner, IMO.  Note that DT_UNKNOWN is zero, so the
array elements lacking an explicit initializer will end up with that.

What's more, the values are ->i_mode >> 12 or 0, depending upon the
value being valid.  And since the upper layers do validate the type,
I'd consider simply using (inode->i_mode & S_IFMT) >> 12 there.
Unlike ext2, ufs stores straight bits 12..15 there (ext2 uses an
enum with sequential values instead; e.g. regular files are encoded
as 1 there, not 8 as on ufs)...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ