1. 11 Feb, 2011 1 commit
    • Linus Torvalds's avatar
      cap_syslog: accept CAP_SYS_ADMIN for now · ee24aebf
      Linus Torvalds authored
      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: default avatarSerge Hallyn <serge@hallyn.com>
      Reviewed-by: default avatarJames Morris <jmorris@namei.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ee24aebf
  2. 26 Jan, 2011 1 commit
    • Torben Hohn's avatar
      console: rename acquire/release_console_sem() to console_lock/unlock() · ac751efa
      Torben Hohn authored
      
      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: default avatarTorben 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: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ac751efa
  3. 13 Jan, 2011 2 commits
  4. 17 Dec, 2010 2 commits
  5. 08 Dec, 2010 2 commits
  6. 28 Nov, 2010 1 commit
    • Serge E. Hallyn's avatar
      security: Define CAP_SYSLOG · ce6ada35
      Serge E. Hallyn authored
      
      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: default avatarSerge Hallyn <serge.hallyn@ubuntu.com>
      Acked-by: default avatarAndrew G. Morgan <morgan@kernel.org>
      Acked-By: default avatarKees 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: default avatarJames Morris <jmorris@namei.org>
      ce6ada35
  7. 26 Nov, 2010 2 commits
    • Heiko Carstens's avatar
      nohz: Fix printk_needs_cpu() return value on offline cpus · 61ab2544
      Heiko Carstens authored
      
      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: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: stable@kernel.org
      LKML-Reference: <20101126120235.406766476@de.ibm.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      61ab2544
    • Heiko Carstens's avatar
      printk: Fix wake_up_klogd() vs cpu hotplug · 49f41383
      Heiko Carstens authored
      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: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Acked-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      LKML-Reference: <20101126124247.GC7023@osiris.boeblingen.de.ibm.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      49f41383
  8. 16 Nov, 2010 1 commit
  9. 15 Nov, 2010 1 commit
  10. 12 Nov, 2010 1 commit
  11. 26 Oct, 2010 3 commits
  12. 12 Oct, 2010 1 commit
  13. 10 Aug, 2010 1 commit
  14. 05 Aug, 2010 1 commit
    • Kevin Cernekee's avatar
      printk: fix delayed messages from CPU hotplug events · 034260d6
      Kevin Cernekee authored
      When a secondary CPU is being brought up, it is not uncommon for
      printk() to be invoked when cpu_online(smp_processor_id()) == 0.  The
      case that I witnessed personally was on MIPS:
      
      http://lkml.org/lkml/2010/5/30/4
      
      If (can_use_console() == 0), printk() will spool its output to log_buf
      and it will be visible in "dmesg", but that output will NOT be echoed to
      the console until somebody calls release_console_sem() from a CPU that
      is online.  Therefore, the boot time messages from the new CPU can get
      stuck in "limbo" for a long time, and might suddenly appear on the
      screen when a completely unrelated event (e.g. "eth0: link is down")
      occurs.
      
      This patch modifies the console code so that any pending messages are
      automatically flushed out to the console whenever a CPU hotplug
      operation completes successfully or aborts.
      
      The issue was seen on 2.6.34.
      
      Original patch by Kevin Cernekee with cleanups by akpm and additional fixes
      by Santosh Shilimkar.  This patch superseeds
      https://patchwork.linux-mips.org/patch/1357/
      
      .
      Signed-off-by: default avatarKevin Cernekee <cernekee@gmail.com>
      To: <mingo@elte.hu>
      To: <akpm@linux-foundation.org>
      To: <simon.kagstrom@netinsight.net>
      To: <David.Woodhouse@intel.com>
      To: <lethal@linux-sh.org>
      Cc: <linux-kernel@vger.kernel.org>
      Cc: <linux-mips@linux-mips.org>
      Reviewed-by: default avatarPaul Mundt <lethal@linux-sh.org>
      Signed-off-by: default avatarKevin Cernekee <cernekee@gmail.com>
      Patchwork: https://patchwork.linux-mips.org/patch/1534/
      
      
      LKML-Reference: <ede63b5a20af951c755736f035d1e787772d7c28@localhost>
      LKML-Reference: <EAF47CD23C76F840A9E7FCE10091EFAB02C5DB6D1F@dbde02.ent.ti.com>
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      034260d6
  15. 21 May, 2010 2 commits
  16. 06 Mar, 2010 1 commit
  17. 04 Feb, 2010 2 commits
  18. 31 Dec, 2009 1 commit
  19. 17 Dec, 2009 1 commit
  20. 02 Dec, 2009 1 commit
  21. 30 Nov, 2009 1 commit
  22. 23 Oct, 2009 1 commit
    • Christian Borntraeger's avatar
      ratelimit: Make suppressed output messages more useful · 5c828713
      Christian Borntraeger authored
      
      Today I got:
      
        [39648.224782] Registered led device: iwl-phy0::TX
        [40676.545099] __ratelimit: 246 callbacks suppressed
        [40676.545103] abcdef[23675]: segfault at 0 ...
      
      as you can see the ratelimit message contains a function prefix.
      Since this is always __ratelimit, this wont help much.
      
      This patch changes __ratelimit and printk_ratelimit to print the
      function name that calls ratelimit.
      
      This will pinpoint the responsible function, as long as not several
      different places call ratelimit with the same ratelimit state at
      the same time. In that case we catch only one random function that
      calls ratelimit after the wait period.
      Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Cc: Dave Young <hidave.darkstar@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      CC: Andrew Morton <akpm@linux-foundation.org>
      LKML-Reference: <200910231458.11832.borntraeger@de.ibm.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      5c828713
  23. 23 Sep, 2009 2 commits
  24. 22 Sep, 2009 1 commit
    • Ingo Molnar's avatar
      printk: Remove ratelimit.h from kernel.h · 3fff4c42
      Ingo Molnar authored
      
      Decouple kernel.h from ratelimit.h: the global declaration of
      printk's ratelimit_state is not needed, and it leads to messy
      circular dependencies due to ratelimit.h's (new) adding of a
      spinlock_types.h include.
      
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: David S. Miller <davem@davemloft.net>
      LKML-Reference: <new-submission>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      3fff4c42
  25. 15 Sep, 2009 1 commit
  26. 08 Aug, 2009 1 commit
  27. 10 Jul, 2009 2 commits
    • Frans Pop's avatar
      printk: Restore previous console_loglevel when re-enabling logging · 1aaad49e
      Frans Pop authored
      When logging to console is disabled from userspace using klogctl()
      and later re-enabled, console_loglevel gets set to the default
      log level instead to the previous value.
      
      This means that if the kernel was booted with 'quiet', the boot is
      suddenly no longer quiet after logging to console gets re-enabled.
      
      Save the current console_loglevel when logging is disabled and
      restore to that value. If the log level is set to a specific value
      while disabled, this is interpreted as an implicit re-enabling of
      the logging.
      
      The problem that prompted this patch is described in:
      
          http://lkml.org/lkml/2009/6/28/234
      
      
      
      There are two variations possible on the patch below:
      
       1) If klogctl(7) is called while logging is not disabled, then set level
          to default (partially preserving current functionality):
        	case 7:		/* Enable logging to console */
       -		console_loglevel = default_console_loglevel;
       +		if (saved_console_loglevel == -1)
       +			console_loglevel = default_console_loglevel;
       +		else {
       +			console_loglevel = saved_console_loglevel;
       +			saved_console_loglevel = -1;
       +		}
      
       2) If klogctl(8) is called while logging is disabled, then don't enable
          logging, but remember the requested value for when logging does get
          enabled again:
        	case 8:		/* Set level of messages printed to console */
       [...]
       - 		console_loglevel = len;
       +		if (saved_console_loglevel == -1)
       +			console_loglevel = len;
       +		else
       +			saved_console_loglevel = len;
      
      Yet another option would be to ignore the request.
      Signed-off-by: default avatarFrans Pop <elendil@planet.nl>
      Cc: cryptsetup@packages.debian.org
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      LKML-Reference: <200907061331.49930.elendil@planet.nl>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      1aaad49e
    • Robin Getz's avatar
      printk: Ensure that "console enabled" messages are printed on the console · 8259cf43
      Robin Getz authored
      
      Today, when a console is registered without CON_PRINTBUFFER,
      end users never see the announcement of it being added, and
      never know if they missed something, if the console is really
      at the start or not, and just leads to general confusion.
      
      This re-orders existing code, to make sure the console is
      added, before the "console [%s%d] enabled" is printed out -
      ensuring that this message is _always_ seen.
      
      This has the desired/intended side effect of making sure that
      "console enabled:" messages are printed on the bootconsole, and
      the real console. This does cause the same line is printed
      twice if the bootconsole and real console are the same device,
      but if they are on different devices, the message is printed to
      both consoles.
      
      Signed-off-by : Robin Getz <rgetz@blackfin.uclinux.org>
      Cc: "Andrew Morton" <akpm@linux-foundation.org>
      Cc: "Linus Torvalds" <torvalds@linux-foundation.org>
      LKML-Reference: <200907091308.37370.rgetz@blackfin.uclinux.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      8259cf43
  28. 03 Jul, 2009 1 commit
    • Robin Getz's avatar
      printk: Enable the use of more than one CON_BOOT (early console) · 4d091611
      Robin Getz authored
      
      Today, register_console() assumes the following usage:
      
        - The first console to register with a flag set to CON_BOOT
          is the one and only bootconsole.
      
        - If another register_console() is called with an additional
          CON_BOOT, it is silently rejected.
      
        - As soon as a console without the CON_BOOT set calls
          registers the bootconsole is automatically unregistered.
      
        - Once there is a "real" console - register_console() will
          silently reject any consoles with it's CON_BOOT flag set.
      
      In many systems (alpha, blackfin, microblaze, mips, powerpc,
      sh, & x86), there are early_printk implementations, which use
      the CON_BOOT which come out serial ports, vga, usb, & memory
      buffers.
      
      In many embedded systems, it would be nice to have two
      bootconsoles - in case the primary fails, you always have
      access to a backup memory buffer - but this requires at least
      two CON_BOOT consoles...
      
      This patch enables that functionality.
      
      With the change applied, on boot you get (if you try to
      re-enable a boot console after the "real" console has been
      registered):
      
        root:/> dmesg | grep console
        bootconsole [early_shadow0] enabled
        bootconsole [early_BFuart0] enabled
        Kernel command line: root=/dev/mtdblock0 rw earlyprintk=serial,uart0,57600 console=ttyBF0,57600 nmi_debug=regs
        console handover:boot [early_BFuart0] boot [early_shadow0]  -> real [ttyBF0]
        Too late to register bootconsole early_shadow0
      
      or:
      
        root:/> dmesg | grep console
        Kernel command line: root=/dev/mtdblock0 rw console=ttyBF0,57600
        console [ttyBF0] enabled
      Signed-off-by: default avatarRobin Getz <rgetz@blackfin.uclinux.org>
      Cc: "Linus Torvalds" <torvalds@linux-foundation.org>
      Cc: "Andrew Morton" <akpm@linux-foundation.org>
      Cc: "Mike Frysinger" <vapier.adi@gmail.com>
      Cc: "Paul Mundt" <lethal@linux-sh.org>
      LKML-Reference: <200907012108.38030.rgetz@blackfin.uclinux.org>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      4d091611
  29. 16 Jun, 2009 2 commits
    • Linus Torvalds's avatar
      printk: Add KERN_DEFAULT printk log-level · e28d7137
      Linus Torvalds authored
      
      This adds a KERN_DEFAULT loglevel marker, for when you cannot decide
      which loglevel you want, and just want to keep an existing printk
      with the default loglevel.
      
      The difference between having KERN_DEFAULT and having no log-level
      marker at all is two-fold:
      
       - having the log-level marker will now force a new-line if the
         previous printout had not added one (perhaps because it forgot,
         but perhaps because it expected a continuation)
      
       - having a log-level marker is required if you are printing out a
         message that otherwise itself could perhaps otherwise be mistaken
         for a log-level.
      Signed-of-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e28d7137
    • Linus Torvalds's avatar
      printk: clean up handling of log-levels and newlines · 5fd29d6c
      Linus Torvalds authored
      
      It used to be that we would only look at the log-level in a printk()
      after explicit newlines, which can cause annoying problems when the
      previous printk() did not end with a '\n'. In that case, the log-level
      marker would be just printed out in the middle of the line, and be
      seen as just noise rather than change the logging level.
      
      This changes things to always look at the log-level in the first
      bytes of the printout. If a log level marker is found, it is always
      used as the log-level. Additionally, if no newline existed, one is
      added (unless the log-level is the explicit KERN_CONT marker, to
      explicitly show that it's a continuation of a previous line).
      Acked-by: default avatarArjan van de Ven <arjan@infradead.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5fd29d6c