]> Git Repo - linux.git/commitdiff
Merge tag 'selinux-pr-20191007' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <[email protected]>
Tue, 8 Oct 2019 17:51:37 +0000 (10:51 -0700)
committerLinus Torvalds <[email protected]>
Tue, 8 Oct 2019 17:51:37 +0000 (10:51 -0700)
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()

1  2 
security/selinux/ss/services.c

index 3a29e7c24ba936f38a934e78dc9893c71e97eeeb,39c317099d8d85c9b3f4ba8964d2c299d0b80aa1..a5813c7629c17f229f6e016cd3d5e0db86f975f7
@@@ -1,4 -1,3 +1,4 @@@
 +// SPDX-License-Identifier: GPL-2.0-only
  /*
   * Implementation of the security services.
   *
@@@ -36,6 -35,9 +36,6 @@@
   * Copyright (C) 2004-2006 Trusted Computer Solutions, Inc.
   * Copyright (C) 2003 - 2004, 2006 Tresys Technology, LLC
   * Copyright (C) 2003 Red Hat, Inc., James Morris <[email protected]>
 - *    This program is free software; you can redistribute it and/or modify
 - *    it under the terms of the GNU General Public License as published by
 - *    the Free Software Foundation, version 2.
   */
  #include <linux/kernel.h>
  #include <linux/slab.h>
@@@ -1946,7 -1948,14 +1946,14 @@@ static int convert_context(struct conte
                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;
This page took 0.08129 seconds and 4 git commands to generate.