forked from luck/tmp_suning_uos_patched
1b8b31a2e6
Convert the policy read-write lock to RCU. This is significantly simplified by the earlier work to encapsulate the policy data structures and refactor the policy load and boolean setting logic. Move the latest_granting sequence number into the selinux_policy structure so that it can be updated atomically with the policy. Since removing the policy rwlock and moving latest_granting reduces the selinux_ss structure to nothing more than a wrapper around the selinux_policy pointer, get rid of the extra layer of indirection. At present this change merely passes a hardcoded 1 to rcu_dereference_check() in the cases where we know we do not need to take rcu_read_lock(), with the preceding comment explaining why. Alternatively we could pass fsi->mutex down from selinuxfs and apply a lockdep check on it instead. Based in part on earlier attempts to convert the policy rwlock to RCU by Kaigai Kohei [1] and by Peter Enderborg [2]. [1] https://lore.kernel.org/selinux/6e2f9128-e191-ebb3-0e87-74bfccb0767f@tycho.nsa.gov/ [2] https://lore.kernel.org/selinux/20180530141104.28569-1-peter.enderborg@sony.com/ Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com> Reviewed-by: Ondrej Mosnacek <omosnace@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
39 lines
998 B
C
39 lines
998 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Implementation of the security services.
|
|
*
|
|
* Author : Stephen Smalley, <sds@tycho.nsa.gov>
|
|
*/
|
|
#ifndef _SS_SERVICES_H_
|
|
#define _SS_SERVICES_H_
|
|
|
|
#include "policydb.h"
|
|
|
|
/* Mapping for a single class */
|
|
struct selinux_mapping {
|
|
u16 value; /* policy value for class */
|
|
unsigned int num_perms; /* number of permissions in class */
|
|
u32 perms[sizeof(u32) * 8]; /* policy values for permissions */
|
|
};
|
|
|
|
/* Map for all of the classes, with array size */
|
|
struct selinux_map {
|
|
struct selinux_mapping *mapping; /* indexed by class */
|
|
u16 size; /* array size of mapping */
|
|
};
|
|
|
|
struct selinux_policy {
|
|
struct sidtab *sidtab;
|
|
struct policydb policydb;
|
|
struct selinux_map map;
|
|
u32 latest_granting;
|
|
} __randomize_layout;
|
|
|
|
void services_compute_xperms_drivers(struct extended_perms *xperms,
|
|
struct avtab_node *node);
|
|
|
|
void services_compute_xperms_decision(struct extended_perms_decision *xpermd,
|
|
struct avtab_node *node);
|
|
|
|
#endif /* _SS_SERVICES_H_ */
|