]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit468035f64f5ad80a20a5e17a0374129b99a91e8d
tree11dcd5c0e1ebe476284d310dd60299be0ef5fae8
parentd86f9803d35f33bd71403a163a05b52a3ffea063
selftests/net: add txring_overwrite

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

Before commit 6fc822ab0cbc ("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]