Re: [PATCH] a.out don't exec over NFS

Jan Rekorajski (baggins@hunter.mimuw.edu.pl)
Mon, 8 Mar 1999 15:49:12 +0100


--sm4nu43k4a2Rpi4c
Content-Type: text/plain; charset=us-ascii

On Sun, 07 Mar 1999, Linus Torvalds wrote:
>
> On Mon, 8 Mar 1999, Jan Rekorajski wrote:
> >
> > You mean mmap? The problem is that most mmaps expects offset to be blocksize
> > aligned.
>
> And some don't, like NFS.
>
> Basically, if a filesystem is using "generic_file_mmap()" (and most of
> them are), then the issue is whether the filesystem has a bmap() entry for
> the inode or not, and bmap is designed for block-aligned usage. Some fs's
> (msdos) have a special smap function to do "sector mapping" rather than
> block mapping.
>
> > In case of a.out offset is 1024 and if blocksize is != 1024 you
> > may forget running a.out binaries
>
> Wrong.
>
> It works perfectly fine on NFS. NFS doesn't use the block mpping stuff at
> all, and can map stuff at any offset.
>

OK, so is the following patch correct? It adds a check for bmap to
"generic_file_mmap()" and "do_load_aout_binary()" and if there isn't one
allows mmaping at any offset.

Jan

--sm4nu43k4a2Rpi4c
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="bmap-check.patch"

diff -ur linux-2.2.1/fs/binfmt_aout.c linux-2.2.1-e2c/fs/binfmt_aout.c
--- linux-2.2.1/fs/binfmt_aout.c Sat Nov 14 00:14:20 1998
+++ linux-2.2.1-e2c/fs/binfmt_aout.c Mon Mar 8 15:38:08 1999
@@ -327,6 +327,8 @@
}

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)) {
printk(KERN_NOTICE "N_TXTOFF < BLOCK_SIZE. Please convert binary.\n");
return -ENOEXEC;
diff -ur linux-2.2.1/mm/filemap.c linux-2.2.1-e2c/mm/filemap.c
--- linux-2.2.1/mm/filemap.c Sun Feb 7 03:04:53 1999
+++ linux-2.2.1-e2c/mm/filemap.c Mon Mar 8 15:39:22 1999
@@ -1293,7 +1293,8 @@
return -EINVAL;
} else {
ops = &file_private_mmap;
- if (vma->vm_offset & (inode->i_sb->s_blocksize - 1))
+ if (inode->i_op && inode->i_op->bmap &&
+ (vma->vm_offset & (inode->i_sb->s_blocksize - 1)))
return -EINVAL;
}
if (!inode->i_sb || !S_ISREG(inode->i_mode))

--sm4nu43k4a2Rpi4c--

-
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/