]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
UBUNTU: SAUCE: LSM stacking: verify display LSM
authorJohn Johansen <john.johansen@canonical.com>
Wed, 27 Sep 2017 05:28:08 +0000 (01:28 -0400)
committerSeth Forshee <seth.forshee@canonical.com>
Tue, 10 Apr 2018 18:06:20 +0000 (13:06 -0500)
BugLink: http://bugs.launchpad.net/bugs/1763062
Make sure the display LSM is verified to be a registered LSM, to
avoid breakage when a bad name is passed.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
security/security.c

index 4c1fec9f8bc055ce223c510abe830391f416b6ba..4e2b4c628221242aba258b0cfd2583b543e5f507 100644 (file)
@@ -1662,6 +1662,7 @@ static int lsm_task_prctl(int option, unsigned long arg2, unsigned long arg3,
        char buffer[SECURITY_NAME_MAX + 1];
        __user char *optval = (__user char *)arg2;
        __user int *optlen = (__user int *)arg3;
+       struct security_hook_list *hp;
        int dlen;
        int len;
 
@@ -1687,17 +1688,22 @@ static int lsm_task_prctl(int option, unsigned long arg2, unsigned long arg3,
                if (copy_from_user(buffer, optval, len))
                        return -EFAULT;
                buffer[len] = '\0';
-               /*
-                * Trust the caller to know what lsm name(s) are available.
-                */
+               /* verify the requested LSM is registered */
+               list_for_each_entry(hp, &security_hook_heads.getprocattr, list) {
+                       if (!strcmp(buffer, hp->lsm)) {
+                               strcpy(lsm, hp->lsm);
+                               goto out;
+                       }
+               }
                if (!strncmp(buffer, nolsm, NOLSMLEN))
                        lsm[0] = '\0';
                else
-                       strcpy(lsm, buffer);
+                       return -ENOENT;
                break;
        default:
                return -ENOSYS;
        }
+out:
        return 0;
 }
 #endif