1. 12 4月, 2018 8 次提交
  2. 07 4月, 2018 18 次提交
    • T
      leaking_addresses: check if file name contains address · c73dff59
      Tobin C. Harding 提交于
      Sometimes files may be created by using output from printk.  As the scan
      traverses the directory tree we should parse each path name and check if
      it is leaking an address.
      
      Add check for leaking address on each path name.
      Suggested-by: NTycho Andersen <tycho@tycho.ws>
      Acked-by: NTycho Andersen <tycho@tycho.ws>
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      c73dff59
    • T
      leaking_addresses: explicitly name variable used in regex · 2306a677
      Tobin C. Harding 提交于
      Currently sub routine may_leak_address() is checking regex against Perl
      special variable $_ which is _fortunately_ being set correctly in a loop
      before this sub routine is called.  We already have declared a variable
      to hold this value '$line' we should use it.
      
      Use $line in regex match instead of implicit $_
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      2306a677
    • T
      leaking_addresses: remove version number · 34827374
      Tobin C. Harding 提交于
      We have git now, we don't need a version number.  This was originally
      added because leaking_addresses.pl shamelessly (and mindlessly) copied
      checkpatch.pl
      
      Remove version number from script.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      34827374
    • T
      leaking_addresses: skip '/proc/1/syscall' · 2ad74293
      Tobin C. Harding 提交于
      The pointers listed in /proc/1/syscall are user pointers, and negative
      syscall args will show up like kernel addresses.
      
      For example
      
      /proc/31808/syscall: 0 0x3 0x55b107a38180 0x2000 0xffffffffffffffb0 \
      0x55b107a302d0 0x55b107a38180 0x7fffa313b8e8 0x7ff098560d11
      
      Skip parsing /proc/1/syscall
      Suggested-by: NTycho Andersen <tycho@tycho.ws>
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      2ad74293
    • T
      leaking_addresses: skip all /proc/PID except /proc/1 · 472c9e10
      Tobin C. Harding 提交于
      When the system is idle it is likely that most files under /proc/PID
      will be identical for various processes.  Scanning _all_ the PIDs under
      /proc is unnecessary and implies that we are thoroughly scanning /proc.
      This is _not_ the case because there may be ways userspace can trigger
      creation of /proc files that leak addresses but were not present during
      a scan.  For these two reasons we should exclude all PID directories
      under /proc except '1/'
      
      Exclude all /proc/PID except /proc/1.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      472c9e10
    • T
      leaking_addresses: cache architecture name · 5e4bac34
      Tobin C. Harding 提交于
      Currently we are repeatedly calling `uname -m`.  This is causing the
      script to take a long time to run (more than 10 seconds to parse
      /proc/kallsyms).  We can use Perl state variables to cache the result of
      the first call to `uname -m`.  With this change in place the script
      scans the whole kernel in under a minute.
      
      Cache machine architecture in state variable.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      5e4bac34
    • T
      leaking_addresses: simplify path skipping · b401f56f
      Tobin C. Harding 提交于
      Currently script has multiple configuration arrays.  This is confusing,
      evident by the fact that a bunch of the entries are in the wrong place.
      We can simplify the code by just having a single array for absolute
      paths to skip and a single array for file names to skip wherever they
      appear in the scanned directory tree.  There are also currently multiple
      subroutines to handle the different arrays, we can reduce these to a
      single subroutine also.
      
      Simplify the path skipping code.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      b401f56f
    • T
      leaking_addresses: do not parse binary files · e2858cad
      Tobin C. Harding 提交于
      Currently script parses binary files.  Since we are scanning for
      readable kernel addresses there is no need to parse binary files.  We
      can use Perl to check if file is binary and skip parsing it if so.
      
      Do not parse binary files.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      e2858cad
    • T
      leaking_addresses: add 32-bit support · 1410fe4e
      Tobin C. Harding 提交于
      Currently script only supports x86_64 and ppc64.  It would be nice to be
      able to scan 32-bit machines also.  We can add support for 32-bit
      architectures by modifying how we check for false positives, taking
      advantage of the page offset used by the kernel, and using the correct
      regular expression.
      
      Support for 32-bit machines is enabled by the observation that the kernel
      addresses on 32-bit machines are larger [in value] than the page offset.
      We can use this to filter false positives when scanning the kernel for
      leaking addresses.
      
      Programmatic determination of the running architecture is not
      immediately obvious (current 32-bit machines return various strings from
      `uname -m`).  We therefore provide a flag to enable scanning of 32-bit
      kernels.  Also we can check the kernel config file for the offset and if
      not found default to 0xc0000000.  A command line option to parse in the
      page offset is also provided.  We do automatically detect architecture
      if running on ix86.
      
      Add support for 32-bit kernels.  Add a command line option for page
      offset.
      Suggested-by: NKaiwan N Billimoria <kaiwan.billimoria@gmail.com>
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      1410fe4e
    • T
      leaking_addresses: add is_arch() wrapper subroutine · 5eb0da05
      Tobin C. Harding 提交于
      Currently there is duplicate code when checking the architecture type.
      We can remove the duplication by implementing a wrapper function
      is_arch().
      
      Implement and use wrapper function is_arch().
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      5eb0da05
    • T
      leaking_addresses: use system command to get arch · 6efb7458
      Tobin C. Harding 提交于
      Currently script uses Perl to get the machine architecture. This can be
      erroneous since Perl uses the architecture of the machine that Perl was
      compiled on not the architecture of the running machine. We should use
      the systems `uname` command instead.
      
      Use `uname -m` instead of Perl to get the machine architecture.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      6efb7458
    • T
      leaking_addresses: add support for 5 page table levels · 2f042c93
      Tobin C. Harding 提交于
      Currently script only supports 4 page table levels because of the way
      the kernel address regular expression is crafted. We can do better than
      this. Using previously added support for kernel configuration options we
      can get the number of page table levels defined by
      CONFIG_PGTABLE_LEVELS. Using this value a correct regular expression can
      be crafted. This only supports 5 page tables on x86_64.
      
      Add support for 5 page table levels on x86_64.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      2f042c93
    • T
      leaking_addresses: add support for kernel config file · f9d2a42d
      Tobin C. Harding 提交于
      Features that rely on the ability to get kernel configuration options
      are ready to be implemented in script. In preparation for this we can
      add support for kernel config options as a separate patch to ease
      review.
      
      Add support for locating and parsing kernel configuration file.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      f9d2a42d
    • T
      leaking_addresses: add range check for vsyscall memory · 87e37588
      Tobin C. Harding 提交于
      Currently script checks only first and last address in the vsyscall
      memory range. We can do better than this. When checking for false
      positives against $match, we can convert $match to a hexadecimal value
      then check if it lies within the range of vsyscall addresses.
      
      Check whole range of vsyscall addresses when checking for false
      positive.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      87e37588
    • T
      leaking_addresses: indent dependant options · 15d60a35
      Tobin C. Harding 提交于
      A number of the command line options to script are dependant on the
      option --input-raw being set. If we indent these options it makes
      explicit this dependency.
      
      Indent options dependant on --input-raw.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      15d60a35
    • T
      leaking_addresses: remove command examples · 6145de83
      Tobin C. Harding 提交于
      Currently help output includes command examples. These were cute when we
      first started development of this script but are unnecessary.
      
      Remove command examples.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      6145de83
    • T
      leaking_addresses: remove mention of kptr_restrict · 20cdfb5f
      Tobin C. Harding 提交于
      leaking_addresses.pl can be run with kptr_restrict==0 now, we don't need
      the comment about setting kptr_restrict any more.
      
      Remove comment suggesting setting kptr_restrict.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      20cdfb5f
    • T
      leaking_addresses: fix typo function not called · 6d23dd9b
      Tobin C. Harding 提交于
      Currently code uses a check against an undefined variable because the
      variable is a sub routine name and is not evaluated.
      
      Evaluate subroutine; add parenthesis to sub routine name.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      6d23dd9b
  3. 06 4月, 2018 1 次提交
    • C
      scripts/faddr2line: show the code context · 6870c016
      Changbin Du 提交于
      Inspired by gdb command 'list', show the code context of target lines.
      Here is a example:
      
      $ scripts/faddr2line vmlinux native_write_msr+0x6
      native_write_msr+0x6/0x20:
      arch_static_branch at arch/x86/include/asm/msr.h:105
      100             return EAX_EDX_VAL(val, low, high);
      101     }
      102
      103     static inline void notrace __wrmsr(unsigned int msr, u32 low, u32 high)
      104     {
      105             asm volatile("1: wrmsr\n"
      106                          "2:\n"
      107                          _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_wrmsr_unsafe)
      108                          : : "c" (msr), "a"(low), "d" (high) : "memory");
      109     }
      110
      (inlined by) static_key_false at include/linux/jump_label.h:142
      137     #define JUMP_TYPE_LINKED        2UL
      138     #define JUMP_TYPE_MASK          3UL
      139
      140     static __always_inline bool static_key_false(struct static_key *key)
      141     {
      142             return arch_static_branch(key, false);
      143     }
      144
      145     static __always_inline bool static_key_true(struct static_key *key)
      146     {
      147             return !arch_static_branch(key, true);
      (inlined by) native_write_msr at arch/x86/include/asm/msr.h:150
      145     static inline void notrace
      146     native_write_msr(unsigned int msr, u32 low, u32 high)
      147     {
      148             __wrmsr(msr, low, high);
      149
      150             if (msr_tracepoint_active(__tracepoint_write_msr))
      151                     do_trace_write_msr(msr, ((u64)high << 32 | low), 0);
      152     }
      153
      154     /* Can be uninlined because referenced by paravirt */
      155     static inline int notrace
      
      Link: http://lkml.kernel.org/r/1521444205-2259-1-git-send-email-changbin.du@intel.comSigned-off-by: NChangbin Du <changbin.du@intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Cc: NeilBrown <neilb@suse.com>
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6870c016
  4. 03 4月, 2018 1 次提交
  5. 31 3月, 2018 2 次提交
  6. 30 3月, 2018 1 次提交
  7. 28 3月, 2018 2 次提交
  8. 26 3月, 2018 7 次提交
    • T
      scripts/checkstack.pl: remove blackfin support · e53a05a4
      Tobias Klauser 提交于
      The Blackfin port has been removed from the kernel, also remove the
      blackfin specific bits from the checkstack.pl script.
      Signed-off-by: NTobias Klauser <tklauser@distanz.ch>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      e53a05a4
    • A
      recordmcount.pl: drop blackin and tile support · 82831598
      Arnd Bergmann 提交于
      These two architectures are getting removed, so we no longer
      need the special cases.
      Acked-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      82831598
    • M
      kconfig: use yylineno option instead of manual lineno increments · 18492685
      Masahiro Yamada 提交于
      Tracking the line number by hand is error-prone since you need to
      increment it in every \n matching pattern.
      
      If '%option yylineno' is set, flex defines 'yylineno' to contain the
      current line number and automatically updates it each time it reads a
      \n character.  This is much more convenient although the lexer does
      not initializes yylineno, so you need to set it to 1 each time you
      start reading a new file, and restore it you go back to the previous
      file.
      
      I tested this with DEBUG_PARSE, and confirmed the same dump message
      was produced.
      
      I removed the perf-report option.  Otherwise, I see the following
      message:
        %option yylineno entails a performance penalty ONLY on rules that
        can match newline characters
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      18492685
    • M
      kconfig: detect recursive inclusion earlier · 379a8eb8
      Masahiro Yamada 提交于
      Currently, the recursive inclusion is not detected when the offending
      file is about to be included; it is detected the offending file is
      about to include the *next* file.  This is because the detection loop
      does not involve the file being included.
      
      Do this check against the file that is about to be included so that
      the recursive inclusion is detected before unneeded parsing happens.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      379a8eb8
    • M
      kconfig: remove duplicated file name and lineno of recursive inclusion · 32a94b8b
      Masahiro Yamada 提交于
      As in the unit test, the error message for the recursive inclusion
      looks like this:
      
        Kconfig.inc1:4: recursive inclusion detected. Inclusion path:
          current file : 'Kconfig.inc1'
          included from: 'Kconfig.inc3:1'
          included from: 'Kconfig.inc2:3'
          included from: 'Kconfig.inc1:4'
      
      The 'Kconfig.inc1:4' is duplicated in the first and last lines.
      Also, the single quotes do not help readability.
      
      Change the message like follows:
      
        Recursive inclusion detected.
        Inclusion path:
          current file : Kconfig.inc1
          included from: Kconfig.inc3:1
          included from: Kconfig.inc2:3
          included from: Kconfig.inc1:4
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      32a94b8b
    • M
      kconfig: do not include both curses.h and ncurses.h for nconfig · 26561514
      Masahiro Yamada 提交于
      nconf.h includes <curses.h> and "ncurses.h", but it does not need to
      include both.  Generally, it should fall back to curses.h only when
      ncurses.h is not found.  But, looks like it has never happened;
      these includes have been here for many years since commit 692d97c3
      ("kconfig: new configuration interface (nconfig)"), and nobody has
      complained about hard-coding of ncurses.h .  Let's simply drop the
      curses.h inclusion.
      
      I replaced "ncurses.h" with <ncurses.h> since it is not a local file.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      26561514
    • M
      kconfig: make unmet dependency warnings readable · f8f69dc0
      Masahiro Yamada 提交于
      Currently, the unmet dependency warnings end up with endlessly long
      expressions, most of which are false positives.
      
      Here is test code to demonstrate how it currently works.
      
      [Test Case]
      
        config DEP1
                def_bool y
      
        config DEP2
                bool "DEP2"
      
        config A
                bool "A"
                select E
      
        config B
                bool "B"
                depends on DEP2
                select E
      
        config C
                bool "C"
                depends on DEP1 && DEP2
                select E
      
        config D
                def_bool n
                select E
      
        config E
                bool
                depends on DEP1 && DEP2
      
      [Result]
      
        $ make config
        scripts/kconfig/conf  --oldaskconfig Kconfig
        *
        * Linux Kernel Configuration
        *
        DEP2 (DEP2) [N/y/?] (NEW) n
        A (A) [N/y/?] (NEW) y
        warning: (A && B && D) selects E which has unmet direct
        dependencies (DEP1 && DEP2)
      
      Here, I see some points to be improved.
      
      First, '(A || B || D)' would make more sense than '(A && B && D)'.
      I am not sure if this is intentional, but expr_simplify_unmet_dep()
      turns OR expressions into AND, like follows:
      
              case E_OR:
                      return expr_alloc_and(
      
      Second, we see false positives.  'A' is a real unmet dependency.
      'B' is false positive because 'DEP1' is fixed to 'y', and 'B' depends
      on 'DEP2'.  'C' was correctly dropped by expr_simplify_unmet_dep().
      'D' is also false positive because it has no chance to be enabled.
      Current expr_simplify_unmet_dep() cannot avoid those false positives.
      
      After all, I decided to use the same helpers as used for printing
      reverse dependencies in the help.
      
      With this commit, unreadable warnings (most of the reported symbols are
      false positives) in the real world:
      
      $ make ARCH=score allyesconfig
      scripts/kconfig/conf  --allyesconfig Kconfig
      warning: (HWSPINLOCK_QCOM && AHCI_MTK && STMMAC_PLATFORM &&
       DWMAC_IPQ806X && DWMAC_LPC18XX && DWMAC_OXNAS && DWMAC_ROCKCHIP &&
       DWMAC_SOCFPGA && DWMAC_STI && TI_CPSW && PINCTRL_GEMINI &&
       PINCTRL_OXNAS && PINCTRL_ROCKCHIP && PINCTRL_DOVE &&
       PINCTRL_ARMADA_37XX && PINCTRL_STM32 && S3C2410_WATCHDOG &&
       VIDEO_OMAP3 && VIDEO_S5P_FIMC && USB_XHCI_MTK && RTC_DRV_AT91SAM9 &&
       LPC18XX_DMAMUX && VIDEO_OMAP4 && COMMON_CLK_GEMINI &&
       COMMON_CLK_ASPEED && COMMON_CLK_NXP && COMMON_CLK_OXNAS &&
       COMMON_CLK_BOSTON && QCOM_ADSP_PIL && QCOM_Q6V5_PIL && QCOM_GSBI &&
       ATMEL_EBI && ST_IRQCHIP && RESET_IMX7 && PHY_HI6220_USB &&
       PHY_RALINK_USB && PHY_ROCKCHIP_PCIE && PHY_DA8XX_USB) selects
       MFD_SYSCON which has unmet direct dependencies (HAS_IOMEM)
      warning: (PINCTRL_AT91 && PINCTRL_AT91PIO4 && PINCTRL_OXNAS &&
       PINCTRL_PISTACHIO && PINCTRL_PIC32 && PINCTRL_MESON &&
       PINCTRL_NOMADIK && PINCTRL_MTK && PINCTRL_MT7622 && GPIO_TB10X)
       selects OF_GPIO which has unmet direct dependencies (GPIOLIB && OF &&
       HAS_IOMEM)
      warning: (FAULT_INJECTION_STACKTRACE_FILTER && LATENCYTOP && LOCKDEP)
       selects FRAME_POINTER which has unmet direct dependencies
       (DEBUG_KERNEL && (CRIS || M68K || FRV || UML || SUPERH || BLACKFIN ||
       MN10300 || METAG) || ARCH_WANT_FRAME_POINTERS)
      
      will be turned into:
      
      $ make ARCH=score allyesconfig
      scripts/kconfig/conf  --allyesconfig Kconfig
      
      WARNING: unmet direct dependencies detected for MFD_SYSCON
        Depends on [n]: HAS_IOMEM [=n]
        Selected by [y]:
        - PINCTRL_STM32 [=y] && PINCTRL [=y] && (ARCH_STM32 ||
       COMPILE_TEST [=y]) && OF [=y]
        - RTC_DRV_AT91SAM9 [=y] && RTC_CLASS [=y] && (ARCH_AT91 ||
       COMPILE_TEST [=y])
        - RESET_IMX7 [=y] && RESET_CONTROLLER [=y]
        - PHY_HI6220_USB [=y] && (ARCH_HISI && ARM64 ||
       COMPILE_TEST [=y])
        - PHY_RALINK_USB [=y] && (RALINK || COMPILE_TEST [=y])
        - PHY_ROCKCHIP_PCIE [=y] && (ARCH_ROCKCHIP && OF [=y] ||
       COMPILE_TEST [=y])
      
      WARNING: unmet direct dependencies detected for OF_GPIO
        Depends on [n]: GPIOLIB [=y] && OF [=y] && HAS_IOMEM [=n]
        Selected by [y]:
        - PINCTRL_MTK [=y] && PINCTRL [=y] && (ARCH_MEDIATEK ||
       COMPILE_TEST [=y]) && OF [=y]
        - PINCTRL_MT7622 [=y] && PINCTRL [=y] && (ARCH_MEDIATEK ||
       COMPILE_TEST [=y]) && OF [=y] && (ARM64 || COMPILE_TEST [=y])
      
      WARNING: unmet direct dependencies detected for FRAME_POINTER
        Depends on [n]: DEBUG_KERNEL [=y] && (CRIS || M68K || FRV || UML ||
       SUPERH || BLACKFIN || MN10300 || METAG) || ARCH_WANT_FRAME_POINTERS [=n]
        Selected by [y]:
        - LATENCYTOP [=y] && DEBUG_KERNEL [=y] && STACKTRACE_SUPPORT [=y] &&
       PROC_FS [=y] && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND &&
       !ARC && !X86
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NPetr Vorel <petr.vorel@gmail.com>
      f8f69dc0