This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
Clement Calmels
1804dc6e14
/proc/self/maps doesn't display the real file offset
This addresses
http://bugzilla.kernel.org/show_bug.cgi?id=11318
In function show_map (file: fs/proc/task_mmu.c), if vma->vm_pgoff > 2^20
than (vma->vm_pgoff << PAGE_SIZE) is greater than 2^32 (with PAGE_SIZE
equal to 4096 (i.e. 2^12). The next seq_printf use an unsigned long for
the conversion of (vma->vm_pgoff << PAGE_SIZE), as a result the offset
value displayed in /proc/self/maps is truncated if the page offset is
greater than 2^20.
A test that shows this issue:
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#define PAGE_SIZE (getpagesize())
#if __i386__
# define U64_STR "%llx"
#elif __x86_64
# define U64_STR "%lx"
#else
# error "Architecture Unsupported"
#endif
int main(int argc, char *argv[])
{
int fd;
char *addr;
off64_t offset = 0x10000000;
char *filename = "/dev/zero";
fd = open(filename, O_RDONLY);
if (fd < 0) {
perror("open");
return 1;
}
offset *= 0x10;
printf("offset = " U64_STR "\n", offset);
addr = (char*)mmap64(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd,
offset);
if ((void*)addr == MAP_FAILED) {
perror("mmap64");
return 1;
}
{
FILE *fmaps;
char *line = NULL;
size_t len = 0;
ssize_t read;
size_t filename_len = strlen(filename);
fmaps = fopen("/proc/self/maps", "r");
if (!fmaps) {
perror("fopen");
return 1;
}
while ((read = getline(&line, &len, fmaps)) != -1) {
if ((read > filename_len + 1)
&& (strncmp(&line[read - filename_len - 1], filename, filename_len) == 0))
printf("%s", line);
}
if (line)
free(line);
fclose(fmaps);
}
close(fd);
return 0;
}
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Clement Calmels <cboulte@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
2008-08-20 15:40:30 -07:00 |
.. |
Kconfig
|
proc: move Kconfig to fs/proc/Kconfig
|
2008-07-25 10:53:45 -07:00 |
Makefile
|
[NET]: Make /proc/net per network namespace
|
2007-10-10 16:49:06 -07:00 |
array.c
|
tracehook: tracehook_tracer_task
|
2008-07-26 12:00:08 -07:00 |
base.c
|
proc: fix warnings
|
2008-08-05 14:33:50 -07:00 |
generic.c
|
[PATCH 2/2] proc: switch inode number allocation to IDA
|
2008-08-01 11:25:28 -04:00 |
inode-alloc.txt
|
Linux-2.6.12-rc2
|
2005-04-16 15:20:36 -07:00 |
inode.c
|
[PATCH] sanitize proc_sysctl
|
2008-07-26 20:53:12 -04:00 |
internal.h
|
proc: always do ->release
|
2008-07-25 10:53:44 -07:00 |
kcore.c
|
elf: use ELF_CORE_EFLAGS for kcore ELF header flags
|
2008-07-25 10:53:42 -07:00 |
kmsg.c
|
move proc_kmsg_operations to fs/proc/internal.h
|
2008-07-25 10:53:44 -07:00 |
mmu.c
|
fs/proc/mmu.c: headers butchery
|
2007-10-17 08:42:48 -07:00 |
nommu.c
|
/proc/self/maps doesn't display the real file offset
|
2008-08-20 15:40:30 -07:00 |
proc_devtree.c
|
[POWERPC] Make struct property's value a void *
|
2007-04-13 03:55:18 +10:00 |
proc_misc.c
|
vmallocinfo: add NUMA information
|
2008-07-24 10:47:17 -07:00 |
proc_net.c
|
netns: make get_proc_net() static
|
2008-07-22 14:19:19 -07:00 |
proc_sysctl.c
|
[PATCH] sanitize ->permission() prototype
|
2008-07-26 20:53:14 -04:00 |
proc_tty.c
|
tty: Ldisc revamp
|
2008-07-20 17:12:34 -07:00 |
root.c
|
proc: introduce proc_create_data to setup de->data
|
2008-04-29 08:06:20 -07:00 |
task_mmu.c
|
/proc/self/maps doesn't display the real file offset
|
2008-08-20 15:40:30 -07:00 |
task_nommu.c
|
Security: split proc ptrace checking into read vs. attach
|
2008-07-14 15:01:47 +10:00 |
vmcore.c
|
aout: remove unnecessary inclusions of {asm, linux}/a.out.h
|
2008-02-08 09:22:30 -08:00 |