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

nacl: support sel_ldr_x86_64 -h/-r/-w etc fd passing #7930

Closed
gopherbot opened this issue May 3, 2014 · 4 comments
Closed

nacl: support sel_ldr_x86_64 -h/-r/-w etc fd passing #7930

gopherbot opened this issue May 3, 2014 · 4 comments
Labels
FrozenDueToAge OS-NaCl GOOS=nacl, Native Client, removed in Go 1.14
Milestone

Comments

@gopherbot
Copy link

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)
}
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, os-nativeclient, release-go1.3maybe.

@rsc
Copy link
Contributor

rsc commented May 11, 2014

Comment 2:

Labels changed: added release-none, removed release-go1.3maybe.

Status changed to Accepted.

@gopherbot
Copy link
Author

Comment 3:

Passing an FD for a listening TCP/unix domain socket would be really nice too.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc added OS-NaCl GOOS=nacl, Native Client, removed in Go 1.14 and removed release-none labels Apr 10, 2015
@ALTree
Copy link
Member

ALTree commented Oct 8, 2019

With nacl support being removed in 1.14 (#30439), this seems unlikely to be implemented. Closing here.

@ALTree ALTree closed this as completed Oct 8, 2019
@golang golang locked and limited conversation to collaborators Oct 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge OS-NaCl GOOS=nacl, Native Client, removed in Go 1.14
Projects
None yet
Development

No branches or pull requests

4 participants