1. 12 6月, 2018 1 次提交
  2. 08 6月, 2018 4 次提交
    • A
      tools/testing/selftests/proc: test /proc/*/fd a bit (+ PF_KTHREAD is ABI!) · b2f5de03
      Alexey Dobriyan 提交于
      * Test lookup in /proc/self/fd.
        "map_files" lookup story showed that lookup is not that simple.
      
      * Test that all those symlinks open the same file.
        Check with (st_dev, st_info).
      
      * Test that kernel threads do not have anything in their /proc/*/fd/
        directory.
      
      Now this is where things get interesting.
      
      First, kernel threads aren't pinned by /proc/self or equivalent,
      thus some "atomicity" is required.
      
      Second, ->comm can contain whitespace and ')'.
      No, they are not escaped.
      
      Third, the only reliable way to check if process is kernel thread
      appears to be field #9 in /proc/*/stat.
      
      This field is struct task_struct::flags in decimal!
      Check is done by testing PF_KTHREAD flags like we do in kernel.
      
      	PF_KTREAD value is a part of userspace ABI !!!
      
      Other methods for determining kernel threadness are not reliable:
      * RSS can be 0 if everything is swapped, even while reading
        from /proc/self.
      
      * ->total_vm CAN BE ZERO if process is finishing
      
      	munmap(NULL, whole address space);
      
      * /proc/*/maps and similar files can be empty because unmapping
        everything works. Read returning 0 can't distinguish between
        kernel thread and such suicide process.
      
      Link: http://lkml.kernel.org/r/20180505000414.GA15090@avx2Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b2f5de03
    • M
      mm: mark pages in use for page tables · 1d40a5ea
      Matthew Wilcox 提交于
      Define a new PageTable bit in the page_type and use it to mark pages in
      use as page tables.  This can be helpful when debugging crashdumps or
      analysing memory fragmentation.  Add a KPF flag to report these pages to
      userspace and update page-types.c to interpret that flag.
      
      Note that only pages currently accounted as NR_PAGETABLES are tracked as
      PageTable; this does not include pgd/p4d/pud/pmd pages.  Those will be the
      subject of a later patch.
      
      Link: http://lkml.kernel.org/r/20180518194519.3820-4-willy@infradead.orgSigned-off-by: NMatthew Wilcox <mawilcox@microsoft.com>
      Acked-by: NKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Jérôme Glisse <jglisse@redhat.com>
      Cc: Lai Jiangshan <jiangshanlai@gmail.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1d40a5ea
    • Y
      tools/bpf: fix selftest get_cgroup_id_user · 23316a36
      Yonghong Song 提交于
      Commit f269099a ("tools/bpf: add a selftest for
      bpf_get_current_cgroup_id() helper") added a test
      for bpf_get_current_cgroup_id() helper. The bpf program
      is attached to tracepoint syscalls/sys_enter_nanosleep
      and will record the cgroup id if the tracepoint is hit.
      The test program creates a cgroup and attachs itself to
      this cgroup and expects that the test program process
      cgroup id is the same as the cgroup_id retrieved
      by the bpf program.
      
      In a light system where no other processes called
      nanosleep syscall, the test case can pass.
      In a busy system where many different processes can hit
      syscalls/sys_enter_nanosleep tracepoint, the cgroup id
      recorded by bpf program may not match the test program
      process cgroup_id.
      
      This patch fixed an issue by communicating the test program
      pid to bpf program. The bpf program only records
      cgroup id if the current task pid is the same as
      passed-in pid. This ensures that the recorded cgroup_id
      is for the cgroup within which the test program resides.
      
      Fixes: f269099a ("tools/bpf: add a selftest for bpf_get_current_cgroup_id() helper")
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      23316a36
    • D
      bpf: reject passing modified ctx to helper functions · 58990d1f
      Daniel Borkmann 提交于
      As commit 28e33f9d ("bpf: disallow arithmetic operations on
      context pointer") already describes, f1174f77 ("bpf/verifier:
      rework value tracking") removed the specific white-listed cases
      we had previously where we would allow for pointer arithmetic in
      order to further generalize it, and allow e.g. context access via
      modified registers. While the dereferencing of modified context
      pointers had been forbidden through 28e33f9d, syzkaller did
      recently manage to trigger several KASAN splats for slab out of
      bounds access and use after frees by simply passing a modified
      context pointer to a helper function which would then do the bad
      access since verifier allowed it in adjust_ptr_min_max_vals().
      
      Rejecting arithmetic on ctx pointer in adjust_ptr_min_max_vals()
      generally could break existing programs as there's a valid use
      case in tracing in combination with passing the ctx to helpers as
      bpf_probe_read(), where the register then becomes unknown at
      verification time due to adding a non-constant offset to it. An
      access sequence may look like the following:
      
        offset = args->filename;  /* field __data_loc filename */
        bpf_probe_read(&dst, len, (char *)args + offset); // args is ctx
      
      There are two options: i) we could special case the ctx and as
      soon as we add a constant or bounded offset to it (hence ctx type
      wouldn't change) we could turn the ctx into an unknown scalar, or
      ii) we generalize the sanity test for ctx member access into a
      small helper and assert it on the ctx register that was passed
      as a function argument. Fwiw, latter is more obvious and less
      complex at the same time, and one case that may potentially be
      legitimate in future for ctx member access at least would be for
      ctx to carry a const offset. Therefore, fix follows approach
      from ii) and adds test cases to BPF kselftests.
      
      Fixes: f1174f77 ("bpf/verifier: rework value tracking")
      Reported-by: syzbot+3d0b2441dbb71751615e@syzkaller.appspotmail.com
      Reported-by: syzbot+c8504affd4fdd0c1b626@syzkaller.appspotmail.com
      Reported-by: syzbot+e5190cb881d8660fb1a3@syzkaller.appspotmail.com
      Reported-by: syzbot+efae31b384d5badbd620@syzkaller.appspotmail.com
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NYonghong Song <yhs@fb.com>
      Acked-by: NEdward Cree <ecree@solarflare.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      58990d1f
  3. 07 6月, 2018 2 次提交
    • J
      perf script python: Add dict fields introduction to Documentation · ac56aa45
      Jin Yao 提交于
      Add a brief introduction about fields to perf-script-python.txt.
      
      It should help python script developers in easily finding what fields
      are supported.
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jin Yao <yao.jin@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1527843663-32288-4-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ac56aa45
    • J
      perf script python: Add more PMU fields to event handler dict · 48a1f565
      Jin Yao 提交于
      When doing pmu sampling and then running a script with perf script -s
      script.py, the process_event function gets dictionary with some fields
      from the perf ring buffer (like ip, sym, callchain etc).
      
      But we miss quite a few fields we report now, for example, LBRs, data
      source, weight, transaction, iregs, uregs, etc.
      
      This patch reports these fields for perf script python processing.
      
        New keys/items:
        ---------------
        key  : brstack
        items: from, to, from_dsoname, to_dsoname, mispred,
               predicted, in_tx, abort, cycles.
      
        key  : brstacksym
        items: from, to, pred, in_tx, abort (converted string)
      
        key  : datasrc
        key  : datasrc_decode (decoded string)
        key  : iregs
        key  : uregs
        key  : weight
        key  : transaction
      
        v2:
        ---
        Add new fields for dso.
        Use PyBool_FromLong() for mispred/predicted/in_tx/abort
      
      Committer notes:
      
      !sym->name isn't valid, as its not a pointer, its a [0] array, use
      !sym->name[0] instead, guaranteed to be the case by symbol__new.
      
      This was caught by just one of the containers:
      
        52    54.22 ubuntu:17.04                  : FAIL gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406
      
          CC       /tmp/build/perf/util/scripting-engines/trace-event-python.o
        util/scripting-engines/trace-event-python.c:534:20: error: address of array 'sym->name' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
                if (!sym || !sym->name)
                          ~~~~~~^~~~
        1 error generated.
        mv: cannot stat '/tmp/build/perf/util/scripting-engines/.trace-event-python.o.tmp': No such file or directory
        /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/util/scripting-engines/trace-event-python.o' failed
        make[5]: *** [/tmp/build/perf/util/scripting-engines/trace-event-python.o] Error 1
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jin Yao <yao.jin@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1527843663-32288-3-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      48a1f565
  4. 06 6月, 2018 26 次提交
  5. 05 6月, 2018 4 次提交
  6. 04 6月, 2018 3 次提交