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]
Message-ID: <20151015134844.GY6104@lakka.kapsi.fi>
Date:	Thu, 15 Oct 2015 16:48:44 +0300
From:	Mikko Rapeli <mikko.rapeli@....fi>
To:	Alex Deucher <alexdeucher@...il.com>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Maling list - DRI developers 
	<dri-devel@...ts.freedesktop.org>, linux-api@...r.kernel.org
Subject: Re: [PATCH v4 04/79] drm_mode.h: use __u32 and __u64 from
 linux/types.h

On Thu, Oct 15, 2015 at 09:32:10AM -0400, Alex Deucher wrote:
> On Thu, Oct 15, 2015 at 1:55 AM, Mikko Rapeli <mikko.rapeli@....fi> wrote:
> > Fixes userspace compilation error:
> >
> > drm/drm_mode.h:472:2: error: unknown type name ‘uint32_t’
> >
> > Signed-off-by: Mikko Rapeli <mikko.rapeli@....fi>
> 
> NACK on all these type conversions.  This has not been a problem for
> years and years and the result looks terrible.

Documentation/CodingStyle, section 5

 (e) Types safe for use in userspace.

     In certain structures which are visible to userspace, we cannot
     require C99 types and cannot use the 'u32' form above. Thus, we
     use __u32 and similar types in all structures which are shared
     with userspace.

I have only been looking at kernel headers from userspace occationally in
the past 10 years and had a several cases where the provided headers did
not compile when included into trivial programs trying to use the structs
for an ioctl() for example. This long lasting problem triggered me to write
a test for this and provide these fixes too. In previous reviews usage
of <stdint.h> and its types in kernel headers was already NACK'ed
so I changed several places from uint32_t's to __u32.

With these changes it is btw trivial now to add a grep test the there
are no uint32_t's in include/uapi/ anymore, thus enforcing that coding style
rule.

-Mikko

> Alex
> 
> > ---
> >  include/uapi/drm/drm_mode.h | 16 ++++++++--------
> >  1 file changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > index 359107a..0ed8d9d 100644
> > --- a/include/uapi/drm/drm_mode.h
> > +++ b/include/uapi/drm/drm_mode.h
> > @@ -508,14 +508,14 @@ struct drm_mode_crtc_page_flip {
> >
> >  /* create a dumb scanout buffer */
> >  struct drm_mode_create_dumb {
> > -       uint32_t height;
> > -       uint32_t width;
> > -       uint32_t bpp;
> > -       uint32_t flags;
> > +       __u32 height;
> > +       __u32 width;
> > +       __u32 bpp;
> > +       __u32 flags;
> >         /* handle, pitch, size will be returned */
> > -       uint32_t handle;
> > -       uint32_t pitch;
> > -       uint64_t size;
> > +       __u32 handle;
> > +       __u32 pitch;
> > +       __u64 size;
> >  };
> >
> >  /* set up for mmap of a dumb scanout buffer */
> > @@ -532,7 +532,7 @@ struct drm_mode_map_dumb {
> >  };
> >
> >  struct drm_mode_destroy_dumb {
> > -       uint32_t handle;
> > +       __u32 handle;
> >  };
> >
> >  /* page-flip flags are valid, plus: */
> > --
> > 2.5.0
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@...ts.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ