Re: [PATCH 10/10] misc: fix ubsan warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/27/17 11:14 AM, Darrick J. Wong wrote:
> On Fri, Oct 27, 2017 at 08:48:07AM -0500, Eric Sandeen wrote:

...

>>> diff --git a/include/command.h b/include/command.h
>>> index fb3f5c7..59eab96 100644
>>> --- a/include/command.h
>>> +++ b/include/command.h
>>> @@ -25,7 +25,7 @@
>>>   * not iterate the command args function callout and so can be used
>>>   * for functions like "help" that should only ever be run once.
>>>   */
>>> -#define CMD_FLAG_ONESHOT	(1<<31)
>>> +#define CMD_FLAG_ONESHOT	(1U<<31)
>>>  #define CMD_FLAG_FOREIGN_OK	(1<<30)	/* command not restricted to XFS */
>>>  #define CMD_FLAG_LIBRARY	(1<<29)	/* command provided by libxcmd */
>>
>> What complained about this?  cmd flags is a signed int, right, so why is
>> this a problem?  (And why are we only using the top 3 bits?  And let's just do 1U
>> on every flag if it's really needed, but why is it needed?  I must be missing
>> something.)
> 
> I think the complaint is that "1" is signed int, and ubsan doesn't like
> us shifting a value bit into the sign bit.

Oh right, duh.

> But yeah, I suppose if we 'U'ize one of them we could do it for all.
> 
> (Though really, why not start with the lower bits?)

Heh, so:

io/init.h:

#define CMD_NOFILE_OK   (1<<0)  /* command doesn't need an open file    */
#define CMD_NOMAP_OK    (1<<1)  /* command doesn't need a mapped region */
#define CMD_FOREIGN_OK  CMD_FLAG_FOREIGN_OK

include/command.h:

#define CMD_FLAG_ONESHOT        (1<<31)
#define CMD_FLAG_FOREIGN_OK     (1<<30) /* command not restricted to XFS */
#define CMD_FLAG_LIBRARY        (1<<29) /* command provided by libxcmd */

What could possibly go wrong?

-Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux