aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/garbage.c
diff options
context:
space:
mode:
authorKuniyuki Iwashima <[email protected]>2024-06-20 20:56:13 +0000
committerPaolo Abeni <[email protected]>2024-06-25 09:10:18 +0000
commit3955802f160b5c61ac00d7e54da8d746f2e4a2d5 (patch)
tree6da18af7ce90884b0dedb68c25ad4c52041b38d7 /net/unix/garbage.c
parentMerge branch 'locking-introduce-nested-bh-locking' (diff)
downloadkernel-3955802f160b5c61ac00d7e54da8d746f2e4a2d5.tar.gz
kernel-3955802f160b5c61ac00d7e54da8d746f2e4a2d5.zip
af_unix: Define locking order for unix_table_double_lock().
When created, AF_UNIX socket is put into net->unx.table.buckets[], and the hash is stored in sk->sk_hash. * unbound socket : 0 <= sk_hash <= UNIX_HASH_MOD When bind() is called, the socket could be moved to another bucket. * pathname socket : 0 <= sk_hash <= UNIX_HASH_MOD * abstract socket : UNIX_HASH_MOD + 1 <= sk_hash <= UNIX_HASH_MOD * 2 + 1 Then, we call unix_table_double_lock() which locks a single bucket or two. Let's define the order as unix_table_lock_cmp_fn() instead of using spin_lock_nested(). The locking is always done in ascending order of sk->sk_hash, which is the index of buckets/locks array allocated by kvmalloc_array(). sk_hash_A < sk_hash_B <=> &locks[sk_hash_A].dep_map < &locks[sk_hash_B].dep_map So, the relation of two sk->sk_hash can be derived from the addresses of dep_map in the array of locks. Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Kent Overstreet <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
Diffstat (limited to 'net/unix/garbage.c')
0 files changed, 0 insertions, 0 deletions