google / gvisor

Application Kernel for Containers
https://gvisor.dev
Apache License 2.0
15.83k stars 1.3k forks source link

ICMP sockets allow receiving on IPv4 broadcast and multicast #5763

Open puradox opened 3 years ago

puradox commented 3 years ago

Description

While creating packetimpact tests for ICMP sockets, I noticed they allow receiving from IPv4 broadcast and multicast addresses while bound to the IPv4 any address (0.0.0.0). This behavior deviates from Linux, resulting in a packetimpact failure.

Steps to reproduce

$ blaze test //third_party/gvisor/test/packetimpact/tests:icmp_send_recv_dgram_native_test
[...]
//third_party/gvisor/test/packetimpact/tests:icmp_send_recv_dgram_native_test PASSED in 195.6s

$ blaze test //third_party/gvisor/test/packetimpact/tests:icmp_send_recv_dgram_netstack_test
[...]
//third_party/gvisor/test/packetimpact/tests:icmp_send_recv_dgram_netstack_test FAILED in 178.8s

The log file shows the deviation in gVisor:

--- FAIL: TestICMPv4SocketReceive (84.39s)
    --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=255.255.255.255/bindToDevice=false/expectData=false (0.16s)
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=255.255.255.255/bindToDevice=false/expectData=false/empty (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=8, payload="\x00\x00M+\xb2\xd4\x00\x00", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=255.255.255.255/bindToDevice=false/expectData=false/small (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=19, payload="\x00\x00\xbb\\\xb2\xd4\x00\x00hello world", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=255.255.255.255/bindToDevice=false/expectData=false/random1k (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=100, payload="\x00\x00>H\xb2\xd4\x00\x00\xd6-T\xb0\x13\xdct-k\xd4c%F\x0fi+vԙ\x1f\a\x96\x82\r\u07bf\x15\f}3\x82\x97\x95xM\xd2u\x9b3M'\x06p\xa7&IA\xbe]\x99\xd4`\xd0x\xa9\xee\xdc6`\xcb1v\xad0/\x93e\xf0\xbdi\x8eF\x9f>cQ\x1a\xbc\x81\x10\x99\x95ۡ{\xe1\xab\xe8\xbc҄\a", errno=errno 0
    --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=255.255.255.255/bindToDevice=true/expectData=false (0.18s)
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=255.255.255.255/bindToDevice=true/expectData=false/empty (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=8, payload="\x00\x00G\x99\xb8f\x00\x00", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=255.255.255.255/bindToDevice=true/expectData=false/small (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=19, payload="\x00\x00\xb5ʸf\x00\x00hello world", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=255.255.255.255/bindToDevice=true/expectData=false/random1k (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=100, payload="\x00\x00Xl\xb8f\x00\x00|,\xc8ɷE\xb0赑\x99\x14$ZI\xac\x19,\xd7}\x10\u07b9\xa2Ib?i`e\xa52\xc2\x0e\uf79b\x0f\xe7\x06W\x95f\xa9\xee\xb1MN\x82Q\xa7u\x0e)\xea\xa6\x0f\x03L\x1az\x1dQ\xaa\x03\xa4_\xff\x89\xac\xf4\x10\x80\xde\xecU\x06\x12\x8b\x06\xf0\x03\xfaF\xbc@!\xa8/\xadj\x80", errno=errno 0
    --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=224.0.0.1/bindToDevice=false/expectData=false (0.15s)
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=224.0.0.1/bindToDevice=false/expectData=false/empty (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=8, payload="\x00\x007\xb4\xc8K\x00\x00", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=224.0.0.1/bindToDevice=false/expectData=false/small (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=19, payload="\x00\x00\xa5\xe5\xc8K\x00\x00hello world", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=224.0.0.1/bindToDevice=false/expectData=false/random1k (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=100, payload="\x00\x00\xee[\xc8K\x00\x00Ql\u007f\xe28\xc8\a\x81\x80e\xbf1 \x03\xc1.\x02R]i\xd9b\x9a\x99\xe4\xacf\xad.y/0,Ҧ\xf5\xf7\x02\xdd(\x04\a8\xa0\x84\xa7\x05/,>ВL3\xb7\xa5\xd3W\xb7ɢ\x9c\xeb\xd8b\x1aK\xfb{\xb3Fv\xff!\rY\xf7\xf9\xd4\xea\xfb|\\I\f\x9e\xa4\x84\x02\xaf[\xb0", errno=errno 0
    --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=224.0.0.1/bindToDevice=true/expectData=false (0.13s)
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=224.0.0.1/bindToDevice=true/expectData=false/empty (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=8, payload="\x00\x004\xc0\xcb?\x00\x00", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=224.0.0.1/bindToDevice=true/expectData=false/small (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=19, payload="\x00\x00\xa2\xf1\xcb?\x00\x00hello world", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=224.0.0.1/bindToDevice=true/expectData=false/random1k (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=100, payload="\x00\x00\xa8f\xcb?\x00\x00\xb8ě\u007f\x04\xda\xdc(\xd2\xec\xdd\x0fP\x8d\xad!5\x843\x04\xe3x\xb3\xbczO%\u007f\xa41k\xe9V\xe0\xa0!\xed\xb8\x04_9\xfa\x9f\x00 \x87\xf0g\x19\x9b\xd6\x00\x1aʭ\xd2aK\xf6\xae\xfd?\t\x8f\x92\xa9Yh_$\xbb\"\x06\xc3G5\x9d\x9cj\xdchG\x11{\xb44\xacl@\xeca\x8f", errno=errno 0
    --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=217.132.229.255/bindToDevice=false/expectData=false (0.16s)
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=217.132.229.255/bindToDevice=false/expectData=false/empty (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=8, payload="\x00\x00;\xa4\xc4[\x00\x00", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=217.132.229.255/bindToDevice=false/expectData=false/small (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=19, payload="\x00\x00\xa9\xd5\xc4[\x00\x00hello world", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=217.132.229.255/bindToDevice=false/expectData=false/random1k (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=100, payload="\x00\x00yl\xc4[\x00\x00zӌ\"Ϳ}+\u007f\xf7\xd8S\x83\xc1x\xa85\xec`L?\x9e\xe3s\x99\xf7݂n4\xf1\xa3Z\xb7]\xa4K\xa5o\x86\t}\xdc\x0f6X\xef[\xd6Z$\xf4\xdeBUа4\x11\xa9\xd7\xf0\xdd\u009e3ˆ]\xa23\x93G\x1a\xa9Nl\x9er\xe7\x89 m;\xa1\x18\xae\xcd9rph", errno=errno 0
    --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=217.132.229.255/bindToDevice=true/expectData=false (0.13s)
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=217.132.229.255/bindToDevice=true/expectData=false/empty (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=8, payload="\x00\x000\xae\xcfQ\x00\x00", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=217.132.229.255/bindToDevice=true/expectData=false/small (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=19, payload="\x00\x00\x9e\xdf\xcfQ\x00\x00hello world", errno=errno 0
        --- FAIL: TestICMPv4SocketReceive/bindTo=0.0.0.0/sendTo=217.132.229.255/bindToDevice=true/expectData=false/random1k (0.00s)
            third_party/gvisor/test/packetimpact/tests/icmp_send_recv_dgram_test.go:492: Recv got unexpected result, ret=100, payload="\x00\x00\xce]\xcfQ\x00\x00X\xfe\xd4#L\xb8\xbc\xab\x1b\x8b\x18\xbfP\x95e\x06\xba\xae\x8b\xc1\xb7I\"P\xf3\xad\xf6B\x941\x03\x87\xf1Լ\xac\x12e(\x95\xd4\xf2\xdc\xe2o8\a3\xce\vX \xe9\xfc\xd8Q*\x15\x85\xa4\x99@\xa3/ȇZ\xc3\xc9T*Bp`.^\x97\xe7 \x90\xedq\xb5\x1b\xad\xb7u4\x04)\xfd\xbe", errno=errno 0
github-actions[bot] commented 1 year ago

A friendly reminder that this issue had no activity for 120 days.

github-actions[bot] commented 11 months ago

This issue has been closed due to lack of activity.

github-actions[bot] commented 10 months ago

There are TODOs still referencing this issue:

  1. test/packetimpact/tests/generic_dgram_socket_send_recv_test.go:291: Remove this if statement once gVisor
  2. test/packetimpact/tests/generic_dgram_socket_send_recv_test.go:497: Remove this if statement once gVisor

Search TODO

github-actions[bot] commented 6 months ago

A friendly reminder that this issue had no activity for 120 days.