1. 24 Apr, 2018 36 commits
    • Mika Westerberg's avatar
      ACPI / hotplug / PCI: Check presence of slot itself in get_slot_status() · 63aa8d89
      Mika Westerberg authored
      commit 13d3047c upstream.
      
      Mike Lothian reported that plugging in a USB-C device does not work
      properly in his Dell Alienware system.  This system has an Intel Alpine
      Ridge Thunderbolt controller providing USB-C functionality.  In these
      systems the USB controller (xHCI) is hotplugged whenever a device is
      connected to the port using ACPI-based hotplug.
      
      The ACPI description of the root port in question is as follows:
      
        Device (RP01)
        {
            Name (_ADR, 0x001C0000)
      
            Device (PXSX)
            {
                Name (_ADR, 0x02)
      
                Method (_RMV, 0, NotSerialized)
                {
                    // ...
                }
            }
      
      Here _ADR 0x02 means device 0, function 2 on the bus under root port (RP01)
      but that seems to be incorrect because device 0 is the upstream port of the
      Alpine Ridge PCIe switch and it has no functions other than 0 (the bridge
      itself).  When we get ACPI Notify() to the root port resulting from
      connecting a USB-C device, Linux tries to read PCI_VENDOR_ID from device 0,
      function 2 which of course always returns 0xffffffff because there is no
      such function and we never find the device.
      
      In Windows this works fine.
      
      Now, since we get ACPI Notify() to the root port and not to the PXSX device
      we should actually start our scan from there as well and not from the
      non-existent PXSX device.  Fix this by checking presence of the slot itself
      (function 0) if we fail to do that otherwise.
      
      While there use pci_bus_read_dev_vendor_id() in get_slot_status(), which is
      the recommended way to read Device and Vendor IDs of devices on PCI buses.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=198557Reported-by: default avatarMike Lothian <mike@fireburn.co.uk>
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      63aa8d89
    • Hans de Goede's avatar
      ACPI / video: Add quirk to force acpi-video backlight on Samsung 670Z5E · bd69c85f
      Hans de Goede authored
      commit bbf03861 upstream.
      
      Just like many other Samsung models, the 670Z5E needs to use the acpi-video
      backlight interface rather then the native one for backlight control to
      work, add a quirk for this.
      
      Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1557060
      Cc: All applicable <stable@vger.kernel.org>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd69c85f
    • Dan Carpenter's avatar
      regmap: Fix reversed bounds check in regmap_raw_write() · d8ad6cb0
      Dan Carpenter authored
      commit f00e7109 upstream.
      
      We're supposed to be checking that "val_len" is not too large but
      instead we check if it is smaller than the max.
      
      The only function affected would be regmap_i2c_smbus_i2c_write() in
      drivers/base/regmap/regmap-i2c.c.  Strangely that function has its own
      limit check which returns an error if (count >= I2C_SMBUS_BLOCK_MAX) so
      it doesn't look like it has ever been able to do anything except return
      an error.
      
      Fixes: c335931e ("regmap: Add raw_write/read checks for max_raw_write/read sizes")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8ad6cb0
    • Jason Andryuk's avatar
      xen-netfront: Fix hang on device removal · 4c65e94e
      Jason Andryuk authored
      commit c2d2e673 upstream.
      
      A toolstack may delete the vif frontend and backend xenstore entries
      while xen-netfront is in the removal code path.  In that case, the
      checks for xenbus_read_driver_state would return XenbusStateUnknown, and
      xennet_remove would hang indefinitely.  This hang prevents system
      shutdown.
      
      xennet_remove must be able to handle XenbusStateUnknown, and
      netback_changed must also wake up the wake_queue for that state as well.
      
      Fixes: 5b5971df ("xen-netfront: remove warning when unloading module")
      Signed-off-by: default avatarJason Andryuk <jandryuk@gmail.com>
      Cc: Eduardo Otubo <otubo@redhat.com>
      Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4c65e94e
    • Santiago Esteban's avatar
      ARM: dts: at91: sama5d4: fix pinctrl compatible string · 318a306c
      Santiago Esteban authored
      commit 9a06757d upstream.
      
      The compatible string is incorrect. Add atmel,sama5d3-pinctrl since
      it's the appropriate compatible string. Remove the
      atmel,at91rm9200-pinctrl compatible string, this fallback is
      useless, there are too many changes.
      Signed-off-by: default avatarSantiago Esteban <Santiago.Esteban@microchip.com>
      Signed-off-by: default avatarLudovic Desroches <ludovic.desroches@microchip.com>
      Cc: stable@vger.kernel.org #v3.18
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      318a306c
    • Nicolas Ferre's avatar
      ARM: dts: at91: at91sam9g25: fix mux-mask pinctrl property · 31118e88
      Nicolas Ferre authored
      commit e8fd0adf upstream.
      
      There are only 19 PIOB pins having primary names PB0-PB18. Not all of them
      have a 'C' function. So the pinctrl property mask ends up being the same as the
      other SoC of the at91sam9x5 series.
      Reported-by: default avatarMarek Sieranski <marek.sieranski@microchip.com>
      Signed-off-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
      Cc: <stable@vger.kernel.org> # v3.8+
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      31118e88
    • Heinrich Schuchardt's avatar
      usb: musb: gadget: misplaced out of bounds check · e2300789
      Heinrich Schuchardt authored
      commit af6f8529 upstream.
      
      musb->endpoints[] has array size MUSB_C_NUM_EPS.
      We must check array bounds before accessing the array and not afterwards.
      Signed-off-by: default avatarHeinrich Schuchardt <xypron.glpk@gmx.de>
      Signed-off-by: default avatarBin Liu <b-liu@ti.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2300789
    • Vlastimil Babka's avatar
      mm, slab: reschedule cache_reap() on the same CPU · 5a310ab0
      Vlastimil Babka authored
      commit a9f2a846 upstream.
      
      cache_reap() is initially scheduled in start_cpu_timer() via
      schedule_delayed_work_on(). But then the next iterations are scheduled
      via schedule_delayed_work(), i.e. using WORK_CPU_UNBOUND.
      
      Thus since commit ef557180 ("workqueue: schedule WORK_CPU_UNBOUND
      work on wq_unbound_cpumask CPUs") there is no guarantee the future
      iterations will run on the originally intended cpu, although it's still
      preferred.  I was able to demonstrate this with
      /sys/module/workqueue/parameters/debug_force_rr_cpu.  IIUC, it may also
      happen due to migrating timers in nohz context.  As a result, some cpu's
      would be calling cache_reap() more frequently and others never.
      
      This patch uses schedule_delayed_work_on() with the current cpu when
      scheduling the next iteration.
      
      Link: http://lkml.kernel.org/r/20180411070007.32225-1-vbabka@suse.cz
      Fixes: ef557180 ("workqueue: schedule WORK_CPU_UNBOUND work on wq_unbound_cpumask CPUs")
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Acked-by: default avatarPekka Enberg <penberg@kernel.org>
      Acked-by: default avatarChristoph Lameter <cl@linux.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Lai Jiangshan <jiangshanlai@gmail.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Stephen Boyd <sboyd@kernel.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5a310ab0
    • Eric Biggers's avatar
      ipc/shm: fix use-after-free of shm file via remap_file_pages() · b7e06a79
      Eric Biggers authored
      commit 3f05317d upstream.
      
      syzbot reported a use-after-free of shm_file_data(file)->file->f_op in
      shm_get_unmapped_area(), called via sys_remap_file_pages().
      
      Unfortunately it couldn't generate a reproducer, but I found a bug which
      I think caused it.  When remap_file_pages() is passed a full System V
      shared memory segment, the memory is first unmapped, then a new map is
      created using the ->vm_file.  Between these steps, the shm ID can be
      removed and reused for a new shm segment.  But, shm_mmap() only checks
      whether the ID is currently valid before calling the underlying file's
      ->mmap(); it doesn't check whether it was reused.  Thus it can use the
      wrong underlying file, one that was already freed.
      
      Fix this by making the "outer" shm file (the one that gets put in
      ->vm_file) hold a reference to the real shm file, and by making
      __shm_open() require that the file associated with the shm ID matches
      the one associated with the "outer" file.
      
      Taking the reference to the real shm file is needed to fully solve the
      problem, since otherwise sfd->file could point to a freed file, which
      then could be reallocated for the reused shm ID, causing the wrong shm
      segment to be mapped (and without the required permission checks).
      
      Commit 1ac0b6de ("ipc/shm: handle removed segments gracefully in
      shm_mmap()") almost fixed this bug, but it didn't go far enough because
      it didn't consider the case where the shm ID is reused.
      
      The following program usually reproduces this bug:
      
      	#include <stdlib.h>
      	#include <sys/shm.h>
      	#include <sys/syscall.h>
      	#include <unistd.h>
      
      	int main()
      	{
      		int is_parent = (fork() != 0);
      		srand(getpid());
      		for (;;) {
      			int id = shmget(0xF00F, 4096, IPC_CREAT|0700);
      			if (is_parent) {
      				void *addr = shmat(id, NULL, 0);
      				usleep(rand() % 50);
      				while (!syscall(__NR_remap_file_pages, addr, 4096, 0, 0, 0));
      			} else {
      				usleep(rand() % 50);
      				shmctl(id, IPC_RMID, NULL);
      			}
      		}
      	}
      
      It causes the following NULL pointer dereference due to a 'struct file'
      being used while it's being freed.  (I couldn't actually get a KASAN
      use-after-free splat like in the syzbot report.  But I think it's
      possible with this bug; it would just take a more extraordinary race...)
      
      	BUG: unable to handle kernel NULL pointer dereference at 0000000000000058
      	PGD 0 P4D 0
      	Oops: 0000 [#1] SMP NOPTI
      	CPU: 9 PID: 258 Comm: syz_ipc Not tainted 4.16.0-05140-gf8cf2f16 #189
      	Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-20171110_100015-anatol 04/01/2014
      	RIP: 0010:d_inode include/linux/dcache.h:519 [inline]
      	RIP: 0010:touch_atime+0x25/0xd0 fs/inode.c:1724
      	[...]
      	Call Trace:
      	 file_accessed include/linux/fs.h:2063 [inline]
      	 shmem_mmap+0x25/0x40 mm/shmem.c:2149
      	 call_mmap include/linux/fs.h:1789 [inline]
      	 shm_mmap+0x34/0x80 ipc/shm.c:465
      	 call_mmap include/linux/fs.h:1789 [inline]
      	 mmap_region+0x309/0x5b0 mm/mmap.c:1712
      	 do_mmap+0x294/0x4a0 mm/mmap.c:1483
      	 do_mmap_pgoff include/linux/mm.h:2235 [inline]
      	 SYSC_remap_file_pages mm/mmap.c:2853 [inline]
      	 SyS_remap_file_pages+0x232/0x310 mm/mmap.c:2769
      	 do_syscall_64+0x64/0x1a0 arch/x86/entry/common.c:287
      	 entry_SYSCALL_64_after_hwframe+0x42/0xb7
      
      [ebiggers@google.com: add comment]
        Link: http://lkml.kernel.org/r/20180410192850.235835-1-ebiggers3@gmail.com
      Link: http://lkml.kernel.org/r/20180409043039.28915-1-ebiggers3@gmail.com
      Reported-by: syzbot+d11f321e7f1923157eac80aa990b446596f46439@syzkaller.appspotmail.com
      Fixes: c8d78c18 ("mm: replace remap_file_pages() syscall with emulation")
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Acked-by: default avatarDavidlohr Bueso <dbueso@suse.de>
      Cc: Manfred Spraul <manfred@colorfullife.com>
      Cc: "Eric W . Biederman" <ebiederm@xmission.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b7e06a79
    • Takashi Iwai's avatar
      resource: fix integer overflow at reallocation · 0a2f9fe1
      Takashi Iwai authored
      commit 60bb83b8 upstream.
      
      We've got a bug report indicating a kernel panic at booting on an x86-32
      system, and it turned out to be the invalid PCI resource assigned after
      reallocation.  __find_resource() first aligns the resource start address
      and resets the end address with start+size-1 accordingly, then checks
      whether it's contained.  Here the end address may overflow the integer,
      although resource_contains() still returns true because the function
      validates only start and end address.  So this ends up with returning an
      invalid resource (start > end).
      
      There was already an attempt to cover such a problem in the commit
      47ea91b4 ("Resource: fix wrong resource window calculation"), but
      this case is an overseen one.
      
      This patch adds the validity check of the newly calculated resource for
      avoiding the integer overflow problem.
      
      Bugzilla: http://bugzilla.opensuse.org/show_bug.cgi?id=1086739
      Link: http://lkml.kernel.org/r/s5hpo37d5l8.wl-tiwai@suse.de
      Fixes: 23c570a6 ("resource: ability to resize an allocated resource")
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Reported-by: default avatarMichael Henders <hendersm@shaw.ca>
      Tested-by: default avatarMichael Henders <hendersm@shaw.ca>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Ram Pai <linuxram@us.ibm.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a2f9fe1
    • Andrew Morton's avatar
      fs/reiserfs/journal.c: add missing resierfs_warning() arg · bc6305c0
      Andrew Morton authored
      commit 9ad553ab upstream.
      
      One use of the reiserfs_warning() macro in journal_init_dev() is missing
      a parameter, causing the following warning:
      
        REISERFS warning (device loop0): journal_init_dev: Cannot open '%s': %i journal_init_dev:
      
      This also causes a WARN_ONCE() warning in the vsprintf code, and then a
      panic if panic_on_warn is set.
      
        Please remove unsupported %/ in format string
        WARNING: CPU: 1 PID: 4480 at lib/vsprintf.c:2138 format_decode+0x77f/0x830 lib/vsprintf.c:2138
        Kernel panic - not syncing: panic_on_warn set ...
      
      Just add another string argument to the macro invocation.
      
      Addresses https://syzkaller.appspot.com/bug?id=0627d4551fdc39bf1ef5d82cd9eef587047f7718
      
      Link: http://lkml.kernel.org/r/d678ebe1-6f54-8090-df4c-b9affad62293@infradead.orgSigned-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: <syzbot+6bd77b88c1977c03f584@syzkaller.appspotmail.com>
      Tested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Acked-by: default avatarJeff Mahoney <jeffm@suse.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Jan Kara <jack@suse.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc6305c0
    • Richard Weinberger's avatar
      ubi: Reject MLC NAND · 78cc9472
      Richard Weinberger authored
      commit b5094b7f upstream.
      
      While UBI and UBIFS seem to work at first sight with MLC NAND, you will
      most likely lose all your data upon a power-cut or due to read/write
      disturb.
      In order to protect users from bad surprises, refuse to attach to MLC
      NAND.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Acked-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
      Acked-by: default avatarArtem Bityutskiy <dedekind1@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      78cc9472
    • Romain Izard's avatar
      ubi: Fix error for write access · 782635ba
      Romain Izard authored
      commit 78a8dfba upstream.
      
      When opening a device with write access, ubiblock_open returns an error
      code. Currently, this error code is -EPERM, but this is not the right
      value.
      
      The open function for other block devices returns -EROFS when opening
      read-only devices with FMODE_WRITE set. When used with dm-verity, the
      veritysetup userspace tool is expecting EROFS, and refuses to use the
      ubiblock device.
      
      Use -EROFS for ubiblock as well. As a result, veritysetup accepts the
      ubiblock device as valid.
      
      Cc: stable@vger.kernel.org
      Fixes: 9d54c8a3 (UBI: R/O block driver on top of UBI volumes)
      Signed-off-by: default avatarRomain Izard <romain.izard.pro@gmail.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      782635ba
    • Richard Weinberger's avatar
      ubi: fastmap: Don't flush fastmap work on detach · 75ee8566
      Richard Weinberger authored
      commit 29b7a6fa upstream.
      
      At this point UBI volumes have already been free()'ed and fastmap can no
      longer access these data structures.
      Reported-by: default avatarMartin Townsend <mtownsend1973@gmail.com>
      Fixes: 74cdaf24 ("UBI: Fastmap: Fix memory leaks while closing the WL sub-system")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75ee8566
    • Richard Weinberger's avatar
      ubifs: Check ubifs_wbuf_sync() return code · a4e98ec0
      Richard Weinberger authored
      commit aac17948 upstream.
      
      If ubifs_wbuf_sync() fails we must not write a master node with the
      dirty marker cleared.
      Otherwise it is possible that in case of an IO error while syncing we
      mark the filesystem as clean and UBIFS refuses to recover upon next
      mount.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 1e51764a ("UBIFS: add new flash file system")
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a4e98ec0
    • Tejun Heo's avatar
      tty: make n_tty_read() always abort if hangup is in progress · 12ed237c
      Tejun Heo authored
      commit 28b0f8a6 upstream.
      
      A tty is hung up by __tty_hangup() setting file->f_op to
      hung_up_tty_fops, which is skipped on ttys whose write operation isn't
      tty_write().  This means that, for example, /dev/console whose write
      op is redirected_tty_write() is never actually marked hung up.
      
      Because n_tty_read() uses the hung up status to decide whether to
      abort the waiting readers, the lack of hung-up marking can lead to the
      following scenario.
      
       1. A session contains two processes.  The leader and its child.  The
          child ignores SIGHUP.
      
       2. The leader exits and starts disassociating from the controlling
          terminal (/dev/console).
      
       3. __tty_hangup() skips setting f_op to hung_up_tty_fops.
      
       4. SIGHUP is delivered and ignored.
      
       5. tty_ldisc_hangup() is invoked.  It wakes up the waits which should
          clear the read lockers of tty->ldisc_sem.
      
       6. The reader wakes up but because tty_hung_up_p() is false, it
          doesn't abort and goes back to sleep while read-holding
          tty->ldisc_sem.
      
       7. The leader progresses to tty_ldisc_lock() in tty_ldisc_hangup()
          and is now stuck in D sleep indefinitely waiting for
          tty->ldisc_sem.
      
      The following is Alan's explanation on why some ttys aren't hung up.
      
       http://lkml.kernel.org/r/20171101170908.6ad08580@alans-desktop
      
       1. It broke the serial consoles because they would hang up and close
          down the hardware. With tty_port that *should* be fixable properly
          for any cases remaining.
      
       2. The console layer was (and still is) completely broken and doens't
          refcount properly. So if you turn on console hangups it breaks (as
          indeed does freeing consoles and half a dozen other things).
      
      As neither can be fixed quickly, this patch works around the problem
      by introducing a new flag, TTY_HUPPING, which is used solely to tell
      n_tty_read() that hang-up is in progress for the console and the
      readers should be aborted regardless of the hung-up status of the
      device.
      
      The following is a sample hung task warning caused by this issue.
      
        INFO: task agetty:2662 blocked for more than 120 seconds.
              Not tainted 4.11.3-dbg-tty-lockup-02478-gfd6c7ee-dirty #28
        "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
            0  2662      1 0x00000086
        Call Trace:
         __schedule+0x267/0x890
         schedule+0x36/0x80
         schedule_timeout+0x23c/0x2e0
         ldsem_down_write+0xce/0x1f6
         tty_ldisc_lock+0x16/0x30
         tty_ldisc_hangup+0xb3/0x1b0
         __tty_hangup+0x300/0x410
         disassociate_ctty+0x6c/0x290
         do_exit+0x7ef/0xb00
         do_group_exit+0x3f/0xa0
         get_signal+0x1b3/0x5d0
         do_signal+0x28/0x660
         exit_to_usermode_loop+0x46/0x86
         do_syscall_64+0x9c/0xb0
         entry_SYSCALL64_slow_path+0x25/0x25
      
      The following is the repro.  Run "$PROG /dev/console".  The parent
      process hangs in D state.
      
        #include <sys/types.h>
        #include <sys/stat.h>
        #include <sys/wait.h>
        #include <sys/ioctl.h>
        #include <fcntl.h>
        #include <unistd.h>
        #include <stdio.h>
        #include <stdlib.h>
        #include <errno.h>
        #include <signal.h>
        #include <time.h>
        #include <termios.h>
      
        int main(int argc, char **argv)
        {
      	  struct sigaction sact = { .sa_handler = SIG_IGN };
      	  struct timespec ts1s = { .tv_sec = 1 };
      	  pid_t pid;
      	  int fd;
      
      	  if (argc < 2) {
      		  fprintf(stderr, "test-hung-tty /dev/$TTY\n");
      		  return 1;
      	  }
      
      	  /* fork a child to ensure that it isn't already the session leader */
      	  pid = fork();
      	  if (pid < 0) {
      		  perror("fork");
      		  return 1;
      	  }
      
      	  if (pid > 0) {
      		  /* top parent, wait for everyone */
      		  while (waitpid(-1, NULL, 0) >= 0)
      			  ;
      		  if (errno != ECHILD)
      			  perror("waitpid");
      		  return 0;
      	  }
      
      	  /* new session, start a new session and set the controlling tty */
      	  if (setsid() < 0) {
      		  perror("setsid");
      		  return 1;
      	  }
      
      	  fd = open(argv[1], O_RDWR);
      	  if (fd < 0) {
      		  perror("open");
      		  return 1;
      	  }
      
      	  if (ioctl(fd, TIOCSCTTY, 1) < 0) {
      		  perror("ioctl");
      		  return 1;
      	  }
      
      	  /* fork a child, sleep a bit and exit */
      	  pid = fork();
      	  if (pid < 0) {
      		  perror("fork");
      		  return 1;
      	  }
      
      	  if (pid > 0) {
      		  nanosleep(&ts1s, NULL);
      		  printf("Session leader exiting\n");
      		  exit(0);
      	  }
      
      	  /*
      	   * The child ignores SIGHUP and keeps reading from the controlling
      	   * tty.  Because SIGHUP is ignored, the child doesn't get killed on
      	   * parent exit and the bug in n_tty makes the read(2) block the
      	   * parent's control terminal hangup attempt.  The parent ends up in
      	   * D sleep until the child is explicitly killed.
      	   */
      	  sigaction(SIGHUP, &sact, NULL);
      	  printf("Child reading tty\n");
      	  while (1) {
      		  char buf[1024];
      
      		  if (read(fd, buf, sizeof(buf)) < 0) {
      			  perror("read");
      			  return 1;
      		  }
      	  }
      
      	  return 0;
        }
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Alan Cox <alan@llwyncelyn.cymru>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      12ed237c
    • Ville Syrjälä's avatar
      x86/hweight: Don't clobber %rdi · 34a6851c
      Ville Syrjälä authored
      commit 65ea11ec upstream.
      
      The caller expects %rdi to remain intact, push+pop it make that happen.
      
      Fixes the following kind of explosions on my core2duo machine when
      trying to reboot or shut down:
      
        general protection fault: 0000 [#1] PREEMPT SMP
        Modules linked in: i915 i2c_algo_bit drm_kms_helper cfbfillrect syscopyarea cfbimgblt sysfillrect sysimgblt fb_sys_fops cfbcopyarea drm netconsole configfs binfmt_misc iTCO_wdt psmouse pcspkr snd_hda_codec_idt e100 coretemp hwmon snd_hda_codec_generic i2c_i801 mii i2c_smbus lpc_ich mfd_core snd_hda_intel uhci_hcd snd_hda_codec snd_hwdep snd_hda_core ehci_pci 8250 ehci_hcd snd_pcm 8250_base usbcore evdev serial_core usb_common parport_pc parport snd_timer snd soundcore
        CPU: 0 PID: 3070 Comm: reboot Not tainted 4.8.0-rc1-perf-dirty #69
        Hardware name:                  /D946GZIS, BIOS TS94610J.86A.0087.2007.1107.1049 11/07/2007
        task: ffff88012a0b4080 task.stack: ffff880123850000
        RIP: 0010:[<ffffffff81003c92>]  [<ffffffff81003c92>] x86_perf_event_update+0x52/0xc0
        RSP: 0018:ffff880123853b60  EFLAGS: 00010087
        RAX: 0000000000000001 RBX: ffff88012fc0a3c0 RCX: 000000000000001e
        RDX: 0000000000000000 RSI: 0000000040000000 RDI: ffff88012b014800
        RBP: ffff880123853b88 R08: ffffffffffffffff R09: 0000000000000000
        R10: ffffea0004a012c0 R11: ffffea0004acedc0 R12: ffffffff80000001
        R13: ffff88012b0149c0 R14: ffff88012b014800 R15: 0000000000000018
        FS:  00007f8b155cd700(0000) GS:ffff88012fc00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00007f8b155f5000 CR3: 000000012a2d7000 CR4: 00000000000006f0
        Stack:
         ffff88012fc0a3c0 ffff88012b014800 0000000000000004 0000000000000001
         ffff88012fc1b750 ffff880123853bb0 ffffffff81003d59 ffff88012b014800
         ffff88012fc0a3c0 ffff88012b014800 ffff880123853bd8 ffffffff81003e13
        Call Trace:
         [<ffffffff81003d59>] x86_pmu_stop+0x59/0xd0
         [<ffffffff81003e13>] x86_pmu_del+0x43/0x140
         [<ffffffff8111705d>] event_sched_out.isra.105+0xbd/0x260
         [<ffffffff8111738d>] __perf_remove_from_context+0x2d/0xb0
         [<ffffffff8111745d>] __perf_event_exit_context+0x4d/0x70
         [<ffffffff810c8826>] generic_exec_single+0xb6/0x140
         [<ffffffff81117410>] ? __perf_remove_from_context+0xb0/0xb0
         [<ffffffff81117410>] ? __perf_remove_from_context+0xb0/0xb0
         [<ffffffff810c898f>] smp_call_function_single+0xdf/0x140
         [<ffffffff81113d27>] perf_event_exit_cpu_context+0x87/0xc0
         [<ffffffff81113d73>] perf_reboot+0x13/0x40
         [<ffffffff8107578a>] notifier_call_chain+0x4a/0x70
         [<ffffffff81075ad7>] __blocking_notifier_call_chain+0x47/0x60
         [<ffffffff81075b06>] blocking_notifier_call_chain+0x16/0x20
         [<ffffffff81076a1d>] kernel_restart_prepare+0x1d/0x40
         [<ffffffff81076ae2>] kernel_restart+0x12/0x60
         [<ffffffff81076d56>] SYSC_reboot+0xf6/0x1b0
         [<ffffffff811a823c>] ? mntput_no_expire+0x2c/0x1b0
         [<ffffffff811a83e4>] ? mntput+0x24/0x40
         [<ffffffff811894fc>] ? __fput+0x16c/0x1e0
         [<ffffffff811895ae>] ? ____fput+0xe/0x10
         [<ffffffff81072fc3>] ? task_work_run+0x83/0xa0
         [<ffffffff81001623>] ? exit_to_usermode_loop+0x53/0xc0
         [<ffffffff8100105a>] ? trace_hardirqs_on_thunk+0x1a/0x1c
         [<ffffffff81076e6e>] SyS_reboot+0xe/0x10
         [<ffffffff814c4ba5>] entry_SYSCALL_64_fastpath+0x18/0xa3
        Code: 7c 4c 8d af c0 01 00 00 49 89 fe eb 10 48 09 c2 4c 89 e0 49 0f b1 55 00 4c 39 e0 74 35 4d 8b a6 c0 01 00 00 41 8b 8e 60 01 00 00 <0f> 33 8b 35 6e 02 8c 00 48 c1 e2 20 85 f6 7e d2 48 89 d3 89 cf
        RIP  [<ffffffff81003c92>] x86_perf_event_update+0x52/0xc0
         RSP <ffff880123853b60>
        ---[ end trace 7ec95181faf211be ]---
        note: reboot[3070] exited with preempt_count 2
      
      Cc: Borislav Petkov <bp@suse.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Fixes: f5967101 ("x86/hweight: Get rid of the special calling convention")
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Matthias Kaehlcke <mka@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      34a6851c
    • Borislav Petkov's avatar
      x86/hweight: Get rid of the special calling convention · c597f987
      Borislav Petkov authored
      commit f5967101 upstream.
      
      People complained about ARCH_HWEIGHT_CFLAGS and how it throws a wrench
      into kcov, lto, etc, experimentations.
      
      Add asm versions for __sw_hweight{32,64}() and do explicit saving and
      restoring of clobbered registers. This gets rid of the special calling
      convention. We get to call those functions on !X86_FEATURE_POPCNT CPUs.
      
      We still need to hardcode POPCNT and register operands as some old gas
      versions which we support, do not know about POPCNT.
      
      Btw, remove redundant REX prefix from 32-bit POPCNT because alternatives
      can do padding now.
      Suggested-by: default avatarH. Peter Anvin <hpa@zytor.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1464605787-20603-1-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarMatthias Kaehlcke <mka@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c597f987
    • Phil Elwell's avatar
      lan78xx: Correctly indicate invalid OTP · 3d069960
      Phil Elwell authored
      
      [ Upstream commit 4bfc3380 ]
      
      lan78xx_read_otp tries to return -EINVAL in the event of invalid OTP
      content, but the value gets overwritten before it is returned and the
      read goes ahead anyway. Make the read conditional as it should be
      and preserve the error code.
      
      Fixes: 55d7de9d ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
      Signed-off-by: default avatarPhil Elwell <phil@raspberrypi.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3d069960
    • Tejaswi Tanikella's avatar
      slip: Check if rstate is initialized before uncompressing · 46043941
      Tejaswi Tanikella authored
      
      [ Upstream commit 3f01ddb9 ]
      
      On receiving a packet the state index points to the rstate which must be
      used to fill up IP and TCP headers. But if the state index points to a
      rstate which is unitialized, i.e. filled with zeros, it gets stuck in an
      infinite loop inside ip_fast_csum trying to compute the ip checsum of a
      header with zero length.
      
      89.666953:   <2> [<ffffff9dd3e94d38>] slhc_uncompress+0x464/0x468
      89.666965:   <2> [<ffffff9dd3e87d88>] ppp_receive_nonmp_frame+0x3b4/0x65c
      89.666978:   <2> [<ffffff9dd3e89dd4>] ppp_receive_frame+0x64/0x7e0
      89.666991:   <2> [<ffffff9dd3e8a708>] ppp_input+0x104/0x198
      89.667005:   <2> [<ffffff9dd3e93868>] pppopns_recv_core+0x238/0x370
      89.667027:   <2> [<ffffff9dd4428fc8>] __sk_receive_skb+0xdc/0x250
      89.667040:   <2> [<ffffff9dd3e939e4>] pppopns_recv+0x44/0x60
      89.667053:   <2> [<ffffff9dd4426848>] __sock_queue_rcv_skb+0x16c/0x24c
      89.667065:   <2> [<ffffff9dd4426954>] sock_queue_rcv_skb+0x2c/0x38
      89.667085:   <2> [<ffffff9dd44f7358>] raw_rcv+0x124/0x154
      89.667098:   <2> [<ffffff9dd44f7568>] raw_local_deliver+0x1e0/0x22c
      89.667117:   <2> [<ffffff9dd44c8ba0>] ip_local_deliver_finish+0x70/0x24c
      89.667131:   <2> [<ffffff9dd44c92f4>] ip_local_deliver+0x100/0x10c
      
      ./scripts/faddr2line vmlinux slhc_uncompress+0x464/0x468 output:
       ip_fast_csum at arch/arm64/include/asm/checksum.h:40
       (inlined by) slhc_uncompress at drivers/net/slip/slhc.c:615
      
      Adding a variable to indicate if the current rstate is initialized. If
      such a packet arrives, move to toss state.
      Signed-off-by: default avatarTejaswi Tanikella <tejaswit@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      46043941
    • Bassem Boubaker's avatar
      cdc_ether: flag the Cinterion AHS8 modem by gemalto as WWAN · 085c9c4b
      Bassem Boubaker authored
      
      [ Upstream commit 53765341 ]
      
      The Cinterion AHS8 is a 3G device with one embedded WWAN interface
      using cdc_ether as a driver.
      
      The modem is controlled via AT commands through the exposed TTYs.
      
      AT+CGDCONT write command can be used to activate or deactivate a WWAN
      connection for a PDP context defined with the same command. UE
      supports one WWAN adapter.
      Signed-off-by: default avatarBassem Boubaker <bassem.boubaker@actia.fr>
      Acked-by: default avatarOliver Neukum <oneukum@suse.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      085c9c4b
    • Marek Szyprowski's avatar
      hwmon: (ina2xx) Fix access to uninitialized mutex · 09293a7b
      Marek Szyprowski authored
      commit 0c4c5860 upstream.
      
      Initialize data->config_lock mutex before it is used by the driver code.
      
      This fixes following warning on Odroid XU3 boards:
      
      INFO: trying to register non-static key.
      the code is fine but needs lockdep annotation.
      turning off the locking correctness validator.
      CPU: 5 PID: 1 Comm: swapper/0 Not tainted 4.15.0-rc7-next-20180115-00001-gb75575dee3f2 #107
      Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
      [<c0111504>] (unwind_backtrace) from [<c010dbec>] (show_stack+0x10/0x14)
      [<c010dbec>] (show_stack) from [<c09b3f74>] (dump_stack+0x90/0xc8)
      [<c09b3f74>] (dump_stack) from [<c0179528>] (register_lock_class+0x1c0/0x59c)
      [<c0179528>] (register_lock_class) from [<c017bd1c>] (__lock_acquire+0x78/0x1850)
      [<c017bd1c>] (__lock_acquire) from [<c017de30>] (lock_acquire+0xc8/0x2b8)
      [<c017de30>] (lock_acquire) from [<c09ca59c>] (__mutex_lock+0x60/0xa0c)
      [<c09ca59c>] (__mutex_lock) from [<c09cafd0>] (mutex_lock_nested+0x1c/0x24)
      [<c09cafd0>] (mutex_lock_nested) from [<c068b0d0>] (ina2xx_set_shunt+0x70/0xb0)
      [<c068b0d0>] (ina2xx_set_shunt) from [<c068b218>] (ina2xx_probe+0x88/0x1b0)
      [<c068b218>] (ina2xx_probe) from [<c0673d90>] (i2c_device_probe+0x1e0/0x2d0)
      [<c0673d90>] (i2c_device_probe) from [<c053a268>] (driver_probe_device+0x2b8/0x4a0)
      [<c053a268>] (driver_probe_device) from [<c053a54c>] (__driver_attach+0xfc/0x120)
      [<c053a54c>] (__driver_attach) from [<c05384cc>] (bus_for_each_dev+0x58/0x7c)
      [<c05384cc>] (bus_for_each_dev) from [<c0539590>] (bus_add_driver+0x174/0x250)
      [<c0539590>] (bus_add_driver) from [<c053b5e0>] (driver_register+0x78/0xf4)
      [<c053b5e0>] (driver_register) from [<c0675ef0>] (i2c_register_driver+0x38/0xa8)
      [<c0675ef0>] (i2c_register_driver) from [<c0102b40>] (do_one_initcall+0x48/0x18c)
      [<c0102b40>] (do_one_initcall) from [<c0e00df0>] (kernel_init_freeable+0x110/0x1d4)
      [<c0e00df0>] (kernel_init_freeable) from [<c09c8120>] (kernel_init+0x8/0x114)
      [<c09c8120>] (kernel_init) from [<c01010b4>] (ret_from_fork+0x14/0x20)
      
      Fixes: 5d389b12 ("hwmon: (ina2xx) Make calibration register value fixed")
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      [backport to v4.4.y/v4.9.y: context changes]
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09293a7b
    • Sudhir Sreedharan's avatar
      rtl8187: Fix NULL pointer dereference in priv->conf_mutex · 2f2c030c
      Sudhir Sreedharan authored
      commit 7972326a upstream.
      
      This can be reproduced by bind/unbind the driver multiple times
      in AM3517 board.
      
      Analysis revealed that rtl8187_start() was invoked before probe
      finishes(ie. before the mutex is initialized).
      
       INFO: trying to register non-static key.
       the code is fine but needs lockdep annotation.
       turning off the locking correctness validator.
       CPU: 0 PID: 821 Comm: wpa_supplicant Not tainted 4.9.80-dirty #250
       Hardware name: Generic AM3517 (Flattened Device Tree)
       [<c010e0d8>] (unwind_backtrace) from [<c010beac>] (show_stack+0x10/0x14)
       [<c010beac>] (show_stack) from [<c017401c>] (register_lock_class+0x4f4/0x55c)
       [<c017401c>] (register_lock_class) from [<c0176fe0>] (__lock_acquire+0x74/0x1938)
       [<c0176fe0>] (__lock_acquire) from [<c0178cfc>] (lock_acquire+0xfc/0x23c)
       [<c0178cfc>] (lock_acquire) from [<c08aa2f8>] (mutex_lock_nested+0x50/0x3b0)
       [<c08aa2f8>] (mutex_lock_nested) from [<c05f5bf8>] (rtl8187_start+0x2c/0xd54)
       [<c05f5bf8>] (rtl8187_start) from [<c082dea0>] (drv_start+0xa8/0x320)
       [<c082dea0>] (drv_start) from [<c084d1d4>] (ieee80211_do_open+0x2bc/0x8e4)
       [<c084d1d4>] (ieee80211_do_open) from [<c069be94>] (__dev_open+0xb8/0x120)
       [<c069be94>] (__dev_open) from [<c069c11c>] (__dev_change_flags+0x88/0x14c)
       [<c069c11c>] (__dev_change_flags) from [<c069c1f8>] (dev_change_flags+0x18/0x48)
       [<c069c1f8>] (dev_change_flags) from [<c0710b08>] (devinet_ioctl+0x738/0x840)
       [<c0710b08>] (devinet_ioctl) from [<c067925c>] (sock_ioctl+0x164/0x2f4)
       [<c067925c>] (sock_ioctl) from [<c02883f8>] (do_vfs_ioctl+0x8c/0x9d0)
       [<c02883f8>] (do_vfs_ioctl) from [<c0288da8>] (SyS_ioctl+0x6c/0x7c)
       [<c0288da8>] (SyS_ioctl) from [<c0107760>] (ret_fast_syscall+0x0/0x1c)
       Unable to handle kernel NULL pointer dereference at virtual address 00000000
       pgd = cd1ec000
       [00000000] *pgd=8d1de831, *pte=00000000, *ppte=00000000
       Internal error: Oops: 817 [#1] PREEMPT ARM
       Modules linked in:
       CPU: 0 PID: 821 Comm: wpa_supplicant Not tainted 4.9.80-dirty #250
       Hardware name: Generic AM3517 (Flattened Device Tree)
       task: ce73eec0 task.stack: cd1ea000
       PC is at mutex_lock_nested+0xe8/0x3b0
       LR is at mutex_lock_nested+0xd0/0x3b0
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSudhir Sreedharan <ssreedharan@mvista.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f2c030c
    • Al Viro's avatar
      getname_kernel() needs to make sure that ->name != ->iname in long case · 5da4880c
      Al Viro authored
      commit 30ce4d19 upstream.
      
      missed it in "kill struct filename.separate" several years ago.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5da4880c
    • Vasily Gorbik's avatar
      s390/ipl: ensure loadparm valid flag is set · 93da190b
      Vasily Gorbik authored
      commit 15deb080 upstream.
      
      When loadparm is set in reipl parm block, the kernel should also set
      DIAG308_FLAGS_LP_VALID flag.
      
      This fixes loadparm ignoring during z/VM fcp -> ccw reipl and kvm direct
      boot -> ccw reipl.
      
      Cc: <stable@vger.kernel.org>
      Reviewed-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93da190b
    • Julian Wiedmann's avatar
      s390/qdio: don't merge ERROR output buffers · 7dc2c154
      Julian Wiedmann authored
      commit 0cf1e051 upstream.
      
      On an Output queue, both EMPTY and PENDING buffer states imply that the
      buffer is ready for completion-processing by the upper-layer drivers.
      
      So for a non-QEBSM Output queue, get_buf_states() merges mixed
      batches of PENDING and EMPTY buffers into one large batch of EMPTY
      buffers. The upper-layer driver (ie. qeth) later distuingishes PENDING
      from EMPTY by inspecting the slsb_state for
      QDIO_OUTBUF_STATE_FLAG_PENDING.
      
      But the merge logic in get_buf_states() contains a bug that causes us to
      erronously also merge ERROR buffers into such a batch of EMPTY buffers
      (ERROR is 0xaf, EMPTY is 0xa1; so ERROR & EMPTY == EMPTY).
      Effectively, most outbound ERROR buffers are currently discarded
      silently and processed as if they had succeeded.
      
      Note that this affects _all_ non-QEBSM device types, not just IQD with CQ.
      
      Fix it by explicitly spelling out the exact conditions for merging.
      
      For extracting the "get initial state" part out of the loop, this relies
      on the fact that get_buf_states() is never called with a count of 0. The
      QEBSM path already strictly requires this, and the two callers with
      variable 'count' make sure of it.
      
      Fixes: 104ea556 ("qdio: support asynchronous delivery of storage blocks")
      Cc: <stable@vger.kernel.org> #v3.2+
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.vnet.ibm.com>
      Reviewed-by: default avatarUrsula Braun <ubraun@linux.vnet.ibm.com>
      Reviewed-by: default avatarBenjamin Block <bblock@linux.vnet.ibm.com>
      Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7dc2c154
    • Julian Wiedmann's avatar
      s390/qdio: don't retry EQBS after CCQ 96 · f614d9f7
      Julian Wiedmann authored
      commit dae55b6f upstream.
      
      Immediate retry of EQBS after CCQ 96 means that we potentially misreport
      the state of buffers inspected during the first EQBS call.
      
      This occurs when
      1. the first EQBS finds all inspected buffers still in the initial state
         set by the driver (ie INPUT EMPTY or OUTPUT PRIMED),
      2. the EQBS terminates early with CCQ 96, and
      3. by the time that the second EQBS comes around, the state of those
         previously inspected buffers has changed.
      
      If the state reported by the second EQBS is 'driver-owned', all we know
      is that the previous buffers are driver-owned now as well. But we can't
      tell if they all have the same state. So for instance
      - the second EQBS reports OUTPUT EMPTY, but any number of the previous
        buffers could be OUTPUT ERROR by now,
      - the second EQBS reports OUTPUT ERROR, but any number of the previous
        buffers could be OUTPUT EMPTY by now.
      
      Effectively, this can result in both over- and underreporting of errors.
      
      If the state reported by the second EQBS is 'HW-owned', that doesn't
      guarantee that the previous buffers have not been switched to
      driver-owned in the mean time. So for instance
      - the second EQBS reports INPUT EMPTY, but any number of the previous
        buffers could be INPUT PRIMED (or INPUT ERROR) by now.
      
      This would result in failure to process pending work on the queue. If
      it's the final check before yielding initiative, this can cause
      a (temporary) queue stall due to IRQ avoidance.
      
      Fixes: 25f269f1 ("[S390] qdio: EQBS retry after CCQ 96")
      Cc: <stable@vger.kernel.org> #v3.2+
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.vnet.ibm.com>
      Reviewed-by: default avatarBenjamin Block <bblock@linux.vnet.ibm.com>
      Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f614d9f7
    • Tetsuo Handa's avatar
      block/loop: fix deadlock after loop_set_status · 123d3064
      Tetsuo Handa authored
      commit 1e047eaa upstream.
      
      syzbot is reporting deadlocks at __blkdev_get() [1].
      
      ----------------------------------------
      [   92.493919] systemd-udevd   D12696   525      1 0x00000000
      [   92.495891] Call Trace:
      [   92.501560]  schedule+0x23/0x80
      [   92.502923]  schedule_preempt_disabled+0x5/0x10
      [   92.504645]  __mutex_lock+0x416/0x9e0
      [   92.510760]  __blkdev_get+0x73/0x4f0
      [   92.512220]  blkdev_get+0x12e/0x390
      [   92.518151]  do_dentry_open+0x1c3/0x2f0
      [   92.519815]  path_openat+0x5d9/0xdc0
      [   92.521437]  do_filp_open+0x7d/0xf0
      [   92.527365]  do_sys_open+0x1b8/0x250
      [   92.528831]  do_syscall_64+0x6e/0x270
      [   92.530341]  entry_SYSCALL_64_after_hwframe+0x42/0xb7
      
      [   92.931922] 1 lock held by systemd-udevd/525:
      [   92.933642]  #0: 00000000a2849e25 (&bdev->bd_mutex){+.+.}, at: __blkdev_get+0x73/0x4f0
      ----------------------------------------
      
      The reason of deadlock turned out that wait_event_interruptible() in
      blk_queue_enter() got stuck with bdev->bd_mutex held at __blkdev_put()
      due to q->mq_freeze_depth == 1.
      
      ----------------------------------------
      [   92.787172] a.out           S12584   634    633 0x80000002
      [   92.789120] Call Trace:
      [   92.796693]  schedule+0x23/0x80
      [   92.797994]  blk_queue_enter+0x3cb/0x540
      [   92.803272]  generic_make_request+0xf0/0x3d0
      [   92.807970]  submit_bio+0x67/0x130
      [   92.810928]  submit_bh_wbc+0x15e/0x190
      [   92.812461]  __block_write_full_page+0x218/0x460
      [   92.815792]  __writepage+0x11/0x50
      [   92.817209]  write_cache_pages+0x1ae/0x3d0
      [   92.825585]  generic_writepages+0x5a/0x90
      [   92.831865]  do_writepages+0x43/0xd0
      [   92.836972]  __filemap_fdatawrite_range+0xc1/0x100
      [   92.838788]  filemap_write_and_wait+0x24/0x70
      [   92.840491]  __blkdev_put+0x69/0x1e0
      [   92.841949]  blkdev_close+0x16/0x20
      [   92.843418]  __fput+0xda/0x1f0
      [   92.844740]  task_work_run+0x87/0xb0
      [   92.846215]  do_exit+0x2f5/0xba0
      [   92.850528]  do_group_exit+0x34/0xb0
      [   92.852018]  SyS_exit_group+0xb/0x10
      [   92.853449]  do_syscall_64+0x6e/0x270
      [   92.854944]  entry_SYSCALL_64_after_hwframe+0x42/0xb7
      
      [   92.943530] 1 lock held by a.out/634:
      [   92.945105]  #0: 00000000a2849e25 (&bdev->bd_mutex){+.+.}, at: __blkdev_put+0x3c/0x1e0
      ----------------------------------------
      
      The reason of q->mq_freeze_depth == 1 turned out that loop_set_status()
      forgot to call blk_mq_unfreeze_queue() at error paths for
      info->lo_encrypt_type != NULL case.
      
      ----------------------------------------
      [   37.509497] CPU: 2 PID: 634 Comm: a.out Tainted: G        W        4.16.0+ #457
      [   37.513608] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/19/2017
      [   37.518832] RIP: 0010:blk_freeze_queue_start+0x17/0x40
      [   37.521778] RSP: 0018:ffffb0c2013e7c60 EFLAGS: 00010246
      [   37.524078] RAX: 0000000000000000 RBX: ffff8b07b1519798 RCX: 0000000000000000
      [   37.527015] RDX: 0000000000000002 RSI: ffffb0c2013e7cc0 RDI: ffff8b07b1519798
      [   37.529934] RBP: ffffb0c2013e7cc0 R08: 0000000000000008 R09: 47a189966239b898
      [   37.532684] R10: dad78b99b278552f R11: 9332dca72259d5ef R12: ffff8b07acd73678
      [   37.535452] R13: 0000000000004c04 R14: 0000000000000000 R15: ffff8b07b841e940
      [   37.538186] FS:  00007fede33b9740(0000) GS:ffff8b07b8e80000(0000) knlGS:0000000000000000
      [   37.541168] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   37.543590] CR2: 00000000206fdf18 CR3: 0000000130b30006 CR4: 00000000000606e0
      [   37.546410] Call Trace:
      [   37.547902]  blk_freeze_queue+0x9/0x30
      [   37.549968]  loop_set_status+0x67/0x3c0 [loop]
      [   37.549975]  loop_set_status64+0x3b/0x70 [loop]
      [   37.549986]  lo_ioctl+0x223/0x810 [loop]
      [   37.549995]  blkdev_ioctl+0x572/0x980
      [   37.550003]  block_ioctl+0x34/0x40
      [   37.550006]  do_vfs_ioctl+0xa7/0x6d0
      [   37.550017]  ksys_ioctl+0x6b/0x80
      [   37.573076]  SyS_ioctl+0x5/0x10
      [   37.574831]  do_syscall_64+0x6e/0x270
      [   37.576769]  entry_SYSCALL_64_after_hwframe+0x42/0xb7
      ----------------------------------------
      
      [1] https://syzkaller.appspot.com/bug?id=cd662bc3f6022c0979d01a262c318fab2ee9b56fSigned-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Reported-by: default avatarsyzbot <bot+48594378e9851eab70bcd6f99327c7db58c5a28a@syzkaller.appspotmail.com>
      Fixes: ecdd0959 ("block/loop: fix race between I/O and set_status")
      Cc: Ming Lei <tom.leiming@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: stable <stable@vger.kernel.org>
      Cc: Jens Axboe <axboe@fb.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      123d3064
    • Greg Kroah-Hartman's avatar
      Revert "perf tests: Decompress kernel module before objdump" · 9580b588
      Greg Kroah-Hartman authored
      This reverts commit b0761b57 which is
      commit 94df1040 upstream.
      
      It breaks the build of perf on 4.4.y, so I'm dropping it.
      Reported-by: default avatarPavlos Parissis <pavlos.parissis@gmail.com>
      Reported-by: default avatarLei Chen <chenl.lei@gmail.com>
      Reported-by: default avatarMaxime Hadjinlian <maxime.hadjinlian@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: kernel-team@lge.com
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Sasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9580b588
    • Arnd Bergmann's avatar
      radeon: hide pointless #warning when compile testing · f83eb6b5
      Arnd Bergmann authored
      commit c02216ac upstream.
      
      In randconfig testing, we sometimes get this warning:
      
      drivers/gpu/drm/radeon/radeon_object.c: In function 'radeon_bo_create':
      drivers/gpu/drm/radeon/radeon_object.c:242:2: error: #warning Please enable CONFIG_MTRR and CONFIG_X86_PAT for better performance thanks to write-combining [-Werror=cpp]
       #warning Please enable CONFIG_MTRR and CONFIG_X86_PAT for better performance \
      
      This is rather annoying since almost all other code produces no build-time
      output unless we have found a real bug. We already fixed this in the
      amdgpu driver in commit 31bb90f1 ("drm/amdgpu: shut up #warning for
      compile testing") by adding a CONFIG_COMPILE_TEST check last year and
      agreed to do the same here, but both Michel and I then forgot about it
      until I came across the issue again now.
      
      For stable kernels, as this is one of very few remaining randconfig
      warnings in 4.14.
      
      Cc: stable@vger.kernel.org
      Link: https://patchwork.kernel.org/patch/9550009/Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f83eb6b5
    • Adrian Hunter's avatar
      perf intel-pt: Fix timestamp following overflow · f20002ad
      Adrian Hunter authored
      commit 91d29b28 upstream.
      
      timestamp_insn_cnt is used to estimate the timestamp based on the number of
      instructions since the last known timestamp.
      
      If the estimate is not accurate enough decoding might not be correctly
      synchronized with side-band events causing more trace errors.
      
      However there are always timestamps following an overflow, so the
      estimate is not needed and can indeed result in more errors.
      
      Suppress the estimate by setting timestamp_insn_cnt to zero.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/1520431349-30689-5-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f20002ad
    • Adrian Hunter's avatar
      perf intel-pt: Fix error recovery from missing TIP packet · 292924ec
      Adrian Hunter authored
      commit 1c196a6c upstream.
      
      When a TIP packet is expected but there is a different packet, it is an
      error. However the unexpected packet might be something important like a
      TSC packet, so after the error, it is necessary to continue from there,
      rather than the next packet. That is achieved by setting pkt_step to
      zero.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/1520431349-30689-4-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      292924ec
    • Adrian Hunter's avatar
      perf intel-pt: Fix sync_switch · 410ce740
      Adrian Hunter authored
      commit 63d8e38f upstream.
      
      sync_switch is a facility to synchronize decoding more closely with the
      point in the kernel when the context actually switched.
      
      The flag when sync_switch is enabled was global to the decoding, whereas
      it is really specific to the CPU.
      
      The trace data for different CPUs is put on different queues, so add
      sync_switch to the intel_pt_queue structure and use that in preference
      to the global setting in the intel_pt structure.
      
      That fixes problems decoding one CPU's trace because sync_switch was
      disabled on a different CPU's queue.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/1520431349-30689-3-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      410ce740
    • Adrian Hunter's avatar
      perf intel-pt: Fix overlap detection to identify consecutive buffers correctly · aedc7bff
      Adrian Hunter authored
      commit 117db4b2 upstream.
      
      Overlap detection was not not updating the buffer's 'consecutive' flag.
      Marking buffers consecutive has the advantage that decoding begins from
      the start of the buffer instead of the first PSB. Fix overlap detection
      to identify consecutive buffers correctly.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/1520431349-30689-2-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aedc7bff
    • Helge Deller's avatar
      parisc: Fix out of array access in match_pci_device() · 8778f3e6
      Helge Deller authored
      commit 615b2665 upstream.
      
      As found by the ubsan checker, the value of the 'index' variable can be
      out of range for the bc[] array:
      
      UBSAN: Undefined behaviour in arch/parisc/kernel/drivers.c:655:21
      index 6 is out of range for type 'char [6]'
      Backtrace:
       [<104fa850>] __ubsan_handle_out_of_bounds+0x68/0x80
       [<1019d83c>] check_parent+0xc0/0x170
       [<1019d91c>] descend_children+0x30/0x6c
       [<1059e164>] device_for_each_child+0x60/0x98
       [<1019cd54>] parse_tree_node+0x40/0x54
       [<1019d86c>] check_parent+0xf0/0x170
       [<1019d91c>] descend_children+0x30/0x6c
       [<1059e164>] device_for_each_child+0x60/0x98
       [<1019d938>] descend_children+0x4c/0x6c
       [<1059e164>] device_for_each_child+0x60/0x98
       [<1019cd54>] parse_tree_node+0x40/0x54
       [<1019cffc>] hwpath_to_device+0xa4/0xc4
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8778f3e6
    • Mauro Carvalho Chehab's avatar
      media: v4l2-compat-ioctl32: don't oops on overlay · 96adc5c8
      Mauro Carvalho Chehab authored
      commit 85ea29f1 upstream.
      
      At put_v4l2_window32(), it tries to access kp->clips. However,
      kp points to an userspace pointer. So, it should be obtained
      via get_user(), otherwise it can OOPS:
      
       vivid-000: ==================  END STATUS  ==================
       BUG: unable to handle kernel paging request at 00000000fffb18e0
       IP: [<ffffffffc05468d9>] __put_v4l2_format32+0x169/0x220 [videodev]
       PGD 3f5776067 PUD 3f576f067 PMD 3f5769067 PTE 800000042548f067
       Oops: 0001 [#1] SMP
       Modules linked in: vivid videobuf2_vmalloc videobuf2_memops v4l2_dv_timings videobuf2_core v4l2_common videodev media xt_CHECKSUM iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack tun bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables bluetooth rfkill binfmt_misc snd_hda_codec_hdmi i915 snd_hda_intel snd_hda_controller snd_hda_codec intel_rapl x86_pkg_temp_thermal snd_hwdep intel_powerclamp snd_pcm coretemp snd_seq_midi kvm_intel kvm snd_seq_midi_event snd_rawmidi i2c_algo_bit drm_kms_helper snd_seq drm crct10dif_pclmul e1000e snd_seq_device crc32_pclmul snd_timer ghash_clmulni_intel snd mei_me mei ptp pps_core soundcore lpc_ich video crc32c_intel [last unloaded: media]
       CPU: 2 PID: 28332 Comm: v4l2-compliance Not tainted 3.18.102+ #107
       Hardware name:                  /NUC5i7RYB, BIOS RYBDWi35.86A.0364.2017.0511.0949 05/11/2017
       task: ffff8804293f8000 ti: ffff8803f5640000 task.ti: ffff8803f5640000
       RIP: 0010:[<ffffffffc05468d9>]  [<ffffffffc05468d9>] __put_v4l2_format32+0x169/0x220 [videodev]
       RSP: 0018:ffff8803f5643e28  EFLAGS: 00010246
       RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00000000fffb1ab4
       RDX: 00000000fffb1a68 RSI: 00000000fffb18d8 RDI: 00000000fffb1aa8
       RBP: ffff8803f5643e48 R08: 0000000000000001 R09: ffff8803f54b0378
       R10: 0000000000000000 R11: 0000000000000168 R12: 00000000fffb18c0
       R13: 00000000fffb1a94 R14: 00000000fffb18c8 R15: 0000000000000000
       FS:  0000000000000000(0000) GS:ffff880456d00000(0063) knlGS:00000000f7100980
       CS:  0010 DS: 002b ES: 002b CR0: 0000000080050033
       CR2: 00000000fffb18e0 CR3: 00000003f552b000 CR4: 00000000003407e0
       Stack:
        00000000fffb1a94 00000000c0cc5640 0000000000000056 ffff8804274f3600
        ffff8803f5643ed0 ffffffffc0547e16 0000000000000003 ffff8803f5643eb0
        ffffffff81301460 ffff88009db44b01 ffff880441942520 ffff8800c0d05640
       Call Trace:
        [<ffffffffc0547e16>] v4l2_compat_ioctl32+0x12d6/0x1b1d [videodev]
        [<ffffffff81301460>] ? file_has_perm+0x70/0xc0
        [<ffffffff81252a2c>] compat_SyS_ioctl+0xec/0x1200
        [<ffffffff8173241a>] sysenter_dispatch+0x7/0x21
       Code: 00 00 48 8b 80 48 c0 ff ff 48 83 e8 38 49 39 c6 0f 87 2b ff ff ff 49 8d 45 1c e8 a3 ce e3 c0 85 c0 0f 85 1a ff ff ff 41 8d 40 ff <4d> 8b 64 24 20 41 89 d5 48 8d 44 40 03 4d 8d 34 c4 eb 15 0f 1f
       RIP  [<ffffffffc05468d9>] __put_v4l2_format32+0x169/0x220 [videodev]
       RSP <ffff8803f5643e28>
       CR2: 00000000fffb18e0
      
      Tested with vivid driver on Kernel v3.18.102.
      
      Same bug happens upstream too:
      
       BUG: KASAN: user-memory-access in __put_v4l2_format32+0x98/0x4d0 [videodev]
       Read of size 8 at addr 00000000ffe48400 by task v4l2-compliance/8713
      
       CPU: 0 PID: 8713 Comm: v4l2-compliance Not tainted 4.16.0-rc4+ #108
       Hardware name:  /NUC5i7RYB, BIOS RYBDWi35.86A.0364.2017.0511.0949 05/11/2017
       Call Trace:
        dump_stack+0x5c/0x7c
        kasan_report+0x164/0x380
        ? __put_v4l2_format32+0x98/0x4d0 [videodev]
        __put_v4l2_format32+0x98/0x4d0 [videodev]
        v4l2_compat_ioctl32+0x1aec/0x27a0 [videodev]
        ? __fsnotify_inode_delete+0x20/0x20
        ? __put_v4l2_format32+0x4d0/0x4d0 [videodev]
        compat_SyS_ioctl+0x646/0x14d0
        ? do_ioctl+0x30/0x30
        do_fast_syscall_32+0x191/0x3f4
        entry_SYSENTER_compat+0x6b/0x7a
       ==================================================================
       Disabling lock debugging due to kernel taint
       BUG: unable to handle kernel paging request at 00000000ffe48400
       IP: __put_v4l2_format32+0x98/0x4d0 [videodev]
       PGD 3a22fb067 P4D 3a22fb067 PUD 39b6f0067 PMD 39b6f1067 PTE 80000003256af067
       Oops: 0001 [#1] SMP KASAN
       Modules linked in: vivid videobuf2_vmalloc videobuf2_dma_contig videobuf2_memops v4l2_tpg v4l2_dv_timings videobuf2_v4l2 videobuf2_common v4l2_common videodev xt_CHECKSUM iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack libcrc32c tun bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables bluetooth rfkill ecdh_generic binfmt_misc snd_hda_codec_hdmi intel_rapl x86_pkg_temp_thermal intel_powerclamp i915 coretemp snd_hda_intel snd_hda_codec kvm_intel snd_hwdep snd_hda_core kvm snd_pcm irqbypass crct10dif_pclmul crc32_pclmul snd_seq_midi ghash_clmulni_intel snd_seq_midi_event i2c_algo_bit intel_cstate snd_rawmidi intel_uncore snd_seq drm_kms_helper e1000e snd_seq_device snd_timer intel_rapl_perf
        drm ptp snd mei_me mei lpc_ich pps_core soundcore video crc32c_intel
       CPU: 0 PID: 8713 Comm: v4l2-compliance Tainted: G    B            4.16.0-rc4+ #108
       Hardware name:  /NUC5i7RYB, BIOS RYBDWi35.86A.0364.2017.0511.0949 05/11/2017
       RIP: 0010:__put_v4l2_format32+0x98/0x4d0 [videodev]
       RSP: 0018:ffff8803b9be7d30 EFLAGS: 00010282
       RAX: 0000000000000000 RBX: ffff8803ac983e80 RCX: ffffffff8cd929f2
       RDX: 1ffffffff1d0a149 RSI: 0000000000000297 RDI: 0000000000000297
       RBP: 00000000ffe485c0 R08: fffffbfff1cf5123 R09: ffffffff8e7a8948
       R10: 0000000000000001 R11: fffffbfff1cf5122 R12: 00000000ffe483e0
       R13: 00000000ffe485c4 R14: ffff8803ac985918 R15: 00000000ffe483e8
       FS:  0000000000000000(0000) GS:ffff880407400000(0063) knlGS:00000000f7a46980
       CS:  0010 DS: 002b ES: 002b CR0: 0000000080050033
       CR2: 00000000ffe48400 CR3: 00000003a83f2003 CR4: 00000000003606f0
       Call Trace:
        v4l2_compat_ioctl32+0x1aec/0x27a0 [videodev]
        ? __fsnotify_inode_delete+0x20/0x20
        ? __put_v4l2_format32+0x4d0/0x4d0 [videodev]
        compat_SyS_ioctl+0x646/0x14d0
        ? do_ioctl+0x30/0x30
        do_fast_syscall_32+0x191/0x3f4
        entry_SYSENTER_compat+0x6b/0x7a
       Code: 4c 89 f7 4d 8d 7c 24 08 e8 e6 a4 69 cb 48 8b 83 98 1a 00 00 48 83 e8 10 49 39 c7 0f 87 9d 01 00 00 49 8d 7c 24 20 e8 c8 a4 69 cb <4d> 8b 74 24 20 4c 89 ef 4c 89 fe ba 10 00 00 00 e8 23 d9 08 cc
       RIP: __put_v4l2_format32+0x98/0x4d0 [videodev] RSP: ffff8803b9be7d30
       CR2: 00000000ffe48400
      
      cc: stable@vger.kernel.org
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Reviewed-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Reviewed-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      96adc5c8
  2. 13 Apr, 2018 4 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.4.128 · dbb78762
      Greg Kroah-Hartman authored
      dbb78762
    • Greg Hackmann's avatar
      Revert "xhci: plat: Register shutdown for xhci_plat" · f02dc098
      Greg Hackmann authored
      Pixel 2 field testers reported that when they tried to reboot their
      phones with some USB devices plugged in, the reboot would get wedged and
      eventually trigger watchdog reset.  Once the Pixel kernel team found a
      reliable repro case, they narrowed it down to this commit's 4.4.y
      backport.  Reverting the change made the issue go away.
      
      This reverts commit b07c1251.
      Signed-off-by: default avatarGreg Hackmann <ghackmann@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f02dc098
    • David Ahern's avatar
      vrf: Fix use after free and double free in vrf_finish_output · 56f8ae4e
      David Ahern authored
      commit 82dd0d2a upstream.
      
      Miguel reported an skb use after free / double free in vrf_finish_output
      when neigh_output returns an error. The vrf driver should return after
      the call to neigh_output as it takes over the skb on error path as well.
      
      Patch is a simplified version of Miguel's patch which was written for 4.9,
      and updated to top of tree.
      
      Fixes: 8f58336d ("net: Add ethernet header for pass through VRF device")
      Signed-off-by: default avatarMiguel Fadon Perlines <mfadon@teldat.com>
      Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      [ backport to 4.4 and 4.9 dropped the sock_confirm_neigh and
        changed neigh_output to dst_neigh_output ]
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      56f8ae4e
    • Paolo Abeni's avatar
      ipv6: the entire IPv6 header chain must fit the first fragment · d7d9a326
      Paolo Abeni authored
      
      [ Upstream commit 10b8a3de ]
      
      While building ipv6 datagram we currently allow arbitrary large
      extheaders, even beyond pmtu size. The syzbot has found a way
      to exploit the above to trigger the following splat:
      
      kernel BUG at ./include/linux/skbuff.h:2073!
      invalid opcode: 0000 [#1] SMP KASAN
      Dumping ftrace buffer:
          (ftrace buffer empty)
      Modules linked in:
      CPU: 1 PID: 4230 Comm: syzkaller672661 Not tainted 4.16.0-rc2+ #326
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
      Google 01/01/2011
      RIP: 0010:__skb_pull include/linux/skbuff.h:2073 [inline]
      RIP: 0010:__ip6_make_skb+0x1ac8/0x2190 net/ipv6/ip6_output.c:1636
      RSP: 0018:ffff8801bc18f0f0 EFLAGS: 00010293
      RAX: ffff8801b17400c0 RBX: 0000000000000738 RCX: ffffffff84f01828
      RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff8801b415ac18
      RBP: ffff8801bc18f360 R08: ffff8801b4576844 R09: 0000000000000000
      R10: ffff8801bc18f380 R11: ffffed00367aee4e R12: 00000000000000d6
      R13: ffff8801b415a740 R14: dffffc0000000000 R15: ffff8801b45767c0
      FS:  0000000001535880(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 000000002000b000 CR3: 00000001b4123001 CR4: 00000000001606e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
        ip6_finish_skb include/net/ipv6.h:969 [inline]
        udp_v6_push_pending_frames+0x269/0x3b0 net/ipv6/udp.c:1073
        udpv6_sendmsg+0x2a96/0x3400 net/ipv6/udp.c:1343
        inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:764
        sock_sendmsg_nosec net/socket.c:630 [inline]
        sock_sendmsg+0xca/0x110 net/socket.c:640
        ___sys_sendmsg+0x320/0x8b0 net/socket.c:2046
        __sys_sendmmsg+0x1ee/0x620 net/socket.c:2136
        SYSC_sendmmsg net/socket.c:2167 [inline]
        SyS_sendmmsg+0x35/0x60 net/socket.c:2162
        do_syscall_64+0x280/0x940 arch/x86/entry/common.c:287
        entry_SYSCALL_64_after_hwframe+0x42/0xb7
      RIP: 0033:0x4404c9
      RSP: 002b:00007ffdce35f948 EFLAGS: 00000217 ORIG_RAX: 0000000000000133
      RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004404c9
      RDX: 0000000000000003 RSI: 0000000020001f00 RDI: 0000000000000003
      RBP: 00000000006cb018 R08: 00000000004002c8 R09: 00000000004002c8
      R10: 0000000020000080 R11: 0000000000000217 R12: 0000000000401df0
      R13: 0000000000401e80 R14: 0000000000000000 R15: 0000000000000000
      Code: ff e8 1d 5e b9 fc e9 15 e9 ff ff e8 13 5e b9 fc e9 44 e8 ff ff e8 29
      5e b9 fc e9 c0 e6 ff ff e8 3f f3 80 fc 0f 0b e8 38 f3 80 fc <0f> 0b 49 8d
      87 80 00 00 00 4d 8d 87 84 00 00 00 48 89 85 20 fe
      RIP: __skb_pull include/linux/skbuff.h:2073 [inline] RSP: ffff8801bc18f0f0
      RIP: __ip6_make_skb+0x1ac8/0x2190 net/ipv6/ip6_output.c:1636 RSP:
      ffff8801bc18f0f0
      
      As stated by RFC 7112 section 5:
      
         When a host fragments an IPv6 datagram, it MUST include the entire
         IPv6 Header Chain in the First Fragment.
      
      So this patch addresses the issue dropping datagrams with excessive
      extheader length. It also updates the error path to report to the
      calling socket nonnegative pmtu values.
      
      The issue apparently predates git history.
      
      v1 -> v2: cleanup error path, as per Eric's suggestion
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Reported-by: syzbot+91e6f9932ff122fa4410@syzkaller.appspotmail.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d7d9a326