diff options
author | Kuniyuki Iwashima <kuniyu@amazon.com> | 2025-01-16 14:34:35 +0900 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2025-01-20 11:27:40 -0800 |
commit | c32f0bd7d4838982c6724fca0da92353f27c6f88 (patch) | |
tree | 723ddd8b7d23aee2c7560596b851cfd387201f51 /net | |
parent | 454d402481d45af79ee7eea7e64bce02bbbe9766 (diff) | |
download | linux-c32f0bd7d4838982c6724fca0da92353f27c6f88.tar.gz linux-c32f0bd7d4838982c6724fca0da92353f27c6f88.tar.bz2 linux-c32f0bd7d4838982c6724fca0da92353f27c6f88.zip |
af_unix: Set drop reason in unix_release_sock().
unix_release_sock() is called when the last refcnt of struct file
is released.
Let's define a new drop reason SKB_DROP_REASON_SOCKET_CLOSE and
set it for kfree_skb() in unix_release_sock().
# echo 1 > /sys/kernel/tracing/events/skb/kfree_skb/enable
# python3
>>> from socket import *
>>> s1, s2 = socketpair(AF_UNIX)
>>> s1.send(b'hello world')
>>> s2.close()
# cat /sys/kernel/tracing/trace_pipe
...
python3-280 ... kfree_skb: ... protocol=0 location=unix_release_sock+0x260/0x420 reason: SOCKET_CLOSE
To be precise, unix_release_sock() is also called for a new child
socket in unix_stream_connect() when something fails, but the new
sk does not have skb in the recv queue then and no event is logged.
Note that only tcp_inbound_ao_hash() uses a similar drop reason,
SKB_DROP_REASON_TCP_CLOSE, and this can be generalised later.
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250116053441.5758-3-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/unix/af_unix.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 8f2b605ce5b3..a05d25cc5545 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -715,8 +715,8 @@ static void unix_release_sock(struct sock *sk, int embrion) if (state == TCP_LISTEN) unix_release_sock(skb->sk, 1); - /* passed fds are erased in the kfree_skb hook */ - kfree_skb(skb); + /* passed fds are erased in the kfree_skb hook */ + kfree_skb_reason(skb, SKB_DROP_REASON_SOCKET_CLOSE); } if (path.dentry) |