1. 24 Apr, 2011 6 commits
    • Dan Rosenberg's avatar
      [SCSI] pmcraid: reject negative request size · 5f6279da
      Dan Rosenberg authored
      There's a code path in pmcraid that can be reached via device ioctl that
      causes all sorts of ugliness, including heap corruption or triggering
      the OOM killer due to consecutive allocation of large numbers of pages.
      Not especially relevant from a security perspective, since users must
      have CAP_SYS_ADMIN to open the character device.
      
      First, the user can call pmcraid_chr_ioctl() with a type
      PMCRAID_PASSTHROUGH_IOCTL.  A pmcraid_passthrough_ioctl_buffer
      is copied in, and the request_size variable is set to
      buffer->ioarcb.data_transfer_length, which is an arbitrary 32-bit signed
      value provided by the user.
      
      If a negative value is provided here, bad things can happen.  For
      example, pmcraid_build_passthrough_ioadls() is called with this
      request_size, which immediately calls pmcraid_alloc_sglist() with a
      negative size.  The resulting math on allocating a scatter list can
      result in an overflow in the kzalloc() call (if num_elem is 0, the
      sglist will be smaller than expected), or if num_elem is unexpectedly
      large the subsequent loop will call alloc_pages() repeatedly, a high
      number of pages will be allocated and the OOM killer might be invoked.
      
      Prevent this value from being negative in pmcraid_ioctl_passthrough().
      Signed-off-by: default avatarDan Rosenberg <drosenberg@vsecurity.com>
      Cc: stable@kernel.org
      Cc: Anil Ravindranath <anil_ravindranath@pmc-sierra.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      5f6279da
    • James Bottomley's avatar
      [SCSI] put stricter guards on queue dead checks · 86cbfb56
      James Bottomley authored
      SCSI uses request_queue->queuedata == NULL as a signal that the queue
      is dying.  We set this state in the sdev release function.  However,
      this allows a small window where we release the last reference but
      haven't quite got to this stage yet and so something will try to take
      a reference in scsi_request_fn and oops.  It's very rare, but we had a
      report here, so we're pushing this as a bug fix
      
      The actual fix is to set request_queue->queuedata to NULL in
      scsi_remove_device() before we drop the reference.  This causes
      correct automatic rejects from scsi_request_fn as people who hold
      additional references try to submit work and prevents anything from
      getting a new reference to the sdev that way.
      
      Cc: stable@kernel.org
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      86cbfb56
    • Mike Snitzer's avatar
      [SCSI] scsi_dh: fix reference counting in scsi_dh_activate error path · 0b839357
      Mike Snitzer authored
      Commit db422318 ([SCSI] scsi_dh:
      propagate SCSI device deletion) introduced a regression where the device
      reference is not dropped prior to scsi_dh_activate's early return from
      the error path.
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Cc: stable@kernel.org # 2.6.38
      Reviewed-by: default avatarMike Christie <michaelc@cs.wisc.edu>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      0b839357
    • Dan Rosenberg's avatar
      [SCSI] mpt2sas: prevent heap overflows and unchecked reads · a1f74ae8
      Dan Rosenberg authored
      At two points in handling device ioctls via /dev/mpt2ctl, user-supplied
      length values are used to copy data from userspace into heap buffers
      without bounds checking, allowing controllable heap corruption and
      subsequently privilege escalation.
      
      Additionally, user-supplied values are used to determine the size of a
      copy_to_user() as well as the offset into the buffer to be read, with no
      bounds checking, allowing users to read arbitrary kernel memory.
      Signed-off-by: default avatarDan Rosenberg <drosenberg@vsecurity.com>
      Cc: stable@kernel.org
      Acked-by: default avatarEric Moore <eric.moore@lsi.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      a1f74ae8
    • Linus Torvalds's avatar
      Merge branch 'pm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6 · 686c4cbb
      Linus Torvalds authored
      * 'pm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6:
        PM: Add missing syscore_suspend() and syscore_resume() calls
        PM: Fix error code paths executed after failing syscore_suspend()
      686c4cbb
    • Linus Torvalds's avatar
      vfs: get rid of 'struct dcache_hash_bucket' abstraction · b07ad996
      Linus Torvalds authored
      It's a useless abstraction for 'hlist_bl_head', and it doesn't actually
      help anything - quite the reverse.  All the users end up having to know
      about the hlist_bl_head details anyway, using 'struct hlist_bl_node *'
      etc. So it just makes the code look confusing.
      
      And the cost of it is extra '&b->head' syntactic noise, but more
      importantly it spuriously makes the hash table dentry list look
      different from the per-superblock DCACHE_DISCONNECTED dentry list.
      
      As a result, the code ended up using ad-hoc locking for one case and
      special helper functions for what is really another totally identical
      case in the very same function.
      
      Make it all look and work the same.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b07ad996
  2. 22 Apr, 2011 9 commits
    • Linus Torvalds's avatar
      Merge branch 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6 · 0f1d9f78
      Linus Torvalds authored
      * 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6:
        tty/n_gsm: fix bug in CRC calculation for gsm1 mode
        serial/imx: read cts state only after acking cts change irq
        parport_pc.c: correctly release the requested region for the IT887x
      0f1d9f78
    • Andi Kleen's avatar
      SECURITY: Move exec_permission RCU checks into security modules · 8c9e80ed
      Andi Kleen authored
      Right now all RCU walks fall back to reference walk when CONFIG_SECURITY
      is enabled, even though just the standard capability module is active.
      This is because security_inode_exec_permission unconditionally fails
      RCU walks.
      
      Move this decision to the low level security module. This requires
      passing the RCU flags down the security hook. This way at least
      the capability module and a few easy cases in selinux/smack work
      with RCU walks with CONFIG_SECURITY=y
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Acked-by: default avatarEric Paris <eparis@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8c9e80ed
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6 · 8d082f8f
      Linus Torvalds authored
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6:
        ALSA: hda - Fix unused warnings when !SND_HDA_NEEDS_RESUME
        ALSA: hda - Add a fix-up for Acer dmic with ALC271x codec
        ASoC: add a module alias to the FSI driver
        ALSA: emu10k1 - Fix "Music" controls to "Synth" controls in documents
        ARM: s3c2440: gta02; Register dfbmcs320 device for BT audio interface
        ASoC: codecs: JZ4740: Fix OOPS
        ASoC: Fix output PGA enabling in wm_hubs CODECs
        ASoC: sn95031: decorate function with __devexit_p()
        ASoC: SAMSUNG: Fix the inverted clocks handling for pcm driver
        ASoC: sst_platform: Fix lock acquring
        ASoC: fsi: driver safely remove for against irq
        ASoC: fsi: modify vague PM control on probe
        ASoC: fsi: take care in failing case of dai register
        MAINTAINERS: Update Samsung ASoC maintainer's id
        ASoC: WM8903: HP and Line out PGA/mixer DAPM fixes
        ASoC: Set left channel volume update bits for WM8994
        ASoC: fix config error path
        ASoC: check channel mismatch between cpu_dai and codec_dai
        ASoC: Tegra: Suspend/resume support
      8d082f8f
    • Linus Torvalds's avatar
      Merge branch 'perf-fixes-for-linus' of... · 258ba6a5
      Linus Torvalds authored
      Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
      
      * 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
        perf, x86: Update/fix Intel Nehalem cache events
        perf, x86: P4 PMU - Don't forget to clear cpuc->active_mask on overflow
        x86, perf event: Turn off unstructured raw event access to offcore registers
        perf: Support Xeon E7's via the Westmere PMU driver
      258ba6a5
    • Linus Torvalds's avatar
      Merge branch 'irq-fixes-for-linus' of... · d6d61c97
      Linus Torvalds authored
      Merge branch 'irq-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
      
      * 'irq-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
        xtensa: Fixup irq conversion fallout and nmi_count
      d6d61c97
    • Peter Zijlstra's avatar
      perf, x86: Update/fix Intel Nehalem cache events · f4929bd3
      Peter Zijlstra authored
      Change the Nehalem cache events to use retired memory instruction counters
      (similar to Westmere), this greatly improves the provided stats.
      
      Using:
      
      main ()
      {
              int i;
      
              for (i = 0; i < 1000000000; i++) {
                      asm("mov (%%rsp), %%rbx;"
                          "mov %%rbx, (%%rsp);" : : : "rbx");
              }
      }
      
      We find:
      
       $ perf stat --repeat 10 -e instructions:u -e l1-dcache-loads:u -e l1-dcache-stores:u ./loop_1b_loads+stores
        Performance counter stats for './loop_1b_loads+stores' (10 runs):
            4,000,081,056 instructions:u           #      0.000 IPC ( +-   0.000% )
            4,999,502,846 l1-dcache-loads:u          ( +-   0.008% )
            1,000,034,832 l1-dcache-stores:u         ( +-   0.000% )
               1.565184942  seconds time elapsed   ( +-   0.005% )
      
      The 5b is surprising - we'd expect 1b:
      
       $ perf stat --repeat 10 -e instructions:u -e r10b:u -e l1-dcache-stores:u ./loop_1b_loads+stores
        Performance counter stats for './loop_1b_loads+stores' (10 runs):
            4,000,081,054 instructions:u           #      0.000 IPC ( +-   0.000% )
            1,000,021,961 r10b:u                     ( +-   0.000% )
            1,000,030,951 l1-dcache-stores:u         ( +-   0.000% )
               1.565055422  seconds time elapsed   ( +-   0.003% )
      
      Which this patch thus fixes.
      Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Lin Ming <ming.m.lin@intel.com>
      Cc: Cyrill Gorcunov <gorcunov@openvz.org>
      Link: http://lkml.kernel.org/n/tip-q9rtru7b7840tws75xzboapv@git.kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@elte.hu>
      f4929bd3
    • Cyrill Gorcunov's avatar
      perf, x86: P4 PMU - Don't forget to clear cpuc->active_mask on overflow · 1ea5a6af
      Cyrill Gorcunov authored
      It's not enough to simply disable event on overflow the
      cpuc->active_mask should be cleared as well otherwise counter
      may stall in "active" even in real being already disabled (which
      potentially may lead to the situation that user may not use this
      counter further).
      
      Don pointed out that:
      
       " I also noticed this patch fixed some unknown NMIs
         on a P4 when I stressed the box".
      Tested-by: default avatarLin Ming <ming.m.lin@intel.com>
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
      Acked-by: default avatarDon Zickus <dzickus@redhat.com>
      Signed-off-by: default avatarDon Zickus <dzickus@redhat.com>
      Cc: Cyrill Gorcunov <gorcunov@gmail.com>
      Link: http://lkml.kernel.org/r/1303398203-2918-3-git-send-email-dzickus@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@elte.hu>
      1ea5a6af
    • Ingo Molnar's avatar
      x86, perf event: Turn off unstructured raw event access to offcore registers · b52c55c6
      Ingo Molnar authored
      Andi Kleen pointed out that the Intel offcore support patches were merged
      without user-space tool support to the functionality:
      
       |
       | The offcore_msr perf kernel code was merged into 2.6.39-rc*, but the
       | user space bits were not. This made it impossible to set the extra mask
       | and actually do the OFFCORE profiling
       |
      
      Andi submitted a preliminary patch for user-space support, as an
      extension to perf's raw event syntax:
      
       |
       | Some raw events -- like the Intel OFFCORE events -- support additional
       | parameters. These can be appended after a ':'.
       |
       | For example on a multi socket Intel Nehalem:
       |
       |    perf stat -e r1b7:20ff -a sleep 1
       |
       | Profile the OFFCORE_RESPONSE.ANY_REQUEST with event mask REMOTE_DRAM_0
       | that measures any access to DRAM on another socket.
       |
      
      But this kind of usability is absolutely unacceptable - users should not
      be expected to type in magic, CPU and model specific incantations to get
      access to useful hardware functionality.
      
      The proper solution is to expose useful offcore functionality via
      generalized events - that way users do not have to care which specific
      CPU model they are using, they can use the conceptual event and not some
      model specific quirky hexa number.
      
      We already have such generalization in place for CPU cache events,
      and it's all very extensible.
      
      "Offcore" events measure general DRAM access patters along various
      parameters. They are particularly useful in NUMA systems.
      
      We want to support them via generalized DRAM events: either as the
      fourth level of cache (after the last-level cache), or as a separate
      generalization category.
      
      That way user-space support would be very obvious, memory access
      profiling could be done via self-explanatory commands like:
      
        perf record -e dram ./myapp
        perf record -e dram-remote ./myapp
      
      ... to measure DRAM accesses or more expensive cross-node NUMA DRAM
      accesses.
      
      These generalized events would work on all CPUs and architectures that
      have comparable PMU features.
      
      ( Note, these are just examples: actual implementation could have more
        sophistication and more parameter - as long as they center around
        similarly simple usecases. )
      
      Now we do not want to revert *all* of the current offcore bits, as they
      are still somewhat useful for generic last-level-cache events, implemented
      in this commit:
      
        e994d7d2: perf: Fix LLC-* events on Intel Nehalem/Westmere
      
      But we definitely do not yet want to expose the unstructured raw events
      to user-space, until better generalization and usability is implemented
      for these hardware event features.
      
      ( Note: after generalization has been implemented raw offcore events can be
        supported as well: there can always be an odd event that is marginally
        useful but not useful enough to generalize. DRAM profiling is definitely
        *not* such a category so generalization must be done first. )
      
      Furthermore, PERF_TYPE_RAW access to these registers was not intended
      to go upstream without proper support - it was a side-effect of the above
      e994d7d2 commit, not mentioned in the changelog.
      
      As v2.6.39 is nearing release we go for the simplest approach: disable
      the PERF_TYPE_RAW offcore hack for now, before it escapes into a released
      kernel and becomes an ABI.
      
      Once proper structure is implemented for these hardware events and users
      are offered usable solutions we can revisit this issue.
      Reported-by: default avatarAndi Kleen <ak@linux.intel.com>
      Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Link: http://lkml.kernel.org/r/1302658203-4239-1-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarIngo Molnar <mingo@elte.hu>
      b52c55c6
    • Andi Kleen's avatar
      perf: Support Xeon E7's via the Westmere PMU driver · b2508e82
      Andi Kleen authored
      There's a new model number public, 47, for Xeon E7 (aka Westmere EX).
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: a.p.zijlstra@chello.nl
      Link: http://lkml.kernel.org/r/1303429715-10202-1-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarIngo Molnar <mingo@elte.hu>
      b2508e82
  3. 21 Apr, 2011 25 commits