1. 28 2月, 2013 1 次提交
  2. 25 1月, 2013 1 次提交
    • A
      x86/msr: Add capabilities check · c903f045
      Alan Cox 提交于
      At the moment the MSR driver only relies upon file system
      checks. This means that anything as root with any capability set
      can write to MSRs. Historically that wasn't very interesting but
      on modern processors the MSRs are such that writing to them
      provides several ways to execute arbitary code in kernel space.
      Sample code and documentation on doing this is circulating and
      MSR attacks are used on Windows 64bit rootkits already.
      
      In the Linux case you still need to be able to open the device
      file so the impact is fairly limited and reduces the security of
      some capability and security model based systems down towards
      that of a generic "root owns the box" setup.
      
      Therefore they should require CAP_SYS_RAWIO to prevent an
      elevation of capabilities. The impact of this is fairly minimal
      on most setups because they don't have heavy use of
      capabilities. Those using SELinux, SMACK or AppArmor rules might
      want to consider if their rulesets on the MSR driver could be
      tighter.
      Signed-off-by: NAlan Cox <alan@linux.intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Horses <stable@kernel.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      c903f045
  3. 23 9月, 2012 1 次提交
    • S
      Use get_online_cpus to avoid races involving CPU hotplug · a2db672a
      Silas Boyd-Wickizer 提交于
      If arch/x86/kernel/msr.c is a module, a CPU might offline or online
      between the for_each_online_cpu(i) loop and the call to
      register_hotcpu_notifier in msr_init or the call to
      unregister_hotcpu_notifier in msr_exit. The potential races can lead
      to leaks/duplicates, attempts to destroy non-existant devices, or
      random pointer dereferences.
      
      For example, in msr_init if:
      
              for_each_online_cpu(i) {
                      err = msr_device_create(i);
                      if (err != 0)
                              goto out_class;
              }
              <----- CPU offlines
              register_hotcpu_notifier(&msr_class_cpu_notifier);
      
      and the CPU never onlines before msr_exit, then the module will never
      call msr_device_destroy for the associated CPU.
      
      This fix surrounds for_each_online_cpu and register_hotcpu_notifier or
      unregister_hotcpu_notifier with get_online_cpus+put_online_cpus.
      
      Tested on a VM.
      Signed-off-by: NSilas Boyd-Wickizer <sbw@mit.edu>
      Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      a2db672a
  4. 29 3月, 2012 1 次提交
  5. 04 1月, 2012 1 次提交
  6. 18 11月, 2010 1 次提交
  7. 28 5月, 2010 1 次提交
  8. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  9. 27 1月, 2010 1 次提交
  10. 16 12月, 2009 1 次提交
    • H
      x86, msr/cpuid: Register enough minors for the MSR and CPUID drivers · 0b962d47
      H. Peter Anvin 提交于
      register_chrdev() hardcodes registering 256 minors, presumably to
      avoid breaking old drivers.  However, we need to register enough
      minors so that we have all possible CPUs.
      
      checkpatch warns on this patch, but the patch is correct: NR_CPUS here
      is a static *upper bound* on the *maximum CPU index* (not *number of
      CPUs!*) and that is what we want.
      Reported-and-tested-by: NRuss Anderson <rja@sgi.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NH. Peter Anvin <hpa@zytor.com>
      LKML-Reference: <tip-*@git.kernel.org>
      0b962d47
  11. 15 12月, 2009 1 次提交
    • H
      x86, msr: Remove incorrect, duplicated code in the MSR driver · 494c2ebf
      H. Peter Anvin 提交于
      The MSR driver would compute the values for cpu and c at declaration,
      and then again in the body of the function.  This isn't merely
      redundant, but unsafe, since cpu might not refer to a valid CPU at
      that point.
      
      Remove the unnecessary and dangerous references in the declarations.
      This code now matches the equivalent code in the CPUID driver.
      Signed-off-by: NH. Peter Anvin <hpa@zytor.com>
      494c2ebf
  12. 08 10月, 2009 1 次提交
    • F
      x86, msr: Remove the bkl from msr_open() · d6c30405
      Frederic Weisbecker 提交于
      Remove the big kernel lock from msr_open() as it doesn't protect
      anything there.
      
      The only racy event that can happen here is a concurrent cpu shutdown.
      
      So let's look at what could be racy during/after the above event:
      
      - The cpu_online() check is racy, but the bkl doesn't help about
        that anyway it disables preemption but we may be chcking another
        cpu than the current one.
        Also the cpu can still become offlined between open and read calls.
      
      - The cpu_data(cpu) returns a safe pointer too. It won't be released on
        cpu offlining. But some fields can be changed from
        arch/x86/kernel/smpboot.c:remove_siblinginfo() :
      
      	- phys_proc_id
      	- cpu_core_id
      
        Those are not read from msr_open(). What we are checking is the
        x86_capability that is left untouched on offlining.
      
      So this removal looks safe.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: John Kacur <jkacur@redhat.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Sven-Thorsten Dietrich <sdietrich@suse.de>
      LKML-Reference: <1254944602-7382-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NH. Peter Anvin <hpa@zytor.com>
      d6c30405
  13. 20 9月, 2009 1 次提交
  14. 01 9月, 2009 2 次提交
  15. 16 6月, 2009 1 次提交
  16. 12 1月, 2009 1 次提交
  17. 04 1月, 2009 1 次提交
  18. 17 10月, 2008 1 次提交
  19. 26 8月, 2008 2 次提交
  20. 15 8月, 2008 1 次提交
  21. 22 7月, 2008 1 次提交
  22. 19 5月, 2008 1 次提交
  23. 20 4月, 2008 1 次提交
    • R
      PM: Remove destroy_suspended_device() · b844eba2
      Rafael J. Wysocki 提交于
      After 2.6.24 there was a plan to make the PM core acquire all device
      semaphores during a suspend/hibernation to protect itself from
      concurrent operations involving device objects.  That proved to be
      too heavy-handed and we found a better way to achieve the goal, but
      before it happened, we had introduced the functions
      device_pm_schedule_removal() and destroy_suspended_device() to allow
      drivers to "safely" destroy a suspended device and we had adapted some
      drivers to use them.  Now that these functions are no longer necessary,
      it seems reasonable to remove them and modify their users to use the
      normal device unregistration instead.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b844eba2
  24. 17 4月, 2008 1 次提交
  25. 04 2月, 2008 1 次提交
  26. 02 2月, 2008 1 次提交
    • S
      x86: fix section mismatch warnings when referencing notifiers · c72258c7
      Sam Ravnborg 提交于
      Fix the following warnings:
      WARNING: arch/x86/kernel/built-in.o(.exit.text+0xf8): Section mismatch in reference from the function msr_exit() to the variable .cpuinit.data:msr_class_cpu_notifier
      WARNING: arch/x86/kernel/built-in.o(.exit.text+0x158): Section mismatch in reference from the function cpuid_exit() to the variable .cpuinit.data:cpuid_class_cpu_notifier
      WARNING: arch/x86/kernel/built-in.o(.exit.text+0x171): Section mismatch in reference from the function microcode_exit() to the variable .cpuinit.data:mc_cpu_notifier
      
      In all three cases there were a function annotated __exit
      that referenced a variable annotated __cpuinitdata.
      
      The fix was to replace the annotation of the notifier
      with __refdata to tell modpost that the reference to
      a _cpuinit function in the notifier are OK.
      The unregister call that references the notifier
      variable will simple delete the function pointer
      so there is no problem ignoring the reference.
      
      Note: This looks like another case where __cpuinit
      has been used as replacement for proper use
      of CONFIG_HOTPLUG_CPU to decide what code are used for
      HOTPLUG_CPU.
      Signed-off-by: NSam Ravnborg <sam@ravnborg.org>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      c72258c7
  27. 25 1月, 2008 1 次提交
    • R
      PM: Acquire device locks on suspend · 775b64d2
      Rafael J. Wysocki 提交于
      This patch reorganizes the way suspend and resume notifications are
      sent to drivers.  The major changes are that now the PM core acquires
      every device semaphore before calling the methods, and calls to
      device_add() during suspends will fail, while calls to device_del()
      during suspends will block.
      
      It also provides a way to safely remove a suspended device with the
      help of the PM core, by using the device_pm_schedule_removal() callback
      introduced specifically for this purpose, and updates two drivers (msr
      and cpuid) that need to use it.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      775b64d2
  28. 20 10月, 2007 1 次提交
    • M
      x86: convert cpuinfo_x86 array to a per_cpu array · 92cb7612
      Mike Travis 提交于
      cpu_data is currently an array defined using NR_CPUS.  This means that
      we overallocate since we will rarely really use maximum configured cpus.
      When NR_CPU count is raised to 4096 the size of cpu_data becomes
      3,145,728 bytes.
      
      These changes were adopted from the sparc64 (and ia64) code.  An
      additional field was added to cpuinfo_x86 to be a non-ambiguous cpu
      index.  This corresponds to the index into a cpumask_t as well as the
      per_cpu index.  It's used in various places like show_cpuinfo().
      
      cpu_data is defined to be the boot_cpu_data structure for the NON-SMP
      case.
      Signed-off-by: NMike Travis <travis@sgi.com>
      Acked-by: NChristoph Lameter <clameter@sgi.com>
      Cc: Andi Kleen <ak@suse.de>
      Cc: James Bottomley <James.Bottomley@steeleye.com>
      Cc: Dmitry Torokhov <dtor@mail.ru>
      Cc: "Antonino A. Daplas" <adaplas@pol.net>
      Cc: Mark M. Hoffman <mhoffman@lightlink.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      92cb7612
  29. 19 10月, 2007 2 次提交
  30. 18 10月, 2007 1 次提交
  31. 14 10月, 2007 1 次提交
    • D
      Delete filenames in comments. · 835c34a1
      Dave Jones 提交于
      Since the x86 merge, lots of files that referenced their own filenames
      are no longer correct.  Rather than keep them up to date, just delete
      them, as they add no real value.
      
      Additionally:
      - fix up comment formatting in scx200_32.c
      - Remove a credit from myself in setup_64.c from a time when we had no SCM
      - remove longwinded history from tsc_32.c which can be figured out from
        git.
      Signed-off-by: NDave Jones <davej@redhat.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      835c34a1
  32. 11 10月, 2007 1 次提交
  33. 10 5月, 2007 1 次提交
    • R
      Add suspend-related notifications for CPU hotplug · 8bb78442
      Rafael J. Wysocki 提交于
      Since nonboot CPUs are now disabled after tasks and devices have been
      frozen and the CPU hotplug infrastructure is used for this purpose, we need
      special CPU hotplug notifications that will help the CPU-hotplug-aware
      subsystems distinguish normal CPU hotplug events from CPU hotplug events
      related to a system-wide suspend or resume operation in progress.  This
      patch introduces such notifications and causes them to be used during
      suspend and resume transitions.  It also changes all of the
      CPU-hotplug-aware subsystems to take these notifications into consideration
      (for now they are handled in the same way as the corresponding "normal"
      ones).
      
      [oleg@tv-sign.ru: cleanups]
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: Gautham R Shenoy <ego@in.ibm.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Signed-off-by: NOleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8bb78442
  34. 08 5月, 2007 1 次提交
  35. 13 2月, 2007 2 次提交
  36. 09 12月, 2006 1 次提交