1. 12 1月, 2010 1 次提交
  2. 16 12月, 2009 1 次提交
    • N
      mm hugetlb: add hugepage support to pagemap · 5dc37642
      Naoya Horiguchi 提交于
      This patch enables extraction of the pfn of a hugepage from
      /proc/pid/pagemap in an architecture independent manner.
      
      Details
      -------
      My test program (leak_pagemap) works as follows:
       - creat() and mmap() a file on hugetlbfs (file size is 200MB == 100 hugepages,)
       - read()/write() something on it,
       - call page-types with option -p,
       - munmap() and unlink() the file on hugetlbfs
      
      Without my patches
      ------------------
      $ ./leak_pagemap
                   flags page-count       MB  symbolic-flags                     long-symbolic-flags
      0x0000000000000000          1        0  __________________________________
      0x0000000000000804          1        0  __R________M______________________ referenced,mmap
      0x000000000000086c         81        0  __RU_lA____M______________________ referenced,uptodate,lru,active,mmap
      0x0000000000005808          5        0  ___U_______Ma_b___________________ uptodate,mmap,anonymous,swapbacked
      0x0000000000005868         12        0  ___U_lA____Ma_b___________________ uptodate,lru,active,mmap,anonymous,swapbacked
      0x000000000000586c          1        0  __RU_lA____Ma_b___________________ referenced,uptodate,lru,active,mmap,anonymous,swapbacked
                   total        101        0
      
      The output of page-types don't show any hugepage.
      
      With my patches
      ---------------
      $ ./leak_pagemap
                   flags page-count       MB  symbolic-flags                     long-symbolic-flags
      0x0000000000000000          1        0  __________________________________
      0x0000000000030000      51100      199  ________________TG________________ compound_tail,huge
      0x0000000000028018        100        0  ___UD__________H_G________________ uptodate,dirty,compound_head,huge
      0x0000000000000804          1        0  __R________M______________________ referenced,mmap
      0x000000000000080c          1        0  __RU_______M______________________ referenced,uptodate,mmap
      0x000000000000086c         80        0  __RU_lA____M______________________ referenced,uptodate,lru,active,mmap
      0x0000000000005808          4        0  ___U_______Ma_b___________________ uptodate,mmap,anonymous,swapbacked
      0x0000000000005868         12        0  ___U_lA____Ma_b___________________ uptodate,lru,active,mmap,anonymous,swapbacked
      0x000000000000586c          1        0  __RU_lA____Ma_b___________________ referenced,uptodate,lru,active,mmap,anonymous,swapbacked
                   total      51300      200
      
      The output of page-types shows 51200 pages contributing to hugepages,
      containing 100 head pages and 51100 tail pages as expected.
      
      [akpm@linux-foundation.org: build fix]
      Signed-off-by: NNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Wu Fengguang <fengguang.wu@intel.com>
      Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
      Cc: Mel Gorman <mel@csn.ul.ie>
      Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
      Cc: Andy Whitcroft <apw@canonical.com>
      Cc: David Rientjes <rientjes@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5dc37642
  3. 23 9月, 2009 2 次提交
    • S
      procfs: provide stack information for threads · d899bf7b
      Stefani Seibold 提交于
      A patch to give a better overview of the userland application stack usage,
      especially for embedded linux.
      
      Currently you are only able to dump the main process/thread stack usage
      which is showed in /proc/pid/status by the "VmStk" Value.  But you get no
      information about the consumed stack memory of the the threads.
      
      There is an enhancement in the /proc/<pid>/{task/*,}/*maps and which marks
      the vm mapping where the thread stack pointer reside with "[thread stack
      xxxxxxxx]".  xxxxxxxx is the maximum size of stack.  This is a value
      information, because libpthread doesn't set the start of the stack to the
      top of the mapped area, depending of the pthread usage.
      
      A sample output of /proc/<pid>/task/<tid>/maps looks like:
      
      08048000-08049000 r-xp 00000000 03:00 8312       /opt/z
      08049000-0804a000 rw-p 00001000 03:00 8312       /opt/z
      0804a000-0806b000 rw-p 00000000 00:00 0          [heap]
      a7d12000-a7d13000 ---p 00000000 00:00 0
      a7d13000-a7f13000 rw-p 00000000 00:00 0          [thread stack: 001ff4b4]
      a7f13000-a7f14000 ---p 00000000 00:00 0
      a7f14000-a7f36000 rw-p 00000000 00:00 0
      a7f36000-a8069000 r-xp 00000000 03:00 4222       /lib/libc.so.6
      a8069000-a806b000 r--p 00133000 03:00 4222       /lib/libc.so.6
      a806b000-a806c000 rw-p 00135000 03:00 4222       /lib/libc.so.6
      a806c000-a806f000 rw-p 00000000 00:00 0
      a806f000-a8083000 r-xp 00000000 03:00 14462      /lib/libpthread.so.0
      a8083000-a8084000 r--p 00013000 03:00 14462      /lib/libpthread.so.0
      a8084000-a8085000 rw-p 00014000 03:00 14462      /lib/libpthread.so.0
      a8085000-a8088000 rw-p 00000000 00:00 0
      a8088000-a80a4000 r-xp 00000000 03:00 8317       /lib/ld-linux.so.2
      a80a4000-a80a5000 r--p 0001b000 03:00 8317       /lib/ld-linux.so.2
      a80a5000-a80a6000 rw-p 0001c000 03:00 8317       /lib/ld-linux.so.2
      afaf5000-afb0a000 rw-p 00000000 00:00 0          [stack]
      ffffe000-fffff000 r-xp 00000000 00:00 0          [vdso]
      
      Also there is a new entry "stack usage" in /proc/<pid>/{task/*,}/status
      which will you give the current stack usage in kb.
      
      A sample output of /proc/self/status looks like:
      
      Name:	cat
      State:	R (running)
      Tgid:	507
      Pid:	507
      .
      .
      .
      CapBnd:	fffffffffffffeff
      voluntary_ctxt_switches:	0
      nonvoluntary_ctxt_switches:	0
      Stack usage:	12 kB
      
      I also fixed stack base address in /proc/<pid>/{task/*,}/stat to the base
      address of the associated thread stack and not the one of the main
      process.  This makes more sense.
      
      [akpm@linux-foundation.org: fs/proc/array.c now needs walk_page_range()]
      Signed-off-by: NStefani Seibold <stefani@seibold.net>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Randy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d899bf7b
    • V
      fs/proc/task_mmu.c v1: fix clear_refs_write() input sanity check · fb92a4b0
      Vincent Li 提交于
      Andrew Morton pointed out similar string hacking and obfuscated check for
      zero-length input at the end of the function, David Rientjes suggested to
      use strict_strtol to replace simple_strtol, this patch cover above
      suggestions, add removing of leading and trailing whitespace from user
      input.  It does not change function behavious.
      Signed-off-by: NVincent Li <macli@brc.ubc.ca>
      Acked-by: NDavid Rientjes <rientjes@google.com>
      Cc: Matt Mackall <mpm@selenic.com>
      Cc: Amerigo Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      fb92a4b0
  4. 22 9月, 2009 1 次提交
  5. 10 8月, 2009 2 次提交
  6. 03 5月, 2009 1 次提交
  7. 07 4月, 2009 1 次提交
  8. 31 3月, 2009 1 次提交
    • M
      proc: fix sparse warnings in pagemap_read() · 09729a99
      Milind Arun Choudhary 提交于
      fs/proc/task_mmu.c:696:12: warning: cast removes address space of expression
      fs/proc/task_mmu.c:696:9: warning: incorrect type in assignment (different address spaces)
      fs/proc/task_mmu.c:696:9:    expected unsigned long long [noderef] [usertype] <asn:1>*out
      fs/proc/task_mmu.c:696:9:    got unsigned long long [usertype] *<noident>
      fs/proc/task_mmu.c:697:12: warning: cast removes address space of expression
      fs/proc/task_mmu.c:697:9: warning: incorrect type in assignment (different address spaces)
      fs/proc/task_mmu.c:697:9:    expected unsigned long long [noderef] [usertype] <asn:1>*end
      fs/proc/task_mmu.c:697:9:    got unsigned long long [usertype] *<noident>
      fs/proc/task_mmu.c:723:12: warning: cast removes address space of expression
      fs/proc/task_mmu.c:723:26: error: subtraction of different types can't work (different address spaces)
      fs/proc/task_mmu.c:725:24: error: subtraction of different types can't work (different address spaces)
      Signed-off-by: NMilind Arun Choudhary <milindchoudhary@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      09729a99
  9. 07 1月, 2009 2 次提交
  10. 11 12月, 2008 1 次提交
  11. 23 10月, 2008 1 次提交
    • J
      proc: fix vma display mismatch between /proc/pid/{maps,smaps} · 7c88db0c
      Joe Korty 提交于
      Commit 4752c369 aka
      "maps4: simplify interdependence of maps and smaps" broke /proc/pid/smaps,
      causing it to display some vmas twice and other vmas not at all.  For example:
      
          grep .- /proc/1/smaps >/tmp/smaps; diff /proc/1/maps /tmp/smaps
      
          1  25d24
          2  < 7fd7e23aa000-7fd7e23ac000 rw-p 7fd7e23aa000 00:00 0
          3  28a28
          4  > ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0  [vsyscall]
      
      The bug has something to do with setting m->version before all the
      seq_printf's have been performed.  show_map was doing this correctly,
      but show_smap was doing this in the middle of its seq_printf sequence.
      This patch arranges things so that the setting of m->version in show_smap
      is also done at the end of its seq_printf sequence.
      
      Testing: in addition to the above grep test, for each process I summed
      up the 'Rss' fields of /proc/pid/smaps and compared that to the 'VmRSS'
      field of /proc/pid/status.  All matched except for Xorg (which has a
      /dev/mem mapping which Rss accounts for but VmRSS does not).  This result
      gives us some confidence that neither /proc/pid/maps nor /proc/pid/smaps
      are any longer skipping or double-counting vmas.
      Signed-off-by: NJoe Korty <joe.korty@ccur.com>
      Cc: Matt Mackall <mpm@selenic.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      7c88db0c
  12. 10 10月, 2008 1 次提交
  13. 21 8月, 2008 1 次提交
    • C
      /proc/self/maps doesn't display the real file offset · 1804dc6e
      Clement Calmels 提交于
      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: NClement Calmels <cboulte@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1804dc6e
  14. 23 7月, 2008 1 次提交
  15. 14 7月, 2008 1 次提交
    • S
      Security: split proc ptrace checking into read vs. attach · 006ebb40
      Stephen Smalley 提交于
      Enable security modules to distinguish reading of process state via
      proc from full ptrace access by renaming ptrace_may_attach to
      ptrace_may_access and adding a mode argument indicating whether only
      read access or full attach access is requested.  This allows security
      modules to permit access to reading process state without granting
      full ptrace access.  The base DAC/capability checking remains unchanged.
      
      Read access to /proc/pid/mem continues to apply a full ptrace attach
      check since check_mem_permission() already requires the current task
      to already be ptracing the target.  The other ptrace checks within
      proc for elements like environ, maps, and fds are changed to pass the
      read mode instead of attach.
      
      In the SELinux case, we model such reading of process state as a
      reading of a proc file labeled with the target process' label.  This
      enables SELinux policy to permit such reading of process state without
      permitting control or manipulation of the target process, as there are
      a number of cases where programs probe for such information via proc
      but do not need to be able to control the target (e.g. procps,
      lsof, PolicyKit, ConsoleKit).  At present we have to choose between
      allowing full ptrace in policy (more permissive than required/desired)
      or breaking functionality (or in some cases just silencing the denials
      via dontaudit rules but this can hide genuine attacks).
      
      This version of the patch incorporates comments from Casey Schaufler
      (change/replace existing ptrace_may_attach interface, pass access
      mode), and Chris Wright (provide greater consistency in the checking).
      
      Note that like their predecessors __ptrace_may_attach and
      ptrace_may_attach, the __ptrace_may_access and ptrace_may_access
      interfaces use different return value conventions from each other (0
      or -errno vs. 1 or 0).  I retained this difference to avoid any
      changes to the caller logic but made the difference clearer by
      changing the latter interface to return a bool rather than an int and
      by adding a comment about it to ptrace.h for any future callers.
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Acked-by: NChris Wright <chrisw@sous-sol.org>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      006ebb40
  16. 06 7月, 2008 2 次提交
  17. 13 6月, 2008 2 次提交
  18. 07 6月, 2008 1 次提交
  19. 09 5月, 2008 1 次提交
  20. 29 4月, 2008 1 次提交
    • M
      procfs task exe symlink · 925d1c40
      Matt Helsley 提交于
      The kernel implements readlink of /proc/pid/exe by getting the file from
      the first executable VMA.  Then the path to the file is reconstructed and
      reported as the result.
      
      Because of the VMA walk the code is slightly different on nommu systems.
      This patch avoids separate /proc/pid/exe code on nommu systems.  Instead of
      walking the VMAs to find the first executable file-backed VMA we store a
      reference to the exec'd file in the mm_struct.
      
      That reference would prevent the filesystem holding the executable file
      from being unmounted even after unmapping the VMAs.  So we track the number
      of VM_EXECUTABLE VMAs and drop the new reference when the last one is
      unmapped.  This avoids pinning the mounted filesystem.
      
      [akpm@linux-foundation.org: improve comments]
      [yamamoto@valinux.co.jp: fix dup_mmap]
      Signed-off-by: NMatt Helsley <matthltc@us.ibm.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: David Howells <dhowells@redhat.com>
      Cc:"Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Hugh Dickins <hugh@veritas.com>
      Signed-off-by: NYAMAMOTO Takashi <yamamoto@valinux.co.jp>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      925d1c40
  21. 28 4月, 2008 2 次提交
  22. 23 3月, 2008 1 次提交
  23. 14 3月, 2008 1 次提交
  24. 24 2月, 2008 1 次提交
  25. 15 2月, 2008 2 次提交
  26. 09 2月, 2008 2 次提交
  27. 06 2月, 2008 6 次提交