From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 761AB3783AE for ; Mon, 2 Feb 2026 15:10:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770045055; cv=none; b=T3ebCR/0H5HItpKuO/gKLvCNo63/vXA+hYaTw84l71dj+PvZJWQNy/2xhpCxpBtcCvYb2Bw+r0JXH4/wO6kMW1r7ioWAJpWLoTV08iqf+VGueaJqSSc0GNbpAP76DXDtxwO6lFXrahiEYi/5ngEsN5L+ZHRt2g6JDs6ETyLwuxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770045055; c=relaxed/simple; bh=NM2TwJCxd5xmyuMjEUz/VOe1jSYTkQR9YWOx3e921oA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=diuF1SvwvKhieUu4wXBq8beoIPLkF3i4IrHE4xEZVy43P/ccaciHwCAB0oyegvJG18MEg4Zu8fUZxhQCU0WToumWtkDUUWjLQ+zIgY4/oT0C3UuIG9zsPhUJjBwyviZI77GXamvrxyFcaqxCDXj00/ERbO6DGg66qkaRSyfsRRU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=none smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=OK3srajg; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="OK3srajg" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=hDSJE4EkTKFGGkPhn4SeHIi1SiIBeSssNODaa+nXt/0=; b=OK3srajgyUf9c4eoWt+HpqmoeF zCW8TWlSyPm5QmnzBxjRM8Wx9F3ZpamTfBVahM5HHOI5XgWP29DS6PmBGlUf4qDn5gea1FCwpm381 DoBFgexDF4X8Vd1KCovhH/Oed2GyXV3PAbB9JeAY+DyhJ8kdxKS5vw80qFKy0kmYC3gl4MUy2dflO Vb9o9dFXoYvMH3W9BYfKqALbQf5KqVPqk3HTnrZdKR8Y7Ftsf7f1KUcDmnPNKFc+26Y+TLygkRyzY rzH6MTrJJ+VgiKqGp+eoF1PA2Q4oyEurjrvFhB7c7KyLpm/9hXpoAUOPLP03nJYcfFdAdowBLokg1 wAorNQzA==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1vmvZf-00481y-9s; Mon, 02 Feb 2026 15:10:47 +0000 Date: Mon, 2 Feb 2026 07:10:43 -0800 From: Breno Leitao To: Will Deacon Cc: Catalin Marinas , Thiago Jung Bauermann , Mark Brown , 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() Message-ID: References: <20260130-arm64_cgs-v1-1-c9b6942b6b70@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Debian-User: leitao 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 > > --- > > 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