monzo / aws-nitro-util

Utilities to reproducibly build images for AWS Nitro Enclaves
MIT License
24 stars 3 forks source link

Default golang based init does not work #22

Closed roshanr95 closed 1 month ago

roshanr95 commented 1 month ago

I tried running the hello world example with the default golang based init in the repo. It fails with

launched cmd=/bin/hello
A NULL argv[0] was passed through an exec system call.
child exited by signal
reaped all children, returned with signal=signal 134

Haven't really tried to debug it since I'm not sure how to make changes that work with nix :sweat_smile: but I think it comes from https://github.com/monzo/aws-nitro-util/blob/master/init/init.go#L371. argv[0] should contain the name of the program which I don't think it does currently. Making it cmd[0:] instead of cmd[1:] might help.

It works fine using AWS's init btw, so something wrong with the golang init for sure unless I'm missing something. I used the below snippet derived from the examples to use AWS's init.

            init = pkgs.stdenv.mkDerivation {
                name = "eif-init";
                src = (pkgs.fetchFromGitHub {
                owner = "aws";
                repo = "aws-nitro-enclaves-sdk-bootstrap";
                rev = "746ec5d";
                sha256 = "sha256-KtO/pNYI5uvXrVYZszES6Z0ShkDgORulMxBWWoiA+tg=";
                }) + "/init"; # we just need the subfolder of this repo

                nativeBuildInputs = [ pkgs.glibc.static ];
                buildPhase = "make";
                installPhase = "cp -r ./init $out";
            };
Cottand commented 1 month ago

hey @roshanr95 you are correct, in ForkExec the second argument should include all args including argv0. Putting a PR together now. Thanks for catching this! We did not get the error you got when using the go-based init.