Skip to contentSkip to conversation

negative seek offsets in VFS

DISCUSSION Paul Taysom 1 participant 1 message May 26, 2005 VFS

lore
Share & tools
lore
#0 lore raw

The addresses returned from /proc/kallsyms on the x86_64 are negative and when I print the address of a kernel variable with "%p" it comes out negative.

Paul Taysom

Quoted 4 lines
Quoted 1 line
Quoted 1 line

Bryan Henderson <[email protected]> 5/25/2005 6:56:26 PM >>>

My x86-64 users are complaining again that they cannot reach kernel text addresses in /dev/kmem. The reason is that they are negative and the the VFS read and seek code just EINVALs them.

Come now -- the kernel addresses are not negative, and neither is any file offset.

You apparently mean that when you coerce a kernel address which exceeds the range of a file offset type into a file offset type, it comes out negative.

Quoted 3 lines

I dont quite get why they are there anyways, the super block has max file size field and checking against that should be enough for all the filesystems, no?

But this isn't about exceeding a maximum file size -- it's about exceeding the range of offsets that is representable in this C data type.

So I guess the real question is why is the loff_t type signed, thereby making it incapable of representing sufficiently large offsets? The answer is that there are POSIX interfaces that overload a single data structure as both a file offset or size and a status code. If a loff_t value is positive, it is a file offset, but if it's negative, it's a status code. Consider lseek -- if you allowed a negative offset and just declared that it stands for the large positive offset you'd get if you coerced it to an unsigned 64 bit integer, then how would you tell a success from a failure in the return code?

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html