android_kernel_sony_sdm845/fs/ocfs2
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
..
cluster BACKPORT: net: Work around lockdep limitation in sockets that use sockets 2026-05-15 17:56:15 +07:00
dlm fs/ocfs2/dlm/dlmdebug.c: fix a sleep-in-atomic-context bug in dlm_print_one_mle() 2019-11-28 18:28:41 +01:00
dlmfs This is the 4.9.318 stable release 2022-06-14 17:02:23 +02:00
acl.c ocfs2: fix passing zero to 'PTR_ERR' warning 2020-01-04 13:41:03 +01:00
acl.h ocfs2: fix posix_acl_create deadlock 2016-05-12 15:52:50 -07:00
alloc.c ocfs2: fix data corruption after conversion from inline format 2021-10-27 09:34:00 +02:00
alloc.h ocfs2: retry on ENOSPC if sufficient space in truncate log 2016-08-02 17:31:41 -04:00
aops.c ocfs2: fix deadlock between setattr and dio_end_io_write 2021-04-16 11:59:06 +02:00
aops.h ocfs2: fix ip_unaligned_aio deadlock with dio work queue 2016-03-25 16:37:42 -07:00
blockcheck.c
blockcheck.h
buffer_head_io.c ocfs2: don't put and assigning null to bh allocated outside 2019-11-28 18:28:53 +01:00
buffer_head_io.h
dcache.c fs/ocfs2: fix race in ocfs2_dentry_attach_lock() 2019-06-22 08:17:18 +02:00
dcache.h
dir.c ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entry 2018-11-21 09:26:00 +01:00
dir.h
dlmglue.c ocfs2: drop acl cache for directories too 2021-10-06 10:23:38 +02:00
dlmglue.h ocfs2/dlmglue: prepare tracking logic to avoid recursive cluster lock 2017-10-21 17:21:36 +02:00
export.c ocfs2: fix ocfs2 read inode data panic in ocfs2_iget 2019-05-21 18:48:58 +02:00
export.h
extent_map.c
extent_map.h
file.c statx: Add a system call to make enhanced file info available 2025-07-10 14:15:39 -04:00
file.h statx: Add a system call to make enhanced file info available 2025-07-10 14:15:39 -04:00
filecheck.c ocfs2: fix snprintf() checking 2021-07-20 16:21:01 +02:00
filecheck.h ocfs2: sysfile interfaces for online file check 2016-03-22 15:36:02 -07:00
heartbeat.c
heartbeat.h
inode.c ocfs2: fix improper handling of return errno 2016-05-26 15:35:44 -07:00
inode.h ocfs2: fix undefined struct variable in inode.h 2016-10-07 18:46:26 -07:00
ioctl.c fs: ocfs2: fix a possible null-pointer dereference in ocfs2_info_scan_inode_alloc() 2019-11-06 12:18:11 +01:00
ioctl.h
journal.c ocfs2: call journal flush to mark journal as empty after journal recovery when mount 2020-01-23 08:19:38 +01:00
journal.h ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans() 2020-02-28 15:42:41 +01:00
Kconfig
localalloc.c ocfs2: fix panic due to ocfs2_wq is null 2019-10-29 09:15:08 +01:00
localalloc.h
locks.c
locks.h
Makefile ocfs2: disable BUG assertions in reading blocks 2016-06-24 17:23:52 -07:00
mmap.c mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros 2016-04-04 10:41:08 -07:00
mmap.h
move_extents.c ocfs2: fix clusters leak in ocfs2_defrag_extent() 2019-11-28 18:28:53 +01:00
move_extents.h
namei.c ocfs2: fix BUG when iput after ocfs2_mknod fails 2022-11-03 23:49:14 +09:00
namei.h
ocfs1_fs_compat.h
ocfs2.h ocfs2: change slot number type s16 to u16 2020-08-21 11:02:08 +02:00
ocfs2_fs.h ocfs2: fix value of OCFS2_INVALID_SLOT 2020-06-30 15:38:44 -04:00
ocfs2_ioctl.h
ocfs2_lockid.h
ocfs2_lockingver.h
ocfs2_trace.h switch generic_file_splice_read() to use of ->read_iter() 2016-10-05 18:23:56 -04:00
quota.h
quota_global.c quota: Check that quota is not dirty before release 2019-12-21 10:42:08 +01:00
quota_local.c
refcounttree.c fs: Replace CURRENT_TIME with current_time() for inode timestamps 2016-09-27 21:06:21 -04:00
refcounttree.h
reservations.c
reservations.h
resize.c ocfs2: solve a problem of crossing the boundary in updating backups 2016-03-25 16:37:42 -07:00
resize.h
slot_map.c ocfs2: clean up an unneeded goto in ocfs2_put_slot() 2016-05-19 19:12:14 -07:00
slot_map.h
stack_o2cb.c
stack_user.c ocfs2: ensure that dlm lockspace is created by kernel module 2016-08-02 17:31:41 -04:00
stackglue.c ocfs2: fix memory leak in ocfs2_stack_glue_init() 2023-01-07 12:07:13 +01:00
stackglue.h ocfs2: remove ocfs2_is_o2cb_active() 2019-11-28 18:29:02 +01:00
suballoc.c ocfs2: change slot number type s16 to u16 2020-08-21 11:02:08 +02:00
suballoc.h
super.c ocfs2: mount fails with buffer overflow in strlen 2021-10-27 09:34:00 +02:00
super.h ocfs2: fix occurring deadlock by changing ocfs2_wq from global to local 2016-03-25 16:37:42 -07:00
symlink.c vfs: Remove {get,set,remove}xattr inode operations 2016-10-07 21:48:36 -04:00
symlink.h
sysfile.c
sysfile.h
uptodate.c
uptodate.h
xattr.c Revert "fs: ocfs2: fix possible null-pointer dereferences in ocfs2_xa_prepare_entry()" 2019-11-28 18:28:08 +01:00
xattr.h ocfs2: fix posix_acl_create deadlock 2016-05-12 15:52:50 -07:00