forked from Minki/linux
358be65640
Packet sockets with PACKET_TX_RING send skbs with user data in frags.
Before commit 5cd8d46ea1
("packet: copy user buffers before orphan
or clone") ring slots could be released prematurely, possibly allowing
a process to overwrite data still in flight.
This test opens two packet sockets, one to send and one to read.
The sender has a tx ring of one slot. It sends two packets with
different payload, then reads both and verifies their payload.
Before the above commit, both receive calls return the same data as
the send calls use the same buffer. From the commit, the clone
needed for looping onto a packet socket triggers an skb_copy_ubufs
to create a private copy. The separate sends each arrive correctly.
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
38 lines
666 B
Bash
Executable File
38 lines
666 B
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
if [ $(id -u) != 0 ]; then
|
|
echo $msg must be run as root >&2
|
|
exit 0
|
|
fi
|
|
|
|
echo "--------------------"
|
|
echo "running psock_fanout test"
|
|
echo "--------------------"
|
|
./in_netns.sh ./psock_fanout
|
|
if [ $? -ne 0 ]; then
|
|
echo "[FAIL]"
|
|
else
|
|
echo "[PASS]"
|
|
fi
|
|
|
|
echo "--------------------"
|
|
echo "running psock_tpacket test"
|
|
echo "--------------------"
|
|
./in_netns.sh ./psock_tpacket
|
|
if [ $? -ne 0 ]; then
|
|
echo "[FAIL]"
|
|
else
|
|
echo "[PASS]"
|
|
fi
|
|
|
|
echo "--------------------"
|
|
echo "running txring_overwrite test"
|
|
echo "--------------------"
|
|
./in_netns.sh ./txring_overwrite
|
|
if [ $? -ne 0 ]; then
|
|
echo "[FAIL]"
|
|
else
|
|
echo "[PASS]"
|
|
fi
|