From: Breno Leitao <leitao@debian.org>
To: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
Mark Brown <broonie@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64/gcs: Fix error handling in arch_set_shadow_stack_status()
Date: Mon, 2 Feb 2026 07:10:43 -0800 [thread overview]
Message-ID: <aYC-UhyMdh2YJSty@gmail.com> (raw)
In-Reply-To: <aYC4WygNsqtGePnq@willie-the-truck>
On Mon, Feb 02, 2026 at 02:44:43PM +0000, Will Deacon wrote:
> On Fri, Jan 30, 2026 at 01:43:09AM -0800, Breno Leitao wrote:
> > alloc_gcs() returns an error-encoded pointer on failure, which comes
> > from do_mmap(), not NULL.
> >
> > The current NULL check fails to detect errors, which could lead to using
> > an invalid GCS address.
> >
> > Use IS_ERR_VALUE() to properly detect errors, consistent with the
> > check in gcs_alloc_thread_stack().
> >
> > Fixes: b57180c75c7eb ("arm64/gcs: Implement shadow stack prctl() interface")
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> > ---
> > PS: This was compiled-tested only, given I unfortunately don't have
> > a hardware to test on _yet_.
> > ---
> > arch/arm64/mm/gcs.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm64/mm/gcs.c b/arch/arm64/mm/gcs.c
> > index 6e93f78de79b1..efce7642b1d7b 100644
> > --- a/arch/arm64/mm/gcs.c
> > +++ b/arch/arm64/mm/gcs.c
> > @@ -199,8 +199,8 @@ int arch_set_shadow_stack_status(struct task_struct *task, unsigned long arg)
> >
> > size = gcs_size(0);
> > gcs = alloc_gcs(0, size);
> > - if (!gcs)
> > - return -ENOMEM;
> > + if (IS_ERR_VALUE(gcs))
> > + return PTR_ERR((void *)gcs);
>
> Why do you need to go via PTR_ERR() here? 'gcs' is an 'unsigned long' so
> can't we just return that directly?
yea, PTR_ERR() is not helping here. We can definitely return gcs
directly.
I will update it,
--breno
prev parent reply other threads:[~2026-02-02 15:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 9:43 [PATCH] arm64/gcs: Fix error handling in arch_set_shadow_stack_status() Breno Leitao
2026-02-02 13:11 ` Mark Brown
2026-02-02 14:44 ` Will Deacon
2026-02-02 15:10 ` Breno Leitao [this message]
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=aYC-UhyMdh2YJSty@gmail.com \
--to=leitao@debian.org \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thiago.bauermann@linaro.org \
--cc=will@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 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.