hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/m68k/kernel/signal.c
....@@ -47,7 +47,6 @@
4747
4848 #include <asm/setup.h>
4949 #include <linux/uaccess.h>
50
-#include <asm/pgtable.h>
5150 #include <asm/traps.h>
5251 #include <asm/ucontext.h>
5352 #include <asm/cacheflush.h>
....@@ -62,25 +61,25 @@
6261 #define FMT4SIZE 0
6362 #else
6463 #define FORMAT 0
65
-#define FMT4SIZE sizeof(((struct frame *)0)->un.fmt4)
64
+#define FMT4SIZE sizeof_field(struct frame, un.fmt4)
6665 #endif
6766
6867 static const int frame_size_change[16] = {
69
- [1] = -1, /* sizeof(((struct frame *)0)->un.fmt1), */
70
- [2] = sizeof(((struct frame *)0)->un.fmt2),
71
- [3] = sizeof(((struct frame *)0)->un.fmt3),
68
+ [1] = -1, /* sizeof_field(struct frame, un.fmt1), */
69
+ [2] = sizeof_field(struct frame, un.fmt2),
70
+ [3] = sizeof_field(struct frame, un.fmt3),
7271 [4] = FMT4SIZE,
73
- [5] = -1, /* sizeof(((struct frame *)0)->un.fmt5), */
74
- [6] = -1, /* sizeof(((struct frame *)0)->un.fmt6), */
75
- [7] = sizeof(((struct frame *)0)->un.fmt7),
76
- [8] = -1, /* sizeof(((struct frame *)0)->un.fmt8), */
77
- [9] = sizeof(((struct frame *)0)->un.fmt9),
78
- [10] = sizeof(((struct frame *)0)->un.fmta),
79
- [11] = sizeof(((struct frame *)0)->un.fmtb),
80
- [12] = -1, /* sizeof(((struct frame *)0)->un.fmtc), */
81
- [13] = -1, /* sizeof(((struct frame *)0)->un.fmtd), */
82
- [14] = -1, /* sizeof(((struct frame *)0)->un.fmte), */
83
- [15] = -1, /* sizeof(((struct frame *)0)->un.fmtf), */
72
+ [5] = -1, /* sizeof_field(struct frame, un.fmt5), */
73
+ [6] = -1, /* sizeof_field(struct frame, un.fmt6), */
74
+ [7] = sizeof_field(struct frame, un.fmt7),
75
+ [8] = -1, /* sizeof_field(struct frame, un.fmt8), */
76
+ [9] = sizeof_field(struct frame, un.fmt9),
77
+ [10] = sizeof_field(struct frame, un.fmta),
78
+ [11] = sizeof_field(struct frame, un.fmtb),
79
+ [12] = -1, /* sizeof_field(struct frame, un.fmtc), */
80
+ [13] = -1, /* sizeof_field(struct frame, un.fmtd), */
81
+ [14] = -1, /* sizeof_field(struct frame, un.fmte), */
82
+ [15] = -1, /* sizeof_field(struct frame, un.fmtf), */
8483 };
8584
8685 static inline int frame_extra_sizes(int f)
....@@ -651,7 +650,8 @@
651650 regs->vector = formatvec & 0xfff;
652651 } else {
653652 struct switch_stack *sw = (struct switch_stack *)regs - 1;
654
- unsigned long buf[fsize / 2]; /* yes, twice as much */
653
+ /* yes, twice as much as max(sizeof(frame.un.fmt<x>)) */
654
+ unsigned long buf[sizeof_field(struct frame, un) / 2];
655655
656656 /* that'll make sure that expansion won't crap over data */
657657 if (copy_from_user(buf + fsize / 4, fp, fsize))
....@@ -787,7 +787,7 @@
787787 struct sigframe __user *frame = (struct sigframe __user *)(usp - 4);
788788 sigset_t set;
789789
790
- if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
790
+ if (!access_ok(frame, sizeof(*frame)))
791791 goto badframe;
792792 if (__get_user(set.sig[0], &frame->sc.sc_mask) ||
793793 (_NSIG_WORDS > 1 &&
....@@ -802,7 +802,7 @@
802802 return regs->d0;
803803
804804 badframe:
805
- force_sig(SIGSEGV, current);
805
+ force_sig(SIGSEGV);
806806 return 0;
807807 }
808808
....@@ -812,7 +812,7 @@
812812 struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(usp - 4);
813813 sigset_t set;
814814
815
- if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
815
+ if (!access_ok(frame, sizeof(*frame)))
816816 goto badframe;
817817 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
818818 goto badframe;
....@@ -824,7 +824,7 @@
824824 return regs->d0;
825825
826826 badframe:
827
- force_sig(SIGSEGV, current);
827
+ force_sig(SIGSEGV);
828828 return 0;
829829 }
830830
....@@ -882,11 +882,17 @@
882882 }
883883
884884 static inline void __user *
885
-get_sigframe(struct ksignal *ksig, size_t frame_size)
885
+get_sigframe(struct ksignal *ksig, struct pt_regs *tregs, size_t frame_size)
886886 {
887887 unsigned long usp = sigsp(rdusp(), ksig);
888
+ unsigned long gap = 0;
888889
889
- return (void __user *)((usp - frame_size) & -8UL);
890
+ if (CPU_IS_020_OR_030 && tregs->format == 0xb) {
891
+ /* USP is unreliable so use worst-case value */
892
+ gap = 256;
893
+ }
894
+
895
+ return (void __user *)((usp - gap - frame_size) & -8UL);
890896 }
891897
892898 static int setup_frame(struct ksignal *ksig, sigset_t *set,
....@@ -904,7 +910,7 @@
904910 return -EFAULT;
905911 }
906912
907
- frame = get_sigframe(ksig, sizeof(*frame) + fsize);
913
+ frame = get_sigframe(ksig, tregs, sizeof(*frame) + fsize);
908914
909915 if (fsize)
910916 err |= copy_to_user (frame + 1, regs + 1, fsize);
....@@ -928,7 +934,8 @@
928934 err |= __put_user(0x70004e40 + (__NR_sigreturn << 16),
929935 (long __user *)(frame->retcode));
930936 #else
931
- err |= __put_user((void *) ret_from_user_signal, &frame->pretcode);
937
+ err |= __put_user((long) ret_from_user_signal,
938
+ (long __user *) &frame->pretcode);
932939 #endif
933940
934941 if (err)
....@@ -975,7 +982,7 @@
975982 return -EFAULT;
976983 }
977984
978
- frame = get_sigframe(ksig, sizeof(*frame));
985
+ frame = get_sigframe(ksig, tregs, sizeof(*frame));
979986
980987 if (fsize)
981988 err |= copy_to_user (&frame->uc.uc_extra, regs + 1, fsize);
....@@ -1007,7 +1014,8 @@
10071014 err |= __put_user(0x4e40, (short __user *)(frame->retcode + 4));
10081015 #endif
10091016 #else
1010
- err |= __put_user((void *) ret_from_user_rt_signal, &frame->pretcode);
1017
+ err |= __put_user((long) ret_from_user_rt_signal,
1018
+ (long __user *) &frame->pretcode);
10111019 #endif /* CONFIG_MMU */
10121020
10131021 if (err)
....@@ -1063,7 +1071,7 @@
10631071 regs->d0 = -EINTR;
10641072 break;
10651073 }
1066
- /* fallthrough */
1074
+ fallthrough;
10671075 case -ERESTARTNOINTR:
10681076 do_restart:
10691077 regs->d0 = regs->orig_d0;
....@@ -1127,9 +1135,10 @@
11271135
11281136 void do_notify_resume(struct pt_regs *regs)
11291137 {
1130
- if (test_thread_flag(TIF_SIGPENDING))
1138
+ if (test_thread_flag(TIF_NOTIFY_SIGNAL) ||
1139
+ test_thread_flag(TIF_SIGPENDING))
11311140 do_signal(regs);
11321141
1133
- if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME))
1142
+ if (test_thread_flag(TIF_NOTIFY_RESUME))
11341143 tracehook_notify_resume(regs);
11351144 }