Bug 11318

Summary: /proc/self/maps doesn't display the real file offset
Product: Platform Specific/Hardware Reporter: Clement Calmels (cboulte)
Component: i386Assignee: platform_i386
Status: RESOLVED CODE_FIX    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.26 Subsystem:
Regression: --- Bisected commit-id:
Attachments: a program that use mmap64 to mmap with an offset > 2^32 and display the associated line in /proc/self/maps
A way to correct the /proc/self/maps output

Description Clement Calmels 2008-08-13 06:39:11 UTC
Latest working kernel version:
Earliest failing kernel version:
Distribution: Sles 10 SP 1
Hardware Environment: HP Proliant DL140
Software Environment:
Problem Description:

I wrote a simple test that use mmap64 to map a file (/dev/zero) with an offset value of 0x100000000. When I check /proc/self/maps the offset value reported is 00000000. The issue is in fs/proc/task_mmu.c function 'show_map' where 'seq_printf' use the %lx converter to print a (long * PAGE_SIZE) value.
In my case the offset is 0x100000000 (long long) and the pgoffset is 0x100000 (long).

Steps to reproduce:

I will attach the test I wrote (compile line: $ gcc -O2 -g -Wall mmap64.c -o mmap64) and a patch that seems to correct this issue.
Comment 1 Clement Calmels 2008-08-13 06:41:29 UTC
Created attachment 17218 [details]
a program that use mmap64 to mmap with an offset > 2^32 and display the associated line in /proc/self/maps

Compile:
gcc -g -Wall -O2 src/mmap64.c -o mmap64

Result on a 2.6.26:
$ ./mmap64
offset = 100000000
b7efd000-b7efe000 r--p 00000000 00:0e 2050      /dev/zero
Comment 2 Clement Calmels 2008-08-13 06:42:55 UTC
Created attachment 17219 [details]
A way to correct the /proc/self/maps output

Test on 2.6.26, i386 and x86_64.
Comment 3 Andrew Morton 2008-08-13 10:11:29 UTC
OK.

Please submit patches via email, as per Documentation/SubmittingPatches.

cc this one to linux-kernel@vger.kernel.org and to akpm@linux-foundation.org

thanks.
Comment 4 Andrew Morton 2008-08-18 14:13:33 UTC
Merged proc-self-maps-doesnt-display-the-real-file-offset.patch into -mm.