Bug 11318 - /proc/self/maps doesn't display the real file offset
Summary: /proc/self/maps doesn't display the real file offset
Status: RESOLVED CODE_FIX
Alias: None
Product: Platform Specific/Hardware
Classification: Unclassified
Component: i386 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: platform_i386
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-13 06:39 UTC by Clement Calmels
Modified: 2008-08-18 14:13 UTC (History)
0 users

See Also:
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 (1.22 KB, text/x-csrc)
2008-08-13 06:41 UTC, Clement Calmels
Details
A way to correct the /proc/self/maps output (1.50 KB, patch)
2008-08-13 06:42 UTC, Clement Calmels
Details | Diff

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.

Note You need to log in before you can comment on or make changes to this bug.