Skip to content

Log syscalls that are handled in the shim#2646

Merged
stevenengler merged 5 commits intoshadow:mainfrom
stevenengler:strace-in-shim
Jan 9, 2023
Merged

Log syscalls that are handled in the shim#2646
stevenengler merged 5 commits intoshadow:mainfrom
stevenengler:strace-in-shim

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

Examples of shim-handled syscalls:

00:10:00.301000001 [tid 1000] epoll_wait(...) = 1
00:10:00.301000001 [tid 1000] read(7, 0x7ffffffee6d0, 65536) = 1460
000000600301000001 [tid 1000] clock_gettime(...) = 0
00:10:00.301000001 [tid 1000] epoll_wait(...) = 1
00:10:00.301000001 [tid 1000] epoll_wait(...) = 1
00:10:00.301000001 [tid 1000] read(7, 0x7ffffffee6d0, 65536) = 1460
000000600301000001 [tid 1000] clock_gettime(...) = 0
00:10:00.301000001 [tid 1000] epoll_wait(...) = 1
00:10:00.301000001 [tid 1000] epoll_wait(...) = 1
00:10:00.301000001 [tid 1000] read(7, 0x7ffffffee6d0, 65536) = 1460
000000600301000001 [tid 1000] clock_gettime(...) = 0
00:10:00.301000001 [tid 1000] epoll_wait(...) = 1
00:10:00.301000001 [tid 1000] epoll_wait(...) = 1

Examples of native syscalls:

00:10:00.000000000 [tid 1000] munmap(0x7ffff7ffb000, 118) = 0
000000600000000000 [tid 1000] gettimeofday(...) = 0
00:10:00.000000000 [tid 1000] access(...) = <native>
000000600000000000 [tid 1000] ^^^ = 0
00:10:00.000000000 [tid 1000] access(...) = <native>
000000600000000000 [tid 1000] ^^^ = 0
00:10:00.000000000 [tid 1000] openat(-100, "../../../conf/tgen.client.graphml.xml", O_LARGEFILE | O_RDONLY, (empty)) = 3
00:10:00.000000000 [tid 1000] readlink(...) = <native>
000000600000000000 [tid 1000] ^^^ = 27

The time isn't formatted properly in these log lines, but I'll leave that for a future PR.

@stevenengler stevenengler self-assigned this Jan 6, 2023
@stevenengler stevenengler marked this pull request as ready for review January 6, 2023 22:56
@github-actions github-actions bot added Component: Documentation In-repository documentation, under docs/ Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable labels Jan 6, 2023
@stevenengler stevenengler requested review from sporksmith and removed request for sporksmith January 6, 2023 23:01
@stevenengler
Copy link
Copy Markdown
Contributor Author

stevenengler commented Jan 7, 2023

I think the failed tests are because I'm calling dprintf() from the shim, but we should only be calling async-signal safe functions (which dprintf isn't). I think the best solution might be a rust function which does the formatting and writing to the fd.

Edit: I just formatted to a temporary buffer in C and called write() instead.

Edit 2: The goland preemption test was timing out because it makes a lot of syscalls in a busy loop.

Edit 3: @sporksmith Since the shim's vdso just makes the syscall, this patch will log vdso time calls as syscalls. I think this doesn't hurt at all, but wanted to mention it here in case you think we shouldn't log these vdso calls in the strace log. The normal strace tool wouldn't log these, but we don't need to follow the strace tool.

@stevenengler stevenengler force-pushed the strace-in-shim branch 2 times, most recently from 889a020 to 9321500 Compare January 7, 2023 01:28
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 7, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@920e066). Click here to learn what that means.
Patch coverage: 80.00% of modified lines in pull request are covered.

❗ Current head 4afdeee differs from pull request most recent head 09f2155. Consider uploading reports for the commit 09f2155 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2646   +/-   ##
=======================================
  Coverage        ?   67.34%           
=======================================
  Files           ?      202           
  Lines           ?    29920           
  Branches        ?     5827           
=======================================
  Hits            ?    20150           
  Misses          ?     5180           
  Partials        ?     4590           
Flag Coverage Δ
tests 67.34% <80.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/lib/shadow-shim-helper-rs/src/lib.rs 75.00% <ø> (ø)
src/lib/shim/shim_syscall.c 78.91% <68.18%> (ø)
src/lib/shim/shim_sys.c 73.45% <70.37%> (ø)
src/lib/shadow-shim-helper-rs/src/option.rs 81.81% <81.81%> (ø)
src/lib/shadow-shim-helper-rs/src/shim_shmem.rs 76.82% <100.00%> (ø)
src/main/host/process.rs 84.18% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions github-actions bot added Component: Build Build/install tools and dependencies Component: Testing Unit and integration tests and frameworks labels Jan 7, 2023
@stevenengler stevenengler force-pushed the strace-in-shim branch 2 times, most recently from e3874d5 to 9457701 Compare January 7, 2023 02:43
@sporksmith
Copy link
Copy Markdown
Contributor

Edit 3: @sporksmith Since the shim's vdso just makes the syscall, this patch will log vdso time calls as syscalls. I think this doesn't hurt at all, but wanted to mention it here in case you think we shouldn't log these vdso calls in the strace log. The normal strace tool wouldn't log these, but we don't need to follow the strace tool.

Yeah, I think logging them is probably what we want.

@stevenengler stevenengler enabled auto-merge January 9, 2023 19:21
@stevenengler stevenengler merged commit 96b472d into shadow:main Jan 9, 2023
@stevenengler stevenengler deleted the strace-in-shim branch January 9, 2023 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Build Build/install tools and dependencies Component: Documentation In-repository documentation, under docs/ Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable Component: Testing Unit and integration tests and frameworks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants