summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/socket/netlink
diff options
context:
space:
mode:
authorKevin Krakauer <krakauer@google.com>2018-05-15 14:55:29 -0700
committerShentubot <shentubot@google.com>2018-05-15 14:56:18 -0700
commit96c28a43682e8a665142da5b8b0734198fff3a00 (patch)
tree503d6fab03f8598a7d56a61ba8e9ed5714965616 /pkg/sentry/socket/netlink
parent9889c29d6d26ba86b5e3590eac85bfb8393dd54e (diff)
sentry: Replaces saving of inet.Stack with retrieval via context.
Previously, inet.Stack was referenced in 2 structs in sentry/socket that can be saved/restored. If an app is saved and restored on another machine, it may try to use the old stack, which will have been replaced by a new stack on the new machine. PiperOrigin-RevId: 196733985 Change-Id: I6a8cfe73b5d7a90749734677dada635ab3389cb9
Diffstat (limited to 'pkg/sentry/socket/netlink')
-rw-r--r--pkg/sentry/socket/netlink/route/protocol.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/pkg/sentry/socket/netlink/route/protocol.go b/pkg/sentry/socket/netlink/route/protocol.go
index d611519d4..e8030c518 100644
--- a/pkg/sentry/socket/netlink/route/protocol.go
+++ b/pkg/sentry/socket/netlink/route/protocol.go
@@ -43,20 +43,13 @@ func typeKind(typ uint16) commandKind {
}
// Protocol implements netlink.Protocol.
-type Protocol struct {
- // stack is the network stack that this provider describes.
- //
- // May be nil.
- stack inet.Stack
-}
+type Protocol struct{}
var _ netlink.Protocol = (*Protocol)(nil)
// NewProtocol creates a NETLINK_ROUTE netlink.Protocol.
func NewProtocol(t *kernel.Task) (netlink.Protocol, *syserr.Error) {
- return &Protocol{
- stack: t.NetworkContext(),
- }, nil
+ return &Protocol{}, nil
}
// Protocol implements netlink.Protocol.Protocol.
@@ -83,12 +76,13 @@ func (p *Protocol) dumpLinks(ctx context.Context, hdr linux.NetlinkMessageHeader
// We always send back an NLMSG_DONE.
ms.Multi = true
- if p.stack == nil {
+ stack := inet.StackFromContext(ctx)
+ if stack == nil {
// No network devices.
return nil
}
- for id, i := range p.stack.Interfaces() {
+ for id, i := range stack.Interfaces() {
m := ms.AddMessage(linux.NetlinkMessageHeader{
Type: linux.RTM_NEWLINK,
})
@@ -124,12 +118,13 @@ func (p *Protocol) dumpAddrs(ctx context.Context, hdr linux.NetlinkMessageHeader
// We always send back an NLMSG_DONE.
ms.Multi = true
- if p.stack == nil {
+ stack := inet.StackFromContext(ctx)
+ if stack == nil {
// No network devices.
return nil
}
- for id, as := range p.stack.InterfaceAddrs() {
+ for id, as := range stack.InterfaceAddrs() {
for _, a := range as {
m := ms.AddMessage(linux.NetlinkMessageHeader{
Type: linux.RTM_NEWADDR,