Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 305283 - sys-boot/grub-0.97 fails to report memory limits correctly with >=sys-devel/gcc-4.1 SSP
Summary: sys-boot/grub-0.97 fails to report memory limits correctly with >=sys-devel/...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard: done:0.97-r10
Keywords:
Depends on:
Blocks: 318171
  Show dependency tree
 
Reported: 2010-02-15 16:34 UTC by Anthony Basile
Modified: 2010-06-25 06:21 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Turn off ssp in libgrub_a_CFLAGS (fix-ssp.patch,694 bytes, patch)
2010-02-18 23:11 UTC, Anthony Basile
Details | Diff
Turn off ssp in libgrub_a_CFLAGS (grub-0.97-fix-ssp.patch,694 bytes, patch)
2010-03-07 14:08 UTC, Anthony Basile
Details | Diff
New ebuild to apply the fix ssp patch (grub-0.97-r12.ebuild,8.99 KB, text/plain)
2010-03-07 14:11 UTC, Anthony Basile
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Basile gentoo-dev 2010-02-15 16:34:41 UTC
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)
Comment 1 Magnus Granberg gentoo-dev 2010-02-15 17:02:27 UTC
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.
Comment 2 Anthony Basile gentoo-dev 2010-02-18 23:08:08 UTC
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.
Comment 3 Anthony Basile gentoo-dev 2010-02-18 23:11:43 UTC
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
Comment 4 SpanKY gentoo-dev 2010-03-07 05:42:44 UTC
so we're clear, libgrub.a is used entirely by the stage1/stage2 code as well as the Linux `grub` program ?
Comment 5 Anthony Basile gentoo-dev 2010-03-07 14:06:59 UTC
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.
Comment 6 Anthony Basile gentoo-dev 2010-03-07 14:08:16 UTC
Created attachment 222477 [details, diff]
Turn off ssp in libgrub_a_CFLAGS
Comment 7 Anthony Basile gentoo-dev 2010-03-07 14:11:49 UTC
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
Comment 9 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2010-03-21 21:42:14 UTC
just reopening until such time as I spin the next grub patchset and ebuild.
Comment 10 Magnus Granberg gentoo-dev 2010-06-17 01:47:48 UTC
When will the grub patchset be bumed?
For the >=GCC 4.4.3 with SSP support will be commited to the tree this weekend.
Comment 11 SpanKY gentoo-dev 2010-06-17 02:03:52 UTC
i dont bump 0.9x versions ... being leaving that to Robin
Comment 12 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2010-06-25 06:21:24 UTC
Now committed and published as new patchset: grub-0.97-patches-1.10.tar.bz2
Ebuild sys-boot/grub-0.97-r10 committed.