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:   Fri, 7 Jan 2022 22:18:30 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Vlastimil Babka' <vbabka@...e.cz>,
        Pintu Agarwal <pintu.ping@...il.com>,
        Christian Brauner <christian.brauner@...ntu.com>
CC:     Cyrill Gorcunov <gorcunov@...il.com>,
        Pintu Kumar <quic_pintu@...cinc.com>,
        open list <linux-kernel@...r.kernel.org>,
        "Andrew Morton" <akpm@...ux-foundation.org>,
        linux-mm <linux-mm@...ck.org>,
        "ebiederm@...ssion.com" <ebiederm@...ssion.com>,
        "sfr@...b.auug.org.au" <sfr@...b.auug.org.au>,
        "legion@...nel.org" <legion@...nel.org>,
        "sashal@...nel.org" <sashal@...nel.org>,
        "chris.hyser@...cle.com" <chris.hyser@...cle.com>,
        "ccross@...gle.com" <ccross@...gle.com>,
        "pcc@...gle.com" <pcc@...gle.com>,
        "dave@...olabs.net" <dave@...olabs.net>,
        "caoxiaofeng@...ong.com" <caoxiaofeng@...ong.com>,
        "david@...hat.com" <david@...hat.com>,
        Linux API <linux-api@...r.kernel.org>
Subject: RE: [PATCH] sysinfo: include availram field in sysinfo struct

> > These are the header changes for quick look:
> > {{{
> > diff --git a/include/uapi/linux/sysinfo.h b/include/uapi/linux/sysinfo.h
> > index 6e77e90..fe84c6a 100644
> > --- a/include/uapi/linux/sysinfo.h
> > +++ b/include/uapi/linux/sysinfo.h
> > @@ -12,7 +12,6 @@ struct sysinfo {
> >         __kernel_ulong_t freeram;       /* Available memory size */
> >         __kernel_ulong_t sharedram;     /* Amount of shared memory */
> >         __kernel_ulong_t bufferram;     /* Memory used by buffers */
> > -       __kernel_ulong_t availram;      /* Memory available for allocation */
> >         __kernel_ulong_t totalswap;     /* Total swap space size */
> >         __kernel_ulong_t freeswap;      /* swap space still available */
> >         __u16 procs;                    /* Number of current processes */
> > @@ -20,7 +19,8 @@ struct sysinfo {
> >         __kernel_ulong_t totalhigh;     /* Total high memory size */
> >         __kernel_ulong_t freehigh;      /* Available high memory size */
> >         __u32 mem_unit;                 /* Memory unit size in bytes */
> > -       char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)];   /*
> > Padding: libc5 uses this.. */
> > +       __kernel_ulong_t availram;      /* Memory available for allocation */
> > +       char _f[20-3*sizeof(__kernel_ulong_t)-sizeof(__u32)];   /*
> > Padding: libc5 uses this.. */
> >  };
> > }}}
> >
> > If this is fine, I will push the new patch set.
> 
> Please CC linux-api@...r.kernel.org on the new posting.

That is probably still broken.
If __kernel_ulong_t is 64bit there is architecture
dependant padding after mem_unit.

In particular a 32bit x86 app running on a 64bit kernel
will probably see the wrong layout.

You definitely need a compile-time assert on the total structure size.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ