Безопасность компьютерных систем 2017/SECCOMP — различия между версиями
Материал из Wiki - Факультет компьютерных наук
Gamajun (обсуждение | вклад) (Новая страница: «== Тестовый пример 2 == ''' #include <stdio.h> #include <seccomp.h> #include <unistd.h> #include <sys/fcntl.h> #include <errno.h> int main() {…») |
Gamajun (обсуждение | вклад) |
||
(не показаны 4 промежуточные версии этого же участника) | |||
Строка 1: | Строка 1: | ||
+ | == Linux seccomp == | ||
+ | Ссылки для изучения: | ||
+ | |||
+ | # Рекомендуемая основная презентация (пригодится для выполнения бонусного задания к заданию 3): http://events.linuxfoundation.org/sites/events/files/slides/limiting_kernel_attack_surface_with_seccomp-ContainerCon.eu_2016-Kerrisk.pdf | ||
+ | # https://eigenstate.org/notes/seccomp | ||
+ | # Kafel - язык для конструирования политик seccomp (not an official Google product) https://github.com/google/kafel | ||
+ | |||
== Тестовый пример 2 == | == Тестовый пример 2 == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | int main() { | + | #include <stdio.h> |
+ | #include <seccomp.h> | ||
+ | #include <unistd.h> | ||
+ | #include <sys/fcntl.h> | ||
+ | #include <errno.h> | ||
+ | int main() { | ||
pid_t pid; | pid_t pid; | ||
− | |||
scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_TRAP); | scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_TRAP); | ||
− | |||
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 0); | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 0); | ||
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 0); | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 0); | ||
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(sigreturn), 0); | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(sigreturn), 0); | ||
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(exit_group), 0); | seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(exit_group), 0); | ||
− | |||
− | |||
printf ("No restrictions yet\n"); | printf ("No restrictions yet\n"); | ||
− | |||
seccomp_load(ctx); | seccomp_load(ctx); | ||
pid = getpid(); | pid = getpid(); | ||
− | |||
printf("!! YOU SHOULD NOT SEE THIS!! My PID is%d\n", pid); | printf("!! YOU SHOULD NOT SEE THIS!! My PID is%d\n", pid); | ||
− | |||
return 0; | return 0; | ||
− | } | + | } |
− | + |
Текущая версия на 22:17, 4 декабря 2017
Linux seccomp
Ссылки для изучения:
- Рекомендуемая основная презентация (пригодится для выполнения бонусного задания к заданию 3): http://events.linuxfoundation.org/sites/events/files/slides/limiting_kernel_attack_surface_with_seccomp-ContainerCon.eu_2016-Kerrisk.pdf
- https://eigenstate.org/notes/seccomp
- Kafel - язык для конструирования политик seccomp (not an official Google product) https://github.com/google/kafel
Тестовый пример 2
#include <stdio.h> #include <seccomp.h> #include <unistd.h> #include <sys/fcntl.h> #include <errno.h> int main() { pid_t pid; scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_TRAP); seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 0); seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 0); seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(sigreturn), 0); seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(exit_group), 0); printf ("No restrictions yet\n"); seccomp_load(ctx); pid = getpid(); printf("!! YOU SHOULD NOT SEE THIS!! My PID is%d\n", pid); return 0; }