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:   Mon, 17 Dec 2018 22:43:40 -0700
From:   Andreas Dilger <adilger@...ger.ca>
To:     "Theodore Y. Ts'o" <tytso@....edu>
Cc:     Ext4 Developers List <linux-ext4@...r.kernel.org>
Subject: Re: [PATCH] ext4: avoid declaring fs inconsistent due to invalid file
 handles

On Dec 17, 2018, at 9:45 PM, Theodore Y. Ts'o <tytso@....edu> wrote:
> 
> On Mon, Dec 17, 2018 at 03:53:46PM -0700, Andreas Dilger wrote:
>>> +#define EXT4_IGET_NORMAL	1
>>> +#define EXT4_IGET_HANDLE	2
>> 
>> It would be better to make this:
>> 
>> enum ext4_iget_flags {
>>        EXT4_IGET_RESERVED = 0x00,	/* just guessing, see further below */
>> 	EXT4_IGET_NORMAL   = 0x01,
>> 	EXT4_IGET_HANDLE   = 0x02,
>> };
>> 
>>> -	inode = ext4_iget(sb, ino);
>>> +	inode = ext4_iget(sb, ino, 0);
>> 
>> What does "0" mean?  It isn't in the list of EXT4_IGET_* flags.
>> I'm guessing it means that access to reserved or otherwise invalid
>> inodes is allowed?
> 
> The flags are boolean OR'ed together, much like O_TRUNC | O_CREAT,
> etc.  So an enum isn't really appropriate.

I don't think that it is verboten to use binary flag values in an enum,
if you explicitly specify the values, which is why I used "0x01", "0x02"
to make it more clear these are binary values.  IMHO, using a named enum
is a good way to annotate the function parameters rather than a generic
"int flag" parameter that is ambiguous unless you look at the function
code to see what the values of "flag" might be.

> So 0 means we're not enforcing "must be a normal inode" rules, and
> we're also not going to avoid throwing an EXT4_ERROR if the inode
> number is invalid.

So that matches what I reverse engineered, which was EXT4_IGET_RESERVED
but might have a better name if you can think of it.  I originally had
EXT4_IGET_NONE = 0, but I don't think that is quite correct.

> I had thought it was obvious that flags can be or'ed together, and
> that "modes" are what might use an enum.

Their definition as "1" and "2" didn't make it clear that the next
possible value was "4" and not "3".

> I personally like flags because the can be more expressive, although
> I can see that "modes" are simpler since there is a much smaller set
> of valid modes, and you don't have to worry about define what happens
> when flags interact in unusual/unexpected ways.

I'm not against flags, and I figured out that they were orthogonal
flags after reading the whole patch.

> It sounds like should add more explicit documentation at the very
> least so it's more clear what's going on.
> 
>      	      	   	 	      - Ted


Cheers, Andreas






Download attachment "signature.asc" of type "application/pgp-signature" (874 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ