Annotation of /trunk/kernel26-alx/patches-3.10/0136-3.10.37-all-fixes.patch
Parent Directory | Revision Log
Revision 2672 -
(hide annotations)
(download)
Tue Jul 21 16:46:35 2015 UTC (9 years, 2 months ago) by niro
File size: 50505 byte(s)
Tue Jul 21 16:46:35 2015 UTC (9 years, 2 months ago) by niro
File size: 50505 byte(s)
-3.10.84-alx-r1
1 | niro | 2672 | diff --git a/Makefile b/Makefile |
2 | index b5f4ef30f6e6..bd9fb5b72fc0 100644 | ||
3 | --- a/Makefile | ||
4 | +++ b/Makefile | ||
5 | @@ -1,6 +1,6 @@ | ||
6 | VERSION = 3 | ||
7 | PATCHLEVEL = 10 | ||
8 | -SUBLEVEL = 36 | ||
9 | +SUBLEVEL = 37 | ||
10 | EXTRAVERSION = | ||
11 | NAME = TOSSUG Baby Fish | ||
12 | |||
13 | diff --git a/arch/arc/boot/dts/nsimosci.dts b/arch/arc/boot/dts/nsimosci.dts | ||
14 | index ea16d782af58..4f31b2eb5cdf 100644 | ||
15 | --- a/arch/arc/boot/dts/nsimosci.dts | ||
16 | +++ b/arch/arc/boot/dts/nsimosci.dts | ||
17 | @@ -11,13 +11,16 @@ | ||
18 | |||
19 | / { | ||
20 | compatible = "snps,nsimosci"; | ||
21 | - clock-frequency = <80000000>; /* 80 MHZ */ | ||
22 | + clock-frequency = <20000000>; /* 20 MHZ */ | ||
23 | #address-cells = <1>; | ||
24 | #size-cells = <1>; | ||
25 | interrupt-parent = <&intc>; | ||
26 | |||
27 | chosen { | ||
28 | - bootargs = "console=tty0 consoleblank=0"; | ||
29 | + /* this is for console on PGU */ | ||
30 | + /* bootargs = "console=tty0 consoleblank=0"; */ | ||
31 | + /* this is for console on serial */ | ||
32 | + bootargs = "earlycon=uart8250,mmio32,0xc0000000,115200n8 console=ttyS0,115200n8 consoleblank=0 debug"; | ||
33 | }; | ||
34 | |||
35 | aliases { | ||
36 | @@ -44,15 +47,14 @@ | ||
37 | }; | ||
38 | |||
39 | uart0: serial@c0000000 { | ||
40 | - compatible = "snps,dw-apb-uart"; | ||
41 | + compatible = "ns8250"; | ||
42 | reg = <0xc0000000 0x2000>; | ||
43 | interrupts = <11>; | ||
44 | - #clock-frequency = <80000000>; | ||
45 | clock-frequency = <3686400>; | ||
46 | baud = <115200>; | ||
47 | reg-shift = <2>; | ||
48 | reg-io-width = <4>; | ||
49 | - status = "okay"; | ||
50 | + no-loopback-test = <1>; | ||
51 | }; | ||
52 | |||
53 | pgu0: pgu@c9000000 { | ||
54 | diff --git a/arch/arc/configs/nsimosci_defconfig b/arch/arc/configs/nsimosci_defconfig | ||
55 | index 446c96c24eff..00788e741ce7 100644 | ||
56 | --- a/arch/arc/configs/nsimosci_defconfig | ||
57 | +++ b/arch/arc/configs/nsimosci_defconfig | ||
58 | @@ -54,6 +54,7 @@ CONFIG_SERIO_ARC_PS2=y | ||
59 | CONFIG_SERIAL_8250=y | ||
60 | CONFIG_SERIAL_8250_CONSOLE=y | ||
61 | CONFIG_SERIAL_8250_DW=y | ||
62 | +CONFIG_SERIAL_OF_PLATFORM=y | ||
63 | CONFIG_SERIAL_ARC=y | ||
64 | CONFIG_SERIAL_ARC_CONSOLE=y | ||
65 | # CONFIG_HW_RANDOM is not set | ||
66 | diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig | ||
67 | index 821170e5f6ed..b969eea4e237 100644 | ||
68 | --- a/arch/m68k/Kconfig | ||
69 | +++ b/arch/m68k/Kconfig | ||
70 | @@ -16,6 +16,7 @@ config M68K | ||
71 | select FPU if MMU | ||
72 | select ARCH_WANT_IPC_PARSE_VERSION | ||
73 | select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE | ||
74 | + select HAVE_FUTEX_CMPXCHG if MMU && FUTEX | ||
75 | select HAVE_MOD_ARCH_SPECIFIC | ||
76 | select MODULES_USE_ELF_REL | ||
77 | select MODULES_USE_ELF_RELA | ||
78 | diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig | ||
79 | index 97dcbea97a1c..d8d6eeca56b0 100644 | ||
80 | --- a/arch/s390/Kconfig | ||
81 | +++ b/arch/s390/Kconfig | ||
82 | @@ -116,6 +116,7 @@ config S390 | ||
83 | select HAVE_FUNCTION_GRAPH_TRACER | ||
84 | select HAVE_FUNCTION_TRACER | ||
85 | select HAVE_FUNCTION_TRACE_MCOUNT_TEST | ||
86 | + select HAVE_FUTEX_CMPXCHG if FUTEX | ||
87 | select HAVE_KERNEL_BZIP2 | ||
88 | select HAVE_KERNEL_GZIP | ||
89 | select HAVE_KERNEL_LZMA | ||
90 | diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S | ||
91 | index 586f41aac361..185fad49d86f 100644 | ||
92 | --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S | ||
93 | +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S | ||
94 | @@ -24,10 +24,6 @@ | ||
95 | .align 16 | ||
96 | .Lbswap_mask: | ||
97 | .octa 0x000102030405060708090a0b0c0d0e0f | ||
98 | -.Lpoly: | ||
99 | - .octa 0xc2000000000000000000000000000001 | ||
100 | -.Ltwo_one: | ||
101 | - .octa 0x00000001000000000000000000000001 | ||
102 | |||
103 | #define DATA %xmm0 | ||
104 | #define SHASH %xmm1 | ||
105 | @@ -134,28 +130,3 @@ ENTRY(clmul_ghash_update) | ||
106 | .Lupdate_just_ret: | ||
107 | ret | ||
108 | ENDPROC(clmul_ghash_update) | ||
109 | - | ||
110 | -/* | ||
111 | - * void clmul_ghash_setkey(be128 *shash, const u8 *key); | ||
112 | - * | ||
113 | - * Calculate hash_key << 1 mod poly | ||
114 | - */ | ||
115 | -ENTRY(clmul_ghash_setkey) | ||
116 | - movaps .Lbswap_mask, BSWAP | ||
117 | - movups (%rsi), %xmm0 | ||
118 | - PSHUFB_XMM BSWAP %xmm0 | ||
119 | - movaps %xmm0, %xmm1 | ||
120 | - psllq $1, %xmm0 | ||
121 | - psrlq $63, %xmm1 | ||
122 | - movaps %xmm1, %xmm2 | ||
123 | - pslldq $8, %xmm1 | ||
124 | - psrldq $8, %xmm2 | ||
125 | - por %xmm1, %xmm0 | ||
126 | - # reduction | ||
127 | - pshufd $0b00100100, %xmm2, %xmm1 | ||
128 | - pcmpeqd .Ltwo_one, %xmm1 | ||
129 | - pand .Lpoly, %xmm1 | ||
130 | - pxor %xmm1, %xmm0 | ||
131 | - movups %xmm0, (%rdi) | ||
132 | - ret | ||
133 | -ENDPROC(clmul_ghash_setkey) | ||
134 | diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/ghash-clmulni-intel_glue.c | ||
135 | index 6759dd1135be..d785cf2c529c 100644 | ||
136 | --- a/arch/x86/crypto/ghash-clmulni-intel_glue.c | ||
137 | +++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c | ||
138 | @@ -30,8 +30,6 @@ void clmul_ghash_mul(char *dst, const be128 *shash); | ||
139 | void clmul_ghash_update(char *dst, const char *src, unsigned int srclen, | ||
140 | const be128 *shash); | ||
141 | |||
142 | -void clmul_ghash_setkey(be128 *shash, const u8 *key); | ||
143 | - | ||
144 | struct ghash_async_ctx { | ||
145 | struct cryptd_ahash *cryptd_tfm; | ||
146 | }; | ||
147 | @@ -58,13 +56,23 @@ static int ghash_setkey(struct crypto_shash *tfm, | ||
148 | const u8 *key, unsigned int keylen) | ||
149 | { | ||
150 | struct ghash_ctx *ctx = crypto_shash_ctx(tfm); | ||
151 | + be128 *x = (be128 *)key; | ||
152 | + u64 a, b; | ||
153 | |||
154 | if (keylen != GHASH_BLOCK_SIZE) { | ||
155 | crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); | ||
156 | return -EINVAL; | ||
157 | } | ||
158 | |||
159 | - clmul_ghash_setkey(&ctx->shash, key); | ||
160 | + /* perform multiplication by 'x' in GF(2^128) */ | ||
161 | + a = be64_to_cpu(x->a); | ||
162 | + b = be64_to_cpu(x->b); | ||
163 | + | ||
164 | + ctx->shash.a = (__be64)((b << 1) | (a >> 63)); | ||
165 | + ctx->shash.b = (__be64)((a << 1) | (b >> 63)); | ||
166 | + | ||
167 | + if (a >> 63) | ||
168 | + ctx->shash.b ^= cpu_to_be64(0xc2); | ||
169 | |||
170 | return 0; | ||
171 | } | ||
172 | diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c | ||
173 | index 648554742a99..66f6cf5064ec 100644 | ||
174 | --- a/drivers/cpufreq/cpufreq.c | ||
175 | +++ b/drivers/cpufreq/cpufreq.c | ||
176 | @@ -46,6 +46,7 @@ static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); | ||
177 | static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); | ||
178 | #endif | ||
179 | static DEFINE_RWLOCK(cpufreq_driver_lock); | ||
180 | +static DEFINE_MUTEX(cpufreq_governor_lock); | ||
181 | |||
182 | /* | ||
183 | * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure | ||
184 | @@ -1563,6 +1564,21 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | ||
185 | |||
186 | pr_debug("__cpufreq_governor for CPU %u, event %u\n", | ||
187 | policy->cpu, event); | ||
188 | + | ||
189 | + mutex_lock(&cpufreq_governor_lock); | ||
190 | + if ((!policy->governor_enabled && (event == CPUFREQ_GOV_STOP)) || | ||
191 | + (policy->governor_enabled && (event == CPUFREQ_GOV_START))) { | ||
192 | + mutex_unlock(&cpufreq_governor_lock); | ||
193 | + return -EBUSY; | ||
194 | + } | ||
195 | + | ||
196 | + if (event == CPUFREQ_GOV_STOP) | ||
197 | + policy->governor_enabled = false; | ||
198 | + else if (event == CPUFREQ_GOV_START) | ||
199 | + policy->governor_enabled = true; | ||
200 | + | ||
201 | + mutex_unlock(&cpufreq_governor_lock); | ||
202 | + | ||
203 | ret = policy->governor->governor(policy, event); | ||
204 | |||
205 | if (!ret) { | ||
206 | @@ -1570,6 +1586,14 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | ||
207 | policy->governor->initialized++; | ||
208 | else if (event == CPUFREQ_GOV_POLICY_EXIT) | ||
209 | policy->governor->initialized--; | ||
210 | + } else { | ||
211 | + /* Restore original values */ | ||
212 | + mutex_lock(&cpufreq_governor_lock); | ||
213 | + if (event == CPUFREQ_GOV_STOP) | ||
214 | + policy->governor_enabled = true; | ||
215 | + else if (event == CPUFREQ_GOV_START) | ||
216 | + policy->governor_enabled = false; | ||
217 | + mutex_unlock(&cpufreq_governor_lock); | ||
218 | } | ||
219 | |||
220 | /* we keep one module reference alive for | ||
221 | diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c | ||
222 | index a86ff72141f3..28a0b32c73b3 100644 | ||
223 | --- a/drivers/cpufreq/cpufreq_governor.c | ||
224 | +++ b/drivers/cpufreq/cpufreq_governor.c | ||
225 | @@ -177,6 +177,9 @@ void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy, | ||
226 | { | ||
227 | int i; | ||
228 | |||
229 | + if (!policy->governor_enabled) | ||
230 | + return; | ||
231 | + | ||
232 | if (!all_cpus) { | ||
233 | __gov_queue_work(smp_processor_id(), dbs_data, delay); | ||
234 | } else { | ||
235 | diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c | ||
236 | index ea0222a45b7b..b07ca0d3f56a 100644 | ||
237 | --- a/drivers/cpufreq/powernow-k6.c | ||
238 | +++ b/drivers/cpufreq/powernow-k6.c | ||
239 | @@ -26,41 +26,108 @@ | ||
240 | static unsigned int busfreq; /* FSB, in 10 kHz */ | ||
241 | static unsigned int max_multiplier; | ||
242 | |||
243 | +static unsigned int param_busfreq = 0; | ||
244 | +static unsigned int param_max_multiplier = 0; | ||
245 | + | ||
246 | +module_param_named(max_multiplier, param_max_multiplier, uint, S_IRUGO); | ||
247 | +MODULE_PARM_DESC(max_multiplier, "Maximum multiplier (allowed values: 20 30 35 40 45 50 55 60)"); | ||
248 | + | ||
249 | +module_param_named(bus_frequency, param_busfreq, uint, S_IRUGO); | ||
250 | +MODULE_PARM_DESC(bus_frequency, "Bus frequency in kHz"); | ||
251 | |||
252 | /* Clock ratio multiplied by 10 - see table 27 in AMD#23446 */ | ||
253 | static struct cpufreq_frequency_table clock_ratio[] = { | ||
254 | - {45, /* 000 -> 4.5x */ 0}, | ||
255 | + {60, /* 110 -> 6.0x */ 0}, | ||
256 | + {55, /* 011 -> 5.5x */ 0}, | ||
257 | {50, /* 001 -> 5.0x */ 0}, | ||
258 | + {45, /* 000 -> 4.5x */ 0}, | ||
259 | {40, /* 010 -> 4.0x */ 0}, | ||
260 | - {55, /* 011 -> 5.5x */ 0}, | ||
261 | - {20, /* 100 -> 2.0x */ 0}, | ||
262 | - {30, /* 101 -> 3.0x */ 0}, | ||
263 | - {60, /* 110 -> 6.0x */ 0}, | ||
264 | {35, /* 111 -> 3.5x */ 0}, | ||
265 | + {30, /* 101 -> 3.0x */ 0}, | ||
266 | + {20, /* 100 -> 2.0x */ 0}, | ||
267 | {0, CPUFREQ_TABLE_END} | ||
268 | }; | ||
269 | |||
270 | +static const u8 index_to_register[8] = { 6, 3, 1, 0, 2, 7, 5, 4 }; | ||
271 | +static const u8 register_to_index[8] = { 3, 2, 4, 1, 7, 6, 0, 5 }; | ||
272 | + | ||
273 | +static const struct { | ||
274 | + unsigned freq; | ||
275 | + unsigned mult; | ||
276 | +} usual_frequency_table[] = { | ||
277 | + { 400000, 40 }, // 100 * 4 | ||
278 | + { 450000, 45 }, // 100 * 4.5 | ||
279 | + { 475000, 50 }, // 95 * 5 | ||
280 | + { 500000, 50 }, // 100 * 5 | ||
281 | + { 506250, 45 }, // 112.5 * 4.5 | ||
282 | + { 533500, 55 }, // 97 * 5.5 | ||
283 | + { 550000, 55 }, // 100 * 5.5 | ||
284 | + { 562500, 50 }, // 112.5 * 5 | ||
285 | + { 570000, 60 }, // 95 * 6 | ||
286 | + { 600000, 60 }, // 100 * 6 | ||
287 | + { 618750, 55 }, // 112.5 * 5.5 | ||
288 | + { 660000, 55 }, // 120 * 5.5 | ||
289 | + { 675000, 60 }, // 112.5 * 6 | ||
290 | + { 720000, 60 }, // 120 * 6 | ||
291 | +}; | ||
292 | + | ||
293 | +#define FREQ_RANGE 3000 | ||
294 | |||
295 | /** | ||
296 | * powernow_k6_get_cpu_multiplier - returns the current FSB multiplier | ||
297 | * | ||
298 | - * Returns the current setting of the frequency multiplier. Core clock | ||
299 | + * Returns the current setting of the frequency multiplier. Core clock | ||
300 | * speed is frequency of the Front-Side Bus multiplied with this value. | ||
301 | */ | ||
302 | static int powernow_k6_get_cpu_multiplier(void) | ||
303 | { | ||
304 | - u64 invalue = 0; | ||
305 | + unsigned long invalue = 0; | ||
306 | u32 msrval; | ||
307 | |||
308 | + local_irq_disable(); | ||
309 | + | ||
310 | msrval = POWERNOW_IOPORT + 0x1; | ||
311 | wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */ | ||
312 | invalue = inl(POWERNOW_IOPORT + 0x8); | ||
313 | msrval = POWERNOW_IOPORT + 0x0; | ||
314 | wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ | ||
315 | |||
316 | - return clock_ratio[(invalue >> 5)&7].index; | ||
317 | + local_irq_enable(); | ||
318 | + | ||
319 | + return clock_ratio[register_to_index[(invalue >> 5)&7]].index; | ||
320 | } | ||
321 | |||
322 | +static void powernow_k6_set_cpu_multiplier(unsigned int best_i) | ||
323 | +{ | ||
324 | + unsigned long outvalue, invalue; | ||
325 | + unsigned long msrval; | ||
326 | + unsigned long cr0; | ||
327 | + | ||
328 | + /* we now need to transform best_i to the BVC format, see AMD#23446 */ | ||
329 | + | ||
330 | + /* | ||
331 | + * The processor doesn't respond to inquiry cycles while changing the | ||
332 | + * frequency, so we must disable cache. | ||
333 | + */ | ||
334 | + local_irq_disable(); | ||
335 | + cr0 = read_cr0(); | ||
336 | + write_cr0(cr0 | X86_CR0_CD); | ||
337 | + wbinvd(); | ||
338 | + | ||
339 | + outvalue = (1<<12) | (1<<10) | (1<<9) | (index_to_register[best_i]<<5); | ||
340 | + | ||
341 | + msrval = POWERNOW_IOPORT + 0x1; | ||
342 | + wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */ | ||
343 | + invalue = inl(POWERNOW_IOPORT + 0x8); | ||
344 | + invalue = invalue & 0x1f; | ||
345 | + outvalue = outvalue | invalue; | ||
346 | + outl(outvalue, (POWERNOW_IOPORT + 0x8)); | ||
347 | + msrval = POWERNOW_IOPORT + 0x0; | ||
348 | + wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ | ||
349 | + | ||
350 | + write_cr0(cr0); | ||
351 | + local_irq_enable(); | ||
352 | +} | ||
353 | |||
354 | /** | ||
355 | * powernow_k6_set_state - set the PowerNow! multiplier | ||
356 | @@ -71,8 +138,6 @@ static int powernow_k6_get_cpu_multiplier(void) | ||
357 | static void powernow_k6_set_state(struct cpufreq_policy *policy, | ||
358 | unsigned int best_i) | ||
359 | { | ||
360 | - unsigned long outvalue = 0, invalue = 0; | ||
361 | - unsigned long msrval; | ||
362 | struct cpufreq_freqs freqs; | ||
363 | |||
364 | if (clock_ratio[best_i].index > max_multiplier) { | ||
365 | @@ -85,18 +150,7 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy, | ||
366 | |||
367 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
368 | |||
369 | - /* we now need to transform best_i to the BVC format, see AMD#23446 */ | ||
370 | - | ||
371 | - outvalue = (1<<12) | (1<<10) | (1<<9) | (best_i<<5); | ||
372 | - | ||
373 | - msrval = POWERNOW_IOPORT + 0x1; | ||
374 | - wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */ | ||
375 | - invalue = inl(POWERNOW_IOPORT + 0x8); | ||
376 | - invalue = invalue & 0xf; | ||
377 | - outvalue = outvalue | invalue; | ||
378 | - outl(outvalue , (POWERNOW_IOPORT + 0x8)); | ||
379 | - msrval = POWERNOW_IOPORT + 0x0; | ||
380 | - wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ | ||
381 | + powernow_k6_set_cpu_multiplier(best_i); | ||
382 | |||
383 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
384 | |||
385 | @@ -141,18 +195,57 @@ static int powernow_k6_target(struct cpufreq_policy *policy, | ||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | - | ||
390 | static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | ||
391 | { | ||
392 | unsigned int i, f; | ||
393 | int result; | ||
394 | + unsigned khz; | ||
395 | |||
396 | if (policy->cpu != 0) | ||
397 | return -ENODEV; | ||
398 | |||
399 | - /* get frequencies */ | ||
400 | - max_multiplier = powernow_k6_get_cpu_multiplier(); | ||
401 | - busfreq = cpu_khz / max_multiplier; | ||
402 | + max_multiplier = 0; | ||
403 | + khz = cpu_khz; | ||
404 | + for (i = 0; i < ARRAY_SIZE(usual_frequency_table); i++) { | ||
405 | + if (khz >= usual_frequency_table[i].freq - FREQ_RANGE && | ||
406 | + khz <= usual_frequency_table[i].freq + FREQ_RANGE) { | ||
407 | + khz = usual_frequency_table[i].freq; | ||
408 | + max_multiplier = usual_frequency_table[i].mult; | ||
409 | + break; | ||
410 | + } | ||
411 | + } | ||
412 | + if (param_max_multiplier) { | ||
413 | + for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { | ||
414 | + if (clock_ratio[i].index == param_max_multiplier) { | ||
415 | + max_multiplier = param_max_multiplier; | ||
416 | + goto have_max_multiplier; | ||
417 | + } | ||
418 | + } | ||
419 | + printk(KERN_ERR "powernow-k6: invalid max_multiplier parameter, valid parameters 20, 30, 35, 40, 45, 50, 55, 60\n"); | ||
420 | + return -EINVAL; | ||
421 | + } | ||
422 | + | ||
423 | + if (!max_multiplier) { | ||
424 | + printk(KERN_WARNING "powernow-k6: unknown frequency %u, cannot determine current multiplier\n", khz); | ||
425 | + printk(KERN_WARNING "powernow-k6: use module parameters max_multiplier and bus_frequency\n"); | ||
426 | + return -EOPNOTSUPP; | ||
427 | + } | ||
428 | + | ||
429 | +have_max_multiplier: | ||
430 | + param_max_multiplier = max_multiplier; | ||
431 | + | ||
432 | + if (param_busfreq) { | ||
433 | + if (param_busfreq >= 50000 && param_busfreq <= 150000) { | ||
434 | + busfreq = param_busfreq / 10; | ||
435 | + goto have_busfreq; | ||
436 | + } | ||
437 | + printk(KERN_ERR "powernow-k6: invalid bus_frequency parameter, allowed range 50000 - 150000 kHz\n"); | ||
438 | + return -EINVAL; | ||
439 | + } | ||
440 | + | ||
441 | + busfreq = khz / max_multiplier; | ||
442 | +have_busfreq: | ||
443 | + param_busfreq = busfreq * 10; | ||
444 | |||
445 | /* table init */ | ||
446 | for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { | ||
447 | @@ -164,7 +257,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | ||
448 | } | ||
449 | |||
450 | /* cpuinfo and default policy values */ | ||
451 | - policy->cpuinfo.transition_latency = 200000; | ||
452 | + policy->cpuinfo.transition_latency = 500000; | ||
453 | policy->cur = busfreq * max_multiplier; | ||
454 | |||
455 | result = cpufreq_frequency_table_cpuinfo(policy, clock_ratio); | ||
456 | diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c | ||
457 | index 8dfaaae94444..2253271b3fac 100644 | ||
458 | --- a/drivers/cpuidle/driver.c | ||
459 | +++ b/drivers/cpuidle/driver.c | ||
460 | @@ -251,7 +251,8 @@ struct cpuidle_driver *cpuidle_driver_ref(void) | ||
461 | spin_lock(&cpuidle_driver_lock); | ||
462 | |||
463 | drv = cpuidle_get_driver(); | ||
464 | - drv->refcnt++; | ||
465 | + if (drv) | ||
466 | + drv->refcnt++; | ||
467 | |||
468 | spin_unlock(&cpuidle_driver_lock); | ||
469 | return drv; | ||
470 | diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c | ||
471 | index 02125e6a9109..5a4da94aefb0 100644 | ||
472 | --- a/drivers/isdn/isdnloop/isdnloop.c | ||
473 | +++ b/drivers/isdn/isdnloop/isdnloop.c | ||
474 | @@ -518,9 +518,9 @@ static isdnloop_stat isdnloop_cmd_table[] = | ||
475 | static void | ||
476 | isdnloop_fake_err(isdnloop_card *card) | ||
477 | { | ||
478 | - char buf[60]; | ||
479 | + char buf[64]; | ||
480 | |||
481 | - sprintf(buf, "E%s", card->omsg); | ||
482 | + snprintf(buf, sizeof(buf), "E%s", card->omsg); | ||
483 | isdnloop_fake(card, buf, -1); | ||
484 | isdnloop_fake(card, "NAK", -1); | ||
485 | } | ||
486 | @@ -903,6 +903,8 @@ isdnloop_parse_cmd(isdnloop_card *card) | ||
487 | case 7: | ||
488 | /* 0x;EAZ */ | ||
489 | p += 3; | ||
490 | + if (strlen(p) >= sizeof(card->eazlist[0])) | ||
491 | + break; | ||
492 | strcpy(card->eazlist[ch - 1], p); | ||
493 | break; | ||
494 | case 8: | ||
495 | @@ -1070,6 +1072,12 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp) | ||
496 | return -EBUSY; | ||
497 | if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef))) | ||
498 | return -EFAULT; | ||
499 | + | ||
500 | + for (i = 0; i < 3; i++) { | ||
501 | + if (!memchr(sdef.num[i], 0, sizeof(sdef.num[i]))) | ||
502 | + return -EINVAL; | ||
503 | + } | ||
504 | + | ||
505 | spin_lock_irqsave(&card->isdnloop_lock, flags); | ||
506 | switch (sdef.ptype) { | ||
507 | case ISDN_PTYPE_EURO: | ||
508 | @@ -1127,7 +1135,7 @@ isdnloop_command(isdn_ctrl *c, isdnloop_card *card) | ||
509 | { | ||
510 | ulong a; | ||
511 | int i; | ||
512 | - char cbuf[60]; | ||
513 | + char cbuf[80]; | ||
514 | isdn_ctrl cmd; | ||
515 | isdnloop_cdef cdef; | ||
516 | |||
517 | @@ -1192,7 +1200,6 @@ isdnloop_command(isdn_ctrl *c, isdnloop_card *card) | ||
518 | break; | ||
519 | if ((c->arg & 255) < ISDNLOOP_BCH) { | ||
520 | char *p; | ||
521 | - char dial[50]; | ||
522 | char dcode[4]; | ||
523 | |||
524 | a = c->arg; | ||
525 | @@ -1204,10 +1211,10 @@ isdnloop_command(isdn_ctrl *c, isdnloop_card *card) | ||
526 | } else | ||
527 | /* Normal Dial */ | ||
528 | strcpy(dcode, "CAL"); | ||
529 | - strcpy(dial, p); | ||
530 | - sprintf(cbuf, "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1), | ||
531 | - dcode, dial, c->parm.setup.si1, | ||
532 | - c->parm.setup.si2, c->parm.setup.eazmsn); | ||
533 | + snprintf(cbuf, sizeof(cbuf), | ||
534 | + "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1), | ||
535 | + dcode, p, c->parm.setup.si1, | ||
536 | + c->parm.setup.si2, c->parm.setup.eazmsn); | ||
537 | i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); | ||
538 | } | ||
539 | break; | ||
540 | diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c | ||
541 | index e27d5c839be5..4a0db617ab64 100644 | ||
542 | --- a/drivers/net/ethernet/broadcom/tg3.c | ||
543 | +++ b/drivers/net/ethernet/broadcom/tg3.c | ||
544 | @@ -17308,8 +17308,6 @@ static int tg3_init_one(struct pci_dev *pdev, | ||
545 | |||
546 | tg3_init_bufmgr_config(tp); | ||
547 | |||
548 | - features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX; | ||
549 | - | ||
550 | /* 5700 B0 chips do not support checksumming correctly due | ||
551 | * to hardware bugs. | ||
552 | */ | ||
553 | @@ -17341,7 +17339,8 @@ static int tg3_init_one(struct pci_dev *pdev, | ||
554 | features |= NETIF_F_TSO_ECN; | ||
555 | } | ||
556 | |||
557 | - dev->features |= features; | ||
558 | + dev->features |= features | NETIF_F_HW_VLAN_CTAG_TX | | ||
559 | + NETIF_F_HW_VLAN_CTAG_RX; | ||
560 | dev->vlan_features |= features; | ||
561 | |||
562 | /* | ||
563 | diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c | ||
564 | index f6dce4765de4..3d50e7db141e 100644 | ||
565 | --- a/drivers/net/usb/usbnet.c | ||
566 | +++ b/drivers/net/usb/usbnet.c | ||
567 | @@ -727,14 +727,12 @@ EXPORT_SYMBOL_GPL(usbnet_unlink_rx_urbs); | ||
568 | // precondition: never called in_interrupt | ||
569 | static void usbnet_terminate_urbs(struct usbnet *dev) | ||
570 | { | ||
571 | - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(unlink_wakeup); | ||
572 | DECLARE_WAITQUEUE(wait, current); | ||
573 | int temp; | ||
574 | |||
575 | /* ensure there are no more active urbs */ | ||
576 | - add_wait_queue(&unlink_wakeup, &wait); | ||
577 | + add_wait_queue(&dev->wait, &wait); | ||
578 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
579 | - dev->wait = &unlink_wakeup; | ||
580 | temp = unlink_urbs(dev, &dev->txq) + | ||
581 | unlink_urbs(dev, &dev->rxq); | ||
582 | |||
583 | @@ -748,15 +746,14 @@ static void usbnet_terminate_urbs(struct usbnet *dev) | ||
584 | "waited for %d urb completions\n", temp); | ||
585 | } | ||
586 | set_current_state(TASK_RUNNING); | ||
587 | - dev->wait = NULL; | ||
588 | - remove_wait_queue(&unlink_wakeup, &wait); | ||
589 | + remove_wait_queue(&dev->wait, &wait); | ||
590 | } | ||
591 | |||
592 | int usbnet_stop (struct net_device *net) | ||
593 | { | ||
594 | struct usbnet *dev = netdev_priv(net); | ||
595 | struct driver_info *info = dev->driver_info; | ||
596 | - int retval; | ||
597 | + int retval, pm; | ||
598 | |||
599 | clear_bit(EVENT_DEV_OPEN, &dev->flags); | ||
600 | netif_stop_queue (net); | ||
601 | @@ -766,6 +763,8 @@ int usbnet_stop (struct net_device *net) | ||
602 | net->stats.rx_packets, net->stats.tx_packets, | ||
603 | net->stats.rx_errors, net->stats.tx_errors); | ||
604 | |||
605 | + /* to not race resume */ | ||
606 | + pm = usb_autopm_get_interface(dev->intf); | ||
607 | /* allow minidriver to stop correctly (wireless devices to turn off | ||
608 | * radio etc) */ | ||
609 | if (info->stop) { | ||
610 | @@ -792,6 +791,9 @@ int usbnet_stop (struct net_device *net) | ||
611 | dev->flags = 0; | ||
612 | del_timer_sync (&dev->delay); | ||
613 | tasklet_kill (&dev->bh); | ||
614 | + if (!pm) | ||
615 | + usb_autopm_put_interface(dev->intf); | ||
616 | + | ||
617 | if (info->manage_power && | ||
618 | !test_and_clear_bit(EVENT_NO_RUNTIME_PM, &dev->flags)) | ||
619 | info->manage_power(dev, 0); | ||
620 | @@ -1360,11 +1362,12 @@ static void usbnet_bh (unsigned long param) | ||
621 | /* restart RX again after disabling due to high error rate */ | ||
622 | clear_bit(EVENT_RX_KILL, &dev->flags); | ||
623 | |||
624 | - // waiting for all pending urbs to complete? | ||
625 | - if (dev->wait) { | ||
626 | - if ((dev->txq.qlen + dev->rxq.qlen + dev->done.qlen) == 0) { | ||
627 | - wake_up (dev->wait); | ||
628 | - } | ||
629 | + /* waiting for all pending urbs to complete? | ||
630 | + * only then can we forgo submitting anew | ||
631 | + */ | ||
632 | + if (waitqueue_active(&dev->wait)) { | ||
633 | + if (dev->txq.qlen + dev->rxq.qlen + dev->done.qlen == 0) | ||
634 | + wake_up_all(&dev->wait); | ||
635 | |||
636 | // or are we maybe short a few urbs? | ||
637 | } else if (netif_running (dev->net) && | ||
638 | @@ -1502,6 +1505,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | ||
639 | dev->driver_name = name; | ||
640 | dev->msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV | ||
641 | | NETIF_MSG_PROBE | NETIF_MSG_LINK); | ||
642 | + init_waitqueue_head(&dev->wait); | ||
643 | skb_queue_head_init (&dev->rxq); | ||
644 | skb_queue_head_init (&dev->txq); | ||
645 | skb_queue_head_init (&dev->done); | ||
646 | @@ -1694,9 +1698,10 @@ int usbnet_resume (struct usb_interface *intf) | ||
647 | spin_unlock_irq(&dev->txq.lock); | ||
648 | |||
649 | if (test_bit(EVENT_DEV_OPEN, &dev->flags)) { | ||
650 | - /* handle remote wakeup ASAP */ | ||
651 | - if (!dev->wait && | ||
652 | - netif_device_present(dev->net) && | ||
653 | + /* handle remote wakeup ASAP | ||
654 | + * we cannot race against stop | ||
655 | + */ | ||
656 | + if (netif_device_present(dev->net) && | ||
657 | !timer_pending(&dev->delay) && | ||
658 | !test_bit(EVENT_RX_HALT, &dev->flags)) | ||
659 | rx_alloc_submit(dev, GFP_NOIO); | ||
660 | diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c | ||
661 | index 054489fdf54a..9673edfff451 100644 | ||
662 | --- a/drivers/net/vxlan.c | ||
663 | +++ b/drivers/net/vxlan.c | ||
664 | @@ -845,6 +845,9 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb) | ||
665 | |||
666 | neigh_release(n); | ||
667 | |||
668 | + if (reply == NULL) | ||
669 | + goto out; | ||
670 | + | ||
671 | skb_reset_mac_header(reply); | ||
672 | __skb_pull(reply, skb_network_offset(reply)); | ||
673 | reply->ip_summed = CHECKSUM_UNNECESSARY; | ||
674 | diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c | ||
675 | index 36efb418c26f..70b830f6c4bf 100644 | ||
676 | --- a/drivers/net/xen-netback/netback.c | ||
677 | +++ b/drivers/net/xen-netback/netback.c | ||
678 | @@ -347,8 +347,8 @@ static bool start_new_rx_buffer(int offset, unsigned long size, int head) | ||
679 | * into multiple copies tend to give large frags their | ||
680 | * own buffers as before. | ||
681 | */ | ||
682 | - if ((offset + size > MAX_BUFFER_OFFSET) && | ||
683 | - (size <= MAX_BUFFER_OFFSET) && offset && !head) | ||
684 | + BUG_ON(size > MAX_BUFFER_OFFSET); | ||
685 | + if ((offset + size > MAX_BUFFER_OFFSET) && offset && !head) | ||
686 | return true; | ||
687 | |||
688 | return false; | ||
689 | diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c | ||
690 | index d6a518ce4d6d..c7fdabd0e5d3 100644 | ||
691 | --- a/drivers/vhost/net.c | ||
692 | +++ b/drivers/vhost/net.c | ||
693 | @@ -513,9 +513,13 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, | ||
694 | r = -ENOBUFS; | ||
695 | goto err; | ||
696 | } | ||
697 | - d = vhost_get_vq_desc(vq->dev, vq, vq->iov + seg, | ||
698 | + r = vhost_get_vq_desc(vq->dev, vq, vq->iov + seg, | ||
699 | ARRAY_SIZE(vq->iov) - seg, &out, | ||
700 | &in, log, log_num); | ||
701 | + if (unlikely(r < 0)) | ||
702 | + goto err; | ||
703 | + | ||
704 | + d = r; | ||
705 | if (d == vq->num) { | ||
706 | r = 0; | ||
707 | goto err; | ||
708 | @@ -540,6 +544,12 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, | ||
709 | *iovcount = seg; | ||
710 | if (unlikely(log)) | ||
711 | *log_num = nlogs; | ||
712 | + | ||
713 | + /* Detect overrun */ | ||
714 | + if (unlikely(datalen > 0)) { | ||
715 | + r = UIO_MAXIOV + 1; | ||
716 | + goto err; | ||
717 | + } | ||
718 | return headcount; | ||
719 | err: | ||
720 | vhost_discard_vq_desc(vq, headcount); | ||
721 | @@ -595,6 +605,14 @@ static void handle_rx(struct vhost_net *net) | ||
722 | /* On error, stop handling until the next kick. */ | ||
723 | if (unlikely(headcount < 0)) | ||
724 | break; | ||
725 | + /* On overrun, truncate and discard */ | ||
726 | + if (unlikely(headcount > UIO_MAXIOV)) { | ||
727 | + msg.msg_iovlen = 1; | ||
728 | + err = sock->ops->recvmsg(NULL, sock, &msg, | ||
729 | + 1, MSG_DONTWAIT | MSG_TRUNC); | ||
730 | + pr_debug("Discarded rx packet: len %zd\n", sock_len); | ||
731 | + continue; | ||
732 | + } | ||
733 | /* OK, now we need to know about added descriptors. */ | ||
734 | if (!headcount) { | ||
735 | if (unlikely(vhost_enable_notify(&net->dev, vq))) { | ||
736 | diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h | ||
737 | index 037d36ae63e5..1a81b7470bc4 100644 | ||
738 | --- a/include/linux/cpufreq.h | ||
739 | +++ b/include/linux/cpufreq.h | ||
740 | @@ -107,6 +107,7 @@ struct cpufreq_policy { | ||
741 | unsigned int policy; /* see above */ | ||
742 | struct cpufreq_governor *governor; /* see below */ | ||
743 | void *governor_data; | ||
744 | + bool governor_enabled; /* governor start/stop flag */ | ||
745 | |||
746 | struct work_struct update; /* if update_policy() needs to be | ||
747 | * called, but you're in IRQ context */ | ||
748 | diff --git a/include/linux/futex.h b/include/linux/futex.h | ||
749 | index b0d95cac826e..6435f46d6e13 100644 | ||
750 | --- a/include/linux/futex.h | ||
751 | +++ b/include/linux/futex.h | ||
752 | @@ -55,7 +55,11 @@ union futex_key { | ||
753 | #ifdef CONFIG_FUTEX | ||
754 | extern void exit_robust_list(struct task_struct *curr); | ||
755 | extern void exit_pi_state_list(struct task_struct *curr); | ||
756 | +#ifdef CONFIG_HAVE_FUTEX_CMPXCHG | ||
757 | +#define futex_cmpxchg_enabled 1 | ||
758 | +#else | ||
759 | extern int futex_cmpxchg_enabled; | ||
760 | +#endif | ||
761 | #else | ||
762 | static inline void exit_robust_list(struct task_struct *curr) | ||
763 | { | ||
764 | diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h | ||
765 | index f18d64129f99..123b21bef1b4 100644 | ||
766 | --- a/include/linux/usb/usbnet.h | ||
767 | +++ b/include/linux/usb/usbnet.h | ||
768 | @@ -30,7 +30,7 @@ struct usbnet { | ||
769 | struct driver_info *driver_info; | ||
770 | const char *driver_name; | ||
771 | void *driver_priv; | ||
772 | - wait_queue_head_t *wait; | ||
773 | + wait_queue_head_t wait; | ||
774 | struct mutex phy_mutex; | ||
775 | unsigned char suspend_count; | ||
776 | unsigned char pkt_cnt, pkt_err; | ||
777 | diff --git a/include/net/sock.h b/include/net/sock.h | ||
778 | index cec4c723db9a..8f32b779bc83 100644 | ||
779 | --- a/include/net/sock.h | ||
780 | +++ b/include/net/sock.h | ||
781 | @@ -1437,6 +1437,11 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb) | ||
782 | */ | ||
783 | #define sock_owned_by_user(sk) ((sk)->sk_lock.owned) | ||
784 | |||
785 | +static inline void sock_release_ownership(struct sock *sk) | ||
786 | +{ | ||
787 | + sk->sk_lock.owned = 0; | ||
788 | +} | ||
789 | + | ||
790 | /* | ||
791 | * Macro so as to not evaluate some arguments when | ||
792 | * lockdep is not enabled. | ||
793 | diff --git a/init/Kconfig b/init/Kconfig | ||
794 | index 2d9b83104dcf..5d6febaea56d 100644 | ||
795 | --- a/init/Kconfig | ||
796 | +++ b/init/Kconfig | ||
797 | @@ -1365,6 +1365,13 @@ config FUTEX | ||
798 | support for "fast userspace mutexes". The resulting kernel may not | ||
799 | run glibc-based applications correctly. | ||
800 | |||
801 | +config HAVE_FUTEX_CMPXCHG | ||
802 | + bool | ||
803 | + help | ||
804 | + Architectures should select this if futex_atomic_cmpxchg_inatomic() | ||
805 | + is implemented and always working. This removes a couple of runtime | ||
806 | + checks. | ||
807 | + | ||
808 | config EPOLL | ||
809 | bool "Enable eventpoll support" if EXPERT | ||
810 | default y | ||
811 | diff --git a/kernel/futex.c b/kernel/futex.c | ||
812 | index a283b3041072..3bc18bf48d0c 100644 | ||
813 | --- a/kernel/futex.c | ||
814 | +++ b/kernel/futex.c | ||
815 | @@ -67,7 +67,9 @@ | ||
816 | |||
817 | #include "rtmutex_common.h" | ||
818 | |||
819 | +#ifndef CONFIG_HAVE_FUTEX_CMPXCHG | ||
820 | int __read_mostly futex_cmpxchg_enabled; | ||
821 | +#endif | ||
822 | |||
823 | #define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8) | ||
824 | |||
825 | @@ -2729,10 +2731,10 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, | ||
826 | return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); | ||
827 | } | ||
828 | |||
829 | -static int __init futex_init(void) | ||
830 | +static void __init futex_detect_cmpxchg(void) | ||
831 | { | ||
832 | +#ifndef CONFIG_HAVE_FUTEX_CMPXCHG | ||
833 | u32 curval; | ||
834 | - int i; | ||
835 | |||
836 | /* | ||
837 | * This will fail and we want it. Some arch implementations do | ||
838 | @@ -2746,6 +2748,14 @@ static int __init futex_init(void) | ||
839 | */ | ||
840 | if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT) | ||
841 | futex_cmpxchg_enabled = 1; | ||
842 | +#endif | ||
843 | +} | ||
844 | + | ||
845 | +static int __init futex_init(void) | ||
846 | +{ | ||
847 | + int i; | ||
848 | + | ||
849 | + futex_detect_cmpxchg(); | ||
850 | |||
851 | for (i = 0; i < ARRAY_SIZE(futex_queues); i++) { | ||
852 | plist_head_init(&futex_queues[i].chain); | ||
853 | diff --git a/lib/nlattr.c b/lib/nlattr.c | ||
854 | index 18eca7809b08..fc6754720ced 100644 | ||
855 | --- a/lib/nlattr.c | ||
856 | +++ b/lib/nlattr.c | ||
857 | @@ -303,9 +303,15 @@ int nla_memcmp(const struct nlattr *nla, const void *data, | ||
858 | */ | ||
859 | int nla_strcmp(const struct nlattr *nla, const char *str) | ||
860 | { | ||
861 | - int len = strlen(str) + 1; | ||
862 | - int d = nla_len(nla) - len; | ||
863 | + int len = strlen(str); | ||
864 | + char *buf = nla_data(nla); | ||
865 | + int attrlen = nla_len(nla); | ||
866 | + int d; | ||
867 | |||
868 | + if (attrlen > 0 && buf[attrlen - 1] == '\0') | ||
869 | + attrlen--; | ||
870 | + | ||
871 | + d = attrlen - len; | ||
872 | if (d == 0) | ||
873 | d = memcmp(nla_data(nla), str, len); | ||
874 | |||
875 | diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c | ||
876 | index 9424f3718ea7..86abb2e59aea 100644 | ||
877 | --- a/net/8021q/vlan.c | ||
878 | +++ b/net/8021q/vlan.c | ||
879 | @@ -305,9 +305,11 @@ static void vlan_sync_address(struct net_device *dev, | ||
880 | static void vlan_transfer_features(struct net_device *dev, | ||
881 | struct net_device *vlandev) | ||
882 | { | ||
883 | + struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev); | ||
884 | + | ||
885 | vlandev->gso_max_size = dev->gso_max_size; | ||
886 | |||
887 | - if (dev->features & NETIF_F_HW_VLAN_CTAG_TX) | ||
888 | + if (vlan_hw_offload_capable(dev->features, vlan->vlan_proto)) | ||
889 | vlandev->hard_header_len = dev->hard_header_len; | ||
890 | else | ||
891 | vlandev->hard_header_len = dev->hard_header_len + VLAN_HLEN; | ||
892 | diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c | ||
893 | index 4af64afc7022..cf35f383db4c 100644 | ||
894 | --- a/net/8021q/vlan_dev.c | ||
895 | +++ b/net/8021q/vlan_dev.c | ||
896 | @@ -557,6 +557,9 @@ static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *dev | ||
897 | struct vlan_dev_priv *vlan = vlan_dev_priv(dev); | ||
898 | struct net_device *real_dev = vlan->real_dev; | ||
899 | |||
900 | + if (saddr == NULL) | ||
901 | + saddr = dev->dev_addr; | ||
902 | + | ||
903 | return dev_hard_header(skb, real_dev, type, daddr, saddr, len); | ||
904 | } | ||
905 | |||
906 | @@ -608,7 +611,8 @@ static int vlan_dev_init(struct net_device *dev) | ||
907 | #endif | ||
908 | |||
909 | dev->needed_headroom = real_dev->needed_headroom; | ||
910 | - if (real_dev->features & NETIF_F_HW_VLAN_CTAG_TX) { | ||
911 | + if (vlan_hw_offload_capable(real_dev->features, | ||
912 | + vlan_dev_priv(dev)->vlan_proto)) { | ||
913 | dev->header_ops = &vlan_passthru_header_ops; | ||
914 | dev->hard_header_len = real_dev->hard_header_len; | ||
915 | } else { | ||
916 | diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c | ||
917 | index 2a180a380181..81de0106528b 100644 | ||
918 | --- a/net/bridge/br_multicast.c | ||
919 | +++ b/net/bridge/br_multicast.c | ||
920 | @@ -1176,6 +1176,12 @@ static int br_ip6_multicast_query(struct net_bridge *br, | ||
921 | |||
922 | br_multicast_query_received(br, port, !ipv6_addr_any(&ip6h->saddr)); | ||
923 | |||
924 | + /* RFC2710+RFC3810 (MLDv1+MLDv2) require link-local source addresses */ | ||
925 | + if (!(ipv6_addr_type(&ip6h->saddr) & IPV6_ADDR_LINKLOCAL)) { | ||
926 | + err = -EINVAL; | ||
927 | + goto out; | ||
928 | + } | ||
929 | + | ||
930 | if (skb->len == sizeof(*mld)) { | ||
931 | if (!pskb_may_pull(skb, sizeof(*mld))) { | ||
932 | err = -EINVAL; | ||
933 | diff --git a/net/core/netpoll.c b/net/core/netpoll.c | ||
934 | index 433a1051d323..e861438d5454 100644 | ||
935 | --- a/net/core/netpoll.c | ||
936 | +++ b/net/core/netpoll.c | ||
937 | @@ -745,7 +745,7 @@ static bool pkt_is_ns(struct sk_buff *skb) | ||
938 | struct nd_msg *msg; | ||
939 | struct ipv6hdr *hdr; | ||
940 | |||
941 | - if (skb->protocol != htons(ETH_P_ARP)) | ||
942 | + if (skb->protocol != htons(ETH_P_IPV6)) | ||
943 | return false; | ||
944 | if (!pskb_may_pull(skb, sizeof(struct ipv6hdr) + sizeof(struct nd_msg))) | ||
945 | return false; | ||
946 | diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c | ||
947 | index fd01eca52a13..4c3087dffe78 100644 | ||
948 | --- a/net/core/rtnetlink.c | ||
949 | +++ b/net/core/rtnetlink.c | ||
950 | @@ -1973,12 +1973,13 @@ EXPORT_SYMBOL(rtmsg_ifinfo); | ||
951 | static int nlmsg_populate_fdb_fill(struct sk_buff *skb, | ||
952 | struct net_device *dev, | ||
953 | u8 *addr, u32 pid, u32 seq, | ||
954 | - int type, unsigned int flags) | ||
955 | + int type, unsigned int flags, | ||
956 | + int nlflags) | ||
957 | { | ||
958 | struct nlmsghdr *nlh; | ||
959 | struct ndmsg *ndm; | ||
960 | |||
961 | - nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ndm), NLM_F_MULTI); | ||
962 | + nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ndm), nlflags); | ||
963 | if (!nlh) | ||
964 | return -EMSGSIZE; | ||
965 | |||
966 | @@ -2016,7 +2017,7 @@ static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, int type) | ||
967 | if (!skb) | ||
968 | goto errout; | ||
969 | |||
970 | - err = nlmsg_populate_fdb_fill(skb, dev, addr, 0, 0, type, NTF_SELF); | ||
971 | + err = nlmsg_populate_fdb_fill(skb, dev, addr, 0, 0, type, NTF_SELF, 0); | ||
972 | if (err < 0) { | ||
973 | kfree_skb(skb); | ||
974 | goto errout; | ||
975 | @@ -2249,7 +2250,8 @@ static int nlmsg_populate_fdb(struct sk_buff *skb, | ||
976 | |||
977 | err = nlmsg_populate_fdb_fill(skb, dev, ha->addr, | ||
978 | portid, seq, | ||
979 | - RTM_NEWNEIGH, NTF_SELF); | ||
980 | + RTM_NEWNEIGH, NTF_SELF, | ||
981 | + NLM_F_MULTI); | ||
982 | if (err < 0) | ||
983 | return err; | ||
984 | skip: | ||
985 | diff --git a/net/core/sock.c b/net/core/sock.c | ||
986 | index 3ba527074f7f..d743099250f4 100644 | ||
987 | --- a/net/core/sock.c | ||
988 | +++ b/net/core/sock.c | ||
989 | @@ -2309,10 +2309,13 @@ void release_sock(struct sock *sk) | ||
990 | if (sk->sk_backlog.tail) | ||
991 | __release_sock(sk); | ||
992 | |||
993 | + /* Warning : release_cb() might need to release sk ownership, | ||
994 | + * ie call sock_release_ownership(sk) before us. | ||
995 | + */ | ||
996 | if (sk->sk_prot->release_cb) | ||
997 | sk->sk_prot->release_cb(sk); | ||
998 | |||
999 | - sk->sk_lock.owned = 0; | ||
1000 | + sock_release_ownership(sk); | ||
1001 | if (waitqueue_active(&sk->sk_lock.wq)) | ||
1002 | wake_up(&sk->sk_lock.wq); | ||
1003 | spin_unlock_bh(&sk->sk_lock.slock); | ||
1004 | diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c | ||
1005 | index 7e06641e36ae..af02a39175e3 100644 | ||
1006 | --- a/net/ipv4/inet_fragment.c | ||
1007 | +++ b/net/ipv4/inet_fragment.c | ||
1008 | @@ -211,7 +211,7 @@ int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force) | ||
1009 | } | ||
1010 | |||
1011 | work = frag_mem_limit(nf) - nf->low_thresh; | ||
1012 | - while (work > 0) { | ||
1013 | + while (work > 0 || force) { | ||
1014 | spin_lock(&nf->lru_lock); | ||
1015 | |||
1016 | if (list_empty(&nf->lru_list)) { | ||
1017 | @@ -283,9 +283,10 @@ static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf, | ||
1018 | |||
1019 | atomic_inc(&qp->refcnt); | ||
1020 | hlist_add_head(&qp->list, &hb->chain); | ||
1021 | + inet_frag_lru_add(nf, qp); | ||
1022 | spin_unlock(&hb->chain_lock); | ||
1023 | read_unlock(&f->lock); | ||
1024 | - inet_frag_lru_add(nf, qp); | ||
1025 | + | ||
1026 | return qp; | ||
1027 | } | ||
1028 | |||
1029 | diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c | ||
1030 | index 7dbad6835843..49797ed0917c 100644 | ||
1031 | --- a/net/ipv4/ipmr.c | ||
1032 | +++ b/net/ipv4/ipmr.c | ||
1033 | @@ -2255,13 +2255,14 @@ int ipmr_get_route(struct net *net, struct sk_buff *skb, | ||
1034 | } | ||
1035 | |||
1036 | static int ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, | ||
1037 | - u32 portid, u32 seq, struct mfc_cache *c, int cmd) | ||
1038 | + u32 portid, u32 seq, struct mfc_cache *c, int cmd, | ||
1039 | + int flags) | ||
1040 | { | ||
1041 | struct nlmsghdr *nlh; | ||
1042 | struct rtmsg *rtm; | ||
1043 | int err; | ||
1044 | |||
1045 | - nlh = nlmsg_put(skb, portid, seq, cmd, sizeof(*rtm), NLM_F_MULTI); | ||
1046 | + nlh = nlmsg_put(skb, portid, seq, cmd, sizeof(*rtm), flags); | ||
1047 | if (nlh == NULL) | ||
1048 | return -EMSGSIZE; | ||
1049 | |||
1050 | @@ -2329,7 +2330,7 @@ static void mroute_netlink_event(struct mr_table *mrt, struct mfc_cache *mfc, | ||
1051 | if (skb == NULL) | ||
1052 | goto errout; | ||
1053 | |||
1054 | - err = ipmr_fill_mroute(mrt, skb, 0, 0, mfc, cmd); | ||
1055 | + err = ipmr_fill_mroute(mrt, skb, 0, 0, mfc, cmd, 0); | ||
1056 | if (err < 0) | ||
1057 | goto errout; | ||
1058 | |||
1059 | @@ -2368,7 +2369,8 @@ static int ipmr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb) | ||
1060 | if (ipmr_fill_mroute(mrt, skb, | ||
1061 | NETLINK_CB(cb->skb).portid, | ||
1062 | cb->nlh->nlmsg_seq, | ||
1063 | - mfc, RTM_NEWROUTE) < 0) | ||
1064 | + mfc, RTM_NEWROUTE, | ||
1065 | + NLM_F_MULTI) < 0) | ||
1066 | goto done; | ||
1067 | next_entry: | ||
1068 | e++; | ||
1069 | @@ -2382,7 +2384,8 @@ next_entry: | ||
1070 | if (ipmr_fill_mroute(mrt, skb, | ||
1071 | NETLINK_CB(cb->skb).portid, | ||
1072 | cb->nlh->nlmsg_seq, | ||
1073 | - mfc, RTM_NEWROUTE) < 0) { | ||
1074 | + mfc, RTM_NEWROUTE, | ||
1075 | + NLM_F_MULTI) < 0) { | ||
1076 | spin_unlock_bh(&mfc_unres_lock); | ||
1077 | goto done; | ||
1078 | } | ||
1079 | diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c | ||
1080 | index 6da3d94a114b..4a4e8746d1b2 100644 | ||
1081 | --- a/net/ipv4/tcp_output.c | ||
1082 | +++ b/net/ipv4/tcp_output.c | ||
1083 | @@ -755,6 +755,17 @@ void tcp_release_cb(struct sock *sk) | ||
1084 | if (flags & (1UL << TCP_TSQ_DEFERRED)) | ||
1085 | tcp_tsq_handler(sk); | ||
1086 | |||
1087 | + /* Here begins the tricky part : | ||
1088 | + * We are called from release_sock() with : | ||
1089 | + * 1) BH disabled | ||
1090 | + * 2) sk_lock.slock spinlock held | ||
1091 | + * 3) socket owned by us (sk->sk_lock.owned == 1) | ||
1092 | + * | ||
1093 | + * But following code is meant to be called from BH handlers, | ||
1094 | + * so we should keep BH disabled, but early release socket ownership | ||
1095 | + */ | ||
1096 | + sock_release_ownership(sk); | ||
1097 | + | ||
1098 | if (flags & (1UL << TCP_WRITE_TIMER_DEFERRED)) { | ||
1099 | tcp_write_timer_handler(sk); | ||
1100 | __sock_put(sk); | ||
1101 | diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c | ||
1102 | index b78a3ee93d52..7bcdd0df68db 100644 | ||
1103 | --- a/net/ipv6/addrconf.c | ||
1104 | +++ b/net/ipv6/addrconf.c | ||
1105 | @@ -1111,8 +1111,11 @@ retry: | ||
1106 | * Lifetime is greater than REGEN_ADVANCE time units. In particular, | ||
1107 | * an implementation must not create a temporary address with a zero | ||
1108 | * Preferred Lifetime. | ||
1109 | + * Use age calculation as in addrconf_verify to avoid unnecessary | ||
1110 | + * temporary addresses being generated. | ||
1111 | */ | ||
1112 | - if (tmp_prefered_lft <= regen_advance) { | ||
1113 | + age = (now - tmp_tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ; | ||
1114 | + if (tmp_prefered_lft <= regen_advance + age) { | ||
1115 | in6_ifa_put(ifp); | ||
1116 | in6_dev_put(idev); | ||
1117 | ret = -1; | ||
1118 | diff --git a/net/ipv6/exthdrs_offload.c b/net/ipv6/exthdrs_offload.c | ||
1119 | index cf77f3abfd06..447a7fbd1bb6 100644 | ||
1120 | --- a/net/ipv6/exthdrs_offload.c | ||
1121 | +++ b/net/ipv6/exthdrs_offload.c | ||
1122 | @@ -25,11 +25,11 @@ int __init ipv6_exthdrs_offload_init(void) | ||
1123 | int ret; | ||
1124 | |||
1125 | ret = inet6_add_offload(&rthdr_offload, IPPROTO_ROUTING); | ||
1126 | - if (!ret) | ||
1127 | + if (ret) | ||
1128 | goto out; | ||
1129 | |||
1130 | ret = inet6_add_offload(&dstopt_offload, IPPROTO_DSTOPTS); | ||
1131 | - if (!ret) | ||
1132 | + if (ret) | ||
1133 | goto out_rt; | ||
1134 | |||
1135 | out: | ||
1136 | diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c | ||
1137 | index 70e704d49007..2dee1d9d7305 100644 | ||
1138 | --- a/net/ipv6/icmp.c | ||
1139 | +++ b/net/ipv6/icmp.c | ||
1140 | @@ -508,7 +508,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info) | ||
1141 | np->tclass, NULL, &fl6, (struct rt6_info *)dst, | ||
1142 | MSG_DONTWAIT, np->dontfrag); | ||
1143 | if (err) { | ||
1144 | - ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTERRORS); | ||
1145 | + ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTERRORS); | ||
1146 | ip6_flush_pending_frames(sk); | ||
1147 | } else { | ||
1148 | err = icmpv6_push_pending_frames(sk, &fl6, &tmp_hdr, | ||
1149 | diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c | ||
1150 | index 98a262b759ae..32fb114b86bb 100644 | ||
1151 | --- a/net/ipv6/ip6_output.c | ||
1152 | +++ b/net/ipv6/ip6_output.c | ||
1153 | @@ -1108,21 +1108,19 @@ static void ip6_append_data_mtu(unsigned int *mtu, | ||
1154 | unsigned int fragheaderlen, | ||
1155 | struct sk_buff *skb, | ||
1156 | struct rt6_info *rt, | ||
1157 | - bool pmtuprobe) | ||
1158 | + unsigned int orig_mtu) | ||
1159 | { | ||
1160 | if (!(rt->dst.flags & DST_XFRM_TUNNEL)) { | ||
1161 | if (skb == NULL) { | ||
1162 | /* first fragment, reserve header_len */ | ||
1163 | - *mtu = *mtu - rt->dst.header_len; | ||
1164 | + *mtu = orig_mtu - rt->dst.header_len; | ||
1165 | |||
1166 | } else { | ||
1167 | /* | ||
1168 | * this fragment is not first, the headers | ||
1169 | * space is regarded as data space. | ||
1170 | */ | ||
1171 | - *mtu = min(*mtu, pmtuprobe ? | ||
1172 | - rt->dst.dev->mtu : | ||
1173 | - dst_mtu(rt->dst.path)); | ||
1174 | + *mtu = orig_mtu; | ||
1175 | } | ||
1176 | *maxfraglen = ((*mtu - fragheaderlen) & ~7) | ||
1177 | + fragheaderlen - sizeof(struct frag_hdr); | ||
1178 | @@ -1139,7 +1137,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, | ||
1179 | struct ipv6_pinfo *np = inet6_sk(sk); | ||
1180 | struct inet_cork *cork; | ||
1181 | struct sk_buff *skb, *skb_prev = NULL; | ||
1182 | - unsigned int maxfraglen, fragheaderlen, mtu; | ||
1183 | + unsigned int maxfraglen, fragheaderlen, mtu, orig_mtu; | ||
1184 | int exthdrlen; | ||
1185 | int dst_exthdrlen; | ||
1186 | int hh_len; | ||
1187 | @@ -1221,6 +1219,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, | ||
1188 | dst_exthdrlen = 0; | ||
1189 | mtu = cork->fragsize; | ||
1190 | } | ||
1191 | + orig_mtu = mtu; | ||
1192 | |||
1193 | hh_len = LL_RESERVED_SPACE(rt->dst.dev); | ||
1194 | |||
1195 | @@ -1300,8 +1299,7 @@ alloc_new_skb: | ||
1196 | if (skb == NULL || skb_prev == NULL) | ||
1197 | ip6_append_data_mtu(&mtu, &maxfraglen, | ||
1198 | fragheaderlen, skb, rt, | ||
1199 | - np->pmtudisc == | ||
1200 | - IPV6_PMTUDISC_PROBE); | ||
1201 | + orig_mtu); | ||
1202 | |||
1203 | skb_prev = skb; | ||
1204 | |||
1205 | @@ -1556,8 +1554,8 @@ int ip6_push_pending_frames(struct sock *sk) | ||
1206 | if (proto == IPPROTO_ICMPV6) { | ||
1207 | struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb)); | ||
1208 | |||
1209 | - ICMP6MSGOUT_INC_STATS_BH(net, idev, icmp6_hdr(skb)->icmp6_type); | ||
1210 | - ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS); | ||
1211 | + ICMP6MSGOUT_INC_STATS(net, idev, icmp6_hdr(skb)->icmp6_type); | ||
1212 | + ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTMSGS); | ||
1213 | } | ||
1214 | |||
1215 | err = ip6_local_out(skb); | ||
1216 | diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c | ||
1217 | index 9f44ebc17759..2c84072b1da7 100644 | ||
1218 | --- a/net/ipv6/ip6mr.c | ||
1219 | +++ b/net/ipv6/ip6mr.c | ||
1220 | @@ -2351,13 +2351,14 @@ int ip6mr_get_route(struct net *net, | ||
1221 | } | ||
1222 | |||
1223 | static int ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, | ||
1224 | - u32 portid, u32 seq, struct mfc6_cache *c, int cmd) | ||
1225 | + u32 portid, u32 seq, struct mfc6_cache *c, int cmd, | ||
1226 | + int flags) | ||
1227 | { | ||
1228 | struct nlmsghdr *nlh; | ||
1229 | struct rtmsg *rtm; | ||
1230 | int err; | ||
1231 | |||
1232 | - nlh = nlmsg_put(skb, portid, seq, cmd, sizeof(*rtm), NLM_F_MULTI); | ||
1233 | + nlh = nlmsg_put(skb, portid, seq, cmd, sizeof(*rtm), flags); | ||
1234 | if (nlh == NULL) | ||
1235 | return -EMSGSIZE; | ||
1236 | |||
1237 | @@ -2425,7 +2426,7 @@ static void mr6_netlink_event(struct mr6_table *mrt, struct mfc6_cache *mfc, | ||
1238 | if (skb == NULL) | ||
1239 | goto errout; | ||
1240 | |||
1241 | - err = ip6mr_fill_mroute(mrt, skb, 0, 0, mfc, cmd); | ||
1242 | + err = ip6mr_fill_mroute(mrt, skb, 0, 0, mfc, cmd, 0); | ||
1243 | if (err < 0) | ||
1244 | goto errout; | ||
1245 | |||
1246 | @@ -2464,7 +2465,8 @@ static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb) | ||
1247 | if (ip6mr_fill_mroute(mrt, skb, | ||
1248 | NETLINK_CB(cb->skb).portid, | ||
1249 | cb->nlh->nlmsg_seq, | ||
1250 | - mfc, RTM_NEWROUTE) < 0) | ||
1251 | + mfc, RTM_NEWROUTE, | ||
1252 | + NLM_F_MULTI) < 0) | ||
1253 | goto done; | ||
1254 | next_entry: | ||
1255 | e++; | ||
1256 | @@ -2478,7 +2480,8 @@ next_entry: | ||
1257 | if (ip6mr_fill_mroute(mrt, skb, | ||
1258 | NETLINK_CB(cb->skb).portid, | ||
1259 | cb->nlh->nlmsg_seq, | ||
1260 | - mfc, RTM_NEWROUTE) < 0) { | ||
1261 | + mfc, RTM_NEWROUTE, | ||
1262 | + NLM_F_MULTI) < 0) { | ||
1263 | spin_unlock_bh(&mfc_unres_lock); | ||
1264 | goto done; | ||
1265 | } | ||
1266 | diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c | ||
1267 | index 952eaed38808..734aec059ffd 100644 | ||
1268 | --- a/net/ipv6/mcast.c | ||
1269 | +++ b/net/ipv6/mcast.c | ||
1270 | @@ -1439,11 +1439,12 @@ static void mld_sendpack(struct sk_buff *skb) | ||
1271 | dst_output); | ||
1272 | out: | ||
1273 | if (!err) { | ||
1274 | - ICMP6MSGOUT_INC_STATS_BH(net, idev, ICMPV6_MLD2_REPORT); | ||
1275 | - ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS); | ||
1276 | - IP6_UPD_PO_STATS_BH(net, idev, IPSTATS_MIB_OUTMCAST, payload_len); | ||
1277 | - } else | ||
1278 | - IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_OUTDISCARDS); | ||
1279 | + ICMP6MSGOUT_INC_STATS(net, idev, ICMPV6_MLD2_REPORT); | ||
1280 | + ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTMSGS); | ||
1281 | + IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUTMCAST, payload_len); | ||
1282 | + } else { | ||
1283 | + IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS); | ||
1284 | + } | ||
1285 | |||
1286 | rcu_read_unlock(); | ||
1287 | return; | ||
1288 | diff --git a/net/ipv6/route.c b/net/ipv6/route.c | ||
1289 | index 6c389300f4e9..3fde3e977862 100644 | ||
1290 | --- a/net/ipv6/route.c | ||
1291 | +++ b/net/ipv6/route.c | ||
1292 | @@ -1428,7 +1428,7 @@ int ip6_route_add(struct fib6_config *cfg) | ||
1293 | if (!table) | ||
1294 | goto out; | ||
1295 | |||
1296 | - rt = ip6_dst_alloc(net, NULL, DST_NOCOUNT, table); | ||
1297 | + rt = ip6_dst_alloc(net, NULL, (cfg->fc_flags & RTF_ADDRCONF) ? 0 : DST_NOCOUNT, table); | ||
1298 | |||
1299 | if (!rt) { | ||
1300 | err = -ENOMEM; | ||
1301 | diff --git a/net/rds/iw.c b/net/rds/iw.c | ||
1302 | index 7826d46baa70..589935661d66 100644 | ||
1303 | --- a/net/rds/iw.c | ||
1304 | +++ b/net/rds/iw.c | ||
1305 | @@ -239,7 +239,8 @@ static int rds_iw_laddr_check(__be32 addr) | ||
1306 | ret = rdma_bind_addr(cm_id, (struct sockaddr *)&sin); | ||
1307 | /* due to this, we will claim to support IB devices unless we | ||
1308 | check node_type. */ | ||
1309 | - if (ret || cm_id->device->node_type != RDMA_NODE_RNIC) | ||
1310 | + if (ret || !cm_id->device || | ||
1311 | + cm_id->device->node_type != RDMA_NODE_RNIC) | ||
1312 | ret = -EADDRNOTAVAIL; | ||
1313 | |||
1314 | rdsdebug("addr %pI4 ret %d node type %d\n", | ||
1315 | diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c | ||
1316 | index cf579e71cff0..673921cfb97e 100644 | ||
1317 | --- a/net/sctp/sm_make_chunk.c | ||
1318 | +++ b/net/sctp/sm_make_chunk.c | ||
1319 | @@ -1403,8 +1403,8 @@ static void sctp_chunk_destroy(struct sctp_chunk *chunk) | ||
1320 | BUG_ON(!list_empty(&chunk->list)); | ||
1321 | list_del_init(&chunk->transmitted_list); | ||
1322 | |||
1323 | - /* Free the chunk skb data and the SCTP_chunk stub itself. */ | ||
1324 | - dev_kfree_skb(chunk->skb); | ||
1325 | + consume_skb(chunk->skb); | ||
1326 | + consume_skb(chunk->auth_chunk); | ||
1327 | |||
1328 | SCTP_DBG_OBJCNT_DEC(chunk); | ||
1329 | kmem_cache_free(sctp_chunk_cachep, chunk); | ||
1330 | diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c | ||
1331 | index 7ceb25ba85b8..9973079401c4 100644 | ||
1332 | --- a/net/sctp/sm_statefuns.c | ||
1333 | +++ b/net/sctp/sm_statefuns.c | ||
1334 | @@ -767,7 +767,6 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(struct net *net, | ||
1335 | |||
1336 | /* Make sure that we and the peer are AUTH capable */ | ||
1337 | if (!net->sctp.auth_enable || !new_asoc->peer.auth_capable) { | ||
1338 | - kfree_skb(chunk->auth_chunk); | ||
1339 | sctp_association_free(new_asoc); | ||
1340 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); | ||
1341 | } | ||
1342 | @@ -782,10 +781,6 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(struct net *net, | ||
1343 | auth.transport = chunk->transport; | ||
1344 | |||
1345 | ret = sctp_sf_authenticate(net, ep, new_asoc, type, &auth); | ||
1346 | - | ||
1347 | - /* We can now safely free the auth_chunk clone */ | ||
1348 | - kfree_skb(chunk->auth_chunk); | ||
1349 | - | ||
1350 | if (ret != SCTP_IERROR_NO_ERROR) { | ||
1351 | sctp_association_free(new_asoc); | ||
1352 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); | ||
1353 | diff --git a/net/socket.c b/net/socket.c | ||
1354 | index ac72efc3d965..fc90b4f0da3c 100644 | ||
1355 | --- a/net/socket.c | ||
1356 | +++ b/net/socket.c | ||
1357 | @@ -1964,6 +1964,10 @@ static int copy_msghdr_from_user(struct msghdr *kmsg, | ||
1358 | { | ||
1359 | if (copy_from_user(kmsg, umsg, sizeof(struct msghdr))) | ||
1360 | return -EFAULT; | ||
1361 | + | ||
1362 | + if (kmsg->msg_namelen < 0) | ||
1363 | + return -EINVAL; | ||
1364 | + | ||
1365 | if (kmsg->msg_namelen > sizeof(struct sockaddr_storage)) | ||
1366 | kmsg->msg_namelen = sizeof(struct sockaddr_storage); | ||
1367 | return 0; | ||
1368 | diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c | ||
1369 | index 94d334781554..75e198d029d2 100644 | ||
1370 | --- a/net/unix/af_unix.c | ||
1371 | +++ b/net/unix/af_unix.c | ||
1372 | @@ -1792,8 +1792,11 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, | ||
1373 | goto out; | ||
1374 | |||
1375 | err = mutex_lock_interruptible(&u->readlock); | ||
1376 | - if (err) { | ||
1377 | - err = sock_intr_errno(sock_rcvtimeo(sk, noblock)); | ||
1378 | + if (unlikely(err)) { | ||
1379 | + /* recvmsg() in non blocking mode is supposed to return -EAGAIN | ||
1380 | + * sk_rcvtimeo is not honored by mutex_lock_interruptible() | ||
1381 | + */ | ||
1382 | + err = noblock ? -EAGAIN : -ERESTARTSYS; | ||
1383 | goto out; | ||
1384 | } | ||
1385 | |||
1386 | @@ -1913,6 +1916,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | ||
1387 | struct unix_sock *u = unix_sk(sk); | ||
1388 | struct sockaddr_un *sunaddr = msg->msg_name; | ||
1389 | int copied = 0; | ||
1390 | + int noblock = flags & MSG_DONTWAIT; | ||
1391 | int check_creds = 0; | ||
1392 | int target; | ||
1393 | int err = 0; | ||
1394 | @@ -1928,7 +1932,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | ||
1395 | goto out; | ||
1396 | |||
1397 | target = sock_rcvlowat(sk, flags&MSG_WAITALL, size); | ||
1398 | - timeo = sock_rcvtimeo(sk, flags&MSG_DONTWAIT); | ||
1399 | + timeo = sock_rcvtimeo(sk, noblock); | ||
1400 | |||
1401 | /* Lock the socket to prevent queue disordering | ||
1402 | * while sleeps in memcpy_tomsg | ||
1403 | @@ -1940,8 +1944,11 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | ||
1404 | } | ||
1405 | |||
1406 | err = mutex_lock_interruptible(&u->readlock); | ||
1407 | - if (err) { | ||
1408 | - err = sock_intr_errno(timeo); | ||
1409 | + if (unlikely(err)) { | ||
1410 | + /* recvmsg() in non blocking mode is supposed to return -EAGAIN | ||
1411 | + * sk_rcvtimeo is not honored by mutex_lock_interruptible() | ||
1412 | + */ | ||
1413 | + err = noblock ? -EAGAIN : -ERESTARTSYS; | ||
1414 | goto out; | ||
1415 | } | ||
1416 | |||
1417 | diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst | ||
1418 | index 182084d728c8..8ccf83056a7a 100644 | ||
1419 | --- a/scripts/Makefile.headersinst | ||
1420 | +++ b/scripts/Makefile.headersinst | ||
1421 | @@ -47,18 +47,24 @@ header-y := $(filter-out $(generic-y), $(header-y)) | ||
1422 | all-files := $(header-y) $(genhdr-y) $(wrapper-files) | ||
1423 | output-files := $(addprefix $(installdir)/, $(all-files)) | ||
1424 | |||
1425 | -input-files := $(foreach hdr, $(header-y), \ | ||
1426 | +input-files1 := $(foreach hdr, $(header-y), \ | ||
1427 | $(if $(wildcard $(srcdir)/$(hdr)), \ | ||
1428 | - $(wildcard $(srcdir)/$(hdr)), \ | ||
1429 | + $(wildcard $(srcdir)/$(hdr))) \ | ||
1430 | + ) | ||
1431 | +input-files1-name := $(notdir $(input-files1)) | ||
1432 | +input-files2 := $(foreach hdr, $(header-y), \ | ||
1433 | + $(if $(wildcard $(srcdir)/$(hdr)),, \ | ||
1434 | $(if $(wildcard $(oldsrcdir)/$(hdr)), \ | ||
1435 | $(wildcard $(oldsrcdir)/$(hdr)), \ | ||
1436 | $(error Missing UAPI file $(srcdir)/$(hdr))) \ | ||
1437 | - )) \ | ||
1438 | - $(foreach hdr, $(genhdr-y), \ | ||
1439 | + )) | ||
1440 | +input-files2-name := $(notdir $(input-files2)) | ||
1441 | +input-files3 := $(foreach hdr, $(genhdr-y), \ | ||
1442 | $(if $(wildcard $(gendir)/$(hdr)), \ | ||
1443 | $(wildcard $(gendir)/$(hdr)), \ | ||
1444 | $(error Missing generated UAPI file $(gendir)/$(hdr)) \ | ||
1445 | )) | ||
1446 | +input-files3-name := $(notdir $(input-files3)) | ||
1447 | |||
1448 | # Work out what needs to be removed | ||
1449 | oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) | ||
1450 | @@ -72,7 +78,9 @@ printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) | ||
1451 | quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ | ||
1452 | file$(if $(word 2, $(all-files)),s)) | ||
1453 | cmd_install = \ | ||
1454 | - $(CONFIG_SHELL) $< $(installdir) $(input-files); \ | ||
1455 | + $(CONFIG_SHELL) $< $(installdir) $(srcdir) $(input-files1-name); \ | ||
1456 | + $(CONFIG_SHELL) $< $(installdir) $(oldsrcdir) $(input-files2-name); \ | ||
1457 | + $(CONFIG_SHELL) $< $(installdir) $(gendir) $(input-files3-name); \ | ||
1458 | for F in $(wrapper-files); do \ | ||
1459 | echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \ | ||
1460 | done; \ | ||
1461 | @@ -98,7 +106,7 @@ __headersinst: $(subdirs) $(install-file) | ||
1462 | @: | ||
1463 | |||
1464 | targets += $(install-file) | ||
1465 | -$(install-file): scripts/headers_install.sh $(input-files) FORCE | ||
1466 | +$(install-file): scripts/headers_install.sh $(input-files1) $(input-files2) $(input-files3) FORCE | ||
1467 | $(if $(unwanted),$(call cmd,remove),) | ||
1468 | $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) | ||
1469 | $(call if_changed,install) | ||
1470 | diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh | ||
1471 | index 643764f53ea7..5de5660cb708 100644 | ||
1472 | --- a/scripts/headers_install.sh | ||
1473 | +++ b/scripts/headers_install.sh | ||
1474 | @@ -2,7 +2,7 @@ | ||
1475 | |||
1476 | if [ $# -lt 1 ] | ||
1477 | then | ||
1478 | - echo "Usage: headers_install.sh OUTDIR [FILES...] | ||
1479 | + echo "Usage: headers_install.sh OUTDIR SRCDIR [FILES...] | ||
1480 | echo | ||
1481 | echo "Prepares kernel header files for use by user space, by removing" | ||
1482 | echo "all compiler.h definitions and #includes, removing any" | ||
1483 | @@ -10,6 +10,7 @@ then | ||
1484 | echo "asm/inline/volatile keywords." | ||
1485 | echo | ||
1486 | echo "OUTDIR: directory to write each userspace header FILE to." | ||
1487 | + echo "SRCDIR: source directory where files are picked." | ||
1488 | echo "FILES: list of header files to operate on." | ||
1489 | |||
1490 | exit 1 | ||
1491 | @@ -19,6 +20,8 @@ fi | ||
1492 | |||
1493 | OUTDIR="$1" | ||
1494 | shift | ||
1495 | +SRCDIR="$1" | ||
1496 | +shift | ||
1497 | |||
1498 | # Iterate through files listed on command line | ||
1499 | |||
1500 | @@ -34,7 +37,7 @@ do | ||
1501 | -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \ | ||
1502 | -e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \ | ||
1503 | -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \ | ||
1504 | - "$i" > "$OUTDIR/$FILE.sed" || exit 1 | ||
1505 | + "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1 | ||
1506 | scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \ | ||
1507 | > "$OUTDIR/$FILE" | ||
1508 | [ $? -gt 1 ] && exit 1 | ||
1509 | diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c | ||
1510 | index a7096e130c04..70d4a8a7f21c 100644 | ||
1511 | --- a/security/selinux/hooks.c | ||
1512 | +++ b/security/selinux/hooks.c | ||
1513 | @@ -1361,15 +1361,33 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent | ||
1514 | isec->sid = sbsec->sid; | ||
1515 | |||
1516 | if ((sbsec->flags & SE_SBPROC) && !S_ISLNK(inode->i_mode)) { | ||
1517 | - if (opt_dentry) { | ||
1518 | - isec->sclass = inode_mode_to_security_class(inode->i_mode); | ||
1519 | - rc = selinux_proc_get_sid(opt_dentry, | ||
1520 | - isec->sclass, | ||
1521 | - &sid); | ||
1522 | - if (rc) | ||
1523 | - goto out_unlock; | ||
1524 | - isec->sid = sid; | ||
1525 | - } | ||
1526 | + /* We must have a dentry to determine the label on | ||
1527 | + * procfs inodes */ | ||
1528 | + if (opt_dentry) | ||
1529 | + /* Called from d_instantiate or | ||
1530 | + * d_splice_alias. */ | ||
1531 | + dentry = dget(opt_dentry); | ||
1532 | + else | ||
1533 | + /* Called from selinux_complete_init, try to | ||
1534 | + * find a dentry. */ | ||
1535 | + dentry = d_find_alias(inode); | ||
1536 | + /* | ||
1537 | + * This can be hit on boot when a file is accessed | ||
1538 | + * before the policy is loaded. When we load policy we | ||
1539 | + * may find inodes that have no dentry on the | ||
1540 | + * sbsec->isec_head list. No reason to complain as | ||
1541 | + * these will get fixed up the next time we go through | ||
1542 | + * inode_doinit() with a dentry, before these inodes | ||
1543 | + * could be used again by userspace. | ||
1544 | + */ | ||
1545 | + if (!dentry) | ||
1546 | + goto out_unlock; | ||
1547 | + isec->sclass = inode_mode_to_security_class(inode->i_mode); | ||
1548 | + rc = selinux_proc_get_sid(dentry, isec->sclass, &sid); | ||
1549 | + dput(dentry); | ||
1550 | + if (rc) | ||
1551 | + goto out_unlock; | ||
1552 | + isec->sid = sid; | ||
1553 | } | ||
1554 | break; | ||
1555 | } |