entry.S에 대한 질문

newold의 이미지

시스템 콜이 일어나기 전과 시스템 콜이 발생한 후에 각각 시스템콜에 대한 정보를 가져와서 로그를 남기는 프로그램을 짜고 싶은데요.
아무래도 모든 시스템 콜이 발생하기 전과 후에 정보를 얻어올려면 entry.S(어셈코드)에서 어떻게 해야할것 같은데 그 위치와 방법을 모르겠네요.
대충 코드를 봐서는 293번 라인에서 sys_call_table(,%eax,4)와 같은 방법으로 시스템 콜 테이블에서 해당 시스템 콜에대한 주소를 가져와 처리 되므로 그부분 앞에서 시스템 호출이 일어나기 전에 시스템 호츨에 대한 정보를 얻을수 있을것같은데,
문제는 이 부분에서 어떤 식으로 해야할지 모르겠네요??? ㅜㅜ

그리고 시스템 호출이 일어난 후에 시스템 호출에 대한 결과값들도 따로 로그를 남기고 싶은데 ....

283 ENTRY(system_call)
284         pushl %eax                      # save orig_eax
285         SAVE_ALL
286         GET_THREAD_INFO(%ebp)
287         cmpl $(nr_syscalls), %eax
288         jae syscall_badsys
289                                         # system call tracing in operation
290         testb $_TIF_SYSCALL_TRACE,TI_FLAGS(%ebp)
291         jnz syscall_trace_entry
292 syscall_call:
293         call *sys_call_table(,%eax,4)
294         movl %eax,EAX(%esp)             # store the return value
295 syscall_exit:
296         cli                             # make sure we don't miss an interrupt
297                                         # setting need_resched or sigpending
298                                         # between sampling and the iret
299         movl TI_FLAGS(%ebp), %ecx
300         testw $_TIF_ALLWORK_MASK, %cx   # current->work
301         jne syscall_exit_work

어떤 식으로 정보르 얻어와서 로깅할 수 있을지 잘 모르겠네요..

charsyam의 이미지

원래 커널에 영향을 주지 않는 방법으로 System_call 을 훅하시길 바랍니다.
sys_call_table 이던가요 이것을 가져와서 자신이 원하는 함수로 바꿔주고
거기서 원래의 sys_call 을 해주면, 리턴값 같은것도 기록할 수 있겠죠. 뭐
그런데, 조금 무식한 방법처럼 보이기도 하네요 ^^, 각각의 함수를 다 만들어
줘야 하니 ^^ 그럼 고운 하루되세요.

newold wrote:
시스템 콜이 일어나기 전과 시스템 콜이 발생한 후에 각각 시스템콜에 대한 정보를 가져와서 로그를 남기는 프로그램을 짜고 싶은데요.
아무래도 모든 시스템 콜이 발생하기 전과 후에 정보를 얻어올려면 entry.S(어셈코드)에서 어떻게 해야할것 같은데 그 위치와 방법을 모르겠네요.
대충 코드를 봐서는 293번 라인에서 sys_call_table(,%eax,4)와 같은 방법으로 시스템 콜 테이블에서 해당 시스템 콜에대한 주소를 가져와 처리 되므로 그부분 앞에서 시스템 호출이 일어나기 전에 시스템 호츨에 대한 정보를 얻을수 있을것같은데,
문제는 이 부분에서 어떤 식으로 해야할지 모르겠네요??? ㅜㅜ

그리고 시스템 호출이 일어난 후에 시스템 호출에 대한 결과값들도 따로 로그를 남기고 싶은데 ....

283 ENTRY(system_call)
284         pushl %eax                      # save orig_eax
285         SAVE_ALL
286         GET_THREAD_INFO(%ebp)
287         cmpl $(nr_syscalls), %eax
288         jae syscall_badsys
289                                         # system call tracing in operation
290         testb $_TIF_SYSCALL_TRACE,TI_FLAGS(%ebp)
291         jnz syscall_trace_entry
292 syscall_call:
293         call *sys_call_table(,%eax,4)
294         movl %eax,EAX(%esp)             # store the return value
295 syscall_exit:
296         cli                             # make sure we don't miss an interrupt
297                                         # setting need_resched or sigpending
298                                         # between sampling and the iret
299         movl TI_FLAGS(%ebp), %ecx
300         testw $_TIF_ALLWORK_MASK, %cx   # current->work
301         jne syscall_exit_work

어떤 식으로 정보르 얻어와서 로깅할 수 있을지 잘 모르겠네요..

=========================
CharSyam ^^ --- 고운 하루
=========================

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.