commit 7b9d239f0d9f9bbde2c473b642d484dab4bdca79
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Sat May 20 14:22:27 2017 +0200

    Linux 3.18.54

commit 7c1e076eefe76f1522ce94a4d7ce63e42b14438f
Author: Kangjie Lu <kangjielu@gmail.com>
Date:   Tue May 3 16:44:32 2016 -0400

    ALSA: timer: Fix leak in events via snd_timer_user_tinterrupt
    
    commit e4ec8cc8039a7063e24204299b462bd1383184a5 upstream.
    
    The stack object “r1” has a total size of 32 bytes. Its field
    “event” and “val” both contain 4 bytes padding. These 8 bytes
    padding bytes are sent to user without being initialized.
    
    Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bbb79774fcea8b92df051d1d68fcba18d884f860
Author: Kangjie Lu <kangjielu@gmail.com>
Date:   Tue May 3 16:44:20 2016 -0400

    ALSA: timer: Fix leak in events via snd_timer_user_ccallback
    
    commit 9a47e9cff994f37f7f0dbd9ae23740d0f64f9fe6 upstream.
    
    The stack object “r1” has a total size of 32 bytes. Its field
    “event” and “val” both contain 4 bytes padding. These 8 bytes
    padding bytes are sent to user without being initialized.
    
    Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bbcf19d306745832e043e02c7b3d4f4fad82d61e
Author: Kangjie Lu <kangjielu@gmail.com>
Date:   Tue May 3 16:44:07 2016 -0400

    ALSA: timer: Fix leak in SNDRV_TIMER_IOCTL_PARAMS
    
    commit cec8f96e49d9be372fdb0c3836dcf31ec71e457e upstream.
    
    The stack object “tread” has a total size of 32 bytes. Its field
    “event” and “val” both contain 4 bytes padding. These 8 bytes
    padding bytes are sent to user without being initialized.
    
    Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 19f609798f7ea6392028091b42dd53b3c7f9368f
Author: Takashi Iwai <tiwai@suse.de>
Date:   Wed Jan 13 17:48:01 2016 +0100

    ALSA: timer: Fix race among timer ioctls
    
    commit af368027a49a751d6ff4ee9e3f9961f35bb4fede upstream.
    
    ALSA timer ioctls have an open race and this may lead to a
    use-after-free of timer instance object.  A simplistic fix is to make
    each ioctl exclusive.  We have already tread_sem for controlling the
    tread, and extend this as a global mutex to be applied to each ioctl.
    
    The downside is, of course, the worse concurrency.  But these ioctls
    aren't to be parallel accessible, in anyway, so it should be fine to
    serialize there.
    
    Reported-by: Dmitry Vyukov <dvyukov@google.com>
    Tested-by: Dmitry Vyukov <dvyukov@google.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6d4025862a080579362994eeb0095eb78dd801f2
Author: Takashi Iwai <tiwai@suse.de>
Date:   Tue Jan 12 15:36:27 2016 +0100

    ALSA: seq: Fix race at timer setup and close
    
    commit 3567eb6af614dac436c4b16a8d426f9faed639b3 upstream.
    
    ALSA sequencer code has an open race between the timer setup ioctl and
    the close of the client.  This was triggered by syzkaller fuzzer, and
    a use-after-free was caught there as a result.
    
    This patch papers over it by adding a proper queue->timer_mutex lock
    around the timer-related calls in the relevant code path.
    
    Reported-by: Dmitry Vyukov <dvyukov@google.com>
    Tested-by: Dmitry Vyukov <dvyukov@google.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f5efbbc2bd0a4f30c4f312f9d867ff7ef18df2f9
Author: Jann Horn <jannh@google.com>
Date:   Wed Jun 1 11:55:07 2016 +0200

    sched: panic on corrupted stack end
    
    commit 29d6455178a09e1dc340380c582b13356227e8df upstream.
    
    Until now, hitting this BUG_ON caused a recursive oops (because oops
    handling involves do_exit(), which calls into the scheduler, which in
    turn raises an oops), which caused stuff below the stack to be
    overwritten until a panic happened (e.g.  via an oops in interrupt
    context, caused by the overwritten CPU index in the thread_info).
    
    Just panic directly.
    
    Signed-off-by: Jann Horn <jannh@google.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [AmitP: Minor refactoring of upstream changes for linux-3.18.y]
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2ed13588499c3f5f0dc6b6851471178ca5a44576
Author: Bjørn Mork <bjorn@mork.no>
Date:   Mon Mar 7 21:15:36 2016 +0100

    cdc_ncm: do not call usbnet_link_change from cdc_ncm_bind
    
    commit 4d06dd537f95683aba3651098ae288b7cbff8274 upstream.
    
    usbnet_link_change will call schedule_work and should be
    avoided if bind is failing. Otherwise we will end up with
    scheduled work referring to a netdev which has gone away.
    
    Instead of making the call conditional, we can just defer
    it to usbnet_probe, using the driver_info flag made for
    this purpose.
    
    Fixes: 8a34b0ae8778 ("usbnet: cdc_ncm: apply usbnet_link_change")
    Reported-by: Andrey Konovalov <andreyknvl@gmail.com>
    Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Bjørn Mork <bjorn@mork.no>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 18377401142c65b0afe0168502fd335697e47936
Author: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Date:   Tue Jan 19 12:34:58 2016 +0100

    HID: core: prevent out-of-bound readings
    
    commit 50220dead1650609206efe91f0cc116132d59b3f upstream.
    
    Plugging a Logitech DJ receiver with KASAN activated raises a bunch of
    out-of-bound readings.
    
    The fields are allocated up to MAX_USAGE, meaning that potentially, we do
    not have enough fields to fit the incoming values.
    Add checks and silence KASAN.
    
    Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bf9ae79d37c4a159bf06f5749b9f59cf3cf642e5
Author: WANG Cong <xiyou.wangcong@gmail.com>
Date:   Tue Jul 5 22:12:36 2016 -0700

    ppp: defer netns reference release for ppp channel
    
    commit 205e1e255c479f3fd77446415706463b282f94e4 upstream.
    
    Matt reported that we have a NULL pointer dereference
    in ppp_pernet() from ppp_connect_channel(),
    i.e. pch->chan_net is NULL.
    
    This is due to that a parallel ppp_unregister_channel()
    could happen while we are in ppp_connect_channel(), during
    which pch->chan_net set to NULL. Since we need a reference
    to net per channel, it makes sense to sync the refcnt
    with the life time of the channel, therefore we should
    release this reference when we destroy it.
    
    Fixes: 1f461dcdd296 ("ppp: take reference on channels netns")
    Reported-by: Matt Bennett <Matt.Bennett@alliedtelesis.co.nz>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: linux-ppp@vger.kernel.org
    Cc: Guillaume Nault <g.nault@alphalink.fr>
    Cc: Cyrill Gorcunov <gorcunov@openvz.org>
    Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
    Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0e94410993a61b7d279a9f3854c56552a75e5fc7
Author: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Date:   Thu Feb 11 19:37:27 2016 +0000

    af_unix: Guard against other == sk in unix_dgram_sendmsg
    
    commit a5527dda344fff0514b7989ef7a755729769daa1 upstream.
    
    The unix_dgram_sendmsg routine use the following test
    
    if (unlikely(unix_peer(other) != sk && unix_recvq_full(other))) {
    
    to determine if sk and other are in an n:1 association (either
    established via connect or by using sendto to send messages to an
    unrelated socket identified by address). This isn't correct as the
    specified address could have been bound to the sending socket itself or
    because this socket could have been connected to itself by the time of
    the unix_peer_get but disconnected before the unix_state_lock(other). In
    both cases, the if-block would be entered despite other == sk which
    might either block the sender unintentionally or lead to trying to unlock
    the same spin lock twice for a non-blocking send. Add a other != sk
    check to guard against this.
    
    Fixes: 7d267278a9ec ("unix: avoid use-after-free in ep_remove_wait_queue")
    Reported-By: Philipp Hahn <pmhahn@pmhahn.de>
    Signed-off-by: Rainer Weikusat <rweikusat@mobileactivedefense.com>
    Tested-by: Philipp Hahn <pmhahn@pmhahn.de>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a91891444d171f66fe371048c9d3e4a6fad3db6e
Author: Eric Dumazet <edumazet@google.com>
Date:   Mon Dec 7 08:25:21 2015 -0800

    ipv6: sctp: fix lockdep splat in sctp_v6_get_dst()
    
    commit 69ce6487dcd364245a3d26322fc8f4ffd1e8d947 upstream.
    
    While cooking the sctp np->opt rcu fixes, I forgot to move
    one rcu_read_unlock() after the added rcu_dereference() in
    sctp_v6_get_dst()
    
    This gave lockdep warnings reported by Dave Jones.
    
    Fixes: c836a8ba9386 ("ipv6: sctp: add rcu protection around np->opt")
    Reported-by: Dave Jones <davej@codemonkey.org.uk>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f7fdbcdb7bf18411b2322448cca8ce393acf61d9
Author: Eric Dumazet <edumazet@google.com>
Date:   Wed Dec 2 21:48:14 2015 -0800

    ipv6: sctp: add rcu protection around np->opt
    
    commit c836a8ba93869d6a0290a6ae0047fbef09066871 upstream.
    
    This patch completes the work I did in commit 45f6fad84cc3
    ("ipv6: add complete rcu protection around np->opt"), as I missed
    sctp part.
    
    This simply makes sure np->opt is used with proper RCU locking
    and accessors.
    
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6d523f23bb2dadfebcda1636ee2d534259566c6c
Author: Calvin Owens <calvinowens@fb.com>
Date:   Fri Oct 30 16:57:00 2015 -0700

    sg: Fix double-free when drives detach during SG_IO
    
    commit f3951a3709ff50990bf3e188c27d346792103432 upstream.
    
    In sg_common_write(), we free the block request and return -ENODEV if
    the device is detached in the middle of the SG_IO ioctl().
    
    Unfortunately, sg_finish_rem_req() also tries to free srp->rq, so we
    end up freeing rq->cmd in the already free rq object, and then free
    the object itself out from under the current user.
    
    This ends up corrupting random memory via the list_head on the rq
    object. The most common crash trace I saw is this:
    
      ------------[ cut here ]------------
      kernel BUG at block/blk-core.c:1420!
      Call Trace:
      [<ffffffff81281eab>] blk_put_request+0x5b/0x80
      [<ffffffffa0069e5b>] sg_finish_rem_req+0x6b/0x120 [sg]
      [<ffffffffa006bcb9>] sg_common_write.isra.14+0x459/0x5a0 [sg]
      [<ffffffff8125b328>] ? selinux_file_alloc_security+0x48/0x70
      [<ffffffffa006bf95>] sg_new_write.isra.17+0x195/0x2d0 [sg]
      [<ffffffffa006cef4>] sg_ioctl+0x644/0xdb0 [sg]
      [<ffffffff81170f80>] do_vfs_ioctl+0x90/0x520
      [<ffffffff81258967>] ? file_has_perm+0x97/0xb0
      [<ffffffff811714a1>] SyS_ioctl+0x91/0xb0
      [<ffffffff81602afb>] tracesys+0xdd/0xe2
        RIP [<ffffffff81281e04>] __blk_put_request+0x154/0x1a0
    
    The solution is straightforward: just set srp->rq to NULL in the
    failure branch so that sg_finish_rem_req() doesn't attempt to re-free
    it.
    
    Additionally, since sg_rq_end_io() will never be called on the object
    when this happens, we need to free memory backing ->cmd if it isn't
    embedded in the object itself.
    
    KASAN was extremely helpful in finding the root cause of this bug.
    
    Signed-off-by: Calvin Owens <calvinowens@fb.com>
    Acked-by: Douglas Gilbert <dgilbert@interlog.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a4896e11679432f30433f415a5f31d5ebbbf8b66
Author: Lukas Czerner <lczerner@redhat.com>
Date:   Sat Oct 17 22:57:06 2015 -0400

    ext4: fix potential use after free in __ext4_journal_stop
    
    commit 6934da9238da947628be83635e365df41064b09b upstream.
    
    There is a use-after-free possibility in __ext4_journal_stop() in the
    case that we free the handle in the first jbd2_journal_stop() because
    we're referencing handle->h_err afterwards. This was introduced in
    9705acd63b125dee8b15c705216d7186daea4625 and it is wrong. Fix it by
    storing the handle->h_err value beforehand and avoid referencing
    potentially freed handle.
    
    Fixes: 9705acd63b125dee8b15c705216d7186daea4625
    Signed-off-by: Lukas Czerner <lczerner@redhat.com>
    Reviewed-by: Andreas Dilger <adilger@dilger.ca>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7da78079bae82dbaac4b88e0cb1f875e0dc52775
Author: David Howells <dhowells@redhat.com>
Date:   Tue Feb 23 11:03:12 2016 +0000

    KEYS: Fix ASN.1 indefinite length object parsing
    
    commit 23c8a812dc3c621009e4f0e5342aa4e2ede1ceaa upstream.
    
    This fixes CVE-2016-0758.
    
    In the ASN.1 decoder, when the length field of an ASN.1 value is extracted,
    it isn't validated against the remaining amount of data before being added
    to the cursor.  With a sufficiently large size indicated, the check:
    
            datalen - dp < 2
    
    may then fail due to integer overflow.
    
    Fix this by checking the length indicated against the amount of remaining
    data in both places a definite length is determined.
    
    Whilst we're at it, make the following changes:
    
     (1) Check the maximum size of extended length does not exceed the capacity
         of the variable it's being stored in (len) rather than the type that
         variable is assumed to be (size_t).
    
     (2) Compare the EOC tag to the symbolic constant ASN1_EOC rather than the
         integer 0.
    
     (3) To reduce confusion, move the initialisation of len outside of:
    
            for (len = 0; n > 0; n--) {
    
         since it doesn't have anything to do with the loop counter n.
    
    Signed-off-by: David Howells <dhowells@redhat.com>
    Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
    Acked-by: David Woodhouse <David.Woodhouse@intel.com>
    Acked-by: Peter Jones <pjones@redhat.com>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c66d9b77cbda5e0e71ae0dfabaa94b27ca3f6b63
Author: David Howells <dhowells@redhat.com>
Date:   Wed Aug 5 12:54:46 2015 +0100

    ASN.1: Fix non-match detection failure on data overrun
    
    commit 0d62e9dd6da45bbf0f33a8617afc5fe774c8f45f upstream.
    
    If the ASN.1 decoder is asked to parse a sequence of objects, non-optional
    matches get skipped if there's no more data to be had rather than a
    data-overrun error being reported.
    
    This is due to the code segment that decides whether to skip optional
    matches (ie. matches that could get ignored because an element is marked
    OPTIONAL in the grammar) due to a lack of data also skips non-optional
    elements if the data pointer has reached the end of the buffer.
    
    This can be tested with the data decoder for the new RSA akcipher algorithm
    that takes three non-optional integers.  Currently, it skips the last
    integer if there is insufficient data.
    
    Without the fix, #defining DEBUG in asn1_decoder.c will show something
    like:
    
            next_op: pc=0/13 dp=0/270 C=0 J=0
            - match? 30 30 00
            - TAG: 30 266 CONS
            next_op: pc=2/13 dp=4/270 C=1 J=0
            - match? 02 02 00
            - TAG: 02 257
            - LEAF: 257
            next_op: pc=5/13 dp=265/270 C=1 J=0
            - match? 02 02 00
            - TAG: 02 3
            - LEAF: 3
            next_op: pc=8/13 dp=270/270 C=1 J=0
            next_op: pc=11/13 dp=270/270 C=1 J=0
            - end cons t=4 dp=270 l=270/270
    
    The next_op line for pc=8/13 should be followed by a match line.
    
    This is not exploitable for X.509 certificates by means of shortening the
    message and fixing up the ASN.1 CONS tags because:
    
     (1) The relevant records being built up are cleared before use.
    
     (2) If the message is shortened sufficiently to remove the public key, the
         ASN.1 parse of the RSA key will fail quickly due to a lack of data.
    
     (3) Extracted signature data is either turned into MPIs (which cope with a
         0 length) or is simpler integers specifying algoritms and suchlike
         (which can validly be 0); and
    
     (4) The AKID and SKID extensions are optional and their removal is handled
         without risking passing a NULL to asymmetric_key_generate_id().
    
     (5) If the certificate is truncated sufficiently to remove the subject,
         issuer or serialNumber then the ASN.1 decoder will fail with a 'Cons
         stack underflow' return.
    
    This is not exploitable for PKCS#7 messages by means of removal of elements
    from such a message from the tail end of a sequence:
    
     (1) Any shortened X.509 certs embedded in the PKCS#7 message are survivable
         as detailed above.
    
     (2) The message digest content isn't used if it shows a NULL pointer,
         similarly, the authattrs aren't used if that shows a NULL pointer.
    
     (3) A missing signature results in a NULL MPI - which the MPI routines deal
         with.
    
     (4) If data is NULL, it is expected that the message has detached content and
         that is handled appropriately.
    
     (5) If the serialNumber is excised, the unconditional action associated
         with it will pick up the containing SEQUENCE instead, so no NULL
         pointer will be seen here.
    
         If both the issuer and the serialNumber are excised, the ASN.1 decode
         will fail with an 'Unexpected tag' return.
    
         In either case, there's no way to get to asymmetric_key_generate_id()
         with a NULL pointer.
    
     (6) Other fields are decoded to simple integers.  Shortening the message
         to omit an algorithm ID field will cause checks on this to fail early
         in the verification process.
    
    
    This can also be tested by snipping objects off of the end of the ASN.1 stream
    such that mandatory tags are removed - or even from the end of internal
    SEQUENCEs.  If any mandatory tag is missing, the error EBADMSG *should* be
    produced.  Without this patch ERANGE or ENOPKG might be produced or the parse
    may apparently succeed, perhaps with ENOKEY or EKEYREJECTED being produced
    later, depending on what gets snipped.
    
    Just snipping off the final BIT_STRING or OCTET_STRING from either sample
    should be a start since both are mandatory and neither will cause an EBADMSG
    without the patches
    
    Reported-by: Marcel Holtmann <marcel@holtmann.org>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Tested-by: Marcel Holtmann <marcel@holtmann.org>
    Reviewed-by: David Woodhouse <David.Woodhouse@intel.com>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6ee649ba055c71907226820070cde13079d3d49d
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Tue Dec 15 13:49:05 2015 +0100

    perf: Fix race in swevent hash
    
    commit 12ca6ad2e3a896256f086497a7c7406a547ee373 upstream.
    
    There's a race on CPU unplug where we free the swevent hash array
    while it can still have events on. This will result in a
    use-after-free which is BAD.
    
    Simply do not free the hash array on unplug. This leaves the thing
    around and no use-after-free takes place.
    
    When the last swevent dies, we do a for_each_possible_cpu() iteration
    anyway to clean these up, at which time we'll free it, so no leakage
    will occur.
    
    Reported-by: Sasha Levin <sasha.levin@oracle.com>
    Tested-by: Sasha Levin <sasha.levin@oracle.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Vince Weaver <vincent.weaver@maine.edu>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e00f6efe21bd34a7dd1cc3520f6155180e3d8125
Author: Suzuki K. Poulose <suzuki.poulose@arm.com>
Date:   Tue Mar 17 18:14:59 2015 +0000

    arm64: perf: reject groups spanning multiple HW PMUs
    
    commit 8fff105e13041e49b82f92eef034f363a6b1c071 upstream.
    
    The perf core implicitly rejects events spanning multiple HW PMUs, as in
    these cases the event->ctx will differ. However this validation is
    performed after pmu::event_init() is called in perf_init_event(), and
    thus pmu::event_init() may be called with a group leader from a
    different HW PMU.
    
    The ARM64 PMU driver does not take this fact into account, and when
    validating groups assumes that it can call to_arm_pmu(event->pmu) for
    any HW event. When the event in question is from another HW PMU this is
    wrong, and results in dereferencing garbage.
    
    This patch updates the ARM64 PMU driver to first test for and reject
    events from other PMUs, moving the to_arm_pmu and related logic after
    this test. Fixes a crash triggered by perf_fuzzer on Linux-4.0-rc2, with
    a CCI PMU present:
    
    Bad mode in Synchronous Abort handler detected, code 0x86000006 -- IABT (current EL)
    CPU: 0 PID: 1371 Comm: perf_fuzzer Not tainted 3.19.0+ #249
    Hardware name: V2F-1XV7 Cortex-A53x2 SMM (DT)
    task: ffffffc07c73a280 ti: ffffffc07b0a0000 task.ti: ffffffc07b0a0000
    PC is at 0x0
    LR is at validate_event+0x90/0xa8
    pc : [<0000000000000000>] lr : [<ffffffc000090228>] pstate: 00000145
    sp : ffffffc07b0a3ba0
    
    [<          (null)>]           (null)
    [<ffffffc0000907d8>] armpmu_event_init+0x174/0x3cc
    [<ffffffc00015d870>] perf_try_init_event+0x34/0x70
    [<ffffffc000164094>] perf_init_event+0xe0/0x10c
    [<ffffffc000164348>] perf_event_alloc+0x288/0x358
    [<ffffffc000164c5c>] SyS_perf_event_open+0x464/0x98c
    Code: bad PC value
    
    Also cleans up the code to use the arm_pmu only when we know
    that we are dealing with an arm pmu event.
    
    Cc: Will Deacon <will.deacon@arm.com>
    Acked-by: Mark Rutland <mark.rutland@arm.com>
    Acked-by: Peter Ziljstra (Intel) <peterz@infradead.org>
    Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 33b738f7c5a704b729b2502669cf71c7b25ab7d6
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Fri Jan 23 12:24:14 2015 +0100

    perf: Fix event->ctx locking
    
    commit f63a8daa5812afef4f06c962351687e1ff9ccb2b upstream.
    
    There have been a few reported issues wrt. the lack of locking around
    changing event->ctx. This patch tries to address those.
    
    It avoids the whole rwsem thing; and while it appears to work, please
    give it some thought in review.
    
    What I did fail at is sensible runtime checks on the use of
    event->ctx, the RCU use makes it very hard.
    
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Link: http://lkml.kernel.org/r/20150123125834.209535886@infradead.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c8f417a2d6af99b2735709cb60562e0a7c8ddf62
Author: Mark Rutland <mark.rutland@arm.com>
Date:   Thu Jan 8 11:42:59 2015 +0000

    arm64: make sys_call_table const
    
    commit c623b33b4e9599c6ac5076f7db7369eb9869aa04 upstream.
    
    As with x86, mark the sys_call_table const such that it will be placed
    in the .rodata section. This will cause attempts to modify the table
    (accidental or deliberate) to fail when strict page permissions are in
    place. In the absence of strict page permissions, there should be no
    functional change.
    
    Signed-off-by: Mark Rutland <mark.rutland@arm.com>
    Acked-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 55dbe8e1c711581822acb04a9fd2fa2f39a2353c
Author: Szymon Janc <szymon.janc@codecoup.pl>
Date:   Mon Apr 24 18:25:04 2017 -0700

    Bluetooth: Fix user channel for 32bit userspace on 64bit kernel
    
    commit ab89f0bdd63a3721f7cd3f064f39fc4ac7ca14d4 upstream.
    
    Running 32bit userspace on 64bit kernel results in MSG_CMSG_COMPAT being
    defined as 0x80000000. This results in sendmsg failure if used from 32bit
    userspace running on 64bit kernel. Fix this by accounting for MSG_CMSG_COMPAT
    in flags check in hci_sock_sendmsg.
    
    Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
    Signed-off-by: Marko Kiiskila <marko@runtime.io>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0c7581fd01ecc10a69f396d55f00c1427d6d1f6b
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Apr 10 11:21:39 2017 +0200

    serial: omap: suspend device on probe errors
    
    commit 77e6fe7fd2b7cba0bf2f2dc8cde51d7b9a35bf74 upstream.
    
    Make sure to actually suspend the device before returning after a failed
    (or deferred) probe.
    
    Note that autosuspend must be disabled before runtime pm is disabled in
    order to balance the usage count due to a negative autosuspend delay as
    well as to make the final put suspend the device synchronously.
    
    Fixes: 388bc2622680 ("omap-serial: Fix the error handling in the omap_serial probe")
    Cc: Shubhrajyoti D <shubhrajyoti@ti.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Acked-by: Tony Lindgren <tony@atomide.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8763b1d53903eae8554830e6f4aed42f47ef5c18
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Apr 10 11:21:38 2017 +0200

    serial: omap: fix runtime-pm handling on unbind
    
    commit 099bd73dc17ed77aa8c98323e043613b6e8f54fc upstream.
    
    An unbalanced and misplaced synchronous put was used to suspend the
    device on driver unbind, something which with a likewise misplaced
    pm_runtime_disable leads to external aborts when an open port is being
    removed.
    
    Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa024010
    ...
    [<c046e760>] (serial_omap_set_mctrl) from [<c046a064>] (uart_update_mctrl+0x50/0x60)
    [<c046a064>] (uart_update_mctrl) from [<c046a400>] (uart_shutdown+0xbc/0x138)
    [<c046a400>] (uart_shutdown) from [<c046bd2c>] (uart_hangup+0x94/0x190)
    [<c046bd2c>] (uart_hangup) from [<c045b760>] (__tty_hangup+0x404/0x41c)
    [<c045b760>] (__tty_hangup) from [<c045b794>] (tty_vhangup+0x1c/0x20)
    [<c045b794>] (tty_vhangup) from [<c046ccc8>] (uart_remove_one_port+0xec/0x260)
    [<c046ccc8>] (uart_remove_one_port) from [<c046ef4c>] (serial_omap_remove+0x40/0x60)
    [<c046ef4c>] (serial_omap_remove) from [<c04845e8>] (platform_drv_remove+0x34/0x4c)
    
    Fix this up by resuming the device before deregistering the port and by
    suspending and disabling runtime pm only after the port has been
    removed.
    
    Also make sure to disable autosuspend before disabling runtime pm so
    that the usage count is balanced and device actually suspended before
    returning.
    
    Note that due to a negative autosuspend delay being set in probe, the
    unbalanced put would actually suspend the device on first driver unbind,
    while rebinding and again unbinding would result in a negative
    power.usage_count.
    
    Fixes: 7e9c8e7dbf3b ("serial: omap: make sure to suspend device before remove")
    Cc: Felipe Balbi <balbi@kernel.org>
    Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Acked-by: Tony Lindgren <tony@atomide.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f9a25f25bd32e2d010070ea2f9021cd903c862cf
Author: NeilBrown <neilb@suse.com>
Date:   Thu Apr 6 12:06:37 2017 +1000

    md/raid1: avoid reusing a resync bio after error handling.
    
    commit 0c9d5b127f695818c2c5a3868c1f28ca2969e905 upstream.
    
    fix_sync_read_error() modifies a bio on a newly faulty
    device by setting bi_end_io to end_sync_write.
    This ensure that put_buf() will still call rdev_dec_pending()
    as required, but makes sure that subsequent code in
    fix_sync_read_error() doesn't try to read from the device.
    
    Unfortunately this interacts badly with sync_request_write()
    which assumes that any bio with bi_end_io set to non-NULL
    other than end_sync_read is safe to write to.
    
    As the device is now faulty it doesn't make sense to write.
    As the bio was recently used for a read, it is "dirty"
    and not suitable for immediate submission.
    In particular, ->bi_next might be non-NULL, which will cause
    generic_make_request() to complain.
    
    Break this interaction by refusing to write to devices
    which are marked as Faulty.
    
    Reported-and-tested-by: Michael Wang <yun.wang@profitbricks.com>
    Fixes: 2e52d449bcec ("md/raid1: add failfast handling for reads.")
    Signed-off-by: NeilBrown <neilb@suse.com>
    Signed-off-by: Shaohua Li <shli@fb.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3848f89affa3be8a070c2c50cf9faf51c06d7208
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date:   Fri Apr 7 02:33:30 2017 +0200

    padata: free correct variable
    
    commit 07a77929ba672d93642a56dc2255dd21e6e2290b upstream.
    
    The author meant to free the variable that was just allocated, instead
    of the one that failed to be allocated, but made a simple typo. This
    patch rectifies that.
    
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8c0b48aa446f82104a4994c63b5ffd9cb1117f1d
Author: Björn Jacke <bj@sernet.de>
Date:   Fri May 5 04:36:16 2017 +0200

    CIFS: add misssing SFM mapping for doublequote
    
    commit 85435d7a15294f9f7ef23469e6aaf7c5dfcc54f0 upstream.
    
    SFM is mapping doublequote to 0xF020
    
    Without this patch creating files with doublequote fails to Windows/Mac
    
    Signed-off-by: Bjoern Jacke <bjacke@samba.org>
    Signed-off-by: Steve French <smfrench@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2e8057983a5ff603ef0dc91bfd144fbf589739de
Author: Björn Jacke <bj@sernet.de>
Date:   Wed May 3 23:47:44 2017 +0200

    CIFS: fix mapping of SFM_SPACE and SFM_PERIOD
    
    commit b704e70b7cf48f9b67c07d585168e102dfa30bb4 upstream.
    
    - trailing space maps to 0xF028
    - trailing period maps to 0xF029
    
    This fix corrects the mapping of file names which have a trailing character
    that would otherwise be illegal (period or space) but is allowed by POSIX.
    
    Signed-off-by: Bjoern Jacke <bjacke@samba.org>
    Signed-off-by: Steve French <smfrench@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7b88a092468d83f01c2d8685455394017485cd56
Author: Steve French <smfrench@gmail.com>
Date:   Wed May 3 21:12:20 2017 -0500

    SMB3: Work around mount failure when using SMB3 dialect to Macs
    
    commit 7db0a6efdc3e990cdfd4b24820d010e9eb7890ad upstream.
    
    Macs send the maximum buffer size in response on ioctl to validate
    negotiate security information, which causes us to fail the mount
    as the response buffer is larger than the expected response.
    
    Changed ioctl response processing to allow for padding of validate
    negotiate ioctl response and limit the maximum response size to
    maximum buffer size.
    
    Signed-off-by: Steve French <steve.french@primarydata.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d5fa0a5c5c13241b0de42c862d582512743da21e
Author: Steve French <smfrench@gmail.com>
Date:   Tue May 2 13:35:20 2017 -0500

    Set unicode flag on cifs echo request to avoid Mac error
    
    commit 26c9cb668c7fbf9830516b75d8bee70b699ed449 upstream.
    
    Mac requires the unicode flag to be set for cifs, even for the smb
    echo request (which doesn't have strings).
    
    Without this Mac rejects the periodic echo requests (when mounting
    with cifs) that we use to check if server is down
    
    Signed-off-by: Steve French <smfrench@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 489bc9fed9735697b4387f8b8c9ec5b79e59f0b4
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Wed May 3 14:56:02 2017 -0700

    fs/block_dev: always invalidate cleancache in invalidate_bdev()
    
    commit a5f6a6a9c72eac38a7fadd1a038532bc8516337c upstream.
    
    invalidate_bdev() calls cleancache_invalidate_inode() iff ->nrpages != 0
    which doen't make any sense.
    
    Make sure that invalidate_bdev() always calls cleancache_invalidate_inode()
    regardless of mapping->nrpages value.
    
    Fixes: c515e1fd361c ("mm/fs: add hooks to support cleancache")
    Link: http://lkml.kernel.org/r/20170424164135.22350-3-aryabinin@virtuozzo.com
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
    Cc: Jens Axboe <axboe@kernel.dk>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Alexey Kuznetsov <kuznet@virtuozzo.com>
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: Nikolay Borisov <n.borisov.lkml@gmail.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a38b13bc2db02a6ec07b4bbc7864df10a03a1270
Author: Luis Henriques <lhenriques@suse.com>
Date:   Fri Apr 28 11:14:04 2017 +0100

    ceph: fix memory leak in __ceph_setxattr()
    
    commit eeca958dce0a9231d1969f86196653eb50fcc9b3 upstream.
    
    The ceph_inode_xattr needs to be released when removing an xattr.  Easily
    reproducible running the 'generic/020' test from xfstests or simply by
    doing:
    
      attr -s attr0 -V 0 /mnt/test && attr -r attr0 /mnt/test
    
    While there, also fix the error path.
    
    Here's the kmemleak splat:
    
    unreferenced object 0xffff88001f86fbc0 (size 64):
      comm "attr", pid 244, jiffies 4294904246 (age 98.464s)
      hex dump (first 32 bytes):
        40 fa 86 1f 00 88 ff ff 80 32 38 1f 00 88 ff ff  @........28.....
        00 01 00 00 00 00 ad de 00 02 00 00 00 00 ad de  ................
      backtrace:
        [<ffffffff81560199>] kmemleak_alloc+0x49/0xa0
        [<ffffffff810f3e5b>] kmem_cache_alloc+0x9b/0xf0
        [<ffffffff812b157e>] __ceph_setxattr+0x17e/0x820
        [<ffffffff812b1c57>] ceph_set_xattr_handler+0x37/0x40
        [<ffffffff8111fb4b>] __vfs_removexattr+0x4b/0x60
        [<ffffffff8111fd37>] vfs_removexattr+0x77/0xd0
        [<ffffffff8111fdd1>] removexattr+0x41/0x60
        [<ffffffff8111fe65>] path_removexattr+0x75/0xa0
        [<ffffffff81120aeb>] SyS_lremovexattr+0xb/0x10
        [<ffffffff81564b20>] entry_SYSCALL_64_fastpath+0x13/0x94
        [<ffffffffffffffff>] 0xffffffffffffffff
    
    Signed-off-by: Luis Henriques <lhenriques@suse.com>
    Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cea7e7245ea80f96031cb128a2a6d409bbd6535e
Author: Michal Hocko <mhocko@suse.com>
Date:   Mon May 8 15:57:24 2017 -0700

    fs/xattr.c: zero out memory copied to userspace in getxattr
    
    commit 81be3dee96346fbe08c31be5ef74f03f6b63cf68 upstream.
    
    getxattr uses vmalloc to allocate memory if kzalloc fails.  This is
    filled by vfs_getxattr and then copied to the userspace.  vmalloc,
    however, doesn't zero out the memory so if the specific implementation
    of the xattr handler is sloppy we can theoretically expose a kernel
    memory.  There is no real sign this is really the case but let's make
    sure this will not happen and use vzalloc instead.
    
    Fixes: 779302e67835 ("fs/xattr.c:getxattr(): improve handling of allocation failures")
    Link: http://lkml.kernel.org/r/20170306103327.2766-1-mhocko@kernel.org
    Acked-by: Kees Cook <keescook@chromium.org>
    Reported-by: Vlastimil Babka <vbabka@suse.cz>
    Signed-off-by: Michal Hocko <mhocko@suse.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 28aafa8aa24648fd8a1a67962187b5a7a5e373c4
Author: Jack Morgenstein <jackm@dev.mellanox.co.il>
Date:   Tue Mar 21 12:57:05 2017 +0200

    IB/mlx4: Fix ib device initialization error flow
    
    commit 99e68909d5aba1861897fe7afc3306c3c81b6de0 upstream.
    
    In mlx4_ib_add, procedure mlx4_ib_alloc_eqs is called to allocate EQs.
    
    However, in the mlx4_ib_add error flow, procedure mlx4_ib_free_eqs is not
    called to free the allocated EQs.
    
    Fixes: e605b743f33d ("IB/mlx4: Increase the number of vectors (EQs) available for ULPs")
    Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
    Signed-off-by: Leon Romanovsky <leon@kernel.org>
    Signed-off-by: Doug Ledford <dledford@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f88282f6669777027e45ff1417967914e3965d82
Author: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
Date:   Wed Mar 29 06:21:59 2017 -0400

    IB/IPoIB: ibX: failed to create mcg debug file
    
    commit 771a52584096c45e4565e8aabb596eece9d73d61 upstream.
    
    When udev renames the netdev devices, ipoib debugfs entries does not
    get renamed. As a result, if subsequent probe of ipoib device reuse the
    name then creating a debugfs entry for the new device would fail.
    
    Also, moved ipoib_create_debug_files and ipoib_delete_debug_files as part
    of ipoib event handling in order to avoid any race condition between these.
    
    Fixes: 1732b0ef3b3a ([IPoIB] add path record information in debugfs)
    Signed-off-by: Vijay Kumar <vijay.ac.kumar@oracle.com>
    Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
    Reviewed-by: Mark Bloch <markb@mellanox.com>
    Signed-off-by: Doug Ledford <dledford@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e106392ee02965eb0fd11a037d7e78db958f310a
Author: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
Date:   Fri Apr 7 12:14:55 2017 -0700

    dm era: save spacemap metadata root after the pre-commit
    
    commit 117aceb030307dcd431fdcff87ce988d3016c34a upstream.
    
    When committing era metadata to disk, it doesn't always save the latest
    spacemap metadata root in superblock. Due to this, metadata is getting
    corrupted sometimes when reopening the device. The correct order of update
    should be, pre-commit (shadows spacemap root), save the spacemap root
    (newly shadowed block) to in-core superblock and then the final commit.
    
    Signed-off-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
    Signed-off-by: Mike Snitzer <snitzer@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 02ad5d8d9d78d0a506b7fd8ec3abeca9fadb701b
Author: Richard Weinberger <richard@nod.at>
Date:   Sat Apr 1 00:41:57 2017 +0200

    um: Fix PTRACE_POKEUSER on x86_64
    
    commit 9abc74a22d85ab29cef9896a2582a530da7e79bf upstream.
    
    This is broken since ever but sadly nobody noticed.
    Recent versions of GDB set DR_CONTROL unconditionally and
    UML dies due to a heap corruption. It turns out that
    the PTRACE_POKEUSER was copy&pasted from i386 and assumes
    that addresses are 4 bytes long.
    
    Fix that by using 8 as address size in the calculation.
    
    Reported-by: jie cao <cj3054@gmail.com>
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3e576d765dc98ef004bd1706ab27733c50c7b976
Author: Ashish Kalra <ashish@bluestacks.com>
Date:   Wed Apr 19 20:50:15 2017 +0530

    x86/boot: Fix BSS corruption/overwrite bug in early x86 kernel startup
    
    commit d594aa0277e541bb997aef0bc0a55172d8138340 upstream.
    
    The minimum size for a new stack (512 bytes) setup for arch/x86/boot components
    when the bootloader does not setup/provide a stack for the early boot components
    is not "enough".
    
    The setup code executing as part of early kernel startup code, uses the stack
    beyond 512 bytes and accidentally overwrites and corrupts part of the BSS
    section. This is exposed mostly in the early video setup code, where
    it was corrupting BSS variables like force_x, force_y, which in-turn affected
    kernel parameters such as screen_info (screen_info.orig_video_cols) and
    later caused an exception/panic in console_init().
    
    Most recent boot loaders setup the stack for early boot components, so this
    stack overwriting into BSS section issue has not been exposed.
    
    Signed-off-by: Ashish Kalra <ashish@bluestacks.com>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Josh Poimboeuf <jpoimboe@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/20170419152015.10011-1-ashishkalra@Ashishs-MacBook-Pro.local
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c8afd85beffa969786e341d2a1516fc7509cca50
Author: Maksim Salau <maksim.salau@gmail.com>
Date:   Tue Apr 25 22:49:21 2017 +0300

    usb: misc: legousbtower: Fix buffers on stack
    
    commit 942a48730faf149ccbf3e12ac718aee120bb3529 upstream.
    
    Allocate buffers on HEAP instead of STACK for local structures
    that are to be received using usb_control_msg().
    
    Signed-off-by: Maksim Salau <maksim.salau@gmail.com>
    Tested-by: Alfredo Rafael Vicente Boix <alviboi@gmail.com>;
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1a39dd098f52f430513b6e59032c0971799c15e7
Author: Guenter Roeck <linux@roeck-us.net>
Date:   Mon Mar 20 14:30:50 2017 -0700

    usb: hub: Do not attempt to autosuspend disconnected devices
    
    commit f5cccf49428447dfbc9edb7a04bb8fc316269781 upstream.
    
    While running a bind/unbind stress test with the dwc3 usb driver on rk3399,
    the following crash was observed.
    
    Unable to handle kernel NULL pointer dereference at virtual address 00000218
    pgd = ffffffc00165f000
    [00000218] *pgd=000000000174f003, *pud=000000000174f003,
                                    *pmd=0000000001750003, *pte=00e8000001751713
    Internal error: Oops: 96000005 [#1] PREEMPT SMP
    Modules linked in: uinput uvcvideo videobuf2_vmalloc cmac
    ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat rfcomm
    xt_mark fuse bridge stp llc zram btusb btrtl btbcm btintel bluetooth
    ip6table_filter mwifiex_pcie mwifiex cfg80211 cdc_ether usbnet r8152 mii joydev
    snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq snd_seq_device ppp_async
    ppp_generic slhc tun
    CPU: 1 PID: 29814 Comm: kworker/1:1 Not tainted 4.4.52 #507
    Hardware name: Google Kevin (DT)
    Workqueue: pm pm_runtime_work
    task: ffffffc0ac540000 ti: ffffffc0af4d4000 task.ti: ffffffc0af4d4000
    PC is at autosuspend_check+0x74/0x174
    LR is at autosuspend_check+0x70/0x174
    ...
    Call trace:
    [<ffffffc00080dcc0>] autosuspend_check+0x74/0x174
    [<ffffffc000810500>] usb_runtime_idle+0x20/0x40
    [<ffffffc000785ae0>] __rpm_callback+0x48/0x7c
    [<ffffffc000786af0>] rpm_idle+0x1e8/0x498
    [<ffffffc000787cdc>] pm_runtime_work+0x88/0xcc
    [<ffffffc000249bb8>] process_one_work+0x390/0x6b8
    [<ffffffc00024abcc>] worker_thread+0x480/0x610
    [<ffffffc000251a80>] kthread+0x164/0x178
    [<ffffffc0002045d0>] ret_from_fork+0x10/0x40
    
    Source:
    
    (gdb) l *0xffffffc00080dcc0
    0xffffffc00080dcc0 is in autosuspend_check
    (drivers/usb/core/driver.c:1778).
    1773            /* We don't need to check interfaces that are
    1774             * disabled for runtime PM.  Either they are unbound
    1775             * or else their drivers don't support autosuspend
    1776             * and so they are permanently active.
    1777             */
    1778            if (intf->dev.power.disable_depth)
    1779                    continue;
    1780            if (atomic_read(&intf->dev.power.usage_count) > 0)
    1781                    return -EBUSY;
    1782            w |= intf->needs_remote_wakeup;
    
    Code analysis shows that intf is set to NULL in usb_disable_device() prior
    to setting actconfig to NULL. At the same time, usb_runtime_idle() does not
    lock the usb device, and neither does any of the functions in the
    traceback. This means that there is no protection against a race condition
    where usb_disable_device() is removing dev->actconfig->interface[] pointers
    while those are being accessed from autosuspend_check().
    
    To solve the problem, synchronize and validate device state between
    autosuspend_check() and usb_disconnect().
    
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b718268d11224946926303e096128583fe9c63f0
Author: Gustavo A. R. Silva <garsilva@embeddedor.com>
Date:   Mon Apr 3 22:48:40 2017 -0500

    usb: misc: add missing continue in switch
    
    commit 2c930e3d0aed1505e86e0928d323df5027817740 upstream.
    
    Add missing continue in switch.
    
    Addresses-Coverity-ID: 1248733
    Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aa55187a099efaeb38c0e98b4a7fac2564e390eb
Author: Ian Abbott <abbotti@mev.co.uk>
Date:   Fri Feb 17 11:09:09 2017 +0000

    staging: comedi: jr3_pci: cope with jiffies wraparound
    
    commit 8ec04a491825e08068e92bed0bba7821893b6433 upstream.
    
    The timer expiry routine `jr3_pci_poll_dev()` checks for expiry by
    checking whether the absolute value of `jiffies` (stored in local
    variable `now`) is greater than the expected expiry time in jiffy units.
    This will fail when `jiffies` wraps around.  Also, it seems to make
    sense to handle the expiry one jiffy earlier than the current test.  Use
    `time_after_eq()` to check for expiry.
    
    Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3157754a285d608f4cbfc7ad9c02ac0bd866e8cc
Author: Ian Abbott <abbotti@mev.co.uk>
Date:   Fri Feb 17 11:09:08 2017 +0000

    staging: comedi: jr3_pci: fix possible null pointer dereference
    
    commit 45292be0b3db0b7f8286683b376e2d9f949d11f9 upstream.
    
    For some reason, the driver does not consider allocation of the
    subdevice private data to be a fatal error when attaching the COMEDI
    device.  It tests the subdevice private data pointer for validity at
    certain points, but omits some crucial tests.  In particular,
    `jr3_pci_auto_attach()` calls `jr3_pci_alloc_spriv()` to allocate and
    initialize the subdevice private data, but the same function
    subsequently dereferences the pointer to access the `next_time_min` and
    `next_time_max` members without checking it first.  The other missing
    test is in the timer expiry routine `jr3_pci_poll_dev()`, but it will
    crash before it gets that far.
    
    Fix the bug by returning `-ENOMEM` from `jr3_pci_auto_attach()` as soon
    as one of the calls to `jr3_pci_alloc_spriv()` returns `NULL`.  The
    COMEDI core will subsequently call `jr3_pci_detach()` to clean up.
    
    Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 411c56dc785ab4943e612258b7ca4faa7ca1ad75
Author: Johan Hovold <johan@kernel.org>
Date:   Wed Apr 26 12:23:04 2017 +0200

    staging: gdm724x: gdm_mux: fix use-after-free on module unload
    
    commit b58f45c8fc301fe83ee28cad3e64686c19e78f1c upstream.
    
    Make sure to deregister the USB driver before releasing the tty driver
    to avoid use-after-free in the USB disconnect callback where the tty
    devices are deregistered.
    
    Fixes: 61e121047645 ("staging: gdm7240: adding LTE USB driver")
    Cc: Won Kang <wkang77@gmail.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d9f9269d7504d1831a5c9f4d067b1492f5d8afc1
Author: Malcolm Priestley <tvboxspy@gmail.com>
Date:   Sat Apr 22 11:14:57 2017 +0100

    staging: vt6656: use off stack for out buffer USB transfers.
    
    commit 12ecd24ef93277e4e5feaf27b0b18f2d3828bc5e upstream.
    
    Since 4.9 mandated USB buffers be heap allocated this causes the driver
    to fail.
    
    Since there is a wide range of buffer sizes use kmemdup to create
    allocated buffer.
    
    Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 240b8b82815ed6d9597db4c94e402fb292c6b79e
Author: Malcolm Priestley <tvboxspy@gmail.com>
Date:   Sat Apr 22 11:14:58 2017 +0100

    staging: vt6656: use off stack for in buffer USB transfers.
    
    commit 05c0cf88bec588a7cb34de569acd871ceef26760 upstream.
    
    Since 4.9 mandated USB buffers to be heap allocated. This causes
    the driver to fail.
    
    Create buffer for USB transfers.
    
    Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ac2340bcf8cec0e42e1833a5951bfadf42a87d7c
Author: Ajay Kaher <ajay.kaher@samsung.com>
Date:   Tue Mar 28 08:09:32 2017 -0400

    USB: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously
    
    commit 2f86a96be0ccb1302b7eee7855dbee5ce4dc5dfb upstream.
    
    There is race condition when two USB class drivers try to call
    init_usb_class at the same time and leads to crash.
    code path: probe->usb_register_dev->init_usb_class
    
    To solve this, mutex locking has been added in init_usb_class() and
    destroy_usb_class().
    
    As pointed by Alan, removed "if (usb_class)" test from destroy_usb_class()
    because usb_class can never be NULL there.
    
    Signed-off-by: Ajay Kaher <ajay.kaher@samsung.com>
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bb123c0a86e4e07825dc209e1d03bbaf508a22e7
Author: Marek Vasut <marex@denx.de>
Date:   Tue Apr 18 20:07:56 2017 +0200

    USB: serial: ftdi_sio: add device ID for Microsemi/Arrow SF2PLUS Dev Kit
    
    commit 31c5d1922b90ddc1da6a6ddecef7cd31f17aa32b upstream.
    
    This development kit has an FT4232 on it with a custom USB VID/PID.
    The FT4232 provides four UARTs, but only two are used. The UART 0
    is used by the FlashPro5 programmer and UART 2 is connected to the
    SmartFusion2 CortexM3 SoC UART port.
    
    Note that the USB VID is registered to Actel according to Linux USB
    VID database, but that was acquired by Microsemi.
    
    Signed-off-by: Marek Vasut <marex@denx.de>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a160801e10a14ffb510fa877394774f9bb64c325
Author: Peter Chen <peter.chen@nxp.com>
Date:   Wed Apr 19 16:55:52 2017 +0300

    usb: host: xhci: print correct command ring address
    
    commit 6fc091fb0459ade939a795bfdcaf645385b951d4 upstream.
    
    Print correct command ring address using 'val_64'.
    
    Signed-off-by: Peter Chen <peter.chen@nxp.com>
    Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a4fffe4fb974d7571ea9e3c5f9abd05cb953df63
Author: Bart Van Assche <bart.vanassche@sandisk.com>
Date:   Thu May 4 15:50:47 2017 -0700

    target/fileio: Fix zero-length READ and WRITE handling
    
    commit 59ac9c078141b8fd0186c0b18660a1b2c24e724e upstream.
    
    This patch fixes zero-length READ and WRITE handling in target/FILEIO,
    which was broken a long time back by:
    
    Since:
    
      commit d81cb44726f050d7cf1be4afd9cb45d153b52066
      Author: Paolo Bonzini <pbonzini@redhat.com>
      Date:   Mon Sep 17 16:36:11 2012 -0700
    
          target: go through normal processing for all zero-length commands
    
    which moved zero-length READ and WRITE completion out of target-core,
    to doing submission into backend driver code.
    
    To address this, go ahead and invoke target_complete_cmd() for any
    non negative return value in fd_do_rw().
    
    Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
    Reviewed-by: Hannes Reinecke <hare@suse.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Cc: Andy Grover <agrover@redhat.com>
    Cc: David Disseldorp <ddiss@suse.de>
    Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>