107 Commits
Author SHA1 Message Date
Andrei Vagin f010ae01ac Fix a few typos 2025-01-29 21:16:51 -08:00
Jamie LiuandgVisor bot 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
cweld510 727bc9c72a Add and implement option to close unsaveable gofer-backed unix sockets
on save
2024-10-04 20:13:38 +00:00
Jing ChenandgVisor bot f681bcc095 Implement RTM_DELROUTE in netstack.
PiperOrigin-RevId: 675711612
2024-09-17 14:33:41 -07:00
Jing ChenandgVisor bot 35309c96c0 Implement RTM_NEWROUTE in netstack to create/replace a route.
PiperOrigin-RevId: 650814137
2024-07-09 18:04:19 -07:00
Jing ChenandgVisor bot b0ee04a097 Skip IFLA_TXQLEN and IFA_BROADCAST in gVisor.
The attributes are expected by Dockerd to start. In gVisor, skipping
the attributes is good enough to run the Docker workloads.

PiperOrigin-RevId: 650362257
2024-07-08 13:49:26 -07:00
Jing ChenandgVisor bot 222258a585 Support RTM_SETLINK in gVisor.
RTM_NEWLINK is the preferred way to change a link's configs. RTM_SETLINK is
needed by setting up Docker in gVisor.

PiperOrigin-RevId: 649789500
2024-07-06 00:49:54 -07:00
Andrei VaginandgVisor bot 01142fe599 netlink: socket controls a network namespace where it has been created
Each socket has to hold a reference on its network namespace.

PiperOrigin-RevId: 640691038
2024-06-05 16:46:01 -07:00
Andrei Vagin af92292ac8 Fix typos 2024-05-02 11:09:16 -07:00
Andrei VaginandgVisor bot 129734a352 Pass NEWLINK netlink commands to network stacks
The NEWLINK commands contains many properties and here is no reason to have
another abstract interface between the Sentry and network stacks.

PiperOrigin-RevId: 627916629
2024-04-24 18:42:44 -07:00
Andrei VaginandgVisor bot ea1a15131f Move helpers to parse netlink message to the separate module
It will be used in following changes.

PiperOrigin-RevId: 622287107
2024-04-05 14:49:39 -07:00
Andrei Vagin 5f4abad306 Fix a few typos
It is an idea of running codespell as part of our presubmit checks.
Before enabling it for new changes, let's fix what it has found.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2023-10-25 12:13:42 -07:00
Andrei VaginandgVisor bot d377e45376 netlink: allow to up/down interfaces via RTM_NEWLINK
It is required to run Docker in gVisor.
Netstack interfaces are always up, so this is no-op.

PiperOrigin-RevId: 576220175
2023-10-24 12:09:49 -07:00
Mustafa Uzun 70fabb2835 fix: rename dumpErrorMesage and dumpAckMessage functions 2023-08-18 10:46:02 +03:00
Jing ChenandgVisor bot 88bbeb404a Implement SO_SNDTIMEO and SO_RCVTIMEO for netlink's setsockopt and getsockopt.
PiperOrigin-RevId: 557933811
2023-08-17 14:18:15 -07:00
Jamie LiuandgVisor bot ff81c0c639 Remove //pkg/sentry/device.
This package was used for VFS1 device number assignment.

PiperOrigin-RevId: 538918926
2023-06-08 16:21:04 -07:00
Kevin KrakauerandgVisor bot 8478fe0a27 stop using tcpip.FullAddress with unix sockets
It's unnecessarily overloading the type, which makes it hard to change the type
in netstack.

PiperOrigin-RevId: 526168235
2023-04-21 16:48:37 -07:00
Nicolas LacasseandgVisor bot dadab01167 Implement hostinet.Stack methods that manipulate interfaces and addresses.
And enable all of the netlink tests that depend on this functionality.

Specifially, this CL implements hostinet.stack:
* .RemoveInterface()
* .AddInterfaceAddr()
* .RemoveInterfaceAddr()

Applications use netlink messages to call into these methods. For hostinet, we
use netlink messages to the host to implement these methods.

Note that the netlink messages are not simple passed from the application to
the host -- they are parsed first and only carefully crafted messages are sent
to the host.

This CL required a lot of refactoring to the existing netlink code in the
hostinet package, as well as a bunch of new functionality. All of that code has
been collected in hostinet/netlink.go

I also changed how we handle CAP_NET_ADMIN and CAP_NET_RAW in tests, since we
must drop those capabilities inside the sandbox if we don't have them on the
host. The new solution is cleaner and does not rely on google-specific env
variables.

PiperOrigin-RevId: 522685544
2023-04-07 14:33:21 -07:00
Etienne PerotandgVisor bot f8b9824813 Update unimpl.EmitUnimplementedEvent interface to add the syscall number.
This catches up the interface to the `EmitUnimplementedEvent` method signature
on `kernel.Kernel`.

Also add build-time test to verify that `kernel.Kernel` implements this
interface, in order to catch such breakages at build time in the future.

PiperOrigin-RevId: 519000411
2023-03-23 17:01:37 -07:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Ayush RanjanandgVisor bot 1fa3c06f1e Delete VFS1 completely.
- Delete pkg/sentry/fs/*.
- Move pkg/sentry/fs/fsutil out of VFS1 directory and remove VFS1 components.
- Remove remaining unused references to VFS1 from remaining codebase.
- Rename/refactor code to avoid even referencing VFS2, unless necessary.
- Rewrite VFS1-only tests to VFS2.

Updates #1624

PiperOrigin-RevId: 490064269
2022-11-21 13:57:52 -08:00
Bruno Dal BoandgVisor bot c40f8e3651 Rename ErrNoRoute to ErrHostUnreachable
ErrNoRoute gets translated to EHOSTUNREACH which causes some code paths to
produce different errors unexpectedly. Rename the error so we can clean up some
sites to return ENETUNREACH more clearly where needed.

Updates #8105

PiperOrigin-RevId: 482355099
2022-10-19 18:29:13 -07:00
Nicolas LacasseandgVisor bot 4761bf4537 Stop emitting unimplemented events from get/setsockopt.
These are of dubious value, and can often flood user's console with errors.

Fixes #8011

PiperOrigin-RevId: 478537513
2022-10-03 10:18:41 -07:00
Nicolas LacasseandgVisor bot e47be0cfc0 Move Send/RecvNotify calls outside of CopyIn/Out, due to lock order.
We were calling Send/RecvNotify inside of endpoint.Send/RecvMsg, which is
called as part of CopyIn/Out with mm.activeMu held. This leads to lock order
violation because those Send/RecvNotify needs TaskSet.mu to send a signal to a
task.

This CL changes endpoint.Send/RecvMsg to return a notification callback which
can be plumbed to the caller of CopyIn/Out and called without mm.activeMu held.

Updated the lock documentation in mm.go to order TaskSet.mu > mm.activeMu.

PiperOrigin-RevId: 452319981
2022-06-01 09:57:46 -07:00
Ayush RanjanandgVisor bot fed9f8ee8e Do not hold transport.Endpoint.mu during mknod in unix bind implementations.
This is consistent with Linux, which calls mknod(), then takes
unix_sock::bindlock and then marks the socket as bound. On error, the mknod is
reverted. See net/unix/af_unix.c:unix_bind_bsd().

This helps break the following lock chain: kernfs.filesystemRWMutex ->
kernel.taskSetRWMutex -> mm.activeRWMutex -> transport.endpointMutex.

PiperOrigin-RevId: 442104624
2022-04-15 15:07:53 -07:00