// SPDX-License-Identifier: GPL-2.0-only /* * mmap based event notifications for SELinux * * Author: KaiGai Kohei <[email protected]> * * Copyright (C) 2010 NEC corporation */ #include <linux/kernel.h> #include <linux/gfp.h> #include <linux/mm.h> #include <linux/mutex.h> #include "avc.h" #include "security.h" /* * The selinux_status_page shall be exposed to userspace applications * using mmap interface on /selinux/status. * It enables to notify applications a few events that will cause reset * of userspace access vector without context switching. * * The selinux_kernel_status structure on the head of status page is * protected from concurrent accesses using seqlock logic, so userspace * application should reference the status page according to the seqlock * logic. * * Typically, application checks status->sequence at the head of access * control routine. If it is odd-number, kernel is updating the status, * so please wait for a moment. If it is changed from the last sequence * number, it means something happen, so application will reset userspace * avc, if needed. * In most cases, application shall confirm the kernel status is not * changed without any system call invocations. */ /* * selinux_kernel_status_page * * It returns a reference to selinux_status_page. If the status page is * not allocated yet, it also tries to allocate it at the first time. */ struct page *selinux_kernel_status_page(void) { … } /* * selinux_status_update_setenforce * * It updates status of the current enforcing/permissive mode. */ void selinux_status_update_setenforce(bool enforcing) { … } /* * selinux_status_update_policyload * * It updates status of the times of policy reloaded, and current * setting of deny_unknown. */ void selinux_status_update_policyload(u32 seqno) { … }