@@ -22,6 +22,7 @@ import (
2222 "gvisor.dev/gvisor/pkg/abi/linux"
2323 "gvisor.dev/gvisor/pkg/context"
2424 "gvisor.dev/gvisor/pkg/errors/linuxerr"
25+ "gvisor.dev/gvisor/pkg/log"
2526 "gvisor.dev/gvisor/pkg/sentry/fsimpl/kernfs"
2627 "gvisor.dev/gvisor/pkg/sentry/kernel"
2728 "gvisor.dev/gvisor/pkg/sentry/kernel/auth"
@@ -68,6 +69,14 @@ var _ kernfs.Inode = (*tasksInode)(nil)
6869func (fs * filesystem ) newTasksInode (ctx context.Context , k * kernel.Kernel , pidns * kernel.PIDNamespace , internalData * InternalData ) * tasksInode {
6970 root := auth .NewRootCredentials (pidns .UserNamespace ())
7071
72+ // /proc is expected to have inode number
73+ // include/linux/proc_ns.h:PROC_ROOT_INO == 1; ensure that this is the case
74+ // by generating its inode number before any of its descendants.
75+ rootIno := fs .NextIno ()
76+ if rootIno != 1 {
77+ log .Traceback ("proc root inode has number %d" , rootIno )
78+ }
79+
7180 contents := map [string ]kernfs.Inode {
7281 "cmdline" : fs .newInode (ctx , root , 0444 , & cmdLineData {}),
7382 "cpuinfo" : fs .newInode (ctx , root , 0444 , newStaticFileSetStat (cpuInfoData (k ))),
@@ -99,7 +108,7 @@ func (fs *filesystem) newTasksInode(ctx context.Context, k *kernel.Kernel, pidns
99108 fs : fs ,
100109 fakeCgroupControllers : internalData .Cgroups ,
101110 }
102- inode .InodeAttrs .Init (ctx , root , linux .UNNAMED_MAJOR , fs .devMinor , fs . NextIno () , linux .ModeDirectory | 0555 )
111+ inode .InodeAttrs .Init (ctx , root , linux .UNNAMED_MAJOR , fs .devMinor , rootIno , linux .ModeDirectory | 0555 )
103112 inode .InitRefs ()
104113
105114 inode .OrderedChildren .Init (kernfs.OrderedChildrenOptions {})
0 commit comments