From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: arch/riscv/kernel/signal.c:196 __restore_cfiss_state() warn: maybe return -EFAULT instead of the bytes remaining?
Date: Fri, 18 Sep 2026 20:19:27 +0200 [thread overview]
Message-ID: <202609182005.wS9nDDeW-lkp@intel.com> (raw)
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Deepak Gupta <debug@rivosinc.com>
CC: Paul Walmsley <pjw@kernel.org>
CC: Andy Chiu <andy.chiu@sifive.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f259f446f5198d98e13756d2cd531812a0ad3064
commit: 66c9c713de597f9b40a319ebda4d3466ce2cdff0 riscv/signal: save and restore the shadow stack on a signal
date: 8 months ago
:::::: branch date: 2 hours ago
:::::: commit date: 8 months ago
config: riscv-randconfig-r2201-20260918 (https://download.01.org/0day-ci/archive/20260918/202609182005.wS9nDDeW-lkp@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 9.5.0
smatch: v0.5.0-9187-g5189e3fb
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
| Fixes: 66c9c713de59 ("riscv/signal: save and restore the shadow stack on a signal")
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202609182005.wS9nDDeW-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 173
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;
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 }
66c9c713de597f Deepak Gupta 2026-01-25 200
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next reply other threads:[~2026-09-18 18:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 18:19 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-02-15 23:56 arch/riscv/kernel/signal.c:196 __restore_cfiss_state() warn: maybe return -EFAULT instead of the bytes remaining? kernel test robot
2026-02-19 7:07 ` Dan Carpenter
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=202609182005.wS9nDDeW-lkp@intel.com \
--to=lkp@intel.com \
--cc=error27@gmail.com \
--cc=oe-kbuild@lists.linux.dev \
/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.