mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-16 07:35:14 +00:00
selinux: fix empty write to keycreate file
[ Upstream commit464c258aa4
] When sid == 0 (we are resetting keycreate_sid to the default value), we should skip the KEY__CREATE check. Before this patch, doing a zero-sized write to /proc/self/keycreate would check if the current task can create unlabeled keys (which would usually fail with -EACCESS and generate an AVC). Now it skips the check and correctly sets the task's keycreate_sid to 0. Bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1719067 Tested using the reproducer from the report above. Fixes:4eb582cf1f
("[PATCH] keys: add a way to store the appropriate context for newly-created keys") Reported-by: Kir Kolyshkin <kir@sacred.ru> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
10e3788e65
commit
914026d581
1 changed files with 6 additions and 5 deletions
|
@ -6550,11 +6550,12 @@ static int selinux_setprocattr(const char *name, void *value, size_t size)
|
||||||
} else if (!strcmp(name, "fscreate")) {
|
} else if (!strcmp(name, "fscreate")) {
|
||||||
tsec->create_sid = sid;
|
tsec->create_sid = sid;
|
||||||
} else if (!strcmp(name, "keycreate")) {
|
} else if (!strcmp(name, "keycreate")) {
|
||||||
error = avc_has_perm(&selinux_state,
|
if (sid) {
|
||||||
mysid, sid, SECCLASS_KEY, KEY__CREATE,
|
error = avc_has_perm(&selinux_state, mysid, sid,
|
||||||
NULL);
|
SECCLASS_KEY, KEY__CREATE, NULL);
|
||||||
if (error)
|
if (error)
|
||||||
goto abort_change;
|
goto abort_change;
|
||||||
|
}
|
||||||
tsec->keycreate_sid = sid;
|
tsec->keycreate_sid = sid;
|
||||||
} else if (!strcmp(name, "sockcreate")) {
|
} else if (!strcmp(name, "sockcreate")) {
|
||||||
tsec->sockcreate_sid = sid;
|
tsec->sockcreate_sid = sid;
|
||||||
|
|
Loading…
Reference in a new issue