aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Getz <robin.getz@analog.com>2010-07-09 13:29:26 -0400
committerMike Frysinger <vapier@gentoo.org>2010-10-22 03:48:55 -0400
commitc0ab9387456d7660dead96ce1b5463741f087db1 (patch)
treed14c3893db3f35db1f856c59dbe68781f954b310
parent3d7dc8836a0f08cbe6d8d499ddce05809b687f58 (diff)
Blackfin: workaround anomaly 05000481 (corruption with ITEST MMRs)
Nothing actually needs to use these MMRs (as direct cache manipulation is done with the DTEST MMRs), so simply hide the read funcs behind the anomaly define. They're generally unusable anyways when this anomaly is in effect. Signed-off-by: Robin Getz <robin.getz@analog.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--arch/blackfin/include/asm/cdef_LPBlackfin.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/blackfin/include/asm/cdef_LPBlackfin.h b/arch/blackfin/include/asm/cdef_LPBlackfin.h
index 6c39d94b44d0..a1f6817687e8 100644
--- a/arch/blackfin/include/asm/cdef_LPBlackfin.h
+++ b/arch/blackfin/include/asm/cdef_LPBlackfin.h
@@ -172,16 +172,19 @@
172#define bfin_write_ICPLB_DATA14(val) bfin_write32(ICPLB_DATA14,val) 172#define bfin_write_ICPLB_DATA14(val) bfin_write32(ICPLB_DATA14,val)
173#define bfin_read_ICPLB_DATA15() bfin_read32(ICPLB_DATA15) 173#define bfin_read_ICPLB_DATA15() bfin_read32(ICPLB_DATA15)
174#define bfin_write_ICPLB_DATA15(val) bfin_write32(ICPLB_DATA15,val) 174#define bfin_write_ICPLB_DATA15(val) bfin_write32(ICPLB_DATA15,val)
175#define bfin_read_ITEST_COMMAND() bfin_read32(ITEST_COMMAND)
176#define bfin_write_ITEST_COMMAND(val) bfin_write32(ITEST_COMMAND,val) 175#define bfin_write_ITEST_COMMAND(val) bfin_write32(ITEST_COMMAND,val)
177#if 0 176#if 0
178#define ITEST_INDEX 0xFFE01304 /* Instruction Test Index Register */ 177#define ITEST_INDEX 0xFFE01304 /* Instruction Test Index Register */
179#endif 178#endif
180#define bfin_read_ITEST_DATA0() bfin_read32(ITEST_DATA0)
181#define bfin_write_ITEST_DATA0(val) bfin_write32(ITEST_DATA0,val) 179#define bfin_write_ITEST_DATA0(val) bfin_write32(ITEST_DATA0,val)
182#define bfin_read_ITEST_DATA1() bfin_read32(ITEST_DATA1)
183#define bfin_write_ITEST_DATA1(val) bfin_write32(ITEST_DATA1,val) 180#define bfin_write_ITEST_DATA1(val) bfin_write32(ITEST_DATA1,val)
184 181
182#if ANOMALY_05000481
183#define bfin_read_ITEST_COMMAND() bfin_read32(ITEST_COMMAND)
184#define bfin_read_ITEST_DATA0() bfin_read32(ITEST_DATA0)
185#define bfin_read_ITEST_DATA1() bfin_read32(ITEST_DATA1)
186#endif
187
185/* Event/Interrupt Registers*/ 188/* Event/Interrupt Registers*/
186 189
187#define bfin_read_EVT0() bfin_read32(EVT0) 190#define bfin_read_EVT0() bfin_read32(EVT0)
:12 -0400 recalc_sigpending_tsk fixes' href='/cgit/cgit.cgi/litmus-rt-tegra.git/commit/kernel/signal.c?id=7bb44adef39ad3bda2be40bb34686bc56bd563a5'>7bb44adef39
b74d0deb968




7bb44adef39










1da177e4c3f



b787f7ba677


b74d0deb968

1da177e4c3f



a27341cd5fc



fba2afaaec7
1da177e4c3f


f84d49b218b
1da177e4c3f

a27341cd5fc












1da177e4c3f

a27341cd5fc






1da177e4c3f

a27341cd5fc


1da177e4c3f
a27341cd5fc
1da177e4c3f

a27341cd5fc

1da177e4c3f

f84d49b218b
1da177e4c3f


f84d49b218b













c69e8d9c01d


d84f4f992cb
c69e8d9c01d
f84d49b218b

1da177e4c3f

10b1fbdb0a0
1da177e4c3f
10b1fbdb0a0
7cf7db8df0b

10b1fbdb0a0
7cf7db8df0b
d84f4f992cb
10b1fbdb0a0
7cf7db8df0b
f84d49b218b
1da177e4c3f
10b1fbdb0a0
78d7d407b62
1da177e4c3f
f84d49b218b



1da177e4c3f
10b1fbdb0a0
d84f4f992cb
1da177e4c3f


d84f4f992cb
1da177e4c3f
d84f4f992cb

1da177e4c3f

514a01b880d
1da177e4c3f







6a14c5c9da0
1da177e4c3f













3bcac0263f0






c81addc9d3a
1da177e4c3f



3bcac0263f0
1da177e4c3f


cbaffba12ce

































10ab825bdef









1da177e4c3f
1da177e4c3f
















abd4f7505ba

445a91d2fe3
b460cbc581a
abd4f7505ba
445a91d2fe3
abd4f7505ba
43918f2bf48
abd4f7505ba

1da177e4c3f


































100360f0307
1da177e4c3f

1da177e4c3f
1da177e4c3f





d4434207616

1da177e4c3f


d4434207616


1da177e4c3f
d4434207616
1da177e4c3f


1da177e4c3f
1da177e4c3f



1da177e4c3f

7486e5d9fc7
1da177e4c3f


1da177e4c3f




27d91e07f9b
1da177e4c3f
1da177e4c3f









100360f0307
1da177e4c3f
1da177e4c3f











c5363d03637
caec4e8dc85



b8fceee17a3
8bfd9a7a229
1da177e4c3f

8bfd9a7a229























c5363d03637
b8fceee17a3
c5363d03637



8bfd9a7a229











92413d771e7
8bfd9a7a229
c5363d03637
1da177e4c3f






























f021a3c2b14

1da177e4c3f





f021a3c2b14
1da177e4c3f








71fabd5e483


























1da177e4c3f


















614c517d7c0










1da177e4c3f

694f690d27d
1da177e4c3f



065add3941b
2e2ba22ea4f
3b5e9e53c6f

7ed20e1ad52
3b5e9e53c6f

614c517d7c0
3b5e9e53c6f
e54dc2431d7
3b5e9e53c6f

1da177e4c3f
3b5e9e53c6f
065add3941b
c69e8d9c01d
065add3941b

c69e8d9c01d


2e2ba22ea4f


2e2ba22ea4f
2e2ba22ea4f









c2f0c7c356d
e54dc2431d7
1da177e4c3f

1da177e4c3f
7e695a5ef5c

1da177e4c3f

7e695a5ef5c



1da177e4c3f
921cf9f6308
1da177e4c3f
ad16a460693
1da177e4c3f

7e695a5ef5c
1da177e4c3f
7e695a5ef5c
1da177e4c3f
7e695a5ef5c
1da177e4c3f


ad16a460693
1da177e4c3f


ad16a460693
1da177e4c3f
fc321d2e60d
1da177e4c3f



ad16a460693
1da177e4c3f



1da177e4c3f








fc321d2e60d
1da177e4c3f



f021a3c2b14
1da177e4c3f




ad16a460693
1da177e4c3f
fc321d2e60d








ad16a460693
fc321d2e60d
ad16a460693
fc321d2e60d


021e1ae3d85
ae6d2ed7bb3
021e1ae3d85


ad16a460693


1da177e4c3f





ad16a460693
1da177e4c3f
1da177e4c3f
7e695a5ef5c
921cf9f6308
1da177e4c3f

71f11dc0250




















5fcd835bf8c
71f11dc0250











5fcd835bf8c
71f11dc0250


























fae5fa44f1f

71f11dc0250
445a91d2fe3
43918f2bf48
71f11dc0250





























af7fff9c13d




7978b567d31

1da177e4c3f
2ca3515aa57
6e65acba7ca
7a0aeb14e18
1da177e4c3f
d1eb650ff41
0a16b607584
6e65acba7ca
921cf9f6308

7e695a5ef5c
2ca3515aa57

1da177e4c3f
2acb024d552



7e695a5ef5c
2acb024d552
fba2afaaec7
1da177e4c3f


b67a1b9e4bf
1da177e4c3f









7a0aeb14e18




f84d49b218b
7a0aeb14e18
1da177e4c3f
2ca3515aa57
1da177e4c3f
b67a1b9e4bf
1da177e4c3f


9cd4fd10437
09bca05c90c
76aac0e9a17
1da177e4c3f
b67a1b9e4bf
1da177e4c3f







6588c1e3ff0

1da177e4c3f

621d31219d9
ba005e1f417






1da177e4c3f
ba005e1f417






1da177e4c3f


53c30337f2c
2ca3515aa57
4cd4b6d4e03

1da177e4c3f

7978b567d31


921cf9f6308


dd34200adc0

921cf9f6308


7978b567d31

45807a1df9f


ba25f9dcc4e
45807a1df9f
ca5cd877ae6
65ea5b03499
45807a1df9f




b45c6e76bc2

45807a1df9f




3a9f84d354c
45807a1df9f
3a9f84d354c
45807a1df9f









1da177e4c3f
4cd4b6d4e03





1da177e4c3f


4cd4b6d4e03
1da177e4c3f

4a30debfb77













1da177e4c3f


ae74c3b69a0




80fe728d593

1da177e4c3f
1da177e4c3f



ae74c3b69a0

1da177e4c3f

ae74c3b69a0






7bb44adef39
ae74c3b69a0
1da177e4c3f
80fe728d593

1da177e4c3f





1da177e4c3f


09faef11df8
1da177e4c3f
09faef11df8

1da177e4c3f
1da177e4c3f

09faef11df8



1da177e4c3f

1da177e4c3f
1da177e4c3f

09faef11df8

1da177e4c3f

b8ed374e202

f63ee72e0fb


1406f2d321b
f63ee72e0fb









1406f2d321b
f63ee72e0fb



c69e8d9c01d

c69e8d9c01d
1da177e4c3f

694f690d27d




f63ee72e0fb
4a30debfb77

1da177e4c3f




146a505d498
1da177e4c3f
c69e8d9c01d
1da177e4c3f
c4b92fc112f
1da177e4c3f



1da177e4c3f

c4b92fc112f
1da177e4c3f


c4b92fc112f
1da177e4c3f


c4b92fc112f
1da177e4c3f
d36174bc2bc
1da177e4c3f

e56d090310d
d36174bc2bc
c4b92fc112f
d36174bc2bc
1da177e4c3f
d36174bc2bc








e56d090310d
6ca25b55130
1da177e4c3f


c3de4b38153

c4b92fc112f


b488893a390
c4b92fc112f



2425c08b372

8f95dc58d05
46113830a18


c69e8d9c01d
14d8c9f3c09
46113830a18



14d8c9f3c09
2425c08b372
46113830a18



c69e8d9c01d
614c517d7c0
c69e8d9c01d

46113830a18


8f95dc58d05


14d8c9f3c09






46113830a18

14d8c9f3c09
46113830a18

2425c08b372
1da177e4c3f







bc64efd220d
1da177e4c3f
8d42db189ca
d5df763b819












1da177e4c3f


1da177e4c3f
d25141a8183

1da177e4c3f





8d42db189ca
1da177e4c3f
d5df763b819

8d42db189ca
1da177e4c3f





1da177e4c3f


1da177e4c3f



7ed20e1ad52
1da177e4c3f

4a30debfb77
1da177e4c3f

b67a1b9e4bf


1da177e4c3f


b67a1b9e4bf
1da177e4c3f

1da177e4c3f


b67a1b9e4bf
1da177e4c3f




















c4b92fc112f

146a505d498






c4b92fc112f








1da177e4c3f



f84d49b218b
1da177e4c3f



1da177e4c3f

f84d49b218b
1da177e4c3f
f84d49b218b
1da177e4c3f
f84d49b218b

1da177e4c3f




60187d2708c

1da177e4c3f

c8e85b4f4b9

da7978b0348
1da177e4c3f
60187d2708c
c8e85b4f4b9




60187d2708c
c8e85b4f4b9
60187d2708c

c8e85b4f4b9

1da177e4c3f

ac5c215383f
9e3bd6c3fb2
e62e6650e99
2ca3515aa57
e62e6650e99

2ca3515aa57
4cd4b6d4e03
e62e6650e99




7e695a5ef5c
921cf9f6308
e62e6650e99


9e3bd6c3fb2




9e3bd6c3fb2

e62e6650e99
9e3bd6c3fb2
ba661292a2b
9e3bd6c3fb2
9e3bd6c3fb2
2ca3515aa57
9e3bd6c3fb2

4cd4b6d4e03
e62e6650e99



9e3bd6c3fb2

1da177e4c3f
1da177e4c3f

2b2a1ff64af


1da177e4c3f
2b2a1ff64af
1da177e4c3f



1b04624f93b
1da177e4c3f



e1abb39c609
1da177e4c3f
5cb11446892
1da177e4c3f



b488893a390













c69e8d9c01d
b488893a390

32bd671d6cb



1da177e4c3f












5cb11446892
1da177e4c3f
















1b04624f93b
1da177e4c3f
2b2a1ff64af
1da177e4c3f
7ed20e1ad52
1da177e4c3f


2b2a1ff64af
1b04624f93b
1da177e4c3f

a1d5e21e3e3
1da177e4c3f


bc505a478d3
1da177e4c3f

5cb11446892
bc505a478d3





1da177e4c3f

b488893a390



d92656633b8
c69e8d9c01d
b488893a390

d8878ba3f05

1da177e4c3f



























d5f70c00ad2

5cb11446892
d5f70c00ad2
d5f70c00ad2





999d9fc1670
d5f70c00ad2

999d9fc1670
d5f70c00ad2





1da177e4c3f
1a669c2f16d




3d749b9e676

1a669c2f16d


1da177e4c3f






20686a309aa

1da177e4c3f
20686a309aa
b8401150836

1da177e4c3f
1a669c2f16d














3d749b9e676

1a669c2f16d

1da177e4c3f










d9ae90ac4bd
1da177e4c3f

3d749b9e676
a1d5e21e3e3
53da1d9456f






1da177e4c3f
53da1d9456f
1da177e4c3f



6405f7f4675
1da177e4c3f
6405f7f4675
20686a309aa

6405f7f4675
1da177e4c3f


13b1c3d4b49






1da177e4c3f









b74d0deb968
1da177e4c3f
b74d0deb968
1da177e4c3f










b488893a390
76aac0e9a17
1da177e4c3f


20686a309aa
1da177e4c3f


1da177e4c3f





a122b341b74
1da177e4c3f

ae6d2ed7bb3
1da177e4c3f
ae6d2ed7bb3
f558b7e4080

2b201a9eddf
573cf9ad72c
f558b7e4080
1da177e4c3f

a122b341b74
1da177e4c3f
a122b341b74
1da177e4c3f
ae6d2ed7bb3
a122b341b74
1da177e4c3f
a122b341b74


1da177e4c3f
d12619b5ff5
e1abb39c609
ae6d2ed7bb3
a122b341b74

1da177e4c3f
ae6d2ed7bb3


















1da177e4c3f
ae6d2ed7bb3












dac27f4a09c
1da177e4c3f


18c98b65279


5cb11446892
18c98b65279






















c69e8d9c01d
18c98b65279










1da177e4c3f


f6b76d4fb00


1da177e4c3f
13b1c3d4b49






fc558a7496b

f6b76d4fb00
021e1ae3d85




f6b76d4fb00

e442055193e
f6b76d4fb00
e442055193e
ae6d2ed7bb3

fa00b80b3c4
ae6d2ed7bb3




e442055193e


1da177e4c3f

7bcf6a2ca5f










1be53963b05



7bcf6a2ca5f

1da177e4c3f
18c98b65279
7bcf6a2ca5f









1da177e4c3f

f9d4257e01d


1da177e4c3f

















84d737866e2
0fbc26a6cfa
b3bfa0cba86






84d737866e2
fae5fa44f1f
b3bfa0cba86
1da177e4c3f













f6b76d4fb00
1da177e4c3f


3e7cd6c413c
1da177e4c3f

f6b76d4fb00
1da177e4c3f

7bcf6a2ca5f
1da177e4c3f










f6b76d4fb00
1da177e4c3f




2dce81bff28
1da177e4c3f
2dce81bff28
7bcf6a2ca5f
1da177e4c3f







7bcf6a2ca5f
1da177e4c3f




7bcf6a2ca5f
1da177e4c3f

f6b76d4fb00
1da177e4c3f


d12619b5ff5


5dee1707dfb
d12619b5ff5
5dee1707dfb


d12619b5ff5

5dee1707dfb
d12619b5ff5




5dee1707dfb













ae6d2ed7bb3
5dee1707dfb

d12619b5ff5

ae6d2ed7bb3
d12619b5ff5
ae6d2ed7bb3
d12619b5ff5



1da177e4c3f



1da177e4c3f










754fe8d297b
1da177e4c3f


























1da177e4c3f

a26fd335b48


1da177e4c3f















a26fd335b48
1da177e4c3f


17da2bd90ab

1da177e4c3f

























































17da2bd90ab
1da177e4c3f

















fba2afaaec7

1da177e4c3f

























a337fdac7a5







1da177e4c3f























17da2bd90ab


1da177e4c3f













































75bcc8c5e1d
1da177e4c3f
1da177e4c3f























17da2bd90ab
1da177e4c3f





b488893a390
76aac0e9a17
1da177e4c3f



30b4ae8a449

1da177e4c3f
1da177e4c3f
30b4ae8a449
1da177e4c3f
3547ff3aefb
228ebcbe634
b488893a390
30b4ae8a449
1da177e4c3f



4a30debfb77








1da177e4c3f

3547ff3aefb
6dd69f1061b
1da177e4c3f


30b4ae8a449












6dd69f1061b





72fd4a35a82
6dd69f1061b


a5f8fa9e9ba
6dd69f1061b







1da177e4c3f


a5f8fa9e9ba
1da177e4c3f
1da177e4c3f



6dd69f1061b
1da177e4c3f

a5f8fa9e9ba

1da177e4c3f















62ab4505e3e

























88531f725bd
1da177e4c3f
93585eeaf3d
1da177e4c3f
71fabd5e483
1da177e4c3f
7ed20e1ad52
1da177e4c3f

93585eeaf3d
1da177e4c3f

1da177e4c3f



9ac95f2f90e

88531f725bd
1da177e4c3f










35de254dc60
71fabd5e483


1da177e4c3f
71fabd5e483
1da177e4c3f

1da177e4c3f
1da177e4c3f











0083fc2c50e


1da177e4c3f






0dd8486b5cf





1da177e4c3f






























0083fc2c50e
1da177e4c3f

0083fc2c50e
1da177e4c3f
0083fc2c50e


1da177e4c3f

1da177e4c3f





b290ebe2c46
1da177e4c3f









b290ebe2c46

1da177e4c3f
















































d4e82042c4c



1da177e4c3f




























a5f8fa9e9ba
1da177e4c3f




a5f8fa9e9ba
1da177e4c3f


















a5f8fa9e9ba
1da177e4c3f





c70d3d703ad
1da177e4c3f








a5f8fa9e9ba
1da177e4c3f







150256d8aad
d4e82042c4c
150256d8aad


















4e4c22c7114
150256d8aad



f269fdd1829




1da177e4c3f

0a31bd5f2bb
1da177e4c3f
67fc4e0cb93







































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794











                                                                  

                         







                           
                         
                           
                            
                            
                             
                          

                                

                                
 



                        
                                                 




                               
                                          
 

                                      
                                                               
 

                                                         
 

                                                             
                                                     


                                                               
 

                                                           
 
                             
 


                                                             
                                                                




                                                 
                                                                            
 




                                                       
                                                                                

                         
                                                        




                                                               
                                                          

































                                                                          
                                                       


                                                
                                                               
                                                       

                         




                                                                               










                                                                              



                            


                                                                       

                                                  



                                                                              



                                                                 
                                                           


                                   
 

                                












                                                              

                              






                                                        

                      


                                 
                              
                                              

                      

                                   

                      
 


                   













                                                                                 


                                                                               
                                                                      
   

                                                                                  

                                  
                                 
 
          

                                                                      
           
                        
                                             
                                      
                          
 
                              
                                             
                                                            
                                                             



                                          
                                  
                                              
                               


                                         
                               
         

                 

 
                                               







                                            
                                             













                                                                         






                                                   
                                         



                                                       
                           


                                                            

































                                                              









                                                              
  
















                                                                  

                                                      
                                                                         
                                
                         
                                                     
                         
                                                          

 


































                                                                           
                                                                             

                                          
 





                                                                    

                                                   


                                  


                                      
                    
              


                                                 
                



                                                             

                                     
                                        


                                 




                                                                       
                                             
 









                                                                                   
                                                   
         











                                                                            
                  



                                                                       
                                                            
                     

                                                                      























                                                                           
 
                            



                                               











                                                                           
                                                           
         
                                                                                






























                                                                      

                                                                             





                                                                           
                                      








                                                         


























                                                                   


















                                                                  










                                                            

                                         
                                           



                                                               
                                        
                        

                  
                               

                               
                               
                         
 

                                                                                
                             
 
                              
                               

                                             


                                         


                                 
                                              









                                                                          
 
                                                   

 
  

                                                                     

                                                                      



                                                                     
   
                                                                               
 
                                                 

                              
                                                          
                  
                                                                        
                   
                                          


                                                                          
                                                                         


                                                                     
                                          
                                    
                                 



                                                           
                                                                             



                                                                         








                                                                          
                                              



                                                                     
                                               




                                                                                                 
                                          
 








                                                                           
                                                        
                                                    
                                                  


                                                  
                          
                                                                               


                                                                           


                                                                    





                                                                         
                                                               
                 
         
 
                                                      

 




















                                                                           
                                                                      











                                                                             
                                                 


























                                                                             

                                                                         
                                                  
                              
                                                         





























                                                                       




                                                                      

                                                                              
 
                                   
                           
                            
 
                                            
 
                                                 

                                                      
                         

                                                                   
          



                                                              
                                       
                         
          


                                                                      
                                    









                                                                   




                                                                              
                                                                               
                                 
                
                                                        
                                               
                                                     


                                                  
                                                                 
                                                                               
                                                       
                              
                                                   







                                                     

                                                   

                              
                                          






                                                                         
                                       






                                                                          


         
                                
                                         

                                       

 


                                                                            


                                 

                                                                           


                                                                    

 


                                                                  
                                                            
 
                                              
                                            




                                           

                                                                            




                                              
                          
                        
                         









                                                           
 





                                                                           


                                                                            
                                            

 













                                                                          


                                                             




                                                                 

                                                              
   



                                                                    

                                   

                                                       






                                                    
                                                      
                 
         

                                                       





                                                            


                                       
                                            
 

                                  
 

                                        



                                                            

                                  
                                                       

                                     

                     

 

                                                                   


                                       
                        









                                                                  
                          



                       

                                                 
   

                                                                             




                                                  
 

                                                           




                   
                                                                             
                                     
                                                              
   
                                                                     



                                     

                        
                                                 


                                                            
                                                     


                                    
                                                                 
 
                           

                              
                        
      
                                       
                
                                                          








                                                                       
                          
 


                     

                                                        


                        
                                                         



                          

                                                                        
                                                       


                              
                                 
                            



                               
                        
                                       



                                
                               
                                

                                                        


                                


                                                      






                                                                

           
                          

                   
                                        







                                                                              
                                                                        
 
                












                                                                            


                                          
                                     

                                                                         





                                                                            
                                              
         

                                    
                   





                                                                           


                                                                   



                                                                 
                               

                               
                                                     

 


                                                  


                                                  
                                                         

 


                                         
                                              




















                                                                    

                                                 






                                                             








                                                           



                                                                      
                                                                



                                                                        

                                     
                                                                          
 
              
                                              

                 




                                      

                                                      

                                                

                                                       
                                             
           
                                       




                                                          
                                  
                         

                                            

                                   

 
                                                                       
 
                                   
                                   

                            
 
                                                




                                                  
                                            
                                       


                         




                                                                       

                                                    
                         
         
                               
 
                                
                                                                   

                                                
                                       



                                       

 
  

                                                                               


                                                               
   
                                                      



                                    
                      



                                                                        
                                               
 
                                   



                                                                       













                                                                        
                                            

                          



                                                                  












                                                     
                                                  
















                                                                           
                                            
                                                                     
                                 
         
                                         


                                                               
 
                   

 
                                                                      


                            
                                   

                                       
                             





                                          

                                



                                                                       
                                                                   
                                            

                          

                                                       



























                                                                         

                                       
                                          
                         





                                                                     
                                                                   

                                       
                                                





                                                         
  




                                                                    

                                                                          


  






                                                           

                                                              
   
                                                                       

                                              
 














                                                                               

                                             

         










                                                    
                                         

                                                    
                                
                                                               






                                                               
                                            
                                            



                                                                     
                                                                    
                   
                                                  

                                               
                                            


          






                                                                         









                                                                          
                                                         
           
                                       










                                                          
                                            
                                    


                                                  
                                         


                                                    





                                                                      
                                    

                                                    
                   
 
                                     

                                      
                                                                 
                                                     
                                 

                                                              
                                            
                   
                                             
 
                                          
                                                                                
                          


                                                                     
                           
                                                       
                                                            
                                                        

                                                     
         


















                                                                       
 












                                                                      
 


                 


                                                            
                                  






















                                                             
                                                         










                                                              


                                                                         


                                                          
 






                                                                               

                        
                                         




                                                                       

                                                                 
                                                              
                                                  
 

                                                                
 




                                                                             


                            

                                       










                                                                               



                                                                     

                                                                          
 
                                   









                                                                    

                 


                                                       

















                                                                       
                  
                                                               






                                                                              
                   
                                                                  
                                                        













                                                                               
                                                                   


                                                                              
                                                               

                                                    
                                                                 

                         
                                                                     










                                                                 
                                                   




                                                                  
 
                                                 
                                                
                                                                         







                                                                           
                                                                          




                                               
                                              

                                
                                           


                     


                                          
                              
 


                                                                        

         
                                              




                                                                    













                                                                   
                                                                             

         

                                                
                                   
                                          
                                                          



                                            



                                  










                                   
                                


























                                                                              

                                                  


                                           















                                                                       
 


                     

                                                                 

























































                                                                           
                                                                          

















                                                                  

                                                                     

























                                                                      







                                                                                     























                                                                          


                                                                               













































                                                                                 
                                                                          
 























                                                                     
                                           





                               
                                             
                                    



                                                    

                                                                      
 
                              
                           
 
                        
                                   
                                                           
                                                            



                                                                         








                                                                               

                 
                          
 


                     












                                                       





                                                   
                                                                         


                                                                         
                                                          







                                                 


                                                                     
                                            
 



                                                 
                                     

 

                                                      















                                                                         

























                                                                          
                                                                            
 
                                        
                              
                      
 
                                                                           

                               
                                       

                                                  



                           

                                                                   
                          










                                                                              
                                                                    


                                                                              
                            
                                                                       

                                                   
                 











                                                                                  


                                                       






                                   





                                                               






























                                                                                      
                  

                                
                                                                  
                                 


                                                                  

         





                                 
                                                       









                                                                      

                                                                  
















































                                                                  



                                                     




























                                                                             
                         




                                       
                                       


















                                                                       
                                                          





                                                    
                                        








                                                               
                      







                                            
                                    
                                                                              


















                                                                       
                              



                                          




                                                                           

                              
                                                           
 







































                                                                              
/*
 *  linux/kernel/signal.c
 *
 *  Copyright (C) 1991, 1992  Linus Torvalds
 *
 *  1997-11-02  Modified for POSIX.1b signals by Richard Henderson
 *
 *  2003-06-02  Jim Houston - Concurrent Computer Corp.
 *		Changes to use preallocated sigqueue structures
 *		to allow signals to be sent reliably.
 */

#include <linux/slab.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/tty.h>
#include <linux/binfmts.h>
#include <linux/security.h>
#include <linux/syscalls.h>
#include <linux/ptrace.h>
#include <linux/signal.h>
#include <linux/signalfd.h>
#include <linux/ratelimit.h>
#include <linux/tracehook.h>
#include <linux/capability.h>
#include <linux/freezer.h>
#include <linux/pid_namespace.h>
#include <linux/nsproxy.h>
#define CREATE_TRACE_POINTS
#include <trace/events/signal.h>

#include <asm/param.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
#include <asm/siginfo.h>
#include "audit.h"	/* audit_signal_info() */

/*
 * SLAB caches for signal bits.
 */

static struct kmem_cache *sigqueue_cachep;

int print_fatal_signals __read_mostly;

static void __user *sig_handler(struct task_struct *t, int sig)
{
	return t->sighand->action[sig - 1].sa.sa_handler;
}

static int sig_handler_ignored(void __user *handler, int sig)
{
	/* Is it explicitly or implicitly ignored? */
	return handler == SIG_IGN ||
		(handler == SIG_DFL && sig_kernel_ignore(sig));
}

static int sig_task_ignored(struct task_struct *t, int sig,
		int from_ancestor_ns)
{
	void __user *handler;

	handler = sig_handler(t, sig);

	if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) &&
			handler == SIG_DFL && !from_ancestor_ns)
		return 1;

	return sig_handler_ignored(handler, sig);
}

static int sig_ignored(struct task_struct *t, int sig, int from_ancestor_ns)
{
	/*
	 * Blocked signals are never ignored, since the
	 * signal handler may change by the time it is
	 * unblocked.
	 */
	if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
		return 0;

	if (!sig_task_ignored(t, sig, from_ancestor_ns))
		return 0;

	/*
	 * Tracers may want to know about even ignored signals.
	 */
	return !tracehook_consider_ignored_signal(t, sig);
}

/*
 * Re-calculate pending state from the set of locally pending
 * signals, globally pending signals, and blocked signals.
 */
static inline int has_pending_signals(sigset_t *signal, sigset_t *blocked)
{
	unsigned long ready;
	long i;

	switch (_NSIG_WORDS) {
	default:
		for (i = _NSIG_WORDS, ready = 0; --i >= 0 ;)
			ready |= signal->sig[i] &~ blocked->sig[i];
		break;

	case 4: ready  = signal->sig[3] &~ blocked->sig[3];
		ready |= signal->sig[2] &~ blocked->sig[2];
		ready |= signal->sig[1] &~ blocked->sig[1];
		ready |= signal->sig[0] &~ blocked->sig[0];
		break;

	case 2: ready  = signal->sig[1] &~ blocked->sig[1];
		ready |= signal->sig[0] &~ blocked->sig[0];
		break;

	case 1: ready  = signal->sig[0] &~ blocked->sig[0];
	}
	return ready !=	0;
}

#define PENDING(p,b) has_pending_signals(&(p)->signal, (b))

static int recalc_sigpending_tsk(struct task_struct *t)
{
	if (t->signal->group_stop_count > 0 ||
	    PENDING(&t->pending, &t->blocked) ||
	    PENDING(&t->signal->shared_pending, &t->blocked)) {
		set_tsk_thread_flag(t, TIF_SIGPENDING);
		return 1;
	}
	/*
	 * We must never clear the flag in another thread, or in current
	 * when it's possible the current syscall is returning -ERESTART*.
	 * So we don't clear it here, and only callers who know they should do.
	 */
	return 0;
}

/*
 * After recalculating TIF_SIGPENDING, we need to make sure the task wakes up.
 * This is superfluous when called on current, the wakeup is a harmless no-op.
 */
void recalc_sigpending_and_wake(struct task_struct *t)
{
	if (recalc_sigpending_tsk(t))
		signal_wake_up(t, 0);
}

void recalc_sigpending(void)
{
	if (unlikely(tracehook_force_sigpending()))
		set_thread_flag(TIF_SIGPENDING);
	else if (!recalc_sigpending_tsk(current) && !freezing(current))
		clear_thread_flag(TIF_SIGPENDING);

}

/* Given the mask, find the first available signal that should be serviced. */

#define SYNCHRONOUS_MASK \
	(sigmask(SIGSEGV) | sigmask(SIGBUS) | sigmask(SIGILL) | \
	 sigmask(SIGTRAP) | sigmask(SIGFPE))

int next_signal(struct sigpending *pending, sigset_t *mask)
{
	unsigned long i, *s, *m, x;
	int sig = 0;

	s = pending->signal.sig;
	m = mask->sig;

	/*
	 * Handle the first word specially: it contains the
	 * synchronous signals that need to be dequeued first.
	 */
	x = *s &~ *m;
	if (x) {
		if (x & SYNCHRONOUS_MASK)
			x &= SYNCHRONOUS_MASK;
		sig = ffz(~x) + 1;
		return sig;
	}

	switch (_NSIG_WORDS) {
	default:
		for (i = 1; i < _NSIG_WORDS; ++i) {
			x = *++s &~ *++m;
			if (!x)
				continue;
			sig = ffz(~x) + i*_NSIG_BPW + 1;
			break;
		}
		break;

	case 2:
		x = s[1] &~ m[1];
		if (!x)
			break;
		sig = ffz(~x) + _NSIG_BPW + 1;
		break;

	case 1:
		/* Nothing to do */
		break;
	}

	return sig;
}

static inline void print_dropped_signal(int sig)
{
	static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 10);

	if (!print_fatal_signals)
		return;

	if (!__ratelimit(&ratelimit_state))
		return;

	printk(KERN_INFO "%s/%d: reached RLIMIT_SIGPENDING, dropped signal %d\n",
				current->comm, current->pid, sig);
}

/*
 * allocate a new signal queue record
 * - this may be called without locks if and only if t == current, otherwise an
 *   appopriate lock must be held to stop the target task from exiting
 */
static struct sigqueue *
__sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimit)
{
	struct sigqueue *q = NULL;
	struct user_struct *user;

	/*
	 * Protect access to @t credentials. This can go away when all
	 * callers hold rcu read lock.
	 */
	rcu_read_lock();
	user = get_uid(__task_cred(t)->user);
	atomic_inc(&user->sigpending);
	rcu_read_unlock();

	if (override_rlimit ||
	    atomic_read(&user->sigpending) <=
			task_rlimit(t, RLIMIT_SIGPENDING)) {
		q = kmem_cache_alloc(sigqueue_cachep, flags);
	} else {
		print_dropped_signal(sig);
	}

	if (unlikely(q == NULL)) {
		atomic_dec(&user->sigpending);
		free_uid(user);
	} else {
		INIT_LIST_HEAD(&q->list);
		q->flags = 0;
		q->user = user;
	}

	return q;
}

static void __sigqueue_free(struct sigqueue *q)
{
	if (q->flags & SIGQUEUE_PREALLOC)
		return;
	atomic_dec(&q->user->sigpending);
	free_uid(q->user);
	kmem_cache_free(sigqueue_cachep, q);
}

void flush_sigqueue(struct sigpending *queue)
{
	struct sigqueue *q;

	sigemptyset(&queue->signal);
	while (!list_empty(&queue->list)) {
		q = list_entry(queue->list.next, struct sigqueue , list);
		list_del_init(&q->list);
		__sigqueue_free(q);
	}
}

/*
 * Flush all pending signals for a task.
 */
void __flush_signals(struct task_struct *t)
{
	clear_tsk_thread_flag(t, TIF_SIGPENDING);
	flush_sigqueue(&t->pending);
	flush_sigqueue(&t->signal->shared_pending);
}

void flush_signals(struct task_struct *t)
{
	unsigned long flags;

	spin_lock_irqsave(&t->sighand->siglock, flags);
	__flush_signals(t);
	spin_unlock_irqrestore(&t->sighand->siglock, flags);
}

static void __flush_itimer_signals(struct sigpending *pending)
{
	sigset_t signal, retain;
	struct sigqueue *q, *n;

	signal = pending->signal;
	sigemptyset(&retain);

	list_for_each_entry_safe(q, n, &pending->list, list) {
		int sig = q->info.si_signo;

		if (likely(q->info.si_code != SI_TIMER)) {
			sigaddset(&retain, sig);
		} else {
			sigdelset(&signal, sig);
			list_del_init(&q->list);
			__sigqueue_free(q);
		}
	}

	sigorsets(&pending->signal, &signal, &retain);
}

void flush_itimer_signals(void)
{
	struct task_struct *tsk = current;
	unsigned long flags;

	spin_lock_irqsave(&tsk->sighand->siglock, flags);
	__flush_itimer_signals(&tsk->pending);
	__flush_itimer_signals(&tsk->signal->shared_pending);
	spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
}

void ignore_signals(struct task_struct *t)
{
	int i;

	for (i = 0; i < _NSIG; ++i)
		t->sighand->action[i].sa.sa_handler = SIG_IGN;

	flush_signals(t);
}

/*
 * Flush all handlers for a task.
 */

void
flush_signal_handlers(struct task_struct *t, int force_default)
{
	int i;
	struct k_sigaction *ka = &t->sighand->action[0];
	for (i = _NSIG ; i != 0 ; i--) {
		if (force_default || ka->sa.sa_handler != SIG_IGN)
			ka->sa.sa_handler = SIG_DFL;
		ka->sa.sa_flags = 0;
		sigemptyset(&ka->sa.sa_mask);
		ka++;
	}
}

int unhandled_signal(struct task_struct *tsk, int sig)
{
	void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
	if (is_global_init(tsk))
		return 1;
	if (handler != SIG_IGN && handler != SIG_DFL)
		return 0;
	return !tracehook_consider_fatal_signal(tsk, sig);
}


/* Notify the system that a driver wants to block all signals for this
 * process, and wants to be notified if any signals at all were to be
 * sent/acted upon.  If the notifier routine returns non-zero, then the
 * signal will be acted upon after all.  If the notifier routine returns 0,
 * then then signal will be blocked.  Only one block per process is
 * allowed.  priv is a pointer to private data that the notifier routine
 * can use to determine if the signal should be blocked or not.  */

void
block_all_signals(int (*notifier)(void *priv), void *priv, sigset_t *mask)
{
	unsigned long flags;

	spin_lock_irqsave(&current->sighand->siglock, flags);
	current->notifier_mask = mask;
	current->notifier_data = priv;
	current->notifier = notifier;
	spin_unlock_irqrestore(&current->sighand->siglock, flags);
}

/* Notify the system that blocking has ended. */

void
unblock_all_signals(void)
{
	unsigned long flags;

	spin_lock_irqsave(&current->sighand->siglock, flags);
	current->notifier = NULL;
	current->notifier_data = NULL;
	recalc_sigpending();
	spin_unlock_irqrestore(&current->sighand->siglock, flags);
}

static void collect_signal(int sig, struct sigpending *list, siginfo_t *info)
{
	struct sigqueue *q, *first = NULL;

	/*
	 * Collect the siginfo appropriate to this signal.  Check if
	 * there is another siginfo for the same signal.
	*/
	list_for_each_entry(q, &list->list, list) {
		if (q->info.si_signo == sig) {
			if (first)
				goto still_pending;
			first = q;
		}
	}

	sigdelset(&list->signal, sig);

	if (first) {
still_pending:
		list_del_init(&first->list);
		copy_siginfo(info, &first->info);
		__sigqueue_free(first);
	} else {
		/* Ok, it wasn't in the queue.  This must be
		   a fast-pathed signal or we must have been
		   out of queue space.  So zero out the info.
		 */
		info->si_signo = sig;
		info->si_errno = 0;
		info->si_code = SI_USER;
		info->si_pid = 0;
		info->si_uid = 0;
	}
}

static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
			siginfo_t *info)
{
	int sig = next_signal(pending, mask);

	if (sig) {
		if (current->notifier) {
			if (sigismember(current->notifier_mask, sig)) {
				if (!(current->notifier)(current->notifier_data)) {
					clear_thread_flag(TIF_SIGPENDING);
					return 0;
				}
			}
		}

		collect_signal(sig, pending, info);
	}

	return sig;
}

/*
 * Dequeue a signal and return the element to the caller, which is 
 * expected to free it.
 *
 * All callers have to hold the siglock.
 */
int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
{
	int signr;

	/* We only dequeue private signals from ourselves, we don't let
	 * signalfd steal them
	 */
	signr = __dequeue_signal(&tsk->pending, mask, info);
	if (!signr) {
		signr = __dequeue_signal(&tsk->signal->shared_pending,
					 mask, info);
		/*
		 * itimer signal ?
		 *
		 * itimers are process shared and we restart periodic
		 * itimers in the signal delivery path to prevent DoS
		 * attacks in the high resolution timer case. This is
		 * compliant with the old way of self restarting
		 * itimers, as the SIGALRM is a legacy signal and only
		 * queued once. Changing the restart behaviour to
		 * restart the timer in the signal dequeue path is
		 * reducing the timer noise on heavy loaded !highres
		 * systems too.
		 */
		if (unlikely(signr == SIGALRM)) {
			struct hrtimer *tmr = &tsk->signal->real_timer;

			if (!hrtimer_is_queued(tmr) &&
			    tsk->signal->it_real_incr.tv64 != 0) {
				hrtimer_forward(tmr, tmr->base->get_time(),
						tsk->signal->it_real_incr);
				hrtimer_restart(tmr);
			}
		}
	}

	recalc_sigpending();
	if (!signr)
		return 0;

	if (unlikely(sig_kernel_stop(signr))) {
		/*
		 * Set a marker that we have dequeued a stop signal.  Our
		 * caller might release the siglock and then the pending
		 * stop signal it is about to process is no longer in the
		 * pending bitmasks, but must still be cleared by a SIGCONT
		 * (and overruled by a SIGKILL).  So those cases clear this
		 * shared flag after we've set it.  Note that this flag may
		 * remain set after the signal we return is ignored or
		 * handled.  That doesn't matter because its only purpose
		 * is to alert stop-signal processing code when another
		 * processor has come along and cleared the flag.
		 */
		tsk->signal->flags |= SIGNAL_STOP_DEQUEUED;
	}
	if ((info->si_code & __SI_MASK) == __SI_TIMER && info->si_sys_private) {
		/*
		 * Release the siglock to ensure proper locking order
		 * of timer locks outside of siglocks.  Note, we leave
		 * irqs disabled here, since the posix-timers code is
		 * about to disable them again anyway.
		 */
		spin_unlock(&tsk->sighand->siglock);
		do_schedule_next_timer(info);
		spin_lock(&tsk->sighand->siglock);
	}
	return signr;
}

/*
 * Tell a process that it has a new active signal..
 *
 * NOTE! we rely on the previous spin_lock to
 * lock interrupts for us! We can only be called with
 * "siglock" held, and the local interrupt must
 * have been disabled when that got acquired!
 *
 * No need to set need_resched since signal event passing
 * goes through ->blocked
 */
void signal_wake_up(struct task_struct *t, int resume)
{
	unsigned int mask;

	set_tsk_thread_flag(t, TIF_SIGPENDING);

	/*
	 * For SIGKILL, we want to wake it up in the stopped/traced/killable
	 * case. We don't check t->state here because there is a race with it
	 * executing another processor and just now entering stopped state.
	 * By using wake_up_state, we ensure the process will wake up and
	 * handle its death signal.
	 */
	mask = TASK_INTERRUPTIBLE;
	if (resume)
		mask |= TASK_WAKEKILL;
	if (!wake_up_state(t, mask))
		kick_process(t);
}

/*
 * Remove signals in mask from the pending set and queue.
 * Returns 1 if any signals were found.
 *
 * All callers must be holding the siglock.
 *
 * This version takes a sigset mask and looks at all signals,
 * not just those in the first mask word.
 */
static int rm_from_queue_full(sigset_t *mask, struct sigpending *s)
{
	struct sigqueue *q, *n;
	sigset_t m;

	sigandsets(&m, mask, &s->signal);
	if (sigisemptyset(&m))
		return 0;

	signandsets(&s->signal, &s->signal, mask);
	list_for_each_entry_safe(q, n, &s->list, list) {
		if (sigismember(mask, q->info.si_signo)) {
			list_del_init(&q->list);
			__sigqueue_free(q);
		}
	}
	return 1;
}
/*
 * Remove signals in mask from the pending set and queue.
 * Returns 1 if any signals were found.
 *
 * All callers must be holding the siglock.
 */
static int rm_from_queue(unsigned long mask, struct sigpending *s)
{
	struct sigqueue *q, *n;

	if (!sigtestsetmask(&s->signal, mask))
		return 0;

	sigdelsetmask(&s->signal, mask);
	list_for_each_entry_safe(q, n, &s->list, list) {
		if (q->info.si_signo < SIGRTMIN &&
		    (mask & sigmask(q->info.si_signo))) {
			list_del_init(&q->list);
			__sigqueue_free(q);
		}
	}
	return 1;
}

static inline int is_si_special(const struct siginfo *info)
{
	return info <= SEND_SIG_FORCED;
}

static inline bool si_fromuser(const struct siginfo *info)
{
	return info == SEND_SIG_NOINFO ||
		(!is_si_special(info) && SI_FROMUSER(info));
}

/*
 * Bad permissions for sending the signal
 * - the caller must hold the RCU read lock
 */
static int check_kill_permission(int sig, struct siginfo *info,
				 struct task_struct *t)
{
	const struct cred *cred, *tcred;
	struct pid *sid;
	int error;

	if (!valid_signal(sig))
		return -EINVAL;

	if (!si_fromuser(info))
		return 0;

	error = audit_signal_info(sig, t); /* Let audit system see the signal */
	if (error)
		return error;

	cred = current_cred();
	tcred = __task_cred(t);
	if (!same_thread_group(current, t) &&
	    (cred->euid ^ tcred->suid) &&
	    (cred->euid ^ tcred->uid) &&
	    (cred->uid  ^ tcred->suid) &&
	    (cred->uid  ^ tcred->uid) &&
	    !capable(CAP_KILL)) {
		switch (sig) {
		case SIGCONT:
			sid = task_session(t);
			/*
			 * We don't return the error if sid == NULL. The
			 * task was unhashed, the caller must notice this.
			 */
			if (!sid || sid == task_session(current))
				break;
		default:
			return -EPERM;
		}
	}

	return security_task_kill(t, info, sig, 0);
}

/*
 * Handle magic process-wide effects of stop/continue signals. Unlike
 * the signal actions, these happen immediately at signal-generation
 * time regardless of blocking, ignoring, or handling.  This does the
 * actual continuing for SIGCONT, but not the actual stopping for stop
 * signals. The process stop is done as a signal action for SIG_DFL.
 *
 * Returns true if the signal should be actually delivered, otherwise
 * it should be dropped.
 */
static int prepare_signal(int sig, struct task_struct *p, int from_ancestor_ns)
{
	struct signal_struct *signal = p->signal;
	struct task_struct *t;

	if (unlikely(signal->flags & SIGNAL_GROUP_EXIT)) {
		/*
		 * The process is in the middle of dying, nothing to do.
		 */
	} else if (sig_kernel_stop(sig)) {
		/*
		 * This is a stop signal.  Remove SIGCONT from all queues.
		 */
		rm_from_queue(sigmask(SIGCONT), &signal->shared_pending);
		t = p;
		do {
			rm_from_queue(sigmask(SIGCONT), &t->pending);
		} while_each_thread(p, t);
	} else if (sig == SIGCONT) {
		unsigned int why;
		/*
		 * Remove all stop signals from all queues,
		 * and wake all threads.
		 */
		rm_from_queue(SIG_KERNEL_STOP_MASK, &signal->shared_pending);
		t = p;
		do {
			unsigned int state;
			rm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending);
			/*
			 * If there is a handler for SIGCONT, we must make
			 * sure that no thread returns to user mode before
			 * we post the signal, in case it was the only
			 * thread eligible to run the signal handler--then
			 * it must not do anything between resuming and
			 * running the handler.  With the TIF_SIGPENDING
			 * flag set, the thread will pause and acquire the
			 * siglock that we hold now and until we've queued
			 * the pending signal.
			 *
			 * Wake up the stopped thread _after_ setting
			 * TIF_SIGPENDING
			 */
			state = __TASK_STOPPED;
			if (sig_user_defined(t, SIGCONT) && !sigismember(&t->blocked, SIGCONT)) {
				set_tsk_thread_flag(t, TIF_SIGPENDING);
				state |= TASK_INTERRUPTIBLE;
			}
			wake_up_state(t, state);
		} while_each_thread(p, t);

		/*
		 * Notify the parent with CLD_CONTINUED if we were stopped.
		 *
		 * If we were in the middle of a group stop, we pretend it
		 * was already finished, and then continued. Since SIGCHLD
		 * doesn't queue we report only CLD_STOPPED, as if the next
		 * CLD_CONTINUED was dropped.
		 */
		why = 0;
		if (signal->flags & SIGNAL_STOP_STOPPED)
			why |= SIGNAL_CLD_CONTINUED;
		else if (signal->group_stop_count)
			why |= SIGNAL_CLD_STOPPED;

		if (why) {
			/*
			 * The first thread which returns from do_signal_stop()
			 * will take ->siglock, notice SIGNAL_CLD_MASK, and
			 * notify its parent. See get_signal_to_deliver().
			 */
			signal->flags = why | SIGNAL_STOP_CONTINUED;
			signal->group_stop_count = 0;
			signal->group_exit_code = 0;
		} else {
			/*
			 * We are not stopped, but there could be a stop
			 * signal in the middle of being processed after
			 * being removed from the queue.  Clear that too.
			 */
			signal->flags &= ~SIGNAL_STOP_DEQUEUED;
		}
	}

	return !sig_ignored(p, sig, from_ancestor_ns);
}

/*
 * Test if P wants to take SIG.  After we've checked all threads with this,
 * it's equivalent to finding no threads not blocking SIG.  Any threads not
 * blocking SIG were ruled out because they are not running and already
 * have pending signals.  Such threads will dequeue from the shared queue
 * as soon as they're available, so putting the signal on the shared queue
 * will be equivalent to sending it to one such thread.
 */
static inline int wants_signal(int sig, struct task_struct *p)
{
	if (sigismember(&p->blocked, sig))
		return 0;
	if (p->flags & PF_EXITING)
		return 0;
	if (sig == SIGKILL)
		return 1;
	if (task_is_stopped_or_traced(p))
		return 0;
	return task_curr(p) || !signal_pending(p);
}

static void complete_signal(int sig, struct task_struct *p, int group)
{
	struct signal_struct *signal = p->signal;
	struct task_struct *t;

	/*
	 * Now find a thread we can wake up to take the signal off the queue.
	 *
	 * If the main thread wants the signal, it gets first crack.
	 * Probably the least surprising to the average bear.
	 */
	if (wants_signal(sig, p))
		t = p;
	else if (!group || thread_group_empty(p))
		/*
		 * There is just one thread and it does not need to be woken.
		 * It will dequeue unblocked signals before it runs again.
		 */
		return;
	else {
		/*
		 * Otherwise try to find a suitable thread.
		 */
		t = signal->curr_target;
		while (!wants_signal(sig, t)) {
			t = next_thread(t);
			if (t == signal->curr_target)
				/*
				 * No thread needs to be woken.
				 * Any eligible threads will see
				 * the signal in the queue soon.
				 */
				return;
		}
		signal->curr_target = t;
	}

	/*
	 * Found a killable thread.  If the signal will be fatal,
	 * then start taking the whole group down immediately.
	 */
	if (sig_fatal(p, sig) &&
	    !(signal->flags & (SIGNAL_UNKILLABLE | SIGNAL_GROUP_EXIT)) &&
	    !sigismember(&t->real_blocked, sig) &&
	    (sig == SIGKILL ||
	     !tracehook_consider_fatal_signal(t, sig))) {
		/*
		 * This signal will be fatal to the whole group.
		 */
		if (!sig_kernel_coredump(sig)) {
			/*
			 * Start a group exit and wake everybody up.
			 * This way we don't have other threads
			 * running and doing things after a slower
			 * thread has the fatal signal pending.
			 */
			signal->flags = SIGNAL_GROUP_EXIT;
			signal->group_exit_code = sig;
			signal->group_stop_count = 0;
			t = p;
			do {
				sigaddset(&t->pending.signal, SIGKILL);
				signal_wake_up(t, 1);
			} while_each_thread(p, t);
			return;
		}
	}

	/*
	 * The signal is already in the shared-pending queue.
	 * Tell the chosen thread to wake up and dequeue it.
	 */
	signal_wake_up(t, sig == SIGKILL);
	return;
}

static inline int legacy_queue(struct sigpending *signals, int sig)
{
	return (sig < SIGRTMIN) && sigismember(&signals->signal, sig);
}

static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
			int group, int from_ancestor_ns)
{
	struct sigpending *pending;
	struct sigqueue *q;
	int override_rlimit;

	trace_signal_generate(sig, info, t);

	assert_spin_locked(&t->sighand->siglock);

	if (!prepare_signal(sig, t, from_ancestor_ns))
		return 0;

	pending = group ? &t->signal->shared_pending : &t->pending;
	/*
	 * Short-circuit ignored signals and support queuing
	 * exactly one non-rt signal, so that we can get more
	 * detailed information about the cause of the signal.
	 */
	if (legacy_queue(pending, sig))
		return 0;
	/*
	 * fast-pathed signals for kernel-internal things like SIGSTOP
	 * or SIGKILL.
	 */
	if (info == SEND_SIG_FORCED)
		goto out_set;

	/* Real-time signals must be queued if sent by sigqueue, or
	   some other real-time mechanism.  It is implementation
	   defined whether kill() does so.  We attempt to do so, on
	   the principle of least surprise, but since kill is not
	   allowed to fail with EAGAIN when low on memory we just
	   make sure at least one signal gets delivered and don't
	   pass on the info struct.  */

	if (sig < SIGRTMIN)
		override_rlimit = (is_si_special(info) || info->si_code >= 0);
	else
		override_rlimit = 0;

	q = __sigqueue_alloc(sig, t, GFP_ATOMIC | __GFP_NOTRACK_FALSE_POSITIVE,
		override_rlimit);
	if (q) {
		list_add_tail(&q->list, &pending->list);
		switch ((unsigned long) info) {
		case (unsigned long) SEND_SIG_NOINFO:
			q->info.si_signo = sig;
			q->info.si_errno = 0;
			q->info.si_code = SI_USER;
			q->info.si_pid = task_tgid_nr_ns(current,
							task_active_pid_ns(t));
			q->info.si_uid = current_uid();
			break;
		case (unsigned long) SEND_SIG_PRIV:
			q->info.si_signo = sig;
			q->info.si_errno = 0;
			q->info.si_code = SI_KERNEL;
			q->info.si_pid = 0;
			q->info.si_uid = 0;
			break;
		default:
			copy_siginfo(&q->info, info);
			if (from_ancestor_ns)
				q->info.si_pid = 0;
			break;
		}
	} else if (!is_si_special(info)) {
		if (sig >= SIGRTMIN && info->si_code != SI_USER) {
			/*
			 * Queue overflow, abort.  We may abort if the
			 * signal was rt and sent by user using something
			 * other than kill().
			 */
			trace_signal_overflow_fail(sig, group, info);
			return -EAGAIN;
		} else {
			/*
			 * This is a silent loss of information.  We still
			 * send the signal, but the *info bits are lost.
			 */
			trace_signal_lose_info(sig, group, info);
		}
	}

out_set:
	signalfd_notify(t, sig);
	sigaddset(&pending->signal, sig);
	complete_signal(sig, t, group);
	return 0;
}

static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
			int group)
{
	int from_ancestor_ns = 0;

#ifdef CONFIG_PID_NS
	from_ancestor_ns = si_fromuser(info) &&
			   !task_pid_nr_ns(current, task_active_pid_ns(t));
#endif

	return __send_signal(sig, info, t, group, from_ancestor_ns);
}

static void print_fatal_signal(struct pt_regs *regs, int signr)
{
	printk("%s/%d: potentially unexpected fatal signal %d.\n",
		current->comm, task_pid_nr(current), signr);

#if defined(__i386__) && !defined(__arch_um__)
	printk("code at %08lx: ", regs->ip);
	{
		int i;
		for (i = 0; i < 16; i++) {
			unsigned char insn;

			if (get_user(insn, (unsigned char *)(regs->ip + i)))
				break;
			printk("%02x ", insn);
		}
	}
#endif
	printk("\n");
	preempt_disable();
	show_regs(regs);
	preempt_enable();
}

static int __init setup_print_fatal_signals(char *str)
{
	get_option (&str, &print_fatal_signals);

	return 1;
}

__setup("print-fatal-signals=", setup_print_fatal_signals);

int
__group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
{
	return send_signal(sig, info, p, 1);
}

static int
specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
{
	return send_signal(sig, info, t, 0);
}

int do_send_sig_info(int sig, struct siginfo *info, struct task_struct *p,
			bool group)
{
	unsigned long flags;
	int ret = -ESRCH;

	if (lock_task_sighand(p, &flags)) {
		ret = send_signal(sig, info, p, group);
		unlock_task_sighand(p, &flags);
	}

	return ret;
}

/*
 * Force a signal that the process can't ignore: if necessary
 * we unblock the signal and change any SIG_IGN to SIG_DFL.
 *
 * Note: If we unblock the signal, we always reset it to SIG_DFL,
 * since we do not want to have a signal handler that was blocked
 * be invoked when user space had explicitly blocked it.
 *
 * We don't want to have recursive SIGSEGV's etc, for example,
 * that is why we also clear SIGNAL_UNKILLABLE.
 */
int
force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
{
	unsigned long int flags;
	int ret, blocked, ignored;
	struct k_sigaction *action;

	spin_lock_irqsave(&t->sighand->siglock, flags);
	action = &t->sighand->action[sig-1];
	ignored = action->sa.sa_handler == SIG_IGN;
	blocked = sigismember(&t->blocked, sig);
	if (blocked || ignored) {
		action->sa.sa_handler = SIG_DFL;
		if (blocked) {
			sigdelset(&t->blocked, sig);
			recalc_sigpending_and_wake(t);
		}
	}
	if (action->sa.sa_handler == SIG_DFL)
		t->signal->flags &= ~SIGNAL_UNKILLABLE;
	ret = specific_send_sig_info(sig, info, t);
	spin_unlock_irqrestore(&t->sighand->siglock, flags);

	return ret;
}

/*
 * Nuke all other threads in the group.
 */
int zap_other_threads(struct task_struct *p)
{
	struct task_struct *t = p;
	int count = 0;

	p->signal->group_stop_count = 0;

	while_each_thread(p, t) {
		count++;

		/* Don't bother with already dead threads */
		if (t->exit_state)
			continue;
		sigaddset(&t->pending.signal, SIGKILL);
		signal_wake_up(t, 1);
	}

	return count;
}

struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
					   unsigned long *flags)
{
	struct sighand_struct *sighand;

	rcu_read_lock();
	for (;;) {
		sighand = rcu_dereference(tsk->sighand);
		if (unlikely(sighand == NULL))
			break;

		spin_lock_irqsave(&sighand->siglock, *flags);
		if (likely(sighand == tsk->sighand))
			break;
		spin_unlock_irqrestore(&sighand->siglock, *flags);
	}
	rcu_read_unlock();

	return sighand;
}

/*
 * send signal info to all the members of a group
 */
int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
{
	int ret;

	rcu_read_lock();
	ret = check_kill_permission(sig, info, p);
	rcu_read_unlock();

	if (!ret && sig)
		ret = do_send_sig_info(sig, info, p, true);

	return ret;
}

/*
 * __kill_pgrp_info() sends a signal to a process group: this is what the tty
 * control characters do (^C, ^Z etc)
 * - the caller must hold at least a readlock on tasklist_lock
 */
int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp)
{
	struct task_struct *p = NULL;
	int retval, success;

	success = 0;
	retval = -ESRCH;
	do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
		int err = group_send_sig_info(sig, info, p);
		success |= !err;
		retval = err;
	} while_each_pid_task(pgrp, PIDTYPE_PGID, p);
	return success ? 0 : retval;
}

int kill_pid_info(int sig, struct siginfo *info, struct pid *pid)
{
	int error = -ESRCH;
	struct task_struct *p;

	rcu_read_lock();
retry:
	p = pid_task(pid, PIDTYPE_PID);
	if (p) {
		error = group_send_sig_info(sig, info, p);
		if (unlikely(error == -ESRCH))
			/*
			 * The task was unhashed in between, try again.
			 * If it is dead, pid_task() will return NULL,
			 * if we race with de_thread() it will find the
			 * new leader.
			 */
			goto retry;
	}
	rcu_read_unlock();

	return error;
}

int
kill_proc_info(int sig, struct siginfo *info, pid_t pid)
{
	int error;
	rcu_read_lock();
	error = kill_pid_info(sig, info, find_vpid(pid));
	rcu_read_unlock();
	return error;
}

/* like kill_pid_info(), but doesn't use uid/euid of "current" */
int kill_pid_info_as_uid(int sig, struct siginfo *info, struct pid *pid,
		      uid_t uid, uid_t euid, u32 secid)
{
	int ret = -EINVAL;
	struct task_struct *p;
	const struct cred *pcred;
	unsigned long flags;

	if (!valid_signal(sig))
		return ret;

	rcu_read_lock();
	p = pid_task(pid, PIDTYPE_PID);
	if (!p) {
		ret = -ESRCH;
		goto out_unlock;
	}
	pcred = __task_cred(p);
	if (si_fromuser(info) &&
	    euid != pcred->suid && euid != pcred->uid &&
	    uid  != pcred->suid && uid  != pcred->uid) {
		ret = -EPERM;
		goto out_unlock;
	}
	ret = security_task_kill(p, info, sig, secid);
	if (ret)
		goto out_unlock;

	if (sig) {
		if (lock_task_sighand(p, &flags)) {
			ret = __send_signal(sig, info, p, 1, 0);
			unlock_task_sighand(p, &flags);
		} else
			ret = -ESRCH;
	}
out_unlock:
	rcu_read_unlock();
	return ret;
}
EXPORT_SYMBOL_GPL(kill_pid_info_as_uid);

/*
 * kill_something_info() interprets pid in interesting ways just like kill(2).
 *
 * POSIX specifies that kill(-1,sig) is unspecified, but what we have
 * is probably wrong.  Should make it like BSD or SYSV.
 */

static int kill_something_info(int sig, struct siginfo *info, pid_t pid)
{
	int ret;

	if (pid > 0) {
		rcu_read_lock();
		ret = kill_pid_info(sig, info, find_vpid(pid));
		rcu_read_unlock();
		return ret;
	}

	read_lock(&tasklist_lock);
	if (pid != -1) {
		ret = __kill_pgrp_info(sig, info,
				pid ? find_vpid(-pid) : task_pgrp(current));
	} else {
		int retval = 0, count = 0;
		struct task_struct * p;

		for_each_process(p) {
			if (task_pid_vnr(p) > 1 &&