From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NNeSG-0000Pn-3p for mharc-grub-devel@gnu.org; Wed, 23 Dec 2009 22:33:36 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NNeSD-0000NB-QN for grub-devel@gnu.org; Wed, 23 Dec 2009 22:33:33 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NNeS9-0000Jb-8A for grub-devel@gnu.org; Wed, 23 Dec 2009 22:33:33 -0500 Received: from [199.232.76.173] (port=50791 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNeS9-0000JT-4G for grub-devel@gnu.org; Wed, 23 Dec 2009 22:33:29 -0500 Received: from iona.labri.fr ([147.210.8.143]:32805) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NNeS8-0001ZK-P0 for grub-devel@gnu.org; Wed, 23 Dec 2009 22:33:29 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by iona.labri.fr (Postfix) with ESMTP id 2B82D36B7A for ; Thu, 24 Dec 2009 04:33:27 +0100 (CET) X-Virus-Scanned: amavisd-new at labri.fr Received: from iona.labri.fr ([127.0.0.1]) by localhost (iona.labri.fr [127.0.0.1]) (amavisd-new, port 10027) with LMTP id iupPIt2S+HAY for ; Thu, 24 Dec 2009 04:33:27 +0100 (CET) Received: from [192.168.1.50] (c2433-1-88-160-112-182.fbx.proxad.net [88.160.112.182]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by iona.labri.fr (Postfix) with ESMTP id F0C9136B74 for ; Thu, 24 Dec 2009 04:33:26 +0100 (CET) Message-ID: <4B32E106.60608@labri.fr> Date: Thu, 24 Dec 2009 04:33:26 +0100 From: =?ISO-8859-1?Q?Gr=E9goire_Sutre?= User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707) MIME-Version: 1.0 To: The development of GNU GRUB References: <4B32821F.6050607@labri.fr> <4B32CA68.6090404@labri.fr> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: Non-static variables and nested function pointers [bug #28392] X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Dec 2009 03:33:34 -0000 Seth Goldberg wrote: > Exactly -- the presence of the execstack attribute in the segment is=20 > merely a request -- the kernel is free to discard it, and many OSes do,= =20 > as you've found :). The problem is more complex: I tried a simple example with a pointer to=20 a nested function, and it runs without any segfault on NetBSD/i386. This would suggest that, by default, the stack is executable -- at least=20 if trampolines are used? The same example segfaults on Debian/amd64 if compiled with=20 -Wl,-z,noexecstack (and does not segfault otherwise). After some digging, I found threads in the archives of the mailing list=20 on the problem of executable stack on NetBSD. This led to a patch that=20 is now part of trunk if I'm not mistaken. http://lists.gnu.org/archive/html/grub-devel/2008-02/msg00095.html I will try to test on NetBSD/amd64 and report here (in a few days), as=20 NetBSD's support for non-executable stack and heap seems better on amd64. Gr=E9goire #include int apply(void (*hook) (int *)) { int a =3D 0; hook(&a); hook(&a); return a; } int main (int argc, char *argv[]) { int j =3D 5; int res; void hook(int *n) { *n =3D *n + j; j--; } res =3D apply(hook); printf("result: %d, j=3D%d\n", res, j); return 0; }