0

I was reading the implementation of wireguard-go, and found it handles reading less than 4 bytes from the TUN device file when the no packet information flag is not set.

I wonder is it possible that this can happen without any error? And how can? I'm especially curious about the kernel part code. I'm very new to this. Any links to the code or references are appreciated.

https://github.com/WireGuard/wireguard-go/blob/6a08d81f6bc465a2276c61093d96e567d00beb24/tun/tun_linux.go#L369

I found this documentation, but it doesn't mention the case. https://www.kernel.org/doc/html/v5.8/networking/tuntap.html#frame-format

  • My guess is that this case (on line 369 of the first link) never happens (there are always 4 header bytes when the flag is absent), but the application being made by a security-wise person, this non-existing case is still tested. – A.B Jul 04 '22 at 10:00
  • @A.B Thank you for your guess! It really makes sense. I'm going to believe that for now. – Sirius Lee Jul 05 '22 at 12:58

0 Answers0