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

/dev/fd/ support #1267

Closed
TejaswineeL opened this issue Apr 4, 2023 · 7 comments · Fixed by #1873
Closed

/dev/fd/ support #1267

TejaswineeL opened this issue Apr 4, 2023 · 7 comments · Fixed by #1873

Comments

@TejaswineeL
Copy link
Contributor

Description of the problem

I am getting below error in gramine when trying to execute process substitution with gramine. Named pipe file /dev/fd/63 is not getting detetcted by gramine:

diff: /dev/fd/63: No such file or directory

Process substitution is a form of inter-process communication that allows the input or output of a command to appear as a file. This allows programs that normally only accept files to directly read from or write to another program.
Reference: https://en.wikipedia.org/wiki/Process_substitution

Steps to reproduce

gramine 1.4

  1. Navigate to CI-Examples/bash
  2. Create 2 dummpy text files (here file1 and file2)
  3. Run the command gramine-direct bash -c 'diff file2 <(sort file1)'

(Here, result of sort file1 is stored to named pipe file /dev/fd/63. Now this run time generated (named pipe) file acts as argument for diff command
so the given command becomes diff file2 /dev/fd/63)

Expected results

we should see the unmatched(uncommon) text out of the 2 files (as diff stands for differenciation)

Actual results

diff: /dev/fd/63: No such file or directory
process_substitution_failure_log.txt

Gramine commit hash

gramine 1.4-aefd5d0875c4fdf76edd67f5043952bdd32b0f7a

@mkow
Copy link
Member

mkow commented Apr 4, 2023

This doesn't work because bash is using /dev/fd/ which isn't implemented at all in Gramine.

@dimakuv
Copy link
Contributor

dimakuv commented Apr 4, 2023

This doesn't work because bash is using /dev/fd/ which isn't implemented at all in Gramine.

Which is actually bad. I think we need to implement these pseudo-dirs to operate on FDs sooner than later...

@mkow
Copy link
Member

mkow commented Apr 4, 2023

Should be easy, we already have them in /proc/self/fd/.

@mkow mkow changed the title Named Pipe file is not found during process substitution by gramine /dev/fd/ support Apr 9, 2023
@kailun-qin
Copy link
Contributor

Should be easy, we already have them in /proc/self/fd/.

There's currently no dentry associated w/ the paths of the pipes created during this process substitution. So even if we have /dev/fd/ (linking to /proc/self/fd/), I guess we may not be able to enable this exmple (gramine-xxx bash -c 'diff file2 <(sort file1)') which can be implemented via e.g., stat() underneath.

@mkow
Copy link
Member

mkow commented Apr 13, 2023

There's currently no dentry associated w/ the paths of the pipes created during this process substitution

First, let's switch to Linux-level terms, "process substitution" is a Bash-specific feature ;) So, you're talking here about support for named pipes? (I think we support them?) Or that we don't create /proc/self/fd/ entry after creation of anonymous pipes? (pipe())

can be implemented via e.g., stat() underneath

Not sure what do you mean here.

@kailun-qin
Copy link
Contributor

Or that we don't create /proc/self/fd/ entry after creation of anonymous pipes? (pipe())

Yes, this is what I meant. I.e., if we do a stat() on /proc/self/fd/xxx right after pipe(), I don't think stat() will succeed. Since the example may have similar flows, it might not work.

@mkow
Copy link
Member

mkow commented Apr 13, 2023

Hmm, it seem to work only partially, we create an entry there, but without a proper dentry. I guess we'd need to add it to make it functional: (this is under gramine-direct)

bash-5.0# ls -la <(echo 123) /proc/self/fd/63
ls: cannot access '/dev/fd/63': No such file or directory
ls: /proc/self/fd/63: Function not implemented
lrwxrwxrwx 1 0 0 0 Jan  1  1970 /proc/self/fd/63 -> pipe:[?]

bash-5.0# cat <(echo 123) /proc/self/fd/63
cat: /dev/fd/63: No such file or directory
cat: /proc/self/fd/63: No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants