Judger icon indicating copy to clipboard operation
Judger copied to clipboard

关于uid和gid的问题

Open Zeng1998 opened this issue 4 years ago • 8 comments

编译之后我尝试在命令行下执行

sudo ./Judger --max_cpu_time=1000 --max_real_time=2000 --max_memory=134217728 --max_process_number=200 --ax_output_size=10000 --max_stack=33554432 --exe_path="../demo/main" --input_path="../demo/1.in" --output_path="../demo/1.out" --error_path="../demo/1.out" --log_path="judger.log" --seccomp_rule_name="c_cpp" --uid=1000 --gid=1000

uid和gid设置为当前系统的用户,结果返回系统错误

{
    "cpu_time": 1,
    "real_time": 114,
    "memory": 2158592,
    "signal": 31,
    "exit_code": 0,
    "error": 0,
    "result": 4
}

然后我又试了其他的uid和gid,发现除了当前用户(1000),其他都可以正常执行,包括随便一个uid,系统里不存在的用户也可以?,这是什么原理呢?

Zeng1998 avatar Sep 15 '20 02:09 Zeng1998

result 4 是 runtime error 吧,signal 31 是被 seccomp 干掉了,看下 dmesg -T 找找相关日志看下是哪个 syscall。

virusdefender avatar Sep 15 '20 03:09 virusdefender

result 4 是 runtime error 吧,signal 31 是被 seccomp 干掉了,看下 dmesg -T 找找相关日志看下是哪个 syscall。

看了下syscall是4,不懂orz

Zeng1998 avatar Sep 15 '20 05:09 Zeng1998

[一 9月 14 11:06:16 2020] Judger[19946]: segfault at 0 ip 00007f066ea1b811 sp 00007ffdd8829c18 error 4 in libc-2.27.so[7f066e88d000+1e7000] [一 9月 14 11:06:16 2020] Code: 2e 0f 1f 84 00 00 00 00 00 31 c0 c5 f8 77 c3 66 2e 0f 1f 84 00 00 00 00 00 89 f9 48 89 fa c5 f9 ef c0 83 e1 3f 83 f9 20 77 1f fd 74 0f c5 fd d7 c1 85 c0 0f 85 df 00 00 00 48 83 c7 20 83 e1 [一 9月 14 11:06:35 2020] Judger[20180]: segfault at 0 ip 00007f04bc279811 sp 00007ffc71521a18 error 4 in libc-2.27.so[7f04bc0eb000+1e7000] [一 9月 14 11:06:35 2020] Code: 2e 0f 1f 84 00 00 00 00 00 31 c0 c5 f8 77 c3 66 2e 0f 1f 84 00 00 00 00 00 89 f9 48 89 fa c5 f9 ef c0 83 e1 3f 83 f9 20 77 1f fd 74 0f c5 fd d7 c1 85 c0 0f 85 df 00 00 00 48 83 c7 20 83 e1 [一 9月 14 11:16:48 2020] Judger[26145]: segfault at 0 ip 00007fc3d3d68811 sp 00007ffc68f3a9a8 error 4 in libc-2.27.so[7fc3d3bda000+1e7000] [一 9月 14 11:16:48 2020] Code: 2e 0f 1f 84 00 00 00 00 00 31 c0 c5 f8 77 c3 66 2e 0f 1f 84 00 00 00 00 00 89 f9 48 89 fa c5 f9 ef c0 83 e1 3f 83 f9 20 77 1f fd 74 0f c5 fd d7 c1 85 c0 0f 85 df 00 00 00 48 83 c7 20 83 e1

dmesg -T执行后,里面有几个错误。。。系统是ubuntu18.04

Zeng1998 avatar Sep 15 '20 06:09 Zeng1998

你运行的 demo 咋写的,是那个崩了?

virusdefender avatar Sep 15 '20 06:09 virusdefender

你运行的 demo 咋写的,是那个崩了?

#include <stdio.h>
int main(int argc, char *argv[]) {
    char input[1000];
    scanf("%s", input);
    printf("Hello %s\n", input);
    return 0;
}

还是这个代码,我先手动编译,然后命令行跑,uid设置成其他的都可以,唯独我当前用户 (1000)就不行

Zeng1998 avatar Sep 15 '20 07:09 Zeng1998

然后发现 不加max_process_number这个参数,或者改为默认的-1,或者改成2000以上 就不出问题了。。。

Zeng1998 avatar Sep 15 '20 09:09 Zeng1998

demo.py 怎么跑起来,我的报错了 Traceback (most recent call last): File "demo.py", line 26, in <module> gid=0) ValueError: Invalid args and kwargs

bennetty74 avatar Mar 30 '21 07:03 bennetty74

然后发现 不加max_process_number这个参数,或者改为默认的-1,或者改成2000以上 就不出问题了。。。

我也遇到这个问题了,但是不加这个max_process_number参数还是会出现同样的错误,改成-1或者2000以上都不能解决问题。

realize-me avatar Apr 05 '21 14:04 realize-me