]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
usb: gadget: f_fs: change ep->ep safe in ffs_epfile_io()
authorLinyu Yuan <quic_linyyuan@quicinc.com>
Fri, 10 Jun 2022 12:17:58 +0000 (20:17 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 26 Aug 2022 08:53:33 +0000 (10:53 +0200)
commit4fecafc24c73c24d651b644031e9d3c776211285
tree8207fb510d7ab4a5d0f573988d0766737db5bb3e
parent8e21ea1e466a093131a53ddf01a7c43f16b9dbb4
usb: gadget: f_fs: change ep->ep safe in ffs_epfile_io()

BugLink: https://bugs.launchpad.net/bugs/1983149
commit 0698f0209d8032e8869525aeb68f65ee7fde12ad upstream.

In ffs_epfile_io(), when read/write data in blocking mode, it will wait
the completion in interruptible mode, if task receive a signal, it will
terminate the wait, at same time, if function unbind occurs,
ffs_func_unbind() will kfree all eps, ffs_epfile_io() still try to
dequeue request by dereferencing ep which may become invalid.

Fix it by add ep spinlock and will not dereference ep if it is not valid.

Cc: <stable@vger.kernel.org> # 5.15
Reported-by: Michael Wu <michael@allwinnertech.com>
Tested-by: Michael Wu <michael@allwinnertech.com>
Reviewed-by: John Keeping <john@metanate.com>
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
Link: https://lore.kernel.org/r/1654863478-26228-3-git-send-email-quic_linyyuan@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/usb/gadget/function/f_fs.c