diff options
author | Michael Pratt <mpratt@google.com> | 2021-04-21 10:39:29 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-04-21 10:41:28 -0700 |
commit | c2955339d86437981ce53d2971ce83479ef94028 (patch) | |
tree | e68486bf1e193f23d6b3e9ba506c50c073a94a65 /runsc/fsgofer | |
parent | 07a78ecb2918905af030a8cf81ee86ddd1c622c5 (diff) |
Automated rollback of changelist 369325957
PiperOrigin-RevId: 369686285
Diffstat (limited to 'runsc/fsgofer')
-rw-r--r-- | runsc/fsgofer/fsgofer.go | 57 | ||||
-rw-r--r-- | runsc/fsgofer/fsgofer_test.go | 10 |
2 files changed, 13 insertions, 54 deletions
diff --git a/runsc/fsgofer/fsgofer.go b/runsc/fsgofer/fsgofer.go index b81ede5ae..e04ddda47 100644 --- a/runsc/fsgofer/fsgofer.go +++ b/runsc/fsgofer/fsgofer.go @@ -21,7 +21,6 @@ package fsgofer import ( - "errors" "fmt" "io" "math" @@ -59,6 +58,9 @@ var verityXattrs = map[string]struct{}{ // join is equivalent to path.Join() but skips path.Clean() which is expensive. func join(parent, child string) string { + if child == "." || child == ".." { + panic(fmt.Sprintf("invalid child path %q", child)) + } return parent + "/" + child } @@ -1224,56 +1226,3 @@ func (l *localFile) checkROMount() error { } return nil } - -func (l *localFile) MultiGetAttr(names []string) ([]p9.FullStat, error) { - stats := make([]p9.FullStat, 0, len(names)) - - if len(names) > 0 && names[0] == "" { - qid, valid, attr, err := l.GetAttr(p9.AttrMask{}) - if err != nil { - return nil, err - } - stats = append(stats, p9.FullStat{ - QID: qid, - Valid: valid, - Attr: attr, - }) - names = names[1:] - } - - parent := l.file.FD() - for _, name := range names { - child, err := unix.Openat(parent, name, openFlags|unix.O_PATH, 0) - if parent != l.file.FD() { - // Parent is no longer needed. - _ = unix.Close(parent) - } - if err != nil { - if errors.Is(err, unix.ENOENT) { - // No pont in continuing any further. - break - } - return nil, err - } - - var stat unix.Stat_t - if err := unix.Fstat(child, &stat); err != nil { - _ = unix.Close(child) - return nil, err - } - valid, attr := l.fillAttr(&stat) - stats = append(stats, p9.FullStat{ - QID: l.attachPoint.makeQID(&stat), - Valid: valid, - Attr: attr, - }) - if (stat.Mode & unix.S_IFMT) != unix.S_IFDIR { - // Doesn't need to continue if entry is not a dir. Including symlinks - // that cannot be followed. - _ = unix.Close(child) - break - } - parent = child - } - return stats, nil -} diff --git a/runsc/fsgofer/fsgofer_test.go b/runsc/fsgofer/fsgofer_test.go index 77723827a..d7e141476 100644 --- a/runsc/fsgofer/fsgofer_test.go +++ b/runsc/fsgofer/fsgofer_test.go @@ -703,6 +703,16 @@ func TestWalkNotFound(t *testing.T) { }) } +func TestWalkPanic(t *testing.T) { + runCustom(t, []uint32{unix.S_IFDIR}, allConfs, func(t *testing.T, s state) { + for _, name := range []string{".", ".."} { + assertPanic(t, func() { + s.file.Walk([]string{name}) + }) + } + }) +} + func TestWalkDup(t *testing.T) { runAll(t, func(t *testing.T, s state) { _, dup, err := s.file.Walk([]string{}) |