hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
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 }
....@@ -258,11 +278,11 @@
258278 enum pid_type;
259279
260280 extern int next_signal(struct sigpending *pending, sigset_t *mask);
261
-extern int do_send_sig_info(int sig, struct siginfo *info,
281
+extern int do_send_sig_info(int sig, struct kernel_siginfo *info,
262282 struct task_struct *p, enum pid_type type);
263
-extern int group_send_sig_info(int sig, struct siginfo *info,
283
+extern int group_send_sig_info(int sig, struct kernel_siginfo *info,
264284 struct task_struct *p, enum pid_type type);
265
-extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
285
+extern int __group_send_sig_info(int, struct kernel_siginfo *, struct task_struct *);
266286 extern int sigprocmask(int, sigset_t *, sigset_t *);
267287 extern void set_current_blocked(sigset_t *);
268288 extern void __set_current_blocked(const sigset_t *);
....@@ -392,7 +412,7 @@
392412 #endif
393413
394414 #define siginmask(sig, mask) \
395
- ((sig) < SIGRTMIN && (rt_sigmask(sig) & (mask)))
415
+ ((sig) > 0 && (sig) < SIGRTMIN && (rt_sigmask(sig) & (mask)))
396416
397417 #define SIG_KERNEL_ONLY_MASK (\
398418 rt_sigmask(SIGKILL) | rt_sigmask(SIGSTOP))
....@@ -435,12 +455,12 @@
435455 int restore_altstack(const stack_t __user *);
436456 int __save_altstack(stack_t __user *, unsigned long);
437457
438
-#define save_altstack_ex(uss, sp) do { \
458
+#define unsafe_save_altstack(uss, sp, label) do { \
439459 stack_t __user *__uss = uss; \
440460 struct task_struct *t = current; \
441
- put_user_ex((void __user *)t->sas_ss_sp, &__uss->ss_sp); \
442
- put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \
443
- put_user_ex(t->sas_ss_size, &__uss->ss_size); \
461
+ unsafe_put_user((void __user *)t->sas_ss_sp, &__uss->ss_sp, label); \
462
+ unsafe_put_user(t->sas_ss_flags, &__uss->ss_flags, label); \
463
+ unsafe_put_user(t->sas_ss_size, &__uss->ss_size, label); \
444464 if (t->sas_ss_flags & SS_AUTODISARM) \
445465 sas_ss_reset(t); \
446466 } while (0);
....@@ -450,4 +470,18 @@
450470 extern void render_sigset_t(struct seq_file *, const char *, sigset_t *);
451471 #endif
452472
473
+#ifndef arch_untagged_si_addr
474
+/*
475
+ * Given a fault address and a signal and si_code which correspond to the
476
+ * _sigfault union member, returns the address that must appear in si_addr if
477
+ * the signal handler does not have SA_EXPOSE_TAGBITS enabled in sa_flags.
478
+ */
479
+static inline void __user *arch_untagged_si_addr(void __user *addr,
480
+ unsigned long sig,
481
+ unsigned long si_code)
482
+{
483
+ return addr;
484
+}
485
+#endif
486
+
453487 #endif /* _LINUX_SIGNAL_H */