From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GhvAJ-0006za-Dx for mharc-grub-devel@gnu.org; Wed, 08 Nov 2006 16:40:59 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GhvAH-0006xd-6N for grub-devel@gnu.org; Wed, 08 Nov 2006 16:40:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GhvAG-0006x8-GO for grub-devel@gnu.org; Wed, 08 Nov 2006 16:40:56 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GhvAF-0006wY-4c; Wed, 08 Nov 2006 16:40:55 -0500 Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GhvAF-0004hY-4c; Wed, 08 Nov 2006 16:40:55 -0500 Received: from tschwinge by fencepost.gnu.org with local (Exim 4.34) id 1GhvAE-0006io-De; Wed, 08 Nov 2006 16:40:54 -0500 Date: Wed, 8 Nov 2006 22:40:54 +0100 From: Thomas Schwinge To: bug-hurd@gnu.org, grub-devel@gnu.org Message-ID: <20061108214054.GU32338@fencepost> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="hSsVBZHIO2Q9XETc" Content-Disposition: inline X-Homepage: http://nic-nac-project.de/~schwinge/ User-Agent: Mutt/1.5.6+20040907i Cc: Subject: Stack protection via GCC's `-fstack-protector' X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Nov 2006 21:40:57 -0000 --hSsVBZHIO2Q9XETc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable [Please keep both and in the recipients list.] Hello! For some time, GCC now offers the following feature: info Gcc #v+ `-fstack-protector' Emit extra code to check for buffer overflows, such as stack smashing attacks. This is done by adding a guard variable to functions with vulnerable objects. This includes functions that call alloca, and functions with buffers larger than 8 bytes. The guards are initialized when a function is entered and then checked when the function exits. If a guard check fails, an error message is printed and the program exits. #v- I now happen to be running a GCC 4.1 installation which has that one enabled by default. Unfortunately, building GNU Mach and GRUB2 (didn't check GRUB legacy) is affected by that: GRUB2 #v+ [...] gcc -o kernel.exec kernel_img-kern_i386_pc_startup.o kernel_img-kern_main.o= kernel_img-kern_device.o kernel_img-kern_disk.o kernel_img-kern_dl.o kerne= l_img-kern_file.o kernel_img-kern_fs.o kernel_img-kern_err.o kernel_img-ker= n_misc.o kernel_img-kern_mm.o kernel_img-kern_loader.o kernel_img-kern_resc= ue.o kernel_img-kern_term.o kernel_img-kern_i386_dl.o kernel_img-kern_i386_= pc_init.o kernel_img-kern_parser.o kernel_img-kern_partition.o kernel_img-k= ern_env.o kernel_img-disk_i386_pc_biosdisk.o kernel_img-term_i386_pc_consol= e.o kernel_img-symlist.o -nostdlib -Wl,-N,-Ttext,8200 -fno-builtin -mrtd -= mregparm=3D3 -m32 kernel_img-kern_device.o: In function `grub_device_iterate': =2E./kern/device.c:142: undefined reference to `__stack_chk_fail' kernel_img-kern_disk.o: In function `grub_disk_write': =2E./kern/disk.c:553: undefined reference to `__stack_chk_fail' kernel_img-kern_misc.o: In function `grub_vsprintf': =2E./kern/misc.c:897: undefined reference to `__stack_chk_fail' kernel_img-kern_rescue.o: In function `grub_rescue_cmd_cat': =2E./kern/rescue.c:169: undefined reference to `__stack_chk_fail' kernel_img-kern_i386_pc_init.o: In function `grub_machine_set_prefix': =2E./kern/i386/pc/init.c:239: undefined reference to `__stack_chk_fail' kernel_img-kern_parser.o:../kern/parser.c:230: more undefined references to= `__stack_chk_fail' follow collect2: ld returned 1 exit status make: *** [kernel.exec] Error 1 #v- GNU Mach #v+ [...] ld -u _start -r -o gnumach.o --start-group libkernel.a liblinux.a liblinux= _pcmcia_cs_modules.a liblinux_pcmcia_cs_clients.a liblinux_pcmcia_cs_wirele= ss.a=20 nm -u gnumach.o | sed 's/ *U *//;s/^_*//' | sort -u > gnumach-undef sed '/^memcpy$/d; /^memmove$/d; /^memset$/d; /^bcopy$/d; /^bzero$/d; /^strc= hr$/d; /^strstr$/d; /^strsep$/d; /^strpbrk$/d; /^strtok$/d; /^htonl$/d; /^h= tons$/d; /^ntohl$/d; /^ntohs$/d; /^etext$/d; /^edata$/d; /^end$/d;' gnumach= -undef > gnumach-undef-bad if test -s gnumach-undef-bad; \ then cat gnumach-undef-bad; exit 2; else true; fi stack_chk_fail make[2]: *** [clib-routines.o] Error 2 make[2]: Leaving directory `/fs/data/mount/home/thomas/tmp/source/gnumach/g= numach-1-branch/build' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/fs/data/mount/home/thomas/tmp/source/gnumach/g= numach-1-branch/build' make: *** [all] Error 2 #v- Is it feasible to have the `-fstack-protector' functionality in GNU Mach and GRUB2 (and how to do that, then) or shall we unconditionally pass `-fno-stack-protector' if available? Regards, Thomas --hSsVBZHIO2Q9XETc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFFUk7mgfzh735dTTURAjY3AJ0Sjhr2m/fH2u2l/QKM+AoGilZVWgCeJ+Ma J6inXIzNbYlkZEwbafeaKds= =/jzY -----END PGP SIGNATURE----- --hSsVBZHIO2Q9XETc--