]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
UBUNTU: SAUCE: LSM: Verify LSM display sanity in binder
authorCasey Schaufler <casey@schaufler-ca.com>
Tue, 24 Mar 2020 00:00:09 +0000 (17:00 -0700)
committerPaolo Pisati <paolo.pisati@canonical.com>
Tue, 2 Nov 2021 07:24:52 +0000 (08:24 +0100)
Verify that the tasks on the ends of a binder transaction
use the same "display" security module. This prevents confusion
of security "contexts".

Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
security/security.c

index 24f28cfc0a31fcf20ce1bbe0daf9336d881f3701..68cf6c0691ff4d9f9289173616f6bd374e9ff01d 100644 (file)
@@ -815,9 +815,38 @@ int security_binder_set_context_mgr(struct task_struct *mgr)
 }
 EXPORT_SYMBOL(security_binder_set_context_mgr);
 
+/**
+ * security_binder_transaction - Binder driver transaction check
+ * @from: source of the transaction
+ * @to: destination of the transaction
+ *
+ * Verify that the tasks have the same LSM "display", then
+ * call the security module hooks.
+ *
+ * Returns -EINVAL if the displays don't match, or the
+ * result of the security module checks.
+ */
 int security_binder_transaction(struct task_struct *from,
                                struct task_struct *to)
 {
+       int from_display = lsm_task_display(from);
+       int to_display = lsm_task_display(to);
+
+       /*
+        * If the display is LSMBLOB_INVALID the first module that has
+        * an entry is used. This will be in the 0 slot.
+        *
+        * This is currently only required if the server has requested
+        * peer contexts, but it would be unwieldly to have too much of
+        * the binder driver detail here.
+        */
+       if (from_display == LSMBLOB_INVALID)
+               from_display = 0;
+       if (to_display == LSMBLOB_INVALID)
+               to_display = 0;
+       if (from_display != to_display)
+               return -EINVAL;
+
        return call_int_hook(binder_transaction, 0, from, to);
 }
 EXPORT_SYMBOL(security_binder_transaction);