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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Sat, 23 May 2020 06:48:41 +0000
From:   Luis Chamberlain <mcgrof@...nel.org>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Scott Branden <scott.branden@...adcom.com>,
        David Brown <david.brown@...aro.org>,
        Alexander Viro <viro@...iv.linux.org.uk>,
        Shuah Khan <shuah@...nel.org>, bjorn.andersson@...aro.org,
        Shuah Khan <skhan@...uxfoundation.org>,
        Arnd Bergmann <arnd@...db.de>,
        "Rafael J . Wysocki" <rafael@...nel.org>,
        linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
        linux-fsdevel@...r.kernel.org,
        BCM Kernel Feedback <bcm-kernel-feedback-list@...adcom.com>,
        Olof Johansson <olof@...om.net>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Dan Carpenter <dan.carpenter@...cle.com>,
        Colin Ian King <colin.king@...onical.com>,
        Kees Cook <keescook@...omium.org>,
        Takashi Iwai <tiwai@...e.de>, linux-kselftest@...r.kernel.org,
        Andy Gross <agross@...nel.org>
Subject: Re: [PATCH] firmware_loader: change enum fw_opt to u32

On Sat, May 23, 2020 at 08:05:48AM +0200, Greg Kroah-Hartman wrote:
> On Fri, May 22, 2020 at 11:00:25PM +0000, Luis Chamberlain wrote:
> > On Fri, May 22, 2020 at 03:49:05PM -0700, Scott Branden wrote:
> > > Hi Luis,
> > > 
> > > On 2020-05-22 3:45 p.m., Luis Chamberlain wrote:
> > > > On Fri, May 22, 2020 at 02:46:58PM -0700, Scott Branden wrote:
> > > > >   /**
> > > > > - * enum fw_opt - options to control firmware loading behaviour
> > > > > + * fw_opt - options to control firmware loading behaviour
> > > > >    *
> > > > >    * @FW_OPT_UEVENT: Enables the fallback mechanism to send a kobject uevent
> > > > >    *	when the firmware is not found. Userspace is in charge to load the
> > > > > @@ -33,15 +33,13 @@
> > > > >    *	the platform's main firmware. If both this fallback and the sysfs
> > > > >    *      fallback are enabled, then this fallback will be tried first.
> > > > >    */
> > > > > -enum fw_opt {
> > > > > -	FW_OPT_UEVENT			= BIT(0),
> > > > > -	FW_OPT_NOWAIT			= BIT(1),
> > > > > -	FW_OPT_USERHELPER		= BIT(2),
> > > > > -	FW_OPT_NO_WARN			= BIT(3),
> > > > > -	FW_OPT_NOCACHE			= BIT(4),
> > > > > -	FW_OPT_NOFALLBACK_SYSFS		= BIT(5),
> > > > > -	FW_OPT_FALLBACK_PLATFORM	= BIT(6),
> > > > > -};
> > > > > +#define FW_OPT_UEVENT			BIT(0)
> > > > > +#define FW_OPT_NOWAIT			BIT(1)
> > > > > +#define FW_OPT_USERHELPER		BIT(2)
> > > > > +#define FW_OPT_NO_WARN			BIT(3)
> > > > > +#define FW_OPT_NOCACHE			BIT(4)
> > > > > +#define FW_OPT_NOFALLBACK_SYSFS		BIT(5)
> > > > > +#define FW_OPT_FALLBACK_PLATFORM	BIT(6)
> > > > Everything looked good up to here. The enum defines each flag.
> > > > We just want to use an enum for *one* flag represetnation, not
> > > > a bundle.
> > >
> > > I do not know exactly what you are looking for then.  The FW_OPT_*
> > > values are OR'd together in the code.  You still want the fw_opt enum
> > > above left in place entirely and then the values used in OR'd
> > > together?
> > 
> > Yes, exactly. If they are combined then we just use a u32 to represent
> > these are then flags combined. An enum represents just *one* flag, not
> > a set which are OR'd together. Let me know if this is still not clear.
> 
> If this is the case, why have an enum at all?  What difference is it
> from a #define like was done here?

If used on a switch to test for cases the compiler will error if you
miss one, and it is easier to use kdoc for them.

  Luis

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ