This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: cut and paste error?


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]