vusec / trrespass

TRRespass
Apache License 2.0
119 stars 25 forks source link

Assertion error #4

Open altostratous opened 3 years ago

altostratous commented 3 years ago
(venv) (base) ali@simon:~/Desktop/Code/trrespass/drama$ sudo make run
sudo obj/tester
tester: src/rev-mc.c:94: uint64_t get_phys_addr(uint64_t): Assertion `entry & (1ULL << 63)' failed.
make: *** [Makefile:58: run] Aborted

I'm compiling x86_64 (default build essentials on my system) Seems the read value out of /proc/self/pagemap has not the correct bits set. How can I fix the problem. Little bit of context:

(venv) (base) ali@simon:~/Desktop/Code/trrespass/drama$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
kevinloughlin commented 2 years ago

I ran into the same issue. I resolved it by switching out the implementation of get_phys_addr() with the implementation of virt_to_phys_user() from this post (where I just used "self" for the pid).

bygo7 commented 2 years ago

I ran into the same issue. I resolved it by switching out the implementation of get_phys_addr() with the implementation of virt_to_phys_user() from this post (where I just used "self" for the pid).

@kevinloughlin if sysconf(_SC_PAGE_SIZE) returns 4096, both codes seem to do same works except the virt_to_phys_user() doesn't have the assertion assert(entry & (1ULL << 63)); Does the entire code work well with you?

bygo7 commented 2 years ago

For this problem, insert a code that bypasses the assertion assert(entry & (1ULL << 63)); AND allocating the v_addr code at rev_mc if (entry & (1ULL << 63) == 0 and (entry & (1ULL << 62) == 1), which means the physical address of the virtual address is not located at main memory(DRAM). I don't know why this happens considering that we have already allocated the memory through mmap.

stefan1wan commented 11 months ago

I guess the reason that the physical address of the virtual address in not located at the main memory is due to Lazy binding. Simply access the memory at the begining of get_phys_addr could bypass, like volatile int a = *(int*)v_addr;.