]> Git Repo - J-linux.git/blob - security/selinux/ss/context.c
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / security / selinux / ss / context.c
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Implementations of the security context functions.
4  *
5  * Author: Ondrej Mosnacek <[email protected]>
6  * Copyright (C) 2020 Red Hat, Inc.
7  */
8
9 #include <linux/jhash.h>
10
11 #include "context.h"
12 #include "mls.h"
13
14 u32 context_compute_hash(const struct context *c)
15 {
16         u32 hash = 0;
17
18         /*
19          * If a context is invalid, it will always be represented by a
20          * context struct with only the len & str set (and vice versa)
21          * under a given policy. Since context structs from different
22          * policies should never meet, it is safe to hash valid and
23          * invalid contexts differently. The context_cmp() function
24          * already operates under the same assumption.
25          */
26         if (c->len)
27                 return full_name_hash(NULL, c->str, c->len);
28
29         hash = jhash_3words(c->user, c->role, c->type, hash);
30         hash = mls_range_hash(&c->range, hash);
31         return hash;
32 }
This page took 0.027871 seconds and 4 git commands to generate.