No description
  • C 98.2%
  • Assembly 1%
  • Makefile 0.3%
  • Shell 0.2%
  • Python 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Lianqin Hu 4efdfdc32d usb: gadget: u_serial: Fix the issue that gs_start_io crashed due to accessing null pointer
commit 4cfbca86f6a8b801f3254e0e3c8f2b1d2d64be2b upstream.

Considering that in some extreme cases,
when u_serial driver is accessed by multiple threads,
Thread A is executing the open operation and calling the gs_open,
Thread B is executing the disconnect operation and calling the
gserial_disconnect function,The port->port_usb pointer will be set to NULL.

E.g.
    Thread A                                 Thread B
    gs_open()                                gadget_unbind_driver()
    gs_start_io()                            composite_disconnect()
    gs_start_rx()                            gserial_disconnect()
    ...                                      ...
    spin_unlock(&port->port_lock)
    status = usb_ep_queue()                  spin_lock(&port->port_lock)
    spin_lock(&port->port_lock)              port->port_usb = NULL
    gs_free_requests(port->port_usb->in)     spin_unlock(&port->port_lock)
    Crash

This causes thread A to access a null pointer (port->port_usb is null)
when calling the gs_free_requests function, causing a crash.

If port_usb is NULL, the release request will be skipped as it
will be done by gserial_disconnect.

So add a null pointer check to gs_start_io before attempting
to access the value of the pointer port->port_usb.

Call trace:
 gs_start_io+0x164/0x25c
 gs_open+0x108/0x13c
 tty_open+0x314/0x638
 chrdev_open+0x1b8/0x258
 do_dentry_open+0x2c4/0x700
 vfs_open+0x2c/0x3c
 path_openat+0xa64/0xc60
 do_filp_open+0xb8/0x164
 do_sys_openat2+0x84/0xf0
 __arm64_sys_openat+0x70/0x9c
 invoke_syscall+0x58/0x114
 el0_svc_common+0x80/0xe0
 do_el0_svc+0x1c/0x28
 el0_svc+0x38/0x68

Fixes: c1dca562be ("usb gadget: split out serial core")
Cc: stable@vger.kernel.org
Suggested-by: Prashanth K <quic_prashk@quicinc.com>
Signed-off-by: Lianqin Hu <hulianqin@vivo.com>
Acked-by: Prashanth K <quic_prashk@quicinc.com>
Link: https://lore.kernel.org/r/TYUPR06MB62178DC3473F9E1A537DCD02D2362@TYUPR06MB6217.apcprd06.prod.outlook.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-12-19 18:05:02 +01:00
arch perf/x86/intel/pt: Fix buffer full but size is 0 case 2024-12-14 19:44:55 +01:00
block block: fix ordering between checking BLK_MQ_S_STOPPED request adding 2024-12-14 19:44:38 +01:00
certs
crypto crypto: pcrypt - Call crypto layer directly when padata_do_parallel() return -EBUSY 2024-12-14 19:44:23 +01:00
Documentation PCI: Add 'reset_subordinate' to reset hierarchy below bridge 2024-12-14 19:44:54 +01:00
drivers usb: gadget: u_serial: Fix the issue that gs_start_io crashed due to accessing null pointer 2024-12-19 18:05:02 +01:00
fs ocfs2: Revert "ocfs2: fix the la space leak when unmounting an ocfs2 volume" 2024-12-14 19:44:56 +01:00
include misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle 2024-12-14 19:44:55 +01:00
init initramfs: avoid filename buffer overrun 2024-12-14 19:44:21 +01:00
ipc
kernel bpf, xdp: Update devmap comments to reflect napi/rcu usage 2024-12-14 19:44:56 +01:00
lib lib: string_helpers: silence snprintf() output truncation warning 2024-12-14 19:44:39 +01:00
LICENSES
mm mm: revert "mm: shmem: fix data-race in shmem_getattr()" 2024-12-14 19:44:19 +01:00
net netpoll: Use rcu_access_pointer() in __netpoll_setup 2024-12-14 19:44:53 +01:00
samples samples/bpf: Fix a resource leak 2024-12-14 19:44:50 +01:00
scripts modpost: Add .irqentry.text to OTHER_SECTIONS 2024-12-14 19:44:56 +01:00
security apparmor: fix 'Do simple duplicate message elimination' 2024-12-14 19:44:34 +01:00
sound ALSA: usb-audio: Fix out of bounds reads when finding clock sources 2024-12-14 19:44:56 +01:00
tools perf trace: Avoid garbage when not printing a syscall's arguments 2024-12-14 19:44:32 +01:00
usr
virt KVM: arm64: vgic-its: Clear ITE when DISCARD frees an ITE 2024-12-14 19:44:55 +01:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore Remove *.orig pattern from .gitignore 2024-11-08 16:20:33 +01:00
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile Linux 5.4.287 2024-12-14 19:44:57 +01:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.