Messages in this thread Patches in this message | | | Date | Sat, 2 Oct 1999 23:34:14 +0200 (CEST) | From | Andrea Arcangeli <> | Subject | [patch] 2.3.18ac10 binfmt_a.out fixes |
| |
I think I found some bug in the a.out code.
It seems to me that we are still checking if the binary-file-offset is minor of the fs blocksize. So I disabled such checks as we don't mmap(MAP_PRIVATE) the file anymore if the fd_offset is not page aligned.
Then there was one do_brk mapping at address zero intead of the address where was want to load the binary.
As last thing I think the `start_addr & PAGE_MASK' was not necessary as first because the old code was using the plain start_addr for doing the mmap(MAP_PRIVATE). the start_addr is just forced to be page aligned in i386. Anyway the current code make not too much sense anyway as it should at least do something like:
start = start_addr & PAGE_MASK; end = start_addr + size; do_brk(start, end-start);
while right now it does:
do_brk(start_addr & PAGE_MASK, size);
I can't try the patch as I never had zmagic binaries under my hands.
--- 2.3.18ac10/fs/binfmt_aout.c Thu Sep 30 17:00:26 1999 +++ 2.3.18ac10-zmagic/fs/binfmt_aout.c Sat Oct 2 23:13:13 1999 @@ -270,7 +270,6 @@ unsigned long fd_offset; unsigned long rlim; int retval; - static unsigned long error_time=0; ex = *((struct exec *) bprm->buf); /* exec-header */ if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != OMAGIC && @@ -282,6 +281,7 @@ fd_offset = N_TXTOFF(ex); +#if 0 #ifdef __i386__ if (N_MAGIC(ex) == ZMAGIC && fd_offset != BLOCK_SIZE) { if((jiffies-error_time) >5) @@ -296,6 +296,7 @@ bprm->dentry->d_inode->i_op && bprm->dentry->d_inode->i_op->get_block && (fd_offset < bprm->dentry->d_inode->i_sb->s_blocksize)) { + static unsigned long error_time=0; if((jiffies-error_time) >5) { printk(KERN_NOTICE "N_TXTOFF < BLOCK_SIZE. Please convert binary.\n"); @@ -304,6 +305,7 @@ return -ENOEXEC; } #endif +#endif /* Check initial limits. This avoids letting people circumvent * size limits imposed on them by creating programs with large @@ -383,7 +385,7 @@ if (!file->f_op || !file->f_op->mmap || ((fd_offset & ~PAGE_MASK) != 0)) { fput(file); sys_close(fd); - do_brk(0, ex.a_text+ex.a_data); + do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data); read_exec(bprm->dentry, fd_offset, (char *) N_TXTADDR(ex), ex.a_text+ex.a_data, 0); flush_icache_range((unsigned long) N_TXTADDR(ex), @@ -493,11 +495,13 @@ goto out_putf; } +#if 0 if (N_MAGIC(ex) == ZMAGIC && N_TXTOFF(ex) && (N_TXTOFF(ex) < inode->i_sb->s_blocksize)) { printk("N_TXTOFF < BLOCK_SIZE. Please convert library\n"); goto out_putf; } +#endif if (N_FLAGS(ex)) goto out_putf; @@ -513,9 +517,7 @@ file->f_dentry->d_name.name ); - do_mmap(NULL, start_addr & PAGE_MASK, ex.a_text + ex.a_data + ex.a_bss, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_FIXED| MAP_PRIVATE, 0); + do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); read_exec(file->f_dentry, N_TXTOFF(ex), (char *)start_addr, ex.a_text + ex.a_data, 0);
I fixed the zero mapped address also in 2.2.13pre14 (I have not tried this one too).
--- 2.2.13pre14/fs/binfmt_aout.c Tue Sep 28 18:32:37 1999 +++ /tmp/binfmt_aout.c Sat Oct 2 23:32:33 1999 @@ -424,7 +424,7 @@ if (!file->f_op || !file->f_op->mmap) { sys_close(fd); - do_mmap(NULL, 0, ex.a_text+ex.a_data, + do_mmap(NULL, N_TXTADDR(ex), ex.a_text+ex.a_data, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_FIXED|MAP_PRIVATE, 0); read_exec(bprm->dentry, fd_offset, 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/
| |