| uftrace를 통해서 user + lib + kernel 호출과정 추적하기

[정리]

1. 주제

- uftrace를 통해 mv 명령의 시스템콜 rename 호출과정을 탐색

2. 전체 내용 요약

1) uftrace record 기능을 사용해 mv 동작시 발생하는 call trace 수집

2) uftrace replay 기능을 사용해 전체 호출 과정 확인

3) mv 동작을 위해 사용되는 rename syscall에 대한 호출 과정 확인 

 

[1) uftrace record 기능을 사용해 mv 동작시 발생하는 call trace 수집]

$ touch file # mv 동작을 하기 위한 file을 생성
$ sudo uftrace record --force -K 5 /bin/mv file file-mv # file에 대해 file-mv로 이름 변경

uftrace record 동작 수행시 trace 관련 파일들이 uftrace.data 경로에 생성됨

 

[2) uftrace replay 기능을 사용해 전체 호출 과정 확인]

해당 trace 파일들을 이용해 reaplay 수행을 하기 위해선 아래 명령어를 수행 해야 함

기타 옵션들이 추가적으로 많이 존재함 ex) function filtering, time resolution

tracing 과정에서 다른 함수들도 포함될 수 있으며, 시간 값 조절 및 filtering을 통해 원하는 함수의 내용을 추출 할 수 있음

$ uftrace replay -t 2ms

함수 콜 내용을 보면 application (/bin/mv)에서 rename을 호출하고 rename은 system call, vfs call 등...을 수행해 결국 file의 이름을 변경 함

 

[3) mv 동작을 위해 사용되는 rename syscall에 대한 호출 과정 확인]

/bin/mv는 여러가지 .so 파일들이 연결되어 있으며 이를 ldd(List Dynamic Dependencies)를 통해 확인 가능함

rename syscall 또한 연결된 .so 파일 중 하나 (libc.so.6)에 존재함

$ ldd /bin/mv

연결된 library 중 libc.so.6 내에서 rename이 구현된 것을 확인

$ objdump -d /lib/x86_64-linux-gnu/libc.so.6 | less
less 화면 상에서 rename 탐색

/bin/mv는 libc.so.6내 존재하는 rename을 호출하며, libc.so.6내 존재하는 rename은 위의 disassemble코드내 두번째 줄에 작성된 것 처럼 syscall을 호출함

system call table내 존재하는 vector table을 존재하기 위해 nr 값이 필요하며, 이 nr 값은 여기에서 보이는 0x52 값임

nr = 0x52 = 82, 82에 위치한 vector table을 접근해 syscall을 수행함

$ vim /usr/include/x86_64-linux-gnu/asm/unistd_64.h

Syscall이 호출되는 되는 과정에 대해 살펴 보자

$ vim ${linux}/arch/x86/entry/entry_64.S

x86_64 CPU이며, 175번째 위치한 do_syscall_64를 호출함으로써 system call을 호출하게 됨

$ vim ${linux}/arch/x86/entry/common.c

do_syscall_64가 호출되어 common.c::do_syscall_64를 호출하며, sys_call_table[nr]을 통해 table을 호출하게 됨

앞에서 언급했던 rename의 nr은 0x52 = 82이며, sys_call_table[82]에 rename 함수 포인터가 세팅되어 있음

 

rename 정의를 쉽게 찾기 위해 아래 명령을 수행

$ ag SYSCALL_DEFINE | grep rename

fs/namei.c:4671에 rename에 대한 syscall이 정의 되어 있으며, 확인 하면 아래와 같으며, do_renameat2()에서 vfs_rename을 호출하게 됨

vfs_rename 내에선 error = old_dir->i_op->rename() 부분에서 file system의 rename call을 수행하게 되고 ext4와 연결됨

 

링크: https://careers.ibm.com/ko/job-details-ko/13459938/linux-kernel-development-engineer-bangalore-in/

Linux Kernel Development Engineer Job in Bangalore, Karnataka | IBM

IBM has a career opportunity for a Linux Kernel Development Engineer in Bangalore, Karnataka

careers.ibm.com


Introduction
The IBM Linux Technology Centre is hiring for our Linux Kernel Development team. As an experienced professional in this field, you bring an understanding of computer architecture and operating system concepts across processor architectures. Design and develop advanced features in the Linux kernel for the next generation server platforms from IBM in collaboration with the Linux community. The areas of development spreads across scheduler, memory management, virtualization, container infrastructure, tracing (e.g. eBPF) and other subsystems of interest in the Linux kernel. This opportunity gets you involved in all the phases of software development and work with a vibrant, reputed and technically accomplished team focusing on open source development.

Your Role and Responsibilities
As a Linux kernel Developer, you possess strong analysis and problem-solving skills. You deliver responsive and efficient solutions involving Linux that enables new Power servers coming to market. You develop and maintain a selected subset(s) of the core kernel infrastructures, across upstream community and major Linux distributions. You collaborate with teams across the hardware, firmware and upstream Linux kernel community to deliver these capabilities. You will analyze system requirements, coordinate feature design and development with other teams.
Responsibilities:

Design and development of features in core Linux Kernel and related user space application, utilities and packages.

Work both with Linux Kernel upstream, as well as internal teams across the hardware and firmware stack to develop and maintain kernel capabilities.

Perform technical analysis of problems and errors in the Linux Kernel.

Review code, build unit tests, and write detailed documentation.

Actively participate in professional organizations and specialized conferences related to your area of work


Required Technical and Professional Expertise

3 to 10+ years of experience in IT Industry

Solid knowledge of the C programming language

Expertise in Linux Kernel internals and implementation principles

In-depth understanding of operating systems concepts, data structures, processor architecture, and virtualization

Solid understanding and experience with the Linux kernel and related upstream development workflow

Experience with working on open source software using tools such git and associated community participation processes.


Preferred Technical and Professional Expertise

Accuracy and thoroughness

Consideration and assertiveness


링크: https://recruit.navercloudcorp.com/navercloud/job/detail/developer?annoId=20005373&classId=&jobId=&entTypeCd=&searchTxt= 

 

링크: https://www.linkedin.com/jobs/view/2431578514

Basic Qualifications

  • Bachelor's degree in Computer Science, Electrical Engineering or a similar field.
  • 1+ years of professional software development experience.
  • Computer Science fundamentals in data structures, algorithm design, problem solving, and complexity analysis
  • Knowledge of professional software engineering best practices for the full software development life cycle, including code reviews, source control management, build processes, testing, and operations.
  • Open to learn low level programming in the virtualization space

Preferred Qualifications

  • Master’s degree in any of the related field.
  • Experience in programming languages like C, C++, bash script and python.
  • Basic understanding of performance critical areas of the Linux Kernel.

Pandas_Cheat_Sheet.pdf
0.33MB

* 실습코드: https://github.com/corazzon/cracking-the-pandas-cheat-sheet

* Pandas Cheet Sheet: https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf

* 판다스 10분 완성 (원문): https://pandas.pydata.org/pandas-docs/stable/user_guide/10min.html

* 판다스 10분 완성 (한글):  https://dataitgirls2.github.io/10minutes2pandas/



출처: https://doitnow-man.tistory.com/102 [즐거운인생 (실패 또하나의 성공)]

+ Recent posts