Skip to content

Commit

Permalink
Add stub entries for /proc/sys/user/*_namespaces files.
Browse files Browse the repository at this point in the history
Some application require that these files exist.
Fixes #11210

PiperOrigin-RevId: 702511700
  • Loading branch information
ayushr2 authored and gvisor-bot committed Dec 4, 2024
1 parent 078be62 commit 119f863
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/sentry/fsimpl/proc/tasks_sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ const (
tcpWMem
)

const (
// maxNamespaces is used to represent the maximum number of namespaces
// that any user in the current user namespace may create. This stub value
// was randomly picked from a Linux system. To implement this properly, we
// would need add counters in auth.UserNamespace and implement the limit
// correctly in namespace implementations.
// See include/linux/user_namespace.h:user_namespace.ucount_max.
maxNamespaces = "385836\n"
)

// newSysDir returns the dentry corresponding to /proc/sys directory.
func (fs *filesystem) newSysDir(ctx context.Context, root *auth.Credentials, k *kernel.Kernel) kernfs.Inode {
return fs.newStaticDir(ctx, root, map[string]kernfs.Inode{
Expand All @@ -70,6 +80,16 @@ func (fs *filesystem) newSysDir(ctx context.Context, root *auth.Credentials, k *
"fs": fs.newStaticDir(ctx, root, map[string]kernfs.Inode{
"nr_open": fs.newInode(ctx, root, 0644, &atomicInt32File{val: &k.MaxFDLimit, min: 8, max: kernel.MaxFdLimit}),
}),
"user": fs.newStaticDir(ctx, root, map[string]kernfs.Inode{
"max_cgroup_namespaces": newStaticFile(maxNamespaces),
"max_ipc_namespaces": newStaticFile(maxNamespaces),
"max_mnt_namespaces": newStaticFile(maxNamespaces),
"max_net_namespaces": newStaticFile(maxNamespaces),
"max_pid_namespaces": newStaticFile(maxNamespaces),
"max_time_namespaces": newStaticFile(maxNamespaces),
"max_user_namespaces": newStaticFile(maxNamespaces),
"max_uts_namespaces": newStaticFile(maxNamespaces),
}),
"vm": fs.newStaticDir(ctx, root, map[string]kernfs.Inode{
"max_map_count": fs.newInode(ctx, root, 0444, newStaticFile("2147483647\n")),
"mmap_min_addr": fs.newInode(ctx, root, 0444, &mmapMinAddrData{k: k}),
Expand Down

0 comments on commit 119f863

Please sign in to comment.