Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stub entries for /proc/sys/user/*_namespaces files. #11244

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading