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

undeclared identifier during make : PR_SET_MM_ARG_START, PR_SET_MM_ARG_END #1

Open
won0c opened this issue Dec 16, 2018 · 11 comments
Open
Labels
Enhancement Enhance on existing features Status: Future This will be fixed or implemented in the future...

Comments

@won0c
Copy link

won0c commented Dec 16, 2018

cmake ..

-- build type not set, default to release
Build Type: Release
-- Checking for module 'libseccomp'
-- Found libseccomp, version 1.0.1
-- Found Criterion library.
-- Test Enabled.
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/cjail-master/build

make

[ 3%] Building C object src/CMakeFiles/libcjail.dir/init.c.o
/usr/cjail-master/src/init.c: In function ‘setprocname’:
/usr/cjail-master/src/init.c:94:32: error: ‘PR_SET_MM_ARG_START’ undeclared (first use in this function)
ret = prctl(PR_SET_MM, PR_SET_MM_ARG_START, argv, 0, 0) ||
^
/usr/cjail-master/src/init.c:94:32: note: each undeclared identifier is reported only once for each function it appears in
/usr/cjail-master/src/init.c:95:30: error: ‘PR_SET_MM_ARG_END’ undeclared (first use in this function)
prctl(PR_SET_MM, PR_SET_MM_ARG_END, argv + strlen(argv) + 1, 0, 0);
^
/usr/cjail-master/src/init.c: In function ‘child_init’:
/usr/cjail-master/src/init.c:385:9: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(ep.resultpipe[1], &result, sizeof(result));
^
make[2]: *** [src/CMakeFiles/libcjail.dir/init.c.o] error 1
make[1]: *** [src/CMakeFiles/libcjail.dir/all] error 2
make: *** [all] error 2

please, your solution...

I don't know why these error ocuur.
my linux kernel version: 3.13.0-117-generic
libseccomp version : 1.0.1

@Leo1003
Copy link
Owner

Leo1003 commented Dec 16, 2018

The macros should be defined in <sys/prctl.h> with kernel version above 3.5, but actually, the header file is belonged to glibc. So I think maybe your glibc version is too old.
Actually, this project is still under development, I am still trying to figure out the minimal kernel version can compile the program and add some configs to turn off the optional features.
If you want to try it, you can try it on a newer linux version (4 or above) to make sure you can compile it without error.
Or try to add these codes at the begining of the source

#ifndef PR_SET_MM_ARG_START
    #define PR_SET_MM_ARG_START		 8
#endif
#ifndef PR_SET_MM_ARG_END
    #define PR_SET_MM_ARG_END		 9
#endif

@Leo1003 Leo1003 added Enhancement Enhance on existing features Status: Future This will be fixed or implemented in the future... labels Dec 16, 2018
@won0c
Copy link
Author

won0c commented Dec 16, 2018

thanks. these errors are solved. but....

[ 17%] Building C object src/CMakeFiles/libcjail.dir/simple_seccomp.c.o
/usr/cjail-master/src/simple_seccomp.c:12:25: fatal error: linux/memfd.h: No such file or directory
compilation terminated.

I think I don't have enough library.. right?

@Leo1003
Copy link
Owner

Leo1003 commented Dec 17, 2018

It seems that memfd_create() is added in glibc 2.27 and require kernel version 3.17.
I think I need to update the dependencies list in README again.

@won0c
Copy link
Author

won0c commented Dec 24, 2018

I have completed the 'make' process with no errors on Ubuntu 18.04.
What do I have to do next? It seems that the next step is installation. but I don't know how to install.

Please let me know the next step in detail..

@won0c
Copy link
Author

won0c commented Dec 24, 2018

I have these errors as follows during installation

make install

[ 53%] Built target libcjail
[ 60%] Built target cjail
[ 67%] Built target utils_test
[ 75%] Built target scconfig_parser_test
[ 82%] Built target basic_test
[ 89%] Built target timing_test
[100%] Built target cjail_static_test
Install the project...
-- Install configuration: "Release"
-- Up-to-date: /usr/local/share/cmake/Modules/CJailTargets.cmake
-- Up-to-date: /usr/local/share/cmake/Modules/CJailTargets-release.cmake
-- Up-to-date: /usr/local/share/cmake/Modules/Findlibseccomp.cmake
-- Up-to-date: /usr/local/share/cmake/Modules/CJailConfig.cmake
-- Up-to-date: /usr/local/share/cmake/Modules/CJailConfigVersion.cmake
-- Up-to-date: /usr/local/lib/libcjail.so.0.7.1
-- Up-to-date: /usr/local/lib/libcjail.so.0
-- Up-to-date: /usr/local/lib/libcjail.so
-- Up-to-date: /usr/local/include/cjail.h
CMake Error at src/cmake_install.cmake:73 (file):
file INSTALL cannot find "/cjail-master/src/
/cjail-master/include/scconfig.h".
Call Stack (most recent call first):
cmake_install.cmake:69 (include)

Makefile:128: recipe for target 'install' failed
make: *** [install] Error 1

@Leo1003
Copy link
Owner

Leo1003 commented Dec 24, 2018

Oh, that's my fault. I shouldn't write cmake list strings in multiple lines. Cmake mistakes the newline and indent spaces as a part of the file path. Instead, I should declare a list variable or just place the second header file in the same line.

@Leo1003
Copy link
Owner

Leo1003 commented Dec 24, 2018

I just pushed a hotfix version to fix this issue. And it can be installed successfully now.

@won0c
Copy link
Author

won0c commented Dec 25, 2018

the installation is complete. thanks.

Could you let me know the command usage of cjail in details?
For example, my case is as follows.

I'd like to judge the code that submitted by any user.
The code is written in c, c++, python, java, javascript and will only run in a folder with the user name, and can not access other folders. Only standard I / O is possible, and the I/O file in a specific folder will be redirected to the code(or user program) by the command.

Especially, I'd like to know the case of interpreter language such as python, java, javascript.

thanks in advance.

@Leo1003
Copy link
Owner

Leo1003 commented Dec 25, 2018

Typically, you need to place the code that you want to run in a directory which can be access by the user you specifying. Then compile (if needed) and run it.
Here is an example of compile command:

  • Run with uid 10001 and gid 10001
  • The code is placed at /home/foobar
  • Compile foobar.c
sudo cjail -d /home/foobar -u 10001 -g 10001 -- /bin/gcc foobar.c

And here is an example of running the code:

sudo cjail -d /home/foobar -u 10001 -g 10001 -- ./a.out

By default, it would be run as uid 65534(nobody) and gid 65534(nobody) if you don't specify the -u or -g options.
If you want to limit the resource of the program, you can see the "Resource Limit Options" section in the help. The help of command line interface is also available in the README.

cjail --help

@won0c
Copy link
Author

won0c commented Dec 26, 2018

Thanks a lot.

What are the return values of cjail when a user code is trying to access other directories or to exceed the limit of resource..

@Leo1003
Copy link
Owner

Leo1003 commented Dec 26, 2018

Sorry for that. Currently, It would return 0 even if user code not successfully return when using the command line interface. This is a to-do improvement in the next release.

  • Error of trying to access other directories is handled by the user code, we can never force a user program to be killed unless using ptrace (it will significantly reduce the performance so I am not going to use it).
  • Exceed the limit of resource will cause the user program to be killed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Enhance on existing features Status: Future This will be fixed or implemented in the future...
Projects
None yet
Development

No branches or pull requests

2 participants