04 Nov, 2018

40 commits

  • [ Upstream commit 0f0e8de334c54c38818a4a5390a39aa09deff5bf ]

    In order to make sure compiler flag detection for ARM works
    correctly the no-integrated-as flags need to be set before
    including the arch specific Makefile.

    Fixes: cfe17c9bbe6a ("kbuild: move cc-option and cc-disable-warning after incl. arch Makefile")
    Signed-off-by: Stefan Agner
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin

    Stefan Agner
     
  • [ Upstream commit 3a9910d7b686546dcc9986e790af17e148f1c888 ]

    qla2x00_tmf_sp_done() now deletes the timer that will run
    qla2x00_tmf_iocb_timeout(), but doesn't check whether the timer already
    expired. Check the return value from del_timer() to avoid calling
    complete() a second time.

    Fixes: 4440e46d5db7 ("[SCSI] qla2xxx: Add IOCB Abort command asynchronous ...")
    Fixes: 1514839b3664 ("scsi: qla2xxx: Fix NULL pointer crash due to active ...")
    Signed-off-by: Ben Hutchings
    Acked-by: Himanshu Madhani
    Signed-off-by: Martin K. Petersen
    Signed-off-by: Sasha Levin

    Ben Hutchings
     
  • [ Upstream commit e279d634f3d57452eb106a0c0e99a6add3fba1a6 ]

    Removed an error message received when configuring ETS total
    bandwidth to be zero.
    Our hardware doesn't support such configuration, so we shall
    reject it in the driver. Nevertheless, we removed the error message
    in order to eliminate error messages caused by old userspace tools
    who try to pass such configuration.

    Fixes: ff0891915cd7 ("net/mlx5e: Fix ETS BW check")
    Signed-off-by: Shay Agroskin
    Reviewed-by: Huy Nguyen
    Reviewed-by: Eran Ben Elisha
    Signed-off-by: Saeed Mahameed
    Signed-off-by: Sasha Levin

    Shay Agroskin
     
  • [ Upstream commit 5df7af85ecd88e8b5f1f31d6456c3cf38a8bbdda ]

    For some phy devices, even though they don't support the MMD extended
    register access, it does have some side effect if we are trying to
    read/write the MMD registers via indirect method. So introduce general
    dummy stubs for MMD register access which these devices can use to avoid
    such side effect.

    Fixes: b6b5e8a69118 ("gianfar: Disable EEE autoneg by default")
    Signed-off-by: Kevin Hao
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Kevin Hao
     
  • [ Upstream commit 0231b1a074c672f8c00da00a57144072890d816b ]

    The Ethernet on mpc8315erdb is broken since commit b6b5e8a69118
    ("gianfar: Disable EEE autoneg by default"). The reason is that
    even though the rtl8211b doesn't support the MMD extended registers
    access, it does return some random values if we trying to access
    the MMD register via indirect method. This makes it seem that the
    EEE is supported by this phy device. And the subsequent writing to
    the MMD registers does cause the phy malfunction. So use the dummy
    stubs for the MMD register access to fix this issue.

    Fixes: b6b5e8a69118 ("gianfar: Disable EEE autoneg by default")
    Signed-off-by: Kevin Hao
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Kevin Hao
     
  • [ Upstream commit e16b4f99f0f79682a7efe191a8ce694d87ca9fc8 ]

    Since crypto API commit 9fa68f62004 ("crypto: hash - prevent using keyed
    hashes without setting key") dm-integrity cannot use keyed algorithms
    without the key being set.

    The dm-integrity recognizes this too late (during use of HMAC), so it
    allows creation and formatting of superblock, but the device is in fact
    unusable.

    Fix it by detecting the key requirement in integrity table constructor.

    Signed-off-by: Milan Broz
    Signed-off-by: Mike Snitzer
    Signed-off-by: Sasha Levin

    Milan Broz
     
  • [ Upstream commit c1e150ceb61e4a585bad156da15c33bfe89f5858 ]

    When CONFIG_NUMA is not set, the build fails with:

    arch/powerpc/platforms/pseries/hotplug-cpu.c:335:4:
    error: déclaration implicite de la fonction « update_numa_cpu_lookup_table »

    So we have to add update_numa_cpu_lookup_table() as an empty function
    when CONFIG_NUMA is not set.

    Fixes: 1d9a090783be ("powerpc/numa: Invalidate numa_cpu_lookup_table on cpu remove")
    Signed-off-by: Corentin Labbe
    Signed-off-by: Michael Ellerman
    Signed-off-by: Sasha Levin

    Corentin Labbe
     
  • [ Upstream commit 6082d9c9c94a408d7409b5f2e4e42ac9e8b16d0d ]

    Adding the vector offset when calling to mlx5_vector2eqn() is wrong.
    This is because mlx5_vector2eqn() checks if EQ index is equal to vector number
    and the fact that the internal completion vectors that mlx5 allocates
    don't get an EQ index.

    The second problem here is that using effective_affinity_mask gives the same
    CPU for different vectors.
    This leads to unmapped queues when calling it from blk_mq_rdma_map_queues().
    This doesn't happen when using affinity_hint mask.

    Fixes: 2572cf57d75a ("mlx5: fix mlx5_get_vector_affinity to start from completion vector 0")
    Fixes: 05e0cc84e00c ("net/mlx5: Fix get vector affinity helper function")
    Signed-off-by: Israel Rukshin
    Reviewed-by: Max Gurtovoy
    Reviewed-by: Sagi Grimberg
    Signed-off-by: Sasha Levin

    Israel Rukshin
     
  • [ Upstream commit 686c97ee29c886ee07d17987d0059874c5c3b5af ]

    Make sure to check both return code fields before(!) processing the
    command response. Otherwise we risk operating on invalid data.

    This matches an earlier fix for SETASSPARMS commands, see
    commit ad3cbf613329 ("s390/qeth: fix error handling in checksum cmd callback").

    Signed-off-by: Julian Wiedmann
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Julian Wiedmann
     
  • [ Upstream commit 6b9f8970cd30929cb6b372fa44fa66da9e59c650 ]

    If the allocation of elem fails, it is not sufficient to simply check
    for NULL and return. We need to also put our reference on the pool or
    else we will leave the pool with a permanent ref count and we will never
    be able to free it.

    Fixes: 4831ca9e4a8e ("IB/rxe: check for allocation failure on elem")
    Suggested-by: Leon Romanovsky
    Signed-off-by: Doug Ledford
    Signed-off-by: Sasha Levin

    Doug Ledford
     
  • [ Upstream commit 1f80bd6a6cc8358b81194e1f5fc16449947396ec ]

    The locking order of vlan_rwsem (LOCK A) and then rtnl (LOCK B),
    contradicts other flows such as ipoib_open possibly causing a deadlock.
    To prevent this deadlock heavy flush is called with RTNL locked and
    only then tries to acquire vlan_rwsem.
    This deadlock is possible only when there are child interfaces.

    [ 140.941758] ======================================================
    [ 140.946276] WARNING: possible circular locking dependency detected
    [ 140.950950] 4.15.0-rc1+ #9 Tainted: G O
    [ 140.954797] ------------------------------------------------------
    [ 140.959424] kworker/u32:1/146 is trying to acquire lock:
    [ 140.963450] (rtnl_mutex){+.+.}, at: [] __ipoib_ib_dev_flush+0x2da/0x4e0 [ib_ipoib]
    [ 140.970006]
    but task is already holding lock:
    [ 140.975141] (&priv->vlan_rwsem){++++}, at: [] __ipoib_ib_dev_flush+0x51/0x4e0 [ib_ipoib]
    [ 140.982105]
    which lock already depends on the new lock.
    [ 140.990023]
    the existing dependency chain (in reverse order) is:
    [ 140.998650]
    -> #1 (&priv->vlan_rwsem){++++}:
    [ 141.005276] down_read+0x4d/0xb0
    [ 141.009560] ipoib_open+0xad/0x120 [ib_ipoib]
    [ 141.014400] __dev_open+0xcb/0x140
    [ 141.017919] __dev_change_flags+0x1a4/0x1e0
    [ 141.022133] dev_change_flags+0x23/0x60
    [ 141.025695] devinet_ioctl+0x704/0x7d0
    [ 141.029156] sock_do_ioctl+0x20/0x50
    [ 141.032526] sock_ioctl+0x221/0x300
    [ 141.036079] do_vfs_ioctl+0xa6/0x6d0
    [ 141.039656] SyS_ioctl+0x74/0x80
    [ 141.042811] entry_SYSCALL_64_fastpath+0x1f/0x96
    [ 141.046891]
    -> #0 (rtnl_mutex){+.+.}:
    [ 141.051701] lock_acquire+0xd4/0x220
    [ 141.055212] __mutex_lock+0x88/0x970
    [ 141.058631] __ipoib_ib_dev_flush+0x2da/0x4e0 [ib_ipoib]
    [ 141.063160] __ipoib_ib_dev_flush+0x71/0x4e0 [ib_ipoib]
    [ 141.067648] process_one_work+0x1f5/0x610
    [ 141.071429] worker_thread+0x4a/0x3f0
    [ 141.074890] kthread+0x141/0x180
    [ 141.078085] ret_from_fork+0x24/0x30
    [ 141.081559]

    other info that might help us debug this:
    [ 141.088967] Possible unsafe locking scenario:
    [ 141.094280] CPU0 CPU1
    [ 141.097953] ---- ----
    [ 141.101640] lock(&priv->vlan_rwsem);
    [ 141.104771] lock(rtnl_mutex);
    [ 141.109207] lock(&priv->vlan_rwsem);
    [ 141.114032] lock(rtnl_mutex);
    [ 141.116800]
    *** DEADLOCK ***

    Fixes: b4b678b06f6e ("IB/ipoib: Grab rtnl lock on heavy flush when calling ndo_open/stop")
    Signed-off-by: Alex Vesker
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin

    Alex Vesker
     
  • [ Upstream commit d18539754d97876503275efc7d00a1901bb0cfad ]

    As reported by Meelis Roos, my previous patch causes an incorrect
    calculation of the timeout, through an undefined signed integer
    overflow:

    [ 12.228155] UBSAN: Undefined behaviour in drivers/scsi/aacraid/commsup.c:2514:49
    [ 12.228229] signed integer overflow:
    [ 12.228283] 964297611 * 250 cannot be represented in type 'long int'

    The problem is that doing a multiplication with HZ first and then
    dividing by USEC_PER_SEC worked correctly for 32-bit microseconds,
    but not for 32-bit nanoseconds, which would require up to 41 bits.

    This reworks the calculation to first convert the nanoseconds into
    jiffies, which should give us the same result as before and not overflow.

    Unfortunately I did not understand the exact intention of the algorithm,
    in particular the part where we add half a second, so it's possible that
    there is still a preexisting problem in this function. I added a comment
    that this would be handled more nicely using usleep_range(), which
    generally works better for waking up at a particular time than the
    current schedule_timeout() based implementation. I did not feel
    comfortable trying to implement that without being sure what the
    intent is here though.

    Fixes: 820f18865912 ("scsi: aacraid: use timespec64 instead of timeval")
    Tested-by: Meelis Roos
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Martin K. Petersen
    Signed-off-by: Sasha Levin

    Arnd Bergmann
     
  • [ Upstream commit 5468099c747240ed97dbb34340fece8ca87be34f ]

    Commit 2f2d0088eb93
    ("usbip: prevent vhci_hcd driver from leaking a socket pointer address")
    in the /sys/devices/platform/vhci_hcd/status.

    Fix the header and field alignment to reflect the changes and make it
    easier to read.

    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Shuah Khan
     
  • [ Upstream commit fb2a1748355161e050e9f49f1ea9a0ae707a148b ]

    Validate command parsing in acpi_nfit_ctl for the clear error command.
    This tests for a crash condition introduced by commit 4b27db7e26cd
    "acpi, nfit: add support for the _LSI, _LSR, and _LSW label methods".

    Cc: Vishal Verma
    Signed-off-by: Dan Williams
    Signed-off-by: Sasha Levin

    Dan Williams
     
  • [ Upstream commit 5cd2d8fc6c6bca979ac5dd8ad0e41153f1f982f9 ]

    The ucode_major and ucode_minor were swapped. This has
    no practical consequences since those fields are not used.
    Same goes for umac_major and umac_minor which were only
    printed under certain debug flags.

    Signed-off-by: Emmanuel Grumbach
    Signed-off-by: Luca Coelho
    Signed-off-by: Sasha Levin

    Emmanuel Grumbach
     
  • [ Upstream commit dfd4b08cf44f27587e2053e006e43a1603328006 ]

    Even if no ALIVE was received, the WRT data can still
    be collected. Add this.

    Signed-off-by: Liad Kaufman
    Signed-off-by: Luca Coelho
    Signed-off-by: Sasha Levin

    Liad Kaufman
     
  • [ Upstream commit 4c59ff5a9a9c54cc26c807dc2fa6933f7e9fa4ef ]

    This bit will be used in CCK to indicate short preamble.

    Signed-off-by: Sara Sharon
    Signed-off-by: Luca Coelho
    Signed-off-by: Sasha Levin

    Sara Sharon
     
  • [ Upstream commit 69eb7765b9c6902444c89c54e7043242faf981e5 ]

    ocfs2_duplicate_clusters_by_page() may crash if one of the extent's pages
    is dirty. When a page has not been written back, it is still in dirty
    state. If ocfs2_duplicate_clusters_by_page() is called against the dirty
    page, the crash happens.

    To fix this bug, we can just unlock the page and wait until the page until
    its not dirty.

    The following is the backtrace:

    kernel BUG at /root/code/ocfs2/refcounttree.c:2961!
    [exception RIP: ocfs2_duplicate_clusters_by_page+822]
    __ocfs2_move_extent+0x80/0x450 [ocfs2]
    ? __ocfs2_claim_clusters+0x130/0x250 [ocfs2]
    ocfs2_defrag_extent+0x5b8/0x5e0 [ocfs2]
    __ocfs2_move_extents_range+0x2a4/0x470 [ocfs2]
    ocfs2_move_extents+0x180/0x3b0 [ocfs2]
    ? ocfs2_wait_for_recovery+0x13/0x70 [ocfs2]
    ocfs2_ioctl_move_extents+0x133/0x2d0 [ocfs2]
    ocfs2_ioctl+0x253/0x640 [ocfs2]
    do_vfs_ioctl+0x90/0x5f0
    SyS_ioctl+0x74/0x80
    do_syscall_64+0x74/0x140
    entry_SYSCALL_64_after_hwframe+0x3d/0xa2

    Once we find the page is dirty, we do not wait until it's clean, rather we
    use write_one_page() to write it back

    Link: http://lkml.kernel.org/r/20180829074740.9438-1-lchen@suse.com
    [lchen@suse.com: update comments]
    Link: http://lkml.kernel.org/r/20180830075041.14879-1-lchen@suse.com
    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Larry Chen
    Acked-by: Changwei Ge
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Junxiao Bi
    Cc: Joseph Qi
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin

    Larry Chen
     
  • [ Upstream commit 0781168e23a2fc8dceb989f11fc5b39b3ccacc35 ]

    In yam_ioctl(), the concrete ioctl command is firstly copied from the
    user-space buffer 'ifr->ifr_data' to 'ioctl_cmd' and checked through the
    following switch statement. If the command is not as expected, an error
    code EINVAL is returned. In the following execution the buffer
    'ifr->ifr_data' is copied again in the cases of the switch statement to
    specific data structures according to what kind of ioctl command is
    requested. However, after the second copy, no re-check is enforced on the
    newly-copied command. Given that the buffer 'ifr->ifr_data' is in the user
    space, a malicious user can race to change the command between the two
    copies. This way, the attacker can inject inconsistent data and cause
    undefined behavior.

    This patch adds a re-check in each case of the switch statement if there is
    a second copy in that case, to re-check whether the command obtained in the
    second copy is the same as the one in the first copy. If not, an error code
    EINVAL will be returned.

    Signed-off-by: Wenwen Wang
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Wenwen Wang
     
  • [ Upstream commit 2c05d88818ab6571816b93edce4d53703870d7ae ]

    In cxgb_extension_ioctl(), the command of the ioctl is firstly copied from
    the user-space buffer 'useraddr' to 'cmd' and checked through the
    switch statement. If the command is not as expected, an error code
    EOPNOTSUPP is returned. In the following execution, i.e., the cases of the
    switch statement, the whole buffer of 'useraddr' is copied again to a
    specific data structure, according to what kind of command is requested.
    However, after the second copy, there is no re-check on the newly-copied
    command. Given that the buffer 'useraddr' is in the user space, a malicious
    user can race to change the command between the two copies. By doing so,
    the attacker can supply malicious data to the kernel and cause undefined
    behavior.

    This patch adds a re-check in each case of the switch statement if there is
    a second copy in that case, to re-check whether the command obtained in the
    second copy is the same as the one in the first copy. If not, an error code
    EINVAL is returned.

    Signed-off-by: Wenwen Wang
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Wenwen Wang
     
  • [ Upstream commit 2d52527e80c2dc0c5f43f50adf183781262ec565 ]

    the be2net implementation of .ndo_tunnel_{add,del}() changes the value of
    NETIF_F_GSO_UDP_TUNNEL bit in 'features' and 'hw_features', but it forgets
    to call netdev_features_change(). Moreover, ethtool setting for that bit
    can potentially be reverted after a tunnel is added or removed.

    GSO already does software segmentation when 'hw_enc_features' is 0, even
    if VXLAN offload is turned on. In addition, commit 096de2f83ebc ("benet:
    stricter vxlan offloading check in be_features_check") avoids hardware
    segmentation of non-VXLAN tunneled packets, or VXLAN packets having wrong
    destination port. So, it's safe to avoid flipping the above feature on
    addition/deletion of VXLAN tunnels.

    Fixes: 630f4b70567f ("be2net: Export tunnel offloads only when a VxLAN tunnel is created")
    Signed-off-by: Davide Caratti
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Davide Caratti
     
  • [ Upstream commit e4a02ed2aaf447fa849e3254bfdb3b9b01e1e520 ]

    If CONFIG_WW_MUTEX_SELFTEST=y is enabled, booting an image
    in an arm64 virtual machine results in the following
    traceback if 8 CPUs are enabled:

    DEBUG_LOCKS_WARN_ON(__owner_task(owner) != current)
    WARNING: CPU: 2 PID: 537 at kernel/locking/mutex.c:1033 __mutex_unlock_slowpath+0x1a8/0x2e0
    ...
    Call trace:
    __mutex_unlock_slowpath()
    ww_mutex_unlock()
    test_cycle_work()
    process_one_work()
    worker_thread()
    kthread()
    ret_from_fork()

    If requesting b_mutex fails with -EDEADLK, the error variable
    is reassigned to the return value from calling ww_mutex_lock
    on a_mutex again. If this call fails, a_mutex is not locked.
    It is, however, unconditionally unlocked subsequently, causing
    the reported warning. Fix the problem by using two error variables.

    With this change, the selftest still fails as follows:

    cyclic deadlock not resolved, ret[7/8] = -35

    However, the traceback is gone.

    Signed-off-by: Guenter Roeck
    Cc: Chris Wilson
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Will Deacon
    Fixes: d1b42b800e5d0 ("locking/ww_mutex: Add kselftests for resolving ww_mutex cyclic deadlocks")
    Link: http://lkml.kernel.org/r/1538516929-9734-1-git-send-email-linux@roeck-us.net
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin

    Guenter Roeck
     
  • [ Upstream commit a07f388e2cde2be74b263f85df6f672fea0305a1 ]

    RMNET RX handler was processing invalid packets that were
    originally sent on the real device and were looped back via
    dev_loopback_xmit(). This was detected using syzkaller.

    Fixes: ceed73a2cf4a ("drivers: net: ethernet: qualcomm: rmnet: Initial implementation")
    Signed-off-by: Sean Tranchetti
    Signed-off-by: Subash Abhinov Kasiviswanathan
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Sean Tranchetti
     
  • [ Upstream commit fe3a83af6a50199bf250fa331e94216912f79395 ]

    Fix a commit 4bcc595ccd80 ("printk: reinstate KERN_CONT for printing
    continuation lines") regression with the `declance' driver, which caused
    the adapter identification message to be split between two lines, e.g.:

    declance.c: v0.011 by Linux MIPS DECstation task force
    tc6: PMAD-AA
    , addr = 08:00:2b:1b:2a:6a, irq = 14
    tc6: registered as eth0.

    Address that properly, by printing identification with a single call,
    making the messages now look like:

    declance.c: v0.011 by Linux MIPS DECstation task force
    tc6: PMAD-AA, addr = 08:00:2b:1b:2a:6a, irq = 14
    tc6: registered as eth0.

    Signed-off-by: Maciej W. Rozycki
    Fixes: 4bcc595ccd80 ("printk: reinstate KERN_CONT for printing continuation lines")
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Maciej W. Rozycki
     
  • [ Upstream commit 657ade07df72847f591ccdb36bd9b91ed0edbac3 ]

    During certain heavy network loads TX could time out
    with TX ring dump.
    TX is sometimes never restarted after reaching
    "tx_stop_threshold" because function "fec_enet_tx_queue"
    only tests the first queue.

    In addition the TX timeout callback function failed to
    recover because it also operated only on the first queue.

    Signed-off-by: Rickard x Andersson
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Rickard x Andersson
     
  • [ Upstream commit d7cbbe49a9304520181fb8c9272d1327deec8453 ]

    In Family 17h, some L3 Cache Performance events require the ThreadMask
    and SliceMask to be set. For other events, these fields do not affect
    the count either way.

    Set ThreadMask and SliceMask to 0xFF and 0xF respectively.

    Signed-off-by: Janakarajan Natarajan
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Alexander Shishkin
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Borislav Petkov
    Cc: H . Peter Anvin
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Suravee
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Link: http://lkml.kernel.org/r/Message-ID:
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin

    Natarajan, Janakarajan
     
  • [ Upstream commit 9d92cfeaf5215158d26d2991be7f7ff865cb98f3 ]

    The counters on M3UPI Link 0 and Link 3 don't count properly, and writing
    0 to these counters may causes system crash on some machines.

    The PCI BDF addresses of the M3UPI in the current code are incorrect.

    The correct addresses should be:

    D18:F1 0x204D
    D18:F2 0x204E
    D18:F5 0x204D

    Signed-off-by: Kan Liang
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Alexander Shishkin
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Fixes: cd34cd97b7b4 ("perf/x86/intel/uncore: Add Skylake server uncore support")
    Link: http://lkml.kernel.org/r/1537538826-55489-1-git-send-email-kan.liang@linux.intel.com
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin

    Kan Liang
     
  • [ Upstream commit cd6fb677ce7e460c25bdd66f689734102ec7d642 ]

    Some of the scheduling tracepoints allow the perf_tp_event
    code to write to ring buffer under different cpu than the
    code is running on.

    This results in corrupted ring buffer data demonstrated in
    following perf commands:

    # perf record -e 'sched:sched_switch,sched:sched_wakeup' perf bench sched messaging
    # Running 'sched/messaging' benchmark:
    # 20 sender and receiver processes per group
    # 10 groups == 400 processes run

    Total time: 0.383 [sec]
    [ perf record: Woken up 8 times to write data ]
    0x42b890 [0]: failed to process type: -1765585640
    [ perf record: Captured and wrote 4.825 MB perf.data (29669 samples) ]

    # perf report --stdio
    0x42b890 [0]: failed to process type: -1765585640

    The reason for the corruption are some of the scheduling tracepoints,
    that have __perf_task dfined and thus allow to store data to another
    cpu ring buffer:

    sched_waking
    sched_wakeup
    sched_wakeup_new
    sched_stat_wait
    sched_stat_sleep
    sched_stat_iowait
    sched_stat_blocked

    The perf_tp_event function first store samples for current cpu
    related events defined for tracepoint:

    hlist_for_each_entry_rcu(event, head, hlist_entry)
    perf_swevent_event(event, count, &data, regs);

    And then iterates events of the 'task' and store the sample
    for any task's event that passes tracepoint checks:

    ctx = rcu_dereference(task->perf_event_ctxp[perf_sw_context]);

    list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
    if (event->attr.type != PERF_TYPE_TRACEPOINT)
    continue;
    if (event->attr.config != entry->type)
    continue;

    perf_swevent_event(event, count, &data, regs);
    }

    Above code can race with same code running on another cpu,
    ending up with 2 cpus trying to store under the same ring
    buffer, which is specifically not allowed.

    This patch prevents the problem, by allowing only events with the same
    current cpu to receive the event.

    NOTE: this requires the use of (per-task-)per-cpu buffers for this
    feature to work; perf-record does this.

    Signed-off-by: Jiri Olsa
    [peterz: small edits to Changelog]
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Alexander Shishkin
    Cc: Andrew Vagin
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Fixes: e6dab5ffab59 ("perf/trace: Add ability to set a target task for events")
    Link: http://lkml.kernel.org/r/20180923161343.GB15054@krava
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin

    Jiri Olsa
     
  • [ Upstream commit a9f9772114c8b07ae75bcb3654bd017461248095 ]

    When we unregister a PMU, we fail to serialize the @pmu_idr properly.
    Fix that by doing the entire thing under pmu_lock.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Alexander Shishkin
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Fixes: 2e80a82a49c4 ("perf: Dynamic pmu types")
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin

    Peter Zijlstra
     
  • [ Upstream commit 1db58529454742f67ebd96e3588315e880b72837 ]

    reg_process_hint_country_ie() can free regulatory_request and return
    REG_REQ_ALREADY_SET. We shouldn't use regulatory_request after it's
    called. KASAN error was observed when this happens.

    BUG: KASAN: use-after-free in reg_process_hint+0x839/0x8aa [cfg80211]
    Read of size 4 at addr ffff8800c430d434 by task kworker/1:3/89

    Workqueue: events reg_todo [cfg80211]
    Call Trace:
    dump_stack+0xc1/0x10c
    ? _atomic_dec_and_lock+0x1ad/0x1ad
    ? _raw_spin_lock_irqsave+0xa0/0xd2
    print_address_description+0x86/0x26f
    ? reg_process_hint+0x839/0x8aa [cfg80211]
    kasan_report+0x241/0x29b
    reg_process_hint+0x839/0x8aa [cfg80211]
    reg_todo+0x204/0x5b9 [cfg80211]
    process_one_work+0x55f/0x8d0
    ? worker_detach_from_pool+0x1b5/0x1b5
    ? _raw_spin_unlock_irq+0x65/0xdd
    ? _raw_spin_unlock_irqrestore+0xf3/0xf3
    worker_thread+0x5dd/0x841
    ? kthread_parkme+0x1d/0x1d
    kthread+0x270/0x285
    ? pr_cont_work+0xe3/0xe3
    ? rcu_read_unlock_sched_notrace+0xca/0xca
    ret_from_fork+0x22/0x40

    Allocated by task 2718:
    set_track+0x63/0xfa
    __kmalloc+0x119/0x1ac
    regulatory_hint_country_ie+0x38/0x329 [cfg80211]
    __cfg80211_connect_result+0x854/0xadd [cfg80211]
    cfg80211_rx_assoc_resp+0x3bc/0x4f0 [cfg80211]
    smsc95xx v1.0.6
    ieee80211_sta_rx_queued_mgmt+0x1803/0x7ed5 [mac80211]
    ieee80211_iface_work+0x411/0x696 [mac80211]
    process_one_work+0x55f/0x8d0
    worker_thread+0x5dd/0x841
    kthread+0x270/0x285
    ret_from_fork+0x22/0x40

    Freed by task 89:
    set_track+0x63/0xfa
    kasan_slab_free+0x6a/0x87
    kfree+0xdc/0x470
    reg_process_hint+0x31e/0x8aa [cfg80211]
    reg_todo+0x204/0x5b9 [cfg80211]
    process_one_work+0x55f/0x8d0
    worker_thread+0x5dd/0x841
    kthread+0x270/0x285
    ret_from_fork+0x22/0x40

    Signed-off-by: Yu Zhao
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Yu Zhao
     
  • [ Upstream commit c530c471ba37bdd9fe1c7185b01455c00ae606fb ]

    The driver does not check for Wake-on-LAN modes specified by an user,
    but will conditionally set the device as wake-up enabled or not based on
    that, which could be a very confusing user experience.

    Fixes: e0e474a83c18 ("smsc95xx: add wol magic packet support")
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Florian Fainelli
     
  • [ Upstream commit 9c734b2769a73eea2e9e9767c0e0bf839ff23679 ]

    The driver does not check for Wake-on-LAN modes specified by an user,
    but will conditionally set the device as wake-up enabled or not based on
    that, which could be a very confusing user experience.

    Fixes: 6c636503260d ("smsc75xx: add wol magic packet support")
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Florian Fainelli
     
  • [ Upstream commit f2750df1548bd8a2b060eb609fc43ca82811af4c ]

    The driver does not check for Wake-on-LAN modes specified by an user,
    but will conditionally set the device as wake-up enabled or not based on
    that, which could be a very confusing user experience.

    Fixes: 21ff2e8976b1 ("r8152: support WOL")
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Florian Fainelli
     
  • [ Upstream commit c5cb93e994ffb43b7b3b1ff10b9f928f54574a36 ]

    The driver currently silently accepts unsupported Wake-on-LAN modes
    (other than WAKE_PHY or WAKE_MAGIC) without reporting that to the user,
    which is confusing.

    Fixes: 19a38d8e0aa3 ("USB2NET : SR9800 : One chip USB2.0 USB2NET SR9800 Device Driver Support")
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Florian Fainelli
     
  • [ Upstream commit eb9ad088f96653a26b340f7c447c44cf023d5cdc ]

    The driver supports a fair amount of Wake-on-LAN modes, but is not
    checking that the user specified one that is supported.

    Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
    Signed-off-by: Florian Fainelli
    Reviewed-by: Woojung Huh
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Florian Fainelli
     
  • [ Upstream commit 5ba6b4aa9a410c5e2c6417df52b5e2118ea9b467 ]

    The driver currently silently accepts unsupported Wake-on-LAN modes
    (other than WAKE_PHY or WAKE_MAGIC) without reporting that to the user,
    which is confusing.

    Fixes: e2ca90c276e1 ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver")
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Florian Fainelli
     
  • [ Upstream commit c4ce446e33d7a0e978256ac6fea4c80e59d9de5f ]

    The driver currently silently accepts unsupported Wake-on-LAN modes
    (other than WAKE_PHY or WAKE_MAGIC) without reporting that to the user,
    which is confusing.

    Fixes: 2e55cc7210fe ("[PATCH] USB: usbnet (3/9) module for ASIX Ethernet adapters")
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Florian Fainelli
     
  • [ Upstream commit 1222a16014888ed9733c11e221730d4a8196222b ]

    Use array_index_nospec() to sanitize i with respect to speculation.

    Note that the user doesn't control i directly, but can make it out
    of bounds by not finding a threshold in the array.

    Signed-off-by: Masashi Honma
    [add note about user control, as explained by Masashi]
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Masashi Honma
     
  • [ Upstream commit 77f2d753819b7d50c16abfb778caf1fe075faed0 ]

    Clang warns when one enumerated type is implicitly converted to another.

    drivers/net/ethernet/qlogic/qed/qed_iwarp.c:1713:25: warning: implicit
    conversion from enumeration type 'enum tcp_ip_version' to different
    enumeration type 'enum qed_tcp_ip_version' [-Wenum-conversion]
    cm_info->ip_version = TCP_IPV4;
    ~ ^~~~~~~~
    drivers/net/ethernet/qlogic/qed/qed_iwarp.c:1733:25: warning: implicit
    conversion from enumeration type 'enum tcp_ip_version' to different
    enumeration type 'enum qed_tcp_ip_version' [-Wenum-conversion]
    cm_info->ip_version = TCP_IPV6;
    ~ ^~~~~~~~
    2 warnings generated.

    Use the appropriate values from the expected type, qed_tcp_ip_version:

    TCP_IPV4 = QED_TCP_IPV4 = 0
    TCP_IPV6 = QED_TCP_IPV6 = 1

    Link: https://github.com/ClangBuiltLinux/linux/issues/125
    Signed-off-by: Nathan Chancellor
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Nathan Chancellor
     
  • [ Upstream commit 1c492a9d55ba99079210ed901dd8a5423f980487 ]

    Clang warns when a constant is used in a boolean context as it thinks a
    bitwise operation may have been intended.

    drivers/net/ethernet/qlogic/qed/qed_vf.c:415:27: warning: use of logical
    '&&' with constant operand [-Wconstant-logical-operand]
    if (!p_iov->b_pre_fp_hsi &&
    ^
    drivers/net/ethernet/qlogic/qed/qed_vf.c:415:27: note: use '&' for a
    bitwise operation
    if (!p_iov->b_pre_fp_hsi &&
    ^~
    &
    drivers/net/ethernet/qlogic/qed/qed_vf.c:415:27: note: remove constant
    to silence this warning
    if (!p_iov->b_pre_fp_hsi &&
    ~^~
    1 warning generated.

    This has been here since commit 1fe614d10f45 ("qed: Relax VF firmware
    requirements") and I am not entirely sure why since 0 isn't a special
    case. Just remove the statement causing Clang to warn since it isn't
    required.

    Link: https://github.com/ClangBuiltLinux/linux/issues/126
    Signed-off-by: Nathan Chancellor
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Nathan Chancellor