Thread (63 messages) 63 messages, 7 authors, 2020-09-10
STALE2126d REVIEWED: 2 (0M)
Revisions (48)
  1. v1 [diff vs current]
  2. v1 [diff vs current]
  3. v1 [diff vs current]
  4. v1 [diff vs current]
  5. v1 [diff vs current]
  6. v2 [diff vs current]
  7. v3 [diff vs current]
  8. v3 [diff vs current]
  9. v4 [diff vs current]
  10. v5 [diff vs current]
  11. v5 [diff vs current]
  12. v7 [diff vs current]
  13. v8 [diff vs current]
  14. v10 [diff vs current]
  15. v10 [diff vs current]
  16. v11 [diff vs current]
  17. v11 [diff vs current]
  18. v11 [diff vs current]
  19. v12 [diff vs current]
  20. v12 [diff vs current]
  21. v12 [diff vs current]
  22. v13 [diff vs current]
  23. v14 [diff vs current]
  24. v15 [diff vs current]
  25. v16 [diff vs current]
  26. v17 [diff vs current]
  27. v18 [diff vs current]
  28. v19 [diff vs current]
  29. v20 current
  30. v21 [diff vs current]
  31. v22 [diff vs current]
  32. v22 [diff vs current]
  33. v24 [diff vs current]
  34. v25 [diff vs current]
  35. v26 [diff vs current]
  36. v27 [diff vs current]
  37. v28 [diff vs current]
  38. v29 [diff vs current]
  39. v30 [diff vs current]
  40. v31 [diff vs current]
  41. v32 [diff vs current]
  42. v33 [diff vs current]
  43. v34 [diff vs current]
  44. v34 [diff vs current]
  45. v35 [diff vs current]
  46. v36 [diff vs current]
  47. v37 [diff vs current]
  48. v38 [diff vs current]

[PATCH v20 19/23] LSM: Verify LSM display sanity in binder

From: Casey Schaufler <casey@schaufler-ca.com>
Date: 2020-08-26 15:22:38
Also in: selinux
Subsystem: security subsystem, the rest · Maintainers: Paul Moore, James Morris, "Serge E. Hallyn", Linus Torvalds

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 <redacted>
Acked-by: Stephen Smalley <redacted>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
---
 security/security.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
diff --git a/security/security.c b/security/security.c
index ddbaf2073b02..95b48721fb17 100644
--- a/security/security.c
+++ b/security/security.c
@@ -788,9 +788,38 @@ int security_binder_set_context_mgr(struct task_struct *mgr)
 	return call_int_hook(binder_set_context_mgr, 0, 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);
 }
 
-- 
2.24.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help