You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems the nacl syscall package's "var files" trickery does not let it
access nacl fds other than 0,1,2. Being able to access open files passed in by the
parent would be nice for things like safely running a query over file contents.
Running go tip f613443b.
How to reproduce:
cat read.go && GOOS=nacl GOARCH=amd64p32 go build -o read read.go &&
sel_ldr_x86_64 -r10:10 ./read 10<read.go
package main
import (
"fmt"
"log"
"syscall"
)
func main() {
buf := make([]byte, 8192)
n, err := syscall.Read(10, buf)
if err != nil {
log.Printf("read error: %s", err)
} else {
fmt.Printf("read %d %q\n", n, buf[:n])
}
}
[30054,1836660608:14:11:08.380778] Native Client module will be loaded at base address
0x00004fc600000000
runtime: nacl_exception_stack: error 38
runtime: nacl_exception_handler: error 38
runtime: nacl_exception_stack: error 38
runtime: nacl_exception_handler: error 38
runtime: nacl_exception_stack: error 38
runtime: nacl_exception_handler: error 38
runtime: nacl_exception_stack: error 38
runtime: nacl_exception_handler: error 38
2014/05/03 21:11:08 read error: Bad file number
[30054,1836447488:14:11:08.398073]
NaClRuntimeHostInterfaceReportExitStatus(0x7fa56df36040, 0x0)
The only creation of type naclFile seem to be in fd_nacl.go init(), for fds 0, 1, 2.
As a proof of concept, these two work:
diff --git i/src/pkg/syscall/fd_nacl.go w/src/pkg/syscall/fd_nacl.go
index cbc8315..d157085 100644
--- i/src/pkg/syscall/fd_nacl.go
+++ w/src/pkg/syscall/fd_nacl.go
@@ -318,3 +318,7 @@ func Pipe(fd []int) error {
fd[1] = newFD(&pipeFile{wr: q})
return nil
}
+
+func OpenNacl(naclFD int) (fd uintptr) {
+ return uintptr(newFD(&naclFile{naclFD: naclFD}))
+}
package main
import (
"io"
"log"
"os"
"syscall"
)
func main() {
fd := syscall.OpenNacl(10)
f := os.NewFile(fd, "/dev/fd/10")
n, err := io.Copy(os.Stdout, f)
log.Println(n, err)
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: