1. 05 10月, 2018 1 次提交
    • S
      vsprintf: Fix off-by-one bug in bstr_printf() processing dereferenced pointers · 62165600
      Steven Rostedt (VMware) 提交于
      The functions vbin_printf() and bstr_printf() are used by trace_printk() to
      try to keep the overhead down during printing. trace_printk() uses
      vbin_printf() at the time of execution, as it only scans the fmt string to
      record the printf values into the buffer, and then uses vbin_printf() to do
      the conversions to print the string based on the format and the saved
      values in the buffer.
      
      This is an issue for dereferenced pointers, as before commit 841a915d,
      the processing of the pointer could happen some time after the pointer value
      was recorded (reading the trace buffer). This means the processing of the
      value at a later time could show different results, or even crash the
      system, if the pointer no longer existed.
      
      Commit 841a915d addressed this by processing dereferenced pointers at
      the time of execution and save the result in the ring buffer as a string.
      The bstr_printf() would then treat these pointers as normal strings, and
      print the value. But there was an off-by-one bug here, where after
      processing the argument, it move the pointer only "strlen(arg)" which made
      the arg pointer not point to the next argument in the ring buffer, but
      instead point to the nul character of the last argument. This causes any
      values after a dereferenced pointer to be corrupted.
      
      Cc: stable@vger.kernel.org
      Fixes: 841a915d ("vsprintf: Do not have bprintf dereference pointers")
      Reported-by: NNikolay Borisov <nborisov@suse.com>
      Tested-by: NNikolay Borisov <nborisov@suse.com>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      62165600
  2. 07 8月, 2018 1 次提交
  3. 18 7月, 2018 2 次提交
  4. 05 6月, 2018 1 次提交
    • G
      lib/vsprintf: Remove atomic-unsafe support for %pCr · 666902e4
      Geert Uytterhoeven 提交于
      "%pCr" formats the current rate of a clock, and calls clk_get_rate().
      The latter obtains a mutex, hence it must not be called from atomic
      context.
      
      Remove support for this rarely-used format, as vsprintf() (and e.g.
      printk()) must be callable from any context.
      
      Any remaining out-of-tree users will start seeing the clock's name
      printed instead of its rate.
      Reported-by: NJia-Ju Bai <baijiaju1990@gmail.com>
      Fixes: 900cca29 ("lib/vsprintf: add %pC{,n,r} format specifiers for clocks")
      Link: http://lkml.kernel.org/r/1527845302-12159-5-git-send-email-geert+renesas@glider.be
      To: Jia-Ju Bai <baijiaju1990@gmail.com>
      To: Jonathan Corbet <corbet@lwn.net>
      To: Michael Turquette <mturquette@baylibre.com>
      To: Stephen Boyd <sboyd@kernel.org>
      To: Zhang Rui <rui.zhang@intel.com>
      To: Eduardo Valentin <edubezval@gmail.com>
      To: Eric Anholt <eric@anholt.net>
      To: Stefan Wahren <stefan.wahren@i2se.com>
      To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-clk@vger.kernel.org
      Cc: linux-pm@vger.kernel.org
      Cc: linux-serial@vger.kernel.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-renesas-soc@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: Geert Uytterhoeven <geert+renesas@glider.be>
      Cc: stable@vger.kernel.org # 4.1+
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NPetr Mladek <pmladek@suse.com>
      666902e4
  5. 16 5月, 2018 1 次提交
    • S
      vsprintf: Replace memory barrier with static_key for random_ptr_key update · 85f4f12d
      Steven Rostedt (VMware) 提交于
      Reviewing Tobin's patches for getting pointers out early before
      entropy has been established, I noticed that there's a lone smp_mb() in
      the code. As with most lone memory barriers, this one appears to be
      incorrectly used.
      
      We currently basically have this:
      
      	get_random_bytes(&ptr_key, sizeof(ptr_key));
      	/*
      	 * have_filled_random_ptr_key==true is dependent on get_random_bytes().
      	 * ptr_to_id() needs to see have_filled_random_ptr_key==true
      	 * after get_random_bytes() returns.
      	 */
      	smp_mb();
      	WRITE_ONCE(have_filled_random_ptr_key, true);
      
      And later we have:
      
      	if (unlikely(!have_filled_random_ptr_key))
      		return string(buf, end, "(ptrval)", spec);
      
      /* Missing memory barrier here. */
      
      	hashval = (unsigned long)siphash_1u64((u64)ptr, &ptr_key);
      
      As the CPU can perform speculative loads, we could have a situation
      with the following:
      
      	CPU0				CPU1
      	----				----
      				   load ptr_key = 0
         store ptr_key = random
         smp_mb()
         store have_filled_random_ptr_key
      
      				   load have_filled_random_ptr_key = true
      
      				    BAD BAD BAD! (you're so bad!)
      
      Because nothing prevents CPU1 from loading ptr_key before loading
      have_filled_random_ptr_key.
      
      But this race is very unlikely, but we can't keep an incorrect smp_mb() in
      place. Instead, replace the have_filled_random_ptr_key with a static_branch
      not_filled_random_ptr_key, that is initialized to true and changed to false
      when we get enough entropy. If the update happens in early boot, the
      static_key is updated immediately, otherwise it will have to wait till
      entropy is filled and this happens in an interrupt handler which can't
      enable a static_key, as that requires a preemptible context. In that case, a
      work_queue is used to enable it, as entropy already took too long to
      establish in the first place waiting a little more shouldn't hurt anything.
      
      The benefit of using the static key is that the unlikely branch in
      vsprintf() now becomes a nop.
      
      Link: http://lkml.kernel.org/r/20180515100558.21df515e@gandalf.local.home
      
      Cc: stable@vger.kernel.org
      Fixes: ad67b74d ("printk: hash addresses printed with %p")
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      85f4f12d
  6. 18 4月, 2018 1 次提交
  7. 12 4月, 2018 1 次提交
    • A
      proc: add seq_put_decimal_ull_width to speed up /proc/pid/smaps · d1be35cb
      Andrei Vagin 提交于
      seq_put_decimal_ull_w(m, str, val, width) prints a decimal number with a
      specified minimal field width.
      
      It is equivalent of seq_printf(m, "%s%*d", str, width, val), but it
      works much faster.
      
      == test_smaps.py
        num = 0
        with open("/proc/1/smaps") as f:
                for x in xrange(10000):
                        data = f.read()
                        f.seek(0, 0)
      ==
      
      == Before patch ==
        $ time python test_smaps.py
        real    0m4.593s
        user    0m0.398s
        sys     0m4.158s
      
      == After patch ==
        $ time python test_smaps.py
        real    0m3.828s
        user    0m0.413s
        sys     0m3.408s
      
      $ perf -g record python test_smaps.py
      == Before patch ==
      -   79.01%     3.36%  python   [kernel.kallsyms]    [k] show_smap.isra.33
         - 75.65% show_smap.isra.33
            + 48.85% seq_printf
            + 15.75% __walk_page_range
            + 9.70% show_map_vma.isra.23
              0.61% seq_puts
      
      == After patch ==
      -   75.51%     4.62%  python   [kernel.kallsyms]    [k] show_smap.isra.33
         - 70.88% show_smap.isra.33
            + 24.82% seq_put_decimal_ull_w
            + 19.78% __walk_page_range
            + 12.74% seq_printf
            + 11.08% show_map_vma.isra.23
            + 1.68% seq_puts
      
      [akpm@linux-foundation.org: fix drivers/of/unittest.c build]
      Link: http://lkml.kernel.org/r/20180212074931.7227-1-avagin@openvz.orgSigned-off-by: NAndrei Vagin <avagin@openvz.org>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d1be35cb
  8. 11 4月, 2018 7 次提交
  9. 06 4月, 2018 1 次提交
  10. 08 2月, 2018 1 次提交
    • A
      vsprintf: avoid misleading "(null)" for %px · 3a129cc2
      Adam Borowski 提交于
      Like %pK already does, print "00000000" instead.
      
      This confused people -- the convention is that "(null)" means you tried to
      dereference a null pointer as opposed to printing the address.
      
      Link: http://lkml.kernel.org/r/20180204174521.21383-1-kilobyte@angband.pl
      To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
      To: Steven Rostedt <rostedt@goodmis.org>
      To: linux-kernel@vger.kernel.org
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Joe Perches <joe@perches.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: "Roberts, William C" <william.c.roberts@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NAdam Borowski <kilobyte@angband.pl>
      Signed-off-by: NPetr Mladek <pmladek@suse.com>
      3a129cc2
  11. 24 1月, 2018 1 次提交
    • S
      vsprintf: Do not have bprintf dereference pointers · 841a915d
      Steven Rostedt (VMware) 提交于
      When trace_printk() was introduced, it was discussed that making it be as
      low overhead as possible, that the processing of the format string should be
      delayed until it is read. That is, a "trace_printk()" should not convert
      the %d into numbers and so on, but instead, save the fmt string and all the
      args in the buffer at the time of recording. When the trace_printk() data is
      read, it would then parse the format string and do the conversions of the
      saved arguments in the tracing buffer.
      
      The code to perform this was added to vsprintf where vbin_printf() would
      save the arguments of a specified format string in a buffer, then
      bstr_printf() could be used to convert the buffer with the same format
      string into the final output, as if vsprintf() was called in one go.
      
      The issue arises when dereferenced pointers are used. The problem is that
      something like %*pbl which reads a bitmask, will save the pointer to the
      bitmask in the buffer. Then the reading of the buffer via bstr_printf() will
      then look at the pointer to process the final output. Obviously the value of
      that pointer could have changed since the time it was recorded to the time
      the buffer is read. Worse yet, the bitmask could be unmapped, and the
      reading of the trace buffer could actually cause a kernel oops.
      
      Another problem is that user space tools such as perf and trace-cmd do not
      have access to the contents of these pointers, and they become useless when
      the tracing buffer is extracted.
      
      Instead of having vbin_printf() simply save the pointer in the buffer for
      later processing, have it perform the formatting at the time bin_printf() is
      called. This will fix the issue of dereferencing pointers at a later time,
      and has the extra benefit of having user space tools understand these
      values.
      
      Since perf and trace-cmd already can handle %p[sSfF] via saving kallsyms,
      their pointers are saved and not processed during vbin_printf(). If they
      were converted, it would break perf and trace-cmd, as they would not know
      how to deal with the conversion.
      
      Link: http://lkml.kernel.org/r/20171228204025.14a71d8f@gandalf.local.homeReported-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      841a915d
  12. 09 1月, 2018 1 次提交
    • S
      symbol lookup: introduce dereference_symbol_descriptor() · 04b8eb7a
      Sergey Senozhatsky 提交于
      dereference_symbol_descriptor() invokes appropriate ARCH specific
      function descriptor dereference callbacks:
      - dereference_kernel_function_descriptor() if the pointer is a
        kernel symbol;
      
      - dereference_module_function_descriptor() if the pointer is a
        module symbol.
      
      This is the last step needed to make '%pS/%ps' smart enough to
      handle function descriptor dereference on affected ARCHs and
      to retire '%pF/%pf'.
      
      To refresh it:
        Some architectures (ia64, ppc64, parisc64) use an indirect pointer
        for C function pointers - the function pointer points to a function
        descriptor and we need to dereference it to get the actual function
        pointer.
      
        Function descriptors live in .opd elf section and all affected
        ARCHs (ia64, ppc64, parisc64) handle it properly for kernel and
        modules. So we, technically, can decide if the dereference is
        needed by simply looking at the pointer: if it belongs to .opd
        section then we need to dereference it.
      
        The kernel and modules have their own .opd sections, obviously,
        that's why we need to split dereference_function_descriptor()
        and use separate kernel and module dereference arch callbacks.
      
      Link: http://lkml.kernel.org/r/20171206043649.GB15885@jagdpanzerIV
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: James Bottomley <jejb@parisc-linux.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Jessica Yu <jeyu@kernel.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: linux-ia64@vger.kernel.org
      Cc: linux-parisc@vger.kernel.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NSergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Tested-by: Tony Luck <tony.luck@intel.com> #ia64
      Tested-by: Santosh Sivaraj <santosh@fossix.org> #powerpc
      Tested-by: Helge Deller <deller@gmx.de> #parisc64
      Signed-off-by: NPetr Mladek <pmladek@suse.com>
      04b8eb7a
  13. 22 12月, 2017 2 次提交
    • J
      vsprintf: Fix a dangling documentation reference · 27e7c0e8
      Jonathan Corbet 提交于
      A reference to printk-formats.txt didn't get updated when the file moved;
      fix that.
      Signed-off-by: NJonathan Corbet <corbet@lwn.net>
      27e7c0e8
    • T
      doc: convert printk-formats.txt to rst · b3ed2321
      Tobin C. Harding 提交于
      Documentation/printk-formats.txt is a candidate for conversion to
      ReStructuredText format. Some effort has already been made to do this
      conversion even thought the suffix is currently .txt
      
      Changes required to complete conversion
      
       - Move printk-formats.txt to core-api/printk-formats.rst
       - Add entry to Documentation/core-api/index.rst
       - Remove entry from Documentation/00-INDEX
       - Fix minor grammatical errors.
       - Order heading adornments as suggested by rst docs.
       - Use 'Passed by reference' uniformly.
       - Update pointer documentation around %px specifier.
       - Fix erroneous double backticks (to commas).
       - Remove extraneous double backticks (suggested by Jonathan Corbet).
       - Simplify documentation for kobject.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      [jc: downcased "kernel"]
      Signed-off-by: NJonathan Corbet <corbet@lwn.net>
      b3ed2321
  14. 30 11月, 2017 1 次提交
    • L
      vsprintf: don't use 'restricted_pointer()' when not restricting · ef0010a3
      Linus Torvalds 提交于
      Instead, just fall back on the new '%p' behavior which hashes the
      pointer.
      
      Otherwise, '%pK' - that was intended to mark a pointer as restricted -
      just ends up leaking pointers that a normal '%p' wouldn't leak.  Which
      just make the whole thing pointless.
      
      I suspect we should actually get rid of '%pK' entirely, and make it just
      work as '%p' regardless, but this is the minimal obvious fix.  People
      who actually use 'kptr_restrict' should weigh in on which behavior they
      want.
      
      Cc: Tobin Harding <me@tobin.cc>
      Cc: Kees Cook <keescook@chromium.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ef0010a3
  15. 29 11月, 2017 3 次提交
    • T
      vsprintf: add printk specifier %px · 7b1924a1
      Tobin C. Harding 提交于
      printk specifier %p now hashes all addresses before printing. Sometimes
      we need to see the actual unmodified address. This can be achieved using
      %lx but then we face the risk that if in future we want to change the
      way the Kernel handles printing of pointers we will have to grep through
      the already existent 50 000 %lx call sites. Let's add specifier %px as a
      clear, opt-in, way to print a pointer and maintain some level of
      isolation from all the other hex integer output within the Kernel.
      
      Add printk specifier %px to print the actual unmodified address.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      7b1924a1
    • T
      printk: hash addresses printed with %p · ad67b74d
      Tobin C. Harding 提交于
      Currently there exist approximately 14 000 places in the kernel where
      addresses are being printed using an unadorned %p. This potentially
      leaks sensitive information regarding the Kernel layout in memory. Many
      of these calls are stale, instead of fixing every call lets hash the
      address by default before printing. This will of course break some
      users, forcing code printing needed addresses to be updated.
      
      Code that _really_ needs the address will soon be able to use the new
      printk specifier %px to print the address.
      
      For what it's worth, usage of unadorned %p can be broken down as
      follows (thanks to Joe Perches).
      
      $ git grep -E '%p[^A-Za-z0-9]' | cut -f1 -d"/" | sort | uniq -c
         1084 arch
           20 block
           10 crypto
           32 Documentation
         8121 drivers
         1221 fs
          143 include
          101 kernel
           69 lib
          100 mm
         1510 net
           40 samples
            7 scripts
           11 security
          166 sound
          152 tools
            2 virt
      
      Add function ptr_to_id() to map an address to a 32 bit unique
      identifier. Hash any unadorned usage of specifier %p and any malformed
      specifiers.
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      ad67b74d
    • T
      vsprintf: refactor %pK code out of pointer() · 57e73442
      Tobin C. Harding 提交于
      Currently code to handle %pK is all within the switch statement in
      pointer(). This is the wrong level of abstraction. Each of the other switch
      clauses call a helper function, pK should do the same.
      
      Refactor code out of pointer() to new function restricted_pointer().
      Signed-off-by: NTobin C. Harding <me@tobin.cc>
      57e73442
  16. 25 10月, 2017 1 次提交
    • M
      locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns... · 6aa7de05
      Mark Rutland 提交于
      locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()
      
      Please do not apply this to mainline directly, instead please re-run the
      coccinelle script shown below and apply its output.
      
      For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
      preference to ACCESS_ONCE(), and new code is expected to use one of the
      former. So far, there's been no reason to change most existing uses of
      ACCESS_ONCE(), as these aren't harmful, and changing them results in
      churn.
      
      However, for some features, the read/write distinction is critical to
      correct operation. To distinguish these cases, separate read/write
      accessors must be used. This patch migrates (most) remaining
      ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following
      coccinelle script:
      
      ----
      // Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and
      // WRITE_ONCE()
      
      // $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch
      
      virtual patch
      
      @ depends on patch @
      expression E1, E2;
      @@
      
      - ACCESS_ONCE(E1) = E2
      + WRITE_ONCE(E1, E2)
      
      @ depends on patch @
      expression E;
      @@
      
      - ACCESS_ONCE(E)
      + READ_ONCE(E)
      ----
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: davem@davemloft.net
      Cc: linux-arch@vger.kernel.org
      Cc: mpe@ellerman.id.au
      Cc: shuah@kernel.org
      Cc: snitzer@redhat.com
      Cc: thor.thayer@linux.intel.com
      Cc: tj@kernel.org
      Cc: viro@zeniv.linux.org.uk
      Cc: will.deacon@arm.com
      Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      6aa7de05
  17. 28 6月, 2017 1 次提交
    • P
      vsprintf: Add %p extension "%pOF" for device tree · ce4fecf1
      Pantelis Antoniou 提交于
      90% of the usage of device node's full_name is printing it out in a
      kernel message. However, storing the full path for every node is
      wasteful and redundant. With a custom format specifier, we can generate
      the full path at run-time and eventually remove the full path from every
      node.
      
      For instance typical use is:
      	pr_info("Frobbing node %s\n", node->full_name);
      
      Which can be written now as:
      	pr_info("Frobbing node %pOF\n", node);
      
      '%pO' is the base specifier to represent kobjects with '%pOF'
      representing struct device_node. Currently, struct device_node is the
      only supported type of kobject.
      
      More fine-grained control of formatting includes printing the name,
      flags, path-spec name and others, explained in the documentation entry.
      
      Originally written by Pantelis, but pretty much rewrote the core
      function using existing string/number functions. The 2 passes were
      unnecessary and have been removed. Also, updated the checkpatch.pl
      check. The unittest code was written by Grant Likely.
      Signed-off-by: NPantelis Antoniou <pantelis.antoniou@konsulko.com>
      Acked-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      ce4fecf1
  18. 05 6月, 2017 1 次提交
  19. 09 5月, 2017 1 次提交
  20. 03 4月, 2017 1 次提交
  21. 28 2月, 2017 1 次提交
  22. 21 5月, 2016 2 次提交
  23. 18 3月, 2016 1 次提交
    • J
      sscanf: implement basic character sets · f9310b2f
      Jessica Yu 提交于
      Implement basic character sets for the '%[' conversion specifier.
      
      The '%[' conversion specifier matches a nonempty sequence of characters
      from the specified set of accepted (or with '^', rejected) characters
      between the brackets.  The substring matched is to be made up of
      characters in (or not in) the set.  This is useful for matching
      substrings that are delimited by something other than spaces.
      
      This implementation differs from its glibc counterpart in the following ways:
       (1) No support for character ranges (e.g., 'a-z' or '0-9')
       (2) The hyphen '-' is not a special character
       (3) The closing bracket ']' cannot be matched
       (4) No support (yet) for discarding matching input ('%*[')
      
      The bitmap code is largely based upon sample code which was provided by
      Rasmus.
      
      The motivation for adding character set support to sscanf originally
      stemmed from the kernel livepatching project.  An ongoing patchset
      utilizes new livepatch Elf symbol and section names to store important
      metadata livepatch needs to properly apply its patches.  Such metadata
      is stored in these section and symbol names as substrings delimited by
      periods '.' and commas ','.  For example, a livepatch symbol name might
      look like this:
      
      .klp.sym.vmlinux.printk,0
      
      However, sscanf currently can only extract "substrings" delimited by
      whitespace using the "%s" specifier.  Thus for the above symbol name,
      one cannot not use sscanf() to extract substrings "vmlinux" or
      "printk", for example.  A number of discussions on the livepatch
      mailing list dealing with string parsing code for extracting these '.'
      and ',' delimited substrings eventually led to the conclusion that such
      code would be completely unnecessary if the kernel sscanf() supported
      character sets.  Thus only a single sscanf() call would be necessary to
      extract these substrings.  In addition, such an addition to sscanf()
      could benefit other areas of the kernel that might have a similar need
      in the future.
      
      [akpm@linux-foundation.org: 80-col tweaks]
      Signed-off-by: NJessica Yu <jeyu@redhat.com>
      Signed-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Kees Cook <keescook@chromium.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f9310b2f
  24. 16 3月, 2016 1 次提交
    • V
      mm, printk: introduce new format string for flags · edf14cdb
      Vlastimil Babka 提交于
      In mm we use several kinds of flags bitfields that are sometimes printed
      for debugging purposes, or exported to userspace via sysfs.  To make
      them easier to interpret independently on kernel version and config, we
      want to dump also the symbolic flag names.  So far this has been done
      with repeated calls to pr_cont(), which is unreliable on SMP, and not
      usable for e.g.  sysfs export.
      
      To get a more reliable and universal solution, this patch extends
      printk() format string for pointers to handle the page flags (%pGp),
      gfp_flags (%pGg) and vma flags (%pGv).  Existing users of
      dump_flag_names() are converted and simplified.
      
      It would be possible to pass flags by value instead of pointer, but the
      %p format string for pointers already has extensions for various kernel
      structures, so it's a good fit, and the extra indirection in a
      non-critical path is negligible.
      
      [linux@rasmusvillemoes.dk: lots of good implementation suggestions]
      Signed-off-by: NVlastimil Babka <vbabka@suse.cz>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Sasha Levin <sasha.levin@oracle.com>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      edf14cdb
  25. 12 2月, 2016 1 次提交
  26. 17 1月, 2016 4 次提交