android_kernel_sony_sdm845/net/bluetooth
Repository files (latest commit first)
Filename Latest commit message Latest commit date
David Howells 3531d69d5b BACKPORT: net: Work around lockdep limitation in sockets that use sockets
Lockdep issues a circular dependency warning when AFS issues an operation
through AF_RXRPC from a context in which the VFS/VM holds the mmap_sem.

The theory lockdep comes up with is as follows:

 (1) If the pagefault handler decides it needs to read pages from AFS, it
     calls AFS with mmap_sem held and AFS begins an AF_RXRPC call, but
     creating a call requires the socket lock:

	mmap_sem must be taken before sk_lock-AF_RXRPC

 (2) afs_open_socket() opens an AF_RXRPC socket and binds it.  rxrpc_bind()
     binds the underlying UDP socket whilst holding its socket lock.
     inet_bind() takes its own socket lock:

	sk_lock-AF_RXRPC must be taken before sk_lock-AF_INET

 (3) Reading from a TCP socket into a userspace buffer might cause a fault
     and thus cause the kernel to take the mmap_sem, but the TCP socket is
     locked whilst doing this:

	sk_lock-AF_INET must be taken before mmap_sem

However, lockdep's theory is wrong in this instance because it deals only
with lock classes and not individual locks.  The AF_INET lock in (2) isn't
really equivalent to the AF_INET lock in (3) as the former deals with a
socket entirely internal to the kernel that never sees userspace.  This is
a limitation in the design of lockdep.

Fix the general case by:

 (1) Double up all the locking keys used in sockets so that one set are
     used if the socket is created by userspace and the other set is used
     if the socket is created by the kernel.

 (2) Store the kern parameter passed to sk_alloc() in a variable in the
     sock struct (sk_kern_sock).  This informs sock_lock_init(),
     sock_init_data() and sk_clone_lock() as to the lock keys to be used.

     Note that the child created by sk_clone_lock() inherits the parent's
     kern setting.

 (3) Add a 'kern' parameter to ->accept() that is analogous to the one
     passed in to ->create() that distinguishes whether kernel_accept() or
     sys_accept4() was the caller and can be passed to sk_alloc().

     Note that a lot of accept functions merely dequeue an already
     allocated socket.  I haven't touched these as the new socket already
     exists before we get the parameter.

     Note also that there are a couple of places where I've made the accepted
     socket unconditionally kernel-based:

	irda_accept()
	rds_rcp_accept_one()
	tcp_accept_from_sock()

     because they follow a sock_create_kern() and accept off of that.

Whilst creating this, I noticed that lustre and ocfs don't create sockets
through sock_create_kern() and thus they aren't marked as for-kernel,
though they appear to be internal.  I wonder if these should do that so
that they use the new set of lock keys.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
2026-05-15 17:56:15 +07:00
..
bnep
cmtp Bluetooth: cmtp: fix possible panic when cmtp_init_sockets() fails 2022-01-27 08:47:33 +01:00
hidp HID: introduce hid_is_using_ll_driver 2021-12-14 10:04:46 +01:00
rfcomm BACKPORT: net: Work around lockdep limitation in sockets that use sockets 2026-05-15 17:56:15 +07:00
6lowpan.c Bluetooth: 6LoWPAN: add missing hci_dev_put() in get_l2cap_conn() 2022-12-14 11:24:34 +01:00
a2mp.c Bluetooth: drop HCI device reference before return 2021-03-03 17:44:32 +01:00
a2mp.h
af_bluetooth.c This is the 4.9.89 stable release 2018-03-22 09:54:47 +01:00
amp.c Bluetooth: Fix null pointer dereference in amp_read_loc_assoc_final_data 2021-03-07 11:25:57 +01:00
amp.h
ecc.c
ecc.h
hci_conn.c bluetooth: Check key sizes only when Secure Simple Pairing is enabled 2026-05-15 17:48:19 +07:00
hci_core.c Bluetooth: hci_core: don't call kfree_skb() under spin_lock_irqsave() 2023-01-07 12:07:23 +01:00
hci_debugfs.c
hci_debugfs.h
hci_event.c Bluetooth: Fix use after free in hci_send_acl 2022-04-20 09:06:43 +02:00
hci_request.c bluetooth: eliminate the potential race condition when removing the HCI controller 2021-05-22 10:40:20 +02:00
hci_request.h
hci_sock.c Bluetooth: defer cleanup of resources in hci_unregister_dev() 2021-08-15 13:01:02 +02:00
hci_sysfs.c Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times 2022-10-26 13:15:46 +02:00
Kconfig
l2cap_core.c Bluetooth: L2CAP: Fix u8 overflow 2023-01-07 12:07:11 +01:00
l2cap_sock.c BACKPORT: net: Work around lockdep limitation in sockets that use sockets 2026-05-15 17:56:15 +07:00
leds.c
leds.h
lib.c
Makefile
mgmt.c Bluetooth: Fix the HCI to MGMT status conversion table 2021-07-20 16:21:08 +02:00
mgmt_util.c
mgmt_util.h
sco.c BACKPORT: net: Work around lockdep limitation in sockets that use sockets 2026-05-15 17:56:15 +07:00
selftest.c
selftest.h
smp.c Bluetooth: SMP: Fail if remote and local public keys are identical 2021-05-26 11:29:09 +02:00
smp.h Bluetooth: SMP: fix crash in unpairing 2018-11-10 07:42:42 -08:00