Skip to content

Commit

Permalink
Merge tag 'selinux-pr-20191007' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/pcmoore/selinux

Pull selinuxfix from Paul Moore:
 "One patch to ensure we don't copy bad memory up into userspace"

* tag 'selinux-pr-20191007' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
  selinux: fix context string corruption in convert_context()
  • Loading branch information
torvalds committed Oct 8, 2019
2 parents f54e66a + 2a52439 commit 2ef4591
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,14 @@ static int convert_context(struct context *oldc, struct context *newc, void *p)
rc = string_to_context_struct(args->newp, NULL, s,
newc, SECSID_NULL);
if (rc == -EINVAL) {
/* Retain string representation for later mapping. */
/*
* Retain string representation for later mapping.
*
* IMPORTANT: We need to copy the contents of oldc->str
* back into s again because string_to_context_struct()
* may have garbled it.
*/
memcpy(s, oldc->str, oldc->len);
context_init(newc);
newc->str = s;
newc->len = oldc->len;
Expand Down

0 comments on commit 2ef4591

Please sign in to comment.