All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] Dynamic Loader Bugs
@ 2004-10-09 16:42 Timothy Baldwin
  2004-10-14 11:34 ` Marco Gerards
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Timothy Baldwin @ 2004-10-09 16:42 UTC (permalink / raw)
  To: The development of GRUB 2


[-- Attachment #1.1: Type: text/plain, Size: 957 bytes --]

1. Gcc 3.4 will delete the module initialization and finalisation functions as 
they appear to be unused.

2. grub_dl_load_file contains a null pointer dereference.

3. The modules contain common symbols, which the dynamic loader can't handle.

4. The dynamic loader uses the size of common symbols as their address, 
instead of returning an error.

Attached is a patch which fixes points 1 to 3.

2004-10-09  Timothy Baldwin  <T.E.Baldwin99@members.leeds.ac.uk>

        * include/grub/dl.h (GRUB_MOD_INIT): Changed __attribute__ ((unused)) 
        to __attribute__ ((used)).
        (GRUB_MOD_FINI): Likewise.
        * kern/dl.c (grub_dl_load_file): Fix null pointer dereference.
        * genmk.rb (PModule): Assign space to common symbols when
          linking modules. 


-- 
Member AFFS, WYLUG, SWP (UK), ANL, RESPECT, Leeds SA, Leeds Anti-war coalition
No to software patents!    No to DRM/EUCD - hands off our computers!

[-- Attachment #1.2: dl.diff --]
[-- Type: text/x-diff, Size: 1847 bytes --]

Index: genmk.rb
===================================================================
RCS file: /cvsroot/grub/grub2/genmk.rb,v
retrieving revision 1.8
diff -u -r1.8 genmk.rb
--- genmk.rb	4 Apr 2004 13:45:59 -0000	1.8
+++ genmk.rb	9 Oct 2004 15:31:20 -0000
@@ -117,12 +117,12 @@
 
 #{@name}: #{pre_obj} #{mod_obj}
 	-rm -f $@
-	$(LD) -r -o $@ $^
+	$(LD) -r -d -o $@ $^
 	$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
 
 #{pre_obj}: #{objs_str}
 	-rm -f $@
-	$(LD) -r -o $@ $^
+	$(LD) -r -d -o $@ $^
 
 #{mod_obj}: #{mod_src}
 	$(CC) $(CPPFLAGS) $(CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $<
Index: include/grub/dl.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/dl.h,v
retrieving revision 1.6
diff -u -r1.6 dl.h
--- include/grub/dl.h	4 Apr 2004 13:46:00 -0000	1.6
+++ include/grub/dl.h	9 Oct 2004 15:31:21 -0000
@@ -26,13 +26,13 @@
 #include <grub/types.h>
 
 #define GRUB_MOD_INIT	\
-static void grub_mod_init (grub_dl_t mod) __attribute__ ((unused)); \
+static void grub_mod_init (grub_dl_t mod) __attribute__ ((used)); \
 static void \
 grub_mod_init (grub_dl_t mod)
 
 #define GRUB_MOD_FINI	\
-static void grub_mod_fini (void) __attribute__ ((unused)); \
+static void grub_mod_fini (void) __attribute__ ((used)); \
 static void \
 grub_mod_fini (void)
 
 #define GRUB_MOD_NAME(name)	\
Index: kern/dl.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/dl.c,v
retrieving revision 1.7
diff -u -r1.7 dl.c
--- kern/dl.c	4 Apr 2004 13:46:01 -0000	1.7
+++ kern/dl.c	9 Oct 2004 15:31:21 -0000
@@ -548,6 +548,8 @@
     goto failed;
 
   mod = grub_dl_load_core (core, size);
+  if (! mod) goto failed;
+  
   mod->ref_count = 0;
 
  failed:

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2005-01-20 18:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-09 16:42 [patch] Dynamic Loader Bugs Timothy Baldwin
2004-10-14 11:34 ` Marco Gerards
2004-10-17 23:11   ` Timothy Baldwin
2004-10-15  0:07 ` Tomas Ebenlendr
2004-10-15 10:51   ` Marco Gerards
2004-10-15 12:13     ` Yoshinori K. Okuji
2004-10-15 13:19       ` Marco Gerards
2004-11-13 12:32       ` Marco Gerards
2004-11-13 13:15         ` Yoshinori K. Okuji
2004-10-17 23:11   ` Timothy Baldwin
2005-01-20 17:33 ` Marco Gerards

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.