14 Oct, 2013

13 commits

  • [ Upstream commit b86783587b3d1d552326d955acee37eac48800f1 ]

    In commit 8ed781668dd49 ("flow_keys: include thoff into flow_keys for
    later usage"), we missed that existing code was using nhoff as a
    temporary variable that could not always contain transport header
    offset.

    This is not a problem for TCP/UDP because port offset (@poff)
    is 0 for these protocols.

    Signed-off-by: Eric Dumazet
    Cc: Daniel Borkmann
    Cc: Nikolay Aleksandrov
    Acked-by: Nikolay Aleksandrov
    Acked-by: Daniel Borkmann
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Eric Dumazet
     
  • [ Upstream commit 50d1784ee4683f073c0362ee360bfae7a3333d6c ]

    commit 416186fbf8c5b4e4465 ("net: Split core bits of netdev_pick_tx
    into __netdev_pick_tx") added a bug that disables caching of queue
    index in the socket.

    This is the source of packet reorders for TCP flows, and
    again this is happening more often when using FQ pacing.

    Old code was doing

    if (queue_index != old_index)
    sk_tx_queue_set(sk, queue_index);

    Alexander renamed the variables but forgot to change sk_tx_queue_set()
    2nd parameter.

    if (queue_index != new_index)
    sk_tx_queue_set(sk, queue_index);

    This means we store -1 over and over in sk->sk_tx_queue_mapping

    Signed-off-by: Eric Dumazet
    Cc: Alexander Duyck
    Acked-by: Alexander Duyck
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Eric Dumazet
     
  • [ Upstream commit 88362ad8f9a6cea787420b57cc27ccacef000dbe ]

    This was originally reported in [1] and posted by Neil Horman [2], he said:

    Fix up a missed null pointer check in the asconf code. If we don't find
    a local address, but we pass in an address length of more than 1, we may
    dereference a NULL laddr pointer. Currently this can't happen, as the only
    users of the function pass in the value 1 as the addrcnt parameter, but
    its not hot path, and it doesn't hurt to check for NULL should that ever
    be the case.

    The callpath from sctp_asconf_mgmt() looks okay. But this could be triggered
    from sctp_setsockopt_bindx() call with SCTP_BINDX_REM_ADDR and addrcnt > 1
    while passing all possible addresses from the bind list to SCTP_BINDX_REM_ADDR
    so that we do *not* find a single address in the association's bind address
    list that is not in the packed array of addresses. If this happens when we
    have an established association with ASCONF-capable peers, then we could get
    a NULL pointer dereference as we only check for laddr == NULL && addrcnt == 1
    and call later sctp_make_asconf_update_ip() with NULL laddr.

    BUT: this actually won't happen as sctp_bindx_rem() will catch such a case
    and return with an error earlier. As this is incredably unintuitive and error
    prone, add a check to catch at least future bugs here. As Neil says, its not
    hot path. Introduced by 8a07eb0a5 ("sctp: Add ASCONF operation on the
    single-homed host").

    [1] http://www.spinics.net/lists/linux-sctp/msg02132.html
    [2] http://www.spinics.net/lists/linux-sctp/msg02133.html

    Reported-by: Dan Carpenter
    Signed-off-by: Neil Horman
    Signed-off-by: Daniel Borkmann
    Cc: Michio Honda
    Acked-By: Neil Horman
    Acked-by: Vlad Yasevich
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Daniel Borkmann
     
  • [ Upstream commit a0fb05d1aef0f5df936f80b726d1b3bfd4275f95 ]

    If we do not add braces around ...

    mask |= POLLERR |
    sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;

    ... then this condition always evaluates to true as POLLERR is
    defined as 8 and binary or'd with whatever result comes out of
    sock_flag(). Hence instead of (X | Y) ? A : B, transform it into
    X | (Y ? A : B). Unfortunatelty, commit 8facd5fb73 ("net: fix
    smatch warnings inside datagram_poll") forgot about SCTP. :-(

    Introduced by 7d4c04fc170 ("net: add option to enable error queue
    packets waking select").

    Signed-off-by: Daniel Borkmann
    Cc: Jacob Keller
    Acked-by: Neil Horman
    Acked-by: Vlad Yasevich
    Acked-by: Jacob Keller
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Daniel Borkmann
     
  • [ Upstream commit ae7b4e1f213aa659aedf9c6ecad0bf5f0476e1e2 ]

    When the kernel is compiled with CONFIG_IPV6_SUBTREES, and we return
    with an error in fn = fib6_add_1(), then error codes are encoded into
    the return pointer e.g. ERR_PTR(-ENOENT). In such an error case, we
    write the error code into err and jump to out, hence enter the if(err)
    condition. Now, if CONFIG_IPV6_SUBTREES is enabled, we check for:

    if (pn != fn && pn->leaf == rt)
    ...
    if (pn != fn && !pn->leaf && !(pn->fn_flags & RTN_RTINFO))
    ...

    Since pn is NULL and fn is f.e. ERR_PTR(-ENOENT), then pn != fn
    evaluates to true and causes a NULL-pointer dereference on further
    checks on pn. Fix it, by setting both NULL in error case, so that
    pn != fn already evaluates to false and no further dereference
    takes place.

    This was first correctly implemented in 4a287eba2 ("IPv6 routing,
    NLM_F_* flag support: REPLACE and EXCL flags support, warn about
    missing CREATE flag"), but the bug got later on introduced by
    188c517a0 ("ipv6: return errno pointers consistently for fib6_add_1()").

    Signed-off-by: Daniel Borkmann
    Cc: Lin Ming
    Cc: Matti Vaittinen
    Cc: Hannes Frederic Sowa
    Acked-by: Hannes Frederic Sowa
    Acked-by: Matti Vaittinen
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Daniel Borkmann
     
  • [ Upstream commit 8112b1fe071be01a28a774ed55909e6f4b29712d ]

    In rfc4942 and rfc2460 I cannot find anything which would implicate to
    drop packets which have only padding in tlv.

    Current behaviour breaks TAHI Test v6LC.1.2.6.

    Problem was intruduced in:
    9b905fe6843 "ipv6/exthdrs: strict Pad1 and PadN check"

    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Jiri Pirko
     
  • [ Upstream commit e2e5c4c07caf810d7849658dca42f598b3938e21 ]

    Signed-off-by: Dave Jones
    Acked-by: Neal Cardwell
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Dave Jones
     
  • [ Upstream commit 0c1db731bfcf3a9fd6c58132134f8b0f423552f0 ]

    The indentation here implies this was meant to be a multi-line if.

    Introduced several years back in commit c85c2951d4da1236e32f1858db418221e624aba5
    ("caif: Handle dev_queue_xmit errors.")

    Signed-off-by: Dave Jones
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Dave Jones
     
  • commit bc197eedef1ae082ec662c64c3f4aa302821fb7a upstream.

    27ce4050 ("HID: fix data access in implement()") by mistake removed
    a setting of buffer size in hidp. Fix that by putting it back.

    Reported-by: kbuild test robot
    Signed-off-by: Jiri Kosina
    Signed-off-by: Greg Kroah-Hartman

    Jiri Kosina
     
  • commit 27ce405039bfe6d3f4143415c638f56a3df77dca upstream.

    implement() is setting bytes in LE data stream. In case the data is not
    aligned to 64bits, it reads past the allocated buffer. It doesn't really
    change any value there (it's properly bitmasked), but in case that this
    read past the boundary hits a page boundary, pagefault happens when
    accessing 64bits of 'x' in implement(), and kernel oopses.

    This happens much more often when numbered reports are in use, as the
    initial 8bit skip in the buffer makes the whole process work on values
    which are not aligned to 64bits.

    This problem dates back to attempts in 2005 and 2006 to make implement()
    and extract() as generic as possible, and even back then the problem
    was realized by Adam Kroperlin, but falsely assumed to be impossible
    to cause any harm:

    http://www.mail-archive.com/linux-usb-devel@lists.sourceforge.net/msg47690.html

    I have made several attempts at fixing it "on the spot" directly in
    implement(), but the results were horrible; the special casing for processing
    last 64bit chunk and switching to different math makes it unreadable mess.

    I therefore took a path to allocate a few bytes more which will never make
    it into final report, but are there as a cushion for all the 64bit math
    operations happening in implement() and extract().

    All callers of hid_output_report() are converted at the same time to allocate
    the buffer by newly introduced hid_alloc_report_buf() helper.

    Bruno noticed that the whole raw_size test can be dropped as well, as
    hid_alloc_report_buf() makes sure that the buffer is always of a proper
    size.

    Reviewed-by: Benjamin Tissoires
    Acked-by: Gustavo Padovan
    Signed-off-by: Jiri Kosina
    Signed-off-by: Greg Kroah-Hartman

    Jiri Kosina
     
  • commit 58f09e00ae095e46ef9edfcf3a5fd9ccdfad065e upstream.

    The arg64 struct has a hole after ->buf_size which isn't cleared. Or if
    any of the calls to copy_from_user() fail then that would cause an
    information leak as well.

    This was assigned CVE-2013-2147.

    Signed-off-by: Dan Carpenter
    Acked-by: Mike Miller
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • commit 627aad1c01da6f881e7f98d71fd928ca0c316b1a upstream.

    The pciinfo struct has a two byte hole after ->dev_fn so stack
    information could be leaked to the user.

    This was assigned CVE-2013-2147.

    Signed-off-by: Dan Carpenter
    Acked-by: Mike Miller
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • commit 6390d88529835a8ad3563fe01a5da89fa52d6db2 upstream.

    When trying to unset a previously-set multicast list (i.e. the new list
    has 0 entries), mwifiex_set_multicast_list() was calling down to
    mwifiex_request_set_multicast_list() while leaving
    mcast_list.num_multicast_addr as an uninitialized value.

    We were arriving at mwifiex_cmd_mac_multicast_adr() which would then
    proceed to do an often huge memcpy of
    mcast_list.num_multicast_addr*ETH_ALEN bytes, causing memory corruption
    and hard to debug crashes.

    Fix this by setting mcast_list.num_multicast_addr to 0 when no multicast
    list is provided. Similarly, fix up the logic in
    mwifiex_request_set_multicast_list() to unset the multicast list that
    was previously sent to the hardware in such cases.

    Signed-off-by: Daniel Drake
    Acked-by: Bing Zhao
    Signed-off-by: John W. Linville
    Signed-off-by: Greg Kroah-Hartman

    Daniel Drake
     

05 Oct, 2013

27 commits

  • Greg Kroah-Hartman
     
  • commit 0ce99f749b3834edeb500e17d6ad17e86b60ff83 upstream.

    Apparently Bspec is wrong in this case here even for gm45. Note that
    Bspec is horribly misguided on i965g/gm, so we don't have any other
    data points besides that it seems to make machines work better.

    With this changes all the bits in PORT_HOTPLUG_STAT for the digital
    ports are ordered the same way. This seems to agree with what register
    dumps from the hpd storm handling code shows, where the LIVE bit and
    the short/long pulse STATUS bits light up at the same time with this
    enumeration (but no with the one from Bspec).

    Also tested on my gm45 which has two DP+ ports, and everything seems
    to still work as expected.

    References: http://www.mail-archive.com/intel-gfx@lists.freedesktop.org/msg23054.html
    Cc: Egbert Eich
    Cc: Jan Niggemann
    Tested-by: Jan Niggemann
    [danvet: Add a big warning that Bspec seems to be wrong for these
    bits, suggested by Jani.]
    Acked-by: Jani Nikula
    Signed-off-by: Daniel Vetter
    Signed-off-by: Greg Kroah-Hartman

    Daniel Vetter
     
  • commit 4028b6c4c03f213260e9290ff3a6b5439aad07ce upstream.

    snd_unregister_device() should return the device type and not stream
    direction.

    Signed-off-by: Liam Girdwood
    Acked-by: Vinod Koul
    Tested-by: Vinod Koul
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Liam Girdwood
     
  • commit 5f4513864304672e6ea9eac60583eeac32e679f2 upstream.

    After reports from Chris and Josh Boyer of a rare crash in applesmc,
    Guenter pointed at the initialization problem fixed below. The patch
    has not been verified to fix the crash, but should be applied
    regardless.

    Reported-by:
    Suggested-by: Guenter Roeck
    Signed-off-by: Henrik Rydberg
    Signed-off-by: Guenter Roeck
    Signed-off-by: Greg Kroah-Hartman

    Henrik Rydberg
     
  • commit 7a9caf59f60e55a8caf96f856713bd0ef0cc25a7 upstream.

    When building a kernel without CONFIG_PM, we get a link
    error from referencing mxs_pm_init in the machine
    descriptor. This defines a macro to NULL for that case.

    Signed-off-by: Arnd Bergmann
    Acked-by: Shawn Guo
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • commit 58d327da9721f7a0f6e46c8dfa5cc5546fd7078a upstream.

    These asics seem to use a mix of the DCE2.x and
    DCE3.2 audio interfaces despite what the register spec
    says.

    Fixes:
    https://bugs.freedesktop.org/show_bug.cgi?id=69729
    https://bugs.freedesktop.org/show_bug.cgi?id=69671

    Signed-off-by: Alex Deucher
    Signed-off-by: Greg Kroah-Hartman

    Alex Deucher
     
  • commit 99d79aa2f3b7729e7290e8bda5d0dd8b0240ec62 upstream.

    When dpm was merged, I added a new asic struct for
    rv6xx, but it never got properly updated when the
    hdmi callbacks were added due to the two patch sets
    being developed in parallel.

    Fixes:
    https://bugs.freedesktop.org/show_bug.cgi?id=69729

    Signed-off-by: Alex Deucher
    Reviewed-by: Christian König
    Signed-off-by: Greg Kroah-Hartman

    Alex Deucher
     
  • commit 4a1132a023eb48cf10522d84c5908d43b612c041 upstream.

    The tests are only usable if the acceleration engines have
    been successfully initialized.

    Based on an initial patch from: Alex Ivanov

    Signed-off-by: Alex Deucher
    Signed-off-by: Greg Kroah-Hartman

    Alex Deucher
     
  • commit 0eb3448aa6b31fbf24c31756aba7940cac5ad6b8 upstream.

    Prevent NULL pointer dereference in case when radeon_ring_fini() did it's job.

    Reading of r100_cp_ring_info and radeon_ring_gfx debugfs entries will lead to a KP if ring buffer was deallocated, e.g. on failed ring test.
    Seen on PA-RISC machine having "radeon: ring test failed (scratch(0x8504)=0xCAFEDEAD)" issue.

    v2: agd5f: add some parens around ring->ready check

    Signed-off-by: Alex Ivanov
    Signed-off-by: Alex Deucher
    Signed-off-by: Greg Kroah-Hartman

    Alex Ivanov
     
  • commit 4ca5a6cba53e13b8fd153b0762b4128fab6a3cfb upstream.

    If the user has forced the driver to use the internal GPU gart
    rather than AGP on an AGP card, force the buffers to vram
    as well.

    Signed-off-by: Alex Deucher
    Reviewed-by: Christian König
    Tested-by: Dieter Nützel
    Signed-off-by: Greg Kroah-Hartman

    Alex Deucher
     
  • commit 8d16f258217f2f583af1fd57c5144aa4bbe73e48 upstream.

    There is no clear cut rules or specs for the retry interval, as there
    are many factors that affect overall response time. Increase the
    interval, and even more so on branch devices which may have limited i2c
    bit rates.

    Signed-off-by: Jani Nikula
    Reference: https://bugs.freedesktop.org/show_bug.cgi?id=60263
    Tested-by: Nicolas Suzor
    Reviewed-by: Todd Previte
    Signed-off-by: Daniel Vetter
    Signed-off-by: Greg Kroah-Hartman

    Jani Nikula
     
  • commit 67c72a12254101d4e8d9b9f3a02646ba0be84a2d upstream.

    This regression has been introduced in

    commit 9f11a9e4e50006b615ba94722dfc33ced89664cf
    Author: Daniel Vetter
    Date: Thu Jun 13 00:54:58 2013 +0200

    drm/i915: set up PIPECONF explicitly for i9xx/vlv platforms

    Ville brough up the idea that this is just the pipe A quirk gone
    wrong.

    Note that after resume the bios might or might not have enabled pipe A
    already. We have a bit of magic to make sure that on resume we set up
    a decent mode for pipe A, but I fear if I just smash pipe A to always
    on we'd enable it in a bogus state and hang the hw. Hence the
    readback.

    v2: Clarify the logic a bit as suggested by Chris. Also amend the
    commit message to clarify why we don't unconditionally enable the
    pipe.

    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66462
    References: https://lkml.org/lkml/2013/8/26/238
    Cc: Meelis Roos
    Cc: Chris Wilson
    Cc: Ville Syrjälä
    Reviewed-by: Chris Wilson
    [danvet: Use |= instead of = as suggested by Chris.]
    Signed-off-by: Daniel Vetter
    Signed-off-by: Greg Kroah-Hartman

    Daniel Vetter
     
  • commit 3f6bbd3ffd7b733dd705e494663e5761aa2cb9c1 upstream.

    This doesn't really need to be initialised, but it doesn't hurt,
    silences the compiler, and as it is a counter it makes sense for it to
    start at zero.

    Signed-off-by: NeilBrown
    Signed-off-by: Greg Kroah-Hartman

    NeilBrown
     
  • commit f84cb8a46a771f36a04a02c61ea635c968ed5f6a upstream.

    Workaround the SCSI layer's problematic WRITE SAME heuristics by
    disabling WRITE SAME in the DM multipath device's queue_limits if an
    underlying device disabled it.

    The WRITE SAME heuristics, with both the original commit 5db44863b6eb
    ("[SCSI] sd: Implement support for WRITE SAME") and the updated commit
    66c28f971 ("[SCSI] sd: Update WRITE SAME heuristics"), default to enabling
    WRITE SAME(10) even without successfully determining it is supported.
    After the first failed WRITE SAME the SCSI layer will disable WRITE SAME
    for the device (by setting sdkp->device->no_write_same which results in
    'max_write_same_sectors' in device's queue_limits to be set to 0).

    When a device is stacked ontop of such a SCSI device any changes to that
    SCSI device's queue_limits do not automatically propagate up the stack.
    As such, a DM multipath device will not have its WRITE SAME support
    disabled. This causes the block layer to continue to issue WRITE SAME
    requests to the mpath device which causes paths to fail and (if mpath IO
    isn't configured to queue when no paths are available) it will result in
    actual IO errors to the upper layers.

    This fix doesn't help configurations that have additional devices
    stacked ontop of the mpath device (e.g. LVM created linear DM devices
    ontop). A proper fix that restacks all the queue_limits from the bottom
    of the device stack up will need to be explored if SCSI will continue to
    use this model of optimistically allowing op codes and then disabling
    them after they fail for the first time.

    Before this patch:

    EXT4-fs (dm-6): mounted filesystem with ordered data mode. Opts: (null)
    device-mapper: multipath: XXX snitm debugging: got -EREMOTEIO (-121)
    device-mapper: multipath: XXX snitm debugging: failing WRITE SAME IO with error=-121
    end_request: critical target error, dev dm-6, sector 528
    dm-6: WRITE SAME failed. Manually zeroing.
    device-mapper: multipath: Failing path 8:112.
    end_request: I/O error, dev dm-6, sector 4616
    dm-6: WRITE SAME failed. Manually zeroing.
    end_request: I/O error, dev dm-6, sector 4616
    end_request: I/O error, dev dm-6, sector 5640
    end_request: I/O error, dev dm-6, sector 6664
    end_request: I/O error, dev dm-6, sector 7688
    end_request: I/O error, dev dm-6, sector 524288
    Buffer I/O error on device dm-6, logical block 65536
    lost page write due to I/O error on dm-6
    JBD2: Error -5 detected when updating journal superblock for dm-6-8.
    end_request: I/O error, dev dm-6, sector 524296
    Aborting journal on device dm-6-8.
    end_request: I/O error, dev dm-6, sector 524288
    Buffer I/O error on device dm-6, logical block 65536
    lost page write due to I/O error on dm-6
    JBD2: Error -5 detected when updating journal superblock for dm-6-8.

    # cat /sys/block/sdh/queue/write_same_max_bytes
    0
    # cat /sys/block/dm-6/queue/write_same_max_bytes
    33553920

    After this patch:

    EXT4-fs (dm-6): mounted filesystem with ordered data mode. Opts: (null)
    device-mapper: multipath: XXX snitm debugging: got -EREMOTEIO (-121)
    device-mapper: multipath: XXX snitm debugging: WRITE SAME I/O failed with error=-121
    end_request: critical target error, dev dm-6, sector 528
    dm-6: WRITE SAME failed. Manually zeroing.

    # cat /sys/block/sdh/queue/write_same_max_bytes
    0
    # cat /sys/block/dm-6/queue/write_same_max_bytes
    0

    It should be noted that WRITE SAME support wasn't enabled in DM
    multipath until v3.10.

    Signed-off-by: Mike Snitzer
    Cc: Martin K. Petersen
    Cc: Hannes Reinecke
    Signed-off-by: Greg Kroah-Hartman

    Mike Snitzer
     
  • commit 60e356f381954d79088d0455e357db48cfdd6857 upstream.

    LVM2, since version 2.02.96, creates origin with zero size, then loads
    the snapshot driver and then loads the origin. Consequently, the
    snapshot driver sees the origin size zero and sets the hash size to the
    lower bound 64. Such small hash table causes performance degradation.

    This patch changes it so that the hash size is determined by the size of
    snapshot volume, not minimum of origin and snapshot size. It doesn't
    make sense to set the snapshot size significantly larger than the origin
    size, so we do not need to take origin size into account when
    calculating the hash size.

    Signed-off-by: Mikulas Patocka
    Signed-off-by: Mike Snitzer
    Signed-off-by: Greg Kroah-Hartman

    Mikulas Patocka
     
  • commit 5ea330a75bd86b2b2a01d7b85c516983238306fb upstream.

    The kernel reports a lockdep warning if a snapshot is invalidated because
    it runs out of space.

    The lockdep warning was triggered by commit 0976dfc1d0cd80a4e9dfaf87bd87
    ("workqueue: Catch more locking problems with flush_work()") in v3.5.

    The warning is false positive. The real cause for the warning is that
    the lockdep engine treats different instances of md->lock as a single
    lock.

    This patch is a workaround - we use flush_workqueue instead of flush_work.
    This code path is not performance sensitive (it is called only on
    initialization or invalidation), thus it doesn't matter that we flush the
    whole workqueue.

    The real fix for the problem would be to teach the lockdep engine to treat
    different instances of md->lock as separate locks.

    Signed-off-by: Mikulas Patocka
    Acked-by: Alasdair G Kergon
    Signed-off-by: Mike Snitzer
    Signed-off-by: Greg Kroah-Hartman

    Mikulas Patocka
     
  • commit f123db8e9d6c84c863cb3c44d17e61995dc984fb upstream.

    The put_device(dev) at the bottom of the loop of device_shutdown
    may result in the dev being cleaned up. In device_create_release,
    the dev is kfreed.

    However, device_shutdown attempts to use the dev pointer again after
    put_device by referring to dev->parent.

    Copy the parent pointer instead to avoid this condition.

    This bug was found on Chromium OS's chromeos-3.8, which is based on v3.8.11.
    See bug report : https://code.google.com/p/chromium/issues/detail?id=297842
    This can easily be reproduced when shutting down with
    hidraw devices that report battery condition.
    Two examples are the HP Bluetooth Mouse X4000b and the Apple Magic Mouse.
    For example, with the magic mouse :
    The dev in question is "hidraw0"
    dev->parent is "magicmouse"

    In the course of the shutdown for this device, the input event cleanup calls
    a put on hidraw0, decrementing its reference count.
    When we finally get to put_device(dev) in device_shutdown, kobject_cleanup
    is called and device_create_release does kfree(dev).
    dev->parent is no longer valid, and we may crash in
    put_device(dev->parent).

    This change should be applied on any kernel with this change :
    d1c6c030fcec6f860d9bb6c632a3ebe62e28440b

    Signed-off-by: Benson Leung
    Reviewed-by: Ming Lei
    Signed-off-by: Greg Kroah-Hartman

    Benson Leung
     
  • commit 831abf76643555a99b80a3b54adfa7e4fa0a3259 upstream.

    Trying to read data from the Pegasus Technologies NoteTaker (0e20:0101)
    [1] with the Windows App (EasyNote) works natively but fails when
    Windows is running under KVM (and the USB device handed to KVM).

    The reason is a USB control message
    usb 4-2.2: control urb: bRequestType=22 bRequest=09 wValue=0200 wIndex=0001 wLength=0008
    This goes to endpoint address 0x01 (wIndex); however, endpoint address
    0x01 does not exist. There is an endpoint 0x81 though (same number,
    but other direction); the app may have meant that endpoint instead.

    The kernel thus rejects the IO and thus we see the failure.

    Apparently, Linux is more strict here than Windows ... we can't change
    the Win app easily, so that's a problem.

    It seems that the Win app/driver is buggy here and the driver does not
    behave fully according to the USB HID class spec that it claims to
    belong to. The device seems to happily deal with that though (and
    seems to not really care about this value much).

    So the question is whether the Linux kernel should filter here.
    Rejecting has the risk that somewhat non-compliant userspace apps/
    drivers (most likely in a virtual machine) are prevented from working.
    Not rejecting has the risk of confusing an overly sensitive device with
    such a transfer. Given the fact that Windows does not filter it makes
    this risk rather small though.

    The patch makes the kernel more tolerant: If the endpoint address in
    wIndex does not exist, but an endpoint with toggled direction bit does,
    it will let the transfer through. (It does NOT change the message.)

    With attached patch, the app in Windows in KVM works.
    usb 4-2.2: check_ctrlrecip: process 13073 (qemu-kvm) requesting ep 01 but needs 81

    I suspect this will mostly affect apps in virtual environments; as on
    Linux the apps would have been adapted to the stricter handling of the
    kernel. I have done that for mine[2].

    [1] http://www.pegatech.com/
    [2] https://sourceforge.net/projects/notetakerpen/

    Signed-off-by: Kurt Garloff
    Acked-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Kurt Garloff
     
  • commit 85601f8cf67c56a561a6dd5e130e65fdc179047d upstream.

    Add PCI id for Intel Merrifield

    Signed-off-by: David Cohen
    Signed-off-by: Greg Kroah-Hartman

    David Cohen
     
  • commit b62cd96de3161dfb125a769030eec35a4cab3d3a upstream.

    Add PCI id for Intel BayTrail.

    Signed-off-by: Heikki Krogerus
    Signed-off-by: Felipe Balbi
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     
  • commit ad1260e9fbf768d6bed227d9604ebee76a84aae3 upstream.

    For controller versions greater than 1.6, setting ULPI_PHY_CLK_SEL
    bit when USB_EN bit is already set causes instability issues with
    PHY_CLK_VLD bit. So USB_EN is set only for IP controller version
    below 1.6 before setting ULPI_PHY_CLK_SEL bit

    Signed-off-by: Ramneek Mehresh
    Signed-off-by: Greg Kroah-Hartman

    Ramneek Mehresh
     
  • commit 2606b28aabd7dea1766c23a105e1124c95409c96 upstream.

    There's a bunch of failure exits in ffs_fs_mount() with
    seriously broken recovery logics. Most of that appears to stem
    from misunderstanding of the ->kill_sb() semantics; unlike
    ->put_super() it is called for *all* superblocks of given type,
    no matter how (in)complete the setup had been. ->put_super()
    is called only if ->s_root is not NULL; any failure prior to
    setting ->s_root will have the call of ->put_super() skipped.
    ->kill_sb(), OTOH, awaits every superblock that has come from
    sget().

    Current behaviour of ffs_fs_mount():

    We have struct ffs_sb_fill_data data on stack there. We do
    ffs_dev = functionfs_acquire_dev_callback(dev_name);
    and store that in data.private_data. Then we call mount_nodev(),
    passing it ffs_sb_fill() as a callback. That will either fail
    outright, or manage to call ffs_sb_fill(). There we allocate an
    instance of struct ffs_data, slap the value of ffs_dev (picked
    from data.private_data) into ffs->private_data and overwrite
    data.private_data by storing ffs into an overlapping member
    (data.ffs_data). Then we store ffs into sb->s_fs_info and attempt
    to set the rest of the things up (root inode, root dentry, then
    create /ep0 there). Any of those might fail. Should that
    happen, we get ffs_fs_kill_sb() called before mount_nodev()
    returns. If mount_nodev() fails for any reason whatsoever,
    we proceed to
    functionfs_release_dev_callback(data.ffs_data);

    That's broken in a lot of ways. Suppose the thing has failed in
    allocation of e.g. root inode or dentry. We have
    functionfs_release_dev_callback(ffs);
    ffs_data_put(ffs);
    done by ffs_fs_kill_sb() (ffs accessed via sb->s_fs_info), followed by
    functionfs_release_dev_callback(ffs);
    from ffs_fs_mount() (via data.ffs_data). Note that the second
    functionfs_release_dev_callback() has every chance to be done to freed memory.

    Suppose we fail *before* root inode allocation. What happens then?
    ffs_fs_kill_sb() doesn't do anything to ffs (it's either not called at all,
    or it doesn't have a pointer to ffs stored in sb->s_fs_info). And
    functionfs_release_dev_callback(data.ffs_data);
    is called by ffs_fs_mount(), but here we are in nasal daemon country - we
    are reading from a member of union we'd never stored into. In practice,
    we'll get what we used to store into the overlapping field, i.e. ffs_dev.
    And then we get screwed, since we treat it (struct gfs_ffs_obj * in
    disguise, returned by functionfs_acquire_dev_callback()) as struct
    ffs_data *, pick what would've been ffs_data ->private_data from it
    (*well* past the actual end of the struct gfs_ffs_obj - struct ffs_data
    is much bigger) and poke in whatever it points to.

    FWIW, there's a minor leak on top of all that in case if ffs_sb_fill()
    fails on kstrdup() - ffs is obviously forgotten.

    The thing is, there is no point in playing all those games with union.
    Just allocate and initialize ffs_data *before* calling mount_nodev() and
    pass a pointer to it via data.ffs_data. And once it's stored in
    sb->s_fs_info, clear data.ffs_data, so that ffs_fs_mount() knows that
    it doesn't need to kill the sucker manually - from that point on
    we'll have it done by ->kill_sb().

    Signed-off-by: Al Viro
    Acked-by: Michal Nazarewicz
    Signed-off-by: Greg Kroah-Hartman

    Al Viro
     
  • commit bef073b067a7b1874a6b381e0035bb0516d71a77 upstream.

    Commit 24f531371de1 (USB: EHCI: accept very late isochronous URBs)
    changed the isochronous API provided by ehci-hcd. URBs submitted too
    late, so that the time slots for all their packets have already
    expired, are no longer rejected outright. Instead the submission is
    accepted, and the URB completes normally with a -EXDEV error for each
    packet. This is what client drivers expect.

    This patch implements the same policy in uhci-hcd. It should be
    applied to all kernels containing commit c44b225077bb (UHCI: implement
    new semantics for URB_ISO_ASAP).

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • commit a8693424c751b8247ee19bd8b857f1d4f432b972 upstream.

    Commit 24f531371de1 (USB: EHCI: accept very late isochronous URBs)
    changed the isochronous API provided by ehci-hcd. URBs submitted too
    late, so that the time slots for all their packets have already
    expired, are no longer rejected outright. Instead the submission is
    accepted, and the URB completes normally with a -EXDEV error for each
    packet. This is what client drivers expect.

    This patch implements the same policy in ohci-hcd. The change is more
    complicated than it was in ehci-hcd, because ohci-hcd doesn't scan for
    isochronous completions in the same way as ehci-hcd does. Rather, it
    depends on the hardware adding completed TDs to a "done queue". Some
    OHCI controller don't handle this properly when a TD's time slot has
    already expired, so we have to avoid adding such TDs to the schedule
    in the first place. As a result, if the URB was submitted too late
    then none of its TDs will get put on the schedule, so none of them
    will end up on the done queue, so the driver will never realize that
    the URB should be completed.

    To solve this problem, the patch adds one to urb_priv->td_cnt for such
    URBs, making it larger than urb_priv->length (td_cnt already gets set
    to the number of TD's that had to be skipped because their slots have
    expired). Each time an URB is given back, the finish_urb() routine
    looks to see if urb_priv->td_cnt for the next URB on the same endpoint
    is marked in this way. If so, it gives back the next URB right away.

    This should be applied to all kernels containing commit 815fa7b91761
    (USB: OHCI: fix logic for scheduling isochronous URBs).

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • commit 526867c3ca0caa2e3e846cb993b0f961c33c2abb upstream.

    The halted state of a endpoint cannot be cleared over CLEAR_HALT from a
    user process, because the stopped_td variable was overwritten in the
    handle_stopped_endpoint() function. So the xhci_endpoint_reset() function will
    refuse the reset and communication with device can not run over this endpoint.
    https://bugzilla.kernel.org/show_bug.cgi?id=60699

    Signed-off-by: Florian Wolter
    Signed-off-by: Sarah Sharp
    Cc: Jonghwan Choi
    Signed-off-by: Greg Kroah-Hartman

    Florian Wolter
     
  • commit f875fdbf344b9fde207f66b392c40845dd7e5aa6 upstream.

    Since uhci-hcd, ehci-hcd, and xhci-hcd support runtime PM, the .pm
    field in their pci_driver structures should be protected by CONFIG_PM
    rather than CONFIG_PM_SLEEP. The corresponding change has already
    been made for ohci-hcd.

    Without this change, controllers won't do runtime suspend if system
    suspend or hibernation isn't enabled.

    Signed-off-by: Alan Stern
    CC: Sarah Sharp
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • commit 284d20552461466b04d6bfeafeb1c47a8891b591 upstream.

    When a command times out, the command ring is first aborted,
    and then stopped. If the command ring is empty when it is stopped
    the stop event will point to next command which is not yet set.
    xHCI tries to handle this next event often causing an oops.

    Don't handle command completion events on stopped cmd ring if ring is
    empty.

    This patch should be backported to kernels as old as 3.7, that contain
    the commit b92cc66c047ff7cf587b318fe377061a353c120f "xHCI: add aborting
    command ring function"

    Signed-off-by: Mathias Nyman
    Reported-by: Giovanni
    Signed-off-by: Sarah Sharp
    Signed-off-by: Greg Kroah-Hartman

    Mathias Nyman