QuarkContainer / Quark

A secure container runtime with CRI/OCI interface
Apache License 2.0
317 stars 47 forks source link

armdev: pagefault with small address that not maped #1113

Closed CharlyYu closed 4 months ago

CharlyYu commented 6 months ago

I still get this pagefault with very address that is apparently not maped. when I execute docker run -ddocker run -d --runtime=quark_d nginx`, I got this

[INFO] [1/43c0180000|0] DFSC/IFSC == 0x5, FAR == 0x70, acces-type fault == r--, during address translation == false.
[INFO] [1/615590] hypecall: 8, paras: 43c019d9e8 0 0 0
[INFO] [1/43c0180000|0] VM: PageFaultHandler - FAR: 0x70, PC: 0x2b6cd70c2cd8,TTBR: 0x43c0401000, is-user: true, error code: 0x24.
[INFO] [1/615707] hypecall: 8, paras: 43c019d3c8 0 0 0
[DEBUG] [1/43c0180000|0] VM: Entered HandleFault.
[INFO] [1/615865] hypecall: 8, paras: 43c019cf78 0 0 0
[INFO] [1/43c0180000|0] sendsignalLocked, signal:SignalInfo { Signo: 11, Errno: 0, Code: 1 }, group:false
[INFO] [1/615972] hypecall: 8, paras: 43c019be78 0 0 0
[INFO] [1/43c0180000|0] sendsignalTimerLocked, signal:SignalInfo { Signo: 11, Errno: 0, Code: 1 }

It is a page fault with the address 0x70, which is too small.

CharlyYu commented 6 months ago

I think it is still some bugs related to libc or dynamic linker, when I execute a rust program build with musl, it is ok.

chl337 commented 6 months ago

@CharlyYu This could be (probably) even related to #1099.

shrik3 commented 6 months ago

@CharlyYu This could be (probably) even related to #1099.

As a temporary workaround, please avoid using sys_clone at all. For example, if the docker image has a shell script as a entrypoint, it will call sys_clone with running the actual program.

Sorry I've been really busy recently and I can't help before Friday.

CharlyYu commented 6 months ago

I think it is not related to sys_clone issue, because my test is like below:

  1. compile this into a executable by gcc -o test-print test-print.c
    
    #include<stdio.h>

int main() {

    puts("hello, arm64!\n");
    return 0;

}

2. docker cp this test-print into container of ubuntu, and commit it as a new image, `docker cp test-print <container-id>:/; docker commit <container-id> ubuntu:println`  
3. run quark container of this image by `docker run --runtime=quark_d  ubuntu:println /test-print`

I can not see the "hello, arm64!" log, and check the /var/log/quark/quark.log I get this error:

[INFO] [1/43c0180000|0] DFSC/IFSC == 0x5, FAR == 0x14C0, acces-type fault == r--, during address translation == false. [INFO] [1/589127] hypecall: 8, paras: 43c019d588 0 0 0 [INFO] [1/43c0180000|0] VM: PageFaultHandler - FAR: 0x14c0, PC: 0x2ac41f9d24dc,TTBR: 0x43c0401000, is-user: true, error code: 0x24. [INFO] [1/589495] hypecall: 8, paras: 43c019d588 0 0 0 [ERROR] [1/43c0180000|0] VM: The map is 3fffffe000-8000000000 rw-p 00000000 00:00 0 a000000000-a000001000 r--p 400052a000 00:00 0 [vvar] a000001000-a000003000 r-xs 400052b000 00:00 0 [vdso] e488c3ab000-e488c3ac000 rwxp 00000000 00:4870d 296717 e488c3bb000-e488c3bc000 rw-p 00000000 00:4870d 296717 e488c3bc000-e488c3bd000 rwxp 00001000 00:4870d 296717 2ac41f9c9000-2ac41f9f3000 r-xp 00000000 00:263aa 156586 2ac41f9f3000-2ac41f9f4000 rwxp 0002a000 00:263aa 156586 2ac41f9f4000-2ac41f9f6000 rw-p 00000000 00:00 0 2ac41f9f6000-2ac41f9f8000 r--p 00000000 00:26086 155782 2ac41fa03000-2ac41fa06000 rw-p 0002a000 00:263aa 156586 2ac41fa06000-2ac41fa07000 rwxp 0002d000 00:263aa 156586 2ac41fa10000-2ac41fb99000 r-xp 00000000 00:263bd 156605 2ac41fb99000-2ac41fba8000 ---p 00189000 00:263bd 156605 2ac41fba8000-2ac41fbac000 r--p 00188000 00:263bd 156605 2ac41fbac000-2ac41fbae000 rw-p 0018c000 00:263bd 156605 2ac41fbae000-2ac41fbba000 rw-p 00000000 00:00 0 7fafefeec000-7faff06ec000 rw-p 00000000 00:00 0 [stack] , fault address is not part of it. [INFO] [1/589613] hypecall: 8, paras: 43c019cf68 0 0 0 [DEBUG] [1/43c0180000|0] VM: Entered HandleFault. [INFO] [1/589792] hypecall: 8, paras: 43c019cb18 0 0 0 [INFO] [1/43c0180000|0] sendsignalLocked, signal:SignalInfo { Signo: 11, Errno: 0, Code: 1 }, group:false [INFO] [1/589904] hypecall: 8, paras: 43c019ba18 0 0 0



This time it is a pagefault of `0x14C0`
CharlyYu commented 6 months ago

I think I have got the reason, MProtect changed the page flag, but I think some flag set is wrong, https://github.com/QuarkContainer/Quark/pull/1131 I will test PR and reopen it again.

shrik3 commented 4 months ago

this should be fixed.