2013년 8월 11일 일요일

selinux 014 - OM과 AVC

SELINUX에서 Subject 액세스를 요구하는 주체를 말하며, 프로세스다.
메모리에 올라가서 활동하는 애가 요청을 있으니 당연한 정의다.

Subject OM(Obejct Manager)에서 액세스 요청을 하고 OM AVC(Access Vector Cache)에게 권한 Query 한다. AVC Query 답이 있으면 바로 돌려 보내고 답이 없으면 Security Server에서 Policy 읽어 온다.

쿼리 작업에 시간이 소요되어서 캐시를 두었다고 있다. 나중에 성능을 올리려면 캐시를 고쳐서 향상을 바랄수 있겠구먼.

리눅스 보안 모듈 Framework 원래 있던 녀석인데 SELinux 위해 고쳐 졌다. 리눅스 Sub-System안으로 동작하는 파일, 폴더, 소켓, IPC 등의 커널 서비스 훅에 OM 있다. 원래 있던 녀석(LSM) 포팅을 해야 하므로 모델이 나올 마다 해줘야 하는 것이 짜응…

 X-Windows, D-bus messaging (used by the Gnome desktop), PostgreSQL database, Name Service Cache Daemon (nscd), and the GNU / Linux passwd command 등을 위해서도 포팅이 되어져야 한다. 유저단에도 따로 포팅을 하는 거지.

쿠헐… Non SELinux에서 SELinux로의 포팅은 개떡같다는…

그러나 우분투에서 apt-get isntall SELINUX 설치되는 보면
커널에 이미 포함되어 있어 보인다. 커널이 바뀌는 것일 수도 있겠지만.


root@cooler-desktop:~# uname -a
Linux cooler-desktop 2.6.32-24-generic #43-Ubuntu SMP Thu Sep 16 14:58:24 UTC 2010 x86_64 GNU/Linux

아닌 같아 보인다.

root@cooler-desktop:/# whereis selinux
selinux: /etc/selinux.d /etc/selinux /usr/share/selinux /usr/share/man/man8/selinux.8.gz

Selinux 위에 폴더등에서 있는데

root@cooler-desktop:/etc/selinux/default/contexts/files# ls
file_contexts  file_contexts.homedirs  file_contexts.local  media

요기서 file_contexts 찾았다.

1326 /lib64/security/pam_krb5/pam_krb5_storetmp      --      system_u:object_r:pam_exec_t:s0
1327 /usr/libexec/hald-addon-macbookpro-backlight    --      system_u:object_r:hald_mac_exec_t:s0
1328 /usr/share/hal/device-manager/hal-device-manager        --      system_u:object_r:bin_t:s0

.. 1328 라인…

레이블링 폴더별로 했나 싶다.

Labeling chmod rwx, rwx, rwx처럼
SELinux 퍼미션 조절을 알아 먹는 seinfo 값을 저장하는 거다.
a, b, c  파일이 있다면 전부 A로도 있고
A, B, C로도 있고
A(a), B(b,c) 수도 있다.

리눅스가 대부분 파일로 간주하는 때문에 file_context 중요하다.

  1 /.*     system_u:object_r:default_t:s0

첫번째 라인을 보면 / 있는 애들은 기본으로 물고 간다.

U user
R role
T type
인데 te파일이 중요한 처럼, Type enforcement SELINUX 핵심인 녀석이다.

   4 /mnt(/[^/]*)?   -d      system_u:object_r:mnt_t:s0
   5 /lib/.* system_u:object_r:lib_t:s0
   6 /bin/.* system_u:object_r:bin_t:s0
   7 /dev/.* system_u:object_r:device_t:s0
   8 /usr/.* system_u:object_r:usr_t:s0
   9 /var/.* system_u:object_r:var_t:s0
  10 /etc/.* system_u:object_r:etc_t:s0
  11 /opt/.* system_u:object_r:usr_t:s0
  12 /srv/.* system_u:object_r:var_t:s0
  13 /tmp/.* <>
  14 /sys/.* <>
  15 /dev/[0-9].*    -c      system_u:object_r:usb_device_t:s0
  16 /mnt/[^/]*/.*   <>
  17 /dev/.*mouse.*  -c      system_u:object_r:mouse_device_t:s0
  18 /dev/.*tty[^/]* -c      system_u:object_r:tty_device_t:s0
  19 /dev/[shmx]d[^/]*       -b      system_u:object_r:fixed_disk_device_t:s0
  20 /dev/(raw/)?rawctl      -c      system_u:object_r:fixed_disk_device_t:s0
  21 /dev/(misc/)?psaux      -c      system_u:object_r:mouse_device_t:s0
  22 /opt/(.*/)?man(/.*)?    system_u:object_r:man_t:s0
  23 /opt/(.*/)?lib(/.*)?    system_u:object_r:lib_t:s0
  24 /usr/(.*/)?lib(/.*)?    system_u:object_r:lib_t:s0
  25 /opt/(.*/)?bin(/.*)?    system_u:object_r:bin_t:s0
  26 /usr/(.*/)?bin(/.*)?    system_u:object_r:bin_t:s0


요정도 보면 실재로 구분되는 타입이라고 있다.
/dev아래 마우스란 놈이 /usr/bin 파일에 보려면
Allow mouse_device bin_t:file { read open };
이란 룰이 필요하다.












































댓글 없음:

댓글 쓰기

국정원의 댓글 공작을 지탄합니다.

UPBIT is a South Korean company, and people died of suicide cause of coin investment.

 UPBIT is a South Korean company, and people died of suicide cause of coin. The company helps the people who control the market price manipu...