From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3AB0937AA72; Thu, 29 Jan 2026 08:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769676159; cv=none; b=JOqBNDweiYnyEi/uWCR9Obj25G1gBnr2jUku80xc9FTZTh4ItzOi/AEqrxKWEgEcn2yetsBmtAYuO01sKEdVaCcPBE6XXHYEnCIAp5iLQ9UNgwmAUVQC7IQCa14GqTO2FpBcrBLnlwSIN0aXjCdlhHodNqw0Jv5ofuEx0dv+Tu4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769676159; c=relaxed/simple; bh=9QMEWB+yM4NRpFfl8KXrYJ8s8e6vKN8iej0DvKpGhcU=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=S0dGkj1AU3ofGA5BA5UTTz0Ig297wrdKvKaKrEMRLwzEx4PexW0zgvkFBuFPzYgSsGUBHOoT7mBppgHcNaNPPo7X1umx1wkeeWeAPBizeY1GAE+yp5AgOwDbXDvrsoGKa41+pbAIUHctt6Q92CxGKkaMUSFNwcX4LJxzgpo9rzs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WPGl94Lh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WPGl94Lh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E4C1C4CEF7; Thu, 29 Jan 2026 08:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769676158; bh=9QMEWB+yM4NRpFfl8KXrYJ8s8e6vKN8iej0DvKpGhcU=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=WPGl94Lhk/NCi3lEfZ8z65ulZBNKDA6CREUcGelyPWHfzLrK37HGMuOwr6ymnAWbq zMZw49VV3aaXfUo4RySMTADkUQE8+HOyxLnDUbS9p1QK1M0ZRy5dZoytzUnUWxQCiV JuT7cNRWclddUiuwl9xVh/+NdZ+rP0tENaakniujZDuQet4Cq/5STEjla2SU6a7q9W IS3R+R9rKQilV6AEDsD1IY1uaYb3R1j1y6rd5wzC3bsdxi84+lYX8JX2lPdhLlHGdW /cUwi/rw/43gTiJJkns0weSNlVwB+8yl7oSzYqr3Zf2SXhbeJgLk9oPQYFHNifZxf3 yKjt2ycaK4QFQ== Date: Thu, 29 Jan 2026 01:42:32 -0700 (MST) From: Paul Walmsley To: Deepak Gupta cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Christian Brauner , Peter Zijlstra , Oleg Nesterov , Eric Biederman , Kees Cook , Jonathan Corbet , Shuah Khan , Jann Horn , Conor Dooley , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?ISO-8859-15?Q?Bj=F6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Benno Lossin , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, alistair.francis@wdc.com, richard.henderson@linaro.org, jim.shu@sifive.com, andybnac@gmail.com, kito.cheng@sifive.com, charlie@rivosinc.com, atishp@rivosinc.com, evan@rivosinc.com, cleger@rivosinc.com, alexghiti@rivosinc.com, samitolvanen@google.com, broonie@kernel.org, rick.p.edgecombe@intel.com, rust-for-linux@vger.kernel.org, Zong Li , Andreas Korb , Valentin Haudiquet Subject: Re: [PATCH v26 10/28] riscv/mm: Implement map_shadow_stack() syscall In-Reply-To: Message-ID: <190df1c1-feb2-ae5d-7fdc-dd0c3d780b21@kernel.org> References: <20251211-v5_user_cfi_series-v26-0-f0f419e81ac0@rivosinc.com> <20251211-v5_user_cfi_series-v26-10-f0f419e81ac0@rivosinc.com> 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 Hi, On Mon, 26 Jan 2026, Deepak Gupta wrote: > Can you apply following diff on `allocate_shadow_stack` function in this > patch. > This fixes the bug that I earlier mentioned. We shouldn't be returning > location > to token and instead return base address of shadow stack. Userspace consumer > should be determining token location itself. This matches the ABI of other > arches. Sorry for being late on this. > > diff --git a/arch/riscv/kernel/usercfi.c b/arch/riscv/kernel/usercfi.c > index 27b36034ea85..a8530e6afb1e 100644 > --- a/arch/riscv/kernel/usercfi.c > +++ b/arch/riscv/kernel/usercfi.c > @@ -232,7 +232,7 @@ static unsigned long allocate_shadow_stack(unsigned long > addr, unsigned long siz > { > int flags = MAP_ANONYMOUS | MAP_PRIVATE; > struct mm_struct *mm = current->mm; > - unsigned long populate, tok_loc = 0; > + unsigned long populate; > > if (addr) > flags |= MAP_FIXED_NOREPLACE; > @@ -245,13 +245,11 @@ static unsigned long allocate_shadow_stack(unsigned long > addr, unsigned long siz > if (!set_tok || IS_ERR_VALUE(addr)) > goto out; > > - if (create_rstor_token(addr + token_offset, &tok_loc)) { > + if (create_rstor_token(addr + token_offset, NULL)) { > vm_munmap(addr, size); > return -EINVAL; > } > > - addr = tok_loc; > - > out: > return addr; > } Thanks, this fix has been rolled into the queued patch. The Reviewed-by:s and Tested-by:s have been dropped. - Paul