Commit 9d20e9c
af_unix: Don't peek OOB data without MSG_OOB.
BugLink: https://bugs.launchpad.net/bugs/2067959
[ Upstream commit 22dd70e ]
Currently, we can read OOB data without MSG_OOB by using MSG_PEEK
when OOB data is sitting on the front row, which is apparently
wrong.
>>> from socket import *
>>> c1, c2 = socketpair(AF_UNIX, SOCK_STREAM)
>>> c1.send(b'a', MSG_OOB)
1
>>> c2.recv(1, MSG_PEEK | MSG_DONTWAIT)
b'a'
If manage_oob() is called when no data has been copied, we only
check if the socket enables SO_OOBINLINE or MSG_PEEK is not used.
Otherwise, the skb is returned as is.
However, here we should return NULL if MSG_PEEK is set and no data
has been copied.
Also, in such a case, we should not jump to the redo label because
we will be caught in the loop and hog the CPU until normal data
comes in.
Then, we need to handle skb == NULL case with the if-clause below
the manage_oob() block.
With this patch:
>>> from socket import *
>>> c1, c2 = socketpair(AF_UNIX, SOCK_STREAM)
>>> c1.send(b'a', MSG_OOB)
1
>>> c2.recv(1, MSG_PEEK | MSG_DONTWAIT)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
BlockingIOError: [Errno 11] Resource temporarily unavailable
Fixes: 314001f ("af_unix: Add OOB support")
Signed-off-by: Kuniyuki Iwashima <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Portia Stephens <[email protected]>
Signed-off-by: Stefan Bader <[email protected]>1 parent ef92962 commit 9d20e9c
1 file changed
+5
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2565 | 2565 | | |
2566 | 2566 | | |
2567 | 2567 | | |
2568 | | - | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
2569 | 2571 | | |
2570 | 2572 | | |
2571 | 2573 | | |
| |||
2648 | 2650 | | |
2649 | 2651 | | |
2650 | 2652 | | |
2651 | | - | |
| 2653 | + | |
2652 | 2654 | | |
2653 | | - | |
2654 | | - | |
2655 | | - | |
| 2655 | + | |
2656 | 2656 | | |
2657 | 2657 | | |
2658 | 2658 | | |
| |||
0 commit comments