summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/net/psock_fanout.c
diff options
context:
space:
mode:
authorShuah Khan <shuahkh@osg.samsung.com>2014-11-11 10:04:13 -0700
committerDavid S. Miller <davem@davemloft.net>2014-11-11 21:43:34 -0500
commitfbf8e7211ac7858d3df4a4203c18da7a58560784 (patch)
tree563432a5328a8ebdfeffce9167a6bd8619ac93c1 /tools/testing/selftests/net/psock_fanout.c
parentcaa13a9f6a66f00203bea1ee9fc4446b96dcfe7c (diff)
selftests/net: psock_fanout seg faults in sock_fanout_read_ring()
The while loop in sock_fanout_read_ring() checks mmap region bounds after access, causing it to segfault. Fix it to check count before accessing header->tp_status. This problem can be reproduced consistently when the test in run as follows: make -C tools/testing/selftests TARGETS=net run_tests or make run_tests from tools/testing/selftests or make run_test from tools/testing/selftests/net Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/net/psock_fanout.c')
-rw-r--r--tools/testing/selftests/net/psock_fanout.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/testing/selftests/net/psock_fanout.c b/tools/testing/selftests/net/psock_fanout.c
index 57b9c2b7c4ff..6f6733331d95 100644
--- a/tools/testing/selftests/net/psock_fanout.c
+++ b/tools/testing/selftests/net/psock_fanout.c
@@ -128,7 +128,7 @@ static int sock_fanout_read_ring(int fd, void *ring)
struct tpacket2_hdr *header = ring;
int count = 0;
- while (header->tp_status & TP_STATUS_USER && count < RING_NUM_FRAMES) {
+ while (count < RING_NUM_FRAMES && header->tp_status & TP_STATUS_USER) {
count++;
header = ring + (count * getpagesize());
}