From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4887D33E7 for ; Thu, 20 Mar 2025 21:35:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742506560; cv=none; b=IDd2c3Xn0MD0ZhoMMJeaEm9pBAwLSp391Vv4sCBGBbNO00VB/jakXacd+IZs+CJ1FoFatZkm20bPvB4Wis+Hahr/bcWwJHPYfOO8ihlIpOClNXmrukXsCOfqIe+V1yeBhT6MoU1wu3UVu/eXoJikwXcgZHRyTftJGNIfcxqJKiY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742506560; c=relaxed/simple; bh=0gasMJ9MwLFF9X4TIJDjjd2uvTa8ezZ/DrhvXflVu0E=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:Cc:To:From: References:In-Reply-To; b=jFVVPxdoz4cELIwvPJqDHH/N20C7WNKKaPXEihbi0BBrDwWpqJz9332c+NMKpa9Vlfyv8pgWrYcKZkO+Ee4+Qnff5elziAXB+2Ymxxn0My80ajZmz+yvkMsjTJNT3Z+532oj2faZVYnbl+GTJRMEdY9s8B1NVmUMMcfGeu7sCTA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=G5JYC3jm; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="G5JYC3jm" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43bc21f831bso869815e9.1 for ; Thu, 20 Mar 2025 14:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1742506555; x=1743111355; darn=vger.kernel.org; h=in-reply-to:references:from:to:cc:subject:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=JqJgAERJO0hWodgjO+O6nsJOj3YPTpObkXEvNBlmG3c=; b=G5JYC3jmOb6Ff6mrYC1Qo26ZnarpsB81DQV9Kc+bUEWnMhXaly+qjZvxG0p0KjOBum ryIRnFQu2RO/iEP8XJxRypNekFqA6IpYfSuR0MFKfnHCq6V8wQKpjyhE2jclV1S18efO MJCiKZA+53oolojvPRJ450/cEsJjjlLB2RfSTJhuEgIQarg+KPK1c6akJARSSsofNfPD Rd0HCwzfE4hUr/3VHKKPvGGVSg4m65k7DJmu9iAGCezSGjYisxglBwUQ/tGTEjhO0oBC Y7WtOA/EUh2856lqJ7qx/EgRq3IetHW4JjNIf0sQkNzF1dSt+r92eZ8w/xK63tTQw2bc fXpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742506555; x=1743111355; h=in-reply-to:references:from:to:cc:subject:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=JqJgAERJO0hWodgjO+O6nsJOj3YPTpObkXEvNBlmG3c=; b=OAixbA7q1RIuJDWWE2yJ1Uy9rLHDH+hM6XVNsbSY0dqhpJ2xbWox6B19O3Q7d6Q6fs Q1XK/6cHAIU91Qa56+r2LiOUUXbePq63HH2lrS3+dGN+CFD82xdhLpyPub8ddcfevhyx ga6fsDr9hfd9RqpIy4izO/2uZ4spjJr9XU5QKyeYqDJ3o6dvlofU95i1UQ6OFH6x7dIS h5X4KRprOWXmlfW6k/vbesaP17OmYgM4y7VlHEwtMM6YwkU0neRd1hdl07m2PMImK56H PmkfF/jytnbTI6MBhVlQOV9QEcLoZ0N3/bCmO5R1qr+yfS/1Nt/RKhWHJKsQX7pQyrwo dvQg== X-Gm-Message-State: AOJu0YxoRQ+I59LElVpJ2lmnfpAjmQj/342Ov/4gS+zHJ+jtQMp9dmXC WChWu2EF0qexQzluCC2ZStQmP7GnoheepPjtZoVsHV9PE1gBkWla7bIJ2VhUmes= X-Gm-Gg: ASbGncsTmqVpZbbQUCioH+gWMP0cvRLODAcQVhEIrIw1eKJFV47vWqnytyAj8ARGO4C eZyxtoMjPWtgl4ZgBTdE05IauX/RZXtdMrI+0Ou1l4R9QcLkMKI0uwZlsGmk9TY73TEVTK2yleJ WdkQn9Acwh6yLrGQjXyEdNE/DERISpeUGszsjW3vGcm4inpPljaxfYETMrBquECWJ11bH+RGjut a+7AC02sQ2BHbdKDcBzsELIEaq07MosMWVB8kjeyVE0t6rbQQMtlDo14l9iVqy+4WBJ54Pdyaf7 GH500YEzZEvycabNJsfALl6nYnhSShK+H4PZojeNYwH0+5PytEpinIm5QubKdCbf3P5cTsjuY7w 1Qy1I X-Google-Smtp-Source: AGHT+IHQLBHBcxn45pDMJ6mBe7Q5GjHdSOzikTUHc7bZFFqM3IvCF49MKGgOPWFCY1ifjxDw5fxebw== X-Received: by 2002:a05:600c:3552:b0:439:9a40:aa1a with SMTP id 5b1f17b1804b1-43d5170c622mr550105e9.6.1742506555439; Thu, 20 Mar 2025 14:35:55 -0700 (PDT) Received: from localhost (ip-89-103-73-235.bb.vodafone.cz. [89.103.73.235]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3997f9ef16csm605211f8f.86.2025.03.20.14.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Mar 2025 14:35:53 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 20 Mar 2025 22:35:52 +0100 Message-Id: Subject: Re: [PATCH v12 23/28] riscv: kernel command line option to opt out of user cfi Cc: , , , , , , , , , , , , , , , , , , , , , "linux-riscv" To: "Deepak Gupta" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "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" From: =?utf-8?q?Radim_Kr=C4=8Dm=C3=A1=C5=99?= References: <20250314-v5_user_cfi_series-v12-0-e51202b53138@rivosinc.com> <20250314-v5_user_cfi_series-v12-23-e51202b53138@rivosinc.com> In-Reply-To: <20250314-v5_user_cfi_series-v12-23-e51202b53138@rivosinc.com> 2025-03-14T14:39:42-07:00, Deepak Gupta : > This commit adds a kernel command line option using which user cfi can be > disabled. > > Signed-off-by: Deepak Gupta > --- > arch/riscv/kernel/usercfi.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/arch/riscv/kernel/usercfi.c b/arch/riscv/kernel/usercfi.c > index d31d89618763..813162ce4f15 100644 > --- a/arch/riscv/kernel/usercfi.c > +++ b/arch/riscv/kernel/usercfi.c > @@ -17,6 +17,8 @@ > #include > #include > =20 > +bool disable_riscv_usercfi; > + > #define SHSTK_ENTRY_SIZE sizeof(void *) > =20 > bool is_shstk_enabled(struct task_struct *task) > @@ -396,6 +398,9 @@ int arch_set_shadow_stack_status(struct task_struct *= t, unsigned long status) > unsigned long size =3D 0, addr =3D 0; > bool enable_shstk =3D false; > =20 > + if (disable_riscv_usercfi) > + return 0; > + > if (!cpu_supports_shadow_stack()) > return -EINVAL; > =20 > @@ -475,6 +480,9 @@ int arch_set_indir_br_lp_status(struct task_struct *t= , unsigned long status) > { > bool enable_indir_lp =3D false; > =20 > + if (disable_riscv_usercfi) > + return 0; > + > if (!cpu_supports_indirect_br_lp_instr()) > return -EINVAL; > =20 > @@ -507,3 +515,16 @@ int arch_lock_indir_br_lp_status(struct task_struct = *task, > =20 > return 0; > } > + > +static int __init setup_global_riscv_enable(char *str) > +{ > + if (strcmp(str, "true") =3D=3D 0) > + disable_riscv_usercfi =3D true; > + > + pr_info("Setting riscv usercfi to be %s\n", > + (disable_riscv_usercfi ? "disabled" : "enabled")); > + > + return 1; > +} > + > +__setup("disable_riscv_usercfi=3D", setup_global_riscv_enable); I'd prefer two command line options instead. In any case, I think we still document params in kernel-parameters.txt.