[patch] zmagic 2.2.13 fix [Re: binfmt_aout.c]

Andrea Arcangeli (andrea@suse.de)
Sat, 23 Oct 1999 16:02:16 +0200 (CEST)


On Fri, 22 Oct 1999 Andries.Brouwer@cwi.nl wrote:

>Not so strange, a mmap was missing and two offsets were wrong, if I am

The offset are not wrong, they are simply meaningless as I am doing
anonymous mappings (the file is NULL).

>Please do not put this in 2.2.14. As far as I can see the 2.2.13 patch
>on binfmt_aout.c does not really serve any useful purpose, quite the
>contrary,

It serve useful purposes instead, as now you can also run your ZMAIGC
binary-only stuff also on a ext2 filesystem with a 4k blocksize.

> retval = 0;
>- goto out_putf;
>+ } else {
>+ /* Now use mmap to map the library into memory. */
>+ error = do_mmap(file, start_addr, ex.a_text + ex.a_data,
>+ PROT_READ | PROT_WRITE | PROT_EXEC,
>+ MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE,
>+ N_TXTOFF(ex));
>+ retval = error;
>+ if (error != start_addr)
>+ goto out_putf;
> }
>- /* Now use mmap to map the library into memory. */
>- error = do_mmap(file, start_addr, ex.a_text + ex.a_data,
>- PROT_READ | PROT_WRITE | PROT_EXEC,
>- MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE,
>- N_TXTOFF(ex));
>- retval = error;
>- if (error != start_addr)
>- goto out_putf;
>
> len = PAGE_ALIGN(ex.a_text + ex.a_data);
> bss = ex.a_text + ex.a_data + ex.a_bss;

The above one is the part that made the difference in your patch. I forgot
to alloc the bss.

This four liner should be the only necessary fix against 2.2.13. Please
give it a try and feedback. Many thanks for your patch (reported working
by you) that showed me the real problem immediatly.

--- 2.2.13-zmagic/fs/binfmt_aout.c.~1~ Sat Oct 23 15:31:10 1999
+++ 2.2.13-zmagic/fs/binfmt_aout.c Sat Oct 23 15:44:34 1999
@@ -547,8 +547,7 @@
(char *)start_addr, ex.a_text + ex.a_data, 0);
flush_icache_range((unsigned long) start_addr,
(unsigned long) start_addr + ex.a_text + ex.a_data);
- retval = 0;
- goto out_putf;
+ goto map_bss;
}
/* Now use mmap to map the library into memory. */
error = do_mmap(file, start_addr, ex.a_text + ex.a_data,
@@ -559,6 +558,7 @@
if (error != start_addr)
goto out_putf;

+ map_bss:
len = PAGE_ALIGN(ex.a_text + ex.a_data);
bss = ex.a_text + ex.a_data + ex.a_bss;
if (bss > len) {

About the flooding printk I believe we can left them inserted. You should
have only binary-only stuff using the ZMAGIC format these days (and a
printk each time you start the zmagic program is not an issue I think). If
you are using GPL'd code in ZMAGIC format then you probably want to
upgrade your system instead of removing the printk (or use an old 2.0.x
kernel).

If we'll choose to remove the printk I'd like to take such a patch
separated from the above production-bugfix.

Thanks.

Andrea

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/