![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0 0002 /* 0003 * Implementations of the security context functions. 0004 * 0005 * Author: Ondrej Mosnacek <omosnacek@gmail.com> 0006 * Copyright (C) 2020 Red Hat, Inc. 0007 */ 0008 0009 #include <linux/jhash.h> 0010 0011 #include "context.h" 0012 #include "mls.h" 0013 0014 u32 context_compute_hash(const struct context *c) 0015 { 0016 u32 hash = 0; 0017 0018 /* 0019 * If a context is invalid, it will always be represented by a 0020 * context struct with only the len & str set (and vice versa) 0021 * under a given policy. Since context structs from different 0022 * policies should never meet, it is safe to hash valid and 0023 * invalid contexts differently. The context_cmp() function 0024 * already operates under the same assumption. 0025 */ 0026 if (c->len) 0027 return full_name_hash(NULL, c->str, c->len); 0028 0029 hash = jhash_3words(c->user, c->role, c->type, hash); 0030 hash = mls_range_hash(&c->range, hash); 0031 return hash; 0032 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |