Kernel exploit - task란

2023. 8. 6. 13:33·Kernel Exploit
728x90
반응형

Task란?

다소 검색을 해봤는데 그 의미가 모호한 것 같다.

태스크를 태스크라고도 하고, 스레드라고도하고 프로세스라고 표현한다고 하는데...

지금 공부하고 있는 시점에서는 크게 중요하지 않은 것 같다.

결국은 태스크는 작업 실행 단위를 이야기한다.

 

task_struct란?

결국 모든 태스크들은 task_struct 구조체를 통해 관리하게 된다.

태스크 또는 스레드가 생성되면 do_fork()라는 커널 함수를 거치면서 이 task_struct를 생성하는데,

이 때 권한이나 주소 등을 task_struct 구조체에 넣어두게 된다.

 

즉, fork(), vfork(), pthread_create() 등의 함수를 어플리케이션에서 실행하면 라이브러리에서 해당 함수를 찾아 실행하며,

라이브러리에서는 다시 clone(), vfork() 등의 시스템콜을 하며,

커널에서는 sys_clone(), sys_vfork(), sys_fork()를 실행하고

결론적으로 do_fork() 함수를 실행하게 되며, 해당 함수 내에서 task_struct를 생성한다.

 

task_struct의 구조

모두 다 설명하고 이해하려면 너무 많으니, 중요한 부분만 보자.

아래는 전체 코드이다.

cs.fsu.edu/~baker/opsys/examples/task_struct.html

 

https://www.cs.fsu.edu/~baker/opsys/examples/task_struct.html

 

www.cs.fsu.edu

 

struct mm_struct *mm

해당 부분이 위에서 이야기한 각 주소를 관리하는 영역이다.

이 구조체 내에서 stack, heap, bss, code 등의 영역을 관리한다.

아래 소스코드를 참고하자.

mm_types.h - include/linux/mm_types.h - Linux source code (v6.4.8) - Bootlin

 

mm_types.h - include/linux/mm_types.h - Linux source code (v6.4.8) - Bootlin

/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _LINUX_MM_TYPES_H #define _LINUX_MM_TYPES_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef AT_V

elixir.bootlin.com

 

struct cred

권한을 관리하는 구조체로 kernel exploit에서 가장 중요한 부분이지 않나 싶다.

통상적으로 id가 0이면 root이며, kernel exploit에서는 이 부분을 0으로 만드는 것을 목표로 한다.

cred.h - include/linux/cred.h - Linux source code (v6.4.8) - Bootlin

 

cred.h - include/linux/cred.h - Linux source code (v6.4.8) - Bootlin

/* SPDX-License-Identifier: GPL-2.0-or-later */ /* Credentials management - see Documentation/security/credentials.rst * * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) */ #ifndef _LINUX_CRED_H #defi

elixir.bootlin.com

 

728x90
반응형
저작자표시 비영리 변경금지 (새창열림)

'Kernel Exploit' 카테고리의 다른 글

Kernel exploit - 모듈 프로그래밍  (0) 2023.08.06
Kernel exploit - 디바이스 드라이버  (0) 2023.08.06
Kernel exploit - 슬랩 할당자  (0) 2023.08.06
Kernel exploit - 커널이란  (0) 2023.08.05
Kernel exploit - 들어가며.  (0) 2023.08.05
'Kernel Exploit' 카테고리의 다른 글
  • Kernel exploit - 디바이스 드라이버
  • Kernel exploit - 슬랩 할당자
  • Kernel exploit - 커널이란
  • Kernel exploit - 들어가며.
wyv3rn
wyv3rn
아저씨의 흔한 취미. wyv3rn#1249
  • wyv3rn
    think storage
    wyv3rn
  • 전체
    오늘
    어제
    • 분류 전체보기 (559)
      • To do list (0)
        • Doing (1)
        • Complete (6)
      • Diary (37)
      • Tips & theory (77)
      • Kernel Exploit (28)
        • Theory (16)
        • Exercise (5)
      • File Structure (6)
      • Wargame (352)
        • Dreamhack (183)
        • pwn.college (37)
        • pwnable.tw (0)
        • pwnable.kr (15)
        • Lord of Sqlinjection (4)
        • Cryptohack (20)
        • Root me (27)
        • CodeEngn (4)
        • Exploit Education (22)
        • ROP Emporium (8)
        • H4C (10)
        • Hackerchool (22)
      • CTF (50)
        • Solved (48)
        • Unsolved (2)
      • Script (0)
      • RubiyaLap (0)
  • 블로그 메뉴

    • 홈
    • 방명록
  • 링크

  • 공지사항

    • PWN wargame 모음 (및 느낀점)
    • 비공개 글들에 대해.
    • 뭐라도 하나 얻어가시길...
  • 인기 글

  • 태그

    rop
    BOF
    x86
    Buffer Overflow
    Format String Bug
    docker
    ROOT ME
    la ctf
    root-me
    FSB
    tcache
    cryptohack
    Me
    dreamhack
    pwntools
    64bit
    heap
    lob
    _IO_FILE
    RTL
    libc
    exploit education
    x64
    hackerschool
    CANARY
    root
    phoenix
    vtable
    32bit
    pwnable.kr
  • 최근 댓글

  • 최근 글

  • 250x250
    반응형
  • hELLO· Designed By정상우.v4.10.3
wyv3rn
Kernel exploit - task란
상단으로

티스토리툴바