提交 fbf8e721 编写于 作者: S Shuah Khan 提交者: David S. Miller

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: NShuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 caa13a9f
...@@ -128,7 +128,7 @@ static int sock_fanout_read_ring(int fd, void *ring) ...@@ -128,7 +128,7 @@ static int sock_fanout_read_ring(int fd, void *ring)
struct tpacket2_hdr *header = ring; struct tpacket2_hdr *header = ring;
int count = 0; 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++; count++;
header = ring + (count * getpagesize()); header = ring + (count * getpagesize());
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册