apparmor.d/profiles/kmod

65 lines
1.8 KiB
Text
Raw Normal View History

# vim:syntax=apparmor
# ------------------------------------------------------------------
#
2021-01-10 16:35:07 +01:00
# Copyright (C) 2019-2021 Mikhail Morfikov
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# ------------------------------------------------------------------
2020-12-10 22:33:39 +01:00
abi <abi/3.0>,
2020-12-10 22:33:39 +01:00
include <tunables/global>
@{BUILD_DIR} = /media/debuilder/
@{exec_path} = /{usr/,}bin/{kmod,lsmod}
@{exec_path} += /{usr/,}sbin/{depmod,insmod,lsmod,rmmod,modinfo,modprobe}
profile kmod @{exec_path} {
2020-12-10 22:33:39 +01:00
include <abstractions/base>
include <abstractions/consoles>
# To load/unload kernel modules
# modprobe: ERROR: could not insert '*': Operation not permitted
#
# modprobe: ERROR: ../libkmod/libkmod-module.c:799 kmod_module_remove_module() could not remove
# '*': Operation not permitted
capability sys_module,
# For error logs to go through the syslog mechanism (as LOG_DAEMON with level LOG_NOTICE) rather
# than to standard error.
capability syslog,
@{exec_path} mr,
/{usr/,}lib/modprobe.d/{,*.conf} r,
/etc/modprobe.d/{,*.conf} r,
/{usr/,}lib/modules/*/modules.* rw,
/var/lib/dkms/**/module/*.ko r,
/usr/src/*/*.ko r,
@{sys}/module/{,**} r,
@{PROC}/cmdline r,
@{PROC}/modules r,
# Needed for static-nodes
#capability dac_override,
#owner @{PROC}/@{pid}/fd/1 w,
# For local kernel build
owner /tmp/depmod.*/lib/modules/*/ r,
owner /tmp/depmod.*/lib/modules/*/modules.* rw,
owner @{BUILD_DIR}/**/System.map r,
owner @{BUILD_DIR}/**/debian/*/lib/modules/*/ r,
owner @{BUILD_DIR}/**/debian/*/lib/modules/*/modules.* rw,
owner @{BUILD_DIR}/**/debian/*/lib/modules/*/kernel/{,**/} r,
owner @{BUILD_DIR}/**/debian/*/lib/modules/*/kernel/**/*.ko r,
2020-12-10 22:33:39 +01:00
include if exists <local/kmod>
}