Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

getsockname on AF_UNIX sockets causes a crash #2393

Closed
srcman opened this issue May 24, 2021 · 3 comments · Fixed by gramineproject/gramine#579
Closed

getsockname on AF_UNIX sockets causes a crash #2393

srcman opened this issue May 24, 2021 · 3 comments · Fixed by gramineproject/gramine#579
Assignees

Comments

@srcman
Copy link

srcman commented May 24, 2021

Description of the problem

Using getsockname() or getpeername() on UNIX domain sockets crashes Graphene.

Steps to reproduce

Create a UNIX domain socket with, e.g., socket() or socketpair(), and call getsockname() or getpeername() on the socket.

(A particular situation where this problem occurs is if a UNIX socket object is printed in Python, but this bug is not Python-specific in any way and is reproducible also with C code.)

Tested with Graphene 75962a8 (current master branch).

Expected results

The expected result is that the functions would work also with UNIX domain sockets, ideally perhaps with similar results as Linux produces for different types of UNIX sockets.

Actual results

debug: DkProcessExit: Returning exit code 1 is printed and Graphene exits.

Currently it seems that regardless of the socket type, both shim_do_getsockname() and shim_do_getpeername() call inet_copy_addr(), which seems intended only for AF_INET/AF_INET6 addresses and aborts if given (e.g.) an AF_UNIX socket.

@dimakuv
Copy link

dimakuv commented May 25, 2021

Thanks for reporting this bug!

Currently it seems that regardless of the socket type, both shim_do_getsockname() and shim_do_getpeername() call inet_copy_addr(), which seems intended only for AF_INET/AF_INET6 addresses and aborts if given (e.g.) an AF_UNIX socket.

Yes, I'm pretty sure your analysis is correct. Hopefully we'll find some time soon to fix this bug.

@jkr0103
Copy link
Contributor

jkr0103 commented Aug 20, 2021

Please assign to me

@jkr0103
Copy link
Contributor

jkr0103 commented Sep 7, 2021

@srcman Could you share the sample you are trying to execute with graphene?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants