Skip to content

Commit

Permalink
Merge branch 'af_unix-fix-msg_oob-bugs-with-msg_peek'
Browse files Browse the repository at this point in the history
Kuniyuki Iwashima says:

====================
af_unix: Fix MSG_OOB bugs with MSG_PEEK.

Currently, OOB data can be read without MSG_OOB accidentally
in two cases, and this seris fixes the bugs.

v1: https://lore.kernel.org/netdev/20240409225209.58102-1-kuniyu@amazon.com/
====================

Link: https://lore.kernel.org/r/20240410171016.7621-1-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Apr 13, 2024
2 parents 90be7a5 + 22dd70e commit 27f58f7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -2663,7 +2663,9 @@ static struct sk_buff *manage_oob(struct sk_buff *skb, struct sock *sk,
WRITE_ONCE(u->oob_skb, NULL);
consume_skb(skb);
}
} else if (!(flags & MSG_PEEK)) {
} else if (flags & MSG_PEEK) {
skb = NULL;
} else {
skb_unlink(skb, &sk->sk_receive_queue);
WRITE_ONCE(u->oob_skb, NULL);
if (!WARN_ON_ONCE(skb_unref(skb)))
Expand Down Expand Up @@ -2741,18 +2743,16 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state,
last = skb = skb_peek(&sk->sk_receive_queue);
last_len = last ? last->len : 0;

again:
#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
if (skb) {
skb = manage_oob(skb, sk, flags, copied);
if (!skb) {
if (!skb && copied) {
unix_state_unlock(sk);
if (copied)
break;
goto redo;
break;
}
}
#endif
again:
if (skb == NULL) {
if (copied >= target)
goto unlock;
Expand Down

0 comments on commit 27f58f7

Please sign in to comment.