kernel: check that a task has a network namespace

task.GetNetworkNamespace has to be used when we try to access a remote task.

PiperOrigin-RevId: 552593738
This commit is contained in:
Andrei Vagin
2023-07-31 14:43:55 -07:00
committed by gVisor bot
parent 5babda5341
commit ef95be6e1c
+6 -1
View File
@@ -43,7 +43,12 @@ func (fs *filesystem) newTaskNetDir(ctx context.Context, task *kernel.Task) kern
root := auth.NewRootCredentials(pidns.UserNamespace())
var contents map[string]kernfs.Inode
if stack := task.NetworkNamespace().Stack(); stack != nil {
var stack inet.Stack
if netns := task.GetNetworkNamespace(); netns != nil {
netns.DecRef(ctx)
stack = netns.Stack()
}
if stack != nil {
const (
arp = "IP address HW type Flags HW address Mask Device\n"
netlink = "sk Eth Pid Groups Rmem Wmem Dump Locks Drops Inode\n"