OSDN Git Service

selftests/net: add txring_overwrite
authorWillem de Bruijn <willemb@google.com>
Sun, 25 Nov 2018 02:09:26 +0000 (21:09 -0500)
committerDavid S. Miller <davem@davemloft.net>
Sun, 25 Nov 2018 02:22:21 +0000 (18:22 -0800)
commit358be656406dce296fafeac7a913ba33e9a66971
tree11dcd5c0e1ebe476284d310dd60299be0ef5fae8
parent3c18aa1464f9232d6abac8d7b4540f61b0658d62
selftests/net: add txring_overwrite

Packet sockets with PACKET_TX_RING send skbs with user data in frags.

Before commit 5cd8d46ea156 ("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>
tools/testing/selftests/net/.gitignore
tools/testing/selftests/net/Makefile
tools/testing/selftests/net/run_afpackettests
tools/testing/selftests/net/txring_overwrite.c [new file with mode: 0644]