From: Catalin Marinas <catalin.marinas@arm.com>
To: "Iván Ezequiel Rodriguez" <ivanrwcm25@gmail.com>
Cc: Will Deacon <will@kernel.org>, Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
linux-arm-kernel@lists.infradead.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Mark Rutland <mark.rutland@arm.com>,
Mark Brown <broonie@kernel.org>,
Deepak Gupta <debug@rivosinc.com>,
Alexandre Ghiti <alex@ghiti.fr>,
Albert Ou <aou@eecs.berkeley.edu>, Shuah Khan <shuah@kernel.org>,
Christian Brauner <brauner@kernel.org>,
James Morse <james.morse@arm.com>,
Yury Khrustalev <yury.khrustalev@arm.com>,
Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
Samuel Holland <samuel.holland@sifive.com>,
Zong Li <zong.li@sifive.com>,
Charlie Jenkins <thecharlesjenkins@gmail.com>,
Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>,
Zishun Yi <vulab@iscas.ac.cn>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
stable@vger.kernel.org
Subject: Re: [PATCH v3 1/4] arm64/gcs: release GCS on failed fork
Date: Thu, 29 Oct 2026 20:32:30 +0000 [thread overview]
Message-ID: <auOtXvGD1RHsU-dy@arm.com> (raw)
In-Reply-To: <20261028154315.1272705-2-ivanrwcm25@gmail.com>
On Wed, Oct 28, 2026 at 12:43:12PM -0300, Iván Ezequiel Rodriguez wrote:
> copy_thread() can map a CLONE_VM GCS and still return 0. A later
> copy_process() failure calls exit_thread(), but arm64 did not
> implement it, so the VMA stayed in the parent's mm. Wire
> HAVE_EXIT_THREAD to gcs_free().
>
> x86 already does this via exit_thread() -> shstk_free(). The separate
> x86 TLS leak is different: copy_thread() itself fails after the
> alloc, so copy_process() skips exit_thread().
Is the x86 TLS leak relevant to arm64?
[...]
> @@ -503,6 +517,8 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
>
> p->thread.cpu_context.x19 = (unsigned long)args->fn;
> p->thread.cpu_context.x20 = (unsigned long)args->fn_arg;
> + /* No user GCS alloc here; drop inherited tracking for CLONE_VM. */
> + gcs_reset_thread(p);
My LLM run noticed that this fixes another problem, unrelated to the
failed fork: io_uring and vhost workers are created with args->fn and
CLONE_VM and they inherit gcs_base/gcs_size from the creating task
through arch_dup_task_struct(). Without this reset, a worker exiting
normally unmaps the parent task's GCS.
I was wondering whether to have a separate one-line commit for the
worker thread case but I think I'll just add a comment in the commit
log, keep things simple.
--
Catalin
WARNING: multiple messages have this Message-ID (diff)
From: Catalin Marinas <catalin.marinas@arm.com>
To: "Iván Ezequiel Rodriguez" <ivanrwcm25@gmail.com>
Cc: Will Deacon <will@kernel.org>, Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
linux-arm-kernel@lists.infradead.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Mark Rutland <mark.rutland@arm.com>,
Mark Brown <broonie@kernel.org>,
Deepak Gupta <debug@rivosinc.com>,
Alexandre Ghiti <alex@ghiti.fr>,
Albert Ou <aou@eecs.berkeley.edu>, Shuah Khan <shuah@kernel.org>,
Christian Brauner <brauner@kernel.org>,
James Morse <james.morse@arm.com>,
Yury Khrustalev <yury.khrustalev@arm.com>,
Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
Samuel Holland <samuel.holland@sifive.com>,
Zong Li <zong.li@sifive.com>,
Charlie Jenkins <thecharlesjenkins@gmail.com>,
Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>,
Zishun Yi <vulab@iscas.ac.cn>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
stable@vger.kernel.org
Subject: Re: [PATCH v3 1/4] arm64/gcs: release GCS on failed fork
Date: Thu, 29 Oct 2026 20:32:30 +0000 [thread overview]
Message-ID: <auOtXvGD1RHsU-dy@arm.com> (raw)
In-Reply-To: <20261028154315.1272705-2-ivanrwcm25@gmail.com>
On Wed, Oct 28, 2026 at 12:43:12PM -0300, Iván Ezequiel Rodriguez wrote:
> copy_thread() can map a CLONE_VM GCS and still return 0. A later
> copy_process() failure calls exit_thread(), but arm64 did not
> implement it, so the VMA stayed in the parent's mm. Wire
> HAVE_EXIT_THREAD to gcs_free().
>
> x86 already does this via exit_thread() -> shstk_free(). The separate
> x86 TLS leak is different: copy_thread() itself fails after the
> alloc, so copy_process() skips exit_thread().
Is the x86 TLS leak relevant to arm64?
[...]
> @@ -503,6 +517,8 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
>
> p->thread.cpu_context.x19 = (unsigned long)args->fn;
> p->thread.cpu_context.x20 = (unsigned long)args->fn_arg;
> + /* No user GCS alloc here; drop inherited tracking for CLONE_VM. */
> + gcs_reset_thread(p);
My LLM run noticed that this fixes another problem, unrelated to the
failed fork: io_uring and vhost workers are created with args->fn and
CLONE_VM and they inherit gcs_base/gcs_size from the creating task
through arch_dup_task_struct(). Without this reset, a worker exiting
normally unmaps the parent task's GCS.
I was wondering whether to have a separate one-line commit for the
worker thread case but I think I'll just add a comment in the commit
log, keep things simple.
--
Catalin
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-10-29 20:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 15:43 [PATCH v3 0/4] arm64, riscv: release shadow stacks on failed fork Iván Ezequiel Rodriguez
2026-10-28 15:43 ` Iván Ezequiel Rodriguez
2026-10-28 15:43 ` [PATCH v3 1/4] arm64/gcs: release GCS " Iván Ezequiel Rodriguez
2026-10-28 15:43 ` Iván Ezequiel Rodriguez
2026-10-28 18:41 ` Mark Brown
2026-10-28 18:41 ` Mark Brown
2026-10-29 20:32 ` Catalin Marinas [this message]
2026-10-29 20:32 ` Catalin Marinas
2026-10-29 22:36 ` Mark Brown
2026-10-29 22:36 ` Mark Brown
2026-10-28 15:43 ` [PATCH v3 2/4] riscv/shstk: release shadow stack " Iván Ezequiel Rodriguez
2026-10-28 15:43 ` Iván Ezequiel Rodriguez
2026-10-28 15:43 ` [PATCH v3 3/4] selftests/arm64: GCS must not leak on a failed clone3 Iván Ezequiel Rodriguez
2026-10-28 15:43 ` Iván Ezequiel Rodriguez
2026-10-28 18:31 ` Mark Brown
2026-10-28 18:31 ` Mark Brown
2026-10-28 15:43 ` [PATCH v3 4/4] selftests/riscv: shadow stack " Iván Ezequiel Rodriguez
2026-10-28 15:43 ` Iván Ezequiel Rodriguez
2026-10-29 20:57 ` (subset) [PATCH v3 0/4] arm64, riscv: release shadow stacks on failed fork Catalin Marinas
2026-10-29 20:57 ` Catalin Marinas
2026-10-30 17:00 ` [PATCH 0/1] selftests/arm64: GCS must survive io_uring SQPOLL worker exit Iván Ezequiel Rodriguez
2026-10-30 17:00 ` [PATCH 1/1] " Iván Ezequiel Rodriguez
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=auOtXvGD1RHsU-dy@arm.com \
--to=catalin.marinas@arm.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=brauner@kernel.org \
--cc=broonie@kernel.org \
--cc=debug@rivosinc.com \
--cc=ivanrwcm25@gmail.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=palmer@dabbelt.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=samuel.holland@sifive.com \
--cc=shuah@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tan.shaopeng@jp.fujitsu.com \
--cc=thecharlesjenkins@gmail.com \
--cc=thiago.bauermann@linaro.org \
--cc=vulab@iscas.ac.cn \
--cc=will@kernel.org \
--cc=yury.khrustalev@arm.com \
--cc=zong.li@sifive.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.