1. 20 Aug, 2013 9 commits
  2. 15 Aug, 2013 31 commits
    • Greg Kroah-Hartman's avatar
      Linux 3.10.7 · 519be456
      Greg Kroah-Hartman authored
      519be456
    • Markos Chandras's avatar
      MIPS: Expose missing pci_io{map,unmap} declarations · 5954bd0f
      Markos Chandras authored
      commit 78857614 upstream.
      
      The GENERIC_PCI_IOMAP does not depend on CONFIG_PCI so move
      it to the CONFIG_MIPS symbol so it's always selected for MIPS.
      This fixes the missing pci_iomap declaration for MIPS.
      Moreover, the pci_iounmap function was not defined in the
      io.h header file if the CONFIG_PCI symbol is not set,
      but it should since MIPS is not using CONFIG_GENERIC_IOMAP.
      
      This fixes the following problem on a allyesconfig:
      
      drivers/net/ethernet/3com/3c59x.c:1031:2: error: implicit declaration of
      function 'pci_iomap' [-Werror=implicit-function-declaration]
      drivers/net/ethernet/3com/3c59x.c:1044:3: error: implicit declaration of
      function 'pci_iounmap' [-Werror=implicit-function-declaration]
      Signed-off-by: default avatarMarkos Chandras <markos.chandras@imgtec.com>
      Acked-by: default avatarSteven J. Hill <Steven.Hill@imgtec.com>
      Patchwork: https://patchwork.linux-mips.org/patch/5478/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5954bd0f
    • Arnd Bergmann's avatar
      mtd: omap2: allow bulding as a module · ddb2a2d9
      Arnd Bergmann authored
      commit 930d800b upstream.
      
      The omap2 nand device driver calls into the the elm code, which can
      be a loadable module, and in that case it cannot be built-in itself.
      I can see no reason why the omap2 driver cannot also be a module,
      so let's make the option "tristate" in Kconfig to fix this allmodconfig
      build error:
      
      ERROR: "elm_config" [drivers/mtd/nand/omap2.ko] undefined!
      ERROR: "elm_decode_bch_error_page" [drivers/mtd/nand/omap2.ko] undefined!
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarTony Lindgren <tony@atomide.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Cc: Afzal Mohammed <afzal@ti.com>
      Cc: Russell King <rmk+kernel@arm.linux.org.uk>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ddb2a2d9
    • Arnd Bergmann's avatar
      SCSI: nsp32: use mdelay instead of large udelay constants · c7cf2a75
      Arnd Bergmann authored
      commit b497ceb9 upstream.
      
      ARM cannot handle udelay for more than 2 miliseconds, so we
      should use mdelay instead for those.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarGOTO Masanori <gotom@debian.or.jp>
      Cc: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
      Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c7cf2a75
    • Alex Deucher's avatar
      drm/radeon: always program the MC on startup · 9ff2cb52
      Alex Deucher authored
      commit 6fab3feb upstream.
      
      For r6xx+ asics.  This mirrors the behavior of pre-r6xx
      asics.  We need to program the MC even if something
      else in startup() fails.  Failure to do so results in
      an unusable GPU.
      
      Based on a fix from: Mark Kettenis <kettenis@openbsd.org>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      [ rebased for 3.10 and dropped the drivers/gpu/drm/radeon/cik.c
        bit as it's 3.11 specific code / tmb ]
      Signed-off-by: default avatarThomas Backlund <tmb@mageia.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ff2cb52
    • Christian König's avatar
      drm/radeon: only save UVD bo when we have open handles · 23b6ec0b
      Christian König authored
      commit 4ad9c1c7 upstream.
      
      Otherwise just reinitialize from scratch on resume,
      and so make it more likely to succeed.
      
      v2: rebased for 3.10-stable tree
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23b6ec0b
    • Christian König's avatar
      drm/radeon: fix halting UVD · 6b061129
      Christian König authored
      commit 2858c00d upstream.
      
      Removing the clock/power or resetting the VCPU can cause
      hangs if that happens in the middle of a register write.
      
      Stall the memory and register bus before putting the VCPU
      into reset. Keep it in reset when unloading the module or
      suspending.
      
      v2: rebased on 3.10-stable tree
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6b061129
    • Jani Nikula's avatar
      drm/i915: initialize gt_lock early with other spin locks · 86813a19
      Jani Nikula authored
      commit 14c5cec5 upstream.
      
      commit 181d1b9e
      Author: Daniel Vetter <daniel.vetter@ffwll.ch>
      Date:   Sun Jul 21 13:16:24 2013 +0200
      
          drm/i915: fix up gt init sequence fallout
      
      moved dev_priv->gt_lock initialization after use. Do the initialization
      much earlier with other spin lock initializations.
      Reported-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Tested-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarZhouping Liu <zliu@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86813a19
    • Al Viro's avatar
      reiserfs: fix deadlock in umount · 71986ee0
      Al Viro authored
      commit 672fe15d upstream.
      
      Since remove_proc_entry() started to wait for IO in progress (i.e.
      since 2007 or so), the locking in fs/reiserfs/proc.c became wrong;
      if procfs read happens between the moment when umount() locks the
      victim superblock and removal of /proc/fs/reiserfs/<device>/*,
      we'll get a deadlock - read will wait for s_umount (in sget(),
      called by r_start()), while umount will wait in remove_proc_entry()
      for that read to finish, holding s_umount all along.
      
      Fortunately, the same change allows a much simpler race avoidance -
      all we need to do is remove the procfs entries in the very beginning
      of reiserfs ->kill_sb(); that'll guarantee that pointer to superblock
      will remain valid for the duration for procfs IO, so we don't need
      sget() to keep the sucker alive.  As the matter of fact, we can
      get rid of the home-grown iterator completely, and use single_open()
      instead.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71986ee0
    • Oleg Nesterov's avatar
      debugfs: debugfs_remove_recursive() must not rely on list_empty(d_subdirs) · a9800654
      Oleg Nesterov authored
      commit 776164c1 upstream.
      
      debugfs_remove_recursive() is wrong,
      
      1. it wrongly assumes that !list_empty(d_subdirs) means that this
         dir should be removed.
      
         This is not that bad by itself, but:
      
      2. if d_subdirs does not becomes empty after __debugfs_remove()
         it gives up and silently fails, it doesn't even try to remove
         other entries.
      
         However ->d_subdirs can be non-empty because it still has the
         already deleted !debugfs_positive() entries.
      
      3. simple_release_fs() is called even if __debugfs_remove() fails.
      
      Suppose we have
      
      	dir1/
      		dir2/
      			file2
      		file1
      
      and someone opens dir1/dir2/file2.
      
      Now, debugfs_remove_recursive(dir1/dir2) succeeds, and dir1/dir2 goes
      away.
      
      But debugfs_remove_recursive(dir1) silently fails and doesn't remove
      this directory. Because it tries to delete (the already deleted)
      dir1/dir2/file2 again and then fails due to "Avoid infinite loop"
      logic.
      
      Test-case:
      
      	#!/bin/sh
      
      	cd /sys/kernel/debug/tracing
      	echo 'p:probe/sigprocmask sigprocmask' >> kprobe_events
      	sleep 1000 < events/probe/sigprocmask/id &
      	echo -n >| kprobe_events
      
      	[ -d events/probe ] && echo "ERR!! failed to rm probe"
      
      And after that it is not possible to create another probe entry.
      
      With this patch debugfs_remove_recursive() skips !debugfs_positive()
      files although this is not strictly needed. The most important change
      is that it does not try to make ->d_subdirs empty, it simply scans
      the whole list(s) recursively and removes as much as possible.
      
      Link: http://lkml.kernel.org/r/20130726151256.GC19472@redhat.comAcked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a9800654
    • Julius Werner's avatar
      usb: core: don't try to reset_device() a port that got just disconnected · 6b9cb24d
      Julius Werner authored
      commit 481f2d4f upstream.
      
      The USB hub driver's event handler contains a check to catch SuperSpeed
      devices that transitioned into the SS.Inactive state and tries to fix
      them with a reset. It decides whether to do a plain hub port reset or
      call the usb_reset_device() function based on whether there was a device
      attached to the port.
      
      However, there are device/hub combinations (found with a JetFlash
      Transcend mass storage stick (8564:1000) on the root hub of an Intel
      LynxPoint PCH) which can transition to the SS.Inactive state on
      disconnect (and stay there long enough for the host to notice). In this
      case, above-mentioned reset check will call usb_reset_device() on the
      stale device data structure. The kernel will send pointless LPM control
      messages to the no longer connected device address and can even cause
      several 5 second khubd stalls on some (buggy?) host controllers, before
      finally accepting the device's fate amongst a flurry of error messages.
      
      This patch makes the choice of reset dependent on the port status that
      has just been read from the hub in addition to the existence of an
      in-kernel data structure for the device, and only proceeds with the more
      extensive reset if both are valid.
      Signed-off-by: default avatarJulius Werner <jwerner@chromium.org>
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6b9cb24d
    • Sergey Senozhatsky's avatar
      zram: allow request end to coincide with disksize · 94bcc7de
      Sergey Senozhatsky authored
      commit 75c7caf5 upstream.
      
      Pass valid_io_request() checks if request end coincides with disksize
      (end equals bound), only fail if we attempt to read beyond the bound.
      
      mkfs.ext2 produces numerous errors:
      [ 2164.632747] quiet_error: 1 callbacks suppressed
      [ 2164.633260] Buffer I/O error on device zram0, logical block 153599
      [ 2164.633265] lost page write due to I/O error on zram0
      Signed-off-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Cc: Thomas Backlund <tmb@mageia.org>
      Cc: Minchan Kim <minchan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      94bcc7de
    • Jeff Layton's avatar
      cifs: don't instantiate new dentries in readdir for inodes that need to be revalidated immediately · d1e8adc0
      Jeff Layton authored
      commit 757c4f62 upstream.
      
      David reported that commit c2b93e06 (cifs: only set ops for inodes in
      I_NEW state) caused a regression with mfsymlinks. Prior to that patch,
      if a mfsymlink dentry was instantiated at readdir time, the inode would
      get a new set of ops when it was revalidated. After that patch, this
      did not occur.
      
      This patch addresses this by simply skipping instantiating dentries in
      the readdir codepath when we know that they will need to be immediately
      revalidated. The next attempt to use that dentry will cause a new lookup
      to occur (which is basically what we want to happen anyway).
      Reported-and-Tested-by: default avatarDavid McBride <dwm37@cam.ac.uk>
      Cc: "Stefan (metze) Metzmacher" <metze@samba.org>
      Cc: Sachin Prabhu <sprabhu@redhat.com>
      Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
      Signed-off-by: default avatarSteve French <smfrench@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1e8adc0
    • Chen Gang's avatar
      cifs: extend the buffer length enought for sprintf() using · 4350018a
      Chen Gang authored
      commit 057d6332 upstream.
      
      For cifs_set_cifscreds() in "fs/cifs/connect.c", 'desc' buffer length
      is 'CIFSCREDS_DESC_SIZE' (56 is less than 256), and 'ses->domainName'
      length may be "255 + '\0'".
      
      The related sprintf() may cause memory overflow, so need extend related
      buffer enough to hold all things.
      
      It is also necessary to be sure of 'ses->domainName' must be less than
      256, and define the related macro instead of hard code number '256'.
      Signed-off-by: default avatarChen Gang <gang.chen@asianux.com>
      Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
      Reviewed-by: default avatarShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Reviewed-by: default avatarScott Lovenberg <scott.lovenberg@gmail.com>
      Signed-off-by: default avatarSteve French <smfrench@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4350018a
    • Theodore Ts'o's avatar
      ext4: flush the extent status cache during EXT4_IOC_SWAP_BOOT · 72766b0b
      Theodore Ts'o authored
      commit cde2d7a7 upstream.
      
      Previously we weren't swapping only some of the extent_status LRU
      fields during the processing of the EXT4_IOC_SWAP_BOOT ioctl.  The
      much safer thing to do is to just completely flush the extent status
      tree when doing the swap.
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      Cc: Zheng Liu <gnehzuil.liu@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      72766b0b
    • Piotr Sarna's avatar
      ext4: fix mount/remount error messages for incompatible mount options · c4fa1009
      Piotr Sarna authored
      commit 6ae6514b upstream.
      
      Commit 56889787 ("ext4: improve handling of conflicting mount options")
      introduced incorrect messages shown while choosing wrong mount options.
      
      First of all, both cases of incorrect mount options,
      "data=journal,delalloc" and "data=journal,dioread_nolock" result in
      the same error message.
      
      Secondly, the problem above isn't solved for remount option: the
      mismatched parameter is simply ignored.  Moreover, ext4_msg states
      that remount with options "data=journal,delalloc" succeeded, which is
      not true.
      
      To fix it up, I added a simple check after parse_options() call to
      ensure that data=journal and delalloc/dioread_nolock parameters are
      not present at the same time.
      Signed-off-by: default avatarPiotr Sarna <p.sarna@partner.samsung.com>
      Acked-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c4fa1009
    • Theodore Ts'o's avatar
      ext4: allow the mount options nodelalloc and data=journal · 1929c51f
      Theodore Ts'o authored
      commit 59d9fa5c upstream.
      
      Commit 26092bf5 ("ext4: use a table-driven handler for mount options")
      wrongly disallows the specifying the mount options nodelalloc and
      data=journal simultaneously.  This is incorrect; it should have only
      disallowed the combination of delalloc and data=journal
      simultaneously.
      Reported-by: default avatarPiotr Sarna <p.sarna@partner.samsung.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1929c51f
    • Christian König's avatar
      drm/radeon: stop sending invalid UVD destroy msg · ce512e58
      Christian König authored
      commit 641a0059 upstream.
      
      We also need to check the handle.
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ce512e58
    • Alex Deucher's avatar
      drm/radeon: select audio dto based on encoder id for DCE3 · a76faeeb
      Alex Deucher authored
      commit e1accbf0 upstream.
      
      There are two audio dtos on radeon asics that you can
      select between.  Normally, dto0 is used for hdmi and
      dto1 for DP, but it seems that the dto is somehow
      tied to the encoders on DCE3 asics.
      
      fixes:
      https://bugs.freedesktop.org/show_bug.cgi?id=67435Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a76faeeb
    • Michel Dänzer's avatar
      drm: Don't pass negative delta to ktime_sub_ns() · ac4ae0b9
      Michel Dänzer authored
      commit e91abf80 upstream.
      
      It takes an unsigned value. This happens not to blow up on 64-bit
      architectures, but it does on 32-bit, causing
      drm_calc_vbltimestamp_from_scanoutpos() to calculate totally bogus
      timestamps for vblank events. Which in turn causes e.g. gnome-shell to
      hang after a DPMS off cycle with current xf86-video-ati Git.
      
      [airlied: regression introduced in drm: use monotonic time in drm_calc_vbltimestamp_from_scanoutpos]
      
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59339
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59836Tested-by: default avatarshui yangwei <yangweix.shui@intel.com>
      Signed-off-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
      Reviewed-by: default avatarImre Deak <imre.deak@intel.com>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac4ae0b9
    • Dave Airlie's avatar
      drm/ast: invalidate page tables when pinning a BO · aabfe27d
      Dave Airlie authored
      commit 3ac65259 upstream.
      
      same fix as cirrus and mgag200.
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aabfe27d
    • Egbert Eich's avatar
      drm/mgag200: Invalidate page tables when pinning a BO · 12fb12f1
      Egbert Eich authored
      commit ecaac1c8 upstream.
      
      When a BO gets pinned the placement may get changed. If the memory is
      mapped into user space and user space has already accessed the mapped
      range the page tables are set up but now point to the wrong memory.
      Set bo.mdev->dev_mapping in mgag200_bo_create() to make sure that
      ttm_bo_unmap_virtual() called from ttm_bo_handle_move_mem() will take
      care of this.
      
      v2: Don't call ttm_bo_unmap_virtual() in mgag200_bo_pin(), fix comment.
      Signed-off-by: default avatarEgbert Eich <eich@suse.com>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      12fb12f1
    • Michal Srb's avatar
      drm/cirrus: Invalidate page tables when pinning a BO · 18da37c3
      Michal Srb authored
      commit 109a5159 upstream.
      
      This is a cirrus version of Egbert Eich's patch for mgag200.
      
      Without bo.bdev->dev_mapping set, the ttm_bo_unmap_virtual_locked
      called from ttm_bo_handle_move_mem returns with no effect. If any
      application accessed the memory before it was moved, it will
      access wrong memory next time. This causes crashes when changing
      resolution down.
      Signed-off-by: default avatarMichal Srb <msrb@suse.com>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      18da37c3
    • Amit Shah's avatar
      virtio: console: return -ENODEV on all read operations after unplug · 61ffac73
      Amit Shah authored
      commit 96f97a83 upstream.
      
      If a port gets unplugged while a user is blocked on read(), -ENODEV is
      returned.  However, subsequent read()s returned 0, indicating there's no
      host-side connection (but not indicating the device went away).
      
      This also happened when a port was unplugged and the user didn't have
      any blocking operation pending.  If the user didn't monitor the SIGIO
      signal, they won't have a chance to find out if the port went away.
      
      Fix by returning -ENODEV on all read()s after the port gets unplugged.
      write() already behaves this way.
      Signed-off-by: default avatarAmit Shah <amit.shah@redhat.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      61ffac73
    • Amit Shah's avatar
      virtio: console: fix raising SIGIO after port unplug · 2817b99f
      Amit Shah authored
      commit 92d34538 upstream.
      
      SIGIO should be sent when a port gets unplugged.  It should only be sent
      to prcesses that have the port opened, and have asked for SIGIO to be
      delivered.  We were clearing out guest_connected before calling
      send_sigio_to_port(), resulting in a sigio not getting sent to
      processes.
      
      Fix by setting guest_connected to false after invoking the sigio
      function.
      Signed-off-by: default avatarAmit Shah <amit.shah@redhat.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2817b99f
    • Amit Shah's avatar
      virtio: console: clean up port data immediately at time of unplug · 707ea94e
      Amit Shah authored
      commit ea3768b4 upstream.
      
      We used to keep the port's char device structs and the /sys entries
      around till the last reference to the port was dropped.  This is
      actually unnecessary, and resulted in buggy behaviour:
      
      1. Open port in guest
      2. Hot-unplug port
      3. Hot-plug a port with the same 'name' property as the unplugged one
      
      This resulted in hot-plug being unsuccessful, as a port with the same
      name already exists (even though it was unplugged).
      
      This behaviour resulted in a warning message like this one:
      
      -------------------8<---------------------------------------
      WARNING: at fs/sysfs/dir.c:512 sysfs_add_one+0xc9/0x130() (Not tainted)
      Hardware name: KVM
      sysfs: cannot create duplicate filename
      '/devices/pci0000:00/0000:00:04.0/virtio0/virtio-ports/vport0p1'
      
      Call Trace:
       [<ffffffff8106b607>] ? warn_slowpath_common+0x87/0xc0
       [<ffffffff8106b6f6>] ? warn_slowpath_fmt+0x46/0x50
       [<ffffffff811f2319>] ? sysfs_add_one+0xc9/0x130
       [<ffffffff811f23e8>] ? create_dir+0x68/0xb0
       [<ffffffff811f2469>] ? sysfs_create_dir+0x39/0x50
       [<ffffffff81273129>] ? kobject_add_internal+0xb9/0x260
       [<ffffffff812733d8>] ? kobject_add_varg+0x38/0x60
       [<ffffffff812734b4>] ? kobject_add+0x44/0x70
       [<ffffffff81349de4>] ? get_device_parent+0xf4/0x1d0
       [<ffffffff8134b389>] ? device_add+0xc9/0x650
      
      -------------------8<---------------------------------------
      
      Instead of relying on guest applications to release all references to
      the ports, we should go ahead and unregister the port from all the core
      layers.  Any open/read calls on the port will then just return errors,
      and an unplug/plug operation on the host will succeed as expected.
      
      This also caused buggy behaviour in case of the device removal (not just
      a port): when the device was removed (which means all ports on that
      device are removed automatically as well), the ports with active
      users would clean up only when the last references were dropped -- and
      it would be too late then to be referencing char device pointers,
      resulting in oopses:
      
      -------------------8<---------------------------------------
      PID: 6162   TASK: ffff8801147ad500  CPU: 0   COMMAND: "cat"
       #0 [ffff88011b9d5a90] machine_kexec at ffffffff8103232b
       #1 [ffff88011b9d5af0] crash_kexec at ffffffff810b9322
       #2 [ffff88011b9d5bc0] oops_end at ffffffff814f4a50
       #3 [ffff88011b9d5bf0] die at ffffffff8100f26b
       #4 [ffff88011b9d5c20] do_general_protection at ffffffff814f45e2
       #5 [ffff88011b9d5c50] general_protection at ffffffff814f3db5
          [exception RIP: strlen+2]
          RIP: ffffffff81272ae2  RSP: ffff88011b9d5d00  RFLAGS: 00010246
          RAX: 0000000000000000  RBX: ffff880118901c18  RCX: 0000000000000000
          RDX: ffff88011799982c  RSI: 00000000000000d0  RDI: 3a303030302f3030
          RBP: ffff88011b9d5d38   R8: 0000000000000006   R9: ffffffffa0134500
          R10: 0000000000001000  R11: 0000000000001000  R12: ffff880117a1cc10
          R13: 00000000000000d0  R14: 0000000000000017  R15: ffffffff81aff700
          ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
       #6 [ffff88011b9d5d00] kobject_get_path at ffffffff8126dc5d
       #7 [ffff88011b9d5d40] kobject_uevent_env at ffffffff8126e551
       #8 [ffff88011b9d5dd0] kobject_uevent at ffffffff8126e9eb
       #9 [ffff88011b9d5de0] device_del at ffffffff813440c7
      
      -------------------8<---------------------------------------
      
      So clean up when we have all the context, and all that's left to do when
      the references to the port have dropped is to free up the port struct
      itself.
      Reported-by: default avatarchayang <chayang@redhat.com>
      Reported-by: default avatarYOGANANTH SUBRAMANIAN <anantyog@in.ibm.com>
      Reported-by: default avatarFuXiangChun <xfu@redhat.com>
      Reported-by: default avatarQunfang Zhang <qzhang@redhat.com>
      Reported-by: default avatarSibiao Luo <sluo@redhat.com>
      Signed-off-by: default avatarAmit Shah <amit.shah@redhat.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      707ea94e
    • Amit Shah's avatar
      virtio: console: fix race in port_fops_open() and port unplug · 60391483
      Amit Shah authored
      commit 671bdea2 upstream.
      
      Between open() being called and processed, the port can be unplugged.
      Check if this happened, and bail out.
      
      A simple test script to reproduce this is:
      
      while true; do for i in $(seq 1 100); do echo $i > /dev/vport0p3; done; done;
      
      This opens and closes the port a lot of times; unplugging the port while
      this is happening triggers the bug.
      Signed-off-by: default avatarAmit Shah <amit.shah@redhat.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      60391483
    • Amit Shah's avatar
      virtio: console: fix race with port unplug and open/close · 7b9f0c23
      Amit Shah authored
      commit 057b82be upstream.
      
      There's a window between find_port_by_devt() returning a port and us
      taking a kref on the port, where the port could get unplugged.  Fix it
      by taking the reference in find_port_by_devt() itself.
      
      Problem reported and analyzed by Mateusz Guzik.
      Reported-by: default avatarMateusz Guzik <mguzik@redhat.com>
      Signed-off-by: default avatarAmit Shah <amit.shah@redhat.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b9f0c23
    • Yoshihiro YUNOMAE's avatar
      virtio/console: Add pipe_lock/unlock for splice_write · 98c9710e
      Yoshihiro YUNOMAE authored
      commit 2b4fbf02 upstream.
      
      Add pipe_lock/unlock for splice_write to avoid oops by following competition:
      
      (1) An application gets fds of a trace buffer, virtio-serial, pipe.
      (2) The application does fork()
      (3) The processes execute splice_read(trace buffer) and
          splice_write(virtio-serial) via same pipe.
      
              <parent>                   <child>
        get fds of a trace buffer,
               virtio-serial, pipe
                |
              fork()----------create--------+
                |                           |
            splice(read)                    |           ---+
            splice(write)                   |              +-- no competition
                |                       splice(read)       |
                |                       splice(write)   ---+
                |                           |
            splice(read)                    |
            splice(write)               splice(read)    ------ competition
                |                       splice(write)
      
      Two processes share a pipe_inode_info structure. If the child execute
      splice(read) when the parent tries to execute splice(write), the
      structure can be broken. Existing virtio-serial driver does not get
      lock for the structure in splice_write, so this competition will induce
      oops.
      
      <oops messages>
       BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
       IP: [<ffffffff811a6b5f>] splice_from_pipe_feed+0x6f/0x130
       PGD 7223e067 PUD 72391067 PMD 0
       Oops: 0000 [#1] SMP
       Modules linked in: lockd bnep bluetooth rfkill sunrpc ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 xt_state nf_conntrack ip6table_filter ip6_tables snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_page_alloc snd_timer snd soundcore pcspkr virtio_net virtio_balloon i2c_piix4 i2c_core microcode uinput floppy
       CPU: 0 PID: 1072 Comm: compete-test Not tainted 3.10.0ws+ #55
       Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
       task: ffff880071b98000 ti: ffff88007b55e000 task.ti: ffff88007b55e000
       RIP: 0010:[<ffffffff811a6b5f>]  [<ffffffff811a6b5f>] splice_from_pipe_feed+0x6f/0x130
       RSP: 0018:ffff88007b55fd78  EFLAGS: 00010287
       RAX: 0000000000000000 RBX: ffff88007b55fe20 RCX: 0000000000000000
       RDX: 0000000000001000 RSI: ffff88007a95ba30 RDI: ffff880036f9e6c0
       RBP: ffff88007b55fda8 R08: 00000000000006ec R09: ffff880077626708
       R10: 0000000000000003 R11: ffffffff8139ca59 R12: ffff88007a95ba30
       R13: 0000000000000000 R14: ffffffff8139dd00 R15: ffff880036f9e6c0
       FS:  00007f2e2e3a0740(0000) GS:ffff88007fc00000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
       CR2: 0000000000000018 CR3: 0000000071bd1000 CR4: 00000000000006f0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
       Stack:
        ffffffff8139ca59 ffff88007b55fe20 ffff880036f9e6c0 ffffffff8139dd00
        ffff8800776266c0 ffff880077626708 ffff88007b55fde8 ffffffff811a6e8e
        ffff88007b55fde8 ffffffff8139ca59 ffff880036f9e6c0 ffff88007b55fe20
       Call Trace:
        [<ffffffff8139ca59>] ? alloc_buf.isra.13+0x39/0xb0
        [<ffffffff8139dd00>] ? virtcons_restore+0x100/0x100
        [<ffffffff811a6e8e>] __splice_from_pipe+0x7e/0x90
        [<ffffffff8139ca59>] ? alloc_buf.isra.13+0x39/0xb0
        [<ffffffff8139d739>] port_fops_splice_write+0xe9/0x140
        [<ffffffff8127a3f4>] ? selinux_file_permission+0xc4/0x120
        [<ffffffff8139d650>] ? wait_port_writable+0x1b0/0x1b0
        [<ffffffff811a6fe0>] do_splice_from+0xa0/0x110
        [<ffffffff811a951f>] SyS_splice+0x5ff/0x6b0
        [<ffffffff8161facf>] tracesys+0xdd/0xe2
       Code: 49 8b 87 80 00 00 00 4c 8d 24 d0 8b 53 04 41 8b 44 24 0c 4d 8b 6c 24 10 39 d0 89 03 76 02 89 13 49 8b 44 24 10 4c 89 e6 4c 89 ff <ff> 50 18 85 c0 0f 85 aa 00 00 00 48 89 da 4c 89 e6 4c 89 ff 41
       RIP  [<ffffffff811a6b5f>] splice_from_pipe_feed+0x6f/0x130
        RSP <ffff88007b55fd78>
       CR2: 0000000000000018
       ---[ end trace 24572beb7764de59 ]---
      
      V2: Fix a locking problem for error
      V3: Add Reviewed-by lines and stable@ line in sign-off area
      Signed-off-by: default avatarYoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
      Reviewed-by: default avatarAmit Shah <amit.shah@redhat.com>
      Reviewed-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Amit Shah <amit.shah@redhat.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      98c9710e
    • Yoshihiro YUNOMAE's avatar
      virtio/console: Quit from splice_write if pipe->nrbufs is 0 · 81b80fb8
      Yoshihiro YUNOMAE authored
      commit 68c034fe upstream.
      
      Quit from splice_write if pipe->nrbufs is 0 for avoiding oops in virtio-serial.
      
      When an application was doing splice from a kernel buffer to virtio-serial on
      a guest, the application received signal(SIGINT). This situation will normally
      happen, but the kernel executed a kernel panic by oops as follows:
      
       BUG: unable to handle kernel paging request at ffff882071c8ef28
       IP: [<ffffffff812de48f>] sg_init_table+0x2f/0x50
       PGD 1fac067 PUD 0
       Oops: 0000 [#1] SMP
       Modules linked in: lockd sunrpc bnep bluetooth rfkill ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 xt_state nf_conntrack ip6table_filter ip6_tables snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_page_alloc snd_timer snd microcode virtio_balloon virtio_net pcspkr soundcore i2c_piix4 i2c_core uinput floppy
       CPU: 1 PID: 908 Comm: trace-cmd Not tainted 3.10.0+ #49
       Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
       task: ffff880071c64650 ti: ffff88007bf24000 task.ti: ffff88007bf24000
       RIP: 0010:[<ffffffff812de48f>]  [<ffffffff812de48f>] sg_init_table+0x2f/0x50
       RSP: 0018:ffff88007bf25dd8  EFLAGS: 00010286
       RAX: 0000001fffffffe0 RBX: ffff882071c8ef28 RCX: 0000000000000000
       RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff880071c8ef48
       RBP: ffff88007bf25de8 R08: ffff88007fd15d40 R09: ffff880071c8ef48
       R10: ffffea0001c71040 R11: ffffffff8139c555 R12: 0000000000000000
       R13: ffff88007506a3c0 R14: ffff88007c862500 R15: ffff880071c8ef00
       FS:  00007f0a3646c740(0000) GS:ffff88007fd00000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: ffff882071c8ef28 CR3: 000000007acbb000 CR4: 00000000000006e0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
       Stack:
        ffff880071c8ef48 ffff88007bf25e20 ffff88007bf25e88 ffffffff8139d6fa
        ffff88007bf25e28 ffffffff8127a3f4 0000000000000000 0000000000000000
        ffff880071c8ef48 0000100000000000 0000000000000003 ffff88007bf25e08
       Call Trace:
        [<ffffffff8139d6fa>] port_fops_splice_write+0xaa/0x130
        [<ffffffff8127a3f4>] ? selinux_file_permission+0xc4/0x120
        [<ffffffff8139d650>] ? wait_port_writable+0x1b0/0x1b0
        [<ffffffff811a6fe0>] do_splice_from+0xa0/0x110
        [<ffffffff811a951f>] SyS_splice+0x5ff/0x6b0
        [<ffffffff8161f8c2>] system_call_fastpath+0x16/0x1b
       Code: c1 e2 05 48 89 e5 48 83 ec 10 4c 89 65 f8 41 89 f4 31 f6 48 89 5d f0 48 89 fb e8 8d ce ff ff 41 8d 44 24 ff 48 c1 e0 05 48 01 c3 <48> 8b 03 48 83 e0 fe 48 83 c8 02 48 89 03 48 8b 5d f0 4c 8b 65
       RIP  [<ffffffff812de48f>] sg_init_table+0x2f/0x50
        RSP <ffff88007bf25dd8>
       CR2: ffff882071c8ef28
       ---[ end trace 86323505eb42ea8f ]---
      
      It seems to induce pagefault in sg_init_tabel() when pipe->nrbufs is equal to
      zero. This may happen in a following situation:
      
      (1) The application normally does splice(read) from a kernel buffer, then does
          splice(write) to virtio-serial.
      (2) The application receives SIGINT when is doing splice(read), so splice(read)
          is failed by EINTR. However, the application does not finish the operation.
      (3) The application tries to do splice(write) without pipe->nrbufs.
      (4) The virtio-console driver tries to touch scatterlist structure sgl in
          sg_init_table(), but the region is out of bound.
      
      To avoid the case, a kernel should check whether pipe->nrbufs is empty or not
      when splice_write is executed in the virtio-console driver.
      
      V3: Add Reviewed-by lines and stable@ line in sign-off area.
      Signed-off-by: default avatarYoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
      Reviewed-by: default avatarAmit Shah <amit.shah@redhat.com>
      Reviewed-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Amit Shah <amit.shah@redhat.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      81b80fb8
    • Trond Myklebust's avatar
      SUNRPC: If the rpcbind channel is disconnected, fail the call to unregister · 4662ffcb
      Trond Myklebust authored
      commit 786615bc upstream.
      
      If rpcbind causes our connection to the AF_LOCAL socket to close after
      we've registered a service, then we want to be careful about reconnecting
      since the mount namespace may have changed.
      
      By simply refusing to reconnect the AF_LOCAL socket in the case of
      unregister, we avoid the need to somehow save the mount namespace. While
      this may lead to some services not unregistering properly, it should
      be safe.
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      Cc: Nix <nix@esperi.org.uk>
      Cc: Jeff Layton <jlayton@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4662ffcb