1. 08 5月, 2012 3 次提交
    • K
      kmsg: use do_div() to divide 64bit integer · 5fc32490
      Kay Sievers 提交于
      On Tue, May 8, 2012 at 10:02 AM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
      > kernel/built-in.o: In function `devkmsg_read':
      > printk.c:(.text+0x27e8): undefined reference to `__udivdi3'
      > Most probably the "msg->ts_nsec / 1000" since
      > ts_nsec is a u64 and this is a 32 bit build ...
      Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: NKay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5fc32490
    • K
      kmsg: export printk records to the /dev/kmsg interface · e11fea92
      Kay Sievers 提交于
      Support for multiple concurrent readers of /dev/kmsg, with read(),
      seek(), poll() support. Output of message sequence numbers, to allow
      userspace log consumers to reliably reconnect and reconstruct their
      state at any given time. After open("/dev/kmsg"), read() always
      returns *all* buffered records. If only future messages should be
      read, SEEK_END can be used. In case records get overwritten while
      /dev/kmsg is held open, or records get faster overwritten than they
      are read, the next read() will return -EPIPE and the current reading
      position gets updated to the next available record. The passed
      sequence numbers allow the log consumer to calculate the amount of
      lost messages.
      
        [root@mop ~]# cat /dev/kmsg
        5,0,0;Linux version 3.4.0-rc1+ (kay@mop) (gcc version 4.7.0 20120315 ...
        6,159,423091;ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
        7,160,424069;pci_root PNP0A03:00: host bridge window [io  0x0000-0x0cf7] (ignored)
         SUBSYSTEM=acpi
         DEVICE=+acpi:PNP0A03:00
        6,339,5140900;NET: Registered protocol family 10
        30,340,5690716;udevd[80]: starting version 181
        6,341,6081421;FDC 0 is a S82078B
        6,345,6154686;microcode: CPU0 sig=0x623, pf=0x0, revision=0x0
        7,346,6156968;sr 1:0:0:0: Attached scsi CD-ROM sr0
         SUBSYSTEM=scsi
         DEVICE=+scsi:1:0:0:0
        6,347,6289375;microcode: CPU1 sig=0x623, pf=0x0, revision=0x0
      
      Cc: Karel Zak <kzak@redhat.com>
      Tested-by: NWilliam Douglas <william.douglas@intel.com>
      Signed-off-by: NKay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e11fea92
    • K
      printk: convert byte-buffer to variable-length record buffer · 7ff9554b
      Kay Sievers 提交于
      - Record-based stream instead of the traditional byte stream
        buffer. All records carry a 64 bit timestamp, the syslog facility
        and priority in the record header.
      
      - Records consume almost the same amount, sometimes less memory than
        the traditional byte stream buffer (if printk_time is enabled). The record
        header is 16 bytes long, plus some padding bytes at the end if needed.
        The byte-stream buffer needed 3 chars for the syslog prefix, 15 char for
        the timestamp and a newline.
      
      - Buffer management is based on message sequence numbers. When records
        need to be discarded, the reading heads move on to the next full
        record. Unlike the byte-stream buffer, no old logged lines get
        truncated or partly overwritten by new ones. Sequence numbers also
        allow consumers of the log stream to get notified if any message in
        the stream they are about to read gets discarded during the time
        of reading.
      
      - Better buffered IO support for KERN_CONT continuation lines, when printk()
        is called multiple times for a single line. The use of KERN_CONT is now
        mandatory to use continuation; a few places in the kernel need trivial fixes
        here. The buffering could possibly be extended to per-cpu variables to allow
        better thread-safety for multiple printk() invocations for a single line.
      
      - Full-featured syslog facility value support. Different facilities
        can tag their messages. All userspace-injected messages enforce a
        facility value > 0 now, to be able to reliably distinguish them from
        the kernel-generated messages. Independent subsystems like a
        baseband processor running its own firmware, or a kernel-related
        userspace process can use their own unique facility values. Multiple
        independent log streams can co-exist that way in the same
        buffer. All share the same global sequence number counter to ensure
        proper ordering (and interleaving) and to allow the consumers of the
        log to reliably correlate the events from different facilities.
      Tested-by: NWilliam Douglas <william.douglas@intel.com>
      Signed-off-by: NKay Sievers <kay@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7ff9554b
  2. 15 3月, 2012 1 次提交
  3. 13 3月, 2012 1 次提交
  4. 06 3月, 2012 1 次提交
    • M
      kmsg_dump: don't run on non-error paths by default · c22ab332
      Matthew Garrett 提交于
      Since commit 04c6862c ("kmsg_dump: add kmsg_dump() calls to the
      reboot, halt, poweroff and emergency_restart paths"), kmsg_dump() gets
      run on normal paths including poweroff and reboot.
      
      This is less than ideal given pstore implementations that can only
      represent single backtraces, since a reboot may overwrite a stored oops
      before it's been picked up by userspace.  In addition, some pstore
      backends may have low performance and provide a significant delay in
      reboot as a result.
      
      This patch adds a printk.always_kmsg_dump kernel parameter (which can also
      be changed from userspace).  Without it, the code will only be run on
      failure paths rather than on normal paths.  The option can be enabled in
      environments where there's a desire to attempt to audit whether or not a
      reboot was cleanly requested or not.
      Signed-off-by: NMatthew Garrett <mjg@redhat.com>
      Acked-by: NSeiji Aguchi <seiji.aguchi@hds.com>
      Cc: Seiji Aguchi <seiji.aguchi@hds.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Marco Stornelli <marco.stornelli@gmail.com>
      Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
      Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      c22ab332
  5. 14 2月, 2012 1 次提交
  6. 13 1月, 2012 2 次提交
  7. 09 12月, 2011 1 次提交
  8. 14 11月, 2011 3 次提交
  9. 01 11月, 2011 4 次提交
  10. 13 9月, 2011 1 次提交
  11. 26 8月, 2011 1 次提交
  12. 10 8月, 2011 1 次提交
  13. 14 7月, 2011 1 次提交
  14. 22 6月, 2011 1 次提交
  15. 07 6月, 2011 1 次提交
  16. 25 5月, 2011 1 次提交
    • M
      printk: allocate kernel log buffer earlier · 162a7e75
      Mike Travis 提交于
      On larger systems, because of the numerous ACPI, Bootmem and EFI messages,
      the static log buffer overflows before the larger one specified by the
      log_buf_len param is allocated.  Minimize the overflow by allocating the
      new log buffer as soon as possible.
      
      On kernels without memblock, a later call to setup_log_buf from
      kernel/init.c is the fallback.
      
      [akpm@linux-foundation.org: coding-style fixes]
      [akpm@linux-foundation.org: fix CONFIG_PRINTK=n build]
      Signed-off-by: NMike Travis <travis@sgi.com>
      Cc: Yinghai Lu <yhlu.kernel@gmail.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Jack Steiner <steiner@sgi.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      162a7e75
  17. 23 3月, 2011 3 次提交
  18. 14 3月, 2011 1 次提交
    • K
      printk: do not mangle valid userspace syslog prefixes · 9d90c8d9
      Kay Sievers 提交于
      printk: do not mangle valid userspace syslog prefixes with /dev/kmsg
      
      Log messages passed to the kernel log by using /dev/kmsg or /dev/ttyprintk
      might contain a syslog prefix including the syslog facility value.
      
      This makes printk to recognize these headers properly, extract the real log
      level from it to use, and add the prefix as a proper prefix to the
      log buffer, instead of wrongly printing it as the log message text.
      
      Before:
        $ echo '<14>text' > /dev/kmsg
        $ dmesg -r
        <4>[135159.594810] <14>text
      
      After:
        $ echo '<14>text' > /dev/kmsg
        $ dmesg -r
        <14>[   50.750654] text
      
      Cc: Lennart Poettering <lennart@poettering.net>
      Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9d90c8d9
  19. 11 2月, 2011 1 次提交
    • L
      cap_syslog: accept CAP_SYS_ADMIN for now · ee24aebf
      Linus Torvalds 提交于
      In commit ce6ada35 ("security: Define CAP_SYSLOG") Serge Hallyn
      introduced CAP_SYSLOG, but broke backwards compatibility by no longer
      accepting CAP_SYS_ADMIN as an override (it would cause a warning and
      then reject the operation).
      
      Re-instate CAP_SYS_ADMIN - but keeping the warning - as an acceptable
      capability until any legacy applications have been updated.  There are
      apparently applications out there that drop all capabilities except for
      CAP_SYS_ADMIN in order to access the syslog.
      
      (This is a re-implementation of a patch by Serge, cleaning the logic up
      and making the code more readable)
      Acked-by: NSerge Hallyn <serge@hallyn.com>
      Reviewed-by: NJames Morris <jmorris@namei.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ee24aebf
  20. 26 1月, 2011 1 次提交
    • T
      console: rename acquire/release_console_sem() to console_lock/unlock() · ac751efa
      Torben Hohn 提交于
      The -rt patches change the console_semaphore to console_mutex.  As a
      result, a quite large chunk of the patches changes all
      acquire/release_console_sem() to acquire/release_console_mutex()
      
      This commit makes things use more neutral function names which dont make
      implications about the underlying lock.
      
      The only real change is the return value of console_trylock which is
      inverted from try_acquire_console_sem()
      
      This patch also paves the way to switching console_sem from a semaphore to
      a mutex.
      
      [akpm@linux-foundation.org: coding-style fixes]
      [akpm@linux-foundation.org: make console_trylock return 1 on success, per Geert]
      Signed-off-by: NTorben Hohn <torbenh@gmx.de>
      Cc: Thomas Gleixner <tglx@tglx.de>
      Cc: Greg KH <gregkh@suse.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ac751efa
  21. 14 1月, 2011 2 次提交
  22. 17 12月, 2010 2 次提交
  23. 09 12月, 2010 2 次提交
  24. 29 11月, 2010 1 次提交
    • S
      security: Define CAP_SYSLOG · ce6ada35
      Serge E. Hallyn 提交于
      Privileged syslog operations currently require CAP_SYS_ADMIN.  Split
      this off into a new CAP_SYSLOG privilege which we can sanely take away
      from a container through the capability bounding set.
      
      With this patch, an lxc container can be prevented from messing with
      the host's syslog (i.e. dmesg -c).
      
      Changelog: mar 12 2010: add selinux capability2:cap_syslog perm
      Changelog: nov 22 2010:
      	. port to new kernel
      	. add a WARN_ONCE if userspace isn't using CAP_SYSLOG
      Signed-off-by: NSerge Hallyn <serge.hallyn@ubuntu.com>
      Acked-by: NAndrew G. Morgan <morgan@kernel.org>
      Acked-By: NKees Cook <kees.cook@canonical.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Michael Kerrisk <mtk.manpages@gmail.com>
      Cc: Stephen Smalley <sds@tycho.nsa.gov>
      Cc: "Christopher J. PeBenito" <cpebenito@tresys.com>
      Cc: Eric Paris <eparis@parisplace.org>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      ce6ada35
  25. 26 11月, 2010 2 次提交
    • H
      nohz: Fix printk_needs_cpu() return value on offline cpus · 61ab2544
      Heiko Carstens 提交于
      This patch fixes a hang observed with 2.6.32 kernels where timers got enqueued
      on offline cpus.
      
      printk_needs_cpu() may return 1 if called on offline cpus. When a cpu gets
      offlined it schedules the idle process which, before killing its own cpu, will
      call tick_nohz_stop_sched_tick(). That function in turn will call
      printk_needs_cpu() in order to check if the local tick can be disabled. On
      offline cpus this function should naturally return 0 since regardless if the
      tick gets disabled or not the cpu will be dead short after. That is besides the
      fact that __cpu_disable() should already have made sure that no interrupts on
      the offlined cpu will be delivered anyway.
      
      In this case it prevents tick_nohz_stop_sched_tick() to call
      select_nohz_load_balancer(). No idea if that really is a problem. However what
      made me debug this is that on 2.6.32 the function get_nohz_load_balancer() is
      used within __mod_timer() to select a cpu on which a timer gets enqueued. If
      printk_needs_cpu() returns 1 then the nohz_load_balancer cpu doesn't get
      updated when a cpu gets offlined. It may contain the cpu number of an offline
      cpu. In turn timers get enqueued on an offline cpu and not very surprisingly
      they never expire and cause system hangs.
      
      This has been observed 2.6.32 kernels. On current kernels __mod_timer() uses
      get_nohz_timer_target() which doesn't have that problem. However there might be
      other problems because of the too early exit tick_nohz_stop_sched_tick() in
      case a cpu goes offline.
      
      Easiest way to fix this is just to test if the current cpu is offline and call
      printk_tick() directly which clears the condition.
      
      Alternatively I tried a cpu hotplug notifier which would clear the condition,
      however between calling the notifier function and printk_needs_cpu() something
      could have called printk() again and the problem is back again. This seems to
      be the safest fix.
      Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: stable@kernel.org
      LKML-Reference: <20101126120235.406766476@de.ibm.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      61ab2544
    • H
      printk: Fix wake_up_klogd() vs cpu hotplug · 49f41383
      Heiko Carstens 提交于
      wake_up_klogd() may get called from preemptible context but uses
      __raw_get_cpu_var() to write to a per cpu variable. If it gets preempted
      between getting the address and writing to it, the cpu in question could be
      offline if the process gets scheduled back and hence writes to the per cpu data
      of an offline cpu.
      
      This buggy behaviour was introduced with fa33507a "printk: robustify
      printk, fix #2" which was supposed to fix a "using smp_processor_id() in
      preemptible" warning.
      
      Let's use this_cpu_write() instead which disables preemption and makes sure
      that the outlined scenario cannot happen.
      Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Acked-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      LKML-Reference: <20101126124247.GC7023@osiris.boeblingen.de.ibm.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      49f41383
  26. 17 11月, 2010 1 次提交