Skip to content

Commit 533643b

Browse files
q2venkuba-moo
authored andcommitted
af_unix: Set drop reason in manage_oob().
AF_UNIX SOCK_STREAM socket supports MSG_OOB. When OOB data is sent to a socket, recv() will break at that point. If the next recv() does not have MSG_OOB, the normal data following the OOB data is returned. Then, the OOB skb is dropped. Let's define a new drop reason for that case in manage_oob(). # echo 1 > /sys/kernel/tracing/events/skb/kfree_skb/enable # python3 >>> from socket import * >>> s1, s2 = socketpair(AF_UNIX) >>> s1.send(b'a', MSG_OOB) >>> s1.send(b'b') >>> s2.recv(2) b'b' # cat /sys/kernel/tracing/trace_pipe ... python3-223 ... kfree_skb: ... location=unix_stream_read_generic+0x59e/0xc20 reason: UNIX_SKIP_OOB Signed-off-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c49a157 commit 533643b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

include/net/dropreason-core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
FN(SOCKET_CLOSE) \
1010
FN(SOCKET_FILTER) \
1111
FN(SOCKET_RCVBUFF) \
12+
FN(UNIX_SKIP_OOB) \
1213
FN(PKT_TOO_SMALL) \
1314
FN(TCP_CSUM) \
1415
FN(UDP_CSUM) \
@@ -145,6 +146,11 @@ enum skb_drop_reason {
145146
SKB_DROP_REASON_SOCKET_FILTER,
146147
/** @SKB_DROP_REASON_SOCKET_RCVBUFF: socket receive buff is full */
147148
SKB_DROP_REASON_SOCKET_RCVBUFF,
149+
/**
150+
* @SKB_DROP_REASON_UNIX_SKIP_OOB: Out-Of-Band data is skipped by
151+
* recv() without MSG_OOB so dropped.
152+
*/
153+
SKB_DROP_REASON_UNIX_SKIP_OOB,
148154
/** @SKB_DROP_REASON_PKT_TOO_SMALL: packet size is too small */
149155
SKB_DROP_REASON_PKT_TOO_SMALL,
150156
/** @SKB_DROP_REASON_TCP_CSUM: TCP checksum error */

net/unix/af_unix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,7 @@ static struct sk_buff *manage_oob(struct sk_buff *skb, struct sock *sk,
26952695
spin_unlock(&sk->sk_receive_queue.lock);
26962696

26972697
consume_skb(read_skb);
2698-
kfree_skb(unread_skb);
2698+
kfree_skb_reason(unread_skb, SKB_DROP_REASON_UNIX_SKIP_OOB);
26992699

27002700
return skb;
27012701
}

0 commit comments

Comments
 (0)