690 Commits

Author SHA1 Message Date
Lucas Manning 95ad423f8c Don't return empty translation in ring buffer during bus error.
Reported-by: syzbot+b441fb97dc83729a444d@syzkaller.appspotmail.com
PiperOrigin-RevId: 726111936
2025-02-12 10:43:52 -08:00
Lucas Manning d6454b486f Lock around packetmmap cooked field and check for PACKET_RESERVE opt size.
Reported-by: syzbot+ca91395278b8bbe45820@syzkaller.appspotmail.com
Reported-by: syzbot+7786024ead82f25b39c5@syzkaller.appspotmail.com
PiperOrigin-RevId: 725302503
2025-02-10 12:18:14 -08:00
Lucas Manning faac8f36cd Add support for PACKET_STATISTICS.
PiperOrigin-RevId: 725271073
2025-02-10 10:46:54 -08:00
Lucas Manning 9c490f813d Implement GetSockOpt PACKET_HDRLEN and add a test for tcpdump.
PiperOrigin-RevId: 724445536
2025-02-07 13:06:14 -08:00
Lucas Manning 25084ce9ed Add locking around packetmmap initialization and mode.
Reported-by: syzbot+0bd17f07432518e1a3f4@syzkaller.appspotmail.com
Reported-by: syzbot+c461ce33fdf84ea55105@syzkaller.appspotmail.com
Reported-by: syzbot+8d5e8d31b8303257b69f@syzkaller.appspotmail.com
PiperOrigin-RevId: 724407775
2025-02-07 11:13:16 -08:00
Lucas Manning 213917f3ea Don't switch to using the packet mmap endpoint for zero length requests.
This matches linux's behavior.

Reported-by: syzbot+31f4b63198c23c53c6e2@syzkaller.appspotmail.com
Reported-by: syzbot+e19f276e27cccbbecd0e@syzkaller.appspotmail.com
PiperOrigin-RevId: 724032784
2025-02-06 12:34:46 -08:00
Ayush Ranjan d8518f2991 Validate PACKET_RX_RING and PACKET_VERSION socket option value size.
Reported-by: syzbot+0e132bb052dcf3804e31@syzkaller.appspotmail.com
Reported-by: syzbot+8e48cb352eb08dc2c8ab@syzkaller.appspotmail.com
PiperOrigin-RevId: 723999333
2025-02-06 11:04:23 -08:00
Lucas Manning 6194338723 Add support for setting PACKET_VERSION for PACKET_MMAP.
tcpdump requires TPACKET_V2 to work properly.

PiperOrigin-RevId: 723670574
2025-02-05 15:19:34 -08:00
Lucas Manning 83a4caf2a7 Implement MappablePacketEndpoint for PACKET_MMAP and add tests.
PiperOrigin-RevId: 723590936
2025-02-05 11:39:27 -08:00
Lucas Manning 0f8896589f Implement the PacketMMapEndpoint interface for PACKET_MMAP.
This code is tested in the subsequent change with syscall tests.

PiperOrigin-RevId: 721861305
2025-01-31 12:26:38 -08:00
Andrei Vagin f010ae01ac Fix a few typos 2025-01-29 21:16:51 -08:00
clickyotomy 4a8209f26f netfilter: Support multiport matching (-m multiport)
This set of changes adds:

  - support for `xt_multiport_{,v1}` matchers for matching for
    a range of ports and their inverse, i.e.,:

      ```
      -m multiport [!] --[s|d]ports (PORT,...|PORT:PORT,...)
      ```

  - support for `IP{,6}T_SO_GET_REVISION_MATCH` socket options,
    which allows `iptables` to query for the highest supported
    revision for a given matcher
2025-01-18 09:46:30 -05:00
Nayana Bidari a3e5887415 Changes to support netstack save restore.
- Added a new Stats() method in inet.Stack to get the saved stats
during restore.
- Mark stack.nic, tcpip.Route and stack.addressState structs as "nosave".
These fields should not be saved because the IP addresses and routes can
change during restore and new configuration of routes and IP addresses will be
extracted from the restore spec and initialized in the saved stack.
- Changes in Restore() method in icmp, udp, tcp, packet and raw endpoint files
to support save restore of these endpoints. These changes are flag guarded by
the TESTONLY-save-restore-netstack flag.

PiperOrigin-RevId: 707639274
2024-12-18 12:52:22 -08:00
Jing Chen c88ffa321e Returns ENOBUFS when writing to a veth device whose buffer is full.
A task is stuck when it keeps sendMsg w/o any recvMsg  until  the number of
message exceeds the buffer limit. The change also significantly bumps the
limit from 64 to 1000 for a larger buffer.

Reported-by: syzbot+8788f5c1ba95e12ab07d@syzkaller.appspotmail.com
Reported-by: syzbot+67759fceac0c30ece991@syzkaller.appspotmail.com
PiperOrigin-RevId: 704904404
2024-12-10 17:35:54 -08:00
Lucas Manning 2267c24a41 Add support for custom socket options and setting the experiment IP option.
PiperOrigin-RevId: 700011458
2024-11-25 09:43:21 -08:00
Nayana Bidari df9ba5fb67 Restore listening connections when netstack s/r is enabled.
This CL restores the listening connections when netstack s/r is enabled.
The changes include:
- New method as a workaround to replace the new routes and nics to the loaded
stack after restore.
- New Restore() for transport layer protocols to restore the protocol level
background workers.
- Adds afterLoad() method for fdbased processors.
- Adds a test to verify listening connection is restored after checkpointing
with netstack s/r enabled.
- Few other changes to save restore fields to enable netstack s/r.

PiperOrigin-RevId: 698453124
2024-11-20 11:13:57 -08:00
Jamie Liu e23347e5b5 Move //pkg/sentry/kernel/time to //pkg/sentry/ktime.
This avoids needing to rename it everywhere it's imported.

PiperOrigin-RevId: 693930089
2024-11-06 18:13:51 -08:00
Koichi Shiraishi 0cf77c02f8 all: remove use io/ioutil deprecated package & fix some deprecated thing
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2024-10-10 20:36:24 +09:00
gVisor bot 41c56d467b Merge pull request #10996 from cweld510:cweld/optionally-close-unix-sockets-on-save
PiperOrigin-RevId: 684217787
2024-10-09 16:54:50 -07:00
cweld510 db4ffada10 style feedback: remove newlines, fix import, remove stray comment 2024-10-07 22:39:13 +00:00
cweld510 727bc9c72a Add and implement option to close unsaveable gofer-backed unix sockets
on save
2024-10-04 20:13:38 +00:00
Andrei Vagin 2d0a6f7865 tools/bazeldefs: always pass bazel_cgo to go_library
Its value will be known only on the configuration phase,
before that it can be a select directive.

Updates #9266

PiperOrigin-RevId: 678412518
2024-09-24 15:12:58 -07:00
gVisor bot 079c1a937b Merge pull request #9551 from amysaq2023:support-external-stack
PiperOrigin-RevId: 677933413
2024-09-23 14:12:32 -07:00
Jing Chen f681bcc095 Implement RTM_DELROUTE in netstack.
PiperOrigin-RevId: 675711612
2024-09-17 14:33:41 -07:00
Nayana Bidari 740dc367db Mark netstack as save and use it only in tests
- Adds a new flag which will enable netstack s/r. When the flag is not enabled,
there is no change in the existing behavior. The flag will be enabled only in
tests to verify the s/r functionality of netstack.
- Some additional fields in netstack were causing panic when netstack is
save/restored. Such fields are marked as 'save'/'nosave' accordingly to resolve
the panic.

PiperOrigin-RevId: 668566657
2024-08-28 12:49:43 -07:00