Skip to content
Snippets Groups Projects
  1. Nov 04, 2019
    • Todd Kjos's avatar
      binder: binder: fix possible UAF when freeing buffer · b50355fe
      Todd Kjos authored
      
      There is a race between the binder driver cleaning
      up a completed transaction via binder_free_transaction()
      and a user calling binder_ioctl(BC_FREE_BUFFER) to
      release a buffer. It doesn't matter which is first but
      they need to be protected against running concurrently
      which can result in a UAF.
      
      Bug: 133758011
      Change-Id: Ie1426ff3d00218d050d61ff77b333ddf8818b7c9
      Signed-off-by: default avatarTodd Kjos <tkjos@google.com>
  2. Oct 29, 2019
    • Greg Kroah-Hartman's avatar
      Merge 4.4.198 into android-4.4-o · 4685deca
      Greg Kroah-Hartman authored
      
      Changes in 4.4.198
      	scsi: ufs: skip shutdown if hba is not powered
      	scsi: megaraid: disable device when probe failed after enabled device
      	scsi: qla2xxx: Fix unbound sleep in fcport delete path.
      	ARM: OMAP2+: Fix missing reset done flag for am3 and am43
      	ARM: dts: am4372: Set memory bandwidth limit for DISPC
      	nl80211: fix null pointer dereference
      	mips: Loongson: Fix the link time qualifier of 'serial_exit()'
      	net: hisilicon: Fix usage of uninitialized variable in function mdio_sc_cfg_reg_write()
      	namespace: fix namespace.pl script to support relative paths
      	loop: Add LOOP_SET_DIRECT_IO to compat ioctl
      	net: bcmgenet: Fix RGMII_MODE_EN value for GENET v1/2/3
      	net: bcmgenet: Set phydev->dev_flags only for internal PHYs
      	sctp: change sctp_prot .no_autobind with true
      	net: avoid potential infinite loop in tc_ctl_action()
      	ipv4: Return -ENETUNREACH if we can't create route but saddr is valid
      	memfd: Fix locking when tagging pins
      	USB: legousbtower: fix memleak on disconnect
      	usb: udc: lpc32xx: fix bad bit shift operation
      	USB: serial: ti_usb_3410_5052: fix port-close races
      	USB: ldusb: fix memleak on disconnect
      	USB: usblp: fix use-after-free on disconnect
      	USB: ldusb: fix read info leaks
      	scsi: core: try to get module before removing device
      	ASoC: rsnd: Reinitialize bit clock inversion flag for every format setting
      	cfg80211: wext: avoid copying malformed SSIDs
      	mac80211: Reject malformed SSID elements
      	drm/edid: Add 6 bpc quirk for SDC panel in Lenovo G50
      	scsi: zfcp: fix reaction on bit error threshold notification
      	mm/slub: fix a deadlock in show_slab_objects()
      	xtensa: drop EXPORT_SYMBOL for outs*/ins*
      	parisc: Fix vmap memory leak in ioremap()/iounmap()
      	CIFS: avoid using MID 0xFFFF
      	btrfs: block-group: Fix a memory leak due to missing btrfs_put_block_group()
      	memstick: jmb38x_ms: Fix an error handling path in 'jmb38x_ms_probe()'
      	cpufreq: Avoid cpufreq_suspend() deadlock on system shutdown
      	xen/netback: fix error path of xenvif_connect_data()
      	PCI: PM: Fix pci_power_up()
      	net: sched: Fix memory exposure from short TCA_U32_SEL
      	RDMA/cxgb4: Do not dma memory off of the stack
      	Linux 4.4.198
      
      Change-Id: Ia32cdd181db826ddc5abc8d72416de3f28f19253
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
      4685deca
    • Greg Kroah-Hartman's avatar
      Linux 4.4.198 · da259d02
      Greg Kroah-Hartman authored
      v4.4.198
      da259d02
    • Greg KH's avatar
      RDMA/cxgb4: Do not dma memory off of the stack · 3cd06985
      Greg KH authored
      commit 3840c5b7 upstream.
      
      Nicolas pointed out that the cxgb4 driver is doing dma off of the stack,
      which is generally considered a very bad thing.  On some architectures it
      could be a security problem, but odds are none of them actually run this
      driver, so it's just a "normal" bug.
      
      Resolve this by allocating the memory for a message off of the heap
      instead of the stack.  kmalloc() always will give us a proper memory
      location that DMA will work correctly from.
      
      Link: https://lore.kernel.org/r/20191001165611.GA3542072@kroah.com
      
      
      Reported-by: default avatarNicolas Waisman <nico@semmle.com>
      Tested-by: default avatarPotnuri Bharat Teja <bharat@chelsio.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3cd06985
    • Kees Cook's avatar
      net: sched: Fix memory exposure from short TCA_U32_SEL · 23e0c38d
      Kees Cook authored
      
      commit 98c8f125 upstream.
      
      Via u32_change(), TCA_U32_SEL has an unspecified type in the netlink
      policy, so max length isn't enforced, only minimum. This means nkeys
      (from userspace) was being trusted without checking the actual size of
      nla_len(), which could lead to a memory over-read, and ultimately an
      exposure via a call to u32_dump(). Reachability is CAP_NET_ADMIN within
      a namespace.
      
      Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: netdev@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarZubin Mithra <zsm@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23e0c38d
    • Rafael J. Wysocki's avatar
      PCI: PM: Fix pci_power_up() · 439a1962
      Rafael J. Wysocki authored
      
      commit 45144d42 upstream.
      
      There is an arbitrary difference between the system resume and
      runtime resume code paths for PCI devices regarding the delay to
      apply when switching the devices from D3cold to D0.
      
      Namely, pci_restore_standard_config() used in the runtime resume
      code path calls pci_set_power_state() which in turn invokes
      __pci_start_power_transition() to power up the device through the
      platform firmware and that function applies the transition delay
      (as per PCI Express Base Specification Revision 2.0, Section 6.6.1).
      However, pci_pm_default_resume_early() used in the system resume
      code path calls pci_power_up() which doesn't apply the delay at
      all and that causes issues to occur during resume from
      suspend-to-idle on some systems where the delay is required.
      
      Since there is no reason for that difference to exist, modify
      pci_power_up() to follow pci_set_power_state() more closely and
      invoke __pci_start_power_transition() from there to call the
      platform firmware to power up the device (in case that's necessary).
      
      Fixes: db288c9c ("PCI / PM: restore the original behavior of pci_set_power_state()")
      Reported-by: default avatarDaniel Drake <drake@endlessm.com>
      Tested-by: default avatarDaniel Drake <drake@endlessm.com>
      Link: https://lore.kernel.org/linux-pm/CAD8Lp44TYxrMgPLkHCqF9hv6smEurMXvmmvmtyFhZ6Q4SE+dig@mail.gmail.com/T/#m21be74af263c6a34f36e0fc5c77c5449d9406925
      
      
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Cc: 3.10+ <stable@vger.kernel.org> # 3.10+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      439a1962
    • Juergen Gross's avatar
      xen/netback: fix error path of xenvif_connect_data() · b3310bf5
      Juergen Gross authored
      
      commit 3d5c1a03 upstream.
      
      xenvif_connect_data() calls module_put() in case of error. This is
      wrong as there is no related module_get().
      
      Remove the superfluous module_put().
      
      Fixes: 279f438e ("xen-netback: Don't destroy the netdev until the vif is shut down")
      Cc: <stable@vger.kernel.org> # 3.12
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarPaul Durrant <paul@xen.org>
      Reviewed-by: default avatarWei Liu <wei.liu@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b3310bf5
    • Rafael J. Wysocki's avatar
      cpufreq: Avoid cpufreq_suspend() deadlock on system shutdown · 8bfa06ea
      Rafael J. Wysocki authored
      
      commit 65650b35 upstream.
      
      It is incorrect to set the cpufreq syscore shutdown callback pointer
      to cpufreq_suspend(), because that function cannot be run in the
      syscore stage of system shutdown for two reasons: (a) it may attempt
      to carry out actions depending on devices that have already been shut
      down at that point and (b) the RCU synchronization carried out by it
      may not be able to make progress then.
      
      The latter issue has been present since commit 45975c7d ("rcu:
      Define RCU-sched API in terms of RCU for Tree RCU PREEMPT builds"),
      but the former one has been there since commit 90de2a4a ("cpufreq:
      suspend cpufreq governors on shutdown") regardless.
      
      Fix that by dropping cpufreq_syscore_ops altogether and making
      device_shutdown() call cpufreq_suspend() directly before shutting
      down devices, which is along the lines of what system-wide power
      management does.
      
      Fixes: 45975c7d ("rcu: Define RCU-sched API in terms of RCU for Tree RCU PREEMPT builds")
      Fixes: 90de2a4a ("cpufreq: suspend cpufreq governors on shutdown")
      Reported-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Tested-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Cc: 4.0+ <stable@vger.kernel.org> # 4.0+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8bfa06ea
    • Christophe JAILLET's avatar
      memstick: jmb38x_ms: Fix an error handling path in 'jmb38x_ms_probe()' · 44137b2c
      Christophe JAILLET authored
      
      commit 28c9fac0 upstream.
      
      If 'jmb38x_ms_count_slots()' returns 0, we must undo the previous
      'pci_request_regions()' call.
      
      Goto 'err_out_int' to fix it.
      
      Fixes: 60fdd931 ("memstick: add support for JMicron jmb38x MemoryStick host controller")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      44137b2c
    • Qu Wenruo's avatar
      btrfs: block-group: Fix a memory leak due to missing btrfs_put_block_group() · df514f91
      Qu Wenruo authored
      
      commit 4b654acd upstream.
      
      In btrfs_read_block_groups(), if we have an invalid block group which
      has mixed type (DATA|METADATA) while the fs doesn't have MIXED_GROUPS
      feature, we error out without freeing the block group cache.
      
      This patch will add the missing btrfs_put_block_group() to prevent
      memory leak.
      
      Note for stable backports: the file to patch in versions <= 5.3 is
      fs/btrfs/extent-tree.c
      
      Fixes: 49303381 ("Btrfs: bail out if block group has different mixed flag")
      CC: stable@vger.kernel.org # 4.9+
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      df514f91
    • Roberto Bergantinos Corpas's avatar
      CIFS: avoid using MID 0xFFFF · 0fef1c7d
      Roberto Bergantinos Corpas authored
      
      commit 03d9a9fe upstream.
      
      According to MS-CIFS specification MID 0xFFFF should not be used by the
      CIFS client, but we actually do. Besides, this has proven to cause races
      leading to oops between SendReceive2/cifs_demultiplex_thread. On SMB1,
      MID is a 2 byte value easy to reach in CurrentMid which may conflict with
      an oplock break notification request coming from server
      
      Signed-off-by: default avatarRoberto Bergantinos Corpas <rbergant@redhat.com>
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0fef1c7d
    • Helge Deller's avatar
      parisc: Fix vmap memory leak in ioremap()/iounmap() · b7f9ec25
      Helge Deller authored
      
      commit 513f7f74 upstream.
      
      Sven noticed that calling ioremap() and iounmap() multiple times leads
      to a vmap memory leak:
      	vmap allocation for size 4198400 failed:
      	use vmalloc=<size> to increase size
      
      It seems we missed calling vunmap() in iounmap().
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Noticed-by: default avatarSven Schnelle <svens@stackframe.org>
      Cc: <stable@vger.kernel.org> # v3.16+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b7f9ec25
    • Max Filippov's avatar
      xtensa: drop EXPORT_SYMBOL for outs*/ins* · e1eccccb
      Max Filippov authored
      
      commit 8b39da98 upstream.
      
      Custom outs*/ins* implementations are long gone from the xtensa port,
      remove matching EXPORT_SYMBOLs.
      This fixes the following build warnings issued by modpost since commit
      15bfc234 ("modpost: check for static EXPORT_SYMBOL* functions"):
      
        WARNING: "insb" [vmlinux] is a static EXPORT_SYMBOL
        WARNING: "insw" [vmlinux] is a static EXPORT_SYMBOL
        WARNING: "insl" [vmlinux] is a static EXPORT_SYMBOL
        WARNING: "outsb" [vmlinux] is a static EXPORT_SYMBOL
        WARNING: "outsw" [vmlinux] is a static EXPORT_SYMBOL
        WARNING: "outsl" [vmlinux] is a static EXPORT_SYMBOL
      
      Cc: stable@vger.kernel.org
      Fixes: d38efc1f ("xtensa: adopt generic io routines")
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e1eccccb
    • Qian Cai's avatar
      mm/slub: fix a deadlock in show_slab_objects() · cff989b7
      Qian Cai authored
      commit e4f8e513 upstream.
      
      A long time ago we fixed a similar deadlock in show_slab_objects() [1].
      However, it is apparently due to the commits like 01fb58bc ("slab:
      remove synchronous synchronize_sched() from memcg cache deactivation
      path") and 03afc0e2 ("slab: get_online_mems for
      kmem_cache_{create,destroy,shrink}"), this kind of deadlock is back by
      just reading files in /sys/kernel/slab which will generate a lockdep
      splat below.
      
      Since the "mem_hotplug_lock" here is only to obtain a stable online node
      mask while racing with NUMA node hotplug, in the worst case, the results
      may me miscalculated while doing NUMA node hotplug, but they shall be
      corrected by later reads of the same files.
      
        WARNING: possible circular locking dependency detected
        ------------------------------------------------------
        cat/5224 is trying to acquire lock:
        ffff900012ac3120 (mem_hotplug_lock.rw_sem){++++}, at:
        show_slab_objects+0x94/0x3a8
      
        but task is already holding lock:
        b8ff009693eee398 (kn->count#45){++++}, at: kernfs_seq_start+0x44/0xf0
      
        which lock already depends on the new lock.
      
        the existing dependency chain (in reverse order) is:
      
        -> #2 (kn->count#45){++++}:
               lock_acquire+0x31c/0x360
               __kernfs_remove+0x290/0x490
               kernfs_remove+0x30/0x44
               sysfs_remove_dir+0x70/0x88
               kobject_del+0x50/0xb0
               sysfs_slab_unlink+0x2c/0x38
               shutdown_cache+0xa0/0xf0
               kmemcg_cache_shutdown_fn+0x1c/0x34
               kmemcg_workfn+0x44/0x64
               process_one_work+0x4f4/0x950
               worker_thread+0x390/0x4bc
               kthread+0x1cc/0x1e8
               ret_from_fork+0x10/0x18
      
        -> #1 (slab_mutex){+.+.}:
               lock_acquire+0x31c/0x360
               __mutex_lock_common+0x16c/0xf78
               mutex_lock_nested+0x40/0x50
               memcg_create_kmem_cache+0x38/0x16c
               memcg_kmem_cache_create_func+0x3c/0x70
               process_one_work+0x4f4/0x950
               worker_thread+0x390/0x4bc
               kthread+0x1cc/0x1e8
               ret_from_fork+0x10/0x18
      
        -> #0 (mem_hotplug_lock.rw_sem){++++}:
               validate_chain+0xd10/0x2bcc
               __lock_acquire+0x7f4/0xb8c
               lock_acquire+0x31c/0x360
               get_online_mems+0x54/0x150
               show_slab_objects+0x94/0x3a8
               total_objects_show+0x28/0x34
               slab_attr_show+0x38/0x54
               sysfs_kf_seq_show+0x198/0x2d4
               kernfs_seq_show+0xa4/0xcc
               seq_read+0x30c/0x8a8
               kernfs_fop_read+0xa8/0x314
               __vfs_read+0x88/0x20c
               vfs_read+0xd8/0x10c
               ksys_read+0xb0/0x120
               __arm64_sys_read+0x54/0x88
               el0_svc_handler+0x170/0x240
               el0_svc+0x8/0xc
      
        other info that might help us debug this:
      
        Chain exists of:
          mem_hotplug_lock.rw_sem --> slab_mutex --> kn->count#45
      
         Possible unsafe locking scenario:
      
               CPU0                    CPU1
               ----                    ----
          lock(kn->count#45);
                                       lock(slab_mutex);
                                       lock(kn->count#45);
          lock(mem_hotplug_lock.rw_sem);
      
         *** DEADLOCK ***
      
        3 locks held by cat/5224:
         #0: 9eff00095b14b2a0 (&p->lock){+.+.}, at: seq_read+0x4c/0x8a8
         #1: 0eff008997041480 (&of->mutex){+.+.}, at: kernfs_seq_start+0x34/0xf0
         #2: b8ff009693eee398 (kn->count#45){++++}, at:
        kernfs_seq_start+0x44/0xf0
      
        stack backtrace:
        Call trace:
         dump_backtrace+0x0/0x248
         show_stack+0x20/0x2c
         dump_stack+0xd0/0x140
         print_circular_bug+0x368/0x380
         check_noncircular+0x248/0x250
         validate_chain+0xd10/0x2bcc
         __lock_acquire+0x7f4/0xb8c
         lock_acquire+0x31c/0x360
         get_online_mems+0x54/0x150
         show_slab_objects+0x94/0x3a8
         total_objects_show+0x28/0x34
         slab_attr_show+0x38/0x54
         sysfs_kf_seq_show+0x198/0x2d4
         kernfs_seq_show+0xa4/0xcc
         seq_read+0x30c/0x8a8
         kernfs_fop_read+0xa8/0x314
         __vfs_read+0x88/0x20c
         vfs_read+0xd8/0x10c
         ksys_read+0xb0/0x120
         __arm64_sys_read+0x54/0x88
         el0_svc_handler+0x170/0x240
         el0_svc+0x8/0xc
      
      I think it is important to mention that this doesn't expose the
      show_slab_objects to use-after-free.  There is only a single path that
      might really race here and that is the slab hotplug notifier callback
      __kmem_cache_shrink (via slab_mem_going_offline_callback) but that path
      doesn't really destroy kmem_cache_node data structures.
      
      [1] http://lkml.iu.edu/hypermail/linux/kernel/1101.0/02850.html
      
      [akpm@linux-foundation.org: add comment explaining why we don't need mem_hotplug_lock]
      Link: http://lkml.kernel.org/r/1570192309-10132-1-git-send-email-cai@lca.pw
      
      
      Fixes: 01fb58bc ("slab: remove synchronous synchronize_sched() from memcg cache deactivation path")
      Fixes: 03afc0e2 ("slab: get_online_mems for kmem_cache_{create,destroy,shrink}")
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
      Cc: Roman Gushchin <guro@fb.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cff989b7
    • Steffen Maier's avatar
      scsi: zfcp: fix reaction on bit error threshold notification · 8af00884
      Steffen Maier authored
      [ Upstream commit 2190168a ]
      
      On excessive bit errors for the FCP channel ingress fibre path, the channel
      notifies us.  Previously, we only emitted a kernel message and a trace
      record.  Since performance can become suboptimal with I/O timeouts due to
      bit errors, we now stop using an FCP device by default on channel
      notification so multipath on top can timely failover to other paths.  A new
      module parameter zfcp.ber_stop can be used to get zfcp old behavior.
      
      User explanation of new kernel message:
      
       * Description:
       * The FCP channel reported that its bit error threshold has been exceeded.
       * These errors might result from a problem with the physical components
       * of the local fibre link into the FCP channel.
       * The problem might be damage or malfunction of the cable or
       * cable connection between the FCP channel and
       * the adjacent fabric switch port or the point-to-point peer.
       * Find details about the errors in the HBA trace for the FCP device.
       * The zfcp device driver closed down the FCP device
       * to limit the performance impact from possible I/O command timeouts.
       * User action:
       * Check for problems on the local fibre link, ensure that fibre optics are
       * clean and functional, and all cables are properly plugged.
       * After the repair action, you can manually recover the FCP device by
       * writing "0" into its "failed" sysfs attribute.
       * If recovery through sysfs is not possible, set the CHPID of the device
       * offline and back online on the service element.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: <stable@vger.kernel.org> #2.6.30+
      Link: https://lore.kernel.org/r/20191001104949.42810-1-maier@linux.ibm.com
      
      
      Reviewed-by: default avatarJens Remus <jremus@linux.ibm.com>
      Reviewed-by: default avatarBenjamin Block <bblock@linux.ibm.com>
      Signed-off-by: default avatarSteffen Maier <maier@linux.ibm.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8af00884
    • Kai-Heng Feng's avatar
    • Will Deacon's avatar
      mac80211: Reject malformed SSID elements · 86962d9a
      Will Deacon authored
      
      commit 4152561f upstream.
      
      Although this shouldn't occur in practice, it's a good idea to bounds
      check the length field of the SSID element prior to using it for things
      like allocations or memcpy operations.
      
      Cc: <stable@vger.kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Reported-by: default avatarNicolas Waisman <nico@semmle.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20191004095132.15777-1-will@kernel.org
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86962d9a
    • Will Deacon's avatar
      cfg80211: wext: avoid copying malformed SSIDs · 3ca40f2f
      Will Deacon authored
      
      commit 4ac2813c upstream.
      
      Ensure the SSID element is bounds-checked prior to invoking memcpy()
      with its length field, when copying to userspace.
      
      Cc: <stable@vger.kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Reported-by: default avatarNicolas Waisman <nico@semmle.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20191004095132.15777-2-will@kernel.org
      
      
      [adjust commit log a bit]
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3ca40f2f
    • Junya Monden's avatar
      ASoC: rsnd: Reinitialize bit clock inversion flag for every format setting · 65ac31fb
      Junya Monden authored
      
      commit 22e58665 upstream.
      
      Unlike other format-related DAI parameters, rdai->bit_clk_inv flag
      is not properly re-initialized when setting format for new stream
      processing. The inversion, if requested, is then applied not to default,
      but to a previous value, which leads to SCKP bit in SSICR register being
      set incorrectly.
      Fix this by re-setting the flag to its initial value, determined by format.
      
      Fixes: 1a7889ca ("ASoC: rsnd: fixup SND_SOC_DAIFMT_xB_xF behavior")
      Cc: Andrew Gabbasov <andrew_gabbasov@mentor.com>
      Cc: Jiada Wang <jiada_wang@mentor.com>
      Cc: Timo Wischer <twischer@de.adit-jv.com>
      Cc: stable@vger.kernel.org # v3.17+
      Signed-off-by: default avatarJunya Monden <jmonden@jp.adit-jv.com>
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Acked-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Link: https://lore.kernel.org/r/20191016124255.7442-1-erosca@de.adit-jv.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      65ac31fb
    • Yufen Yu's avatar
      scsi: core: try to get module before removing device · a7d04d58
      Yufen Yu authored
      commit 77c30128 upstream.
      
      We have a test case like block/001 in blktests, which will create a scsi
      device by loading scsi_debug module and then try to delete the device by
      sysfs interface. At the same time, it may remove the scsi_debug module.
      
      And getting a invalid paging request BUG_ON as following:
      
      [   34.625854] BUG: unable to handle page fault for address: ffffffffa0016bb8
      [   34.629189] Oops: 0000 [#1] SMP PTI
      [   34.629618] CPU: 1 PID: 450 Comm: bash Tainted: G        W         5.4.0-rc3+ #473
      [   34.632524] RIP: 0010:scsi_proc_hostdir_rm+0x5/0xa0
      [   34.643555] CR2: ffffffffa0016bb8 CR3: 000000012cd88000 CR4: 00000000000006e0
      [   34.644545] Call Trace:
      [   34.644907]  scsi_host_dev_release+0x6b/0x1f0
      [   34.645511]  device_release+0x74/0x110
      [   34.646046]  kobject_put+0x116/0x390
      [   34.646559]  put_device+0x17/0x30
      [   34.647041]  scsi_target_dev_release+0x2b/0x40
      [   34.647652]  device_release+0x74/0x110
      [   34.648186]  kobject_put+0x116/0x390
      [   34.648691]  put_device+0x17/0x30
      [   34.649157]  scsi_device_dev_release_usercontext+0x2e8/0x360
      [   34.649953]  execute_in_process_context+0x29/0x80
      [   34.650603]  scsi_device_dev_release+0x20/0x30
      [   34.651221]  device_release+0x74/0x110
      [   34.651732]  kobject_put+0x116/0x390
      [   34.652230]  sysfs_unbreak_active_protection+0x3f/0x50
      [   34.652935]  sdev_store_delete.cold.4+0x71/0x8f
      [   34.653579]  dev_attr_store+0x1b/0x40
      [   34.654103]  sysfs_kf_write+0x3d/0x60
      [   34.654603]  kernfs_fop_write+0x174/0x250
      [   34.655165]  __vfs_write+0x1f/0x60
      [   34.655639]  vfs_write+0xc7/0x280
      [   34.656117]  ksys_write+0x6d/0x140
      [   34.656591]  __x64_sys_write+0x1e/0x30
      [   34.657114]  do_syscall_64+0xb1/0x400
      [   34.657627]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [   34.658335] RIP: 0033:0x7f156f337130
      
      During deleting scsi target, the scsi_debug module have been removed. Then,
      sdebug_driver_template belonged to the module cannot be accessd, resulting
      in scsi_proc_hostdir_rm() BUG_ON.
      
      To fix the bug, we add scsi_device_get() in sdev_store_delete() to try to
      increase refcount of module, avoiding the module been removed.
      
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20191015130556.18061-1-yuyufen@huawei.com
      
      
      Signed-off-by: default avatarYufen Yu <yuyufen@huawei.com>
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7d04d58
    • Johan Hovold's avatar
      USB: ldusb: fix read info leaks · 44d3e985
      Johan Hovold authored
      
      commit 7a6f22d7 upstream.
      
      Fix broken read implementation, which could be used to trigger slab info
      leaks.
      
      The driver failed to check if the custom ring buffer was still empty
      when waking up after having waited for more data. This would happen on
      every interrupt-in completion, even if no data had been added to the
      ring buffer (e.g. on disconnect events).
      
      Due to missing sanity checks and uninitialised (kmalloced) ring-buffer
      entries, this meant that huge slab info leaks could easily be triggered.
      
      Note that the empty-buffer check after wakeup is enough to fix the info
      leak on disconnect, but let's clear the buffer on allocation and add a
      sanity check to read() to prevent further leaks.
      
      Fixes: 2824bd25 ("[PATCH] USB: add ldusb driver")
      Cc: stable <stable@vger.kernel.org>     # 2.6.13
      Reported-by: default avatar <syzbot+6fe95b826644f7f12b0b@syzkaller.appspotmail.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191018151955.25135-2-johan@kernel.org
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      44d3e985
    • Johan Hovold's avatar
      USB: usblp: fix use-after-free on disconnect · 3e4cf06e
      Johan Hovold authored
      
      commit 7a759197 upstream.
      
      A recent commit addressing a runtime PM use-count regression, introduced
      a use-after-free by not making sure we held a reference to the struct
      usb_interface for the lifetime of the driver data.
      
      Fixes: 9a315358 ("USB: usblp: fix runtime PM after driver unbind")
      Cc: stable <stable@vger.kernel.org>
      Reported-by: default avatar <syzbot+cd24df4d075c319ebfc5@syzkaller.appspotmail.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191015175522.18490-1-johan@kernel.org
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e4cf06e
    • Johan Hovold's avatar
      USB: ldusb: fix memleak on disconnect · a81304eb
      Johan Hovold authored
      
      commit b14a3904 upstream.
      
      If disconnect() races with release() after a process has been
      interrupted, release() could end up returning early and the driver would
      fail to free its driver data.
      
      Fixes: 2824bd25 ("[PATCH] USB: add ldusb driver")
      Cc: stable <stable@vger.kernel.org>     # 2.6.13
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191010125835.27031-2-johan@kernel.org
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a81304eb
    • Johan Hovold's avatar
      USB: serial: ti_usb_3410_5052: fix port-close races · be742b0b
      Johan Hovold authored
      
      commit 6f1d1dc8 upstream.
      
      Fix races between closing a port and opening or closing another port on
      the same device which could lead to a failure to start or stop the
      shared interrupt URB. The latter could potentially cause a
      use-after-free or worse in the completion handler on driver unbind.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be742b0b
    • Gustavo A. R. Silva's avatar
      usb: udc: lpc32xx: fix bad bit shift operation · ebcfd766
      Gustavo A. R. Silva authored
      
      commit b987b66a upstream.
      
      It seems that the right variable to use in this case is *i*, instead of
      *n*, otherwise there is an undefined behavior when right shifiting by more
      than 31 bits when multiplying n by 8; notice that *n* can take values
      equal or greater than 4 (4, 8, 16, ...).
      
      Also, notice that under the current conditions (bl = 3), we are skiping
      the handling of bytes 3, 7, 31... So, fix this by updating this logic
      and limit *bl* up to 4 instead of up to 3.
      
      This fix is based on function udc_stuff_fifo().
      
      Addresses-Coverity-ID: 1454834 ("Bad bit shift operation")
      Fixes: 24a28e42 ("USB: gadget driver for LPC32xx")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Link: https://lore.kernel.org/r/20191014191830.GA10721@embeddedor
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ebcfd766
    • Johan Hovold's avatar
      USB: legousbtower: fix memleak on disconnect · 5610f75e
      Johan Hovold authored
      
      commit b6c03e5f upstream.
      
      If disconnect() races with release() after a process has been
      interrupted, release() could end up returning early and the driver would
      fail to free its driver data.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191010125835.27031-3-johan@kernel.org
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5610f75e
    • Matthew Wilcox (Oracle)'s avatar
      memfd: Fix locking when tagging pins · eb4058d8
      Matthew Wilcox (Oracle) authored
      
      The RCU lock is insufficient to protect the radix tree iteration as
      a deletion from the tree can occur before we take the spinlock to
      tag the entry.  In 4.19, this has manifested as a bug with the following
      trace:
      
      kernel BUG at lib/radix-tree.c:1429!
      invalid opcode: 0000 [#1] SMP KASAN PTI
      CPU: 7 PID: 6935 Comm: syz-executor.2 Not tainted 4.19.36 #25
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
      RIP: 0010:radix_tree_tag_set+0x200/0x2f0 lib/radix-tree.c:1429
      Code: 00 00 5b 5d 41 5c 41 5d 41 5e 41 5f c3 48 89 44 24 10 e8 a3 29 7e fe 48 8b 44 24 10 48 0f ab 03 e9 d2 fe ff ff e8 90 29 7e fe <0f> 0b 48 c7 c7 e0 5a 87 84 e8 f0 e7 08 ff 4c 89 ef e8 4a ff ac fe
      RSP: 0018:ffff88837b13fb60 EFLAGS: 00010016
      RAX: 0000000000040000 RBX: ffff8883c5515d58 RCX: ffffffff82cb2ef0
      RDX: 0000000000000b72 RSI: ffffc90004cf2000 RDI: ffff8883c5515d98
      RBP: ffff88837b13fb98 R08: ffffed106f627f7e R09: ffffed106f627f7e
      R10: 0000000000000001 R11: ffffed106f627f7d R12: 0000000000000004
      R13: ffffea000d7fea80 R14: 1ffff1106f627f6f R15: 0000000000000002
      FS:  00007fa1b8df2700(0000) GS:ffff8883e2fc0000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007fa1b8df1db8 CR3: 000000037d4d2001 CR4: 0000000000160ee0
      Call Trace:
       memfd_tag_pins mm/memfd.c:51 [inline]
       memfd_wait_for_pins+0x2c5/0x12d0 mm/memfd.c:81
       memfd_add_seals mm/memfd.c:215 [inline]
       memfd_fcntl+0x33d/0x4a0 mm/memfd.c:247
       do_fcntl+0x589/0xeb0 fs/fcntl.c:421
       __do_sys_fcntl fs/fcntl.c:463 [inline]
       __se_sys_fcntl fs/fcntl.c:448 [inline]
       __x64_sys_fcntl+0x12d/0x180 fs/fcntl.c:448
       do_syscall_64+0xc8/0x580 arch/x86/entry/common.c:293
      
      The problem does not occur in mainline due to the XArray rewrite which
      changed the locking to exclude modification of the tree during iteration.
      At the time, nobody realised this was a bugfix.  Backport the locking
      changes to stable.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarzhong jiang <zhongjiang@huawei.com>
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eb4058d8
    • Stefano Brivio's avatar
      ipv4: Return -ENETUNREACH if we can't create route but saddr is valid · 85088e38
      Stefano Brivio authored
      
      [ Upstream commit 595e0651 ]
      
      ...instead of -EINVAL. An issue was found with older kernel versions
      while unplugging a NFS client with pending RPCs, and the wrong error
      code here prevented it from recovering once link is back up with a
      configured address.
      
      Incidentally, this is not an issue anymore since commit 4f8943f8
      ("SUNRPC: Replace direct task wakeups from softirq context"), included
      in 5.2-rc7, had the effect of decoupling the forwarding of this error
      by using SO_ERROR in xs_wake_error(), as pointed out by Benjamin
      Coddington.
      
      To the best of my knowledge, this isn't currently causing any further
      issue, but the error code doesn't look appropriate anyway, and we
      might hit this in other paths as well.
      
      In detail, as analysed by Gonzalo Siero, once the route is deleted
      because the interface is down, and can't be resolved and we return
      -EINVAL here, this ends up, courtesy of inet_sk_rebuild_header(),
      as the socket error seen by tcp_write_err(), called by
      tcp_retransmit_timer().
      
      In turn, tcp_write_err() indirectly calls xs_error_report(), which
      wakes up the RPC pending tasks with a status of -EINVAL. This is then
      seen by call_status() in the SUN RPC implementation, which aborts the
      RPC call calling rpc_exit(), instead of handling this as a
      potentially temporary condition, i.e. as a timeout.
      
      Return -EINVAL only if the input parameters passed to
      ip_route_output_key_hash_rcu() are actually invalid (this is the case
      if the specified source address is multicast, limited broadcast or
      all zeroes), but return -ENETUNREACH in all cases where, at the given
      moment, the given source address doesn't allow resolving the route.
      
      While at it, drop the initialisation of err to -ENETUNREACH, which
      was added to __ip_route_output_key() back then by commit
      0315e382 ("net: Fix behaviour of unreachable, blackhole and
      prohibit routes"), but actually had no effect, as it was, and is,
      overwritten by the fib_lookup() return code assignment, and anyway
      ignored in all other branches, including the if (fl4->saddr) one:
      I find this rather confusing, as it would look like -ENETUNREACH is
      the "default" error, while that statement has no effect.
      
      Also note that after commit fc75fc83 ("ipv4: dont create routes
      on down devices"), we would get -ENETUNREACH if the device is down,
      but -EINVAL if the source address is specified and we can't resolve
      the route, and this appears to be rather inconsistent.
      
      Reported-by: default avatarStefan Walter <walteste@inf.ethz.ch>
      Analysed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Analysed-by: default avatarGonzalo Siero <gsierohu@redhat.com>
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      85088e38
    • Eric Dumazet's avatar
      net: avoid potential infinite loop in tc_ctl_action() · ca0cd16b
      Eric Dumazet authored
      
      [ Upstream commit 39f13ea2 ]
      
      tc_ctl_action() has the ability to loop forever if tcf_action_add()
      returns -EAGAIN.
      
      This special case has been done in case a module needed to be loaded,
      but it turns out that tcf_add_notify() could also return -EAGAIN
      if the socket sk_rcvbuf limit is hit.
      
      We need to separate the two cases, and only loop for the module
      loading case.
      
      While we are at it, add a limit of 10 attempts since unbounded
      loops are always scary.
      
      syzbot repro was something like :
      
      socket(PF_NETLINK, SOCK_RAW|SOCK_NONBLOCK, NETLINK_ROUTE) = 3
      write(3, ..., 38) = 38
      setsockopt(3, SOL_SOCKET, SO_RCVBUF, [0], 4) = 0
      sendmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{..., 388}], msg_controllen=0, msg_flags=0x10}, ...)
      
      NMI backtrace for cpu 0
      CPU: 0 PID: 1054 Comm: khungtaskd Not tainted 5.4.0-rc1+ #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x172/0x1f0 lib/dump_stack.c:113
       nmi_cpu_backtrace.cold+0x70/0xb2 lib/nmi_backtrace.c:101
       nmi_trigger_cpumask_backtrace+0x23b/0x28b lib/nmi_backtrace.c:62
       arch_trigger_cpumask_backtrace+0x14/0x20 arch/x86/kernel/apic/hw_nmi.c:38
       trigger_all_cpu_backtrace include/linux/nmi.h:146 [inline]
       check_hung_uninterruptible_tasks kernel/hung_task.c:205 [inline]
       watchdog+0x9d0/0xef0 kernel/hung_task.c:289
       kthread+0x361/0x430 kernel/kthread.c:255
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
      Sending NMI from CPU 0 to CPUs 1:
      NMI backtrace for cpu 1
      CPU: 1 PID: 8859 Comm: syz-executor910 Not tainted 5.4.0-rc1+ #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:arch_local_save_flags arch/x86/include/asm/paravirt.h:751 [inline]
      RIP: 0010:lockdep_hardirqs_off+0x1df/0x2e0 kernel/locking/lockdep.c:3453
      Code: 5c 08 00 00 5b 41 5c 41 5d 5d c3 48 c7 c0 58 1d f3 88 48 ba 00 00 00 00 00 fc ff df 48 c1 e8 03 80 3c 10 00 0f 85 d3 00 00 00 <48> 83 3d 21 9e 99 07 00 0f 84 b9 00 00 00 9c 58 0f 1f 44 00 00 f6
      RSP: 0018:ffff8880a6f3f1b8 EFLAGS: 00000046
      RAX: 1ffffffff11e63ab RBX: ffff88808c9c6080 RCX: 0000000000000000
      RDX: dffffc0000000000 RSI: 0000000000000000 RDI: ffff88808c9c6914
      RBP: ffff8880a6f3f1d0 R08: ffff88808c9c6080 R09: fffffbfff16be5d1
      R10: fffffbfff16be5d0 R11: 0000000000000003 R12: ffffffff8746591f
      R13: ffff88808c9c6080 R14: ffffffff8746591f R15: 0000000000000003
      FS:  00000000011e4880(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: ffffffffff600400 CR3: 00000000a8920000 CR4: 00000000001406e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       trace_hardirqs_off+0x62/0x240 kernel/trace/trace_preemptirq.c:45
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:108 [inline]
       _raw_spin_lock_irqsave+0x6f/0xcd kernel/locking/spinlock.c:159
       __wake_up_common_lock+0xc8/0x150 kernel/sched/wait.c:122
       __wake_up+0xe/0x10 kernel/sched/wait.c:142
       netlink_unlock_table net/netlink/af_netlink.c:466 [inline]
       netlink_unlock_table net/netlink/af_netlink.c:463 [inline]
       netlink_broadcast_filtered+0x705/0xb80 net/netlink/af_netlink.c:1514
       netlink_broadcast+0x3a/0x50 net/netlink/af_netlink.c:1534
       rtnetlink_send+0xdd/0x110 net/core/rtnetlink.c:714
       tcf_add_notify net/sched/act_api.c:1343 [inline]
       tcf_action_add+0x243/0x370 net/sched/act_api.c:1362
       tc_ctl_action+0x3b5/0x4bc net/sched/act_api.c:1410
       rtnetlink_rcv_msg+0x463/0xb00 net/core/rtnetlink.c:5386
       netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
       rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5404
       netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
       netlink_unicast+0x531/0x710 net/netlink/af_netlink.c:1328
       netlink_sendmsg+0x8a5/0xd60 net/netlink/af_netlink.c:1917
       sock_sendmsg_nosec net/socket.c:637 [inline]
       sock_sendmsg+0xd7/0x130 net/socket.c:657
       ___sys_sendmsg+0x803/0x920 net/socket.c:2311
       __sys_sendmsg+0x105/0x1d0 net/socket.c:2356
       __do_sys_sendmsg net/socket.c:2365 [inline]
       __se_sys_sendmsg net/socket.c:2363 [inline]
       __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2363
       do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x440939
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatar <syzbot+cf0adbb9c28c8866c788@syzkaller.appspotmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ca0cd16b
    • Xin Long's avatar
      sctp: change sctp_prot .no_autobind with true · 9befdc66
      Xin Long authored
      
      [ Upstream commit 63dfb793 ]
      
      syzbot reported a memory leak:
      
        BUG: memory leak, unreferenced object 0xffff888120b3d380 (size 64):
        backtrace:
      
          [...] slab_alloc mm/slab.c:3319 [inline]
          [...] kmem_cache_alloc+0x13f/0x2c0 mm/slab.c:3483
          [...] sctp_bucket_create net/sctp/socket.c:8523 [inline]
          [...] sctp_get_port_local+0x189/0x5a0 net/sctp/socket.c:8270
          [...] sctp_do_bind+0xcc/0x200 net/sctp/socket.c:402
          [...] sctp_bindx_add+0x4b/0xd0 net/sctp/socket.c:497
          [...] sctp_setsockopt_bindx+0x156/0x1b0 net/sctp/socket.c:1022
          [...] sctp_setsockopt net/sctp/socket.c:4641 [inline]
          [...] sctp_setsockopt+0xaea/0x2dc0 net/sctp/socket.c:4611
          [...] sock_common_setsockopt+0x38/0x50 net/core/sock.c:3147
          [...] __sys_setsockopt+0x10f/0x220 net/socket.c:2084
          [...] __do_sys_setsockopt net/socket.c:2100 [inline]
      
      It was caused by when sending msgs without binding a port, in the path:
      inet_sendmsg() -> inet_send_prepare() -> inet_autobind() ->
      .get_port/sctp_get_port(), sp->bind_hash will be set while bp->port is
      not. Later when binding another port by sctp_setsockopt_bindx(), a new
      bucket will be created as bp->port is not set.
      
      sctp's autobind is supposed to call sctp_autobind() where it does all
      things including setting bp->port. Since sctp_autobind() is called in
      sctp_sendmsg() if the sk is not yet bound, it should have skipped the
      auto bind.
      
      THis patch is to avoid calling inet_autobind() in inet_send_prepare()
      by changing sctp_prot .no_autobind with true, also remove the unused
      .get_port.
      
      Reported-by: default avatar <syzbot+d44f7bbebdea49dbc84a@syzkaller.appspotmail.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9befdc66
    • Florian Fainelli's avatar
      net: bcmgenet: Set phydev->dev_flags only for internal PHYs · 0ed0978c
      Florian Fainelli authored
      
      [ Upstream commit 92696286 ]
      
      phydev->dev_flags is entirely dependent on the PHY device driver which
      is going to be used, setting the internal GENET PHY revision in those
      bits only makes sense when drivers/net/phy/bcm7xxx.c is the PHY driver
      being used.
      
      Fixes: 487320c5 ("net: bcmgenet: communicate integrated PHY revision to PHY driver")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Acked-by: default avatarDoug Berger <opendmb@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0ed0978c
    • Florian Fainelli's avatar
      net: bcmgenet: Fix RGMII_MODE_EN value for GENET v1/2/3 · 571e5f93
      Florian Fainelli authored
      
      [ Upstream commit efb86fed ]
      
      The RGMII_MODE_EN bit value was 0 for GENET versions 1 through 3, and
      became 6 for GENET v4 and above, account for that difference.
      
      Fixes: aa09677c ("net: bcmgenet: add MDIO routines")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Acked-by: default avatarDoug Berger <opendmb@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      571e5f93
    • Alessio Balsini's avatar
      loop: Add LOOP_SET_DIRECT_IO to compat ioctl · 896bb987
      Alessio Balsini authored
      
      [ Upstream commit fdbe4eee ]
      
      Enabling Direct I/O with loop devices helps reducing memory usage by
      avoiding double caching.  32 bit applications running on 64 bits systems
      are currently not able to request direct I/O because is missing from the
      lo_compat_ioctl.
      
      This patch fixes the compatibility issue mentioned above by exporting
      LOOP_SET_DIRECT_IO as additional lo_compat_ioctl() entry.
      The input argument for this ioctl is a single long converted to a 1-bit
      boolean, so compatibility is preserved.
      
      Cc: Jens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarAlessio Balsini <balsini@android.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      896bb987
    • Jacob Keller's avatar
      namespace: fix namespace.pl script to support relative paths · 27add8a9
      Jacob Keller authored
      
      [ Upstream commit 82fdd12b ]
      
      The namespace.pl script does not work properly if objtree is not set to
      an absolute path. The do_nm function is run from within the find
      function, which changes directories.
      
      Because of this, appending objtree, $File::Find::dir, and $source, will
      return a path which is not valid from the current directory.
      
      This used to work when objtree was set to an absolute path when using
      "make namespacecheck". It appears to have not worked when calling
      ./scripts/namespace.pl directly.
      
      This behavior was changed in 7e1c0477 ("kbuild: Use relative path
      for $(objtree)", 2014-05-14)
      
      Rather than fixing the Makefile to set objtree to an absolute path, just
      fix namespace.pl to work when srctree and objtree are relative. Also fix
      the script to use an absolute path for these by default.
      
      Use the File::Spec module for this purpose. It's been part of perl
      5 since 5.005.
      
      The curdir() function is used to get the current directory when the
      objtree and srctree aren't set in the environment.
      
      rel2abs() is used to convert possibly relative objtree and srctree
      environment variables to absolute paths.
      
      Finally, the catfile() function is used instead of string appending
      paths together, since this is more robust when joining paths together.
      
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Tested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      27add8a9
    • Yizhuo's avatar
      net: hisilicon: Fix usage of uninitialized variable in function mdio_sc_cfg_reg_write() · 74b2bee5
      Yizhuo authored
      
      [ Upstream commit 53de429f ]
      
      In function mdio_sc_cfg_reg_write(), variable "reg_value" could be
      uninitialized if regmap_read() fails. However, "reg_value" is used
      to decide the control flow later in the if statement, which is
      potentially unsafe.
      
      Signed-off-by: default avatarYizhuo <yzhai003@ucr.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      74b2bee5
    • Christophe JAILLET's avatar
      mips: Loongson: Fix the link time qualifier of 'serial_exit()' · ebc93dc0
      Christophe JAILLET authored
      
      [ Upstream commit 25b69a88 ]
      
      'exit' functions should be marked as __exit, not __init.
      
      Fixes: 85cc0288 ("mips: make loongsoon serial driver explicitly modular")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Cc: chenhc@lemote.com
      Cc: ralf@linux-mips.org
      Cc: jhogan@kernel.org
      Cc: linux-mips@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: kernel-janitors@vger.kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ebc93dc0
    • Miaoqing Pan's avatar
      nl80211: fix null pointer dereference · 4f7a59b5
      Miaoqing Pan authored
      
      [ Upstream commit b501426c ]
      
      If the interface is not in MESH mode, the command 'iw wlanx mpath del'
      will cause kernel panic.
      
      The root cause is null pointer access in mpp_flush_by_proxy(), as the
      pointer 'sdata->u.mesh.mpp_paths' is NULL for non MESH interface.
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000068
      [...]
      PC is at _raw_spin_lock_bh+0x20/0x5c
      LR is at mesh_path_del+0x1c/0x17c [mac80211]
      [...]
      Process iw (pid: 4537, stack limit = 0xd83e0238)
      [...]
      [<c021211c>] (_raw_spin_lock_bh) from [<bf8c7648>] (mesh_path_del+0x1c/0x17c [mac80211])
      [<bf8c7648>] (mesh_path_del [mac80211]) from [<bf6cdb7c>] (extack_doit+0x20/0x68 [compat])
      [<bf6cdb7c>] (extack_doit [compat]) from [<c05c309c>] (genl_rcv_msg+0x274/0x30c)
      [<c05c309c>] (genl_rcv_msg) from [<c05c25d8>] (netlink_rcv_skb+0x58/0xac)
      [<c05c25d8>] (netlink_rcv_skb) from [<c05c2e14>] (genl_rcv+0x20/0x34)
      [<c05c2e14>] (genl_rcv) from [<c05c1f90>] (netlink_unicast+0x11c/0x204)
      [<c05c1f90>] (netlink_unicast) from [<c05c2420>] (netlink_sendmsg+0x30c/0x370)
      [<c05c2420>] (netlink_sendmsg) from [<c05886d0>] (sock_sendmsg+0x70/0x84)
      [<c05886d0>] (sock_sendmsg) from [<c0589f4c>] (___sys_sendmsg.part.3+0x188/0x228)
      [<c0589f4c>] (___sys_sendmsg.part.3) from [<c058add4>] (__sys_sendmsg+0x4c/0x70)
      [<c058add4>] (__sys_sendmsg) from [<c0208c80>] (ret_fast_syscall+0x0/0x44)
      Code: e2822c02 e2822001 e5832004 f590f000 (e1902f9f)
      ---[ end trace bbd717600f8f884d ]---
      
      Signed-off-by: default avatarMiaoqing Pan <miaoqing@codeaurora.org>
      Link: https://lore.kernel.org/r/1569485810-761-1-git-send-email-miaoqing@codeaurora.org
      
      
      [trim useless data from commit message]
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4f7a59b5
    • Peter Ujfalusi's avatar
      ARM: dts: am4372: Set memory bandwidth limit for DISPC · eb5aa18f
      Peter Ujfalusi authored
      
      [ Upstream commit f90ec6cd ]
      
      Set memory bandwidth limit to filter out resolutions above 720p@60Hz to
      avoid underflow errors due to the bandwidth needs of higher resolutions.
      
      am43xx can not provide enough bandwidth to DISPC to correctly handle
      'high' resolutions.
      
      Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
      Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eb5aa18f
    • Tony Lindgren's avatar
      ARM: OMAP2+: Fix missing reset done flag for am3 and am43 · d08c1d74
      Tony Lindgren authored
      
      [ Upstream commit 8ad8041b ]
      
      For ti,sysc-omap4 compatible devices with no sysstatus register, we do have
      reset done status available in the SOFTRESET bit that clears when the reset
      is done. This is documented for example in am437x TRM for DMTIMER_TIOCP_CFG
      register. The am335x TRM just says that SOFTRESET bit value 1 means reset is
      ongoing, but it behaves the same way clearing after reset is done.
      
      With the ti-sysc driver handling this automatically based on no sysstatus
      register defined, we see warnings if SYSC_HAS_RESET_STATUS is missing in the
      legacy platform data:
      
      ti-sysc 48042000.target-module: sysc_flags 00000222 != 00000022
      ti-sysc 48044000.target-module: sysc_flags 00000222 != 00000022
      ti-sysc 48046000.target-module: sysc_flags 00000222 != 00000022
      ...
      
      Let's fix these warnings by adding SYSC_HAS_RESET_STATUS. Let's also
      remove the useless parentheses while at it.
      
      If it turns out we do have ti,sysc-omap4 compatible devices without a
      working SOFTRESET bit we can set up additional quirk handling for it.
      
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d08c1d74
    • Quinn Tran's avatar
      scsi: qla2xxx: Fix unbound sleep in fcport delete path. · 36f88520
      Quinn Tran authored
      [ Upstream commit c3b6a1d3 ]
      
      There are instances, though rare, where a LOGO request cannot be sent out
      and the thread in free session done can wait indefinitely. Fix this by
      putting an upper bound to sleep.
      
      Link: https://lore.kernel.org/r/20190912180918.6436-3-hmadhani@marvell.com
      
      
      Signed-off-by: default avatarQuinn Tran <qutran@marvell.com>
      Signed-off-by: default avatarHimanshu Madhani <hmadhani@marvell.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      36f88520
Loading