From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 BF64125CC40 for ; Thu, 19 Feb 2026 07:07:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771484849; cv=none; b=ACxv2sWoQ80w6E9qbFgYO4BBYOeGM5LqL0OOIwdPW7UpmgE4tXE3tfuSmzu70j8dfbbFt5G58SDcAVqTRuPOxhLY2yjNI6i5bKj6v57ScJX/HgH7LHnJjfzUcZAVLiw/r+IF10YeQg4o8Sbvr2gKdUYfUsDwz8CDq7c81agjqgY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771484849; c=relaxed/simple; bh=8uUVri0cFA+596uYVgu1xjFSWnUH1eYCeHLFHC7qPz0=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=Ms5/RnuWkkKRqm1fVEJexn2bK33oKEgsA+PaKOrKx3LqQ/xLXXqVAmR1OVh5JLMbdSbSGwfBYT3/fTUhziOSEhWfISTYsQOOKbyEvY8hYB033nD9IwAVUP4Xn4vRqu87P3dRgARwcHQC/M4Af5H49+5PQBUJF8+uBuAefqBwvFY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qKQz5fPJ; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qKQz5fPJ" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4837634de51so2694485e9.1 for ; Wed, 18 Feb 2026 23:07:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771484846; x=1772089646; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=a911hhjUe7DJK8Rt561ipBUwNa/gipo2lowXM0LivmU=; b=qKQz5fPJyYXn2Pu40iqOx6TSH8MfDt7tisAMD6TMWrSk+kRFl/9MNziHaB17509+xB AE8tBsjxL0xMGza2iMTHCUKo0WjJwM6KfLqc7ZJLYdAhWBqwyZOmGJ5E1xNDTO46H4Yc cWxJbrlE1kO5jpJ4KCVECv56pEZEnLi6Q9jpUN9DrkACzvAuv25V++yNHDW/iZTZlLny 1bXK6h4SRYWnT9l87qXXyseENoahBECCWB9qlyQQgQ5mw/o7uMKRuyqpsu3SZaBsxEtB 5zpnZiNls/TfMUClzBVZMHRArVrL5XsT+FDFXSb2y/3WXS6mC6sdI/qRoK9FXlo2+Cu3 xzoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771484846; x=1772089646; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a911hhjUe7DJK8Rt561ipBUwNa/gipo2lowXM0LivmU=; b=beGJtqQwH8SkVKxsWtsaNfKPSvt0sGYHdJjjQ4GptVjKLkPRupFLzbIsDApD6cj3mH a0mxggJvQWjJVpyd7mE8+8NYJlJwF0n2bFXAV2qSBYjlH/co3ZbLgZdITr2AcYOfZ1Ks bcjfTiIk/1IsTmhypFOjro3kfp+ZnrTXR3eRC58nA75Mx3EJ29SMD2GQsfPIy5JrPU0v HWzsOQbrbfdTsiknjY2Yj9FqGmhvR8oPI3o8groiqD59fuIIKCwZ4BUfxIP6Bc8Wrpd+ I6M4iGZMtDzJ4JjtAohw+KzLRNX99sGUPjhv8yyfFLVRpEhc7RYtTK7xiHlAsxxNV4og 7ZLw== X-Forwarded-Encrypted: i=1; AJvYcCX6J0gs4Yame+LxHJ4dY+LqcznyZfuMz6o52OU3+6TooWM4y/iWZ0QOD501DTvl+l4+lU252CcBjgJ0qDk=@vger.kernel.org X-Gm-Message-State: AOJu0YzGtyFNpL8H5NItzpuSqijNgU3YQuWGI5b5Vheiut+73L+N2MeO Xyyxu6NJoJ6cTEXjQmHARGXAj5KVGYumGurOmR3aBdRv8EMFzJT0eRTpFjWAmGVOtRc= X-Gm-Gg: AZuq6aJVgIsQEheD5k0xbdOt5FlP7EzyWOofpRK/XnVFUr/HDw5hrvtFGgyJE77+UvD 7SbdBUUloLZRDTOm/gw1aPcoMnW4f5LefO0MOmsV+F4w6L3O5ymKFVwAy9lYYpcy1M6j5ja1C93 G9GONVq1fwJd22V8QsBaPyOZplD+LJWJzmVohEJRrAEENbu5vGpu+dZsgOnePu9S8l+/gGFVW0B 3gASYHPlHKUVKJ2tYeOOHq/b7mUu1dHRHBYinov6X7JyL4Vn8xA+szOMI4RvQwwTNKWU6V+erKF /ByTJ8/ZYu9K54OHU6f+lQW1tzB3tvcApA2DrjQogQLfT6TUP2XQF5+m1z9oTQZUrQXkvI9IaIg jLHS4wrSkAfvmUqvgBgMNpPPRumFSO7+ym0o3Nwva2Oo9VSzDN+4e89Az0MG4HOXO9ZZATDXqb6 yy7Pb9bVIR7rH04tMj9PaCp6EKX1qm X-Received: by 2002:a05:600c:c0ca:b0:483:78c5:d743 with SMTP id 5b1f17b1804b1-48378c5d9fcmr243436965e9.28.1771484845871; Wed, 18 Feb 2026 23:07:25 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4839f986118sm11262595e9.21.2026.02.18.23.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Feb 2026 23:07:25 -0800 (PST) Date: Thu, 19 Feb 2026 10:07:22 +0300 From: Dan Carpenter To: oe-kbuild@lists.linux.dev, Deepak Gupta Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, Paul Walmsley , Andy Chiu Subject: arch/riscv/kernel/signal.c:196 __restore_cfiss_state() warn: maybe return -EFAULT instead of the bytes remaining? Message-ID: <202602160730.QsdCT9Zp-lkp@intel.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 Content-Disposition: inline tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 26a4cfaff82a2dcb810f6bfd5f4842f9b6046c8a commit: 66c9c713de597f9b40a319ebda4d3466ce2cdff0 riscv/signal: save and restore the shadow stack on a signal config: riscv-randconfig-r073-20260216 (https://download.01.org/0day-ci/archive/20260216/202602160730.QsdCT9Zp-lkp@intel.com/config) compiler: riscv64-linux-gcc (GCC) 13.4.0 smatch version: v0.5.0-8994-gd50c5a4c If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Reported-by: Dan Carpenter | Closes: https://lore.kernel.org/r/202602160730.QsdCT9Zp-lkp@intel.com/ New smatch warnings: arch/riscv/kernel/signal.c:196 __restore_cfiss_state() warn: maybe return -EFAULT instead of the bytes remaining? Old smatch warnings: arch/riscv/kernel/signal.c:52 restore_fp_state() warn: maybe return -EFAULT instead of the bytes remaining? arch/riscv/kernel/signal.c:66 save_fp_state() warn: maybe return -EFAULT instead of the bytes remaining? arch/riscv/kernel/signal.c:132 __restore_v_state() warn: maybe return -EFAULT instead of the bytes remaining? arch/riscv/kernel/signal.c:142 __restore_v_state() warn: maybe return -EFAULT instead of the bytes remaining? arch/riscv/kernel/signal.c:228 restore_sigcontext() warn: maybe return -EFAULT instead of the bytes remaining? vim +196 arch/riscv/kernel/signal.c 66c9c713de597f Deepak Gupta 2026-01-25 174 static long __restore_cfiss_state(struct pt_regs *regs, void __user *sc_cfi) 66c9c713de597f Deepak Gupta 2026-01-25 175 { 66c9c713de597f Deepak Gupta 2026-01-25 176 struct __sc_riscv_cfi_state __user *state = sc_cfi; 66c9c713de597f Deepak Gupta 2026-01-25 177 unsigned long ss_ptr = 0; 66c9c713de597f Deepak Gupta 2026-01-25 178 long err; 66c9c713de597f Deepak Gupta 2026-01-25 179 66c9c713de597f Deepak Gupta 2026-01-25 180 /* 66c9c713de597f Deepak Gupta 2026-01-25 181 * Restore shadow stack as a form of token stored on the shadow stack itself as a safe 66c9c713de597f Deepak Gupta 2026-01-25 182 * way to restore. 66c9c713de597f Deepak Gupta 2026-01-25 183 * A token on the shadow stack gives the following properties: 66c9c713de597f Deepak Gupta 2026-01-25 184 * - Safe save and restore for shadow stack switching. Any save of shadow stack 66c9c713de597f Deepak Gupta 2026-01-25 185 * must have saved a token on shadow stack. Similarly any restore of shadow 66c9c713de597f Deepak Gupta 2026-01-25 186 * stack must check the token before restore. Since writing to a shadow stack with 66c9c713de597f Deepak Gupta 2026-01-25 187 * the address of shadow stack itself is not easily allowed, a restore without a save 66c9c713de597f Deepak Gupta 2026-01-25 188 * is quite difficult for an attacker to perform. 66c9c713de597f Deepak Gupta 2026-01-25 189 * - A natural break. A token in the shadow stack provides a natural break in shadow stack 66c9c713de597f Deepak Gupta 2026-01-25 190 * So a single linear range can be bucketed into different shadow stack segments. 66c9c713de597f Deepak Gupta 2026-01-25 191 * sspopchk will detect the condition and fault to kernel as a sw check exception. 66c9c713de597f Deepak Gupta 2026-01-25 192 */ 66c9c713de597f Deepak Gupta 2026-01-25 193 err = __copy_from_user(&ss_ptr, &state->ss_ptr, sizeof(unsigned long)); 66c9c713de597f Deepak Gupta 2026-01-25 194 66c9c713de597f Deepak Gupta 2026-01-25 195 if (unlikely(err)) 66c9c713de597f Deepak Gupta 2026-01-25 @196 return err; A lot of code in signal.c used to return nonsense values because it's highly optimized and the caller handles it. As in: return __copy_from_user(); But this code doesn't feel very optimized, honestly, and I bet returning -EFAULT doesn't hurt anything. I think it would be faster to get rid of the ret variable and do: if (__copy_from_user()) return -EFAULT; My brief and bogus testing seems to show a slight speed up probably based on the smaller stack size. 66c9c713de597f Deepak Gupta 2026-01-25 197 66c9c713de597f Deepak Gupta 2026-01-25 198 return restore_user_shstk(current, ss_ptr); 66c9c713de597f Deepak Gupta 2026-01-25 199 } -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki