Commit a0e31f3a authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'for-v5.13-rc3' of...

Merge branch 'for-v5.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace

Pull siginfo fix from Eric Biederman:
 "During the merge window an issue with si_perf and the siginfo ABI came
  up. The alpha and sparc siginfo structure layout had changed with the
  addition of SIGTRAP TRAP_PERF and the new field si_perf.

  The reason only alpha and sparc were affected is that they are the
  only architectures that use si_trapno.

  Looking deeper it was discovered that si_trapno is used for only a few
  select signals on alpha and sparc, and that none of the other
  _sigfault fields past si_addr are used at all. Which means technically
  no regression on alpha and sparc.

  While the alignment concerns might be dismissed the abuse of si_errno
  by SIGTRAP TRAP_PERF does have the potential to cause regressions in
  existing userspace.

  While we still have time before userspace starts using and depending
  on the new definition siginfo for SIGTRAP TRAP_PERF this set of
  changes cleans up siginfo_t.

   - The si_trapno field is demoted from magic alpha and sparc status
     and made an ordinary union member of the _sigfault member of
     siginfo_t. Without moving it of course.

   - si_perf is replaced with si_perf_data and si_perf_type ending the
     abuse of si_errno.

   - Unnecessary additions to signalfd_siginfo are removed"

* 'for-v5.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
  signalfd: Remove SIL_PERF_EVENT fields from signalfd_siginfo
  signal: Deliver all of the siginfo perf data in _perf
  signal: Factor force_sig_perf out of perf_sigtrap
  signal: Implement SIL_FAULT_TRAPNO
  siginfo: Move si_trapno inside the union inside _si_fault
parents c1f47ebc 922e3013
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -623,7 +623,8 @@ static inline void siginfo_build_tests(void)
	BUILD_BUG_ON(offsetof(siginfo_t, si_pkey) != 0x12);

	/* _sigfault._perf */
	BUILD_BUG_ON(offsetof(siginfo_t, si_perf) != 0x10);
	BUILD_BUG_ON(offsetof(siginfo_t, si_perf_data) != 0x10);
	BUILD_BUG_ON(offsetof(siginfo_t, si_perf_type) != 0x14);

	/* _sigpoll */
	BUILD_BUG_ON(offsetof(siginfo_t, si_band)   != 0x0c);
+7 −2
Original line number Diff line number Diff line
@@ -127,6 +127,9 @@ static inline void signal_compat_build_tests(void)
	BUILD_BUG_ON(offsetof(siginfo_t, si_addr) != 0x10);
	BUILD_BUG_ON(offsetof(compat_siginfo_t, si_addr) != 0x0C);

	BUILD_BUG_ON(offsetof(siginfo_t, si_trapno) != 0x18);
	BUILD_BUG_ON(offsetof(compat_siginfo_t, si_trapno) != 0x10);

	BUILD_BUG_ON(offsetof(siginfo_t, si_addr_lsb) != 0x18);
	BUILD_BUG_ON(offsetof(compat_siginfo_t, si_addr_lsb) != 0x10);

@@ -138,8 +141,10 @@ static inline void signal_compat_build_tests(void)
	BUILD_BUG_ON(offsetof(siginfo_t, si_pkey) != 0x20);
	BUILD_BUG_ON(offsetof(compat_siginfo_t, si_pkey) != 0x14);

	BUILD_BUG_ON(offsetof(siginfo_t, si_perf) != 0x18);
	BUILD_BUG_ON(offsetof(compat_siginfo_t, si_perf) != 0x10);
	BUILD_BUG_ON(offsetof(siginfo_t, si_perf_data) != 0x18);
	BUILD_BUG_ON(offsetof(siginfo_t, si_perf_type) != 0x20);
	BUILD_BUG_ON(offsetof(compat_siginfo_t, si_perf_data) != 0x10);
	BUILD_BUG_ON(offsetof(compat_siginfo_t, si_perf_type) != 0x14);

	CHECK_CSI_OFFSET(_sigpoll);
	CHECK_CSI_SIZE  (_sigpoll, 2*sizeof(int));
+9 −14
Original line number Diff line number Diff line
@@ -114,29 +114,24 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo,
		break;
	case SIL_FAULT_BNDERR:
	case SIL_FAULT_PKUERR:
	case SIL_PERF_EVENT:
		/*
		 * Fall through to the SIL_FAULT case.  Both SIL_FAULT_BNDERR
		 * and SIL_FAULT_PKUERR are only generated by faults that
		 * deliver them synchronously to userspace.  In case someone
		 * injects one of these signals and signalfd catches it treat
		 * it as SIL_FAULT.
		 * Fall through to the SIL_FAULT case.  SIL_FAULT_BNDERR,
		 * SIL_FAULT_PKUERR, and SIL_PERF_EVENT are only
		 * generated by faults that deliver them synchronously to
		 * userspace.  In case someone injects one of these signals
		 * and signalfd catches it treat it as SIL_FAULT.
		 */
	case SIL_FAULT:
		new.ssi_addr = (long) kinfo->si_addr;
#ifdef __ARCH_SI_TRAPNO
		new.ssi_trapno = kinfo->si_trapno;
#endif
		break;
	case SIL_FAULT_MCEERR:
	case SIL_FAULT_TRAPNO:
		new.ssi_addr = (long) kinfo->si_addr;
#ifdef __ARCH_SI_TRAPNO
		new.ssi_trapno = kinfo->si_trapno;
#endif
		new.ssi_addr_lsb = (short) kinfo->si_addr_lsb;
		break;
	case SIL_PERF_EVENT:
	case SIL_FAULT_MCEERR:
		new.ssi_addr = (long) kinfo->si_addr;
		new.ssi_perf = kinfo->si_perf;
		new.ssi_addr_lsb = (short) kinfo->si_addr_lsb;
		break;
	case SIL_CHLD:
		new.ssi_pid    = kinfo->si_pid;
+6 −4
Original line number Diff line number Diff line
@@ -213,12 +213,11 @@ typedef struct compat_siginfo {
		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
		struct {
			compat_uptr_t _addr;	/* faulting insn/memory ref. */
#ifdef __ARCH_SI_TRAPNO
			int _trapno;	/* TRAP # which caused the signal */
#endif
#define __COMPAT_ADDR_BND_PKEY_PAD  (__alignof__(compat_uptr_t) < sizeof(short) ? \
				     sizeof(short) : __alignof__(compat_uptr_t))
			union {
				/* used on alpha and sparc */
				int _trapno;	/* TRAP # which caused the signal */
				/*
				 * used when si_code=BUS_MCEERR_AR or
				 * used when si_code=BUS_MCEERR_AO
@@ -236,7 +235,10 @@ typedef struct compat_siginfo {
					u32 _pkey;
				} _addr_pkey;
				/* used when si_code=TRAP_PERF */
				compat_ulong_t _perf;
				struct {
					compat_ulong_t _data;
					u32 _type;
				} _perf;
			};
		} _sigfault;

+1 −0
Original line number Diff line number Diff line
@@ -326,6 +326,7 @@ int send_sig_mceerr(int code, void __user *, short, struct task_struct *);

int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper);
int force_sig_pkuerr(void __user *addr, u32 pkey);
int force_sig_perf(void __user *addr, u32 type, u64 sig_data);

int force_sig_ptrace_errno_trap(int errno, void __user *addr);

Loading