Re: 2.2.8pre6, can't run ZMAGIC binaries

Andrea Arcangeli (andrea@e-mind.com)
Wed, 12 May 1999 18:36:03 +0200 (CEST)


On Wed, 12 May 1999, Linus Torvalds wrote:

>We already do not allow anybody doing "mmap()" to have anything but page
>alignment. The only loophole right now is "internal" mmaps in the kernel,

It seems to me that we are allowing it also on not VM_SHARED or a file
opened without O_RDWR:

[..]
int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
{
struct vm_operations_struct * ops;
struct inode *inode = file->f_dentry->d_inode;

if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE))
{
ops = &file_shared_mmap;
/* share_page() can only guarantee proper page sharing if
* the offsets are all page aligned. */
if (vma->vm_offset & (PAGE_SIZE - 1))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ here OK
return -EINVAL;
} else {
ops = &file_private_mmap;
if (inode->i_op && inode->i_op->bmap &&
(vma->vm_offset & (inode->i_sb->s_blocksize - 1)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ but here?
return -EINVAL;
}
[..]

Probably I am missing something in the whole picture...

>The reason we don't allow "real" mmap's is that we want to give the user
>mmap coherency (even with private mappings, if they are just read-only)

This make sense. Even if I think the natural is to allow alignment as far
as the bmap/readpage level can handle them.

>The only way to guarantee coherency is to guarantee that everybody has the
>same physical page - which in turn means that everybody has to agree on
>alignment. Thus the page-alignment requirement.

Ok.

>And once you have guaranteed page alignment for normal mmaps, the
>complexity issue makes it attractive to do the same for executables too.
>Note that 1kB executables have mondo problems: they don't even run if the
>underlying filesystem has a blocksize > 1kB - another thing that would be
>fixed if you just read them into memory directly.

Really as I stated in my previous email I think that the executable case
is not a big issue for making sure that everybody uses the same physiscal
page. My point is that nobody run `cp executable /dev/null` while running
`executable'.

Andrea Arcangeli

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