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: <20200919030212.GK32101@casper.infradead.org>
Date:   Sat, 19 Sep 2020 04:02:12 +0100
From:   Matthew Wilcox <willy@...radead.org>
To:     Arvind Sankar <nivedita@...m.mit.edu>
Cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        "Gustavo A. R. Silva" <gustavoars@...nel.org>,
        Dennis Zhou <dennis@...nel.org>, Tejun Heo <tj@...nel.org>,
        Christoph Lameter <cl@...ux.com>,
        Linux-MM <linux-mm@...ck.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Kees Cook <keescook@...omium.org>
Subject: Re: [GIT PULL] percpu fix for v5.9-rc6

On Fri, Sep 18, 2020 at 10:53:36PM -0400, Arvind Sankar wrote:
> I think you can't do this in standard C. It's a GCC extension.
> 
> 	A structure containing a flexible array member, or a union
> 	containing such a structure (possibly recursively), may not be a
> 	member of a structure or an element of an array. (However, these
> 	uses are permitted by GCC as extensions.)

I actually have a patch in the works which wants to do this.

 struct pagevec {
-       unsigned char nr;
-       bool percpu_pvec_drained;
-       struct page *pages[PAGEVEC_SIZE];
+       union {
+               struct {
+                       unsigned char sz;
+                       unsigned char nr;
+                       bool percpu_pvec_drained;
+                       struct page *pages[];
+               };
+               void *__p[PAGEVEC_SIZE + 1];
+       };
 };

I don't think ANSI C permits this, but it's useful to be able to declare
a pagevec on the stack and be guaranteed to get enough memory to hold
a useful sized array of pointers (as well as be able to dynamically
allocate a larger pagevec for the cases which want such a thing).

We could certainly split pagevec into a variable length array version
and have a struct stack_pagevec which had the extra padding, but that
involves changing a lot more code.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ