All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [dvyukov:dvyukov-rseq-pkey 3/3] kernel/rseq.c:406:9: error: unknown type name 'pkey_reg_t'
Date: Sat, 8 Feb 2025 20:10:02 +0800	[thread overview]
Message-ID: <202502082017.0GixUctp-lkp@intel.com> (raw)

tree:   https://github.com/dvyukov/linux dvyukov-rseq-pkey
head:   b991732d23294a961eed6a4a2758c16f0430de9c
commit: b991732d23294a961eed6a4a2758c16f0430de9c [3/3] rseq: Make rseq work with protection keys
config: powerpc-allnoconfig (https://download.01.org/0day-ci/archive/20250208/202502082017.0GixUctp-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250208/202502082017.0GixUctp-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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502082017.0GixUctp-lkp@intel.com/

All errors (new ones prefixed by >>):

   kernel/rseq.c: In function '__rseq_handle_notify_resume':
>> kernel/rseq.c:406:9: error: unknown type name 'pkey_reg_t'
     406 |         pkey_reg_t saved;
         |         ^~~~~~~~~~
>> kernel/rseq.c:426:17: error: implicit declaration of function 'write_pkey_reg' [-Wimplicit-function-declaration]
     426 |                 write_pkey_reg(saved);
         |                 ^~~~~~~~~~~~~~
>> kernel/rseq.c:455:25: error: implicit declaration of function 'switch_to_permissive_pkey_reg' [-Wimplicit-function-declaration]
     455 |                 saved = switch_to_permissive_pkey_reg();
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/pkey_reg_t +406 kernel/rseq.c

   390	
   391	/*
   392	 * This resume handler must always be executed between any of:
   393	 * - preemption,
   394	 * - signal delivery,
   395	 * and return to user-space.
   396	 *
   397	 * This is how we can ensure that the entire rseq critical section
   398	 * will issue the commit instruction only if executed atomically with
   399	 * respect to other threads scheduled on the same CPU, and with respect
   400	 * to signal handlers.
   401	 */
   402	void __rseq_handle_notify_resume(struct ksignal *ksig, struct pt_regs *regs)
   403	{
   404		struct task_struct *t = current;
   405		int ret, sig;
 > 406		pkey_reg_t saved;
   407		bool switched_pkey_reg = false;
   408	
   409		if (unlikely(t->flags & PF_EXITING))
   410			return;
   411	
   412	retry:
   413		/*
   414		 * regs is NULL if and only if the caller is in a syscall path.  Skip
   415		 * fixup and leave rseq_cs as is so that rseq_sycall() will detect and
   416		 * kill a misbehaving userspace on debug kernels.
   417		 */
   418		if (regs) {
   419			ret = rseq_ip_fixup(regs);
   420			if (unlikely(ret < 0))
   421				goto error;
   422		}
   423		if (unlikely(rseq_update_cpu_node_id(t)))
   424			goto error;
   425		if (switched_pkey_reg)
 > 426			write_pkey_reg(saved);
   427		return;
   428	
   429	error:
   430		/*
   431		 * If the application registers rseq, and ever switches to another
   432		 * pkey protection (such that the rseq becomes inaccessible), then
   433		 * any context switch will cause failure here attemping to read/write
   434		 * struct rseq and/or rseq_cs. Since context switches are
   435		 * asynchronous and are outside of the application control
   436		 * (not part of the restricted code scope), we temporarily switch
   437		 * to premissive pkey register to read/write rseq/rseq_cs,
   438		 * similarly to signal delivery.
   439		 *
   440		 * We don't bother to check if the failure really happened due to
   441		 * pkeys or not, since it does not matter (performance-wise and
   442		 * otherwise).
   443		 *
   444		 * If the restricted code installs rseq_cs in inaccessible to it
   445		 * due to pkeys page, we still let this function read the rseq_cs.
   446		 * It's unclear what benefits the resticted code gets by doing this
   447		 * (it probably already hijacked control flow at this point), and
   448		 * presumably any sane sandbox should prohibit restricted code
   449		 * from accessing struct rseq, and this is still better than
   450		 * terminating the app unconditionally (it always has a choice
   451		 * of not using rseq and pkeys together).
   452		 */
   453		if (!switched_pkey_reg) {
   454			switched_pkey_reg = true;
 > 455			saved = switch_to_permissive_pkey_reg();
   456			goto retry;
   457		} else {
   458			write_pkey_reg(saved);
   459		}
   460		sig = ksig ? ksig->sig : 0;
   461		force_sigsegv(sig);
   462	}
   463	

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

                 reply	other threads:[~2025-02-08 12:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202502082017.0GixUctp-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=dvyukov@google.com \
    --cc=oe-kbuild-all@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.