1 |
commit: 6594b9d62b8be3c01b3fdd0cb2befdfb3ea6d67c |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jun 27 14:59:56 2014 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jun 27 14:59:56 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/linux-patches.git;a=commit;h=6594b9d6 |
7 |
|
8 |
Linux patch 3.14.9 |
9 |
|
10 |
--- |
11 |
0000_README | 4 + |
12 |
1008_linux-3.14.9.patch | 3272 +++++++++++++++++++++++++++++++++++++++++++++++ |
13 |
2 files changed, 3276 insertions(+) |
14 |
|
15 |
diff --git a/0000_README b/0000_README |
16 |
index 4c8b812..d0fbbbf 100644 |
17 |
--- a/0000_README |
18 |
+++ b/0000_README |
19 |
@@ -74,6 +74,10 @@ Patch: 1007_linux-3.14.8.patch |
20 |
From: http://www.kernel.org |
21 |
Desc: Linux 3.14.8 |
22 |
|
23 |
+Patch: 1008_linux-3.14.9.patch |
24 |
+From: http://www.kernel.org |
25 |
+Desc: Linux 3.14.9 |
26 |
+ |
27 |
Patch: 1500_XATTR_USER_PREFIX.patch |
28 |
From: https://bugs.gentoo.org/show_bug.cgi?id=470644 |
29 |
Desc: Support for namespace user.pax.* on tmpfs. |
30 |
|
31 |
diff --git a/1008_linux-3.14.9.patch b/1008_linux-3.14.9.patch |
32 |
new file mode 100644 |
33 |
index 0000000..696e263 |
34 |
--- /dev/null |
35 |
+++ b/1008_linux-3.14.9.patch |
36 |
@@ -0,0 +1,3272 @@ |
37 |
+diff --git a/Documentation/ABI/testing/ima_policy b/Documentation/ABI/testing/ima_policy |
38 |
+index f1c5cc9d17a8..4c3efe434806 100644 |
39 |
+--- a/Documentation/ABI/testing/ima_policy |
40 |
++++ b/Documentation/ABI/testing/ima_policy |
41 |
+@@ -23,7 +23,7 @@ Description: |
42 |
+ [fowner]] |
43 |
+ lsm: [[subj_user=] [subj_role=] [subj_type=] |
44 |
+ [obj_user=] [obj_role=] [obj_type=]] |
45 |
+- option: [[appraise_type=]] |
46 |
++ option: [[appraise_type=]] [permit_directio] |
47 |
+ |
48 |
+ base: func:= [BPRM_CHECK][MMAP_CHECK][FILE_CHECK][MODULE_CHECK] |
49 |
+ mask:= [MAY_READ] [MAY_WRITE] [MAY_APPEND] [MAY_EXEC] |
50 |
+diff --git a/Makefile b/Makefile |
51 |
+index ef1d59b750ea..ee247656432f 100644 |
52 |
+--- a/Makefile |
53 |
++++ b/Makefile |
54 |
+@@ -1,6 +1,6 @@ |
55 |
+ VERSION = 3 |
56 |
+ PATCHLEVEL = 14 |
57 |
+-SUBLEVEL = 8 |
58 |
++SUBLEVEL = 9 |
59 |
+ EXTRAVERSION = |
60 |
+ NAME = Remembering Coco |
61 |
+ |
62 |
+diff --git a/arch/arm/mach-at91/sysirq_mask.c b/arch/arm/mach-at91/sysirq_mask.c |
63 |
+index 2ba694f9626b..f8bc3511a8c8 100644 |
64 |
+--- a/arch/arm/mach-at91/sysirq_mask.c |
65 |
++++ b/arch/arm/mach-at91/sysirq_mask.c |
66 |
+@@ -25,24 +25,28 @@ |
67 |
+ |
68 |
+ #include "generic.h" |
69 |
+ |
70 |
+-#define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */ |
71 |
+-#define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */ |
72 |
++#define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */ |
73 |
++#define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */ |
74 |
++#define AT91_RTC_IRQ_MASK 0x1f /* Available IRQs mask */ |
75 |
+ |
76 |
+ void __init at91_sysirq_mask_rtc(u32 rtc_base) |
77 |
+ { |
78 |
+ void __iomem *base; |
79 |
+- u32 mask; |
80 |
+ |
81 |
+ base = ioremap(rtc_base, 64); |
82 |
+ if (!base) |
83 |
+ return; |
84 |
+ |
85 |
+- mask = readl_relaxed(base + AT91_RTC_IMR); |
86 |
+- if (mask) { |
87 |
+- pr_info("AT91: Disabling rtc irq\n"); |
88 |
+- writel_relaxed(mask, base + AT91_RTC_IDR); |
89 |
+- (void)readl_relaxed(base + AT91_RTC_IMR); /* flush */ |
90 |
+- } |
91 |
++ /* |
92 |
++ * sam9x5 SoCs have the following errata: |
93 |
++ * "RTC: Interrupt Mask Register cannot be used |
94 |
++ * Interrupt Mask Register read always returns 0." |
95 |
++ * |
96 |
++ * Hence we're not relying on IMR values to disable |
97 |
++ * interrupts. |
98 |
++ */ |
99 |
++ writel_relaxed(AT91_RTC_IRQ_MASK, base + AT91_RTC_IDR); |
100 |
++ (void)readl_relaxed(base + AT91_RTC_IMR); /* flush */ |
101 |
+ |
102 |
+ iounmap(base); |
103 |
+ } |
104 |
+diff --git a/arch/mips/kvm/kvm_mips.c b/arch/mips/kvm/kvm_mips.c |
105 |
+index da5186fbd77a..5efce56f0df0 100644 |
106 |
+--- a/arch/mips/kvm/kvm_mips.c |
107 |
++++ b/arch/mips/kvm/kvm_mips.c |
108 |
+@@ -304,7 +304,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) |
109 |
+ if (cpu_has_veic || cpu_has_vint) { |
110 |
+ size = 0x200 + VECTORSPACING * 64; |
111 |
+ } else { |
112 |
+- size = 0x200; |
113 |
++ size = 0x4000; |
114 |
+ } |
115 |
+ |
116 |
+ /* Save Linux EBASE */ |
117 |
+diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c |
118 |
+index 01fe9946d388..44d258da0a1b 100644 |
119 |
+--- a/arch/sparc/net/bpf_jit_comp.c |
120 |
++++ b/arch/sparc/net/bpf_jit_comp.c |
121 |
+@@ -83,9 +83,9 @@ static void bpf_flush_icache(void *start_, void *end_) |
122 |
+ #define BNE (F2(0, 2) | CONDNE) |
123 |
+ |
124 |
+ #ifdef CONFIG_SPARC64 |
125 |
+-#define BNE_PTR (F2(0, 1) | CONDNE | (2 << 20)) |
126 |
++#define BE_PTR (F2(0, 1) | CONDE | (2 << 20)) |
127 |
+ #else |
128 |
+-#define BNE_PTR BNE |
129 |
++#define BE_PTR BE |
130 |
+ #endif |
131 |
+ |
132 |
+ #define SETHI(K, REG) \ |
133 |
+@@ -600,7 +600,7 @@ void bpf_jit_compile(struct sk_filter *fp) |
134 |
+ case BPF_S_ANC_IFINDEX: |
135 |
+ emit_skb_loadptr(dev, r_A); |
136 |
+ emit_cmpi(r_A, 0); |
137 |
+- emit_branch(BNE_PTR, cleanup_addr + 4); |
138 |
++ emit_branch(BE_PTR, cleanup_addr + 4); |
139 |
+ emit_nop(); |
140 |
+ emit_load32(r_A, struct net_device, ifindex, r_A); |
141 |
+ break; |
142 |
+@@ -613,7 +613,7 @@ void bpf_jit_compile(struct sk_filter *fp) |
143 |
+ case BPF_S_ANC_HATYPE: |
144 |
+ emit_skb_loadptr(dev, r_A); |
145 |
+ emit_cmpi(r_A, 0); |
146 |
+- emit_branch(BNE_PTR, cleanup_addr + 4); |
147 |
++ emit_branch(BE_PTR, cleanup_addr + 4); |
148 |
+ emit_nop(); |
149 |
+ emit_load16(r_A, struct net_device, type, r_A); |
150 |
+ break; |
151 |
+diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c |
152 |
+index 9736529ade08..006911858174 100644 |
153 |
+--- a/arch/x86/kvm/lapic.c |
154 |
++++ b/arch/x86/kvm/lapic.c |
155 |
+@@ -360,6 +360,8 @@ static inline void apic_clear_irr(int vec, struct kvm_lapic *apic) |
156 |
+ |
157 |
+ static inline void apic_set_isr(int vec, struct kvm_lapic *apic) |
158 |
+ { |
159 |
++ /* Note that we never get here with APIC virtualization enabled. */ |
160 |
++ |
161 |
+ if (!__apic_test_and_set_vector(vec, apic->regs + APIC_ISR)) |
162 |
+ ++apic->isr_count; |
163 |
+ BUG_ON(apic->isr_count > MAX_APIC_VECTOR); |
164 |
+@@ -371,12 +373,48 @@ static inline void apic_set_isr(int vec, struct kvm_lapic *apic) |
165 |
+ apic->highest_isr_cache = vec; |
166 |
+ } |
167 |
+ |
168 |
++static inline int apic_find_highest_isr(struct kvm_lapic *apic) |
169 |
++{ |
170 |
++ int result; |
171 |
++ |
172 |
++ /* |
173 |
++ * Note that isr_count is always 1, and highest_isr_cache |
174 |
++ * is always -1, with APIC virtualization enabled. |
175 |
++ */ |
176 |
++ if (!apic->isr_count) |
177 |
++ return -1; |
178 |
++ if (likely(apic->highest_isr_cache != -1)) |
179 |
++ return apic->highest_isr_cache; |
180 |
++ |
181 |
++ result = find_highest_vector(apic->regs + APIC_ISR); |
182 |
++ ASSERT(result == -1 || result >= 16); |
183 |
++ |
184 |
++ return result; |
185 |
++} |
186 |
++ |
187 |
+ static inline void apic_clear_isr(int vec, struct kvm_lapic *apic) |
188 |
+ { |
189 |
+- if (__apic_test_and_clear_vector(vec, apic->regs + APIC_ISR)) |
190 |
++ struct kvm_vcpu *vcpu; |
191 |
++ if (!__apic_test_and_clear_vector(vec, apic->regs + APIC_ISR)) |
192 |
++ return; |
193 |
++ |
194 |
++ vcpu = apic->vcpu; |
195 |
++ |
196 |
++ /* |
197 |
++ * We do get here for APIC virtualization enabled if the guest |
198 |
++ * uses the Hyper-V APIC enlightenment. In this case we may need |
199 |
++ * to trigger a new interrupt delivery by writing the SVI field; |
200 |
++ * on the other hand isr_count and highest_isr_cache are unused |
201 |
++ * and must be left alone. |
202 |
++ */ |
203 |
++ if (unlikely(kvm_apic_vid_enabled(vcpu->kvm))) |
204 |
++ kvm_x86_ops->hwapic_isr_update(vcpu->kvm, |
205 |
++ apic_find_highest_isr(apic)); |
206 |
++ else { |
207 |
+ --apic->isr_count; |
208 |
+- BUG_ON(apic->isr_count < 0); |
209 |
+- apic->highest_isr_cache = -1; |
210 |
++ BUG_ON(apic->isr_count < 0); |
211 |
++ apic->highest_isr_cache = -1; |
212 |
++ } |
213 |
+ } |
214 |
+ |
215 |
+ int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu) |
216 |
+@@ -456,22 +494,6 @@ static void pv_eoi_clr_pending(struct kvm_vcpu *vcpu) |
217 |
+ __clear_bit(KVM_APIC_PV_EOI_PENDING, &vcpu->arch.apic_attention); |
218 |
+ } |
219 |
+ |
220 |
+-static inline int apic_find_highest_isr(struct kvm_lapic *apic) |
221 |
+-{ |
222 |
+- int result; |
223 |
+- |
224 |
+- /* Note that isr_count is always 1 with vid enabled */ |
225 |
+- if (!apic->isr_count) |
226 |
+- return -1; |
227 |
+- if (likely(apic->highest_isr_cache != -1)) |
228 |
+- return apic->highest_isr_cache; |
229 |
+- |
230 |
+- result = find_highest_vector(apic->regs + APIC_ISR); |
231 |
+- ASSERT(result == -1 || result >= 16); |
232 |
+- |
233 |
+- return result; |
234 |
+-} |
235 |
+- |
236 |
+ void kvm_apic_update_tmr(struct kvm_vcpu *vcpu, u32 *tmr) |
237 |
+ { |
238 |
+ struct kvm_lapic *apic = vcpu->arch.apic; |
239 |
+@@ -1605,6 +1627,8 @@ int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu) |
240 |
+ int vector = kvm_apic_has_interrupt(vcpu); |
241 |
+ struct kvm_lapic *apic = vcpu->arch.apic; |
242 |
+ |
243 |
++ /* Note that we never get here with APIC virtualization enabled. */ |
244 |
++ |
245 |
+ if (vector == -1) |
246 |
+ return -1; |
247 |
+ |
248 |
+diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c |
249 |
+index 1512e41cd93d..43665d0d0905 100644 |
250 |
+--- a/crypto/crypto_user.c |
251 |
++++ b/crypto/crypto_user.c |
252 |
+@@ -466,7 +466,7 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
253 |
+ type -= CRYPTO_MSG_BASE; |
254 |
+ link = &crypto_dispatch[type]; |
255 |
+ |
256 |
+- if (!capable(CAP_NET_ADMIN)) |
257 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
258 |
+ return -EPERM; |
259 |
+ |
260 |
+ if ((type == (CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE) && |
261 |
+diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c |
262 |
+index 18c5b9b16645..3165811e2407 100644 |
263 |
+--- a/drivers/connector/cn_proc.c |
264 |
++++ b/drivers/connector/cn_proc.c |
265 |
+@@ -369,7 +369,7 @@ static void cn_proc_mcast_ctl(struct cn_msg *msg, |
266 |
+ return; |
267 |
+ |
268 |
+ /* Can only change if privileged. */ |
269 |
+- if (!capable(CAP_NET_ADMIN)) { |
270 |
++ if (!__netlink_ns_capable(nsp, &init_user_ns, CAP_NET_ADMIN)) { |
271 |
+ err = EPERM; |
272 |
+ goto out; |
273 |
+ } |
274 |
+diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c |
275 |
+index 2e7801af466e..05827eccc53a 100644 |
276 |
+--- a/drivers/hv/connection.c |
277 |
++++ b/drivers/hv/connection.c |
278 |
+@@ -224,8 +224,8 @@ cleanup: |
279 |
+ vmbus_connection.int_page = NULL; |
280 |
+ } |
281 |
+ |
282 |
+- free_pages((unsigned long)vmbus_connection.monitor_pages[0], 1); |
283 |
+- free_pages((unsigned long)vmbus_connection.monitor_pages[1], 1); |
284 |
++ free_pages((unsigned long)vmbus_connection.monitor_pages[0], 0); |
285 |
++ free_pages((unsigned long)vmbus_connection.monitor_pages[1], 0); |
286 |
+ vmbus_connection.monitor_pages[0] = NULL; |
287 |
+ vmbus_connection.monitor_pages[1] = NULL; |
288 |
+ |
289 |
+diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c |
290 |
+index 7e17a5495e02..393fd8a98735 100644 |
291 |
+--- a/drivers/hv/hv_balloon.c |
292 |
++++ b/drivers/hv/hv_balloon.c |
293 |
+@@ -19,6 +19,7 @@ |
294 |
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
295 |
+ |
296 |
+ #include <linux/kernel.h> |
297 |
++#include <linux/jiffies.h> |
298 |
+ #include <linux/mman.h> |
299 |
+ #include <linux/delay.h> |
300 |
+ #include <linux/init.h> |
301 |
+@@ -459,6 +460,11 @@ static bool do_hot_add; |
302 |
+ */ |
303 |
+ static uint pressure_report_delay = 45; |
304 |
+ |
305 |
++/* |
306 |
++ * The last time we posted a pressure report to host. |
307 |
++ */ |
308 |
++static unsigned long last_post_time; |
309 |
++ |
310 |
+ module_param(hot_add, bool, (S_IRUGO | S_IWUSR)); |
311 |
+ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add"); |
312 |
+ |
313 |
+@@ -542,6 +548,7 @@ struct hv_dynmem_device { |
314 |
+ |
315 |
+ static struct hv_dynmem_device dm_device; |
316 |
+ |
317 |
++static void post_status(struct hv_dynmem_device *dm); |
318 |
+ #ifdef CONFIG_MEMORY_HOTPLUG |
319 |
+ |
320 |
+ static void hv_bring_pgs_online(unsigned long start_pfn, unsigned long size) |
321 |
+@@ -612,7 +619,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size, |
322 |
+ * have not been "onlined" within the allowed time. |
323 |
+ */ |
324 |
+ wait_for_completion_timeout(&dm_device.ol_waitevent, 5*HZ); |
325 |
+- |
326 |
++ post_status(&dm_device); |
327 |
+ } |
328 |
+ |
329 |
+ return; |
330 |
+@@ -951,11 +958,17 @@ static void post_status(struct hv_dynmem_device *dm) |
331 |
+ { |
332 |
+ struct dm_status status; |
333 |
+ struct sysinfo val; |
334 |
++ unsigned long now = jiffies; |
335 |
++ unsigned long last_post = last_post_time; |
336 |
+ |
337 |
+ if (pressure_report_delay > 0) { |
338 |
+ --pressure_report_delay; |
339 |
+ return; |
340 |
+ } |
341 |
++ |
342 |
++ if (!time_after(now, (last_post_time + HZ))) |
343 |
++ return; |
344 |
++ |
345 |
+ si_meminfo(&val); |
346 |
+ memset(&status, 0, sizeof(struct dm_status)); |
347 |
+ status.hdr.type = DM_STATUS_REPORT; |
348 |
+@@ -983,6 +996,14 @@ static void post_status(struct hv_dynmem_device *dm) |
349 |
+ if (status.hdr.trans_id != atomic_read(&trans_id)) |
350 |
+ return; |
351 |
+ |
352 |
++ /* |
353 |
++ * If the last post time that we sampled has changed, |
354 |
++ * we have raced, don't post the status. |
355 |
++ */ |
356 |
++ if (last_post != last_post_time) |
357 |
++ return; |
358 |
++ |
359 |
++ last_post_time = jiffies; |
360 |
+ vmbus_sendpacket(dm->dev->channel, &status, |
361 |
+ sizeof(struct dm_status), |
362 |
+ (unsigned long)NULL, |
363 |
+@@ -1117,7 +1138,7 @@ static void balloon_up(struct work_struct *dummy) |
364 |
+ |
365 |
+ if (ret == -EAGAIN) |
366 |
+ msleep(20); |
367 |
+- |
368 |
++ post_status(&dm_device); |
369 |
+ } while (ret == -EAGAIN); |
370 |
+ |
371 |
+ if (ret) { |
372 |
+@@ -1144,8 +1165,10 @@ static void balloon_down(struct hv_dynmem_device *dm, |
373 |
+ struct dm_unballoon_response resp; |
374 |
+ int i; |
375 |
+ |
376 |
+- for (i = 0; i < range_count; i++) |
377 |
++ for (i = 0; i < range_count; i++) { |
378 |
+ free_balloon_pages(dm, &range_array[i]); |
379 |
++ post_status(&dm_device); |
380 |
++ } |
381 |
+ |
382 |
+ if (req->more_pages == 1) |
383 |
+ return; |
384 |
+diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c |
385 |
+index bbba014c9939..e6bf77d1ec08 100644 |
386 |
+--- a/drivers/iio/adc/at91_adc.c |
387 |
++++ b/drivers/iio/adc/at91_adc.c |
388 |
+@@ -322,12 +322,11 @@ static int at91_adc_channel_init(struct iio_dev *idev) |
389 |
+ return idev->num_channels; |
390 |
+ } |
391 |
+ |
392 |
+-static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev, |
393 |
++static int at91_adc_get_trigger_value_by_name(struct iio_dev *idev, |
394 |
+ struct at91_adc_trigger *triggers, |
395 |
+ const char *trigger_name) |
396 |
+ { |
397 |
+ struct at91_adc_state *st = iio_priv(idev); |
398 |
+- u8 value = 0; |
399 |
+ int i; |
400 |
+ |
401 |
+ for (i = 0; i < st->trigger_number; i++) { |
402 |
+@@ -340,15 +339,16 @@ static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev, |
403 |
+ return -ENOMEM; |
404 |
+ |
405 |
+ if (strcmp(trigger_name, name) == 0) { |
406 |
+- value = triggers[i].value; |
407 |
+ kfree(name); |
408 |
+- break; |
409 |
++ if (triggers[i].value == 0) |
410 |
++ return -EINVAL; |
411 |
++ return triggers[i].value; |
412 |
+ } |
413 |
+ |
414 |
+ kfree(name); |
415 |
+ } |
416 |
+ |
417 |
+- return value; |
418 |
++ return -EINVAL; |
419 |
+ } |
420 |
+ |
421 |
+ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) |
422 |
+@@ -358,14 +358,14 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) |
423 |
+ struct iio_buffer *buffer = idev->buffer; |
424 |
+ struct at91_adc_reg_desc *reg = st->registers; |
425 |
+ u32 status = at91_adc_readl(st, reg->trigger_register); |
426 |
+- u8 value; |
427 |
++ int value; |
428 |
+ u8 bit; |
429 |
+ |
430 |
+ value = at91_adc_get_trigger_value_by_name(idev, |
431 |
+ st->trigger_list, |
432 |
+ idev->trig->name); |
433 |
+- if (value == 0) |
434 |
+- return -EINVAL; |
435 |
++ if (value < 0) |
436 |
++ return value; |
437 |
+ |
438 |
+ if (state) { |
439 |
+ st->buffer = kmalloc(idev->scan_bytes, GFP_KERNEL); |
440 |
+diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c |
441 |
+index 360259266d4f..ef5ffc0c37a4 100644 |
442 |
+--- a/drivers/iio/adc/max1363.c |
443 |
++++ b/drivers/iio/adc/max1363.c |
444 |
+@@ -1258,8 +1258,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { |
445 |
+ .num_modes = ARRAY_SIZE(max1238_mode_list), |
446 |
+ .default_mode = s0to11, |
447 |
+ .info = &max1238_info, |
448 |
+- .channels = max1238_channels, |
449 |
+- .num_channels = ARRAY_SIZE(max1238_channels), |
450 |
++ .channels = max1038_channels, |
451 |
++ .num_channels = ARRAY_SIZE(max1038_channels), |
452 |
+ }, |
453 |
+ [max11605] = { |
454 |
+ .bits = 8, |
455 |
+@@ -1268,8 +1268,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { |
456 |
+ .num_modes = ARRAY_SIZE(max1238_mode_list), |
457 |
+ .default_mode = s0to11, |
458 |
+ .info = &max1238_info, |
459 |
+- .channels = max1238_channels, |
460 |
+- .num_channels = ARRAY_SIZE(max1238_channels), |
461 |
++ .channels = max1038_channels, |
462 |
++ .num_channels = ARRAY_SIZE(max1038_channels), |
463 |
+ }, |
464 |
+ [max11606] = { |
465 |
+ .bits = 10, |
466 |
+@@ -1318,8 +1318,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { |
467 |
+ .num_modes = ARRAY_SIZE(max1238_mode_list), |
468 |
+ .default_mode = s0to11, |
469 |
+ .info = &max1238_info, |
470 |
+- .channels = max1238_channels, |
471 |
+- .num_channels = ARRAY_SIZE(max1238_channels), |
472 |
++ .channels = max1138_channels, |
473 |
++ .num_channels = ARRAY_SIZE(max1138_channels), |
474 |
+ }, |
475 |
+ [max11611] = { |
476 |
+ .bits = 10, |
477 |
+@@ -1328,8 +1328,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { |
478 |
+ .num_modes = ARRAY_SIZE(max1238_mode_list), |
479 |
+ .default_mode = s0to11, |
480 |
+ .info = &max1238_info, |
481 |
+- .channels = max1238_channels, |
482 |
+- .num_channels = ARRAY_SIZE(max1238_channels), |
483 |
++ .channels = max1138_channels, |
484 |
++ .num_channels = ARRAY_SIZE(max1138_channels), |
485 |
+ }, |
486 |
+ [max11612] = { |
487 |
+ .bits = 12, |
488 |
+diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c |
489 |
+index 05423543f89d..053117c02bbc 100644 |
490 |
+--- a/drivers/iio/magnetometer/ak8975.c |
491 |
++++ b/drivers/iio/magnetometer/ak8975.c |
492 |
+@@ -352,8 +352,6 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) |
493 |
+ { |
494 |
+ struct ak8975_data *data = iio_priv(indio_dev); |
495 |
+ struct i2c_client *client = data->client; |
496 |
+- u16 meas_reg; |
497 |
+- s16 raw; |
498 |
+ int ret; |
499 |
+ |
500 |
+ mutex_lock(&data->lock); |
501 |
+@@ -401,16 +399,11 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) |
502 |
+ dev_err(&client->dev, "Read axis data fails\n"); |
503 |
+ goto exit; |
504 |
+ } |
505 |
+- meas_reg = ret; |
506 |
+ |
507 |
+ mutex_unlock(&data->lock); |
508 |
+ |
509 |
+- /* Endian conversion of the measured values. */ |
510 |
+- raw = (s16) (le16_to_cpu(meas_reg)); |
511 |
+- |
512 |
+ /* Clamp to valid range. */ |
513 |
+- raw = clamp_t(s16, raw, -4096, 4095); |
514 |
+- *val = raw; |
515 |
++ *val = clamp_t(s16, ret, -4096, 4095); |
516 |
+ return IIO_VAL_INT; |
517 |
+ |
518 |
+ exit: |
519 |
+diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c |
520 |
+index ac8c8ab723e5..fe53669eeeeb 100644 |
521 |
+--- a/drivers/iio/pressure/mpl3115.c |
522 |
++++ b/drivers/iio/pressure/mpl3115.c |
523 |
+@@ -98,7 +98,7 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev, |
524 |
+ mutex_unlock(&data->lock); |
525 |
+ if (ret < 0) |
526 |
+ return ret; |
527 |
+- *val = sign_extend32(be32_to_cpu(tmp) >> 12, 23); |
528 |
++ *val = be32_to_cpu(tmp) >> 12; |
529 |
+ return IIO_VAL_INT; |
530 |
+ case IIO_TEMP: /* in 0.0625 celsius / LSB */ |
531 |
+ mutex_lock(&data->lock); |
532 |
+@@ -112,7 +112,7 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev, |
533 |
+ mutex_unlock(&data->lock); |
534 |
+ if (ret < 0) |
535 |
+ return ret; |
536 |
+- *val = sign_extend32(be32_to_cpu(tmp) >> 20, 15); |
537 |
++ *val = sign_extend32(be32_to_cpu(tmp) >> 20, 11); |
538 |
+ return IIO_VAL_INT; |
539 |
+ default: |
540 |
+ return -EINVAL; |
541 |
+@@ -185,7 +185,7 @@ static const struct iio_chan_spec mpl3115_channels[] = { |
542 |
+ BIT(IIO_CHAN_INFO_SCALE), |
543 |
+ .scan_index = 0, |
544 |
+ .scan_type = { |
545 |
+- .sign = 's', |
546 |
++ .sign = 'u', |
547 |
+ .realbits = 20, |
548 |
+ .storagebits = 32, |
549 |
+ .shift = 12, |
550 |
+diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c |
551 |
+index 95c316bb7a42..4a13b0001471 100644 |
552 |
+--- a/drivers/net/ethernet/mellanox/mlx4/main.c |
553 |
++++ b/drivers/net/ethernet/mellanox/mlx4/main.c |
554 |
+@@ -2275,13 +2275,8 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) |
555 |
+ /* Allow large DMA segments, up to the firmware limit of 1 GB */ |
556 |
+ dma_set_max_seg_size(&pdev->dev, 1024 * 1024 * 1024); |
557 |
+ |
558 |
+- priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
559 |
+- if (!priv) { |
560 |
+- err = -ENOMEM; |
561 |
+- goto err_release_regions; |
562 |
+- } |
563 |
+- |
564 |
+- dev = &priv->dev; |
565 |
++ dev = pci_get_drvdata(pdev); |
566 |
++ priv = mlx4_priv(dev); |
567 |
+ dev->pdev = pdev; |
568 |
+ INIT_LIST_HEAD(&priv->ctx_list); |
569 |
+ spin_lock_init(&priv->ctx_lock); |
570 |
+@@ -2465,8 +2460,7 @@ slave_start: |
571 |
+ mlx4_sense_init(dev); |
572 |
+ mlx4_start_sense(dev); |
573 |
+ |
574 |
+- priv->pci_dev_data = pci_dev_data; |
575 |
+- pci_set_drvdata(pdev, dev); |
576 |
++ priv->removed = 0; |
577 |
+ |
578 |
+ return 0; |
579 |
+ |
580 |
+@@ -2532,84 +2526,108 @@ err_disable_pdev: |
581 |
+ |
582 |
+ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
583 |
+ { |
584 |
++ struct mlx4_priv *priv; |
585 |
++ struct mlx4_dev *dev; |
586 |
++ |
587 |
+ printk_once(KERN_INFO "%s", mlx4_version); |
588 |
+ |
589 |
++ priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
590 |
++ if (!priv) |
591 |
++ return -ENOMEM; |
592 |
++ |
593 |
++ dev = &priv->dev; |
594 |
++ pci_set_drvdata(pdev, dev); |
595 |
++ priv->pci_dev_data = id->driver_data; |
596 |
++ |
597 |
+ return __mlx4_init_one(pdev, id->driver_data); |
598 |
+ } |
599 |
+ |
600 |
+-static void mlx4_remove_one(struct pci_dev *pdev) |
601 |
++static void __mlx4_remove_one(struct pci_dev *pdev) |
602 |
+ { |
603 |
+ struct mlx4_dev *dev = pci_get_drvdata(pdev); |
604 |
+ struct mlx4_priv *priv = mlx4_priv(dev); |
605 |
++ int pci_dev_data; |
606 |
+ int p; |
607 |
+ |
608 |
+- if (dev) { |
609 |
+- /* in SRIOV it is not allowed to unload the pf's |
610 |
+- * driver while there are alive vf's */ |
611 |
+- if (mlx4_is_master(dev)) { |
612 |
+- if (mlx4_how_many_lives_vf(dev)) |
613 |
+- printk(KERN_ERR "Removing PF when there are assigned VF's !!!\n"); |
614 |
+- } |
615 |
+- mlx4_stop_sense(dev); |
616 |
+- mlx4_unregister_device(dev); |
617 |
++ if (priv->removed) |
618 |
++ return; |
619 |
+ |
620 |
+- for (p = 1; p <= dev->caps.num_ports; p++) { |
621 |
+- mlx4_cleanup_port_info(&priv->port[p]); |
622 |
+- mlx4_CLOSE_PORT(dev, p); |
623 |
+- } |
624 |
++ pci_dev_data = priv->pci_dev_data; |
625 |
+ |
626 |
+- if (mlx4_is_master(dev)) |
627 |
+- mlx4_free_resource_tracker(dev, |
628 |
+- RES_TR_FREE_SLAVES_ONLY); |
629 |
+- |
630 |
+- mlx4_cleanup_counters_table(dev); |
631 |
+- mlx4_cleanup_qp_table(dev); |
632 |
+- mlx4_cleanup_srq_table(dev); |
633 |
+- mlx4_cleanup_cq_table(dev); |
634 |
+- mlx4_cmd_use_polling(dev); |
635 |
+- mlx4_cleanup_eq_table(dev); |
636 |
+- mlx4_cleanup_mcg_table(dev); |
637 |
+- mlx4_cleanup_mr_table(dev); |
638 |
+- mlx4_cleanup_xrcd_table(dev); |
639 |
+- mlx4_cleanup_pd_table(dev); |
640 |
++ /* in SRIOV it is not allowed to unload the pf's |
641 |
++ * driver while there are alive vf's */ |
642 |
++ if (mlx4_is_master(dev) && mlx4_how_many_lives_vf(dev)) |
643 |
++ printk(KERN_ERR "Removing PF when there are assigned VF's !!!\n"); |
644 |
++ mlx4_stop_sense(dev); |
645 |
++ mlx4_unregister_device(dev); |
646 |
+ |
647 |
+- if (mlx4_is_master(dev)) |
648 |
+- mlx4_free_resource_tracker(dev, |
649 |
+- RES_TR_FREE_STRUCTS_ONLY); |
650 |
+- |
651 |
+- iounmap(priv->kar); |
652 |
+- mlx4_uar_free(dev, &priv->driver_uar); |
653 |
+- mlx4_cleanup_uar_table(dev); |
654 |
+- if (!mlx4_is_slave(dev)) |
655 |
+- mlx4_clear_steering(dev); |
656 |
+- mlx4_free_eq_table(dev); |
657 |
+- if (mlx4_is_master(dev)) |
658 |
+- mlx4_multi_func_cleanup(dev); |
659 |
+- mlx4_close_hca(dev); |
660 |
+- if (mlx4_is_slave(dev)) |
661 |
+- mlx4_multi_func_cleanup(dev); |
662 |
+- mlx4_cmd_cleanup(dev); |
663 |
+- |
664 |
+- if (dev->flags & MLX4_FLAG_MSI_X) |
665 |
+- pci_disable_msix(pdev); |
666 |
+- if (dev->flags & MLX4_FLAG_SRIOV) { |
667 |
+- mlx4_warn(dev, "Disabling SR-IOV\n"); |
668 |
+- pci_disable_sriov(pdev); |
669 |
+- } |
670 |
++ for (p = 1; p <= dev->caps.num_ports; p++) { |
671 |
++ mlx4_cleanup_port_info(&priv->port[p]); |
672 |
++ mlx4_CLOSE_PORT(dev, p); |
673 |
++ } |
674 |
+ |
675 |
+- if (!mlx4_is_slave(dev)) |
676 |
+- mlx4_free_ownership(dev); |
677 |
++ if (mlx4_is_master(dev)) |
678 |
++ mlx4_free_resource_tracker(dev, |
679 |
++ RES_TR_FREE_SLAVES_ONLY); |
680 |
++ |
681 |
++ mlx4_cleanup_counters_table(dev); |
682 |
++ mlx4_cleanup_qp_table(dev); |
683 |
++ mlx4_cleanup_srq_table(dev); |
684 |
++ mlx4_cleanup_cq_table(dev); |
685 |
++ mlx4_cmd_use_polling(dev); |
686 |
++ mlx4_cleanup_eq_table(dev); |
687 |
++ mlx4_cleanup_mcg_table(dev); |
688 |
++ mlx4_cleanup_mr_table(dev); |
689 |
++ mlx4_cleanup_xrcd_table(dev); |
690 |
++ mlx4_cleanup_pd_table(dev); |
691 |
+ |
692 |
+- kfree(dev->caps.qp0_tunnel); |
693 |
+- kfree(dev->caps.qp0_proxy); |
694 |
+- kfree(dev->caps.qp1_tunnel); |
695 |
+- kfree(dev->caps.qp1_proxy); |
696 |
++ if (mlx4_is_master(dev)) |
697 |
++ mlx4_free_resource_tracker(dev, |
698 |
++ RES_TR_FREE_STRUCTS_ONLY); |
699 |
+ |
700 |
+- kfree(priv); |
701 |
+- pci_release_regions(pdev); |
702 |
+- pci_disable_device(pdev); |
703 |
+- pci_set_drvdata(pdev, NULL); |
704 |
++ iounmap(priv->kar); |
705 |
++ mlx4_uar_free(dev, &priv->driver_uar); |
706 |
++ mlx4_cleanup_uar_table(dev); |
707 |
++ if (!mlx4_is_slave(dev)) |
708 |
++ mlx4_clear_steering(dev); |
709 |
++ mlx4_free_eq_table(dev); |
710 |
++ if (mlx4_is_master(dev)) |
711 |
++ mlx4_multi_func_cleanup(dev); |
712 |
++ mlx4_close_hca(dev); |
713 |
++ if (mlx4_is_slave(dev)) |
714 |
++ mlx4_multi_func_cleanup(dev); |
715 |
++ mlx4_cmd_cleanup(dev); |
716 |
++ |
717 |
++ if (dev->flags & MLX4_FLAG_MSI_X) |
718 |
++ pci_disable_msix(pdev); |
719 |
++ if (dev->flags & MLX4_FLAG_SRIOV) { |
720 |
++ mlx4_warn(dev, "Disabling SR-IOV\n"); |
721 |
++ pci_disable_sriov(pdev); |
722 |
+ } |
723 |
++ |
724 |
++ if (!mlx4_is_slave(dev)) |
725 |
++ mlx4_free_ownership(dev); |
726 |
++ |
727 |
++ kfree(dev->caps.qp0_tunnel); |
728 |
++ kfree(dev->caps.qp0_proxy); |
729 |
++ kfree(dev->caps.qp1_tunnel); |
730 |
++ kfree(dev->caps.qp1_proxy); |
731 |
++ |
732 |
++ pci_release_regions(pdev); |
733 |
++ pci_disable_device(pdev); |
734 |
++ memset(priv, 0, sizeof(*priv)); |
735 |
++ priv->pci_dev_data = pci_dev_data; |
736 |
++ priv->removed = 1; |
737 |
++} |
738 |
++ |
739 |
++static void mlx4_remove_one(struct pci_dev *pdev) |
740 |
++{ |
741 |
++ struct mlx4_dev *dev = pci_get_drvdata(pdev); |
742 |
++ struct mlx4_priv *priv = mlx4_priv(dev); |
743 |
++ |
744 |
++ __mlx4_remove_one(pdev); |
745 |
++ kfree(priv); |
746 |
++ pci_set_drvdata(pdev, NULL); |
747 |
+ } |
748 |
+ |
749 |
+ int mlx4_restart_one(struct pci_dev *pdev) |
750 |
+@@ -2619,7 +2637,7 @@ int mlx4_restart_one(struct pci_dev *pdev) |
751 |
+ int pci_dev_data; |
752 |
+ |
753 |
+ pci_dev_data = priv->pci_dev_data; |
754 |
+- mlx4_remove_one(pdev); |
755 |
++ __mlx4_remove_one(pdev); |
756 |
+ return __mlx4_init_one(pdev, pci_dev_data); |
757 |
+ } |
758 |
+ |
759 |
+@@ -2674,7 +2692,7 @@ MODULE_DEVICE_TABLE(pci, mlx4_pci_table); |
760 |
+ static pci_ers_result_t mlx4_pci_err_detected(struct pci_dev *pdev, |
761 |
+ pci_channel_state_t state) |
762 |
+ { |
763 |
+- mlx4_remove_one(pdev); |
764 |
++ __mlx4_remove_one(pdev); |
765 |
+ |
766 |
+ return state == pci_channel_io_perm_failure ? |
767 |
+ PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET; |
768 |
+@@ -2682,11 +2700,11 @@ static pci_ers_result_t mlx4_pci_err_detected(struct pci_dev *pdev, |
769 |
+ |
770 |
+ static pci_ers_result_t mlx4_pci_slot_reset(struct pci_dev *pdev) |
771 |
+ { |
772 |
+- const struct pci_device_id *id; |
773 |
+- int ret; |
774 |
++ struct mlx4_dev *dev = pci_get_drvdata(pdev); |
775 |
++ struct mlx4_priv *priv = mlx4_priv(dev); |
776 |
++ int ret; |
777 |
+ |
778 |
+- id = pci_match_id(mlx4_pci_table, pdev); |
779 |
+- ret = __mlx4_init_one(pdev, id->driver_data); |
780 |
++ ret = __mlx4_init_one(pdev, priv->pci_dev_data); |
781 |
+ |
782 |
+ return ret ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED; |
783 |
+ } |
784 |
+@@ -2700,7 +2718,7 @@ static struct pci_driver mlx4_driver = { |
785 |
+ .name = DRV_NAME, |
786 |
+ .id_table = mlx4_pci_table, |
787 |
+ .probe = mlx4_init_one, |
788 |
+- .shutdown = mlx4_remove_one, |
789 |
++ .shutdown = __mlx4_remove_one, |
790 |
+ .remove = mlx4_remove_one, |
791 |
+ .err_handler = &mlx4_err_handler, |
792 |
+ }; |
793 |
+diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h |
794 |
+index 7aec6c833973..99d7a28a2ada 100644 |
795 |
+--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h |
796 |
++++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h |
797 |
+@@ -796,6 +796,7 @@ struct mlx4_priv { |
798 |
+ spinlock_t ctx_lock; |
799 |
+ |
800 |
+ int pci_dev_data; |
801 |
++ int removed; |
802 |
+ |
803 |
+ struct list_head pgdir_list; |
804 |
+ struct mutex pgdir_mutex; |
805 |
+diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c |
806 |
+index 7d4f54912bad..3e46c894a107 100644 |
807 |
+--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c |
808 |
++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c |
809 |
+@@ -1022,6 +1022,7 @@ static int qlcnic_dcb_peer_app_info(struct net_device *netdev, |
810 |
+ struct qlcnic_dcb_cee *peer; |
811 |
+ int i; |
812 |
+ |
813 |
++ memset(info, 0, sizeof(*info)); |
814 |
+ *app_count = 0; |
815 |
+ |
816 |
+ if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) |
817 |
+diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c |
818 |
+index 040cb94e8219..957f0ffe31c4 100644 |
819 |
+--- a/drivers/net/ethernet/renesas/sh_eth.c |
820 |
++++ b/drivers/net/ethernet/renesas/sh_eth.c |
821 |
+@@ -301,6 +301,27 @@ static const u16 sh_eth_offset_fast_sh4[SH_ETH_MAX_REGISTER_OFFSET] = { |
822 |
+ }; |
823 |
+ |
824 |
+ static const u16 sh_eth_offset_fast_sh3_sh2[SH_ETH_MAX_REGISTER_OFFSET] = { |
825 |
++ [EDMR] = 0x0000, |
826 |
++ [EDTRR] = 0x0004, |
827 |
++ [EDRRR] = 0x0008, |
828 |
++ [TDLAR] = 0x000c, |
829 |
++ [RDLAR] = 0x0010, |
830 |
++ [EESR] = 0x0014, |
831 |
++ [EESIPR] = 0x0018, |
832 |
++ [TRSCER] = 0x001c, |
833 |
++ [RMFCR] = 0x0020, |
834 |
++ [TFTR] = 0x0024, |
835 |
++ [FDR] = 0x0028, |
836 |
++ [RMCR] = 0x002c, |
837 |
++ [EDOCR] = 0x0030, |
838 |
++ [FCFTR] = 0x0034, |
839 |
++ [RPADIR] = 0x0038, |
840 |
++ [TRIMD] = 0x003c, |
841 |
++ [RBWAR] = 0x0040, |
842 |
++ [RDFAR] = 0x0044, |
843 |
++ [TBRAR] = 0x004c, |
844 |
++ [TDFAR] = 0x0050, |
845 |
++ |
846 |
+ [ECMR] = 0x0160, |
847 |
+ [ECSR] = 0x0164, |
848 |
+ [ECSIPR] = 0x0168, |
849 |
+@@ -539,7 +560,6 @@ static struct sh_eth_cpu_data sh7757_data = { |
850 |
+ .register_type = SH_ETH_REG_FAST_SH4, |
851 |
+ |
852 |
+ .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, |
853 |
+- .rmcr_value = RMCR_RNC, |
854 |
+ |
855 |
+ .tx_check = EESR_FTC | EESR_CND | EESR_DLC | EESR_CD | EESR_RTO, |
856 |
+ .eesr_err_check = EESR_TWB | EESR_TABT | EESR_RABT | EESR_RFE | |
857 |
+@@ -617,7 +637,6 @@ static struct sh_eth_cpu_data sh7757_data_giga = { |
858 |
+ EESR_RFE | EESR_RDE | EESR_RFRMER | EESR_TFE | |
859 |
+ EESR_TDE | EESR_ECI, |
860 |
+ .fdr_value = 0x0000072f, |
861 |
+- .rmcr_value = RMCR_RNC, |
862 |
+ |
863 |
+ .irq_flags = IRQF_SHARED, |
864 |
+ .apr = 1, |
865 |
+@@ -745,7 +764,6 @@ static struct sh_eth_cpu_data r8a7740_data = { |
866 |
+ EESR_RFE | EESR_RDE | EESR_RFRMER | EESR_TFE | |
867 |
+ EESR_TDE | EESR_ECI, |
868 |
+ .fdr_value = 0x0000070f, |
869 |
+- .rmcr_value = RMCR_RNC, |
870 |
+ |
871 |
+ .apr = 1, |
872 |
+ .mpr = 1, |
873 |
+@@ -777,7 +795,6 @@ static struct sh_eth_cpu_data r7s72100_data = { |
874 |
+ EESR_RFE | EESR_RDE | EESR_RFRMER | EESR_TFE | |
875 |
+ EESR_TDE | EESR_ECI, |
876 |
+ .fdr_value = 0x0000070f, |
877 |
+- .rmcr_value = RMCR_RNC, |
878 |
+ |
879 |
+ .no_psr = 1, |
880 |
+ .apr = 1, |
881 |
+@@ -826,9 +843,6 @@ static void sh_eth_set_default_cpu_data(struct sh_eth_cpu_data *cd) |
882 |
+ if (!cd->fdr_value) |
883 |
+ cd->fdr_value = DEFAULT_FDR_INIT; |
884 |
+ |
885 |
+- if (!cd->rmcr_value) |
886 |
+- cd->rmcr_value = DEFAULT_RMCR_VALUE; |
887 |
+- |
888 |
+ if (!cd->tx_check) |
889 |
+ cd->tx_check = DEFAULT_TX_CHECK; |
890 |
+ |
891 |
+@@ -1281,8 +1295,8 @@ static int sh_eth_dev_init(struct net_device *ndev, bool start) |
892 |
+ sh_eth_write(ndev, mdp->cd->fdr_value, FDR); |
893 |
+ sh_eth_write(ndev, 0, TFTR); |
894 |
+ |
895 |
+- /* Frame recv control */ |
896 |
+- sh_eth_write(ndev, mdp->cd->rmcr_value, RMCR); |
897 |
++ /* Frame recv control (enable multiple-packets per rx irq) */ |
898 |
++ sh_eth_write(ndev, RMCR_RNC, RMCR); |
899 |
+ |
900 |
+ sh_eth_write(ndev, DESC_I_RINT8 | DESC_I_RINT5 | DESC_I_TINT2, TRSCER); |
901 |
+ |
902 |
+diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h |
903 |
+index 6075915b88ec..a096b4bf9799 100644 |
904 |
+--- a/drivers/net/ethernet/renesas/sh_eth.h |
905 |
++++ b/drivers/net/ethernet/renesas/sh_eth.h |
906 |
+@@ -320,7 +320,6 @@ enum TD_STS_BIT { |
907 |
+ enum RMCR_BIT { |
908 |
+ RMCR_RNC = 0x00000001, |
909 |
+ }; |
910 |
+-#define DEFAULT_RMCR_VALUE 0x00000000 |
911 |
+ |
912 |
+ /* ECMR */ |
913 |
+ enum FELIC_MODE_BIT { |
914 |
+@@ -467,7 +466,6 @@ struct sh_eth_cpu_data { |
915 |
+ unsigned long fdr_value; |
916 |
+ unsigned long fcftr_value; |
917 |
+ unsigned long rpadir_value; |
918 |
+- unsigned long rmcr_value; |
919 |
+ |
920 |
+ /* interrupt checking mask */ |
921 |
+ unsigned long tx_check; |
922 |
+diff --git a/drivers/net/ethernet/sfc/io.h b/drivers/net/ethernet/sfc/io.h |
923 |
+index 4d3f119b67b3..afb94aa2c15e 100644 |
924 |
+--- a/drivers/net/ethernet/sfc/io.h |
925 |
++++ b/drivers/net/ethernet/sfc/io.h |
926 |
+@@ -66,10 +66,17 @@ |
927 |
+ #define EFX_USE_QWORD_IO 1 |
928 |
+ #endif |
929 |
+ |
930 |
++/* Hardware issue requires that only 64-bit naturally aligned writes |
931 |
++ * are seen by hardware. Its not strictly necessary to restrict to |
932 |
++ * x86_64 arch, but done for safety since unusual write combining behaviour |
933 |
++ * can break PIO. |
934 |
++ */ |
935 |
++#ifdef CONFIG_X86_64 |
936 |
+ /* PIO is a win only if write-combining is possible */ |
937 |
+ #ifdef ARCH_HAS_IOREMAP_WC |
938 |
+ #define EFX_USE_PIO 1 |
939 |
+ #endif |
940 |
++#endif |
941 |
+ |
942 |
+ #ifdef EFX_USE_QWORD_IO |
943 |
+ static inline void _efx_writeq(struct efx_nic *efx, __le64 value, |
944 |
+diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c |
945 |
+index 75d11fa4eb0a..d79c842680a5 100644 |
946 |
+--- a/drivers/net/ethernet/sfc/tx.c |
947 |
++++ b/drivers/net/ethernet/sfc/tx.c |
948 |
+@@ -189,6 +189,18 @@ struct efx_short_copy_buffer { |
949 |
+ u8 buf[L1_CACHE_BYTES]; |
950 |
+ }; |
951 |
+ |
952 |
++/* Copy in explicit 64-bit writes. */ |
953 |
++static void efx_memcpy_64(void __iomem *dest, void *src, size_t len) |
954 |
++{ |
955 |
++ u64 *src64 = src; |
956 |
++ u64 __iomem *dest64 = dest; |
957 |
++ size_t l64 = len / 8; |
958 |
++ size_t i; |
959 |
++ |
960 |
++ for (i = 0; i < l64; i++) |
961 |
++ writeq(src64[i], &dest64[i]); |
962 |
++} |
963 |
++ |
964 |
+ /* Copy to PIO, respecting that writes to PIO buffers must be dword aligned. |
965 |
+ * Advances piobuf pointer. Leaves additional data in the copy buffer. |
966 |
+ */ |
967 |
+@@ -198,7 +210,7 @@ static void efx_memcpy_toio_aligned(struct efx_nic *efx, u8 __iomem **piobuf, |
968 |
+ { |
969 |
+ int block_len = len & ~(sizeof(copy_buf->buf) - 1); |
970 |
+ |
971 |
+- memcpy_toio(*piobuf, data, block_len); |
972 |
++ efx_memcpy_64(*piobuf, data, block_len); |
973 |
+ *piobuf += block_len; |
974 |
+ len -= block_len; |
975 |
+ |
976 |
+@@ -230,7 +242,7 @@ static void efx_memcpy_toio_aligned_cb(struct efx_nic *efx, u8 __iomem **piobuf, |
977 |
+ if (copy_buf->used < sizeof(copy_buf->buf)) |
978 |
+ return; |
979 |
+ |
980 |
+- memcpy_toio(*piobuf, copy_buf->buf, sizeof(copy_buf->buf)); |
981 |
++ efx_memcpy_64(*piobuf, copy_buf->buf, sizeof(copy_buf->buf)); |
982 |
+ *piobuf += sizeof(copy_buf->buf); |
983 |
+ data += copy_to_buf; |
984 |
+ len -= copy_to_buf; |
985 |
+@@ -245,7 +257,7 @@ static void efx_flush_copy_buffer(struct efx_nic *efx, u8 __iomem *piobuf, |
986 |
+ { |
987 |
+ /* if there's anything in it, write the whole buffer, including junk */ |
988 |
+ if (copy_buf->used) |
989 |
+- memcpy_toio(piobuf, copy_buf->buf, sizeof(copy_buf->buf)); |
990 |
++ efx_memcpy_64(piobuf, copy_buf->buf, sizeof(copy_buf->buf)); |
991 |
+ } |
992 |
+ |
993 |
+ /* Traverse skb structure and copy fragments in to PIO buffer. |
994 |
+@@ -304,8 +316,8 @@ efx_enqueue_skb_pio(struct efx_tx_queue *tx_queue, struct sk_buff *skb) |
995 |
+ */ |
996 |
+ BUILD_BUG_ON(L1_CACHE_BYTES > |
997 |
+ SKB_DATA_ALIGN(sizeof(struct skb_shared_info))); |
998 |
+- memcpy_toio(tx_queue->piobuf, skb->data, |
999 |
+- ALIGN(skb->len, L1_CACHE_BYTES)); |
1000 |
++ efx_memcpy_64(tx_queue->piobuf, skb->data, |
1001 |
++ ALIGN(skb->len, L1_CACHE_BYTES)); |
1002 |
+ } |
1003 |
+ |
1004 |
+ EFX_POPULATE_QWORD_5(buffer->option, |
1005 |
+diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c |
1006 |
+index 20bb66944c4a..5adecc5f52b7 100644 |
1007 |
+--- a/drivers/net/macvlan.c |
1008 |
++++ b/drivers/net/macvlan.c |
1009 |
+@@ -1043,7 +1043,6 @@ static int macvlan_device_event(struct notifier_block *unused, |
1010 |
+ list_for_each_entry_safe(vlan, next, &port->vlans, list) |
1011 |
+ vlan->dev->rtnl_link_ops->dellink(vlan->dev, &list_kill); |
1012 |
+ unregister_netdevice_many(&list_kill); |
1013 |
+- list_del(&list_kill); |
1014 |
+ break; |
1015 |
+ case NETDEV_PRE_TYPE_CHANGE: |
1016 |
+ /* Forbid underlaying device to change its type. */ |
1017 |
+diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c |
1018 |
+index c8624a8235ab..26d8c29b59de 100644 |
1019 |
+--- a/drivers/net/team/team.c |
1020 |
++++ b/drivers/net/team/team.c |
1021 |
+@@ -1732,6 +1732,7 @@ static int team_change_mtu(struct net_device *dev, int new_mtu) |
1022 |
+ * to traverse list in reverse under rcu_read_lock |
1023 |
+ */ |
1024 |
+ mutex_lock(&team->lock); |
1025 |
++ team->port_mtu_change_allowed = true; |
1026 |
+ list_for_each_entry(port, &team->port_list, list) { |
1027 |
+ err = dev_set_mtu(port->dev, new_mtu); |
1028 |
+ if (err) { |
1029 |
+@@ -1740,6 +1741,7 @@ static int team_change_mtu(struct net_device *dev, int new_mtu) |
1030 |
+ goto unwind; |
1031 |
+ } |
1032 |
+ } |
1033 |
++ team->port_mtu_change_allowed = false; |
1034 |
+ mutex_unlock(&team->lock); |
1035 |
+ |
1036 |
+ dev->mtu = new_mtu; |
1037 |
+@@ -1749,6 +1751,7 @@ static int team_change_mtu(struct net_device *dev, int new_mtu) |
1038 |
+ unwind: |
1039 |
+ list_for_each_entry_continue_reverse(port, &team->port_list, list) |
1040 |
+ dev_set_mtu(port->dev, dev->mtu); |
1041 |
++ team->port_mtu_change_allowed = false; |
1042 |
+ mutex_unlock(&team->lock); |
1043 |
+ |
1044 |
+ return err; |
1045 |
+@@ -2857,7 +2860,9 @@ static int team_device_event(struct notifier_block *unused, |
1046 |
+ break; |
1047 |
+ case NETDEV_PRECHANGEMTU: |
1048 |
+ /* Forbid to change mtu of underlaying device */ |
1049 |
+- return NOTIFY_BAD; |
1050 |
++ if (!port->team->port_mtu_change_allowed) |
1051 |
++ return NOTIFY_BAD; |
1052 |
++ break; |
1053 |
+ case NETDEV_PRE_TYPE_CHANGE: |
1054 |
+ /* Forbid to change type of underlaying device */ |
1055 |
+ return NOTIFY_BAD; |
1056 |
+diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c |
1057 |
+index 48c4902c0d62..b71120842c4f 100644 |
1058 |
+--- a/drivers/net/usb/qmi_wwan.c |
1059 |
++++ b/drivers/net/usb/qmi_wwan.c |
1060 |
+@@ -752,7 +752,12 @@ static const struct usb_device_id products[] = { |
1061 |
+ {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ |
1062 |
+ {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ |
1063 |
+ {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ |
1064 |
+- {QMI_FIXED_INTF(0x0b3c, 0xc005, 6)}, /* Olivetti Olicard 200 */ |
1065 |
++ {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */ |
1066 |
++ {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */ |
1067 |
++ {QMI_FIXED_INTF(0x0b3c, 0xc002, 4)}, /* Olivetti Olicard 140 */ |
1068 |
++ {QMI_FIXED_INTF(0x0b3c, 0xc004, 6)}, /* Olivetti Olicard 155 */ |
1069 |
++ {QMI_FIXED_INTF(0x0b3c, 0xc005, 6)}, /* Olivetti Olicard 200 */ |
1070 |
++ {QMI_FIXED_INTF(0x0b3c, 0xc00a, 6)}, /* Olivetti Olicard 160 */ |
1071 |
+ {QMI_FIXED_INTF(0x0b3c, 0xc00b, 4)}, /* Olivetti Olicard 500 */ |
1072 |
+ {QMI_FIXED_INTF(0x1e2d, 0x0060, 4)}, /* Cinterion PLxx */ |
1073 |
+ {QMI_FIXED_INTF(0x1e2d, 0x0053, 4)}, /* Cinterion PHxx,PXxx */ |
1074 |
+diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c |
1075 |
+index d091e52b00e1..40ad25d7f28b 100644 |
1076 |
+--- a/drivers/net/vxlan.c |
1077 |
++++ b/drivers/net/vxlan.c |
1078 |
+@@ -2282,9 +2282,9 @@ static void vxlan_setup(struct net_device *dev) |
1079 |
+ eth_hw_addr_random(dev); |
1080 |
+ ether_setup(dev); |
1081 |
+ if (vxlan->default_dst.remote_ip.sa.sa_family == AF_INET6) |
1082 |
+- dev->hard_header_len = ETH_HLEN + VXLAN6_HEADROOM; |
1083 |
++ dev->needed_headroom = ETH_HLEN + VXLAN6_HEADROOM; |
1084 |
+ else |
1085 |
+- dev->hard_header_len = ETH_HLEN + VXLAN_HEADROOM; |
1086 |
++ dev->needed_headroom = ETH_HLEN + VXLAN_HEADROOM; |
1087 |
+ |
1088 |
+ dev->netdev_ops = &vxlan_netdev_ops; |
1089 |
+ dev->destructor = free_netdev; |
1090 |
+@@ -2667,8 +2667,7 @@ static int vxlan_newlink(struct net *net, struct net_device *dev, |
1091 |
+ if (!tb[IFLA_MTU]) |
1092 |
+ dev->mtu = lowerdev->mtu - (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM); |
1093 |
+ |
1094 |
+- /* update header length based on lower device */ |
1095 |
+- dev->hard_header_len = lowerdev->hard_header_len + |
1096 |
++ dev->needed_headroom = lowerdev->hard_header_len + |
1097 |
+ (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM); |
1098 |
+ } else if (use_ipv6) |
1099 |
+ vxlan->flags |= VXLAN_F_IPV6; |
1100 |
+diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c |
1101 |
+index 3281c90691c3..44fe83ee9bee 100644 |
1102 |
+--- a/drivers/rtc/rtc-at91rm9200.c |
1103 |
++++ b/drivers/rtc/rtc-at91rm9200.c |
1104 |
+@@ -48,6 +48,7 @@ struct at91_rtc_config { |
1105 |
+ |
1106 |
+ static const struct at91_rtc_config *at91_rtc_config; |
1107 |
+ static DECLARE_COMPLETION(at91_rtc_updated); |
1108 |
++static DECLARE_COMPLETION(at91_rtc_upd_rdy); |
1109 |
+ static unsigned int at91_alarm_year = AT91_RTC_EPOCH; |
1110 |
+ static void __iomem *at91_rtc_regs; |
1111 |
+ static int irq; |
1112 |
+@@ -161,6 +162,8 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm) |
1113 |
+ 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, |
1114 |
+ tm->tm_hour, tm->tm_min, tm->tm_sec); |
1115 |
+ |
1116 |
++ wait_for_completion(&at91_rtc_upd_rdy); |
1117 |
++ |
1118 |
+ /* Stop Time/Calendar from counting */ |
1119 |
+ cr = at91_rtc_read(AT91_RTC_CR); |
1120 |
+ at91_rtc_write(AT91_RTC_CR, cr | AT91_RTC_UPDCAL | AT91_RTC_UPDTIM); |
1121 |
+@@ -183,7 +186,9 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm) |
1122 |
+ |
1123 |
+ /* Restart Time/Calendar */ |
1124 |
+ cr = at91_rtc_read(AT91_RTC_CR); |
1125 |
++ at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_SECEV); |
1126 |
+ at91_rtc_write(AT91_RTC_CR, cr & ~(AT91_RTC_UPDCAL | AT91_RTC_UPDTIM)); |
1127 |
++ at91_rtc_write_ier(AT91_RTC_SECEV); |
1128 |
+ |
1129 |
+ return 0; |
1130 |
+ } |
1131 |
+@@ -290,8 +295,10 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id) |
1132 |
+ if (rtsr) { /* this interrupt is shared! Is it ours? */ |
1133 |
+ if (rtsr & AT91_RTC_ALARM) |
1134 |
+ events |= (RTC_AF | RTC_IRQF); |
1135 |
+- if (rtsr & AT91_RTC_SECEV) |
1136 |
+- events |= (RTC_UF | RTC_IRQF); |
1137 |
++ if (rtsr & AT91_RTC_SECEV) { |
1138 |
++ complete(&at91_rtc_upd_rdy); |
1139 |
++ at91_rtc_write_idr(AT91_RTC_SECEV); |
1140 |
++ } |
1141 |
+ if (rtsr & AT91_RTC_ACKUPD) |
1142 |
+ complete(&at91_rtc_updated); |
1143 |
+ |
1144 |
+@@ -413,6 +420,11 @@ static int __init at91_rtc_probe(struct platform_device *pdev) |
1145 |
+ return PTR_ERR(rtc); |
1146 |
+ platform_set_drvdata(pdev, rtc); |
1147 |
+ |
1148 |
++ /* enable SECEV interrupt in order to initialize at91_rtc_upd_rdy |
1149 |
++ * completion. |
1150 |
++ */ |
1151 |
++ at91_rtc_write_ier(AT91_RTC_SECEV); |
1152 |
++ |
1153 |
+ dev_info(&pdev->dev, "AT91 Real Time Clock driver.\n"); |
1154 |
+ return 0; |
1155 |
+ } |
1156 |
+diff --git a/drivers/scsi/scsi_netlink.c b/drivers/scsi/scsi_netlink.c |
1157 |
+index fe30ea94ffe6..109802f776ed 100644 |
1158 |
+--- a/drivers/scsi/scsi_netlink.c |
1159 |
++++ b/drivers/scsi/scsi_netlink.c |
1160 |
+@@ -77,7 +77,7 @@ scsi_nl_rcv_msg(struct sk_buff *skb) |
1161 |
+ goto next_msg; |
1162 |
+ } |
1163 |
+ |
1164 |
+- if (!capable(CAP_SYS_ADMIN)) { |
1165 |
++ if (!netlink_capable(skb, CAP_SYS_ADMIN)) { |
1166 |
+ err = -EPERM; |
1167 |
+ goto next_msg; |
1168 |
+ } |
1169 |
+diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c |
1170 |
+index 514844efac75..9ec1df9cff95 100644 |
1171 |
+--- a/drivers/staging/iio/adc/mxs-lradc.c |
1172 |
++++ b/drivers/staging/iio/adc/mxs-lradc.c |
1173 |
+@@ -846,6 +846,14 @@ static int mxs_lradc_read_single(struct iio_dev *iio_dev, int chan, int *val) |
1174 |
+ LRADC_CTRL1); |
1175 |
+ mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0); |
1176 |
+ |
1177 |
++ /* Enable / disable the divider per requirement */ |
1178 |
++ if (test_bit(chan, &lradc->is_divided)) |
1179 |
++ mxs_lradc_reg_set(lradc, 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, |
1180 |
++ LRADC_CTRL2); |
1181 |
++ else |
1182 |
++ mxs_lradc_reg_clear(lradc, |
1183 |
++ 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, LRADC_CTRL2); |
1184 |
++ |
1185 |
+ /* Clean the slot's previous content, then set new one. */ |
1186 |
+ mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(0), LRADC_CTRL4); |
1187 |
+ mxs_lradc_reg_set(lradc, chan, LRADC_CTRL4); |
1188 |
+@@ -964,15 +972,11 @@ static int mxs_lradc_write_raw(struct iio_dev *iio_dev, |
1189 |
+ if (val == scale_avail[MXS_LRADC_DIV_DISABLED].integer && |
1190 |
+ val2 == scale_avail[MXS_LRADC_DIV_DISABLED].nano) { |
1191 |
+ /* divider by two disabled */ |
1192 |
+- writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, |
1193 |
+- lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_CLR); |
1194 |
+ clear_bit(chan->channel, &lradc->is_divided); |
1195 |
+ ret = 0; |
1196 |
+ } else if (val == scale_avail[MXS_LRADC_DIV_ENABLED].integer && |
1197 |
+ val2 == scale_avail[MXS_LRADC_DIV_ENABLED].nano) { |
1198 |
+ /* divider by two enabled */ |
1199 |
+- writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, |
1200 |
+- lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_SET); |
1201 |
+ set_bit(chan->channel, &lradc->is_divided); |
1202 |
+ ret = 0; |
1203 |
+ } |
1204 |
+diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c |
1205 |
+index 1e538086d48b..ce1e74e000bb 100644 |
1206 |
+--- a/drivers/staging/iio/light/tsl2x7x_core.c |
1207 |
++++ b/drivers/staging/iio/light/tsl2x7x_core.c |
1208 |
+@@ -667,9 +667,13 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev) |
1209 |
+ chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] = |
1210 |
+ chip->tsl2x7x_settings.prox_pulse_count; |
1211 |
+ chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] = |
1212 |
+- chip->tsl2x7x_settings.prox_thres_low; |
1213 |
++ (chip->tsl2x7x_settings.prox_thres_low) & 0xFF; |
1214 |
++ chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHHI] = |
1215 |
++ (chip->tsl2x7x_settings.prox_thres_low >> 8) & 0xFF; |
1216 |
+ chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] = |
1217 |
+- chip->tsl2x7x_settings.prox_thres_high; |
1218 |
++ (chip->tsl2x7x_settings.prox_thres_high) & 0xFF; |
1219 |
++ chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHHI] = |
1220 |
++ (chip->tsl2x7x_settings.prox_thres_high >> 8) & 0xFF; |
1221 |
+ |
1222 |
+ /* and make sure we're not already on */ |
1223 |
+ if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) { |
1224 |
+diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c |
1225 |
+index de77d9aa22c6..6689de6c5591 100644 |
1226 |
+--- a/drivers/target/iscsi/iscsi_target_auth.c |
1227 |
++++ b/drivers/target/iscsi/iscsi_target_auth.c |
1228 |
+@@ -314,6 +314,16 @@ static int chap_server_compute_md5( |
1229 |
+ goto out; |
1230 |
+ } |
1231 |
+ /* |
1232 |
++ * During mutual authentication, the CHAP_C generated by the |
1233 |
++ * initiator must not match the original CHAP_C generated by |
1234 |
++ * the target. |
1235 |
++ */ |
1236 |
++ if (!memcmp(challenge_binhex, chap->challenge, CHAP_CHALLENGE_LENGTH)) { |
1237 |
++ pr_err("initiator CHAP_C matches target CHAP_C, failing" |
1238 |
++ " login attempt\n"); |
1239 |
++ goto out; |
1240 |
++ } |
1241 |
++ /* |
1242 |
+ * Generate CHAP_N and CHAP_R for mutual authentication. |
1243 |
+ */ |
1244 |
+ tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC); |
1245 |
+diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c |
1246 |
+index 98b48d400a3a..c39cf37800d3 100644 |
1247 |
+--- a/drivers/target/target_core_transport.c |
1248 |
++++ b/drivers/target/target_core_transport.c |
1249 |
+@@ -2342,6 +2342,10 @@ static void target_release_cmd_kref(struct kref *kref) |
1250 |
+ */ |
1251 |
+ int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd) |
1252 |
+ { |
1253 |
++ if (!se_sess) { |
1254 |
++ se_cmd->se_tfo->release_cmd(se_cmd); |
1255 |
++ return 1; |
1256 |
++ } |
1257 |
+ return kref_put_spinlock_irqsave(&se_cmd->cmd_kref, target_release_cmd_kref, |
1258 |
+ &se_sess->sess_cmd_lock); |
1259 |
+ } |
1260 |
+diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c |
1261 |
+index 7783acabe443..eabccd45f4e8 100644 |
1262 |
+--- a/drivers/usb/class/cdc-acm.c |
1263 |
++++ b/drivers/usb/class/cdc-acm.c |
1264 |
+@@ -122,13 +122,23 @@ static void acm_release_minor(struct acm *acm) |
1265 |
+ static int acm_ctrl_msg(struct acm *acm, int request, int value, |
1266 |
+ void *buf, int len) |
1267 |
+ { |
1268 |
+- int retval = usb_control_msg(acm->dev, usb_sndctrlpipe(acm->dev, 0), |
1269 |
++ int retval; |
1270 |
++ |
1271 |
++ retval = usb_autopm_get_interface(acm->control); |
1272 |
++ if (retval) |
1273 |
++ return retval; |
1274 |
++ |
1275 |
++ retval = usb_control_msg(acm->dev, usb_sndctrlpipe(acm->dev, 0), |
1276 |
+ request, USB_RT_ACM, value, |
1277 |
+ acm->control->altsetting[0].desc.bInterfaceNumber, |
1278 |
+ buf, len, 5000); |
1279 |
++ |
1280 |
+ dev_dbg(&acm->control->dev, |
1281 |
+ "%s - rq 0x%02x, val %#x, len %#x, result %d\n", |
1282 |
+ __func__, request, value, len, retval); |
1283 |
++ |
1284 |
++ usb_autopm_put_interface(acm->control); |
1285 |
++ |
1286 |
+ return retval < 0 ? retval : 0; |
1287 |
+ } |
1288 |
+ |
1289 |
+@@ -496,6 +506,7 @@ static int acm_port_activate(struct tty_port *port, struct tty_struct *tty) |
1290 |
+ { |
1291 |
+ struct acm *acm = container_of(port, struct acm, port); |
1292 |
+ int retval = -ENODEV; |
1293 |
++ int i; |
1294 |
+ |
1295 |
+ dev_dbg(&acm->control->dev, "%s\n", __func__); |
1296 |
+ |
1297 |
+@@ -544,6 +555,8 @@ static int acm_port_activate(struct tty_port *port, struct tty_struct *tty) |
1298 |
+ return 0; |
1299 |
+ |
1300 |
+ error_submit_read_urbs: |
1301 |
++ for (i = 0; i < acm->rx_buflimit; i++) |
1302 |
++ usb_kill_urb(acm->read_urbs[i]); |
1303 |
+ acm->ctrlout = 0; |
1304 |
+ acm_set_control(acm, acm->ctrlout); |
1305 |
+ error_set_control: |
1306 |
+@@ -571,21 +584,35 @@ static void acm_port_destruct(struct tty_port *port) |
1307 |
+ static void acm_port_shutdown(struct tty_port *port) |
1308 |
+ { |
1309 |
+ struct acm *acm = container_of(port, struct acm, port); |
1310 |
++ struct urb *urb; |
1311 |
++ struct acm_wb *wb; |
1312 |
+ int i; |
1313 |
++ int pm_err; |
1314 |
+ |
1315 |
+ dev_dbg(&acm->control->dev, "%s\n", __func__); |
1316 |
+ |
1317 |
+ mutex_lock(&acm->mutex); |
1318 |
+ if (!acm->disconnected) { |
1319 |
+- usb_autopm_get_interface(acm->control); |
1320 |
++ pm_err = usb_autopm_get_interface(acm->control); |
1321 |
+ acm_set_control(acm, acm->ctrlout = 0); |
1322 |
++ |
1323 |
++ for (;;) { |
1324 |
++ urb = usb_get_from_anchor(&acm->delayed); |
1325 |
++ if (!urb) |
1326 |
++ break; |
1327 |
++ wb = urb->context; |
1328 |
++ wb->use = 0; |
1329 |
++ usb_autopm_put_interface_async(acm->control); |
1330 |
++ } |
1331 |
++ |
1332 |
+ usb_kill_urb(acm->ctrlurb); |
1333 |
+ for (i = 0; i < ACM_NW; i++) |
1334 |
+ usb_kill_urb(acm->wb[i].urb); |
1335 |
+ for (i = 0; i < acm->rx_buflimit; i++) |
1336 |
+ usb_kill_urb(acm->read_urbs[i]); |
1337 |
+ acm->control->needs_remote_wakeup = 0; |
1338 |
+- usb_autopm_put_interface(acm->control); |
1339 |
++ if (!pm_err) |
1340 |
++ usb_autopm_put_interface(acm->control); |
1341 |
+ } |
1342 |
+ mutex_unlock(&acm->mutex); |
1343 |
+ } |
1344 |
+@@ -644,14 +671,17 @@ static int acm_tty_write(struct tty_struct *tty, |
1345 |
+ memcpy(wb->buf, buf, count); |
1346 |
+ wb->len = count; |
1347 |
+ |
1348 |
+- usb_autopm_get_interface_async(acm->control); |
1349 |
++ stat = usb_autopm_get_interface_async(acm->control); |
1350 |
++ if (stat) { |
1351 |
++ wb->use = 0; |
1352 |
++ spin_unlock_irqrestore(&acm->write_lock, flags); |
1353 |
++ return stat; |
1354 |
++ } |
1355 |
++ |
1356 |
+ if (acm->susp_count) { |
1357 |
+- if (!acm->delayed_wb) |
1358 |
+- acm->delayed_wb = wb; |
1359 |
+- else |
1360 |
+- usb_autopm_put_interface_async(acm->control); |
1361 |
++ usb_anchor_urb(wb->urb, &acm->delayed); |
1362 |
+ spin_unlock_irqrestore(&acm->write_lock, flags); |
1363 |
+- return count; /* A white lie */ |
1364 |
++ return count; |
1365 |
+ } |
1366 |
+ usb_mark_last_busy(acm->dev); |
1367 |
+ |
1368 |
+@@ -1267,6 +1297,7 @@ made_compressed_probe: |
1369 |
+ acm->bInterval = epread->bInterval; |
1370 |
+ tty_port_init(&acm->port); |
1371 |
+ acm->port.ops = &acm_port_ops; |
1372 |
++ init_usb_anchor(&acm->delayed); |
1373 |
+ |
1374 |
+ buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma); |
1375 |
+ if (!buf) { |
1376 |
+@@ -1512,18 +1543,15 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message) |
1377 |
+ struct acm *acm = usb_get_intfdata(intf); |
1378 |
+ int cnt; |
1379 |
+ |
1380 |
++ spin_lock_irq(&acm->read_lock); |
1381 |
++ spin_lock(&acm->write_lock); |
1382 |
+ if (PMSG_IS_AUTO(message)) { |
1383 |
+- int b; |
1384 |
+- |
1385 |
+- spin_lock_irq(&acm->write_lock); |
1386 |
+- b = acm->transmitting; |
1387 |
+- spin_unlock_irq(&acm->write_lock); |
1388 |
+- if (b) |
1389 |
++ if (acm->transmitting) { |
1390 |
++ spin_unlock(&acm->write_lock); |
1391 |
++ spin_unlock_irq(&acm->read_lock); |
1392 |
+ return -EBUSY; |
1393 |
++ } |
1394 |
+ } |
1395 |
+- |
1396 |
+- spin_lock_irq(&acm->read_lock); |
1397 |
+- spin_lock(&acm->write_lock); |
1398 |
+ cnt = acm->susp_count++; |
1399 |
+ spin_unlock(&acm->write_lock); |
1400 |
+ spin_unlock_irq(&acm->read_lock); |
1401 |
+@@ -1531,8 +1559,7 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message) |
1402 |
+ if (cnt) |
1403 |
+ return 0; |
1404 |
+ |
1405 |
+- if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) |
1406 |
+- stop_data_traffic(acm); |
1407 |
++ stop_data_traffic(acm); |
1408 |
+ |
1409 |
+ return 0; |
1410 |
+ } |
1411 |
+@@ -1540,29 +1567,24 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message) |
1412 |
+ static int acm_resume(struct usb_interface *intf) |
1413 |
+ { |
1414 |
+ struct acm *acm = usb_get_intfdata(intf); |
1415 |
+- struct acm_wb *wb; |
1416 |
++ struct urb *urb; |
1417 |
+ int rv = 0; |
1418 |
+- int cnt; |
1419 |
+ |
1420 |
+ spin_lock_irq(&acm->read_lock); |
1421 |
+- acm->susp_count -= 1; |
1422 |
+- cnt = acm->susp_count; |
1423 |
+- spin_unlock_irq(&acm->read_lock); |
1424 |
++ spin_lock(&acm->write_lock); |
1425 |
+ |
1426 |
+- if (cnt) |
1427 |
+- return 0; |
1428 |
++ if (--acm->susp_count) |
1429 |
++ goto out; |
1430 |
+ |
1431 |
+ if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) { |
1432 |
+- rv = usb_submit_urb(acm->ctrlurb, GFP_NOIO); |
1433 |
+- |
1434 |
+- spin_lock_irq(&acm->write_lock); |
1435 |
+- if (acm->delayed_wb) { |
1436 |
+- wb = acm->delayed_wb; |
1437 |
+- acm->delayed_wb = NULL; |
1438 |
+- spin_unlock_irq(&acm->write_lock); |
1439 |
+- acm_start_wb(acm, wb); |
1440 |
+- } else { |
1441 |
+- spin_unlock_irq(&acm->write_lock); |
1442 |
++ rv = usb_submit_urb(acm->ctrlurb, GFP_ATOMIC); |
1443 |
++ |
1444 |
++ for (;;) { |
1445 |
++ urb = usb_get_from_anchor(&acm->delayed); |
1446 |
++ if (!urb) |
1447 |
++ break; |
1448 |
++ |
1449 |
++ acm_start_wb(acm, urb->context); |
1450 |
+ } |
1451 |
+ |
1452 |
+ /* |
1453 |
+@@ -1570,12 +1592,14 @@ static int acm_resume(struct usb_interface *intf) |
1454 |
+ * do the write path at all cost |
1455 |
+ */ |
1456 |
+ if (rv < 0) |
1457 |
+- goto err_out; |
1458 |
++ goto out; |
1459 |
+ |
1460 |
+- rv = acm_submit_read_urbs(acm, GFP_NOIO); |
1461 |
++ rv = acm_submit_read_urbs(acm, GFP_ATOMIC); |
1462 |
+ } |
1463 |
++out: |
1464 |
++ spin_unlock(&acm->write_lock); |
1465 |
++ spin_unlock_irq(&acm->read_lock); |
1466 |
+ |
1467 |
+-err_out: |
1468 |
+ return rv; |
1469 |
+ } |
1470 |
+ |
1471 |
+diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h |
1472 |
+index e38dc785808f..80826f843e04 100644 |
1473 |
+--- a/drivers/usb/class/cdc-acm.h |
1474 |
++++ b/drivers/usb/class/cdc-acm.h |
1475 |
+@@ -120,7 +120,7 @@ struct acm { |
1476 |
+ unsigned int throttled:1; /* actually throttled */ |
1477 |
+ unsigned int throttle_req:1; /* throttle requested */ |
1478 |
+ u8 bInterval; |
1479 |
+- struct acm_wb *delayed_wb; /* write queued for a device about to be woken */ |
1480 |
++ struct usb_anchor delayed; /* writes queued for a device about to be woken */ |
1481 |
+ }; |
1482 |
+ |
1483 |
+ #define CDC_DATA_INTERFACE_TYPE 0x0a |
1484 |
+diff --git a/include/linux/if_team.h b/include/linux/if_team.h |
1485 |
+index a899dc24be15..a6aa970758a2 100644 |
1486 |
+--- a/include/linux/if_team.h |
1487 |
++++ b/include/linux/if_team.h |
1488 |
+@@ -194,6 +194,7 @@ struct team { |
1489 |
+ bool user_carrier_enabled; |
1490 |
+ bool queue_override_enabled; |
1491 |
+ struct list_head *qom_lists; /* array of queue override mapping lists */ |
1492 |
++ bool port_mtu_change_allowed; |
1493 |
+ struct { |
1494 |
+ unsigned int count; |
1495 |
+ unsigned int interval; /* in ms */ |
1496 |
+diff --git a/include/linux/netlink.h b/include/linux/netlink.h |
1497 |
+index aad8eeaf416d..034cda789a15 100644 |
1498 |
+--- a/include/linux/netlink.h |
1499 |
++++ b/include/linux/netlink.h |
1500 |
+@@ -16,9 +16,10 @@ static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb) |
1501 |
+ } |
1502 |
+ |
1503 |
+ enum netlink_skb_flags { |
1504 |
+- NETLINK_SKB_MMAPED = 0x1, /* Packet data is mmaped */ |
1505 |
+- NETLINK_SKB_TX = 0x2, /* Packet was sent by userspace */ |
1506 |
+- NETLINK_SKB_DELIVERED = 0x4, /* Packet was delivered */ |
1507 |
++ NETLINK_SKB_MMAPED = 0x1, /* Packet data is mmaped */ |
1508 |
++ NETLINK_SKB_TX = 0x2, /* Packet was sent by userspace */ |
1509 |
++ NETLINK_SKB_DELIVERED = 0x4, /* Packet was delivered */ |
1510 |
++ NETLINK_SKB_DST = 0x8, /* Dst set in sendto or sendmsg */ |
1511 |
+ }; |
1512 |
+ |
1513 |
+ struct netlink_skb_parms { |
1514 |
+@@ -169,4 +170,11 @@ struct netlink_tap { |
1515 |
+ extern int netlink_add_tap(struct netlink_tap *nt); |
1516 |
+ extern int netlink_remove_tap(struct netlink_tap *nt); |
1517 |
+ |
1518 |
++bool __netlink_ns_capable(const struct netlink_skb_parms *nsp, |
1519 |
++ struct user_namespace *ns, int cap); |
1520 |
++bool netlink_ns_capable(const struct sk_buff *skb, |
1521 |
++ struct user_namespace *ns, int cap); |
1522 |
++bool netlink_capable(const struct sk_buff *skb, int cap); |
1523 |
++bool netlink_net_capable(const struct sk_buff *skb, int cap); |
1524 |
++ |
1525 |
+ #endif /* __LINUX_NETLINK_H */ |
1526 |
+diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h |
1527 |
+index 302ab805b0bb..46cca4c06848 100644 |
1528 |
+--- a/include/linux/sock_diag.h |
1529 |
++++ b/include/linux/sock_diag.h |
1530 |
+@@ -23,7 +23,7 @@ int sock_diag_check_cookie(void *sk, __u32 *cookie); |
1531 |
+ void sock_diag_save_cookie(void *sk, __u32 *cookie); |
1532 |
+ |
1533 |
+ int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attr); |
1534 |
+-int sock_diag_put_filterinfo(struct sock *sk, |
1535 |
++int sock_diag_put_filterinfo(bool may_report_filterinfo, struct sock *sk, |
1536 |
+ struct sk_buff *skb, int attrtype); |
1537 |
+ |
1538 |
+ #endif |
1539 |
+diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h |
1540 |
+index 6efe73c79c52..058271bde27a 100644 |
1541 |
+--- a/include/net/inetpeer.h |
1542 |
++++ b/include/net/inetpeer.h |
1543 |
+@@ -177,16 +177,9 @@ static inline void inet_peer_refcheck(const struct inet_peer *p) |
1544 |
+ /* can be called with or without local BH being disabled */ |
1545 |
+ static inline int inet_getid(struct inet_peer *p, int more) |
1546 |
+ { |
1547 |
+- int old, new; |
1548 |
+ more++; |
1549 |
+ inet_peer_refcheck(p); |
1550 |
+- do { |
1551 |
+- old = atomic_read(&p->ip_id_count); |
1552 |
+- new = old + more; |
1553 |
+- if (!new) |
1554 |
+- new = 1; |
1555 |
+- } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old); |
1556 |
+- return new; |
1557 |
++ return atomic_add_return(more, &p->ip_id_count) - more; |
1558 |
+ } |
1559 |
+ |
1560 |
+ #endif /* _NET_INETPEER_H */ |
1561 |
+diff --git a/include/net/sock.h b/include/net/sock.h |
1562 |
+index b9586a137cad..57c31dd15e64 100644 |
1563 |
+--- a/include/net/sock.h |
1564 |
++++ b/include/net/sock.h |
1565 |
+@@ -2278,6 +2278,11 @@ int sock_get_timestampns(struct sock *, struct timespec __user *); |
1566 |
+ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len, int level, |
1567 |
+ int type); |
1568 |
+ |
1569 |
++bool sk_ns_capable(const struct sock *sk, |
1570 |
++ struct user_namespace *user_ns, int cap); |
1571 |
++bool sk_capable(const struct sock *sk, int cap); |
1572 |
++bool sk_net_capable(const struct sock *sk, int cap); |
1573 |
++ |
1574 |
+ /* |
1575 |
+ * Enable debug/info messages |
1576 |
+ */ |
1577 |
+diff --git a/include/sound/core.h b/include/sound/core.h |
1578 |
+index 2a14f1f02d4f..d6bc9616058b 100644 |
1579 |
+--- a/include/sound/core.h |
1580 |
++++ b/include/sound/core.h |
1581 |
+@@ -121,6 +121,8 @@ struct snd_card { |
1582 |
+ int user_ctl_count; /* count of all user controls */ |
1583 |
+ struct list_head controls; /* all controls for this card */ |
1584 |
+ struct list_head ctl_files; /* active control files */ |
1585 |
++ struct mutex user_ctl_lock; /* protects user controls against |
1586 |
++ concurrent access */ |
1587 |
+ |
1588 |
+ struct snd_info_entry *proc_root; /* root for soundcard specific files */ |
1589 |
+ struct snd_info_entry *proc_id; /* the card id */ |
1590 |
+diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h |
1591 |
+index 5759810e1c1b..21eed488783f 100644 |
1592 |
+--- a/include/uapi/sound/compress_offload.h |
1593 |
++++ b/include/uapi/sound/compress_offload.h |
1594 |
+@@ -80,7 +80,7 @@ struct snd_compr_tstamp { |
1595 |
+ struct snd_compr_avail { |
1596 |
+ __u64 avail; |
1597 |
+ struct snd_compr_tstamp tstamp; |
1598 |
+-}; |
1599 |
++} __attribute__((packed)); |
1600 |
+ |
1601 |
+ enum snd_compr_direction { |
1602 |
+ SND_COMPRESS_PLAYBACK = 0, |
1603 |
+diff --git a/kernel/audit.c b/kernel/audit.c |
1604 |
+index d5f31c17813a..0c9dc860cc15 100644 |
1605 |
+--- a/kernel/audit.c |
1606 |
++++ b/kernel/audit.c |
1607 |
+@@ -639,13 +639,13 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type) |
1608 |
+ case AUDIT_TTY_SET: |
1609 |
+ case AUDIT_TRIM: |
1610 |
+ case AUDIT_MAKE_EQUIV: |
1611 |
+- if (!capable(CAP_AUDIT_CONTROL)) |
1612 |
++ if (!netlink_capable(skb, CAP_AUDIT_CONTROL)) |
1613 |
+ err = -EPERM; |
1614 |
+ break; |
1615 |
+ case AUDIT_USER: |
1616 |
+ case AUDIT_FIRST_USER_MSG ... AUDIT_LAST_USER_MSG: |
1617 |
+ case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2: |
1618 |
+- if (!capable(CAP_AUDIT_WRITE)) |
1619 |
++ if (!netlink_capable(skb, CAP_AUDIT_WRITE)) |
1620 |
+ err = -EPERM; |
1621 |
+ break; |
1622 |
+ default: /* bad msg */ |
1623 |
+diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c |
1624 |
+index df6839e3ce08..99a03acb7d47 100644 |
1625 |
+--- a/lib/lz4/lz4_decompress.c |
1626 |
++++ b/lib/lz4/lz4_decompress.c |
1627 |
+@@ -72,6 +72,8 @@ static int lz4_uncompress(const char *source, char *dest, int osize) |
1628 |
+ len = *ip++; |
1629 |
+ for (; len == 255; length += 255) |
1630 |
+ len = *ip++; |
1631 |
++ if (unlikely(length > (size_t)(length + len))) |
1632 |
++ goto _output_error; |
1633 |
+ length += len; |
1634 |
+ } |
1635 |
+ |
1636 |
+diff --git a/lib/lzo/lzo1x_decompress_safe.c b/lib/lzo/lzo1x_decompress_safe.c |
1637 |
+index 569985d522d5..8563081e8da3 100644 |
1638 |
+--- a/lib/lzo/lzo1x_decompress_safe.c |
1639 |
++++ b/lib/lzo/lzo1x_decompress_safe.c |
1640 |
+@@ -19,11 +19,31 @@ |
1641 |
+ #include <linux/lzo.h> |
1642 |
+ #include "lzodefs.h" |
1643 |
+ |
1644 |
+-#define HAVE_IP(x) ((size_t)(ip_end - ip) >= (size_t)(x)) |
1645 |
+-#define HAVE_OP(x) ((size_t)(op_end - op) >= (size_t)(x)) |
1646 |
+-#define NEED_IP(x) if (!HAVE_IP(x)) goto input_overrun |
1647 |
+-#define NEED_OP(x) if (!HAVE_OP(x)) goto output_overrun |
1648 |
+-#define TEST_LB(m_pos) if ((m_pos) < out) goto lookbehind_overrun |
1649 |
++#define HAVE_IP(t, x) \ |
1650 |
++ (((size_t)(ip_end - ip) >= (size_t)(t + x)) && \ |
1651 |
++ (((t + x) >= t) && ((t + x) >= x))) |
1652 |
++ |
1653 |
++#define HAVE_OP(t, x) \ |
1654 |
++ (((size_t)(op_end - op) >= (size_t)(t + x)) && \ |
1655 |
++ (((t + x) >= t) && ((t + x) >= x))) |
1656 |
++ |
1657 |
++#define NEED_IP(t, x) \ |
1658 |
++ do { \ |
1659 |
++ if (!HAVE_IP(t, x)) \ |
1660 |
++ goto input_overrun; \ |
1661 |
++ } while (0) |
1662 |
++ |
1663 |
++#define NEED_OP(t, x) \ |
1664 |
++ do { \ |
1665 |
++ if (!HAVE_OP(t, x)) \ |
1666 |
++ goto output_overrun; \ |
1667 |
++ } while (0) |
1668 |
++ |
1669 |
++#define TEST_LB(m_pos) \ |
1670 |
++ do { \ |
1671 |
++ if ((m_pos) < out) \ |
1672 |
++ goto lookbehind_overrun; \ |
1673 |
++ } while (0) |
1674 |
+ |
1675 |
+ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, |
1676 |
+ unsigned char *out, size_t *out_len) |
1677 |
+@@ -58,14 +78,14 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len, |
1678 |
+ while (unlikely(*ip == 0)) { |
1679 |
+ t += 255; |
1680 |
+ ip++; |
1681 |
+- NEED_IP(1); |
1682 |
++ NEED_IP(1, 0); |
1683 |
+ } |
1684 |
+ t += 15 + *ip++; |
1685 |
+ } |
1686 |
+ t += 3; |
1687 |
+ copy_literal_run: |
1688 |
+ #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) |
1689 |
+- if (likely(HAVE_IP(t + 15) && HAVE_OP(t + 15))) { |
1690 |
++ if (likely(HAVE_IP(t, 15) && HAVE_OP(t, 15))) { |
1691 |
+ const unsigned char *ie = ip + t; |
1692 |
+ unsigned char *oe = op + t; |
1693 |
+ do { |
1694 |
+@@ -81,8 +101,8 @@ copy_literal_run: |
1695 |
+ } else |
1696 |
+ #endif |
1697 |
+ { |
1698 |
+- NEED_OP(t); |
1699 |
+- NEED_IP(t + 3); |
1700 |
++ NEED_OP(t, 0); |
1701 |
++ NEED_IP(t, 3); |
1702 |
+ do { |
1703 |
+ *op++ = *ip++; |
1704 |
+ } while (--t > 0); |
1705 |
+@@ -95,7 +115,7 @@ copy_literal_run: |
1706 |
+ m_pos -= t >> 2; |
1707 |
+ m_pos -= *ip++ << 2; |
1708 |
+ TEST_LB(m_pos); |
1709 |
+- NEED_OP(2); |
1710 |
++ NEED_OP(2, 0); |
1711 |
+ op[0] = m_pos[0]; |
1712 |
+ op[1] = m_pos[1]; |
1713 |
+ op += 2; |
1714 |
+@@ -119,10 +139,10 @@ copy_literal_run: |
1715 |
+ while (unlikely(*ip == 0)) { |
1716 |
+ t += 255; |
1717 |
+ ip++; |
1718 |
+- NEED_IP(1); |
1719 |
++ NEED_IP(1, 0); |
1720 |
+ } |
1721 |
+ t += 31 + *ip++; |
1722 |
+- NEED_IP(2); |
1723 |
++ NEED_IP(2, 0); |
1724 |
+ } |
1725 |
+ m_pos = op - 1; |
1726 |
+ next = get_unaligned_le16(ip); |
1727 |
+@@ -137,10 +157,10 @@ copy_literal_run: |
1728 |
+ while (unlikely(*ip == 0)) { |
1729 |
+ t += 255; |
1730 |
+ ip++; |
1731 |
+- NEED_IP(1); |
1732 |
++ NEED_IP(1, 0); |
1733 |
+ } |
1734 |
+ t += 7 + *ip++; |
1735 |
+- NEED_IP(2); |
1736 |
++ NEED_IP(2, 0); |
1737 |
+ } |
1738 |
+ next = get_unaligned_le16(ip); |
1739 |
+ ip += 2; |
1740 |
+@@ -154,7 +174,7 @@ copy_literal_run: |
1741 |
+ #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) |
1742 |
+ if (op - m_pos >= 8) { |
1743 |
+ unsigned char *oe = op + t; |
1744 |
+- if (likely(HAVE_OP(t + 15))) { |
1745 |
++ if (likely(HAVE_OP(t, 15))) { |
1746 |
+ do { |
1747 |
+ COPY8(op, m_pos); |
1748 |
+ op += 8; |
1749 |
+@@ -164,7 +184,7 @@ copy_literal_run: |
1750 |
+ m_pos += 8; |
1751 |
+ } while (op < oe); |
1752 |
+ op = oe; |
1753 |
+- if (HAVE_IP(6)) { |
1754 |
++ if (HAVE_IP(6, 0)) { |
1755 |
+ state = next; |
1756 |
+ COPY4(op, ip); |
1757 |
+ op += next; |
1758 |
+@@ -172,7 +192,7 @@ copy_literal_run: |
1759 |
+ continue; |
1760 |
+ } |
1761 |
+ } else { |
1762 |
+- NEED_OP(t); |
1763 |
++ NEED_OP(t, 0); |
1764 |
+ do { |
1765 |
+ *op++ = *m_pos++; |
1766 |
+ } while (op < oe); |
1767 |
+@@ -181,7 +201,7 @@ copy_literal_run: |
1768 |
+ #endif |
1769 |
+ { |
1770 |
+ unsigned char *oe = op + t; |
1771 |
+- NEED_OP(t); |
1772 |
++ NEED_OP(t, 0); |
1773 |
+ op[0] = m_pos[0]; |
1774 |
+ op[1] = m_pos[1]; |
1775 |
+ op += 2; |
1776 |
+@@ -194,15 +214,15 @@ match_next: |
1777 |
+ state = next; |
1778 |
+ t = next; |
1779 |
+ #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) |
1780 |
+- if (likely(HAVE_IP(6) && HAVE_OP(4))) { |
1781 |
++ if (likely(HAVE_IP(6, 0) && HAVE_OP(4, 0))) { |
1782 |
+ COPY4(op, ip); |
1783 |
+ op += t; |
1784 |
+ ip += t; |
1785 |
+ } else |
1786 |
+ #endif |
1787 |
+ { |
1788 |
+- NEED_IP(t + 3); |
1789 |
+- NEED_OP(t); |
1790 |
++ NEED_IP(t, 3); |
1791 |
++ NEED_OP(t, 0); |
1792 |
+ while (t > 0) { |
1793 |
+ *op++ = *ip++; |
1794 |
+ t--; |
1795 |
+diff --git a/lib/nlattr.c b/lib/nlattr.c |
1796 |
+index fc6754720ced..10ad042d01be 100644 |
1797 |
+--- a/lib/nlattr.c |
1798 |
++++ b/lib/nlattr.c |
1799 |
+@@ -201,8 +201,8 @@ int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head, |
1800 |
+ } |
1801 |
+ |
1802 |
+ if (unlikely(rem > 0)) |
1803 |
+- printk(KERN_WARNING "netlink: %d bytes leftover after parsing " |
1804 |
+- "attributes.\n", rem); |
1805 |
++ pr_warn_ratelimited("netlink: %d bytes leftover after parsing attributes in process `%s'.\n", |
1806 |
++ rem, current->comm); |
1807 |
+ |
1808 |
+ err = 0; |
1809 |
+ errout: |
1810 |
+diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c |
1811 |
+index 7985deaff52f..04d6348fd530 100644 |
1812 |
+--- a/net/bridge/br_input.c |
1813 |
++++ b/net/bridge/br_input.c |
1814 |
+@@ -147,8 +147,8 @@ static int br_handle_local_finish(struct sk_buff *skb) |
1815 |
+ struct net_bridge_port *p = br_port_get_rcu(skb->dev); |
1816 |
+ u16 vid = 0; |
1817 |
+ |
1818 |
+- br_vlan_get_tag(skb, &vid); |
1819 |
+- if (p->flags & BR_LEARNING) |
1820 |
++ /* check if vlan is allowed, to avoid spoofing */ |
1821 |
++ if (p->flags & BR_LEARNING && br_should_learn(p, skb, &vid)) |
1822 |
+ br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, false); |
1823 |
+ return 0; /* process further */ |
1824 |
+ } |
1825 |
+diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h |
1826 |
+index 3ba11bc99b65..f2d254b69353 100644 |
1827 |
+--- a/net/bridge/br_private.h |
1828 |
++++ b/net/bridge/br_private.h |
1829 |
+@@ -581,6 +581,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v, |
1830 |
+ struct sk_buff *skb, u16 *vid); |
1831 |
+ bool br_allowed_egress(struct net_bridge *br, const struct net_port_vlans *v, |
1832 |
+ const struct sk_buff *skb); |
1833 |
++bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid); |
1834 |
+ struct sk_buff *br_handle_vlan(struct net_bridge *br, |
1835 |
+ const struct net_port_vlans *v, |
1836 |
+ struct sk_buff *skb); |
1837 |
+@@ -648,6 +649,12 @@ static inline bool br_allowed_egress(struct net_bridge *br, |
1838 |
+ return true; |
1839 |
+ } |
1840 |
+ |
1841 |
++static inline bool br_should_learn(struct net_bridge_port *p, |
1842 |
++ struct sk_buff *skb, u16 *vid) |
1843 |
++{ |
1844 |
++ return true; |
1845 |
++} |
1846 |
++ |
1847 |
+ static inline struct sk_buff *br_handle_vlan(struct net_bridge *br, |
1848 |
+ const struct net_port_vlans *v, |
1849 |
+ struct sk_buff *skb) |
1850 |
+diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c |
1851 |
+index ba7757b7737d..b1c637208497 100644 |
1852 |
+--- a/net/bridge/br_vlan.c |
1853 |
++++ b/net/bridge/br_vlan.c |
1854 |
+@@ -241,6 +241,34 @@ bool br_allowed_egress(struct net_bridge *br, |
1855 |
+ return false; |
1856 |
+ } |
1857 |
+ |
1858 |
++/* Called under RCU */ |
1859 |
++bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid) |
1860 |
++{ |
1861 |
++ struct net_bridge *br = p->br; |
1862 |
++ struct net_port_vlans *v; |
1863 |
++ |
1864 |
++ if (!br->vlan_enabled) |
1865 |
++ return true; |
1866 |
++ |
1867 |
++ v = rcu_dereference(p->vlan_info); |
1868 |
++ if (!v) |
1869 |
++ return false; |
1870 |
++ |
1871 |
++ br_vlan_get_tag(skb, vid); |
1872 |
++ if (!*vid) { |
1873 |
++ *vid = br_get_pvid(v); |
1874 |
++ if (*vid == VLAN_N_VID) |
1875 |
++ return false; |
1876 |
++ |
1877 |
++ return true; |
1878 |
++ } |
1879 |
++ |
1880 |
++ if (test_bit(*vid, v->vlan_bitmap)) |
1881 |
++ return true; |
1882 |
++ |
1883 |
++ return false; |
1884 |
++} |
1885 |
++ |
1886 |
+ /* Must be protected by RTNL. |
1887 |
+ * Must be called with vid in range from 1 to 4094 inclusive. |
1888 |
+ */ |
1889 |
+diff --git a/net/can/gw.c b/net/can/gw.c |
1890 |
+index ac31891967da..050a2110d43f 100644 |
1891 |
+--- a/net/can/gw.c |
1892 |
++++ b/net/can/gw.c |
1893 |
+@@ -804,7 +804,7 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh) |
1894 |
+ u8 limhops = 0; |
1895 |
+ int err = 0; |
1896 |
+ |
1897 |
+- if (!capable(CAP_NET_ADMIN)) |
1898 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
1899 |
+ return -EPERM; |
1900 |
+ |
1901 |
+ if (nlmsg_len(nlh) < sizeof(*r)) |
1902 |
+@@ -893,7 +893,7 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh) |
1903 |
+ u8 limhops = 0; |
1904 |
+ int err = 0; |
1905 |
+ |
1906 |
+- if (!capable(CAP_NET_ADMIN)) |
1907 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
1908 |
+ return -EPERM; |
1909 |
+ |
1910 |
+ if (nlmsg_len(nlh) < sizeof(*r)) |
1911 |
+diff --git a/net/core/dev.c b/net/core/dev.c |
1912 |
+index fccc195e0fc8..4c1b483f7c07 100644 |
1913 |
+--- a/net/core/dev.c |
1914 |
++++ b/net/core/dev.c |
1915 |
+@@ -6548,6 +6548,9 @@ EXPORT_SYMBOL(unregister_netdevice_queue); |
1916 |
+ /** |
1917 |
+ * unregister_netdevice_many - unregister many devices |
1918 |
+ * @head: list of devices |
1919 |
++ * |
1920 |
++ * Note: As most callers use a stack allocated list_head, |
1921 |
++ * we force a list_del() to make sure stack wont be corrupted later. |
1922 |
+ */ |
1923 |
+ void unregister_netdevice_many(struct list_head *head) |
1924 |
+ { |
1925 |
+@@ -6557,6 +6560,7 @@ void unregister_netdevice_many(struct list_head *head) |
1926 |
+ rollback_registered_many(head); |
1927 |
+ list_for_each_entry(dev, head, unreg_list) |
1928 |
+ net_set_todo(dev); |
1929 |
++ list_del(head); |
1930 |
+ } |
1931 |
+ } |
1932 |
+ EXPORT_SYMBOL(unregister_netdevice_many); |
1933 |
+@@ -7012,7 +7016,6 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list) |
1934 |
+ } |
1935 |
+ } |
1936 |
+ unregister_netdevice_many(&dev_kill_list); |
1937 |
+- list_del(&dev_kill_list); |
1938 |
+ rtnl_unlock(); |
1939 |
+ } |
1940 |
+ |
1941 |
+diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c |
1942 |
+index 83b9d6ae5119..aef1500ebc05 100644 |
1943 |
+--- a/net/core/rtnetlink.c |
1944 |
++++ b/net/core/rtnetlink.c |
1945 |
+@@ -1166,6 +1166,7 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) |
1946 |
+ struct nlattr *tb[IFLA_MAX+1]; |
1947 |
+ u32 ext_filter_mask = 0; |
1948 |
+ int err; |
1949 |
++ int hdrlen; |
1950 |
+ |
1951 |
+ s_h = cb->args[0]; |
1952 |
+ s_idx = cb->args[1]; |
1953 |
+@@ -1173,8 +1174,17 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) |
1954 |
+ rcu_read_lock(); |
1955 |
+ cb->seq = net->dev_base_seq; |
1956 |
+ |
1957 |
+- if (nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX, |
1958 |
+- ifla_policy) >= 0) { |
1959 |
++ /* A hack to preserve kernel<->userspace interface. |
1960 |
++ * The correct header is ifinfomsg. It is consistent with rtnl_getlink. |
1961 |
++ * However, before Linux v3.9 the code here assumed rtgenmsg and that's |
1962 |
++ * what iproute2 < v3.9.0 used. |
1963 |
++ * We can detect the old iproute2. Even including the IFLA_EXT_MASK |
1964 |
++ * attribute, its netlink message is shorter than struct ifinfomsg. |
1965 |
++ */ |
1966 |
++ hdrlen = nlmsg_len(cb->nlh) < sizeof(struct ifinfomsg) ? |
1967 |
++ sizeof(struct rtgenmsg) : sizeof(struct ifinfomsg); |
1968 |
++ |
1969 |
++ if (nlmsg_parse(cb->nlh, hdrlen, tb, IFLA_MAX, ifla_policy) >= 0) { |
1970 |
+ |
1971 |
+ if (tb[IFLA_EXT_MASK]) |
1972 |
+ ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]); |
1973 |
+@@ -1428,7 +1438,8 @@ static int do_set_master(struct net_device *dev, int ifindex) |
1974 |
+ return 0; |
1975 |
+ } |
1976 |
+ |
1977 |
+-static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, |
1978 |
++static int do_setlink(const struct sk_buff *skb, |
1979 |
++ struct net_device *dev, struct ifinfomsg *ifm, |
1980 |
+ struct nlattr **tb, char *ifname, int modified) |
1981 |
+ { |
1982 |
+ const struct net_device_ops *ops = dev->netdev_ops; |
1983 |
+@@ -1440,7 +1451,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, |
1984 |
+ err = PTR_ERR(net); |
1985 |
+ goto errout; |
1986 |
+ } |
1987 |
+- if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) { |
1988 |
++ if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) { |
1989 |
+ err = -EPERM; |
1990 |
+ goto errout; |
1991 |
+ } |
1992 |
+@@ -1694,7 +1705,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh) |
1993 |
+ if (err < 0) |
1994 |
+ goto errout; |
1995 |
+ |
1996 |
+- err = do_setlink(dev, ifm, tb, ifname, 0); |
1997 |
++ err = do_setlink(skb, dev, ifm, tb, ifname, 0); |
1998 |
+ errout: |
1999 |
+ return err; |
2000 |
+ } |
2001 |
+@@ -1734,7 +1745,6 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh) |
2002 |
+ |
2003 |
+ ops->dellink(dev, &list_kill); |
2004 |
+ unregister_netdevice_many(&list_kill); |
2005 |
+- list_del(&list_kill); |
2006 |
+ return 0; |
2007 |
+ } |
2008 |
+ |
2009 |
+@@ -1811,7 +1821,8 @@ err: |
2010 |
+ } |
2011 |
+ EXPORT_SYMBOL(rtnl_create_link); |
2012 |
+ |
2013 |
+-static int rtnl_group_changelink(struct net *net, int group, |
2014 |
++static int rtnl_group_changelink(const struct sk_buff *skb, |
2015 |
++ struct net *net, int group, |
2016 |
+ struct ifinfomsg *ifm, |
2017 |
+ struct nlattr **tb) |
2018 |
+ { |
2019 |
+@@ -1820,7 +1831,7 @@ static int rtnl_group_changelink(struct net *net, int group, |
2020 |
+ |
2021 |
+ for_each_netdev(net, dev) { |
2022 |
+ if (dev->group == group) { |
2023 |
+- err = do_setlink(dev, ifm, tb, NULL, 0); |
2024 |
++ err = do_setlink(skb, dev, ifm, tb, NULL, 0); |
2025 |
+ if (err < 0) |
2026 |
+ return err; |
2027 |
+ } |
2028 |
+@@ -1962,12 +1973,12 @@ replay: |
2029 |
+ modified = 1; |
2030 |
+ } |
2031 |
+ |
2032 |
+- return do_setlink(dev, ifm, tb, ifname, modified); |
2033 |
++ return do_setlink(skb, dev, ifm, tb, ifname, modified); |
2034 |
+ } |
2035 |
+ |
2036 |
+ if (!(nlh->nlmsg_flags & NLM_F_CREATE)) { |
2037 |
+ if (ifm->ifi_index == 0 && tb[IFLA_GROUP]) |
2038 |
+- return rtnl_group_changelink(net, |
2039 |
++ return rtnl_group_changelink(skb, net, |
2040 |
+ nla_get_u32(tb[IFLA_GROUP]), |
2041 |
+ ifm, tb); |
2042 |
+ return -ENODEV; |
2043 |
+@@ -2084,9 +2095,13 @@ static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh) |
2044 |
+ struct nlattr *tb[IFLA_MAX+1]; |
2045 |
+ u32 ext_filter_mask = 0; |
2046 |
+ u16 min_ifinfo_dump_size = 0; |
2047 |
++ int hdrlen; |
2048 |
++ |
2049 |
++ /* Same kernel<->userspace interface hack as in rtnl_dump_ifinfo. */ |
2050 |
++ hdrlen = nlmsg_len(nlh) < sizeof(struct ifinfomsg) ? |
2051 |
++ sizeof(struct rtgenmsg) : sizeof(struct ifinfomsg); |
2052 |
+ |
2053 |
+- if (nlmsg_parse(nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX, |
2054 |
+- ifla_policy) >= 0) { |
2055 |
++ if (nlmsg_parse(nlh, hdrlen, tb, IFLA_MAX, ifla_policy) >= 0) { |
2056 |
+ if (tb[IFLA_EXT_MASK]) |
2057 |
+ ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]); |
2058 |
+ } |
2059 |
+@@ -2354,7 +2369,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh) |
2060 |
+ int err = -EINVAL; |
2061 |
+ __u8 *addr; |
2062 |
+ |
2063 |
+- if (!capable(CAP_NET_ADMIN)) |
2064 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
2065 |
+ return -EPERM; |
2066 |
+ |
2067 |
+ err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL); |
2068 |
+@@ -2806,7 +2821,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
2069 |
+ sz_idx = type>>2; |
2070 |
+ kind = type&3; |
2071 |
+ |
2072 |
+- if (kind != 2 && !ns_capable(net->user_ns, CAP_NET_ADMIN)) |
2073 |
++ if (kind != 2 && !netlink_net_capable(skb, CAP_NET_ADMIN)) |
2074 |
+ return -EPERM; |
2075 |
+ |
2076 |
+ if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) { |
2077 |
+diff --git a/net/core/sock.c b/net/core/sock.c |
2078 |
+index c0fc6bdad1e3..c8069561bdb7 100644 |
2079 |
+--- a/net/core/sock.c |
2080 |
++++ b/net/core/sock.c |
2081 |
+@@ -145,6 +145,55 @@ |
2082 |
+ static DEFINE_MUTEX(proto_list_mutex); |
2083 |
+ static LIST_HEAD(proto_list); |
2084 |
+ |
2085 |
++/** |
2086 |
++ * sk_ns_capable - General socket capability test |
2087 |
++ * @sk: Socket to use a capability on or through |
2088 |
++ * @user_ns: The user namespace of the capability to use |
2089 |
++ * @cap: The capability to use |
2090 |
++ * |
2091 |
++ * Test to see if the opener of the socket had when the socket was |
2092 |
++ * created and the current process has the capability @cap in the user |
2093 |
++ * namespace @user_ns. |
2094 |
++ */ |
2095 |
++bool sk_ns_capable(const struct sock *sk, |
2096 |
++ struct user_namespace *user_ns, int cap) |
2097 |
++{ |
2098 |
++ return file_ns_capable(sk->sk_socket->file, user_ns, cap) && |
2099 |
++ ns_capable(user_ns, cap); |
2100 |
++} |
2101 |
++EXPORT_SYMBOL(sk_ns_capable); |
2102 |
++ |
2103 |
++/** |
2104 |
++ * sk_capable - Socket global capability test |
2105 |
++ * @sk: Socket to use a capability on or through |
2106 |
++ * @cap: The global capbility to use |
2107 |
++ * |
2108 |
++ * Test to see if the opener of the socket had when the socket was |
2109 |
++ * created and the current process has the capability @cap in all user |
2110 |
++ * namespaces. |
2111 |
++ */ |
2112 |
++bool sk_capable(const struct sock *sk, int cap) |
2113 |
++{ |
2114 |
++ return sk_ns_capable(sk, &init_user_ns, cap); |
2115 |
++} |
2116 |
++EXPORT_SYMBOL(sk_capable); |
2117 |
++ |
2118 |
++/** |
2119 |
++ * sk_net_capable - Network namespace socket capability test |
2120 |
++ * @sk: Socket to use a capability on or through |
2121 |
++ * @cap: The capability to use |
2122 |
++ * |
2123 |
++ * Test to see if the opener of the socket had when the socke was created |
2124 |
++ * and the current process has the capability @cap over the network namespace |
2125 |
++ * the socket is a member of. |
2126 |
++ */ |
2127 |
++bool sk_net_capable(const struct sock *sk, int cap) |
2128 |
++{ |
2129 |
++ return sk_ns_capable(sk, sock_net(sk)->user_ns, cap); |
2130 |
++} |
2131 |
++EXPORT_SYMBOL(sk_net_capable); |
2132 |
++ |
2133 |
++ |
2134 |
+ #ifdef CONFIG_MEMCG_KMEM |
2135 |
+ int mem_cgroup_sockets_init(struct mem_cgroup *memcg, struct cgroup_subsys *ss) |
2136 |
+ { |
2137 |
+diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c |
2138 |
+index 6a7fae228634..c38e7a2b5a8e 100644 |
2139 |
+--- a/net/core/sock_diag.c |
2140 |
++++ b/net/core/sock_diag.c |
2141 |
+@@ -49,7 +49,7 @@ int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attrtype) |
2142 |
+ } |
2143 |
+ EXPORT_SYMBOL_GPL(sock_diag_put_meminfo); |
2144 |
+ |
2145 |
+-int sock_diag_put_filterinfo(struct sock *sk, |
2146 |
++int sock_diag_put_filterinfo(bool may_report_filterinfo, struct sock *sk, |
2147 |
+ struct sk_buff *skb, int attrtype) |
2148 |
+ { |
2149 |
+ struct nlattr *attr; |
2150 |
+@@ -57,7 +57,7 @@ int sock_diag_put_filterinfo(struct sock *sk, |
2151 |
+ unsigned int len; |
2152 |
+ int err = 0; |
2153 |
+ |
2154 |
+- if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) { |
2155 |
++ if (!may_report_filterinfo) { |
2156 |
+ nla_reserve(skb, attrtype, 0); |
2157 |
+ return 0; |
2158 |
+ } |
2159 |
+diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c |
2160 |
+index 553644402670..f8b98d89c285 100644 |
2161 |
+--- a/net/dcb/dcbnl.c |
2162 |
++++ b/net/dcb/dcbnl.c |
2163 |
+@@ -1669,7 +1669,7 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh) |
2164 |
+ struct nlmsghdr *reply_nlh = NULL; |
2165 |
+ const struct reply_func *fn; |
2166 |
+ |
2167 |
+- if ((nlh->nlmsg_type == RTM_SETDCB) && !capable(CAP_NET_ADMIN)) |
2168 |
++ if ((nlh->nlmsg_type == RTM_SETDCB) && !netlink_capable(skb, CAP_NET_ADMIN)) |
2169 |
+ return -EPERM; |
2170 |
+ |
2171 |
+ ret = nlmsg_parse(nlh, sizeof(*dcb), tb, DCB_ATTR_MAX, |
2172 |
+diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c |
2173 |
+index a603823a3e27..3b726f31c64c 100644 |
2174 |
+--- a/net/decnet/dn_dev.c |
2175 |
++++ b/net/decnet/dn_dev.c |
2176 |
+@@ -574,7 +574,7 @@ static int dn_nl_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh) |
2177 |
+ struct dn_ifaddr __rcu **ifap; |
2178 |
+ int err = -EINVAL; |
2179 |
+ |
2180 |
+- if (!capable(CAP_NET_ADMIN)) |
2181 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
2182 |
+ return -EPERM; |
2183 |
+ |
2184 |
+ if (!net_eq(net, &init_net)) |
2185 |
+@@ -618,7 +618,7 @@ static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh) |
2186 |
+ struct dn_ifaddr *ifa; |
2187 |
+ int err; |
2188 |
+ |
2189 |
+- if (!capable(CAP_NET_ADMIN)) |
2190 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
2191 |
+ return -EPERM; |
2192 |
+ |
2193 |
+ if (!net_eq(net, &init_net)) |
2194 |
+diff --git a/net/decnet/dn_fib.c b/net/decnet/dn_fib.c |
2195 |
+index 57dc159245ec..d332aefb0846 100644 |
2196 |
+--- a/net/decnet/dn_fib.c |
2197 |
++++ b/net/decnet/dn_fib.c |
2198 |
+@@ -505,7 +505,7 @@ static int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh) |
2199 |
+ struct nlattr *attrs[RTA_MAX+1]; |
2200 |
+ int err; |
2201 |
+ |
2202 |
+- if (!capable(CAP_NET_ADMIN)) |
2203 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
2204 |
+ return -EPERM; |
2205 |
+ |
2206 |
+ if (!net_eq(net, &init_net)) |
2207 |
+@@ -530,7 +530,7 @@ static int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh) |
2208 |
+ struct nlattr *attrs[RTA_MAX+1]; |
2209 |
+ int err; |
2210 |
+ |
2211 |
+- if (!capable(CAP_NET_ADMIN)) |
2212 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
2213 |
+ return -EPERM; |
2214 |
+ |
2215 |
+ if (!net_eq(net, &init_net)) |
2216 |
+diff --git a/net/decnet/netfilter/dn_rtmsg.c b/net/decnet/netfilter/dn_rtmsg.c |
2217 |
+index e83015cecfa7..e4d9560a910b 100644 |
2218 |
+--- a/net/decnet/netfilter/dn_rtmsg.c |
2219 |
++++ b/net/decnet/netfilter/dn_rtmsg.c |
2220 |
+@@ -107,7 +107,7 @@ static inline void dnrmg_receive_user_skb(struct sk_buff *skb) |
2221 |
+ if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len) |
2222 |
+ return; |
2223 |
+ |
2224 |
+- if (!capable(CAP_NET_ADMIN)) |
2225 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
2226 |
+ RCV_SKB_FAIL(-EPERM); |
2227 |
+ |
2228 |
+ /* Eventually we might send routing messages too */ |
2229 |
+diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c |
2230 |
+index 8b5134c582f1..a3095fdefbed 100644 |
2231 |
+--- a/net/ipv4/datagram.c |
2232 |
++++ b/net/ipv4/datagram.c |
2233 |
+@@ -86,18 +86,26 @@ out: |
2234 |
+ } |
2235 |
+ EXPORT_SYMBOL(ip4_datagram_connect); |
2236 |
+ |
2237 |
++/* Because UDP xmit path can manipulate sk_dst_cache without holding |
2238 |
++ * socket lock, we need to use sk_dst_set() here, |
2239 |
++ * even if we own the socket lock. |
2240 |
++ */ |
2241 |
+ void ip4_datagram_release_cb(struct sock *sk) |
2242 |
+ { |
2243 |
+ const struct inet_sock *inet = inet_sk(sk); |
2244 |
+ const struct ip_options_rcu *inet_opt; |
2245 |
+ __be32 daddr = inet->inet_daddr; |
2246 |
++ struct dst_entry *dst; |
2247 |
+ struct flowi4 fl4; |
2248 |
+ struct rtable *rt; |
2249 |
+ |
2250 |
+- if (! __sk_dst_get(sk) || __sk_dst_check(sk, 0)) |
2251 |
+- return; |
2252 |
+- |
2253 |
+ rcu_read_lock(); |
2254 |
++ |
2255 |
++ dst = __sk_dst_get(sk); |
2256 |
++ if (!dst || !dst->obsolete || dst->ops->check(dst, 0)) { |
2257 |
++ rcu_read_unlock(); |
2258 |
++ return; |
2259 |
++ } |
2260 |
+ inet_opt = rcu_dereference(inet->inet_opt); |
2261 |
+ if (inet_opt && inet_opt->opt.srr) |
2262 |
+ daddr = inet_opt->opt.faddr; |
2263 |
+@@ -105,8 +113,10 @@ void ip4_datagram_release_cb(struct sock *sk) |
2264 |
+ inet->inet_saddr, inet->inet_dport, |
2265 |
+ inet->inet_sport, sk->sk_protocol, |
2266 |
+ RT_CONN_FLAGS(sk), sk->sk_bound_dev_if); |
2267 |
+- if (!IS_ERR(rt)) |
2268 |
+- __sk_dst_set(sk, &rt->dst); |
2269 |
++ |
2270 |
++ dst = !IS_ERR(rt) ? &rt->dst : NULL; |
2271 |
++ sk_dst_set(sk, dst); |
2272 |
++ |
2273 |
+ rcu_read_unlock(); |
2274 |
+ } |
2275 |
+ EXPORT_SYMBOL_GPL(ip4_datagram_release_cb); |
2276 |
+diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c |
2277 |
+index 812b18351462..62eaa005e146 100644 |
2278 |
+--- a/net/ipv4/ipip.c |
2279 |
++++ b/net/ipv4/ipip.c |
2280 |
+@@ -149,13 +149,13 @@ static int ipip_err(struct sk_buff *skb, u32 info) |
2281 |
+ |
2282 |
+ if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) { |
2283 |
+ ipv4_update_pmtu(skb, dev_net(skb->dev), info, |
2284 |
+- t->dev->ifindex, 0, IPPROTO_IPIP, 0); |
2285 |
++ t->parms.link, 0, IPPROTO_IPIP, 0); |
2286 |
+ err = 0; |
2287 |
+ goto out; |
2288 |
+ } |
2289 |
+ |
2290 |
+ if (type == ICMP_REDIRECT) { |
2291 |
+- ipv4_redirect(skb, dev_net(skb->dev), t->dev->ifindex, 0, |
2292 |
++ ipv4_redirect(skb, dev_net(skb->dev), t->parms.link, 0, |
2293 |
+ IPPROTO_IPIP, 0); |
2294 |
+ err = 0; |
2295 |
+ goto out; |
2296 |
+@@ -486,4 +486,5 @@ static void __exit ipip_fini(void) |
2297 |
+ module_init(ipip_init); |
2298 |
+ module_exit(ipip_fini); |
2299 |
+ MODULE_LICENSE("GPL"); |
2300 |
++MODULE_ALIAS_RTNL_LINK("ipip"); |
2301 |
+ MODULE_ALIAS_NETDEV("tunl0"); |
2302 |
+diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c |
2303 |
+index eeaac399420d..e3647465138b 100644 |
2304 |
+--- a/net/ipv4/tcp_input.c |
2305 |
++++ b/net/ipv4/tcp_input.c |
2306 |
+@@ -2683,13 +2683,12 @@ static void tcp_process_loss(struct sock *sk, int flag, bool is_dupack) |
2307 |
+ bool recovered = !before(tp->snd_una, tp->high_seq); |
2308 |
+ |
2309 |
+ if (tp->frto) { /* F-RTO RFC5682 sec 3.1 (sack enhanced version). */ |
2310 |
+- if (flag & FLAG_ORIG_SACK_ACKED) { |
2311 |
+- /* Step 3.b. A timeout is spurious if not all data are |
2312 |
+- * lost, i.e., never-retransmitted data are (s)acked. |
2313 |
+- */ |
2314 |
+- tcp_try_undo_loss(sk, true); |
2315 |
++ /* Step 3.b. A timeout is spurious if not all data are |
2316 |
++ * lost, i.e., never-retransmitted data are (s)acked. |
2317 |
++ */ |
2318 |
++ if (tcp_try_undo_loss(sk, flag & FLAG_ORIG_SACK_ACKED)) |
2319 |
+ return; |
2320 |
+- } |
2321 |
++ |
2322 |
+ if (after(tp->snd_nxt, tp->high_seq) && |
2323 |
+ (flag & FLAG_DATA_SACKED || is_dupack)) { |
2324 |
+ tp->frto = 0; /* Loss was real: 2nd part of step 3.a */ |
2325 |
+diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c |
2326 |
+index 77bd16fa9f34..b25e852625d8 100644 |
2327 |
+--- a/net/ipv4/udp.c |
2328 |
++++ b/net/ipv4/udp.c |
2329 |
+@@ -1833,6 +1833,10 @@ static struct sock *__udp4_lib_mcast_demux_lookup(struct net *net, |
2330 |
+ unsigned int count, slot = udp_hashfn(net, hnum, udp_table.mask); |
2331 |
+ struct udp_hslot *hslot = &udp_table.hash[slot]; |
2332 |
+ |
2333 |
++ /* Do not bother scanning a too big list */ |
2334 |
++ if (hslot->count > 10) |
2335 |
++ return NULL; |
2336 |
++ |
2337 |
+ rcu_read_lock(); |
2338 |
+ begin: |
2339 |
+ count = 0; |
2340 |
+diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c |
2341 |
+index 0e51f68ab163..912033957ad3 100644 |
2342 |
+--- a/net/ipv6/ip6_tunnel.c |
2343 |
++++ b/net/ipv6/ip6_tunnel.c |
2344 |
+@@ -61,6 +61,7 @@ |
2345 |
+ MODULE_AUTHOR("Ville Nuorvala"); |
2346 |
+ MODULE_DESCRIPTION("IPv6 tunneling device"); |
2347 |
+ MODULE_LICENSE("GPL"); |
2348 |
++MODULE_ALIAS_RTNL_LINK("ip6tnl"); |
2349 |
+ MODULE_ALIAS_NETDEV("ip6tnl0"); |
2350 |
+ |
2351 |
+ #ifdef IP6_TNL_DEBUG |
2352 |
+diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c |
2353 |
+index 827f795209cf..b31a01263185 100644 |
2354 |
+--- a/net/ipv6/output_core.c |
2355 |
++++ b/net/ipv6/output_core.c |
2356 |
+@@ -10,7 +10,7 @@ |
2357 |
+ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt) |
2358 |
+ { |
2359 |
+ static atomic_t ipv6_fragmentation_id; |
2360 |
+- int old, new; |
2361 |
++ int ident; |
2362 |
+ |
2363 |
+ #if IS_ENABLED(CONFIG_IPV6) |
2364 |
+ if (rt && !(rt->dst.flags & DST_NOPEER)) { |
2365 |
+@@ -26,13 +26,8 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt) |
2366 |
+ } |
2367 |
+ } |
2368 |
+ #endif |
2369 |
+- do { |
2370 |
+- old = atomic_read(&ipv6_fragmentation_id); |
2371 |
+- new = old + 1; |
2372 |
+- if (!new) |
2373 |
+- new = 1; |
2374 |
+- } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old); |
2375 |
+- fhdr->identification = htonl(new); |
2376 |
++ ident = atomic_inc_return(&ipv6_fragmentation_id); |
2377 |
++ fhdr->identification = htonl(ident); |
2378 |
+ } |
2379 |
+ EXPORT_SYMBOL(ipv6_select_ident); |
2380 |
+ |
2381 |
+diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c |
2382 |
+index b4d74c86586c..fe548ba72687 100644 |
2383 |
+--- a/net/ipv6/sit.c |
2384 |
++++ b/net/ipv6/sit.c |
2385 |
+@@ -560,12 +560,12 @@ static int ipip6_err(struct sk_buff *skb, u32 info) |
2386 |
+ |
2387 |
+ if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) { |
2388 |
+ ipv4_update_pmtu(skb, dev_net(skb->dev), info, |
2389 |
+- t->dev->ifindex, 0, IPPROTO_IPV6, 0); |
2390 |
++ t->parms.link, 0, IPPROTO_IPV6, 0); |
2391 |
+ err = 0; |
2392 |
+ goto out; |
2393 |
+ } |
2394 |
+ if (type == ICMP_REDIRECT) { |
2395 |
+- ipv4_redirect(skb, dev_net(skb->dev), t->dev->ifindex, 0, |
2396 |
++ ipv4_redirect(skb, dev_net(skb->dev), t->parms.link, 0, |
2397 |
+ IPPROTO_IPV6, 0); |
2398 |
+ err = 0; |
2399 |
+ goto out; |
2400 |
+@@ -1850,4 +1850,5 @@ xfrm_tunnel_failed: |
2401 |
+ module_init(sit_init); |
2402 |
+ module_exit(sit_cleanup); |
2403 |
+ MODULE_LICENSE("GPL"); |
2404 |
++MODULE_ALIAS_RTNL_LINK("sit"); |
2405 |
+ MODULE_ALIAS_NETDEV("sit0"); |
2406 |
+diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c |
2407 |
+index 1e586d92260e..20b63d2ab70f 100644 |
2408 |
+--- a/net/ipv6/udp.c |
2409 |
++++ b/net/ipv6/udp.c |
2410 |
+@@ -716,15 +716,15 @@ static struct sock *udp_v6_mcast_next(struct net *net, struct sock *sk, |
2411 |
+ if (inet->inet_dport != rmt_port) |
2412 |
+ continue; |
2413 |
+ } |
2414 |
+- if (!ipv6_addr_any(&sk->sk_v6_daddr) && |
2415 |
+- !ipv6_addr_equal(&sk->sk_v6_daddr, rmt_addr)) |
2416 |
++ if (!ipv6_addr_any(&s->sk_v6_daddr) && |
2417 |
++ !ipv6_addr_equal(&s->sk_v6_daddr, rmt_addr)) |
2418 |
+ continue; |
2419 |
+ |
2420 |
+ if (s->sk_bound_dev_if && s->sk_bound_dev_if != dif) |
2421 |
+ continue; |
2422 |
+ |
2423 |
+- if (!ipv6_addr_any(&sk->sk_v6_rcv_saddr)) { |
2424 |
+- if (!ipv6_addr_equal(&sk->sk_v6_rcv_saddr, loc_addr)) |
2425 |
++ if (!ipv6_addr_any(&s->sk_v6_rcv_saddr)) { |
2426 |
++ if (!ipv6_addr_equal(&s->sk_v6_rcv_saddr, loc_addr)) |
2427 |
+ continue; |
2428 |
+ } |
2429 |
+ if (!inet6_mc_check(s, loc_addr, rmt_addr)) |
2430 |
+diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c |
2431 |
+index ce1c44370610..8f7fabc46c97 100644 |
2432 |
+--- a/net/mac80211/iface.c |
2433 |
++++ b/net/mac80211/iface.c |
2434 |
+@@ -1761,7 +1761,6 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local) |
2435 |
+ } |
2436 |
+ mutex_unlock(&local->iflist_mtx); |
2437 |
+ unregister_netdevice_many(&unreg_list); |
2438 |
+- list_del(&unreg_list); |
2439 |
+ |
2440 |
+ list_for_each_entry_safe(sdata, tmp, &wdev_list, list) { |
2441 |
+ list_del(&sdata->list); |
2442 |
+diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c |
2443 |
+index 880418d3ee50..bf8a108b46e2 100644 |
2444 |
+--- a/net/netfilter/nfnetlink.c |
2445 |
++++ b/net/netfilter/nfnetlink.c |
2446 |
+@@ -367,7 +367,7 @@ static void nfnetlink_rcv(struct sk_buff *skb) |
2447 |
+ skb->len < nlh->nlmsg_len) |
2448 |
+ return; |
2449 |
+ |
2450 |
+- if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) { |
2451 |
++ if (!netlink_net_capable(skb, CAP_NET_ADMIN)) { |
2452 |
+ netlink_ack(skb, nlh, -EPERM); |
2453 |
+ return; |
2454 |
+ } |
2455 |
+diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c |
2456 |
+index 04748ab649c2..7f40fd25acae 100644 |
2457 |
+--- a/net/netlink/af_netlink.c |
2458 |
++++ b/net/netlink/af_netlink.c |
2459 |
+@@ -1360,7 +1360,74 @@ retry: |
2460 |
+ return err; |
2461 |
+ } |
2462 |
+ |
2463 |
+-static inline int netlink_capable(const struct socket *sock, unsigned int flag) |
2464 |
++/** |
2465 |
++ * __netlink_ns_capable - General netlink message capability test |
2466 |
++ * @nsp: NETLINK_CB of the socket buffer holding a netlink command from userspace. |
2467 |
++ * @user_ns: The user namespace of the capability to use |
2468 |
++ * @cap: The capability to use |
2469 |
++ * |
2470 |
++ * Test to see if the opener of the socket we received the message |
2471 |
++ * from had when the netlink socket was created and the sender of the |
2472 |
++ * message has has the capability @cap in the user namespace @user_ns. |
2473 |
++ */ |
2474 |
++bool __netlink_ns_capable(const struct netlink_skb_parms *nsp, |
2475 |
++ struct user_namespace *user_ns, int cap) |
2476 |
++{ |
2477 |
++ return ((nsp->flags & NETLINK_SKB_DST) || |
2478 |
++ file_ns_capable(nsp->sk->sk_socket->file, user_ns, cap)) && |
2479 |
++ ns_capable(user_ns, cap); |
2480 |
++} |
2481 |
++EXPORT_SYMBOL(__netlink_ns_capable); |
2482 |
++ |
2483 |
++/** |
2484 |
++ * netlink_ns_capable - General netlink message capability test |
2485 |
++ * @skb: socket buffer holding a netlink command from userspace |
2486 |
++ * @user_ns: The user namespace of the capability to use |
2487 |
++ * @cap: The capability to use |
2488 |
++ * |
2489 |
++ * Test to see if the opener of the socket we received the message |
2490 |
++ * from had when the netlink socket was created and the sender of the |
2491 |
++ * message has has the capability @cap in the user namespace @user_ns. |
2492 |
++ */ |
2493 |
++bool netlink_ns_capable(const struct sk_buff *skb, |
2494 |
++ struct user_namespace *user_ns, int cap) |
2495 |
++{ |
2496 |
++ return __netlink_ns_capable(&NETLINK_CB(skb), user_ns, cap); |
2497 |
++} |
2498 |
++EXPORT_SYMBOL(netlink_ns_capable); |
2499 |
++ |
2500 |
++/** |
2501 |
++ * netlink_capable - Netlink global message capability test |
2502 |
++ * @skb: socket buffer holding a netlink command from userspace |
2503 |
++ * @cap: The capability to use |
2504 |
++ * |
2505 |
++ * Test to see if the opener of the socket we received the message |
2506 |
++ * from had when the netlink socket was created and the sender of the |
2507 |
++ * message has has the capability @cap in all user namespaces. |
2508 |
++ */ |
2509 |
++bool netlink_capable(const struct sk_buff *skb, int cap) |
2510 |
++{ |
2511 |
++ return netlink_ns_capable(skb, &init_user_ns, cap); |
2512 |
++} |
2513 |
++EXPORT_SYMBOL(netlink_capable); |
2514 |
++ |
2515 |
++/** |
2516 |
++ * netlink_net_capable - Netlink network namespace message capability test |
2517 |
++ * @skb: socket buffer holding a netlink command from userspace |
2518 |
++ * @cap: The capability to use |
2519 |
++ * |
2520 |
++ * Test to see if the opener of the socket we received the message |
2521 |
++ * from had when the netlink socket was created and the sender of the |
2522 |
++ * message has has the capability @cap over the network namespace of |
2523 |
++ * the socket we received the message from. |
2524 |
++ */ |
2525 |
++bool netlink_net_capable(const struct sk_buff *skb, int cap) |
2526 |
++{ |
2527 |
++ return netlink_ns_capable(skb, sock_net(skb->sk)->user_ns, cap); |
2528 |
++} |
2529 |
++EXPORT_SYMBOL(netlink_net_capable); |
2530 |
++ |
2531 |
++static inline int netlink_allowed(const struct socket *sock, unsigned int flag) |
2532 |
+ { |
2533 |
+ return (nl_table[sock->sk->sk_protocol].flags & flag) || |
2534 |
+ ns_capable(sock_net(sock->sk)->user_ns, CAP_NET_ADMIN); |
2535 |
+@@ -1428,7 +1495,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, |
2536 |
+ |
2537 |
+ /* Only superuser is allowed to listen multicasts */ |
2538 |
+ if (nladdr->nl_groups) { |
2539 |
+- if (!netlink_capable(sock, NL_CFG_F_NONROOT_RECV)) |
2540 |
++ if (!netlink_allowed(sock, NL_CFG_F_NONROOT_RECV)) |
2541 |
+ return -EPERM; |
2542 |
+ err = netlink_realloc_groups(sk); |
2543 |
+ if (err) |
2544 |
+@@ -1490,7 +1557,7 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr, |
2545 |
+ return -EINVAL; |
2546 |
+ |
2547 |
+ if ((nladdr->nl_groups || nladdr->nl_pid) && |
2548 |
+- !netlink_capable(sock, NL_CFG_F_NONROOT_SEND)) |
2549 |
++ !netlink_allowed(sock, NL_CFG_F_NONROOT_SEND)) |
2550 |
+ return -EPERM; |
2551 |
+ |
2552 |
+ if (!nlk->portid) |
2553 |
+@@ -2096,7 +2163,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname, |
2554 |
+ break; |
2555 |
+ case NETLINK_ADD_MEMBERSHIP: |
2556 |
+ case NETLINK_DROP_MEMBERSHIP: { |
2557 |
+- if (!netlink_capable(sock, NL_CFG_F_NONROOT_RECV)) |
2558 |
++ if (!netlink_allowed(sock, NL_CFG_F_NONROOT_RECV)) |
2559 |
+ return -EPERM; |
2560 |
+ err = netlink_realloc_groups(sk); |
2561 |
+ if (err) |
2562 |
+@@ -2228,6 +2295,7 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock, |
2563 |
+ struct sk_buff *skb; |
2564 |
+ int err; |
2565 |
+ struct scm_cookie scm; |
2566 |
++ u32 netlink_skb_flags = 0; |
2567 |
+ |
2568 |
+ if (msg->msg_flags&MSG_OOB) |
2569 |
+ return -EOPNOTSUPP; |
2570 |
+@@ -2247,8 +2315,9 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock, |
2571 |
+ dst_group = ffs(addr->nl_groups); |
2572 |
+ err = -EPERM; |
2573 |
+ if ((dst_group || dst_portid) && |
2574 |
+- !netlink_capable(sock, NL_CFG_F_NONROOT_SEND)) |
2575 |
++ !netlink_allowed(sock, NL_CFG_F_NONROOT_SEND)) |
2576 |
+ goto out; |
2577 |
++ netlink_skb_flags |= NETLINK_SKB_DST; |
2578 |
+ } else { |
2579 |
+ dst_portid = nlk->dst_portid; |
2580 |
+ dst_group = nlk->dst_group; |
2581 |
+@@ -2278,6 +2347,7 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock, |
2582 |
+ NETLINK_CB(skb).portid = nlk->portid; |
2583 |
+ NETLINK_CB(skb).dst_group = dst_group; |
2584 |
+ NETLINK_CB(skb).creds = siocb->scm->creds; |
2585 |
++ NETLINK_CB(skb).flags = netlink_skb_flags; |
2586 |
+ |
2587 |
+ err = -EFAULT; |
2588 |
+ if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) { |
2589 |
+diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c |
2590 |
+index b1dcdb932a86..a3ba3ca0ff92 100644 |
2591 |
+--- a/net/netlink/genetlink.c |
2592 |
++++ b/net/netlink/genetlink.c |
2593 |
+@@ -561,7 +561,7 @@ static int genl_family_rcv_msg(struct genl_family *family, |
2594 |
+ return -EOPNOTSUPP; |
2595 |
+ |
2596 |
+ if ((ops->flags & GENL_ADMIN_PERM) && |
2597 |
+- !capable(CAP_NET_ADMIN)) |
2598 |
++ !netlink_capable(skb, CAP_NET_ADMIN)) |
2599 |
+ return -EPERM; |
2600 |
+ |
2601 |
+ if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) { |
2602 |
+diff --git a/net/packet/diag.c b/net/packet/diag.c |
2603 |
+index 435ff99ba8c7..92f2c7107eec 100644 |
2604 |
+--- a/net/packet/diag.c |
2605 |
++++ b/net/packet/diag.c |
2606 |
+@@ -128,6 +128,7 @@ static int pdiag_put_fanout(struct packet_sock *po, struct sk_buff *nlskb) |
2607 |
+ |
2608 |
+ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, |
2609 |
+ struct packet_diag_req *req, |
2610 |
++ bool may_report_filterinfo, |
2611 |
+ struct user_namespace *user_ns, |
2612 |
+ u32 portid, u32 seq, u32 flags, int sk_ino) |
2613 |
+ { |
2614 |
+@@ -172,7 +173,8 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, |
2615 |
+ goto out_nlmsg_trim; |
2616 |
+ |
2617 |
+ if ((req->pdiag_show & PACKET_SHOW_FILTER) && |
2618 |
+- sock_diag_put_filterinfo(sk, skb, PACKET_DIAG_FILTER)) |
2619 |
++ sock_diag_put_filterinfo(may_report_filterinfo, sk, skb, |
2620 |
++ PACKET_DIAG_FILTER)) |
2621 |
+ goto out_nlmsg_trim; |
2622 |
+ |
2623 |
+ return nlmsg_end(skb, nlh); |
2624 |
+@@ -188,9 +190,11 @@ static int packet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) |
2625 |
+ struct packet_diag_req *req; |
2626 |
+ struct net *net; |
2627 |
+ struct sock *sk; |
2628 |
++ bool may_report_filterinfo; |
2629 |
+ |
2630 |
+ net = sock_net(skb->sk); |
2631 |
+ req = nlmsg_data(cb->nlh); |
2632 |
++ may_report_filterinfo = netlink_net_capable(cb->skb, CAP_NET_ADMIN); |
2633 |
+ |
2634 |
+ mutex_lock(&net->packet.sklist_lock); |
2635 |
+ sk_for_each(sk, &net->packet.sklist) { |
2636 |
+@@ -200,6 +204,7 @@ static int packet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) |
2637 |
+ goto next; |
2638 |
+ |
2639 |
+ if (sk_diag_fill(sk, skb, req, |
2640 |
++ may_report_filterinfo, |
2641 |
+ sk_user_ns(NETLINK_CB(cb->skb).sk), |
2642 |
+ NETLINK_CB(cb->skb).portid, |
2643 |
+ cb->nlh->nlmsg_seq, NLM_F_MULTI, |
2644 |
+diff --git a/net/phonet/pn_netlink.c b/net/phonet/pn_netlink.c |
2645 |
+index dc15f4300808..b64151ade6b3 100644 |
2646 |
+--- a/net/phonet/pn_netlink.c |
2647 |
++++ b/net/phonet/pn_netlink.c |
2648 |
+@@ -70,10 +70,10 @@ static int addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh) |
2649 |
+ int err; |
2650 |
+ u8 pnaddr; |
2651 |
+ |
2652 |
+- if (!capable(CAP_NET_ADMIN)) |
2653 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
2654 |
+ return -EPERM; |
2655 |
+ |
2656 |
+- if (!capable(CAP_SYS_ADMIN)) |
2657 |
++ if (!netlink_capable(skb, CAP_SYS_ADMIN)) |
2658 |
+ return -EPERM; |
2659 |
+ |
2660 |
+ ASSERT_RTNL(); |
2661 |
+@@ -233,10 +233,10 @@ static int route_doit(struct sk_buff *skb, struct nlmsghdr *nlh) |
2662 |
+ int err; |
2663 |
+ u8 dst; |
2664 |
+ |
2665 |
+- if (!capable(CAP_NET_ADMIN)) |
2666 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
2667 |
+ return -EPERM; |
2668 |
+ |
2669 |
+- if (!capable(CAP_SYS_ADMIN)) |
2670 |
++ if (!netlink_capable(skb, CAP_SYS_ADMIN)) |
2671 |
+ return -EPERM; |
2672 |
+ |
2673 |
+ ASSERT_RTNL(); |
2674 |
+diff --git a/net/sched/act_api.c b/net/sched/act_api.c |
2675 |
+index 72bdc7166345..3b2265523552 100644 |
2676 |
+--- a/net/sched/act_api.c |
2677 |
++++ b/net/sched/act_api.c |
2678 |
+@@ -908,7 +908,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n) |
2679 |
+ u32 portid = skb ? NETLINK_CB(skb).portid : 0; |
2680 |
+ int ret = 0, ovr = 0; |
2681 |
+ |
2682 |
+- if ((n->nlmsg_type != RTM_GETACTION) && !capable(CAP_NET_ADMIN)) |
2683 |
++ if ((n->nlmsg_type != RTM_GETACTION) && !netlink_capable(skb, CAP_NET_ADMIN)) |
2684 |
+ return -EPERM; |
2685 |
+ |
2686 |
+ ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL); |
2687 |
+diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c |
2688 |
+index 29a30a14c315..bdbdb1a7920a 100644 |
2689 |
+--- a/net/sched/cls_api.c |
2690 |
++++ b/net/sched/cls_api.c |
2691 |
+@@ -134,7 +134,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n) |
2692 |
+ int err; |
2693 |
+ int tp_created = 0; |
2694 |
+ |
2695 |
+- if ((n->nlmsg_type != RTM_GETTFILTER) && !capable(CAP_NET_ADMIN)) |
2696 |
++ if ((n->nlmsg_type != RTM_GETTFILTER) && !netlink_capable(skb, CAP_NET_ADMIN)) |
2697 |
+ return -EPERM; |
2698 |
+ |
2699 |
+ replay: |
2700 |
+diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c |
2701 |
+index a07d55e75698..98532cfa7823 100644 |
2702 |
+--- a/net/sched/sch_api.c |
2703 |
++++ b/net/sched/sch_api.c |
2704 |
+@@ -1084,7 +1084,7 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n) |
2705 |
+ struct Qdisc *p = NULL; |
2706 |
+ int err; |
2707 |
+ |
2708 |
+- if ((n->nlmsg_type != RTM_GETQDISC) && !capable(CAP_NET_ADMIN)) |
2709 |
++ if ((n->nlmsg_type != RTM_GETQDISC) && !netlink_capable(skb, CAP_NET_ADMIN)) |
2710 |
+ return -EPERM; |
2711 |
+ |
2712 |
+ err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL); |
2713 |
+@@ -1151,7 +1151,7 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n) |
2714 |
+ struct Qdisc *q, *p; |
2715 |
+ int err; |
2716 |
+ |
2717 |
+- if (!capable(CAP_NET_ADMIN)) |
2718 |
++ if (!netlink_capable(skb, CAP_NET_ADMIN)) |
2719 |
+ return -EPERM; |
2720 |
+ |
2721 |
+ replay: |
2722 |
+@@ -1491,7 +1491,7 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n) |
2723 |
+ u32 qid; |
2724 |
+ int err; |
2725 |
+ |
2726 |
+- if ((n->nlmsg_type != RTM_GETTCLASS) && !capable(CAP_NET_ADMIN)) |
2727 |
++ if ((n->nlmsg_type != RTM_GETTCLASS) && !netlink_capable(skb, CAP_NET_ADMIN)) |
2728 |
+ return -EPERM; |
2729 |
+ |
2730 |
+ err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL); |
2731 |
+diff --git a/net/sctp/associola.c b/net/sctp/associola.c |
2732 |
+index 878e17aafbe5..a4d570126f5d 100644 |
2733 |
+--- a/net/sctp/associola.c |
2734 |
++++ b/net/sctp/associola.c |
2735 |
+@@ -330,7 +330,7 @@ void sctp_association_free(struct sctp_association *asoc) |
2736 |
+ /* Only real associations count against the endpoint, so |
2737 |
+ * don't bother for if this is a temporary association. |
2738 |
+ */ |
2739 |
+- if (!asoc->temp) { |
2740 |
++ if (!list_empty(&asoc->asocs)) { |
2741 |
+ list_del(&asoc->asocs); |
2742 |
+ |
2743 |
+ /* Decrement the backlog value for a TCP-style listening |
2744 |
+diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c |
2745 |
+index 3aaf73de9e2d..ad844d365340 100644 |
2746 |
+--- a/net/tipc/netlink.c |
2747 |
++++ b/net/tipc/netlink.c |
2748 |
+@@ -47,7 +47,7 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info) |
2749 |
+ int hdr_space = nlmsg_total_size(GENL_HDRLEN + TIPC_GENL_HDRLEN); |
2750 |
+ u16 cmd; |
2751 |
+ |
2752 |
+- if ((req_userhdr->cmd & 0xC000) && (!capable(CAP_NET_ADMIN))) |
2753 |
++ if ((req_userhdr->cmd & 0xC000) && (!netlink_capable(skb, CAP_NET_ADMIN))) |
2754 |
+ cmd = TIPC_CMD_NOT_NET_ADMIN; |
2755 |
+ else |
2756 |
+ cmd = req_userhdr->cmd; |
2757 |
+diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c |
2758 |
+index 2f7ddc3a59b4..b10d04fa3933 100644 |
2759 |
+--- a/net/xfrm/xfrm_user.c |
2760 |
++++ b/net/xfrm/xfrm_user.c |
2761 |
+@@ -2350,7 +2350,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
2762 |
+ link = &xfrm_dispatch[type]; |
2763 |
+ |
2764 |
+ /* All operations require privileges, even GET */ |
2765 |
+- if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) |
2766 |
++ if (!netlink_net_capable(skb, CAP_NET_ADMIN)) |
2767 |
+ return -EPERM; |
2768 |
+ |
2769 |
+ if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) || |
2770 |
+diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c |
2771 |
+index 336b3ddfe63f..3c5cbb977254 100644 |
2772 |
+--- a/security/integrity/evm/evm_main.c |
2773 |
++++ b/security/integrity/evm/evm_main.c |
2774 |
+@@ -285,12 +285,20 @@ out: |
2775 |
+ * @xattr_value: pointer to the new extended attribute value |
2776 |
+ * @xattr_value_len: pointer to the new extended attribute value length |
2777 |
+ * |
2778 |
+- * Updating 'security.evm' requires CAP_SYS_ADMIN privileges and that |
2779 |
+- * the current value is valid. |
2780 |
++ * Before allowing the 'security.evm' protected xattr to be updated, |
2781 |
++ * verify the existing value is valid. As only the kernel should have |
2782 |
++ * access to the EVM encrypted key needed to calculate the HMAC, prevent |
2783 |
++ * userspace from writing HMAC value. Writing 'security.evm' requires |
2784 |
++ * requires CAP_SYS_ADMIN privileges. |
2785 |
+ */ |
2786 |
+ int evm_inode_setxattr(struct dentry *dentry, const char *xattr_name, |
2787 |
+ const void *xattr_value, size_t xattr_value_len) |
2788 |
+ { |
2789 |
++ const struct evm_ima_xattr_data *xattr_data = xattr_value; |
2790 |
++ |
2791 |
++ if ((strcmp(xattr_name, XATTR_NAME_EVM) == 0) |
2792 |
++ && (xattr_data->type == EVM_XATTR_HMAC)) |
2793 |
++ return -EPERM; |
2794 |
+ return evm_protect_xattr(dentry, xattr_name, xattr_value, |
2795 |
+ xattr_value_len); |
2796 |
+ } |
2797 |
+diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c |
2798 |
+index c38bbce8c6a6..025824af08e0 100644 |
2799 |
+--- a/security/integrity/ima/ima_api.c |
2800 |
++++ b/security/integrity/ima/ima_api.c |
2801 |
+@@ -199,6 +199,7 @@ int ima_collect_measurement(struct integrity_iint_cache *iint, |
2802 |
+ struct evm_ima_xattr_data **xattr_value, |
2803 |
+ int *xattr_len) |
2804 |
+ { |
2805 |
++ const char *audit_cause = "failed"; |
2806 |
+ struct inode *inode = file_inode(file); |
2807 |
+ const char *filename = file->f_dentry->d_name.name; |
2808 |
+ int result = 0; |
2809 |
+@@ -213,6 +214,12 @@ int ima_collect_measurement(struct integrity_iint_cache *iint, |
2810 |
+ if (!(iint->flags & IMA_COLLECTED)) { |
2811 |
+ u64 i_version = file_inode(file)->i_version; |
2812 |
+ |
2813 |
++ if (file->f_flags & O_DIRECT) { |
2814 |
++ audit_cause = "failed(directio)"; |
2815 |
++ result = -EACCES; |
2816 |
++ goto out; |
2817 |
++ } |
2818 |
++ |
2819 |
+ /* use default hash algorithm */ |
2820 |
+ hash.hdr.algo = ima_hash_algo; |
2821 |
+ |
2822 |
+@@ -233,9 +240,10 @@ int ima_collect_measurement(struct integrity_iint_cache *iint, |
2823 |
+ result = -ENOMEM; |
2824 |
+ } |
2825 |
+ } |
2826 |
++out: |
2827 |
+ if (result) |
2828 |
+ integrity_audit_msg(AUDIT_INTEGRITY_DATA, inode, |
2829 |
+- filename, "collect_data", "failed", |
2830 |
++ filename, "collect_data", audit_cause, |
2831 |
+ result, 0); |
2832 |
+ return result; |
2833 |
+ } |
2834 |
+diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c |
2835 |
+index fdf60def52e9..b5c126fe0bd9 100644 |
2836 |
+--- a/security/integrity/ima/ima_crypto.c |
2837 |
++++ b/security/integrity/ima/ima_crypto.c |
2838 |
+@@ -25,6 +25,36 @@ |
2839 |
+ |
2840 |
+ static struct crypto_shash *ima_shash_tfm; |
2841 |
+ |
2842 |
++/** |
2843 |
++ * ima_kernel_read - read file content |
2844 |
++ * |
2845 |
++ * This is a function for reading file content instead of kernel_read(). |
2846 |
++ * It does not perform locking checks to ensure it cannot be blocked. |
2847 |
++ * It does not perform security checks because it is irrelevant for IMA. |
2848 |
++ * |
2849 |
++ */ |
2850 |
++static int ima_kernel_read(struct file *file, loff_t offset, |
2851 |
++ char *addr, unsigned long count) |
2852 |
++{ |
2853 |
++ mm_segment_t old_fs; |
2854 |
++ char __user *buf = addr; |
2855 |
++ ssize_t ret; |
2856 |
++ |
2857 |
++ if (!(file->f_mode & FMODE_READ)) |
2858 |
++ return -EBADF; |
2859 |
++ if (!file->f_op->read && !file->f_op->aio_read) |
2860 |
++ return -EINVAL; |
2861 |
++ |
2862 |
++ old_fs = get_fs(); |
2863 |
++ set_fs(get_ds()); |
2864 |
++ if (file->f_op->read) |
2865 |
++ ret = file->f_op->read(file, buf, count, &offset); |
2866 |
++ else |
2867 |
++ ret = do_sync_read(file, buf, count, &offset); |
2868 |
++ set_fs(old_fs); |
2869 |
++ return ret; |
2870 |
++} |
2871 |
++ |
2872 |
+ int ima_init_crypto(void) |
2873 |
+ { |
2874 |
+ long rc; |
2875 |
+@@ -98,7 +128,7 @@ static int ima_calc_file_hash_tfm(struct file *file, |
2876 |
+ while (offset < i_size) { |
2877 |
+ int rbuf_len; |
2878 |
+ |
2879 |
+- rbuf_len = kernel_read(file, offset, rbuf, PAGE_SIZE); |
2880 |
++ rbuf_len = ima_kernel_read(file, offset, rbuf, PAGE_SIZE); |
2881 |
+ if (rbuf_len < 0) { |
2882 |
+ rc = rbuf_len; |
2883 |
+ break; |
2884 |
+diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c |
2885 |
+index 149ee1119f87..76d8aad146a8 100644 |
2886 |
+--- a/security/integrity/ima/ima_main.c |
2887 |
++++ b/security/integrity/ima/ima_main.c |
2888 |
+@@ -217,8 +217,11 @@ static int process_measurement(struct file *file, const char *filename, |
2889 |
+ xattr_ptr = &xattr_value; |
2890 |
+ |
2891 |
+ rc = ima_collect_measurement(iint, file, xattr_ptr, &xattr_len); |
2892 |
+- if (rc != 0) |
2893 |
++ if (rc != 0) { |
2894 |
++ if (file->f_flags & O_DIRECT) |
2895 |
++ rc = (iint->flags & IMA_PERMIT_DIRECTIO) ? 0 : -EACCES; |
2896 |
+ goto out_digsig; |
2897 |
++ } |
2898 |
+ |
2899 |
+ pathname = !filename ? ima_d_path(&file->f_path, &pathbuf) : filename; |
2900 |
+ if (!pathname) |
2901 |
+diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c |
2902 |
+index a9c3d3cd1990..085c4964be99 100644 |
2903 |
+--- a/security/integrity/ima/ima_policy.c |
2904 |
++++ b/security/integrity/ima/ima_policy.c |
2905 |
+@@ -351,7 +351,7 @@ enum { |
2906 |
+ Opt_obj_user, Opt_obj_role, Opt_obj_type, |
2907 |
+ Opt_subj_user, Opt_subj_role, Opt_subj_type, |
2908 |
+ Opt_func, Opt_mask, Opt_fsmagic, Opt_uid, Opt_fowner, |
2909 |
+- Opt_appraise_type, Opt_fsuuid |
2910 |
++ Opt_appraise_type, Opt_fsuuid, Opt_permit_directio |
2911 |
+ }; |
2912 |
+ |
2913 |
+ static match_table_t policy_tokens = { |
2914 |
+@@ -373,6 +373,7 @@ static match_table_t policy_tokens = { |
2915 |
+ {Opt_uid, "uid=%s"}, |
2916 |
+ {Opt_fowner, "fowner=%s"}, |
2917 |
+ {Opt_appraise_type, "appraise_type=%s"}, |
2918 |
++ {Opt_permit_directio, "permit_directio"}, |
2919 |
+ {Opt_err, NULL} |
2920 |
+ }; |
2921 |
+ |
2922 |
+@@ -621,6 +622,9 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry) |
2923 |
+ else |
2924 |
+ result = -EINVAL; |
2925 |
+ break; |
2926 |
++ case Opt_permit_directio: |
2927 |
++ entry->flags |= IMA_PERMIT_DIRECTIO; |
2928 |
++ break; |
2929 |
+ case Opt_err: |
2930 |
+ ima_log_string(ab, "UNKNOWN", p); |
2931 |
+ result = -EINVAL; |
2932 |
+diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h |
2933 |
+index 2fb5e53e927f..33c0a70f6b15 100644 |
2934 |
+--- a/security/integrity/integrity.h |
2935 |
++++ b/security/integrity/integrity.h |
2936 |
+@@ -30,6 +30,7 @@ |
2937 |
+ #define IMA_ACTION_FLAGS 0xff000000 |
2938 |
+ #define IMA_DIGSIG 0x01000000 |
2939 |
+ #define IMA_DIGSIG_REQUIRED 0x02000000 |
2940 |
++#define IMA_PERMIT_DIRECTIO 0x04000000 |
2941 |
+ |
2942 |
+ #define IMA_DO_MASK (IMA_MEASURE | IMA_APPRAISE | IMA_AUDIT | \ |
2943 |
+ IMA_APPRAISE_SUBMASK) |
2944 |
+diff --git a/sound/core/control.c b/sound/core/control.c |
2945 |
+index d8aa206e8bde..98a29b26c5f4 100644 |
2946 |
+--- a/sound/core/control.c |
2947 |
++++ b/sound/core/control.c |
2948 |
+@@ -289,6 +289,10 @@ static bool snd_ctl_remove_numid_conflict(struct snd_card *card, |
2949 |
+ { |
2950 |
+ struct snd_kcontrol *kctl; |
2951 |
+ |
2952 |
++ /* Make sure that the ids assigned to the control do not wrap around */ |
2953 |
++ if (card->last_numid >= UINT_MAX - count) |
2954 |
++ card->last_numid = 0; |
2955 |
++ |
2956 |
+ list_for_each_entry(kctl, &card->controls, list) { |
2957 |
+ if (kctl->id.numid < card->last_numid + 1 + count && |
2958 |
+ kctl->id.numid + kctl->count > card->last_numid + 1) { |
2959 |
+@@ -331,6 +335,7 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) |
2960 |
+ { |
2961 |
+ struct snd_ctl_elem_id id; |
2962 |
+ unsigned int idx; |
2963 |
++ unsigned int count; |
2964 |
+ int err = -EINVAL; |
2965 |
+ |
2966 |
+ if (! kcontrol) |
2967 |
+@@ -338,6 +343,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) |
2968 |
+ if (snd_BUG_ON(!card || !kcontrol->info)) |
2969 |
+ goto error; |
2970 |
+ id = kcontrol->id; |
2971 |
++ if (id.index > UINT_MAX - kcontrol->count) |
2972 |
++ goto error; |
2973 |
++ |
2974 |
+ down_write(&card->controls_rwsem); |
2975 |
+ if (snd_ctl_find_id(card, &id)) { |
2976 |
+ up_write(&card->controls_rwsem); |
2977 |
+@@ -359,8 +367,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) |
2978 |
+ card->controls_count += kcontrol->count; |
2979 |
+ kcontrol->id.numid = card->last_numid + 1; |
2980 |
+ card->last_numid += kcontrol->count; |
2981 |
++ count = kcontrol->count; |
2982 |
+ up_write(&card->controls_rwsem); |
2983 |
+- for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++) |
2984 |
++ for (idx = 0; idx < count; idx++, id.index++, id.numid++) |
2985 |
+ snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id); |
2986 |
+ return 0; |
2987 |
+ |
2988 |
+@@ -389,6 +398,7 @@ int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, |
2989 |
+ bool add_on_replace) |
2990 |
+ { |
2991 |
+ struct snd_ctl_elem_id id; |
2992 |
++ unsigned int count; |
2993 |
+ unsigned int idx; |
2994 |
+ struct snd_kcontrol *old; |
2995 |
+ int ret; |
2996 |
+@@ -424,8 +434,9 @@ add: |
2997 |
+ card->controls_count += kcontrol->count; |
2998 |
+ kcontrol->id.numid = card->last_numid + 1; |
2999 |
+ card->last_numid += kcontrol->count; |
3000 |
++ count = kcontrol->count; |
3001 |
+ up_write(&card->controls_rwsem); |
3002 |
+- for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++) |
3003 |
++ for (idx = 0; idx < count; idx++, id.index++, id.numid++) |
3004 |
+ snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id); |
3005 |
+ return 0; |
3006 |
+ |
3007 |
+@@ -898,9 +909,9 @@ static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, |
3008 |
+ result = kctl->put(kctl, control); |
3009 |
+ } |
3010 |
+ if (result > 0) { |
3011 |
++ struct snd_ctl_elem_id id = control->id; |
3012 |
+ up_read(&card->controls_rwsem); |
3013 |
+- snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, |
3014 |
+- &control->id); |
3015 |
++ snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &id); |
3016 |
+ return 0; |
3017 |
+ } |
3018 |
+ } |
3019 |
+@@ -992,6 +1003,7 @@ static int snd_ctl_elem_unlock(struct snd_ctl_file *file, |
3020 |
+ |
3021 |
+ struct user_element { |
3022 |
+ struct snd_ctl_elem_info info; |
3023 |
++ struct snd_card *card; |
3024 |
+ void *elem_data; /* element data */ |
3025 |
+ unsigned long elem_data_size; /* size of element data in bytes */ |
3026 |
+ void *tlv_data; /* TLV data */ |
3027 |
+@@ -1035,7 +1047,9 @@ static int snd_ctl_elem_user_get(struct snd_kcontrol *kcontrol, |
3028 |
+ { |
3029 |
+ struct user_element *ue = kcontrol->private_data; |
3030 |
+ |
3031 |
++ mutex_lock(&ue->card->user_ctl_lock); |
3032 |
+ memcpy(&ucontrol->value, ue->elem_data, ue->elem_data_size); |
3033 |
++ mutex_unlock(&ue->card->user_ctl_lock); |
3034 |
+ return 0; |
3035 |
+ } |
3036 |
+ |
3037 |
+@@ -1044,10 +1058,12 @@ static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol, |
3038 |
+ { |
3039 |
+ int change; |
3040 |
+ struct user_element *ue = kcontrol->private_data; |
3041 |
+- |
3042 |
++ |
3043 |
++ mutex_lock(&ue->card->user_ctl_lock); |
3044 |
+ change = memcmp(&ucontrol->value, ue->elem_data, ue->elem_data_size) != 0; |
3045 |
+ if (change) |
3046 |
+ memcpy(ue->elem_data, &ucontrol->value, ue->elem_data_size); |
3047 |
++ mutex_unlock(&ue->card->user_ctl_lock); |
3048 |
+ return change; |
3049 |
+ } |
3050 |
+ |
3051 |
+@@ -1067,19 +1083,32 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol, |
3052 |
+ new_data = memdup_user(tlv, size); |
3053 |
+ if (IS_ERR(new_data)) |
3054 |
+ return PTR_ERR(new_data); |
3055 |
++ mutex_lock(&ue->card->user_ctl_lock); |
3056 |
+ change = ue->tlv_data_size != size; |
3057 |
+ if (!change) |
3058 |
+ change = memcmp(ue->tlv_data, new_data, size); |
3059 |
+ kfree(ue->tlv_data); |
3060 |
+ ue->tlv_data = new_data; |
3061 |
+ ue->tlv_data_size = size; |
3062 |
++ mutex_unlock(&ue->card->user_ctl_lock); |
3063 |
+ } else { |
3064 |
+- if (! ue->tlv_data_size || ! ue->tlv_data) |
3065 |
+- return -ENXIO; |
3066 |
+- if (size < ue->tlv_data_size) |
3067 |
+- return -ENOSPC; |
3068 |
++ int ret = 0; |
3069 |
++ |
3070 |
++ mutex_lock(&ue->card->user_ctl_lock); |
3071 |
++ if (!ue->tlv_data_size || !ue->tlv_data) { |
3072 |
++ ret = -ENXIO; |
3073 |
++ goto err_unlock; |
3074 |
++ } |
3075 |
++ if (size < ue->tlv_data_size) { |
3076 |
++ ret = -ENOSPC; |
3077 |
++ goto err_unlock; |
3078 |
++ } |
3079 |
+ if (copy_to_user(tlv, ue->tlv_data, ue->tlv_data_size)) |
3080 |
+- return -EFAULT; |
3081 |
++ ret = -EFAULT; |
3082 |
++err_unlock: |
3083 |
++ mutex_unlock(&ue->card->user_ctl_lock); |
3084 |
++ if (ret) |
3085 |
++ return ret; |
3086 |
+ } |
3087 |
+ return change; |
3088 |
+ } |
3089 |
+@@ -1137,8 +1166,6 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, |
3090 |
+ struct user_element *ue; |
3091 |
+ int idx, err; |
3092 |
+ |
3093 |
+- if (!replace && card->user_ctl_count >= MAX_USER_CONTROLS) |
3094 |
+- return -ENOMEM; |
3095 |
+ if (info->count < 1) |
3096 |
+ return -EINVAL; |
3097 |
+ access = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : |
3098 |
+@@ -1147,21 +1174,16 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, |
3099 |
+ SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE)); |
3100 |
+ info->id.numid = 0; |
3101 |
+ memset(&kctl, 0, sizeof(kctl)); |
3102 |
+- down_write(&card->controls_rwsem); |
3103 |
+- _kctl = snd_ctl_find_id(card, &info->id); |
3104 |
+- err = 0; |
3105 |
+- if (_kctl) { |
3106 |
+- if (replace) |
3107 |
+- err = snd_ctl_remove(card, _kctl); |
3108 |
+- else |
3109 |
+- err = -EBUSY; |
3110 |
+- } else { |
3111 |
+- if (replace) |
3112 |
+- err = -ENOENT; |
3113 |
++ |
3114 |
++ if (replace) { |
3115 |
++ err = snd_ctl_remove_user_ctl(file, &info->id); |
3116 |
++ if (err) |
3117 |
++ return err; |
3118 |
+ } |
3119 |
+- up_write(&card->controls_rwsem); |
3120 |
+- if (err < 0) |
3121 |
+- return err; |
3122 |
++ |
3123 |
++ if (card->user_ctl_count >= MAX_USER_CONTROLS) |
3124 |
++ return -ENOMEM; |
3125 |
++ |
3126 |
+ memcpy(&kctl.id, &info->id, sizeof(info->id)); |
3127 |
+ kctl.count = info->owner ? info->owner : 1; |
3128 |
+ access |= SNDRV_CTL_ELEM_ACCESS_USER; |
3129 |
+@@ -1211,6 +1233,7 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, |
3130 |
+ ue = kzalloc(sizeof(struct user_element) + private_size, GFP_KERNEL); |
3131 |
+ if (ue == NULL) |
3132 |
+ return -ENOMEM; |
3133 |
++ ue->card = card; |
3134 |
+ ue->info = *info; |
3135 |
+ ue->info.access = 0; |
3136 |
+ ue->elem_data = (char *)ue + sizeof(*ue); |
3137 |
+@@ -1322,8 +1345,9 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file, |
3138 |
+ } |
3139 |
+ err = kctl->tlv.c(kctl, op_flag, tlv.length, _tlv->tlv); |
3140 |
+ if (err > 0) { |
3141 |
++ struct snd_ctl_elem_id id = kctl->id; |
3142 |
+ up_read(&card->controls_rwsem); |
3143 |
+- snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &kctl->id); |
3144 |
++ snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &id); |
3145 |
+ return 0; |
3146 |
+ } |
3147 |
+ } else { |
3148 |
+diff --git a/sound/core/init.c b/sound/core/init.c |
3149 |
+index 0d42fcda0de2..39c25167add8 100644 |
3150 |
+--- a/sound/core/init.c |
3151 |
++++ b/sound/core/init.c |
3152 |
+@@ -218,6 +218,7 @@ int snd_card_create(int idx, const char *xid, |
3153 |
+ INIT_LIST_HEAD(&card->devices); |
3154 |
+ init_rwsem(&card->controls_rwsem); |
3155 |
+ rwlock_init(&card->ctl_files_rwlock); |
3156 |
++ mutex_init(&card->user_ctl_lock); |
3157 |
+ INIT_LIST_HEAD(&card->controls); |
3158 |
+ INIT_LIST_HEAD(&card->ctl_files); |
3159 |
+ spin_lock_init(&card->files_lock); |
3160 |
+diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c |
3161 |
+index 0b6ee2b37bdb..2a16a90fd952 100644 |
3162 |
+--- a/sound/pci/hda/patch_realtek.c |
3163 |
++++ b/sound/pci/hda/patch_realtek.c |
3164 |
+@@ -3932,6 +3932,7 @@ enum { |
3165 |
+ ALC269_FIXUP_HEADSET_MIC, |
3166 |
+ ALC269_FIXUP_QUANTA_MUTE, |
3167 |
+ ALC269_FIXUP_LIFEBOOK, |
3168 |
++ ALC269_FIXUP_LIFEBOOK_EXTMIC, |
3169 |
+ ALC269_FIXUP_AMIC, |
3170 |
+ ALC269_FIXUP_DMIC, |
3171 |
+ ALC269VB_FIXUP_AMIC, |
3172 |
+@@ -4059,6 +4060,13 @@ static const struct hda_fixup alc269_fixups[] = { |
3173 |
+ .chained = true, |
3174 |
+ .chain_id = ALC269_FIXUP_QUANTA_MUTE |
3175 |
+ }, |
3176 |
++ [ALC269_FIXUP_LIFEBOOK_EXTMIC] = { |
3177 |
++ .type = HDA_FIXUP_PINS, |
3178 |
++ .v.pins = (const struct hda_pintbl[]) { |
3179 |
++ { 0x19, 0x01a1903c }, /* headset mic, with jack detect */ |
3180 |
++ { } |
3181 |
++ }, |
3182 |
++ }, |
3183 |
+ [ALC269_FIXUP_AMIC] = { |
3184 |
+ .type = HDA_FIXUP_PINS, |
3185 |
+ .v.pins = (const struct hda_pintbl[]) { |
3186 |
+@@ -4427,14 +4435,24 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
3187 |
+ SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3188 |
+ SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED), |
3189 |
+ /* ALC282 */ |
3190 |
++ SND_PCI_QUIRK(0x103c, 0x220d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3191 |
++ SND_PCI_QUIRK(0x103c, 0x220e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3192 |
+ SND_PCI_QUIRK(0x103c, 0x220f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3193 |
++ SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3194 |
++ SND_PCI_QUIRK(0x103c, 0x2211, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3195 |
++ SND_PCI_QUIRK(0x103c, 0x2212, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3196 |
+ SND_PCI_QUIRK(0x103c, 0x2213, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3197 |
++ SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3198 |
+ SND_PCI_QUIRK(0x103c, 0x2266, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3199 |
+ SND_PCI_QUIRK(0x103c, 0x2267, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3200 |
+ SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3201 |
+ SND_PCI_QUIRK(0x103c, 0x2269, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3202 |
+ SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3203 |
+ SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3204 |
++ SND_PCI_QUIRK(0x103c, 0x226c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3205 |
++ SND_PCI_QUIRK(0x103c, 0x226d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3206 |
++ SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3207 |
++ SND_PCI_QUIRK(0x103c, 0x226f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3208 |
+ SND_PCI_QUIRK(0x103c, 0x227a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3209 |
+ SND_PCI_QUIRK(0x103c, 0x227b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3210 |
+ SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3211 |
+@@ -4474,6 +4492,10 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
3212 |
+ SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3213 |
+ SND_PCI_QUIRK(0x103c, 0x22c3, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3214 |
+ SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3215 |
++ SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3216 |
++ SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3217 |
++ SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3218 |
++ SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3219 |
+ SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED), |
3220 |
+ SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), |
3221 |
+ SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), |
3222 |
+@@ -4496,6 +4518,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
3223 |
+ SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
3224 |
+ SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
3225 |
+ SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
3226 |
++ SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), |
3227 |
+ SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
3228 |
+ SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
3229 |
+ SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
3230 |
+@@ -5536,6 +5559,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
3231 |
+ { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
3232 |
+ { .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 }, |
3233 |
+ { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
3234 |
++ { .id = 0x10ec0867, .name = "ALC891", .patch = patch_alc882 }, |
3235 |
+ { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
3236 |
+ { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
3237 |
+ { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
3238 |
+diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c |
3239 |
+index 9f714ea86613..b3f7c9026a29 100644 |
3240 |
+--- a/sound/soc/codecs/max98090.c |
3241 |
++++ b/sound/soc/codecs/max98090.c |
3242 |
+@@ -255,6 +255,7 @@ static struct reg_default max98090_reg[] = { |
3243 |
+ static bool max98090_volatile_register(struct device *dev, unsigned int reg) |
3244 |
+ { |
3245 |
+ switch (reg) { |
3246 |
++ case M98090_REG_SOFTWARE_RESET: |
3247 |
+ case M98090_REG_DEVICE_STATUS: |
3248 |
+ case M98090_REG_JACK_STATUS: |
3249 |
+ case M98090_REG_REVISION_ID: |
3250 |
+@@ -2360,6 +2361,8 @@ static int max98090_runtime_resume(struct device *dev) |
3251 |
+ |
3252 |
+ regcache_cache_only(max98090->regmap, false); |
3253 |
+ |
3254 |
++ max98090_reset(max98090); |
3255 |
++ |
3256 |
+ regcache_sync(max98090->regmap); |
3257 |
+ |
3258 |
+ return 0; |
3259 |
+diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c |
3260 |
+index 470fbfb4b386..eb241c6571a9 100644 |
3261 |
+--- a/sound/soc/codecs/tlv320aic3x.c |
3262 |
++++ b/sound/soc/codecs/tlv320aic3x.c |
3263 |
+@@ -169,7 +169,7 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, |
3264 |
+ mask <<= shift; |
3265 |
+ val <<= shift; |
3266 |
+ |
3267 |
+- change = snd_soc_test_bits(codec, val, mask, reg); |
3268 |
++ change = snd_soc_test_bits(codec, reg, mask, val); |
3269 |
+ if (change) { |
3270 |
+ update.kcontrol = kcontrol; |
3271 |
+ update.reg = reg; |
3272 |
+diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c |
3273 |
+index c1369c3ad643..731d47b64daa 100644 |
3274 |
+--- a/sound/soc/soc-dapm.c |
3275 |
++++ b/sound/soc/soc-dapm.c |
3276 |
+@@ -2888,22 +2888,19 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, |
3277 |
+ mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); |
3278 |
+ |
3279 |
+ change = dapm_kcontrol_set_value(kcontrol, val); |
3280 |
+- |
3281 |
+- if (reg != SND_SOC_NOPM) { |
3282 |
+- mask = mask << shift; |
3283 |
+- val = val << shift; |
3284 |
+- |
3285 |
+- change = snd_soc_test_bits(codec, reg, mask, val); |
3286 |
+- } |
3287 |
+- |
3288 |
+ if (change) { |
3289 |
+ if (reg != SND_SOC_NOPM) { |
3290 |
+- update.kcontrol = kcontrol; |
3291 |
+- update.reg = reg; |
3292 |
+- update.mask = mask; |
3293 |
+- update.val = val; |
3294 |
++ mask = mask << shift; |
3295 |
++ val = val << shift; |
3296 |
++ |
3297 |
++ if (snd_soc_test_bits(codec, reg, mask, val)) { |
3298 |
++ update.kcontrol = kcontrol; |
3299 |
++ update.reg = reg; |
3300 |
++ update.mask = mask; |
3301 |
++ update.val = val; |
3302 |
++ card->update = &update; |
3303 |
++ } |
3304 |
+ |
3305 |
+- card->update = &update; |
3306 |
+ } |
3307 |
+ |
3308 |
+ ret = soc_dapm_mixer_update_power(card, kcontrol, connect); |