linux-stable/security/selinux
Jann Horn 95ffe19420 selinux: refactor mls_context_to_sid() and make it stricter
The intended behavior change for this patch is to reject any MLS strings
that contain (trailing) garbage if p->mls_enabled is true.

As suggested by Paul Moore, change mls_context_to_sid() so that the two
parts of the range are extracted before the rest of the parsing. Because
now we don't have to scan for two different separators simultaneously
everywhere, we can actually switch to strchr() everywhere instead of the
open-coded loops that scan for two separators at once.

mls_context_to_sid() used to signal how much of the input string was parsed
by updating `*scontext`. However, there is actually no case in which
mls_context_to_sid() only parses a subset of the input and still returns
a success (other than the buggy case with a second '-' in which it
incorrectly claims to have consumed the entire string). Turn `scontext`
into a simple pointer argument and stop redundantly checking whether the
entire input was consumed in string_to_context_struct(). This also lets us
remove the `scontext_len` argument from `string_to_context_struct()`.

Signed-off-by: Jann Horn <jannh@google.com>
[PM: minor merge fuzz in convert_context()]
Signed-off-by: Paul Moore <paul@paul-moore.com>
2018-09-05 17:47:09 -04:00
..
include net: initial AF_XDP skeleton 2018-05-03 15:55:23 -07:00
ss selinux: refactor mls_context_to_sid() and make it stricter 2018-09-05 17:47:09 -04:00
.gitignore
avc.c selinux: Cleanup printk logging in avc 2018-06-19 13:47:13 -04:00
exports.c
hooks.c selinux: fix mounting of cgroup2 under older policies 2018-09-04 18:02:52 -04:00
ibpkey.c selinux: wrap global selinux state 2018-03-01 18:48:02 -05:00
Kconfig security: introduce CONFIG_SECURITY_WRITABLE_HOOKS 2017-03-06 11:00:12 +11:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
netif.c selinux: Cleanup printk logging in netif 2018-06-19 13:45:31 -04:00
netlabel.c selinux: wrap AVC state 2018-03-20 16:58:17 -04:00
netlink.c selinux: Cleanup printk logging in netlink 2018-06-19 13:33:05 -04:00
netnode.c selinux: Cleanup printk logging in netnode 2018-06-19 13:49:10 -04:00
netport.c selinux: Cleanup printk logging in netport 2018-06-19 13:43:01 -04:00
nlmsgtab.c net: sched: introduce chain object to uapi 2018-07-23 20:44:12 -07:00
selinuxfs.c selinux/stable-4.18 PR 20180814 2018-08-15 10:39:06 -07:00
xfrm.c selinux: wrap AVC state 2018-03-20 16:58:17 -04:00