cut and paste error?

Philip Blundell Philip.Blundell@pobox.com
Sun Jan 2 10:40:00 GMT 2000


>Which reminds me: Jakub, why do you make the distinction on whether
>the lower bits are zero?  This should not be necessary as mmap() can
>do what it wants with those bits.  The mmap syscall probably also just
>chops them off.  So this extra `if' should not be necessary.

Assuming you are referring to the `offset & 4095' bit, the kernel performs 
this check for the mmap syscall.  Eg, for i386, this code in 
arch/i386/kernel/sys_i386.c::old_mmap():

	err = -EINVAL;
	if (a.offset & ~PAGE_MASK)
		goto out;

If libc's mmap64 routine just shifts the offset without checking that the bits 
falling off the right are zeros, users passing in non-aligned addresses will 
get them silently truncated to the next page boundary down.  The calling 
program will almost certainly go wrong in this case.

p.




More information about the Libc-hacker mailing list