From 5a6a1eb420620c3d41a9db4ddf7ac7b163310f09 Mon Sep 17 00:00:00 2001 From: Brian Geffon Date: Tue, 4 Dec 2018 14:27:46 -0800 Subject: Enforce name length restriction on paths. NAME_LENGTH must be enforced per component. PiperOrigin-RevId: 224046749 Change-Id: Iba8105b00d951f2509dc768af58e4110dafbe1c9 --- pkg/sentry/fs/dirent.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'pkg/sentry/fs/dirent.go') diff --git a/pkg/sentry/fs/dirent.go b/pkg/sentry/fs/dirent.go index 4c0d1b7ef..4c0482036 100644 --- a/pkg/sentry/fs/dirent.go +++ b/pkg/sentry/fs/dirent.go @@ -458,6 +458,12 @@ func (d *Dirent) walk(ctx context.Context, root *Dirent, name string, walkMayUnl if !IsDir(d.Inode.StableAttr) { return nil, syscall.ENOTDIR } + + // The component must be less than NAME_MAX. + if len(name) > linux.NAME_MAX { + return nil, syscall.ENAMETOOLONG + } + if name == "" || name == "." { d.IncRef() return d, nil -- cgit v1.2.3