summaryrefslogtreecommitdiffhomepage
path: root/runsc/fsgofer/fsgofer_amd64_unsafe.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2020-08-19 18:03:15 -0700
committerAndrei Vagin <avagin@gmail.com>2020-09-09 17:53:10 -0700
commit00ee4cb1a26d8f3cabbbb7fc05d719d8aabbee60 (patch)
treed68a1d75fd2f281b932212770bde241635a2102c /runsc/fsgofer/fsgofer_amd64_unsafe.go
parent59a394f856108dcb33f242a61ff6e1700161b4f3 (diff)
Remove path walk from localFile.Mknod
Replace mknod call with mknodat equivalent to protect against symlink attacks. Also added Mknod tests. Remove goferfs reliance on gofer to check for file existence before creating a synthetic entry. Updates #2923 PiperOrigin-RevId: 327544516
Diffstat (limited to 'runsc/fsgofer/fsgofer_amd64_unsafe.go')
-rw-r--r--runsc/fsgofer/fsgofer_amd64_unsafe.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/runsc/fsgofer/fsgofer_amd64_unsafe.go b/runsc/fsgofer/fsgofer_amd64_unsafe.go
index 5d4aab597..c46958185 100644
--- a/runsc/fsgofer/fsgofer_amd64_unsafe.go
+++ b/runsc/fsgofer/fsgofer_amd64_unsafe.go
@@ -17,25 +17,25 @@
package fsgofer
import (
- "syscall"
"unsafe"
+ "golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/abi/linux"
"gvisor.dev/gvisor/pkg/syserr"
)
-func statAt(dirFd int, name string) (syscall.Stat_t, error) {
- nameBytes, err := syscall.BytePtrFromString(name)
+func statAt(dirFd int, name string) (unix.Stat_t, error) {
+ nameBytes, err := unix.BytePtrFromString(name)
if err != nil {
- return syscall.Stat_t{}, err
+ return unix.Stat_t{}, err
}
namePtr := unsafe.Pointer(nameBytes)
- var stat syscall.Stat_t
+ var stat unix.Stat_t
statPtr := unsafe.Pointer(&stat)
- if _, _, errno := syscall.Syscall6(
- syscall.SYS_NEWFSTATAT,
+ if _, _, errno := unix.Syscall6(
+ unix.SYS_NEWFSTATAT,
uintptr(dirFd),
uintptr(namePtr),
uintptr(statPtr),
@@ -43,7 +43,7 @@ func statAt(dirFd int, name string) (syscall.Stat_t, error) {
0,
0); errno != 0 {
- return syscall.Stat_t{}, syserr.FromHost(errno).ToError()
+ return unix.Stat_t{}, syserr.FromHost(errno).ToError()
}
return stat, nil
}