@@ -3235,94 +3235,94 @@ int copy_siginfo_from_user(kernel_siginfo_t *to, const siginfo_t __user *from)
3235
3235
}
3236
3236
3237
3237
#ifdef CONFIG_COMPAT
3238
- int copy_siginfo_to_user32 (struct compat_siginfo __user * to ,
3239
- const struct kernel_siginfo * from )
3240
- #if defined(CONFIG_X86_X32_ABI ) || defined(CONFIG_IA32_EMULATION )
3241
- {
3242
- return __copy_siginfo_to_user32 (to , from , in_x32_syscall ());
3243
- }
3244
- int __copy_siginfo_to_user32 (struct compat_siginfo __user * to ,
3245
- const struct kernel_siginfo * from , bool x32_ABI )
3246
- #endif
3238
+ /**
3239
+ * copy_siginfo_to_external32 - copy a kernel siginfo into a compat user siginfo
3240
+ * @to: compat siginfo destination
3241
+ * @from: kernel siginfo source
3242
+ *
3243
+ * Note: This function does not work properly for the SIGCHLD on x32, but
3244
+ * fortunately it doesn't have to. The only valid callers for this function are
3245
+ * copy_siginfo_to_user32, which is overriden for x32 and the coredump code.
3246
+ * The latter does not care because SIGCHLD will never cause a coredump.
3247
+ */
3248
+ void copy_siginfo_to_external32 (struct compat_siginfo * to ,
3249
+ const struct kernel_siginfo * from )
3247
3250
{
3248
- struct compat_siginfo new ;
3249
- memset (& new , 0 , sizeof (new ));
3251
+ memset (to , 0 , sizeof (* to ));
3250
3252
3251
- new . si_signo = from -> si_signo ;
3252
- new . si_errno = from -> si_errno ;
3253
- new . si_code = from -> si_code ;
3253
+ to -> si_signo = from -> si_signo ;
3254
+ to -> si_errno = from -> si_errno ;
3255
+ to -> si_code = from -> si_code ;
3254
3256
switch (siginfo_layout (from -> si_signo , from -> si_code )) {
3255
3257
case SIL_KILL :
3256
- new . si_pid = from -> si_pid ;
3257
- new . si_uid = from -> si_uid ;
3258
+ to -> si_pid = from -> si_pid ;
3259
+ to -> si_uid = from -> si_uid ;
3258
3260
break ;
3259
3261
case SIL_TIMER :
3260
- new . si_tid = from -> si_tid ;
3261
- new . si_overrun = from -> si_overrun ;
3262
- new . si_int = from -> si_int ;
3262
+ to -> si_tid = from -> si_tid ;
3263
+ to -> si_overrun = from -> si_overrun ;
3264
+ to -> si_int = from -> si_int ;
3263
3265
break ;
3264
3266
case SIL_POLL :
3265
- new . si_band = from -> si_band ;
3266
- new . si_fd = from -> si_fd ;
3267
+ to -> si_band = from -> si_band ;
3268
+ to -> si_fd = from -> si_fd ;
3267
3269
break ;
3268
3270
case SIL_FAULT :
3269
- new . si_addr = ptr_to_compat (from -> si_addr );
3271
+ to -> si_addr = ptr_to_compat (from -> si_addr );
3270
3272
#ifdef __ARCH_SI_TRAPNO
3271
- new . si_trapno = from -> si_trapno ;
3273
+ to -> si_trapno = from -> si_trapno ;
3272
3274
#endif
3273
3275
break ;
3274
3276
case SIL_FAULT_MCEERR :
3275
- new . si_addr = ptr_to_compat (from -> si_addr );
3277
+ to -> si_addr = ptr_to_compat (from -> si_addr );
3276
3278
#ifdef __ARCH_SI_TRAPNO
3277
- new . si_trapno = from -> si_trapno ;
3279
+ to -> si_trapno = from -> si_trapno ;
3278
3280
#endif
3279
- new . si_addr_lsb = from -> si_addr_lsb ;
3281
+ to -> si_addr_lsb = from -> si_addr_lsb ;
3280
3282
break ;
3281
3283
case SIL_FAULT_BNDERR :
3282
- new . si_addr = ptr_to_compat (from -> si_addr );
3284
+ to -> si_addr = ptr_to_compat (from -> si_addr );
3283
3285
#ifdef __ARCH_SI_TRAPNO
3284
- new . si_trapno = from -> si_trapno ;
3286
+ to -> si_trapno = from -> si_trapno ;
3285
3287
#endif
3286
- new . si_lower = ptr_to_compat (from -> si_lower );
3287
- new . si_upper = ptr_to_compat (from -> si_upper );
3288
+ to -> si_lower = ptr_to_compat (from -> si_lower );
3289
+ to -> si_upper = ptr_to_compat (from -> si_upper );
3288
3290
break ;
3289
3291
case SIL_FAULT_PKUERR :
3290
- new . si_addr = ptr_to_compat (from -> si_addr );
3292
+ to -> si_addr = ptr_to_compat (from -> si_addr );
3291
3293
#ifdef __ARCH_SI_TRAPNO
3292
- new . si_trapno = from -> si_trapno ;
3294
+ to -> si_trapno = from -> si_trapno ;
3293
3295
#endif
3294
- new . si_pkey = from -> si_pkey ;
3296
+ to -> si_pkey = from -> si_pkey ;
3295
3297
break ;
3296
3298
case SIL_CHLD :
3297
- new .si_pid = from -> si_pid ;
3298
- new .si_uid = from -> si_uid ;
3299
- new .si_status = from -> si_status ;
3300
- #ifdef CONFIG_X86_X32_ABI
3301
- if (x32_ABI ) {
3302
- new ._sifields ._sigchld_x32 ._utime = from -> si_utime ;
3303
- new ._sifields ._sigchld_x32 ._stime = from -> si_stime ;
3304
- } else
3305
- #endif
3306
- {
3307
- new .si_utime = from -> si_utime ;
3308
- new .si_stime = from -> si_stime ;
3309
- }
3299
+ to -> si_pid = from -> si_pid ;
3300
+ to -> si_uid = from -> si_uid ;
3301
+ to -> si_status = from -> si_status ;
3302
+ to -> si_utime = from -> si_utime ;
3303
+ to -> si_stime = from -> si_stime ;
3310
3304
break ;
3311
3305
case SIL_RT :
3312
- new . si_pid = from -> si_pid ;
3313
- new . si_uid = from -> si_uid ;
3314
- new . si_int = from -> si_int ;
3306
+ to -> si_pid = from -> si_pid ;
3307
+ to -> si_uid = from -> si_uid ;
3308
+ to -> si_int = from -> si_int ;
3315
3309
break ;
3316
3310
case SIL_SYS :
3317
- new . si_call_addr = ptr_to_compat (from -> si_call_addr );
3318
- new . si_syscall = from -> si_syscall ;
3319
- new . si_arch = from -> si_arch ;
3311
+ to -> si_call_addr = ptr_to_compat (from -> si_call_addr );
3312
+ to -> si_syscall = from -> si_syscall ;
3313
+ to -> si_arch = from -> si_arch ;
3320
3314
break ;
3321
3315
}
3316
+ }
3322
3317
3318
+ int __copy_siginfo_to_user32 (struct compat_siginfo __user * to ,
3319
+ const struct kernel_siginfo * from )
3320
+ {
3321
+ struct compat_siginfo new ;
3322
+
3323
+ copy_siginfo_to_external32 (& new , from );
3323
3324
if (copy_to_user (to , & new , sizeof (struct compat_siginfo )))
3324
3325
return - EFAULT ;
3325
-
3326
3326
return 0 ;
3327
3327
}
3328
3328
0 commit comments