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
UDP Client does not get the correct address using getsockname.
When UDP client connects to a server address, kernel assigns the IP-address:port-number for
the client's end-point. After call to connect system call, the client IP address:port-number can be retrieved using
getsockname system call.
I am using a golang program, that calls a Go library api-> net.DialUDP(which invokes system call connect).
Inside golang's net.DialUDP function, after call to connect system call, they call getsockname to retreive
the client end-points IP-address:port-number, and store it in their handle(as LocalAddress).
When go application code retrieves LocalAddress, it is NOT getting the correct address/port.
Steps to reproduce
Issue reproduced on -> commit fb71e4376a1fa797697832ca5cbd7731dc7f8793
in gramine-project.
If you run the attached go program, you can notice the LocalAddress
retreived by the UDP client is same as RemoteAddress(to which client is connecting to).
Details on how to reproduce are in additional info section below.
Expected results
LocalAddress of client is expected to be different from the server address it is connecting to.
Actual results
LocalAddress of client is same as server address it is connecting to.
From the logs:
Remote UDP address : 127.0.0.1:6000
Local UDP client address : 127.0.0.1:6000
Additional information -->
Attaching zip file, that has the sources to reproduce issue-> go_udp_client.zip
The Go source code is in a sub-folder inside the zip file-> gopro_udp_client/main.go
In graphene repo, under your /home->/graphene/Examples directory, copy this zip file-> , and then unzip it,
to create go_xx directory under /graphene/Examples/go_xx.
Under /graphene/Examples/go_xx$
Run the script -> ./launch_in_graphene_locally.sh
This will build the sample Go program(in a docker container), and then do a graphene-sgx build, and
then it will launch it locally on your host system.
Graphene debug logs, are in the zip file, titled as -> udp_graphene_connect_issue_debug_logs
The text was updated successfully, but these errors were encountered:
Debugged this issue.
When graphene gets a call to getsockname, it does NOT make a system call, instead it returns previously saved value
of socket-address in LibOS socket handle(sock->addr.in.bind) in shim_do_getsockname.
But in this case, the value saved is incorrect(since it is the value of the server address client connected-to, and NOT the address assigned to client by kernel).
When application invokes golang library call-> net.DialUDP-> invokes socket syscall, and then connect system call-> shim_do_connect-> ocall_connect-> sgx_ocall_connect.
In sgx_ocall_connect, after Untrusted-PAL invokes connect syscall, it invokes getsockname to retrieve the caller's IP-address:port-num, ONLY IF bind-addr parameter is passed to ocall_connect, which is NOT the case in this use-case.
So bind-addr is NOT set to output from getsockname in sgx_ocall_connect, and gets set incorrectly to server's address(that client is connecting to).
Description of the problem
UDP Client does not get the correct address using getsockname.
When UDP client connects to a server address, kernel assigns the IP-address:port-number for
the client's end-point. After call to connect system call, the client IP address:port-number can be retrieved using
getsockname system call.
I am using a golang program, that calls a Go library api-> net.DialUDP(which invokes system call connect).
Inside golang's net.DialUDP function, after call to connect system call, they call getsockname to retreive
the client end-points IP-address:port-number, and store it in their handle(as LocalAddress).
When go application code retrieves LocalAddress, it is NOT getting the correct address/port.
Steps to reproduce
Issue reproduced on -> commit fb71e4376a1fa797697832ca5cbd7731dc7f8793
in gramine-project.
If you run the attached go program, you can notice the LocalAddress
retreived by the UDP client is same as RemoteAddress(to which client is connecting to).
Details on how to reproduce are in additional info section below.
Expected results
LocalAddress of client is expected to be different from the server address it is connecting to.
Actual results
LocalAddress of client is same as server address it is connecting to.
From the logs:
Remote UDP address : 127.0.0.1:6000
Local UDP client address : 127.0.0.1:6000
Additional information -->
Attaching zip file, that has the sources to reproduce issue-> go_udp_client.zip
The Go source code is in a sub-folder inside the zip file-> gopro_udp_client/main.go
In graphene repo, under your /home->/graphene/Examples directory, copy this zip file-> , and then unzip it,
to create go_xx directory under /graphene/Examples/go_xx.
Under /graphene/Examples/go_xx$
Run the script -> ./launch_in_graphene_locally.sh
This will build the sample Go program(in a docker container), and then do a graphene-sgx build, and
then it will launch it locally on your host system.
Graphene debug logs, are in the zip file, titled as -> udp_graphene_connect_issue_debug_logs
The text was updated successfully, but these errors were encountered: