1. 24 3月, 2011 1 次提交
    • N
      vsprintf: Introduce %pB format specifier · 0f77a8d3
      Namhyung Kim 提交于
      The %pB format specifier is for stack backtrace. Its handler
      sprint_backtrace() does symbol lookup using (address-1) to
      ensure the address will not point outside of the function.
      
      If there is a tail-call to the function marked "noreturn",
      gcc optimized out the code after the call then causes saved
      return address points outside of the function (i.e. the start
      of the next function), so pollutes call trace somewhat.
      
      This patch adds the %pB printk mechanism that allows architecture
      call-trace printout functions to improve backtrace printouts.
      Signed-off-by: NNamhyung Kim <namhyung@gmail.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      Acked-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: linux-arch@vger.kernel.org
      LKML-Reference: <1300934550-21394-1-git-send-email-namhyung@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      0f77a8d3
  2. 23 3月, 2011 3 次提交
    • A
      kstrto*: converting strings to integers done (hopefully) right · 33ee3b2e
      Alexey Dobriyan 提交于
      1. simple_strto*() do not contain overflow checks and crufty,
         libc way to indicate failure.
      2. strict_strto*() also do not have overflow checks but the name and
         comments pretend they do.
      3. Both families have only "long long" and "long" variants,
         but users want strtou8()
      4. Both "simple" and "strict" prefixes are wrong:
         Simple doesn't exactly say what's so simple, strict should not exist
         because conversion should be strict by default.
      
      The solution is to use "k" prefix and add convertors for more types.
      Enter
      	kstrtoull()
      	kstrtoll()
      	kstrtoul()
      	kstrtol()
      	kstrtouint()
      	kstrtoint()
      
      	kstrtou64()
      	kstrtos64()
      	kstrtou32()
      	kstrtos32()
      	kstrtou16()
      	kstrtos16()
      	kstrtou8()
      	kstrtos8()
      
      Include runtime testsuite (somewhat incomplete) as well.
      
      strict_strto*() become deprecated, stubbed to kstrto*() and
      eventually will be removed altogether.
      
      Use kstrto*() in code today!
      
      Note: on some archs _kstrtoul() and _kstrtol() are left in tree, even if
            they'll be unused at runtime. This is temporarily solution,
            because I don't want to hardcode list of archs where these
            functions aren't needed. Current solution with sizeof() and
            __alignof__ at least always works.
      Signed-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>
      33ee3b2e
    • K
      printk: use %pK for /proc/kallsyms and /proc/modules · 9f36e2c4
      Kees Cook 提交于
      In an effort to reduce kernel address leaks that might be used to help
      target kernel privilege escalation exploits, this patch uses %pK when
      displaying addresses in /proc/kallsyms, /proc/modules, and
      /sys/module/*/sections/*.
      
      Note that this changes %x to %p, so some legitimately 0 values in
      /proc/kallsyms would have changed from 00000000 to "(null)".  To avoid
      this, "(null)" is not used when using the "K" format.  Anything that was
      already successfully parsing "(null)" in addition to full hex digits
      should have no problem with this change.  (Thanks to Joe Perches for the
      suggestion.) Due to the %x to %p, "void *" casts are needed since these
      addresses are already "unsigned long" everywhere internally, due to their
      starting life as ELF section offsets.
      Signed-off-by: NKees Cook <kees.cook@canonical.com>
      Cc: Eugene Teo <eugene@redhat.com>
      Cc: Dan Rosenberg <drosenberg@vsecurity.com>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9f36e2c4
    • J
      vsprintf: neaten %pK kptr_restrict, save a bit of code space · 26297607
      Joe Perches 提交于
      If kptr restrictions are on, just set the passed pointer to NULL.
      
      $ size lib/vsprintf.o.*
         text	   data	    bss	    dec	    hex	filename
         8247	      4	      2	   8253	   203d	lib/vsprintf.o.new
         8282	      4	      2	   8288	   2060	lib/vsprintf.o.old
      Signed-off-by: NJoe Perches <joe@perches.com>
      Cc: Dan Rosenberg <drosenberg@vsecurity.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      26297607
  3. 14 1月, 2011 2 次提交
    • A
      lib/vsprintf.c: fix vscnprintf() if @size is == 0 · b921c69f
      Anton Arapov 提交于
      vscnprintf() should return 0 if @size is == 0.  Update the comment for it,
      as @size is unsigned.
      
      This change based on the code of commit
      b903c0b8 ("lib: fix scnprintf() if @size
      is == 0") moves the real fix into vscnprinf() from scnprintf() and makes
      scnprintf() call vscnprintf(), thus avoid code duplication.
      Signed-off-by: NAnton Arapov <aarapov@redhat.com>
      Acked-by: NChangli Gao <xiaosuo@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b921c69f
    • D
      kptr_restrict for hiding kernel pointers from unprivileged users · 455cd5ab
      Dan Rosenberg 提交于
      Add the %pK printk format specifier and the /proc/sys/kernel/kptr_restrict
      sysctl.
      
      The %pK format specifier is designed to hide exposed kernel pointers,
      specifically via /proc interfaces.  Exposing these pointers provides an
      easy target for kernel write vulnerabilities, since they reveal the
      locations of writable structures containing easily triggerable function
      pointers.  The behavior of %pK depends on the kptr_restrict sysctl.
      
      If kptr_restrict is set to 0, no deviation from the standard %p behavior
      occurs.  If kptr_restrict is set to 1, the default, if the current user
      (intended to be a reader via seq_printf(), etc.) does not have CAP_SYSLOG
      (currently in the LSM tree), kernel pointers using %pK are printed as 0's.
       If kptr_restrict is set to 2, kernel pointers using %pK are printed as
      0's regardless of privileges.  Replacing with 0's was chosen over the
      default "(null)", which cannot be parsed by userland %p, which expects
      "(nil)".
      
      [akpm@linux-foundation.org: check for IRQ context when !kptr_restrict, save an indent level, s/WARN/WARN_ONCE/]
      [akpm@linux-foundation.org: coding-style fixup]
      [randy.dunlap@oracle.com: fix kernel/sysctl.c warning]
      Signed-off-by: NDan Rosenberg <drosenberg@vsecurity.com>
      Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Eric Dumazet <eric.dumazet@gmail.com>
      Cc: Thomas Graf <tgraf@infradead.org>
      Cc: Eugene Teo <eugeneteo@kernel.org>
      Cc: Kees Cook <kees.cook@canonical.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Eric Paris <eparis@parisplace.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      455cd5ab
  4. 27 10月, 2010 2 次提交
  5. 10 8月, 2010 1 次提交
  6. 05 7月, 2010 1 次提交
  7. 25 5月, 2010 2 次提交
  8. 25 4月, 2010 1 次提交
  9. 15 4月, 2010 1 次提交
  10. 15 3月, 2010 2 次提交
  11. 07 3月, 2010 3 次提交
  12. 14 1月, 2010 1 次提交
  13. 12 1月, 2010 1 次提交
  14. 11 1月, 2010 1 次提交
  15. 08 1月, 2010 1 次提交
    • J
      lib/vsprintf.c: Add %pMF to format FDDI bit reversed MAC addresses · bc7259a2
      Joe Perches 提交于
      On Mon, 2010-01-04 at 23:43 +0000, Maciej W. Rozycki wrote:
      > The example below shows an address, and the sequence of bits or symbols
      > that would be transmitted when the address is used in the Source Address
      > or Destination Address fields on the MAC header.  The transmission line
      > shows the address bits in the order transmitted, from left to right.  For
      > IEEE 802 LANs these correspond to actual bits on the medium.  The FDDI
      > symbols line shows how the FDDI PHY sends the address bits as encoded
      > symbols.
      >
      >         MSB:            35:7B:12:00:00:01
      >         Canonical:      AC-DE-48-00-00-80
      >         Transmission:   00110101 01111011 00010010 00000000 00000000 00000001
      >         FDDI Symbols:   35 7B 12 00 00 01"
      >
      > Please note that this address has its group bit clear.
      >
      >  This notation is also defined in the "FDDI MEDIA ACCESS CONTROL-2
      > (MAC-2)" (X3T9/92-120) document although that book does not have a need
      > to use the MSB form and it's skipped.
      
      Adds 6 bytes to object size for x86
      
      New:
      $ size lib/vsprintf.o
         text	   data	    bss	    dec	    hex	filename
         8664	      0	      2	   8666	   21da	lib/vsprintf.o
      $ size lib/vsprintf.o
         text    data     bss     dec     hex filename
         8658       0       2    8660    21d4 lib/vsprintf.o
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bc7259a2
  16. 18 12月, 2009 1 次提交
  17. 16 12月, 2009 10 次提交
  18. 05 11月, 2009 4 次提交
  19. 02 10月, 2009 1 次提交
  20. 23 9月, 2009 1 次提交