From: Dmitry Vyukov <dvyukov@google.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
x86@kernel.org, Kostya Serebryany <kcc@google.com>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Alexander Potapenko <glider@google.com>,
Taras Madan <tarasmadan@google.com>,
"H . J . Lu" <hjl.tools@gmail.com>,
Andi Kleen <ak@linux.intel.com>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Bharata B Rao <bharata@amd.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>,
Ashok Raj <ashok.raj@intel.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] x86/mm/iommu/sva: Do not allow to set FORCE_TAGGED_SVA bit from outside
Date: Mon, 3 Apr 2023 15:55:09 +0200 [thread overview]
Message-ID: <CACT4Y+YoS9e=QVq6iKda5Gv852kVv9OTLaOZ=XCJ65mP0oyAOA@mail.gmail.com> (raw)
In-Reply-To: <20230403111020.3136-3-kirill.shutemov@linux.intel.com>
On Mon, 3 Apr 2023 at 13:10, Kirill A. Shutemov
<kirill.shutemov@linux.intel.com> wrote:
>
> 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>
> ---
> arch/x86/kernel/process_64.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
> index c7dfd727c9ec..cefac2d3a9f6 100644
> --- a/arch/x86/kernel/process_64.c
> +++ b/arch/x86/kernel/process_64.c
> @@ -885,6 +885,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;
prctl_enable_tagged_addr() checks "task->mm != current->mm".
Should we check the same here for consistency? Or also change the
check in prctl_enable_tagged_addr().
arch_prctl() can only do task==current, so I guess "current != task"
is a more reasonable check for prctl_enable_tagged_addr() as well.
> set_bit(MM_CONTEXT_FORCE_TAGGED_SVA, &task->mm->context.flags);
> return 0;
> case ARCH_GET_MAX_TAG_BITS:
> --
> 2.39.2
>
next prev parent reply other threads:[~2023-04-03 13:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-03 11:10 [PATCH 0/2] Couple of trivial fixes for LAM vs. SVA interaction Kirill A. Shutemov
2023-04-03 11:10 ` [PATCH 1/2] x86/mm/iommu/sva: Fix error code for LAM enabling failure due to SVA Kirill A. Shutemov
2023-04-03 13:55 ` Dmitry Vyukov
2023-04-06 15:31 ` Dave Hansen
2023-04-06 15:59 ` Kirill A. Shutemov
2023-04-03 11:10 ` [PATCH 2/2] x86/mm/iommu/sva: Do not allow to set FORCE_TAGGED_SVA bit from outside Kirill A. Shutemov
2023-04-03 13:55 ` Dmitry Vyukov [this message]
2023-04-03 14:31 ` Kirill A. Shutemov
2023-04-03 14:46 ` Dmitry Vyukov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACT4Y+YoS9e=QVq6iKda5Gv852kVv9OTLaOZ=XCJ65mP0oyAOA@mail.gmail.com' \
--to=dvyukov@google.com \
--cc=ak@linux.intel.com \
--cc=andreyknvl@gmail.com \
--cc=ashok.raj@intel.com \
--cc=bharata@amd.com \
--cc=dave.hansen@linux.intel.com \
--cc=glider@google.com \
--cc=hjl.tools@gmail.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=kcc@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=ryabinin.a.a@gmail.com \
--cc=tarasmadan@google.com \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox