)]}'
{
  "commit": "1804dc6e145f3f24a8c94deddfc0a986d380a27f",
  "tree": "965ad5f3dfa7c6dc52bdfab7d838a82f78c8ad12",
  "parents": [
    "35fc908dc0e7ab0002ef18787886cc1340028020"
  ],
  "author": {
    "name": "Clement Calmels",
    "email": "cboulte@gmail.com",
    "time": "Wed Aug 20 14:09:00 2008 -0700"
  },
  "committer": {
    "name": "Linus Torvalds",
    "email": "torvalds@linux-foundation.org",
    "time": "Wed Aug 20 15:40:30 2008 -0700"
  },
  "message": "/proc/self/maps doesn\u0027t display the real file offset\n\nThis addresses\n\n\thttp://bugzilla.kernel.org/show_bug.cgi?id\u003d11318\n\nIn function show_map (file: fs/proc/task_mmu.c), if vma-\u003evm_pgoff \u003e 2^20\nthan (vma-\u003evm_pgoff \u003c\u003c PAGE_SIZE) is greater than 2^32 (with PAGE_SIZE\nequal to 4096 (i.e.  2^12).  The next seq_printf use an unsigned long for\nthe conversion of (vma-\u003evm_pgoff \u003c\u003c PAGE_SIZE), as a result the offset\nvalue displayed in /proc/self/maps is truncated if the page offset is\ngreater than 2^20.\n\nA test that shows this issue:\n\n#define _GNU_SOURCE\n#include \u003csys/types.h\u003e\n#include \u003csys/stat.h\u003e\n#include \u003csys/mman.h\u003e\n#include \u003cstdlib.h\u003e\n#include \u003cstdio.h\u003e\n#include \u003cfcntl.h\u003e\n#include \u003cunistd.h\u003e\n#include \u003cstring.h\u003e\n\n#define PAGE_SIZE (getpagesize())\n\n#if __i386__\n#   define U64_STR \"%llx\"\n#elif __x86_64\n#   define U64_STR \"%lx\"\n#else\n#   error \"Architecture Unsupported\"\n#endif\n\nint main(int argc, char *argv[])\n{\n\tint fd;\n\tchar *addr;\n\toff64_t offset \u003d 0x10000000;\n\tchar *filename \u003d \"/dev/zero\";\n\n\tfd \u003d open(filename, O_RDONLY);\n\tif (fd \u003c 0) {\n\t\tperror(\"open\");\n\t\treturn 1;\n\t}\n\n\toffset *\u003d 0x10;\n\tprintf(\"offset \u003d \" U64_STR \"\\n\", offset);\n\n\taddr \u003d (char*)mmap64(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd,\n\t\t\t     offset);\n\tif ((void*)addr \u003d\u003d MAP_FAILED) {\n\t\tperror(\"mmap64\");\n\t\treturn 1;\n\t}\n\n\t{\n\t\tFILE *fmaps;\n\t\tchar *line \u003d NULL;\n\t\tsize_t len \u003d 0;\n\t\tssize_t read;\n\t\tsize_t filename_len \u003d strlen(filename);\n\n\t\tfmaps \u003d fopen(\"/proc/self/maps\", \"r\");\n\t\tif (!fmaps) {\n\t\t\tperror(\"fopen\");\n\t\t\treturn 1;\n\t\t}\n\t\twhile ((read \u003d getline(\u0026line, \u0026len, fmaps)) !\u003d -1) {\n\t\t\tif ((read \u003e filename_len + 1)\n\t\t\t    \u0026\u0026 (strncmp(\u0026line[read - filename_len - 1], filename, filename_len) \u003d\u003d 0))\n\t\t\t\tprintf(\"%s\", line);\n\t\t}\n\n\t\tif (line)\n\t\t\tfree(line);\n\n\t\tfclose(fmaps);\n\t}\n\n\tclose(fd);\n\treturn 0;\n}\n\n[akpm@linux-foundation.org: coding-style fixes]\nSigned-off-by: Clement Calmels \u003ccboulte@gmail.com\u003e\nSigned-off-by: Andrew Morton \u003cakpm@linux-foundation.org\u003e\nSigned-off-by: Linus Torvalds \u003ctorvalds@linux-foundation.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "79ecd281d2cbf1e1db1484ffe4b24413bc6f9e63",
      "old_mode": 33188,
      "old_path": "fs/proc/nommu.c",
      "new_id": "3f87d2632947371b47df580c32d041fb39bb91ba",
      "new_mode": 33188,
      "new_path": "fs/proc/nommu.c"
    },
    {
      "type": "modify",
      "old_id": "7546a918f7907612b078c411d8eeb288b099ffc2",
      "old_mode": 33188,
      "old_path": "fs/proc/task_mmu.c",
      "new_id": "73d1891ee6259e41f5be2f1d8d2a16948887097d",
      "new_mode": 33188,
      "new_path": "fs/proc/task_mmu.c"
    }
  ]
}
