public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo commit in src/patchsets/grub/0.97: 011_all_grub-0.97-varargs.patch
@ 2010-02-14 16:15 Mike Frysinger (vapier)
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger (vapier) @ 2010-02-14 16:15 UTC (permalink / raw
  To: gentoo-commits

vapier      10/02/14 16:15:23

  Added:                011_all_grub-0.97-varargs.patch
  Log:
  use proper vararg processing to avoid segfaults on hardened systems #279536

Revision  Changes    Path
1.1                  src/patchsets/grub/0.97/011_all_grub-0.97-varargs.patch

file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/grub/0.97/011_all_grub-0.97-varargs.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/grub/0.97/011_all_grub-0.97-varargs.patch?rev=1.1&content-type=text/plain

Index: 011_all_grub-0.97-varargs.patch
===================================================================
https://bugs.gentoo.org/279536

use proper vararg functions instead of trying to walk the stack ourselves

patch by Anthony Basile <basile@opensource.dyc.edu>

--- grub-0.97/stage2/char_io.c
+++ grub-0.97/stage2/char_io.c
@@ -20,6 +20,7 @@
 
 #include <shared.h>
 #include <term.h>
+#include <stdarg.h>
 
 #ifdef SUPPORT_HERCULES
 # include <hercules.h>
@@ -178,10 +179,11 @@
 void
 grub_printf (const char *format,...)
 {
-  int *dataptr = (int *) &format;
+  va_list ap ;
+  va_start(ap, format);
+
   char c, str[16];
   
-  dataptr++;
 
   while ((c = *(format++)) != 0)
     {
@@ -196,17 +198,17 @@
 	  case 'X':
 #endif
 	  case 'u':
-	    *convert_to_ascii (str, c, *((unsigned long *) dataptr++)) = 0;
+	    *convert_to_ascii (str, c, va_arg(ap, unsigned long)) = 0;
 	    grub_putstr (str);
 	    break;
 
 #ifndef STAGE1_5
 	  case 'c':
-	    grub_putchar ((*(dataptr++)) & 0xff);
+	    grub_putchar (va_arg(ap, char) & 0xff);
 	    break;
 
 	  case 's':
-	    grub_putstr ((char *) *(dataptr++));
+	    grub_putstr (va_arg(ap, char *));
 	    break;
 #endif
 	  }
@@ -219,12 +221,12 @@
 {
   /* XXX hohmuth
      ugly hack -- should unify with printf() */
-  int *dataptr = (int *) &format;
+  va_list ap ;
+  va_start(ap, format);
+
   char c, *ptr, str[16];
   char *bp = buffer;
 
-  dataptr++;
-
   while ((c = *format++) != 0)
     {
       if (c != '%')
@@ -233,7 +235,7 @@
 	switch (c = *(format++))
 	  {
 	  case 'd': case 'u': case 'x':
-	    *convert_to_ascii (str, c, *((unsigned long *) dataptr++)) = 0;
+	    *convert_to_ascii (str, c, va_arg(ap, unsigned long)) = 0;
 
 	    ptr = str;
 
@@ -241,12 +243,12 @@
 	      *bp++ = *(ptr++); /* putchar(*(ptr++)); */
 	    break;
 
-	  case 'c': *bp++ = (*(dataptr++))&0xff;
-	    /* putchar((*(dataptr++))&0xff); */
+	  case 'c': *bp++ = va_arg(ap, char) & 0xff;
+	    /* putchar (va_arg(ap, char) & 0xff); */
 	    break;
 
 	  case 's':
-	    ptr = (char *) (*(dataptr++));
+	    ptr = va_arg(ap, char *);
 
 	    while ((c = *ptr++) != 0)
 	      *bp++ = c; /* putchar(c); */






^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gentoo-commits] gentoo commit in src/patchsets/grub/0.97: 011_all_grub-0.97-varargs.patch
@ 2010-03-21 17:39 Mike Frysinger (vapier)
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger (vapier) @ 2010-03-21 17:39 UTC (permalink / raw
  To: gentoo-commits

vapier      10/03/21 17:39:34

  Modified:             011_all_grub-0.97-varargs.patch
  Log:
  replace varags patch with ssp disabling #305283

Revision  Changes    Path
1.2                  src/patchsets/grub/0.97/011_all_grub-0.97-varargs.patch

file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/grub/0.97/011_all_grub-0.97-varargs.patch?rev=1.2&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/grub/0.97/011_all_grub-0.97-varargs.patch?rev=1.2&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/grub/0.97/011_all_grub-0.97-varargs.patch?r1=1.1&r2=1.2

Index: 011_all_grub-0.97-varargs.patch
===================================================================
RCS file: /var/cvsroot/gentoo/src/patchsets/grub/0.97/011_all_grub-0.97-varargs.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 011_all_grub-0.97-varargs.patch	14 Feb 2010 16:15:22 -0000	1.1
+++ 011_all_grub-0.97-varargs.patch	21 Mar 2010 17:39:34 -0000	1.2
@@ -1,92 +1,21 @@
-https://bugs.gentoo.org/279536
+http://bugs.gentoo.org/279536
+http://bugs.gentoo.org/305283
 
-use proper vararg functions instead of trying to walk the stack ourselves
+OK, on second thought, so much of the grub code has screwed up custom-stack
+walking code, we should just disable SSP everywhere to avoid a complete rewrite
+of things.  many files are shared between stage2 and userland `grub`.
 
-patch by Anthony Basile <basile@opensource.dyc.edu>
+XXX: should probably be integrated with configure.ac's grub_cv_cc_no_stack_protector logic
+
+--- grub-0.97/stage2/Makefile.am
++++ grub-0.97/stage2/Makefile.am
+@@ -20,7 +20,7 @@
+ 	fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \
+ 	fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \
+ 	terminfo.c tparm.c graphics.c
+-libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
++libgrub_a_CFLAGS = $(GRUB_CFLAGS) -fno-stack-protector -I$(top_srcdir)/lib \
+ 	-DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
+ 	-DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \
+ 	-DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \
 
---- grub-0.97/stage2/char_io.c
-+++ grub-0.97/stage2/char_io.c
-@@ -20,6 +20,7 @@
- 
- #include <shared.h>
- #include <term.h>
-+#include <stdarg.h>
- 
- #ifdef SUPPORT_HERCULES
- # include <hercules.h>
-@@ -178,10 +179,11 @@
- void
- grub_printf (const char *format,...)
- {
--  int *dataptr = (int *) &format;
-+  va_list ap ;
-+  va_start(ap, format);
-+
-   char c, str[16];
-   
--  dataptr++;
- 
-   while ((c = *(format++)) != 0)
-     {
-@@ -196,17 +198,17 @@
- 	  case 'X':
- #endif
- 	  case 'u':
--	    *convert_to_ascii (str, c, *((unsigned long *) dataptr++)) = 0;
-+	    *convert_to_ascii (str, c, va_arg(ap, unsigned long)) = 0;
- 	    grub_putstr (str);
- 	    break;
- 
- #ifndef STAGE1_5
- 	  case 'c':
--	    grub_putchar ((*(dataptr++)) & 0xff);
-+	    grub_putchar (va_arg(ap, char) & 0xff);
- 	    break;
- 
- 	  case 's':
--	    grub_putstr ((char *) *(dataptr++));
-+	    grub_putstr (va_arg(ap, char *));
- 	    break;
- #endif
- 	  }
-@@ -219,12 +221,12 @@
- {
-   /* XXX hohmuth
-      ugly hack -- should unify with printf() */
--  int *dataptr = (int *) &format;
-+  va_list ap ;
-+  va_start(ap, format);
-+
-   char c, *ptr, str[16];
-   char *bp = buffer;
- 
--  dataptr++;
--
-   while ((c = *format++) != 0)
-     {
-       if (c != '%')
-@@ -233,7 +235,7 @@
- 	switch (c = *(format++))
- 	  {
- 	  case 'd': case 'u': case 'x':
--	    *convert_to_ascii (str, c, *((unsigned long *) dataptr++)) = 0;
-+	    *convert_to_ascii (str, c, va_arg(ap, unsigned long)) = 0;
- 
- 	    ptr = str;
- 
-@@ -241,12 +243,12 @@
- 	      *bp++ = *(ptr++); /* putchar(*(ptr++)); */
- 	    break;
- 
--	  case 'c': *bp++ = (*(dataptr++))&0xff;
--	    /* putchar((*(dataptr++))&0xff); */
-+	  case 'c': *bp++ = va_arg(ap, char) & 0xff;
-+	    /* putchar (va_arg(ap, char) & 0xff); */
- 	    break;
- 
- 	  case 's':
--	    ptr = (char *) (*(dataptr++));
-+	    ptr = va_arg(ap, char *);
- 
- 	    while ((c = *ptr++) != 0)
- 	      *bp++ = c; /* putchar(c); */






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-21 17:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-21 17:39 [gentoo-commits] gentoo commit in src/patchsets/grub/0.97: 011_all_grub-0.97-varargs.patch Mike Frysinger (vapier)
  -- strict thread matches above, loose matches on Subject: below --
2010-02-14 16:15 Mike Frysinger (vapier)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox