--- 2.2.13pre17/fs/binfmt_aout.c Tue Oct 12 23:40:55 1999 +++ 2.2.13pre17-zmagic/fs/binfmt_aout.c Sat Oct 16 16:18:20 1999 @@ -311,7 +311,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 && @@ -323,29 +322,6 @@ fd_offset = N_TXTOFF(ex); -#ifdef __i386__ - if (N_MAGIC(ex) == ZMAGIC && fd_offset != BLOCK_SIZE) { - if((jiffies-error_time) >5) - { - printk(KERN_NOTICE "N_TXTOFF != BLOCK_SIZE. See a.out.h.\n"); - error_time=jiffies; - } - return -ENOEXEC; - } - - if (N_MAGIC(ex) == ZMAGIC && ex.a_text && - bprm->dentry->d_inode->i_op && - bprm->dentry->d_inode->i_op->bmap && - (fd_offset < bprm->dentry->d_inode->i_sb->s_blocksize)) { - if((jiffies-error_time) >5) - { - printk(KERN_NOTICE "N_TXTOFF < BLOCK_SIZE. Please convert binary.\n"); - error_time=jiffies; - } - return -ENOEXEC; - } -#endif - /* Check initial limits. This avoids letting people circumvent * size limits imposed on them by creating programs with large * arrays in the data or bss. @@ -413,6 +389,7 @@ flush_icache_range((unsigned long) 0, (unsigned long) ex.a_text+ex.a_data); } else { + static unsigned long error_time; if ((ex.a_text & 0xfff || ex.a_data & 0xfff) && (N_MAGIC(ex) != NMAGIC)) printk(KERN_NOTICE "executable not page aligned\n"); @@ -420,11 +397,22 @@ fd = open_dentry(bprm->dentry, O_RDONLY); if (fd < 0) return fd; - file = fcheck(fd); + file = fget(fd); - if (!file->f_op || !file->f_op->mmap) { + if ((fd_offset & ~PAGE_MASK) != 0 && + (jiffies-error_time) > 5*HZ) + { + printk(KERN_WARNING + "fd_offset is not page aligned. Please convert program: %s\n", + file->f_dentry->d_name.name + ); + error_time = jiffies; + } + + if (!file->f_op || !file->f_op->mmap || ((fd_offset & ~PAGE_MASK) != 0)) { + fput(file); 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, @@ -441,6 +429,7 @@ fd_offset); if (error != N_TXTADDR(ex)) { + fput(file); sys_close(fd); send_sig(SIGKILL, current, 0); return error; @@ -450,6 +439,7 @@ PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE, fd_offset + ex.a_text); + fput(file); sys_close(fd); if (error != N_DATADDR(ex)) { send_sig(SIGKILL, current, 0); @@ -529,12 +519,6 @@ goto out_putf; } - 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; - } - if (N_FLAGS(ex)) goto out_putf; @@ -543,6 +527,26 @@ start_addr = ex.a_entry & 0xfffff000; + if ((N_TXTOFF(ex) & ~PAGE_MASK) != 0) { + static unsigned long error_time; + + if ((jiffies-error_time) > 5*HZ) + { + printk(KERN_WARNING + "N_TXTOFF is not page aligned. Please convert library: %s\n", + file->f_dentry->d_name.name); + error_time = jiffies; + } + do_mmap(NULL, start_addr, ex.a_text + ex.a_data, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_FIXED| MAP_PRIVATE, 0); + read_exec(file->f_dentry, N_TXTOFF(ex), + (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; + } /* 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,