1. 17 Jan, 2020 16 commits
    • Tyler Hicks's avatar
      drm/i915: Fix use-after-free when destroying GEM context · afb89cd5
      Tyler Hicks authored
      This patch is a simplified fix to address a use-after-free in 4.14.x and
      4.19.x stable kernels. The flaw is already fixed upstream, starting in
      5.2, by commit 7dc40713 ("drm/i915: Introduce a mutex for
      file_priv->context_idr") as part of a more complex patch series that
      isn't appropriate for backporting to stable kernels.
      
      Expand mutex coverage, while destroying the GEM context, to include the
      GEM context lookup step. This fixes a use-after-free detected by KASAN:
      
       ==================================================================
       BUG: KASAN: use-after-free in i915_ppgtt_close+0x2ca/0x2f0
       Write of size 1 at addr ffff8881368a8368 by task i915-poc/3124
      
       CPU: 0 PID: 3124 Comm: i915-poc Not tainted 4.14.164 #1
       Hardware name: HP HP Elite x2 1012 G1 /80FC, BIOS N85 Ver. 01.20 04/05/2017
       Call Trace:
        dump_stack+0xcd/0x12e
        ? _atomic_dec_and_lock+0x1b2/0x1b2
        ? i915_ppgtt_close+0x2ca/0x2f0
        ? printk+0x8f/0xab
        ? show_regs_print_info+0x53/0x53
        ? i915_ppgtt_close+0x2ca/0x2f0
        print_address_description+0x65/0x270
        ? i915_ppgtt_close+0x2ca/0x2f0
        kasan_report+0x251/0x340
        i915_ppgtt_close+0x2ca/0x2f0
        ? __radix_tree_insert+0x3f0/0x3f0
        ? i915_ppgtt_init_hw+0x7c0/0x7c0
        context_close+0x42e/0x680
        ? i915_gem_context_release+0x230/0x230
        ? kasan_kmalloc+0xa0/0xd0
        ? radix_tree_delete_item+0x1d4/0x250
        ? radix_tree_lookup+0x10/0x10
        ? inet_recvmsg+0x4b0/0x4b0
        ? kasan_slab_free+0x88/0xc0
        i915_gem_context_destroy_ioctl+0x236/0x300
        ? i915_gem_context_create_ioctl+0x360/0x360
        ? drm_dev_printk+0x1d0/0x1d0
        ? memcpy+0x34/0x50
        ? i915_gem_context_create_ioctl+0x360/0x360
        drm_ioctl_kernel+0x1b0/0x2b0
        ? drm_ioctl_permit+0x2a0/0x2a0
        ? avc_ss_reset+0xd0/0xd0
        drm_ioctl+0x6fe/0xa20
        ? i915_gem_context_create_ioctl+0x360/0x360
        ? drm_getstats+0x20/0x20
        ? put_unused_fd+0x260/0x260
        do_vfs_ioctl+0x189/0x12d0
        ? ioctl_preallocate+0x280/0x280
        ? selinux_file_ioctl+0x3a7/0x680
        ? selinux_bprm_set_creds+0xe30/0xe30
        ? security_file_ioctl+0x69/0xa0
        ? selinux_bprm_set_creds+0xe30/0xe30
        SyS_ioctl+0x6f/0x80
        ? __sys_sendmmsg+0x4a0/0x4a0
        ? do_vfs_ioctl+0x12d0/0x12d0
        do_syscall_64+0x214/0x5f0
        ? __switch_to_asm+0x31/0x60
        ? __switch_to_asm+0x25/0x60
        ? __switch_to_asm+0x31/0x60
        ? syscall_return_slowpath+0x2c0/0x2c0
        ? copy_overflow+0x20/0x20
        ? __switch_to_asm+0x25/0x60
        ? syscall_return_via_sysret+0x2a/0x7a
        ? prepare_exit_to_usermode+0x200/0x200
        ? __switch_to_asm+0x31/0x60
        ? __switch_to_asm+0x31/0x60
        ? __switch_to_asm+0x25/0x60
        ? __switch_to_asm+0x25/0x60
        ? __switch_to_asm+0x31/0x60
        ? __switch_to_asm+0x25/0x60
        ? __switch_to_asm+0x31/0x60
        ? __switch_to_asm+0x31/0x60
        ? __switch_to_asm+0x25/0x60
        entry_SYSCALL_64_after_hwframe+0x3d/0xa2
       RIP: 0033:0x7f7fda5115d7
       RSP: 002b:00007f7eec317ec8 EFLAGS: 00000286 ORIG_RAX: 0000000000000010
       RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f7fda5115d7
       RDX: 000055b306db9188 RSI: 000000004008646e RDI: 0000000000000003
       RBP: 00007f7eec317ef0 R08: 00007f7eec318700 R09: 0000000000000000
       R10: 0000000000000000 R11: 0000000000000286 R12: 00007f7eec317fc0
       R13: 0000000000000000 R14: 0000000000000000 R15: 00007ffd8007ade0
      
       Allocated by task 2898:
        save_stack+0x32/0xb0
        kasan_kmalloc+0xa0/0xd0
        kmem_cache_alloc_trace+0x5e/0x180
        i915_ppgtt_create+0xab/0x2510
        i915_gem_create_context+0x981/0xf90
        i915_gem_context_create_ioctl+0x1d7/0x360
        drm_ioctl_kernel+0x1b0/0x2b0
        drm_ioctl+0x6fe/0xa20
        do_vfs_ioctl+0x189/0x12d0
        SyS_ioctl+0x6f/0x80
        do_syscall_64+0x214/0x5f0
        entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      
       Freed by task 104:
        save_stack+0x32/0xb0
        kasan_slab_free+0x72/0xc0
        kfree+0x88/0x190
        i915_ppgtt_release+0x24e/0x460
        i915_gem_context_free+0x90/0x480
        contexts_free_worker+0x54/0x80
        process_one_work+0x876/0x14e0
        worker_thread+0x1b8/0xfd0
        kthread+0x2f8/0x3c0
        ret_from_fork+0x35/0x40
      
       The buggy address belongs to the object at ffff8881368a8000
        which belongs to the cache kmalloc-8192 of size 8192
       The buggy address is located 872 bytes inside of
        8192-byte region [ffff8881368a8000, ffff8881368aa000)
       The buggy address belongs to the page:
       page:ffffea0004da2a00 count:1 mapcount:0 mapping:          (null) index:0x0 compound_mapcount: 0
       flags: 0x200000000008100(slab|head)
       raw: 0200000000008100 0000000000000000 0000000000000000 0000000100030003
       raw: dead000000000100 dead000000000200 ffff88822a002280 0000000000000000
       page dumped because: kasan: bad access detected
      
       Memory state around the buggy address:
        ffff8881368a8200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        ffff8881368a8280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       >ffff8881368a8300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                 ^
        ffff8881368a8380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        ffff8881368a8400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ==================================================================
      
      Fixes: 1acfc104 ("drm/i915: Enable rcu-only context lookups")
      Reported-by: default avatar罗权 <luoquan@qianxin.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Jon Bloomfield <jon.bloomfield@intel.com>
      Cc: stable@vger.kernel.org # 4.14.x
      Cc: stable@vger.kernel.org # 4.19.x
      Signed-off-by: default avatarTyler Hicks <tyhicks@canonical.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      afb89cd5
    • YueHaibing's avatar
      dccp: Fix memleak in __feat_register_sp · e58c590c
      YueHaibing authored
      commit 1d3ff095 upstream.
      
      If dccp_feat_push_change fails, we forget free the mem
      which is alloced by kmemdup in dccp_feat_clone_sp_val.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Fixes: e8ef967a ("dccp: Registration routines for changing feature values")
      Reviewed-by: default avatarMukesh Ojha <mojha@codeaurora.org>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e58c590c
    • Navid Emamdoost's avatar
      RDMA: Fix goto target to release the allocated memory · d203ff6a
      Navid Emamdoost authored
      commit 4a9d46a9 upstream.
      
      In bnxt_re_create_srq(), when ib_copy_to_udata() fails allocated memory
      should be released by goto fail.
      
      Fixes: 37cb11ac ("RDMA/bnxt_re: Add SRQ support for Broadcom adapters")
      Link: https://lore.kernel.org/r/20190910222120.16517-1-navid.emamdoost@gmail.comSigned-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
      Reviewed-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d203ff6a
    • Navid Emamdoost's avatar
      iwlwifi: pcie: fix memory leaks in iwl_pcie_ctxt_info_gen3_init · 6e41dd97
      Navid Emamdoost authored
      commit 0f4f1994 upstream.
      
      In iwl_pcie_ctxt_info_gen3_init there are cases that the allocated dma
      memory is leaked in case of error.
      
      DMA memories prph_scratch, prph_info, and ctxt_info_gen3 are allocated
      and initialized to be later assigned to trans_pcie. But in any error case
      before such assignment the allocated memories should be released.
      
      First of such error cases happens when iwl_pcie_init_fw_sec fails.
      Current implementation correctly releases prph_scratch. But in two
      sunsequent error cases where dma_alloc_coherent may fail, such
      releases are missing.
      
      This commit adds release for prph_scratch when allocation for
      prph_info fails, and adds releases for prph_scratch and prph_info when
      allocation for ctxt_info_gen3 fails.
      
      Fixes: 2ee82402 ("iwlwifi: pcie: support context information for 22560 devices")
      Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6e41dd97
    • Navid Emamdoost's avatar
      iwlwifi: dbg_ini: fix memory leak in alloc_sgtable · 09044a4a
      Navid Emamdoost authored
      commit b4b814fe upstream.
      
      In alloc_sgtable if alloc_page fails, the alocated table should be
      released.
      Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09044a4a
    • Vandana BN's avatar
      media: usb:zr364xx:Fix KASAN:null-ptr-deref Read in zr364xx_vidioc_querycap · 0648766c
      Vandana BN authored
      commit 5d2e73a5 upstream.
      
      SyzKaller hit the null pointer deref while reading from uninitialized
      udev->product in zr364xx_vidioc_querycap().
      
      ==================================================================
      BUG: KASAN: null-ptr-deref in read_word_at_a_time+0xe/0x20
      include/linux/compiler.h:274
      Read of size 1 at addr 0000000000000000 by task v4l_id/5287
      
      CPU: 1 PID: 5287 Comm: v4l_id Not tainted 5.1.0-rc3-319004-g43151d6 #6
      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+0xe8/0x16e lib/dump_stack.c:113
        kasan_report.cold+0x5/0x3c mm/kasan/report.c:321
        read_word_at_a_time+0xe/0x20 include/linux/compiler.h:274
        strscpy+0x8a/0x280 lib/string.c:207
        zr364xx_vidioc_querycap+0xb5/0x210 drivers/media/usb/zr364xx/zr364xx.c:706
        v4l_querycap+0x12b/0x340 drivers/media/v4l2-core/v4l2-ioctl.c:1062
        __video_do_ioctl+0x5bb/0xb40 drivers/media/v4l2-core/v4l2-ioctl.c:2874
        video_usercopy+0x44e/0xf00 drivers/media/v4l2-core/v4l2-ioctl.c:3056
        v4l2_ioctl+0x14e/0x1a0 drivers/media/v4l2-core/v4l2-dev.c:364
        vfs_ioctl fs/ioctl.c:46 [inline]
        file_ioctl fs/ioctl.c:509 [inline]
        do_vfs_ioctl+0xced/0x12f0 fs/ioctl.c:696
        ksys_ioctl+0xa0/0xc0 fs/ioctl.c:713
        __do_sys_ioctl fs/ioctl.c:720 [inline]
        __se_sys_ioctl fs/ioctl.c:718 [inline]
        __x64_sys_ioctl+0x74/0xb0 fs/ioctl.c:718
        do_syscall_64+0xcf/0x4f0 arch/x86/entry/common.c:290
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x7f3b56d8b347
      Code: 90 90 90 48 8b 05 f1 fa 2a 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff
      ff c3 90 90 90 90 90 90 90 90 90 90 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff
      ff 73 01 c3 48 8b 0d c1 fa 2a 00 31 d2 48 29 c2 64
      RSP: 002b:00007ffe005d5d68 EFLAGS: 00000202 ORIG_RAX: 0000000000000010
      RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f3b56d8b347
      RDX: 00007ffe005d5d70 RSI: 0000000080685600 RDI: 0000000000000003
      RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000400884
      R13: 00007ffe005d5ec0 R14: 0000000000000000 R15: 0000000000000000
      ==================================================================
      
      For this device udev->product is not initialized and accessing it causes a NULL pointer deref.
      
      The fix is to check for NULL before strscpy() and copy empty string, if
      product is NULL
      
      Reported-by: syzbot+66010012fd4c531a1a96@syzkaller.appspotmail.com
      Signed-off-by: default avatarVandana BN <bnvandana@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      [bwh: Backported to 4.19: This function uses strlcpy() instead of strscpy()]
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0648766c
    • Sheng Yong's avatar
      f2fs: check if file namelen exceeds max value · 4124927e
      Sheng Yong authored
      commit 720db068 upstream.
      
      Dentry bitmap is not enough to detect incorrect dentries. So this patch
      also checks the namelen value of a dentry.
      Signed-off-by: default avatarGong Chen <gongchen4@huawei.com>
      Signed-off-by: default avatarSheng Yong <shengyong1@huawei.com>
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4124927e
    • Jaegeuk Kim's avatar
      f2fs: check memory boundary by insane namelen · 1137c1d4
      Jaegeuk Kim authored
      commit 4e240d1b upstream.
      
      If namelen is corrupted to have very long value, fill_dentries can copy
      wrong memory area.
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1137c1d4
    • Ben Hutchings's avatar
      f2fs: Move err variable to function scope in f2fs_fill_dentries() · 2d57c0a6
      Ben Hutchings authored
      This is preparation for the following backported fixes.  It was done
      upstream as part of commit e1293bdf "f2fs: plug readahead IO in
      readdir()", the rest of which does not seem suitable for stable.
      
      Cc: Jaegeuk Kim <jaegeuk@kernel.org>
      Cc: Chao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2d57c0a6
    • Jouni Malinen's avatar
      mac80211: Do not send Layer 2 Update frame before authorization · 8f483142
      Jouni Malinen authored
      commit 3e493173 upstream.
      
      The Layer 2 Update frame is used to update bridges when a station roams
      to another AP even if that STA does not transmit any frames after the
      reassociation. This behavior was described in IEEE Std 802.11F-2003 as
      something that would happen based on MLME-ASSOCIATE.indication, i.e.,
      before completing 4-way handshake. However, this IEEE trial-use
      recommended practice document was published before RSN (IEEE Std
      802.11i-2004) and as such, did not consider RSN use cases. Furthermore,
      IEEE Std 802.11F-2003 was withdrawn in 2006 and as such, has not been
      maintained amd should not be used anymore.
      
      Sending out the Layer 2 Update frame immediately after association is
      fine for open networks (and also when using SAE, FT protocol, or FILS
      authentication when the station is actually authenticated by the time
      association completes). However, it is not appropriate for cases where
      RSN is used with PSK or EAP authentication since the station is actually
      fully authenticated only once the 4-way handshake completes after
      authentication and attackers might be able to use the unauthenticated
      triggering of Layer 2 Update frame transmission to disrupt bridge
      behavior.
      
      Fix this by postponing transmission of the Layer 2 Update frame from
      station entry addition to the point when the station entry is marked
      authorized. Similarly, send out the VLAN binding update only if the STA
      entry has already been authorized.
      Signed-off-by: default avatarJouni Malinen <jouni@codeaurora.org>
      Reviewed-by: default avatarJohannes Berg <johannes@sipsolutions.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8f483142
    • Dedy Lansky's avatar
      cfg80211/mac80211: make ieee80211_send_layer2_update a public function · 85fa006f
      Dedy Lansky authored
      commit 30ca1aa5 upstream.
      
      Make ieee80211_send_layer2_update() a common function so other drivers
      can re-use it.
      Signed-off-by: default avatarDedy Lansky <dlansky@codeaurora.org>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      [bwh: Backported to 4.19 as dependency of commit 3e493173
       "mac80211: Do not send Layer 2 Update frame before authorization"]
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      85fa006f
    • Arnd Bergmann's avatar
      fs/select: avoid clang stack usage warning · e5caf1d5
      Arnd Bergmann authored
      commit ad312f95 upstream.
      
      The select() implementation is carefully tuned to put a sensible amount
      of data on the stack for holding a copy of the user space fd_set, but
      not too large to risk overflowing the kernel stack.
      
      When building a 32-bit kernel with clang, we need a little more space
      than with gcc, which often triggers a warning:
      
        fs/select.c:619:5: error: stack frame size of 1048 bytes in function 'core_sys_select' [-Werror,-Wframe-larger-than=]
        int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,
      
      I experimentally found that for 32-bit ARM, reducing the maximum stack
      usage by 64 bytes keeps us reliably under the warning limit again.
      
      Link: http://lkml.kernel.org/r/20190307090146.1874906-1-arnd@arndb.deSigned-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.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 avatarMiles Chen <miles.chen@mediatek.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e5caf1d5
    • Arnd Bergmann's avatar
      ethtool: reduce stack usage with clang · 81f7503f
      Arnd Bergmann authored
      commit 3499e87e upstream.
      
      clang inlines the dev_ethtool() more aggressively than gcc does, leading
      to a larger amount of used stack space:
      
      net/core/ethtool.c:2536:24: error: stack frame size of 1216 bytes in function 'dev_ethtool' [-Werror,-Wframe-larger-than=]
      
      Marking the sub-functions that require the most stack space as
      noinline_for_stack gives us reasonable behavior on all compilers.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarMichal Kubecek <mkubecek@suse.cz>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarMiles Chen <miles.chen@mediatek.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      81f7503f
    • Jiri Kosina's avatar
      HID: hidraw, uhid: Always report EPOLLOUT · 30db8e40
      Jiri Kosina authored
      [ Upstream commit 9e635c28 ]
      
      hidraw and uhid device nodes are always available for writing so we should
      always report EPOLLOUT and EPOLLWRNORM bits, not only in the cases when
      there is nothing to read.
      Reported-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Fixes: be54e746 ("HID: uhid: Fix returning EPOLLOUT from uhid_char_poll")
      Fixes: 9f3b61dc ("HID: hidraw: Fix returning EPOLLOUT from hidraw_poll")
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      30db8e40
    • Marcel Holtmann's avatar
      HID: hidraw: Fix returning EPOLLOUT from hidraw_poll · b62df58c
      Marcel Holtmann authored
      [ Upstream commit 9f3b61dc ]
      
      When polling a connected /dev/hidrawX device, it is useful to get the
      EPOLLOUT when writing is possible. Since writing is possible as soon as
      the device is connected, always return it.
      
      Right now EPOLLOUT is only returned when there are also input reports
      are available. This works if devices start sending reports when
      connected, but some HID devices might need an output report first before
      sending any input reports. This change will allow using EPOLLOUT here as
      well.
      
      Fixes: 378b8037 ("hidraw: Return EPOLLOUT from hidraw_poll")
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b62df58c
    • Fabian Henneke's avatar
      hidraw: Return EPOLLOUT from hidraw_poll · d2178fc8
      Fabian Henneke authored
      [ Upstream commit 378b8037 ]
      
      Always return EPOLLOUT from hidraw_poll when a device is connected.
      This is safe since writes are always possible (but will always block).
      
      hidraw does not support non-blocking writes and instead always calls
      blocking backend functions on write requests. Hence, so far, a call to
      poll never returned EPOLLOUT, which confuses tools like socat.
      Signed-off-by: default avatarFabian Henneke <fabian.henneke@gmail.com>
      In-reply-to: <CA+hv5qkyis03CgYTWeWX9cr0my-d2Oe+aZo+mjmWRXgjrGqyrw@mail.gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d2178fc8
  2. 14 Jan, 2020 24 commits