This is a follow up to Bug 279536. After applying the patch to fix the seg fault due to grub_printf, grub runs but prints the wrong values for mbi.mem_lower and mbi.mem_upper as reported in the banner. The values change on each subsequent run and mbi.mem_lower == mbi.mem_upper. Reproducible: Always Steps to Reproduce: 1.ebuild grub-0.97-r9.ebuild unpack 2.apply patch id=219645 3.add stdarg.h to -I in Makefile compile 4.run grub, note banner. Actual Results: You get something like this GNU GRUB version 0.97 (58347480K lower / 58347480K upper memory) but the values change on each subsequent run. Expected Results: You would expect values for mbi.mem_lower, mbi.mem_upper something like GNU GRUB version 0.97 (640K lower / 7168K upper memory)
Breakpoint 1, grub_printf (format=0xf7ff8668 "\n GNU GRUB version %s (%dK lower / %dK upper memory)\n\n") at char_io.c:200 200 *convert_to_ascii (str, c, va_arg(ap, unsigned long)) = 0; (gdb) print mbi.mem_upper $1 = 7168 (gdb) print mbi.mem_lower $2 = 640 But when it print the value of mbi.mem_lower and mbi.mem_upper it get garbage.
Okay a completely different approach is needed. Rather than fix up grub_printf and regress back, we can just turn off ssp on libgrub_a-*.o by adding -fno-stack-protector to the libgrub_a_CFLAGS, and still build the grub utility with ssp. You do not need to apply the patch from Bug 279536 to fix the variadic parameters, only the patch below.
Created attachment 220249 [details, diff] Turn off ssp in libgrub_a_CFLAGS This patch must be applied after all the other patches are applied or else it will fail. grub-0.97-r9.ebuild should be rewritten so that src_unpack patches something like this ... if [[ -n ${PATCHVER} ]] ; then EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/patch fi #bug 279536 epatch "${FILESDIR}"/fix-ssp.patch eautoreconf
so we're clear, libgrub.a is used entirely by the stage1/stage2 code as well as the Linux `grub` program ?
Yes, a quick read of grub/Makefile shows that grub is linked against libgrub.a. I've also written the ebuild and renamed the patch more appropriately. They are on the hardened-dev overlay for testing. I'll attach them here too.
Created attachment 222477 [details, diff] Turn off ssp in libgrub_a_CFLAGS
Created attachment 222479 [details] New ebuild to apply the fix ssp patch The patch needs to be applied after the other patches but before eautoreconf. I'd recommend bundling it with the other patches in grub-0.97-patches-1.9.tar.bz
http://sources.gentoo.org/gentoo/src/patchsets/grub/0.97/011_all_grub-0.97-varargs.patch?r1=1.1&r2=1.2
just reopening until such time as I spin the next grub patchset and ebuild.
When will the grub patchset be bumed? For the >=GCC 4.4.3 with SSP support will be commited to the tree this weekend.
i dont bump 0.9x versions ... being leaving that to Robin
Now committed and published as new patchset: grub-0.97-patches-1.10.tar.bz2 Ebuild sys-boot/grub-0.97-r10 committed.