1. 10 Jun, 2013 40 commits
    • Nithin Nayak Sujir's avatar
      tg3: Avoid null pointer dereference in tg3_interrupt in netconsole mode · e6d11ed5
      Nithin Nayak Sujir authored
      [ Upstream commit 9c13cb8b ]
      
      When netconsole is enabled, logging messages generated during tg3_open
      can result in a null pointer dereference for the uninitialized tg3
      status block. Use the irq_sync flag to disable polling in the early
      stages. irq_sync is cleared when the driver is enabling interrupts after
      all initialization is completed.
      Signed-off-by: default avatarNithin Nayak Sujir <nsujir@broadcom.com>
      Signed-off-by: default avatarMichael Chan <mchan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      e6d11ed5
    • Larry Finger's avatar
      b43legacy: Fix crash on unload when firmware not available · 28c684ce
      Larry Finger authored
      commit 2d838bb6 upstream.
      
      When b43legacy is loaded without the firmware being available, a following
      unload generates a kernel NULL pointer dereference BUG as follows:
      
      [  214.330789] BUG: unable to handle kernel NULL pointer dereference at 0000004c
      [  214.330997] IP: [<c104c395>] drain_workqueue+0x15/0x170
      [  214.331179] *pde = 00000000
      [  214.331311] Oops: 0000 [#1] SMP
      [  214.331471] Modules linked in: b43legacy(-) ssb pcmcia mac80211 cfg80211 af_packet mperf arc4 ppdev sr_mod cdrom sg shpchp yenta_socket pcmcia_rsrc pci_hotplug pcmcia_core battery parport_pc parport floppy container ac button edd autofs4 ohci_hcd ehci_hcd usbcore usb_common thermal processor scsi_dh_rdac scsi_dh_hp_sw scsi_dh_emc scsi_dh_alua scsi_dh fan thermal_sys hwmon ata_generic pata_ali libata [last unloaded: cfg80211]
      [  214.333421] Pid: 3639, comm: modprobe Not tainted 3.6.0-rc6-wl+ #163 Source Technology VIC 9921/ALI Based Notebook
      [  214.333580] EIP: 0060:[<c104c395>] EFLAGS: 00010246 CPU: 0
      [  214.333687] EIP is at drain_workqueue+0x15/0x170
      [  214.333788] EAX: c162ac40 EBX: cdfb8360 ECX: 0000002a EDX: 00002a2a
      [  214.333890] ESI: 00000000 EDI: 00000000 EBP: cd767e7c ESP: cd767e5c
      [  214.333957]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
      [  214.333957] CR0: 8005003b CR2: 0000004c CR3: 0c96a000 CR4: 00000090
      [  214.333957] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
      [  214.333957] DR6: ffff0ff0 DR7: 00000400
      [  214.333957] Process modprobe (pid: 3639, ti=cd766000 task=cf802e90 task.ti=cd766000)
      [  214.333957] Stack:
      [  214.333957]  00000292 cd767e74 c12c5e09 00000296 00000296 cdfb8360 cdfb9220 00000000
      [  214.333957]  cd767e90 c104c4fd cdfb8360 cdfb9220 cd682800 cd767ea4 d0c10184 cd682800
      [  214.333957]  cd767ea4 cba31064 cd767eb8 d0867908 cba31064 d087e09c cd96f034 cd767ec4
      [  214.333957] Call Trace:
      [  214.333957]  [<c12c5e09>] ? skb_dequeue+0x49/0x60
      [  214.333957]  [<c104c4fd>] destroy_workqueue+0xd/0x150
      [  214.333957]  [<d0c10184>] ieee80211_unregister_hw+0xc4/0x100 [mac80211]
      [  214.333957]  [<d0867908>] b43legacy_remove+0x78/0x80 [b43legacy]
      [  214.333957]  [<d083654d>] ssb_device_remove+0x1d/0x30 [ssb]
      [  214.333957]  [<c126f15a>] __device_release_driver+0x5a/0xb0
      [  214.333957]  [<c126fb07>] driver_detach+0x87/0x90
      [  214.333957]  [<c126ef4c>] bus_remove_driver+0x6c/0xe0
      [  214.333957]  [<c1270120>] driver_unregister+0x40/0x70
      [  214.333957]  [<d083686b>] ssb_driver_unregister+0xb/0x10 [ssb]
      [  214.333957]  [<d087c488>] b43legacy_exit+0xd/0xf [b43legacy]
      [  214.333957]  [<c1089dde>] sys_delete_module+0x14e/0x2b0
      [  214.333957]  [<c110a4a7>] ? vfs_write+0xf7/0x150
      [  214.333957]  [<c1240050>] ? tty_write_lock+0x50/0x50
      [  214.333957]  [<c110a6f8>] ? sys_write+0x38/0x70
      [  214.333957]  [<c1397c55>] syscall_call+0x7/0xb
      [  214.333957] Code: bc 27 00 00 00 00 a1 74 61 56 c1 55 89 e5 e8 a3 fc ff ff 5d c3 90 55 89 e5 57 56 89 c6 53 b8 40 ac 62 c1 83 ec 14 e8 bb b7 34 00 <8b> 46 4c 8d 50 01 85 c0 89 56 4c 75 03 83 0e 40 80 05 40 ac 62
      [  214.333957] EIP: [<c104c395>] drain_workqueue+0x15/0x170 SS:ESP 0068:cd767e5c
      [  214.333957] CR2: 000000000000004c
      [  214.341110] ---[ end trace c7e90ec026d875a6 ]---Index: wireless-testing/drivers/net/wireless/b43legacy/main.c
      
      The problem is fixed by making certain that the ucode pointer is not NULL
      before deregistering the driver in mac80211.
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      28c684ce
    • Francois Romieu's avatar
      r8169: incorrect identifier for a 8168dp · 5d977bde
      Francois Romieu authored
      Merge error.
      
      See CFG_METHOD_8 (0x3c800000 + 0x00300000) since version 8.002.00
      of Realtek's driver.
      Signed-off-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
      Cc: Hayes <hayeswang@realtek.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      (cherry picked from commit 17c99297)
      Cc: Thomas Bork <tom@eisfair.net>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      5d977bde
    • Lennart Sorensen's avatar
      r8169: Add support for D-Link 530T rev C1 (Kernel Bug 38862) · fa9652ba
      Lennart Sorensen authored
      [ Upstream commit 93a3aa25 ]
      
      The D-Link DGE-530T rev C1 is a re-badged Realtek 8169 named DLG10028C,
      unlike the previous revisions which were skge based.  It is probably
      the same as the discontinued DGE-528T (0x4300) other than the PCI ID.
      
      The PCI ID is 0x1186:0x4302.
      
      Adding it to r8169.c where 0x1186:0x4300 is already found makes the card
      be detected and work.
      
      This fixes https://bugzilla.kernel.org/show_bug.cgi?id=38862Signed-off-by: default avatarLen Sorensen <lsorense@csclub.uwaterloo.ca>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      (cherry picked from commit 7106159f)
      Cc: Thomas Bork <tom@eisfair.net>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      fa9652ba
    • Timo Teräs's avatar
      r8169: remove the obsolete and incorrect AMD workaround · a0a6cfcd
      Timo Teräs authored
      [ Upstream commit 5d0feaff ]
      
      This was introduced in commit 6dccd16b "r8169: merge with version
      6.001.00 of Realtek's r8169 driver". I did not find the version
      6.001.00 online, but in 6.002.00 or any later r8169 from Realtek
      this hunk is no longer present.
      
      Also commit 05af2142 "r8169: fix Ethernet Hangup for RTL8110SC
      rev d" claims to have fixed this issue otherwise.
      
      The magic compare mask of 0xfffe000 is dubious as it masks
      parts of the Reserved part, and parts of the VLAN tag. But this
      does not make much sense as the VLAN tag parts are perfectly
      valid there. In matter of fact this seems to be triggered with
      any VLAN tagged packet as RxVlanTag bit is matched. I would
      suspect 0xfffe0000 was intended to test reserved part only.
      
      Finally, this hunk is evil as it can cause more packets to be
      handled than what was NAPI quota causing net/core/dev.c:
      net_rx_action(): WARN_ON_ONCE(work > weight) to trigger, and
      mess up the NAPI state causing device to hang.
      
      As result, any system using VLANs and having high receive
      traffic (so that NAPI poll budget limits rtl_rx) would result
      in device hang.
      Signed-off-by: default avatarTimo Teräs <timo.teras@iki.fi>
      Acked-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      (cherry picked from commit 3a42cce9)
      Cc: Thomas Bork <tom@eisfair.net>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      a0a6cfcd
    • Hayes Wang's avatar
      r8169: correct settings of rtl8102e. · 3e472a9a
      Hayes Wang authored
      Adjust and remove certain settings of RTL8102E which are for previous chips.
      Signed-off-by: default avatarHayes Wang <hayeswang@realtek.com>
      Acked-off-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
      (cherry picked from commit d24e9aaf)
      Cc: Thomas Bork <tom@eisfair.net>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      3e472a9a
    • Mathias Krause's avatar
      xfrm_user: return error pointer instead of NULL #2 · 95f86856
      Mathias Krause authored
      commit c2546372 upstream.
      
      When dump_one_policy() returns an error, e.g. because of a too small
      buffer to dump the whole xfrm policy, xfrm_policy_netlink() returns
      NULL instead of an error pointer. But its caller expects an error
      pointer and therefore continues to operate on a NULL skbuff.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Acked-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      95f86856
    • Mathias Krause's avatar
      xfrm_user: return error pointer instead of NULL · 30d5e9d8
      Mathias Krause authored
      commit 864745d2 upstream.
      
      When dump_one_state() returns an error, e.g. because of a too small
      buffer to dump the whole xfrm state, xfrm_state_netlink() returns NULL
      instead of an error pointer. But its callers expect an error pointer
      and therefore continue to operate on a NULL skbuff.
      
      This could lead to a privilege escalation (execution of user code in
      kernel context) if the attacker has CAP_NET_ADMIN and is able to map
      address 0.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Acked-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      30d5e9d8
    • Mathias Krause's avatar
      xfrm_user: fix info leak in copy_to_user_tmpl() · 89cee197
      Mathias Krause authored
      [ Upstream commit 1f86840f ]
      
      The memory used for the template copy is a local stack variable. As
      struct xfrm_user_tmpl contains multiple holes added by the compiler for
      alignment, not initializing the memory will lead to leaking stack bytes
      to userland. Add an explicit memset(0) to avoid the info leak.
      
      Initial version of the patch by Brad Spengler.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Brad Spengler <spender@grsecurity.net>
      Acked-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      89cee197
    • Mathias Krause's avatar
      xfrm_user: fix info leak in copy_to_user_policy() · ab7dec14
      Mathias Krause authored
      [ Upstream commit 7b789836 ]
      
      The memory reserved to dump the xfrm policy includes multiple padding
      bytes added by the compiler for alignment (padding bytes in struct
      xfrm_selector and struct xfrm_userpolicy_info). Add an explicit
      memset(0) before filling the buffer to avoid the heap info leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Acked-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      ab7dec14
    • Mathias Krause's avatar
      xfrm_user: fix info leak in copy_to_user_state() · d6927c1e
      Mathias Krause authored
      [ Upstream commit f778a636 ]
      
      The memory reserved to dump the xfrm state includes the padding bytes of
      struct xfrm_usersa_info added by the compiler for alignment (7 for
      amd64, 3 for i386). Add an explicit memset(0) before filling the buffer
      to avoid the info leak.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Acked-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      d6927c1e
    • Jussi Kivilinna's avatar
      crypto: cryptd - disable softirqs in cryptd_queue_worker to prevent data corruption · e760d49b
      Jussi Kivilinna authored
      commit 9efade1b upstream.
      
      cryptd_queue_worker attempts to prevent simultaneous accesses to crypto
      workqueue by cryptd_enqueue_request using preempt_disable/preempt_enable.
      However cryptd_enqueue_request might be called from softirq context,
      so add local_bh_disable/local_bh_enable to prevent data corruption and
      panics.
      
      Bug report at http://marc.info/?l=linux-crypto-vger&m=134858649616319&w=2
      
      v2:
       - Disable software interrupts instead of hardware interrupts
      Reported-by: default avatarGurucharan Shetty <gurucharan.shetty@gmail.com>
      Signed-off-by: default avatarJussi Kivilinna <jussi.kivilinna@mbnet.fi>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      e760d49b
    • David Howells's avatar
      keys: fix race with concurrent install_user_keyrings() · 554da46d
      David Howells authored
      commit 0da9dfdd upstream.
      
      This fixes CVE-2013-1792.
      
      There is a race in install_user_keyrings() that can cause a NULL pointer
      dereference when called concurrently for the same user if the uid and
      uid-session keyrings are not yet created.  It might be possible for an
      unprivileged user to trigger this by calling keyctl() from userspace in
      parallel immediately after logging in.
      
      Assume that we have two threads both executing lookup_user_key(), both
      looking for KEY_SPEC_USER_SESSION_KEYRING.
      
      	THREAD A			THREAD B
      	===============================	===============================
      					==>call install_user_keyrings();
      	if (!cred->user->session_keyring)
      	==>call install_user_keyrings()
      					...
      					user->uid_keyring = uid_keyring;
      	if (user->uid_keyring)
      		return 0;
      	<==
      	key = cred->user->session_keyring [== NULL]
      					user->session_keyring = session_keyring;
      	atomic_inc(&key->usage); [oops]
      
      At the point thread A dereferences cred->user->session_keyring, thread B
      hasn't updated user->session_keyring yet, but thread A assumes it is
      populated because install_user_keyrings() returned ok.
      
      The race window is really small but can be exploited if, for example,
      thread B is interrupted or preempted after initializing uid_keyring, but
      before doing setting session_keyring.
      
      This couldn't be reproduced on a stock kernel.  However, after placing
      systemtap probe on 'user->session_keyring = session_keyring;' that
      introduced some delay, the kernel could be crashed reliably.
      
      Fix this by checking both pointers before deciding whether to return.
      Alternatively, the test could be done away with entirely as it is checked
      inside the mutex - but since the mutex is global, that may not be the best
      way.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reported-by: default avatarMateusz Guzik <mguzik@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarJames Morris <james.l.morris@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      554da46d
    • Eddie Wai's avatar
      SCSI: bnx2i: Fixed NULL ptr deference for 1G bnx2 Linux iSCSI offload · 4d9de348
      Eddie Wai authored
      commit d6532207 upstream.
      
      This patch fixes the following kernel panic invoked by uninitialized fields
      in the chip initialization for the 1G bnx2 iSCSI offload.
      
      One of the bits in the chip initialization is being used by the latest
      firmware to control overflow packets.  When this control bit gets enabled
      erroneously, it would ultimately result in a bad packet placement which would
      cause the bnx2 driver to dereference a NULL ptr in the placement handler.
      
      This can happen under certain stress I/O environment under the Linux
      iSCSI offload operation.
      
      This change only affects Broadcom's 5709 chipset.
      
      Unable to handle kernel NULL pointer dereference at 0000000000000008 RIP:
       [<ffffffff881f0e7d>] :bnx2:bnx2_poll_work+0xd0d/0x13c5
      Pid: 0, comm: swapper Tainted: G     ---- 2.6.18-333.el5debug #2
      RIP: 0010:[<ffffffff881f0e7d>]  [<ffffffff881f0e7d>] :bnx2:bnx2_poll_work+0xd0d/0x13c5
      RSP: 0018:ffff8101b575bd50  EFLAGS: 00010216
      RAX: 0000000000000005 RBX: ffff81007c5fb180 RCX: 0000000000000000
      RDX: 0000000000000ffc RSI: 00000000817e8000 RDI: 0000000000000220
      RBP: ffff81015bbd7ec0 R08: ffff8100817e9000 R09: 0000000000000000
      R10: ffff81007c5fb180 R11: 00000000000000c8 R12: 000000007a25a010
      R13: 0000000000000000 R14: 0000000000000005 R15: ffff810159f80558
      FS:  0000000000000000(0000) GS:ffff8101afebc240(0000) knlGS:0000000000000000
      CS:  0010 DS: 0018 ES: 0018 CR0: 000000008005003b
      CR2: 0000000000000008 CR3: 0000000000201000 CR4: 00000000000006a0
      Process swapper (pid: 0, threadinfo ffff8101b5754000, task ffff8101afebd820)
      Stack:  000000000000000b ffff810159f80000 0000000000000040 ffff810159f80520
       ffff810159f80500 00cf00cf8008e84b ffffc200100939e0 ffff810009035b20
       0000502900000000 000000be00000001 ffff8100817e7810 00d08101b575bea8
      Call Trace:
       <IRQ>  [<ffffffff8008e0d0>] show_schedstat+0x1c2/0x25b
       [<ffffffff881f1886>] :bnx2:bnx2_poll+0xf6/0x231
       [<ffffffff8000c9b9>] net_rx_action+0xac/0x1b1
       [<ffffffff800125a0>] __do_softirq+0x89/0x133
       [<ffffffff8005e30c>] call_softirq+0x1c/0x28
       [<ffffffff8006d5de>] do_softirq+0x2c/0x7d
       [<ffffffff8006d46e>] do_IRQ+0xee/0xf7
       [<ffffffff8005d625>] ret_from_intr+0x0/0xa
       <EOI>  [<ffffffff801a5780>] acpi_processor_idle_simple+0x1c5/0x341
       [<ffffffff801a573d>] acpi_processor_idle_simple+0x182/0x341
       [<ffffffff801a55bb>] acpi_processor_idle_simple+0x0/0x341
       [<ffffffff80049560>] cpu_idle+0x95/0xb8
       [<ffffffff80078b1c>] start_secondary+0x479/0x488
      Signed-off-by: default avatarEddie Wai <eddie.wai@broadcom.com>
      Reviewed-by: default avatarMike Christie <michaelc@cs.wisc.edu>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      4d9de348
    • James Bottomley's avatar
      fix crash in scsi_dispatch_cmd() · 34cee3a5
      James Bottomley authored
      USB surprise removal of sr is triggering an oops in
      scsi_dispatch_command().  What seems to be happening is that USB is
      hanging on to a queue reference until the last close of the upper
      device, so the crash is caused by surprise remove of a mounted CD
      followed by attempted unmount.
      
      The problem is that USB doesn't issue its final commands as part of
      the SCSI teardown path, but on last close when the block queue is long
      gone.  The long term fix is probably to make sr do the teardown in the
      same way as sd (so remove all the lower bits on ejection, but keep the
      upper disk alive until last close of user space).  However, the
      current oops can be simply fixed by not allowing any commands to be
      sent to a dead queue.
      
      Cc: stable@kernel.org
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      (cherry picked from commit bfe159a5)
      Cc: Thomas Bork <tom@eisfair.net>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      34cee3a5
    • Peter Korsgaard's avatar
      scsi: use __uX types for headers exported to user space · c6203cd4
      Peter Korsgaard authored
      Commit 9e4f5e29 ("FC Pass Thru support") exported a number of header files
      in include/scsi to user space, but didn't change the uX types to the
      userspace-compatible __uX types.  Without that you'll get compile errors
      when including them - E.G.:
      
      include/scsi/scsi.h:145: error: expected specifier-qualifier-list before `u8'
      Signed-off-by: default avatarPeter Korsgaard <jacmet@sunsite.dk>
      Cc: Boaz Harrosh <bharrosh@panasas.com>
      Cc: James Smart <james.smart@emulex.com>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      (cherry picked from commit 083c8c1e)
      Cc: Thomas Bork <tom@eisfair.net>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      c6203cd4
    • Jan Kara's avatar
      scsi: Silence unnecessary warnings about ioctl to partition · 9eb21860
      Jan Kara authored
      commit 6d935928 upstream.
      
      Sometimes, warnings about ioctls to partition happen often enough that they
      form majority of the warnings in the kernel log and users complain. In some
      cases warnings are about ioctls such as SG_IO so it's not good to get rid of
      the warnings completely as they can ease debugging of userspace problems
      when ioctl is refused.
      
      Since I have seen warnings from lots of commands, including some proprietary
      userspace applications, I don't think disallowing the ioctls for processes
      with CAP_SYS_RAWIO will happen in the near future if ever. So lets just
      stop warning for processes with CAP_SYS_RAWIO for which ioctl is allowed.
      
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: James Bottomley <JBottomley@parallels.com>
      CC: linux-scsi@vger.kernel.org
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      [bwh: Backported to 3.2: use ENOTTY, not ENOIOCTLCMD]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      (cherry picked from commit f45c9a6e)
      Cc: Thomas Bork <tom@eisfair.net>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      9eb21860
    • Xiaotian Feng's avatar
      libata: fix Null pointer dereference on disk error · c398e000
      Xiaotian Feng authored
      commit 26cd4d65 upstream.
      
      Following oops were observed when disk error happened:
      
      [ 4272.896937] sd 0:0:0:0: [sda] Unhandled error code
      [ 4272.896939] sd 0:0:0:0: [sda] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
      [ 4272.896942] sd 0:0:0:0: [sda] CDB: Read(10): 28 00 00 5a de a7 00 00 08 00
      [ 4272.896951] end_request: I/O error, dev sda, sector 5955239
      [ 4291.574947] BUG: unable to handle kernel NULL pointer dereference at (null)
      [ 4291.658305] IP: [] ahci_activity_show+0x1/0x40
      [ 4291.730090] PGD 76dbbc067 PUD 6c4fba067 PMD 0
      [ 4291.783408] Oops: 0000 [#1] SMP
      [ 4291.822100] last sysfs file: /sys/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/sw_activity
      [ 4291.934235] CPU 9
      [ 4291.958301] Pid: 27942, comm: hwinfo ......
      
      ata_scsi_find_dev could return NULL, so ata_scsi_activity_{show,store} should check if atadev is NULL.
      Signed-off-by: default avatarXiaotian Feng <dannyfeng@tencent.com>
      Cc: James Bottomley <JBottomley@Parallels.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      c398e000
    • Malcolm Priestley's avatar
      staging: vt6656: [BUG] out of bound array reference in RFbSetPower. · 3d4329e7
      Malcolm Priestley authored
      commit ab1dd996 upstream.
      
      Calling RFbSetPower with uCH zero value will cause out of bound array reference.
      
      This causes 64 bit kernels to oops on boot.
      
      Note: Driver does not function on 64 bit kernels and should be
      blacklisted on them.
      Signed-off-by: default avatarMalcolm Priestley <tvboxspy@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      3d4329e7
    • Ian Abbott's avatar
      staging: comedi: das08: Correct AO output for das08jr-16-ao · cb4d9e9e
      Ian Abbott authored
      commit 61ed59ed upstream.
      
      Don't zero out bits 15..12 of the data value in `das08jr_ao_winsn()` as
      that knobbles the upper three-quarters of the output range for the
      'das08jr-16-ao' board.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      cb4d9e9e
    • Ian Abbott's avatar
      staging: comedi: check s->async for poll(), read() and write() · 57d87ddb
      Ian Abbott authored
      commit cc400e18 upstream.
      
      Some low-level comedi drivers (incorrectly) point `dev->read_subdev` or
      `dev->write_subdev` to a subdevice that does not support asynchronous
      commands.  Comedi's poll(), read() and write() file operation handlers
      assume these subdevices do support asynchronous commands.  In
      particular, they assume `s->async` is valid (where `s` points to the
      read or write subdevice), which it won't be if it has been set
      incorrectly.  This can lead to a NULL pointer dereference.
      
      Check `s->async` is non-NULL in `comedi_poll()`, `comedi_read()` and
      `comedi_write()` to avoid the bug.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      57d87ddb
    • Ian Abbott's avatar
      staging: comedi: don't dereference user memory for INSN_INTTRIG · d20405f5
      Ian Abbott authored
      commit 5d06e3df upstream.
      
      `parse_insn()` is dereferencing the user-space pointer `insn->data`
      directly when handling the `INSN_INTTRIG` comedi instruction.  It
      shouldn't be using `insn->data` at all; it should be using the separate
      `data` pointer passed to the function.  Fix it.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      d20405f5
    • Ian Abbott's avatar
      staging: comedi: jr3_pci: fix iomem dereference · 3b436bd9
      Ian Abbott authored
      commit e1878957 upstream.
      
      Correct a direct dereference of I/O memory to use an appropriate I/O
      memory access function.  Note that the pointer being dereferenced is not
      currently tagged with `__iomem` but I plan to correct that for 3.7.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      3b436bd9
    • Ian Abbott's avatar
      staging: comedi: s626: don't dereference insn->data · 61d9db07
      Ian Abbott authored
      commit b655c2c4 upstream.
      
      `s626_enc_insn_config()` is incorrectly dereferencing `insn->data` which
      is a pointer to user memory.  It should be dereferencing the separate
      `data` parameter that points to a copy of the data in kernel memory.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      61d9db07
    • Ian Abbott's avatar
      staging: comedi: fix memory leak for saved channel list · 09f6f2bb
      Ian Abbott authored
      commit c8cad4c8 upstream.
      
      When `do_cmd_ioctl()` allocates memory for the kernel copy of a channel
      list, it frees any previously allocated channel list in
      `async->cmd.chanlist` and replaces it with the new one.  However, if the
      device is ever removed (or "detached") the cleanup code in
      `cleanup_device()` in "drivers.c" does not free this memory so it is
      lost.
      
      A sensible place to free the kernel copy of the channel list is in
      `do_become_nonbusy()` as at that point the comedi asynchronous command
      associated with the channel list is no longer valid.  Free the channel
      list in `do_become_nonbusy()` instead of `do_cmd_ioctl()` and clear the
      pointer to prevent it being freed more than once.
      
      Note that `cleanup_device()` could be called at an inappropriate time
      while the comedi device is open, but that's a separate bug not related
      to this this patch.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      09f6f2bb
    • Ian Abbott's avatar
      staging: comedi: comedi_test: fix race when cancelling command · 52b64ec2
      Ian Abbott authored
      commit c0729eee upstream.
      
      Éric Piel reported a kernel oops in the "comedi_test" module.  It was a
      NULL pointer dereference within `waveform_ai_interrupt()` (actually a
      timer function) that sometimes occurred when a running asynchronous
      command is cancelled (either by the `COMEDI_CANCEL` ioctl or by closing
      the device file).
      
      This seems to be a race between the caller of `waveform_ai_cancel()`
      which on return from that function goes and tears down the running
      command, and the timer function which uses the command.  In particular,
      `async->cmd.chanlist` gets freed (and the pointer set to NULL) by
      `do_become_nonbusy()` in "comedi_fops.c" but a previously scheduled
      `waveform_ai_interrupt()` timer function will dereference that pointer
      regardless, leading to the oops.
      
      Fix it by replacing the `del_timer()` call in `waveform_ai_cancel()`
      with `del_timer_sync()`.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Reported-by: default avatarÉric Piel <piel@delmic.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      52b64ec2
    • Ian Abbott's avatar
      staging: comedi: ni_labpc: set up command4 register *after* command3 · deb76af6
      Ian Abbott authored
      Commit 22056e2b upstream.
      
      Tuomas <tvainikk _at_ gmail _dot_ com> reported problems getting
      meaningful output from a Lab-PC+ in differential mode for AI cmds, but
      AI insn reads gave correct readings.  He tracked it down to two
      problems, one of which is addressed by this patch.
      
      It seems that writing to the command3 register after writing to the
      command4 register in `labpc_ai_cmd()` messes up the differential
      reference bit setting in the command4 register.  Set up the command4
      register after the command3 register (as in `labpc_ai_rinsn()`) to avoid
      the problem.
      
      Thanks to Tuomas for suggesting the fix.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      deb76af6
    • Ian Abbott's avatar
      staging: comedi: ni_labpc: correct differential channel sequence for AI commands · 0bada243
      Ian Abbott authored
      Commit 4c4bc25d upstream.
      
      Tuomas <tvainikk _at_ gmail _dot_ com> reported problems getting
      meaningful output from a Lab-PC+ in differential mode for AI cmds, but
      AI insn reads gave correct readings.  He tracked it down to two
      problems, one of which is addressed by this patch.
      
      It seems the setting of the channel bits for particular scanning modes
      was incorrect for differential mode.  (Only half the number of channels
      are available in differential mode; comedi refers to them as channels 0,
      1, 2 and 3, but the hardware documentation refers to them as channels 0,
      2, 4 and 6.)  In differential mode, the setting of the channel enable
      bits in the command1 register should depend on whether the scan enable
      bit is set.  Effectively, we need to double the comedi channel number
      when the scan enable bit is not set in differential mode.  The scan
      enable bit gets set when the AI scan mode is `MODE_MULT_CHAN_UP` or
      `MODE_MULT_CHAN_DOWN`, and gets cleared when the AI scan mode is
      `MODE_SINGLE_CHAN` or `MODE_SINGLE_CHAN_INTERVAL`.  The existing test
      for whether the comedi channel number needs to be doubled in
      differential mode is incorrect in `labpc_ai_cmd()`.  This patch corrects
      the test.
      
      Thanks to Tuomas for suggesting the fix.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      0bada243
    • Marcin Jurkowski's avatar
      w1: fix oops when w1_search is called from netlink connector · 245f69a0
      Marcin Jurkowski authored
      commit 9d1817ca upstream.
      
      On Sat, Mar 02, 2013 at 10:45:10AM +0100, Sven Geggus wrote:
      > This is the bad commit I found doing git bisect:
      > 04f482fa is the first bad commit
      > commit 04f482fa
      > Author: Patrick McHardy <kaber@trash.net>
      > Date:   Mon Mar 28 08:39:36 2011 +0000
      
      Good job. I was too lazy to bisect for bad commit;)
      
      Reading the code I found problematic kthread_should_stop call from netlink
      connector which causes the oops. After applying a patch, I've been testing
      owfs+w1 setup for nearly two days and it seems to work very reliable (no
      hangs, no memleaks etc).
      More detailed description and possible fix is given below:
      
      Function w1_search can be called from either kthread or netlink callback.
      While the former works fine, the latter causes oops due to kthread_should_stop
      invocation.
      
      This patch adds a check if w1_search is serving netlink command, skipping
      kthread_should_stop invocation if so.
      Signed-off-by: default avatarMarcin Jurkowski <marcin1j@gmail.com>
      Acked-by: default avatarEvgeniy Polyakov <zbr@ioremap.net>
      Cc: Josh Boyer <jwboyer@gmail.com>
      Tested-by: default avatarSven Geggus <lists@fuchsschwanzdomain.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      245f69a0
    • Chen Gang's avatar
      drivers/char/ipmi: memcpy, need additional 2 bytes to avoid memory overflow · 9eeeda58
      Chen Gang authored
      commit a5f2b3d6 upstream.
      
      When calling memcpy, read_data and write_data need additional 2 bytes.
      
        write_data:
          for checking:  "if (size > IPMI_MAX_MSG_LENGTH)"
          for operating: "memcpy(bt->write_data + 3, data + 1, size - 1)"
      
        read_data:
          for checking:  "if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH)"
          for operating: "memcpy(data + 2, bt->read_data + 4, msg_len - 2)"
      Signed-off-by: default avatarChen Gang <gang.chen@asianux.com>
      Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      9eeeda58
    • Jiri Slaby's avatar
      serial: 8250, increase PASS_LIMIT · d9cbbc3f
      Jiri Slaby authored
      With virtual machines like qemu, it's pretty common to see "too much
      work for irq4" messages nowadays. This happens when a bunch of output
      is printed on the emulated serial console. This is caused by too low
      PASS_LIMIT. When ISR loops more than the limit, it spits the message.
      
      I've been using a kernel with doubled the limit and I couldn't see no
      problems. Maybe it's time to get rid of the message now?
      
      [2.6.32: background info from Ram Gupta]
      
      > I need a patch for serial driver that increases PASS_LIMIT merged in
      > 3.1. I am using 2.6.32 kernel which experiences kernel panic
      > occasionally. It will be great if you can backport to 2.6.32 and 3.0
      > kernel. The commit ID is e7328ae1  serial: 8250, increase PASS_LIMIT
      Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
      Cc: Alan Cox <alan@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      (cherry picked from commit e7328ae1)
      Cc: Ram Gupta <ram.gupta5@gmail.com>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      d9cbbc3f
    • Al Viro's avatar
      PARISC: fix user-triggerable panic on parisc · 0f6bacee
      Al Viro authored
      commit 441a179d upstream.
      
      int sys32_rt_sigprocmask(int how, compat_sigset_t __user *set, compat_sigset_t __user *oset,
                                          unsigned int sigsetsize)
      {
              sigset_t old_set, new_set;
              int ret;
      
              if (set && get_sigset32(set, &new_set, sigsetsize))
      
      ...
      static int
      get_sigset32(compat_sigset_t __user *up, sigset_t *set, size_t sz)
      {
              compat_sigset_t s;
              int r;
      
              if (sz != sizeof *set) panic("put_sigset32()");
      
      In other words, rt_sigprocmask(69, (void *)69, 69) done by 32bit process
      will promptly panic the box.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      0f6bacee
    • Jay Estabrook's avatar
      alpha: Add irongate_io to PCI bus resources · 05cd028a
      Jay Estabrook authored
      commit aa8b4be3 upstream.
      
      Fixes a NULL pointer dereference at boot on UP1500.
      Reviewed-and-Tested-by: default avatarMatt Turner <mattst88@gmail.com>
      Signed-off-by: default avatarJay Estabrook <jay.estabrook@gmail.com>
      Signed-off-by: default avatarMatt Turner <mattst88@gmail.com>
      Signed-off-by: default avatarMichael Cree <mcree@orcon.net.nz>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      05cd028a
    • Konrad Rzeszutek Wilk's avatar
      ACPI / cpuidle: Fix NULL pointer issues when cpuidle is disabled · 711a06c6
      Konrad Rzeszutek Wilk authored
      commit b88a634a upstream.
      
      If cpuidle is disabled, that means that:
      
      	per_cpu(acpi_cpuidle_device, pr->id)
      
      is set to NULL as the acpi_processor_power_init ends up failing at
      
      	 retval = cpuidle_register_driver(&acpi_idle_driver)
      
      (in acpi_processor_power_init) and never sets the per_cpu idle
      device.  So when acpi_processor_hotplug on CPU online notification
      tries to reference said device it crashes:
      
      cpu 3 spinlock event irq 62
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000004
      IP: [<ffffffff81381013>] acpi_processor_setup_cpuidle_cx+0x3f/0x105
      PGD a259b067 PUD ab38b067 PMD 0
      Oops: 0002 [#1] SMP
      odules linked in: dm_multipath dm_mod xen_evtchn iscsi_boot_sysfs iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi libcrc32c crc32c nouveau mxm_wmi wmi radeon ttm sg sr_mod sd_mod cdrom ata_generic ata_piix libata crc32c_intel scsi_mod atl1c i915 fbcon tileblit font bitblit softcursor drm_kms_helper video xen_blkfront xen_netfront fb_sys_fops sysimgblt sysfillrect syscopyarea xenfs xen_privcmd mperf
      CPU 1
      Pid: 3047, comm: bash Not tainted 3.8.0-rc3upstream-00250-g165c029 #1 MSI MS-7680/H61M-P23 (MS-7680)
      RIP: e030:[<ffffffff81381013>]  [<ffffffff81381013>] acpi_processor_setup_cpuidle_cx+0x3f/0x105
      RSP: e02b:ffff88001742dca8  EFLAGS: 00010202
      RAX: 0000000000010be9 RBX: ffff8800a0a61800 RCX: ffff880105380000
      RDX: 0000000000000003 RSI: 0000000000000200 RDI: ffff8800a0a61800
      RBP: ffff88001742dce8 R08: ffffffff81812360 R09: 0000000000000200
      R10: aaaaaaaaaaaaaaaa R11: 0000000000000001 R12: ffff8800a0a61800
      R13: 00000000ffffff01 R14: 0000000000000000 R15: ffffffff81a907a0
      FS:  00007fd6942f7700(0000) GS:ffff880105280000(0000) knlGS:0000000000000000
      CS:  e033 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000004 CR3: 00000000a6773000 CR4: 0000000000042660
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Process bash (pid: 3047, threadinfo ffff88001742c000, task ffff880017944000)
      Stack:
       0000000000000150 ffff880100f59e00 ffff88001742dcd8 ffff8800a0a61800
       0000000000000000 00000000ffffff01 0000000000000000 ffffffff81a907a0
       ffff88001742dd18 ffffffff813815b1 ffff88001742dd08 ffffffff810ae336
      Call Trace:
       [<ffffffff813815b1>] acpi_processor_hotplug+0x7c/0x9f
       [<ffffffff810ae336>] ? schedule_delayed_work_on+0x16/0x20
       [<ffffffff8137ee8f>] acpi_cpu_soft_notify+0x90/0xca
       [<ffffffff8166023d>] notifier_call_chain+0x4d/0x70
       [<ffffffff810bc369>] __raw_notifier_call_chain+0x9/0x10
       [<ffffffff81094a4b>] __cpu_notify+0x1b/0x30
       [<ffffffff81652cf7>] _cpu_up+0x103/0x14b
       [<ffffffff81652e18>] cpu_up+0xd9/0xec
       [<ffffffff8164a254>] store_online+0x94/0xd0
       [<ffffffff814122fb>] dev_attr_store+0x1b/0x20
       [<ffffffff81216404>] sysfs_write_file+0xf4/0x170
      
      This patch fixes it.
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      711a06c6
    • Andi Kleen's avatar
      MCE: Fix vm86 handling for 32bit mce handler · a4d30bc1
      Andi Kleen authored
      commit a129a7c8 upstream.
      
      When running on 32bit the mce handler could misinterpret
      vm86 mode as ring 0. This can affect whether it does recovery
      or not; it was possible to panic when recovery was actually
      possible.
      
      Fix this by always forcing vm86 to look like ring 3.
      
      [ Backport to 3.0 notes:
      Things changed there slightly:
         - move mce_get_rip() up. It fills up m->cs and m->ip values which
           are evaluated in mce_severity(). Therefore move it up right before
           the mce_severity call. This seem to be another bug in 3.0?
         - Place the backport (fix m->cs in V86 case) to where m->cs gets
           filled which is mce_get_rip() in 3.0
      ]
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarThomas Renninger <trenn@suse.de>
      Reviewed-by: default avatarTony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      a4d30bc1
    • Petr Matousek's avatar
      KVM: x86: invalid opcode oops on SET_SREGS with OSXSAVE bit set (CVE-2012-4461) · 228b7542
      Petr Matousek authored
      commit 6d1068b3 upstream.
      
      On hosts without the XSAVE support unprivileged local user can trigger
      oops similar to the one below by setting X86_CR4_OSXSAVE bit in guest
      cr4 register using KVM_SET_SREGS ioctl and later issuing KVM_RUN
      ioctl.
      
      invalid opcode: 0000 [#2] SMP
      Modules linked in: tun ip6table_filter ip6_tables ebtable_nat ebtables
      ...
      Pid: 24935, comm: zoog_kvm_monito Tainted: G      D      3.2.0-3-686-pae
      EIP: 0060:[<f8b9550c>] EFLAGS: 00210246 CPU: 0
      EIP is at kvm_arch_vcpu_ioctl_run+0x92a/0xd13 [kvm]
      EAX: 00000001 EBX: 000f387e ECX: 00000000 EDX: 00000000
      ESI: 00000000 EDI: 00000000 EBP: ef5a0060 ESP: d7c63e70
       DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
      Process zoog_kvm_monito (pid: 24935, ti=d7c62000 task=ed84a0c0
      task.ti=d7c62000)
      Stack:
       00000001 f70a1200 f8b940a9 ef5a0060 00000000 00200202 f8769009 00000000
       ef5a0060 000f387e eda5c020 8722f9c8 00015bae 00000000 ed84a0c0 ed84a0c0
       c12bf02d 0000ae80 ef7f8740 fffffffb f359b740 ef5a0060 f8b85dc1 0000ae80
      Call Trace:
       [<f8b940a9>] ? kvm_arch_vcpu_ioctl_set_sregs+0x2fe/0x308 [kvm]
      ...
       [<c12bfb44>] ? syscall_call+0x7/0xb
      Code: 89 e8 e8 14 ee ff ff ba 00 00 04 00 89 e8 e8 98 48 ff ff 85 c0 74
      1e 83 7d 48 00 75 18 8b 85 08 07 00 00 31 c9 8b 95 0c 07 00 00 <0f> 01
      d1 c7 45 48 01 00 00 00 c7 45 1c 01 00 00 00 0f ae f0 89
      EIP: [<f8b9550c>] kvm_arch_vcpu_ioctl_run+0x92a/0xd13 [kvm] SS:ESP
      0068:d7c63e70
      
      QEMU first retrieves the supported features via KVM_GET_SUPPORTED_CPUID
      and then sets them later. So guest's X86_FEATURE_XSAVE should be masked
      out on hosts without X86_FEATURE_XSAVE, making kvm_set_cr4 with
      X86_CR4_OSXSAVE fail. Userspaces that allow specifying guest cpuid with
      X86_FEATURE_XSAVE even on hosts that do not support it, might be
      susceptible to this attack from inside the guest as well.
      
      Allow setting X86_CR4_OSXSAVE bit only if host has XSAVE support.
      Signed-off-by: default avatarPetr Matousek <pmatouse@redhat.com>
      Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
      [bwh: Backported to 2.6.32: XSAVE is not supported at all, so always
       deny setting OSXSAVE]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      228b7542
    • Andy Honig's avatar
      KVM: Fix bounds checking in ioapic indirect register reads (CVE-2013-1798) · d277a2de
      Andy Honig authored
      commit a2c118bf upstream.
      
      If the guest specifies a IOAPIC_REG_SELECT with an invalid value and follows
      that with a read of the IOAPIC_REG_WINDOW KVM does not properly validate
      that request.  ioapic_read_indirect contains an
      ASSERT(redir_index < IOAPIC_NUM_PINS), but the ASSERT has no effect in
      non-debug builds.  In recent kernels this allows a guest to cause a kernel
      oops by reading invalid memory.  In older kernels (pre-3.3) this allows a
      guest to read from large ranges of host memory.
      
      Tested: tested against apic unit tests.
      Signed-off-by: default avatarAndrew Honig <ahonig@google.com>
      Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
      Cc: Ben Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      d277a2de
    • Marcelo Tosatti's avatar
      KVM: x86: relax MSR_KVM_SYSTEM_TIME alignment check · aa184a86
      Marcelo Tosatti authored
      This was fixed by commit 8f964525
      upstream.  This alternate fix avoids the need for extensive backporting.
      
      RHEL5 i386 guests register non 32-byte aligned addresses:
      
      kvm-clock: cpu 1, msr 0:3018aa5, secondary cpu clock
      kvm-clock: cpu 2, msr 0:301f8e9, secondary cpu clock
      kvm-clock: cpu 3, msr 0:302672d, secondary cpu clock
      
      Check for an address+len that would cross page boundary
      instead.
      Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
      [dannf: backported to Debian's 2.6.32]
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      aa184a86
    • Andy Honig's avatar
      KVM: x86: fix for buffer overflow in handling of MSR_KVM_SYSTEM_TIME (CVE-2013-1796) · 1a33aaff
      Andy Honig authored
      commit c300aa64 upstream.
      
      If the guest sets the GPA of the time_page so that the request to update the
      time straddles a page then KVM will write onto an incorrect page.  The
      write is done byusing kmap atomic to get a pointer to the page for the time
      structure and then performing a memcpy to that page starting at an offset
      that the guest controls.  Well behaved guests always provide a 32-byte aligned
      address, however a malicious guest could use this to corrupt host kernel
      memory.
      
      Tested: Tested against kvmclock unit test.
      Signed-off-by: default avatarAndrew Honig <ahonig@google.com>
      Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
      Cc: Ben Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      1a33aaff
    • Konrad Rzeszutek Wilk's avatar
      xen/bootup: allow {read|write}_cr8 pvops call. · 13fbb875
      Konrad Rzeszutek Wilk authored
      commit 1a7bbda5 upstream.
      
      We actually do not do anything about it. Just return a default
      value of zero and if the kernel tries to write anything but 0
      we BUG_ON.
      
      This fixes the case when an user tries to suspend the machine
      and it blows up in save_processor_state b/c 'read_cr8' is set
      to NULL and we get:
      
      kernel BUG at /home/konrad/ssd/linux/arch/x86/include/asm/paravirt.h:100!
      invalid opcode: 0000 [#1] SMP
      Pid: 2687, comm: init.late Tainted: G           O 3.6.0upstream-00002-gac264ac-dirty #4 Bochs Bochs
      RIP: e030:[<ffffffff814d5f42>]  [<ffffffff814d5f42>] save_processor_state+0x212/0x270
      
      .. snip..
      Call Trace:
       [<ffffffff810733bf>] do_suspend_lowlevel+0xf/0xac
       [<ffffffff8107330c>] ? x86_acpi_suspend_lowlevel+0x10c/0x150
       [<ffffffff81342ee2>] acpi_suspend_enter+0x57/0xd5
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      13fbb875