aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>2023-04-03 13:37:28 +0300
committerKirill A. Shutemov <kirill.shutemov@linux.intel.com>2023-04-12 17:29:18 +0300
commit8d07c0e4ba660724f51de93fe762c2ee05349289 (patch)
tree9932a561f2e315bd81dd4080f88a0215265cd611
parent9f054d94b792addb808fbcee67c2cf2a98580390 (diff)
downloadlinux-lam.tar.gz
x86/mm/iommu/sva: Do not allow to set FORCE_TAGGED_SVA bit from outsidelam
arch_prctl(ARCH_FORCE_TAGGED_SVA) overrides the default and allows LAM and SVA to co-exist in the process. It is expected by called by the process when it knows what it is doing. arch_prctl() operates on the current process, but the same code is reachable from ptrace where it can be called on arbitrary task. Make it strict and only allow to set MM_CONTEXT_FORCE_TAGGED_SVA for the current process. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Fixes: 23e5d9ec2bab ("x86/mm/iommu/sva: Make LAM and SVA mutually exclusive") Suggested-by: Dmitry Vyukov <dvyukov@google.com>
-rw-r--r--arch/x86/kernel/process_64.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 4cc7376b878601..018d47b31cc1be 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -883,6 +883,8 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
case ARCH_ENABLE_TAGGED_ADDR:
return prctl_enable_tagged_addr(task->mm, arg2);
case ARCH_FORCE_TAGGED_SVA:
+ if (current != task)
+ return -EINVAL;
set_bit(MM_CONTEXT_FORCE_TAGGED_SVA, &task->mm->context.flags);
return 0;
case ARCH_GET_MAX_TAG_BITS: