lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202601171848.ydLTJYrz-lkp@intel.com>
Date: Sat, 17 Jan 2026 18:53:26 +0800
From: kernel test robot <lkp@...el.com>
To: Andy Chiu <andybnac@...il.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
 Paul Walmsley <pjw@...nel.org>
Subject: arch/riscv/kernel/signal.c:148:22: sparse: sparse: symbol
 'arch_ext_list' was not declared. Should it be static?

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d3eeb99bbc99cc5eb94a4a75ed4415a0272254ef
commit: 818d78ba1b3f88d2bfee249f25020211488a26c3 riscv: signal: abstract header saving for setup_sigcontext
date:   4 weeks ago
config: riscv-randconfig-r121-20260117 (https://download.01.org/0day-ci/archive/20260117/202601171848.ydLTJYrz-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260117/202601171848.ydLTJYrz-lkp@intel.com/reproduce)

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 <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601171848.ydLTJYrz-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   WARNING: invalid argument to '-march': '_zacas_zabha'
>> arch/riscv/kernel/signal.c:148:22: sparse: sparse: symbol 'arch_ext_list' was not declared. Should it be static?
>> arch/riscv/kernel/signal.c:155:14: sparse: sparse: symbol 'nr_arch_exts' was not declared. Should it be static?
>> arch/riscv/kernel/signal.c:300:39: sparse: sparse: cast removes address space '__user' of expression
>> arch/riscv/kernel/signal.c:300:36: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct __riscv_ctx_hdr [noderef] __user *sc_ext_ptr @@     got void * @@
   arch/riscv/kernel/signal.c:300:36: sparse:     expected struct __riscv_ctx_hdr [noderef] __user *sc_ext_ptr
   arch/riscv/kernel/signal.c:300:36: sparse:     got void *

vim +/arch_ext_list +148 arch/riscv/kernel/signal.c

   147	
 > 148	struct arch_ext_priv arch_ext_list[] = {
   149		{
   150			.magic = RISCV_V_MAGIC,
   151			.save = &save_v_state,
   152		},
   153	};
   154	
 > 155	const size_t nr_arch_exts = ARRAY_SIZE(arch_ext_list);
   156	
   157	static long restore_sigcontext(struct pt_regs *regs,
   158		struct sigcontext __user *sc)
   159	{
   160		void __user *sc_ext_ptr = &sc->sc_extdesc.hdr;
   161		__u32 rsvd;
   162		long err;
   163		/* sc_regs is structured the same as the start of pt_regs */
   164		err = __copy_from_user(regs, &sc->sc_regs, sizeof(sc->sc_regs));
   165		if (unlikely(err))
   166			return err;
   167	
   168		/* Restore the floating-point state. */
   169		if (has_fpu()) {
   170			err = restore_fp_state(regs, &sc->sc_fpregs);
   171			if (unlikely(err))
   172				return err;
   173		}
   174	
   175		/* Check the reserved word before extensions parsing */
   176		err = __get_user(rsvd, &sc->sc_extdesc.reserved);
   177		if (unlikely(err))
   178			return err;
   179		if (unlikely(rsvd))
   180			return -EINVAL;
   181	
   182		while (!err) {
   183			__u32 magic, size;
   184			struct __riscv_ctx_hdr __user *head = sc_ext_ptr;
   185	
   186			err |= __get_user(magic, &head->magic);
   187			err |= __get_user(size, &head->size);
   188			if (unlikely(err))
   189				return err;
   190	
   191			sc_ext_ptr += sizeof(*head);
   192			switch (magic) {
   193			case END_MAGIC:
   194				if (size != END_HDR_SIZE)
   195					return -EINVAL;
   196	
   197				return 0;
   198			case RISCV_V_MAGIC:
   199				if (!(has_vector() || has_xtheadvector()) || !riscv_v_vstate_query(regs) ||
   200				    size != riscv_v_sc_size)
   201					return -EINVAL;
   202	
   203				err = __restore_v_state(regs, sc_ext_ptr);
   204				break;
   205			default:
   206				return -EINVAL;
   207			}
   208			sc_ext_ptr = (void __user *)head + size;
   209		}
   210		return err;
   211	}
   212	
   213	static size_t get_rt_frame_size(bool cal_all)
   214	{
   215		struct rt_sigframe __user *frame;
   216		size_t frame_size;
   217		size_t total_context_size = 0;
   218	
   219		frame_size = sizeof(*frame);
   220	
   221		if (has_vector() || has_xtheadvector()) {
   222			if (cal_all || riscv_v_vstate_query(task_pt_regs(current)))
   223				total_context_size += riscv_v_sc_size;
   224		}
   225	
   226		frame_size += total_context_size;
   227	
   228		frame_size = round_up(frame_size, 16);
   229		return frame_size;
   230	}
   231	
   232	SYSCALL_DEFINE0(rt_sigreturn)
   233	{
   234		struct pt_regs *regs = current_pt_regs();
   235		struct rt_sigframe __user *frame;
   236		struct task_struct *task;
   237		sigset_t set;
   238		size_t frame_size = get_rt_frame_size(false);
   239	
   240		/* Always make any pending restarted system calls return -EINTR */
   241		current->restart_block.fn = do_no_restart_syscall;
   242	
   243		frame = (struct rt_sigframe __user *)regs->sp;
   244	
   245		if (!access_ok(frame, frame_size))
   246			goto badframe;
   247	
   248		if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
   249			goto badframe;
   250	
   251		set_current_blocked(&set);
   252	
   253		if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
   254			goto badframe;
   255	
   256		if (restore_altstack(&frame->uc.uc_stack))
   257			goto badframe;
   258	
   259		regs->cause = -1UL;
   260	
   261		return regs->a0;
   262	
   263	badframe:
   264		task = current;
   265		if (show_unhandled_signals) {
   266			pr_info_ratelimited(
   267				"%s[%d]: bad frame in %s: frame=%p pc=%p sp=%p\n",
   268				task->comm, task_pid_nr(task), __func__,
   269				frame, (void *)regs->epc, (void *)regs->sp);
   270		}
   271		force_sig(SIGSEGV);
   272		return 0;
   273	}
   274	
   275	static long setup_sigcontext(struct rt_sigframe __user *frame,
   276		struct pt_regs *regs)
   277	{
   278		struct sigcontext __user *sc = &frame->uc.uc_mcontext;
   279		struct __riscv_ctx_hdr __user *sc_ext_ptr = &sc->sc_extdesc.hdr;
   280		struct arch_ext_priv *arch_ext;
   281		long err, i, ext_size;
   282	
   283		/* sc_regs is structured the same as the start of pt_regs */
   284		err = __copy_to_user(&sc->sc_regs, regs, sizeof(sc->sc_regs));
   285		/* Save the floating-point state. */
   286		if (has_fpu())
   287			err |= save_fp_state(regs, &sc->sc_fpregs);
   288		/* Save the vector state. */
   289		for (i = 0; i < nr_arch_exts; i++) {
   290			arch_ext = &arch_ext_list[i];
   291			if (!arch_ext->save)
   292				continue;
   293	
   294			ext_size = arch_ext->save(regs, sc_ext_ptr + 1);
   295			if (ext_size <= 0) {
   296				err |= ext_size;
   297			} else {
   298				err |= __put_user(arch_ext->magic, &sc_ext_ptr->magic);
   299				err |= __put_user(ext_size, &sc_ext_ptr->size);
 > 300				sc_ext_ptr = (void *)sc_ext_ptr + ext_size;
   301			}
   302		}
   303		/* Write zero to fp-reserved space and check it on restore_sigcontext */
   304		err |= __put_user(0, &sc->sc_extdesc.reserved);
   305		/* And put END __riscv_ctx_hdr at the end. */
   306		err |= __put_user(END_MAGIC, &sc_ext_ptr->magic);
   307		err |= __put_user(END_HDR_SIZE, &sc_ext_ptr->size);
   308	
   309		return err;
   310	}
   311	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ