hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/include/linux/signal.h
....@@ -11,17 +11,29 @@
1111 /* for sysctl */
1212 extern int print_fatal_signals;
1313
14
-static inline void copy_siginfo(struct siginfo *to, const struct siginfo *from)
14
+static inline void copy_siginfo(kernel_siginfo_t *to,
15
+ const kernel_siginfo_t *from)
1516 {
1617 memcpy(to, from, sizeof(*to));
1718 }
1819
19
-static inline void clear_siginfo(struct siginfo *info)
20
+static inline void clear_siginfo(kernel_siginfo_t *info)
2021 {
2122 memset(info, 0, sizeof(*info));
2223 }
2324
24
-int copy_siginfo_to_user(struct siginfo __user *to, const struct siginfo *from);
25
+#define SI_EXPANSION_SIZE (sizeof(struct siginfo) - sizeof(struct kernel_siginfo))
26
+
27
+static inline void copy_siginfo_to_external(siginfo_t *to,
28
+ const kernel_siginfo_t *from)
29
+{
30
+ memcpy(to, from, sizeof(*from));
31
+ memset(((char *)to) + sizeof(struct kernel_siginfo), 0,
32
+ SI_EXPANSION_SIZE);
33
+}
34
+
35
+int copy_siginfo_to_user(siginfo_t __user *to, const kernel_siginfo_t *from);
36
+int copy_siginfo_from_user(kernel_siginfo_t *to, const siginfo_t __user *from);
2537
2638 enum siginfo_layout {
2739 SIL_KILL,
....@@ -125,9 +137,11 @@
125137 b3 = b->sig[3]; b2 = b->sig[2]; \
126138 r->sig[3] = op(a3, b3); \
127139 r->sig[2] = op(a2, b2); \
140
+ fallthrough; \
128141 case 2: \
129142 a1 = a->sig[1]; b1 = b->sig[1]; \
130143 r->sig[1] = op(a1, b1); \
144
+ fallthrough; \
131145 case 1: \
132146 a0 = a->sig[0]; b0 = b->sig[0]; \
133147 r->sig[0] = op(a0, b0); \
....@@ -157,7 +171,9 @@
157171 switch (_NSIG_WORDS) { \
158172 case 4: set->sig[3] = op(set->sig[3]); \
159173 set->sig[2] = op(set->sig[2]); \
174
+ fallthrough; \
160175 case 2: set->sig[1] = op(set->sig[1]); \
176
+ fallthrough; \
161177 case 1: set->sig[0] = op(set->sig[0]); \
162178 break; \
163179 default: \
....@@ -178,6 +194,7 @@
178194 memset(set, 0, sizeof(sigset_t));
179195 break;
180196 case 2: set->sig[1] = 0;
197
+ fallthrough;
181198 case 1: set->sig[0] = 0;
182199 break;
183200 }
....@@ -190,6 +207,7 @@
190207 memset(set, -1, sizeof(sigset_t));
191208 break;
192209 case 2: set->sig[1] = -1;
210
+ fallthrough;
193211 case 1: set->sig[0] = -1;
194212 break;
195213 }
....@@ -220,6 +238,7 @@
220238 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
221239 break;
222240 case 2: set->sig[1] = 0;
241
+ break;
223242 case 1: ;
224243 }
225244 }
....@@ -232,6 +251,7 @@
232251 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
233252 break;
234253 case 2: set->sig[1] = -1;
254
+ break;
235255 case 1: ;
236256 }
237257 }
....@@ -257,11 +277,11 @@
257277 enum pid_type;
258278
259279 extern int next_signal(struct sigpending *pending, sigset_t *mask);
260
-extern int do_send_sig_info(int sig, struct siginfo *info,
280
+extern int do_send_sig_info(int sig, struct kernel_siginfo *info,
261281 struct task_struct *p, enum pid_type type);
262
-extern int group_send_sig_info(int sig, struct siginfo *info,
282
+extern int group_send_sig_info(int sig, struct kernel_siginfo *info,
263283 struct task_struct *p, enum pid_type type);
264
-extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
284
+extern int __group_send_sig_info(int, struct kernel_siginfo *, struct task_struct *);
265285 extern int sigprocmask(int, sigset_t *, sigset_t *);
266286 extern void set_current_blocked(sigset_t *);
267287 extern void __set_current_blocked(const sigset_t *);
....@@ -391,7 +411,7 @@
391411 #endif
392412
393413 #define siginmask(sig, mask) \
394
- ((sig) < SIGRTMIN && (rt_sigmask(sig) & (mask)))
414
+ ((sig) > 0 && (sig) < SIGRTMIN && (rt_sigmask(sig) & (mask)))
395415
396416 #define SIG_KERNEL_ONLY_MASK (\
397417 rt_sigmask(SIGKILL) | rt_sigmask(SIGSTOP))
....@@ -434,12 +454,12 @@
434454 int restore_altstack(const stack_t __user *);
435455 int __save_altstack(stack_t __user *, unsigned long);
436456
437
-#define save_altstack_ex(uss, sp) do { \
457
+#define unsafe_save_altstack(uss, sp, label) do { \
438458 stack_t __user *__uss = uss; \
439459 struct task_struct *t = current; \
440
- put_user_ex((void __user *)t->sas_ss_sp, &__uss->ss_sp); \
441
- put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \
442
- put_user_ex(t->sas_ss_size, &__uss->ss_size); \
460
+ unsafe_put_user((void __user *)t->sas_ss_sp, &__uss->ss_sp, label); \
461
+ unsafe_put_user(t->sas_ss_flags, &__uss->ss_flags, label); \
462
+ unsafe_put_user(t->sas_ss_size, &__uss->ss_size, label); \
443463 if (t->sas_ss_flags & SS_AUTODISARM) \
444464 sas_ss_reset(t); \
445465 } while (0);
....@@ -449,4 +469,18 @@
449469 extern void render_sigset_t(struct seq_file *, const char *, sigset_t *);
450470 #endif
451471
472
+#ifndef arch_untagged_si_addr
473
+/*
474
+ * Given a fault address and a signal and si_code which correspond to the
475
+ * _sigfault union member, returns the address that must appear in si_addr if
476
+ * the signal handler does not have SA_EXPOSE_TAGBITS enabled in sa_flags.
477
+ */
478
+static inline void __user *arch_untagged_si_addr(void __user *addr,
479
+ unsigned long sig,
480
+ unsigned long si_code)
481
+{
482
+ return addr;
483
+}
484
+#endif
485
+
452486 #endif /* _LINUX_SIGNAL_H */