Contents of /trunk/kernel-alx/patches-4.9/0125-4.9.26-all-fixes.patch
Parent Directory | Revision Log
Revision 2956 -
(show annotations)
(download)
Mon Jul 24 12:03:46 2017 UTC (7 years, 2 months ago) by niro
File size: 57956 byte(s)
Mon Jul 24 12:03:46 2017 UTC (7 years, 2 months ago) by niro
File size: 57956 byte(s)
-added patches-4.9
1 | diff --git a/Makefile b/Makefile |
2 | index 8e18c63388c4..c09679c1a70d 100644 |
3 | --- a/Makefile |
4 | +++ b/Makefile |
5 | @@ -1,6 +1,6 @@ |
6 | VERSION = 4 |
7 | PATCHLEVEL = 9 |
8 | -SUBLEVEL = 25 |
9 | +SUBLEVEL = 26 |
10 | EXTRAVERSION = |
11 | NAME = Roaring Lionus |
12 | |
13 | diff --git a/arch/arc/include/asm/atomic.h b/arch/arc/include/asm/atomic.h |
14 | index b65930a49589..54b54da6384c 100644 |
15 | --- a/arch/arc/include/asm/atomic.h |
16 | +++ b/arch/arc/include/asm/atomic.h |
17 | @@ -17,10 +17,11 @@ |
18 | #include <asm/barrier.h> |
19 | #include <asm/smp.h> |
20 | |
21 | +#define ATOMIC_INIT(i) { (i) } |
22 | + |
23 | #ifndef CONFIG_ARC_PLAT_EZNPS |
24 | |
25 | #define atomic_read(v) READ_ONCE((v)->counter) |
26 | -#define ATOMIC_INIT(i) { (i) } |
27 | |
28 | #ifdef CONFIG_ARC_HAS_LLSC |
29 | |
30 | diff --git a/arch/arc/include/asm/entry-arcv2.h b/arch/arc/include/asm/entry-arcv2.h |
31 | index b5ff87e6f4b7..aee1a77934cf 100644 |
32 | --- a/arch/arc/include/asm/entry-arcv2.h |
33 | +++ b/arch/arc/include/asm/entry-arcv2.h |
34 | @@ -16,6 +16,7 @@ |
35 | ; |
36 | ; Now manually save: r12, sp, fp, gp, r25 |
37 | |
38 | + PUSH r30 |
39 | PUSH r12 |
40 | |
41 | ; Saving pt_regs->sp correctly requires some extra work due to the way |
42 | @@ -72,6 +73,7 @@ |
43 | POPAX AUX_USER_SP |
44 | 1: |
45 | POP r12 |
46 | + POP r30 |
47 | |
48 | .endm |
49 | |
50 | diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h |
51 | index 69095da1fcfd..47111d565a95 100644 |
52 | --- a/arch/arc/include/asm/ptrace.h |
53 | +++ b/arch/arc/include/asm/ptrace.h |
54 | @@ -84,7 +84,7 @@ struct pt_regs { |
55 | unsigned long fp; |
56 | unsigned long sp; /* user/kernel sp depending on where we came from */ |
57 | |
58 | - unsigned long r12; |
59 | + unsigned long r12, r30; |
60 | |
61 | /*------- Below list auto saved by h/w -----------*/ |
62 | unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11; |
63 | diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c |
64 | index 804d2a2a19fe..dd6a18bc10ab 100644 |
65 | --- a/arch/mips/kernel/cevt-r4k.c |
66 | +++ b/arch/mips/kernel/cevt-r4k.c |
67 | @@ -80,7 +80,7 @@ static unsigned int calculate_min_delta(void) |
68 | } |
69 | |
70 | /* Sorted insert of 75th percentile into buf2 */ |
71 | - for (k = 0; k < i; ++k) { |
72 | + for (k = 0; k < i && k < ARRAY_SIZE(buf2); ++k) { |
73 | if (buf1[ARRAY_SIZE(buf1) - 1] < buf2[k]) { |
74 | l = min_t(unsigned int, |
75 | i, ARRAY_SIZE(buf2) - 1); |
76 | diff --git a/arch/mips/kernel/elf.c b/arch/mips/kernel/elf.c |
77 | index 6430bff21fff..5c429d70e17f 100644 |
78 | --- a/arch/mips/kernel/elf.c |
79 | +++ b/arch/mips/kernel/elf.c |
80 | @@ -257,7 +257,7 @@ int arch_check_elf(void *_ehdr, bool has_interpreter, void *_interp_ehdr, |
81 | else if ((prog_req.fr1 && prog_req.frdefault) || |
82 | (prog_req.single && !prog_req.frdefault)) |
83 | /* Make sure 64-bit MIPS III/IV/64R1 will not pick FR1 */ |
84 | - state->overall_fp_mode = ((current_cpu_data.fpu_id & MIPS_FPIR_F64) && |
85 | + state->overall_fp_mode = ((raw_current_cpu_data.fpu_id & MIPS_FPIR_F64) && |
86 | cpu_has_mips_r2_r6) ? |
87 | FP_FR1 : FP_FR0; |
88 | else if (prog_req.fr1) |
89 | diff --git a/arch/mips/kernel/kgdb.c b/arch/mips/kernel/kgdb.c |
90 | index de63d36af895..732d6171ac6a 100644 |
91 | --- a/arch/mips/kernel/kgdb.c |
92 | +++ b/arch/mips/kernel/kgdb.c |
93 | @@ -244,9 +244,6 @@ static int compute_signal(int tt) |
94 | void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) |
95 | { |
96 | int reg; |
97 | - struct thread_info *ti = task_thread_info(p); |
98 | - unsigned long ksp = (unsigned long)ti + THREAD_SIZE - 32; |
99 | - struct pt_regs *regs = (struct pt_regs *)ksp - 1; |
100 | #if (KGDB_GDB_REG_SIZE == 32) |
101 | u32 *ptr = (u32 *)gdb_regs; |
102 | #else |
103 | @@ -254,25 +251,46 @@ void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) |
104 | #endif |
105 | |
106 | for (reg = 0; reg < 16; reg++) |
107 | - *(ptr++) = regs->regs[reg]; |
108 | + *(ptr++) = 0; |
109 | |
110 | /* S0 - S7 */ |
111 | - for (reg = 16; reg < 24; reg++) |
112 | - *(ptr++) = regs->regs[reg]; |
113 | + *(ptr++) = p->thread.reg16; |
114 | + *(ptr++) = p->thread.reg17; |
115 | + *(ptr++) = p->thread.reg18; |
116 | + *(ptr++) = p->thread.reg19; |
117 | + *(ptr++) = p->thread.reg20; |
118 | + *(ptr++) = p->thread.reg21; |
119 | + *(ptr++) = p->thread.reg22; |
120 | + *(ptr++) = p->thread.reg23; |
121 | |
122 | for (reg = 24; reg < 28; reg++) |
123 | *(ptr++) = 0; |
124 | |
125 | /* GP, SP, FP, RA */ |
126 | - for (reg = 28; reg < 32; reg++) |
127 | - *(ptr++) = regs->regs[reg]; |
128 | - |
129 | - *(ptr++) = regs->cp0_status; |
130 | - *(ptr++) = regs->lo; |
131 | - *(ptr++) = regs->hi; |
132 | - *(ptr++) = regs->cp0_badvaddr; |
133 | - *(ptr++) = regs->cp0_cause; |
134 | - *(ptr++) = regs->cp0_epc; |
135 | + *(ptr++) = (long)p; |
136 | + *(ptr++) = p->thread.reg29; |
137 | + *(ptr++) = p->thread.reg30; |
138 | + *(ptr++) = p->thread.reg31; |
139 | + |
140 | + *(ptr++) = p->thread.cp0_status; |
141 | + |
142 | + /* lo, hi */ |
143 | + *(ptr++) = 0; |
144 | + *(ptr++) = 0; |
145 | + |
146 | + /* |
147 | + * BadVAddr, Cause |
148 | + * Ideally these would come from the last exception frame up the stack |
149 | + * but that requires unwinding, otherwise we can't know much for sure. |
150 | + */ |
151 | + *(ptr++) = 0; |
152 | + *(ptr++) = 0; |
153 | + |
154 | + /* |
155 | + * PC |
156 | + * use return address (RA), i.e. the moment after return from resume() |
157 | + */ |
158 | + *(ptr++) = p->thread.reg31; |
159 | } |
160 | |
161 | void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) |
162 | diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h |
163 | index 1fb317fbc0b3..b6802b978140 100644 |
164 | --- a/arch/sparc/include/asm/pgtable_64.h |
165 | +++ b/arch/sparc/include/asm/pgtable_64.h |
166 | @@ -673,26 +673,27 @@ static inline unsigned long pmd_pfn(pmd_t pmd) |
167 | return pte_pfn(pte); |
168 | } |
169 | |
170 | -#ifdef CONFIG_TRANSPARENT_HUGEPAGE |
171 | -static inline unsigned long pmd_dirty(pmd_t pmd) |
172 | +#define __HAVE_ARCH_PMD_WRITE |
173 | +static inline unsigned long pmd_write(pmd_t pmd) |
174 | { |
175 | pte_t pte = __pte(pmd_val(pmd)); |
176 | |
177 | - return pte_dirty(pte); |
178 | + return pte_write(pte); |
179 | } |
180 | |
181 | -static inline unsigned long pmd_young(pmd_t pmd) |
182 | +#ifdef CONFIG_TRANSPARENT_HUGEPAGE |
183 | +static inline unsigned long pmd_dirty(pmd_t pmd) |
184 | { |
185 | pte_t pte = __pte(pmd_val(pmd)); |
186 | |
187 | - return pte_young(pte); |
188 | + return pte_dirty(pte); |
189 | } |
190 | |
191 | -static inline unsigned long pmd_write(pmd_t pmd) |
192 | +static inline unsigned long pmd_young(pmd_t pmd) |
193 | { |
194 | pte_t pte = __pte(pmd_val(pmd)); |
195 | |
196 | - return pte_write(pte); |
197 | + return pte_young(pte); |
198 | } |
199 | |
200 | static inline unsigned long pmd_trans_huge(pmd_t pmd) |
201 | diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c |
202 | index 37aa537b3ad8..bd7e2aa86c45 100644 |
203 | --- a/arch/sparc/mm/init_64.c |
204 | +++ b/arch/sparc/mm/init_64.c |
205 | @@ -1495,7 +1495,7 @@ bool kern_addr_valid(unsigned long addr) |
206 | if ((long)addr < 0L) { |
207 | unsigned long pa = __pa(addr); |
208 | |
209 | - if ((addr >> max_phys_bits) != 0UL) |
210 | + if ((pa >> max_phys_bits) != 0UL) |
211 | return false; |
212 | |
213 | return pfn_valid(pa >> PAGE_SHIFT); |
214 | diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c |
215 | index 8639bb2ae058..6bf09f5594b2 100644 |
216 | --- a/arch/x86/kernel/ftrace.c |
217 | +++ b/arch/x86/kernel/ftrace.c |
218 | @@ -983,6 +983,18 @@ void prepare_ftrace_return(unsigned long self_addr, unsigned long *parent, |
219 | unsigned long return_hooker = (unsigned long) |
220 | &return_to_handler; |
221 | |
222 | + /* |
223 | + * When resuming from suspend-to-ram, this function can be indirectly |
224 | + * called from early CPU startup code while the CPU is in real mode, |
225 | + * which would fail miserably. Make sure the stack pointer is a |
226 | + * virtual address. |
227 | + * |
228 | + * This check isn't as accurate as virt_addr_valid(), but it should be |
229 | + * good enough for this purpose, and it's fast. |
230 | + */ |
231 | + if (unlikely((long)__builtin_frame_address(0) >= 0)) |
232 | + return; |
233 | + |
234 | if (unlikely(ftrace_graph_is_dead())) |
235 | return; |
236 | |
237 | diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h |
238 | index 25eab453f2b2..e7b96f1ac2c5 100644 |
239 | --- a/drivers/input/serio/i8042-x86ia64io.h |
240 | +++ b/drivers/input/serio/i8042-x86ia64io.h |
241 | @@ -685,6 +685,13 @@ static const struct dmi_system_id __initconst i8042_dmi_reset_table[] = { |
242 | DMI_MATCH(DMI_PRODUCT_NAME, "20046"), |
243 | }, |
244 | }, |
245 | + { |
246 | + /* Clevo P650RS, 650RP6, Sager NP8152-S, and others */ |
247 | + .matches = { |
248 | + DMI_MATCH(DMI_SYS_VENDOR, "Notebook"), |
249 | + DMI_MATCH(DMI_PRODUCT_NAME, "P65xRP"), |
250 | + }, |
251 | + }, |
252 | { } |
253 | }; |
254 | |
255 | diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c |
256 | index 437e4807727d..90ed2e12d345 100644 |
257 | --- a/drivers/mmc/host/sdhci-msm.c |
258 | +++ b/drivers/mmc/host/sdhci-msm.c |
259 | @@ -524,9 +524,7 @@ static const struct sdhci_ops sdhci_msm_ops = { |
260 | static const struct sdhci_pltfm_data sdhci_msm_pdata = { |
261 | .quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION | |
262 | SDHCI_QUIRK_NO_CARD_NO_RESET | |
263 | - SDHCI_QUIRK_SINGLE_POWER_WRITE | |
264 | - SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, |
265 | - .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, |
266 | + SDHCI_QUIRK_SINGLE_POWER_WRITE, |
267 | .ops = &sdhci_msm_ops, |
268 | }; |
269 | |
270 | diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c |
271 | index a0dabd4038ba..7ab24c5262f3 100644 |
272 | --- a/drivers/net/can/usb/gs_usb.c |
273 | +++ b/drivers/net/can/usb/gs_usb.c |
274 | @@ -740,13 +740,18 @@ static const struct net_device_ops gs_usb_netdev_ops = { |
275 | static int gs_usb_set_identify(struct net_device *netdev, bool do_identify) |
276 | { |
277 | struct gs_can *dev = netdev_priv(netdev); |
278 | - struct gs_identify_mode imode; |
279 | + struct gs_identify_mode *imode; |
280 | int rc; |
281 | |
282 | + imode = kmalloc(sizeof(*imode), GFP_KERNEL); |
283 | + |
284 | + if (!imode) |
285 | + return -ENOMEM; |
286 | + |
287 | if (do_identify) |
288 | - imode.mode = GS_CAN_IDENTIFY_ON; |
289 | + imode->mode = GS_CAN_IDENTIFY_ON; |
290 | else |
291 | - imode.mode = GS_CAN_IDENTIFY_OFF; |
292 | + imode->mode = GS_CAN_IDENTIFY_OFF; |
293 | |
294 | rc = usb_control_msg(interface_to_usbdev(dev->iface), |
295 | usb_sndctrlpipe(interface_to_usbdev(dev->iface), |
296 | @@ -756,10 +761,12 @@ static int gs_usb_set_identify(struct net_device *netdev, bool do_identify) |
297 | USB_RECIP_INTERFACE, |
298 | dev->channel, |
299 | 0, |
300 | - &imode, |
301 | - sizeof(imode), |
302 | + imode, |
303 | + sizeof(*imode), |
304 | 100); |
305 | |
306 | + kfree(imode); |
307 | + |
308 | return (rc > 0) ? 0 : rc; |
309 | } |
310 | |
311 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h |
312 | index 81d8e3bd01b6..21ce0b701143 100644 |
313 | --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h |
314 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h |
315 | @@ -82,7 +82,7 @@ |
316 | #define MLX5E_VALID_NUM_MTTS(num_mtts) (MLX5_MTT_OCTW(num_mtts) <= U16_MAX) |
317 | |
318 | #define MLX5_UMR_ALIGN (2048) |
319 | -#define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (128) |
320 | +#define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (256) |
321 | |
322 | #define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ (64 * 1024) |
323 | #define MLX5E_DEFAULT_LRO_TIMEOUT 32 |
324 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c |
325 | index 90e81ae9f3bc..e034dbc4913d 100644 |
326 | --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c |
327 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c |
328 | @@ -563,6 +563,7 @@ int mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv, struct ethtool_rxnfc *i |
329 | int idx = 0; |
330 | int err = 0; |
331 | |
332 | + info->data = MAX_NUM_OF_ETHTOOL_RULES; |
333 | while ((!err || err == -ENOENT) && idx < info->rule_cnt) { |
334 | err = mlx5e_ethtool_get_flow(priv, info, location); |
335 | if (!err) |
336 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag.c |
337 | index 55957246c0e8..b5d5519542e8 100644 |
338 | --- a/drivers/net/ethernet/mellanox/mlx5/core/lag.c |
339 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag.c |
340 | @@ -294,7 +294,7 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev, |
341 | struct netdev_notifier_changeupper_info *info) |
342 | { |
343 | struct net_device *upper = info->upper_dev, *ndev_tmp; |
344 | - struct netdev_lag_upper_info *lag_upper_info; |
345 | + struct netdev_lag_upper_info *lag_upper_info = NULL; |
346 | bool is_bonded; |
347 | int bond_status = 0; |
348 | int num_slaves = 0; |
349 | @@ -303,7 +303,8 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev, |
350 | if (!netif_is_lag_master(upper)) |
351 | return 0; |
352 | |
353 | - lag_upper_info = info->upper_info; |
354 | + if (info->linking) |
355 | + lag_upper_info = info->upper_info; |
356 | |
357 | /* The event may still be of interest if the slave does not belong to |
358 | * us, but is enslaved to a master which has one or more of our netdevs |
359 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c |
360 | index 7a196a07fa51..d776db79e325 100644 |
361 | --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c |
362 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c |
363 | @@ -966,7 +966,7 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv, |
364 | if (err) { |
365 | dev_err(&dev->pdev->dev, "Firmware over %d MS in initializing state, aborting\n", |
366 | FW_INIT_TIMEOUT_MILI); |
367 | - goto out_err; |
368 | + goto err_cmd_cleanup; |
369 | } |
370 | |
371 | err = mlx5_core_enable_hca(dev, 0); |
372 | diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c |
373 | index 1a92de705199..a2d218b28c0e 100644 |
374 | --- a/drivers/net/ethernet/renesas/sh_eth.c |
375 | +++ b/drivers/net/ethernet/renesas/sh_eth.c |
376 | @@ -1059,12 +1059,70 @@ static struct mdiobb_ops bb_ops = { |
377 | .get_mdio_data = sh_get_mdio, |
378 | }; |
379 | |
380 | +/* free Tx skb function */ |
381 | +static int sh_eth_tx_free(struct net_device *ndev, bool sent_only) |
382 | +{ |
383 | + struct sh_eth_private *mdp = netdev_priv(ndev); |
384 | + struct sh_eth_txdesc *txdesc; |
385 | + int free_num = 0; |
386 | + int entry; |
387 | + bool sent; |
388 | + |
389 | + for (; mdp->cur_tx - mdp->dirty_tx > 0; mdp->dirty_tx++) { |
390 | + entry = mdp->dirty_tx % mdp->num_tx_ring; |
391 | + txdesc = &mdp->tx_ring[entry]; |
392 | + sent = !(txdesc->status & cpu_to_le32(TD_TACT)); |
393 | + if (sent_only && !sent) |
394 | + break; |
395 | + /* TACT bit must be checked before all the following reads */ |
396 | + dma_rmb(); |
397 | + netif_info(mdp, tx_done, ndev, |
398 | + "tx entry %d status 0x%08x\n", |
399 | + entry, le32_to_cpu(txdesc->status)); |
400 | + /* Free the original skb. */ |
401 | + if (mdp->tx_skbuff[entry]) { |
402 | + dma_unmap_single(&ndev->dev, le32_to_cpu(txdesc->addr), |
403 | + le32_to_cpu(txdesc->len) >> 16, |
404 | + DMA_TO_DEVICE); |
405 | + dev_kfree_skb_irq(mdp->tx_skbuff[entry]); |
406 | + mdp->tx_skbuff[entry] = NULL; |
407 | + free_num++; |
408 | + } |
409 | + txdesc->status = cpu_to_le32(TD_TFP); |
410 | + if (entry >= mdp->num_tx_ring - 1) |
411 | + txdesc->status |= cpu_to_le32(TD_TDLE); |
412 | + |
413 | + if (sent) { |
414 | + ndev->stats.tx_packets++; |
415 | + ndev->stats.tx_bytes += le32_to_cpu(txdesc->len) >> 16; |
416 | + } |
417 | + } |
418 | + return free_num; |
419 | +} |
420 | + |
421 | /* free skb and descriptor buffer */ |
422 | static void sh_eth_ring_free(struct net_device *ndev) |
423 | { |
424 | struct sh_eth_private *mdp = netdev_priv(ndev); |
425 | int ringsize, i; |
426 | |
427 | + if (mdp->rx_ring) { |
428 | + for (i = 0; i < mdp->num_rx_ring; i++) { |
429 | + if (mdp->rx_skbuff[i]) { |
430 | + struct sh_eth_rxdesc *rxdesc = &mdp->rx_ring[i]; |
431 | + |
432 | + dma_unmap_single(&ndev->dev, |
433 | + le32_to_cpu(rxdesc->addr), |
434 | + ALIGN(mdp->rx_buf_sz, 32), |
435 | + DMA_FROM_DEVICE); |
436 | + } |
437 | + } |
438 | + ringsize = sizeof(struct sh_eth_rxdesc) * mdp->num_rx_ring; |
439 | + dma_free_coherent(NULL, ringsize, mdp->rx_ring, |
440 | + mdp->rx_desc_dma); |
441 | + mdp->rx_ring = NULL; |
442 | + } |
443 | + |
444 | /* Free Rx skb ringbuffer */ |
445 | if (mdp->rx_skbuff) { |
446 | for (i = 0; i < mdp->num_rx_ring; i++) |
447 | @@ -1073,27 +1131,18 @@ static void sh_eth_ring_free(struct net_device *ndev) |
448 | kfree(mdp->rx_skbuff); |
449 | mdp->rx_skbuff = NULL; |
450 | |
451 | - /* Free Tx skb ringbuffer */ |
452 | - if (mdp->tx_skbuff) { |
453 | - for (i = 0; i < mdp->num_tx_ring; i++) |
454 | - dev_kfree_skb(mdp->tx_skbuff[i]); |
455 | - } |
456 | - kfree(mdp->tx_skbuff); |
457 | - mdp->tx_skbuff = NULL; |
458 | - |
459 | - if (mdp->rx_ring) { |
460 | - ringsize = sizeof(struct sh_eth_rxdesc) * mdp->num_rx_ring; |
461 | - dma_free_coherent(NULL, ringsize, mdp->rx_ring, |
462 | - mdp->rx_desc_dma); |
463 | - mdp->rx_ring = NULL; |
464 | - } |
465 | - |
466 | if (mdp->tx_ring) { |
467 | + sh_eth_tx_free(ndev, false); |
468 | + |
469 | ringsize = sizeof(struct sh_eth_txdesc) * mdp->num_tx_ring; |
470 | dma_free_coherent(NULL, ringsize, mdp->tx_ring, |
471 | mdp->tx_desc_dma); |
472 | mdp->tx_ring = NULL; |
473 | } |
474 | + |
475 | + /* Free Tx skb ringbuffer */ |
476 | + kfree(mdp->tx_skbuff); |
477 | + mdp->tx_skbuff = NULL; |
478 | } |
479 | |
480 | /* format skb and descriptor buffer */ |
481 | @@ -1341,43 +1390,6 @@ static void sh_eth_dev_exit(struct net_device *ndev) |
482 | update_mac_address(ndev); |
483 | } |
484 | |
485 | -/* free Tx skb function */ |
486 | -static int sh_eth_txfree(struct net_device *ndev) |
487 | -{ |
488 | - struct sh_eth_private *mdp = netdev_priv(ndev); |
489 | - struct sh_eth_txdesc *txdesc; |
490 | - int free_num = 0; |
491 | - int entry; |
492 | - |
493 | - for (; mdp->cur_tx - mdp->dirty_tx > 0; mdp->dirty_tx++) { |
494 | - entry = mdp->dirty_tx % mdp->num_tx_ring; |
495 | - txdesc = &mdp->tx_ring[entry]; |
496 | - if (txdesc->status & cpu_to_le32(TD_TACT)) |
497 | - break; |
498 | - /* TACT bit must be checked before all the following reads */ |
499 | - dma_rmb(); |
500 | - netif_info(mdp, tx_done, ndev, |
501 | - "tx entry %d status 0x%08x\n", |
502 | - entry, le32_to_cpu(txdesc->status)); |
503 | - /* Free the original skb. */ |
504 | - if (mdp->tx_skbuff[entry]) { |
505 | - dma_unmap_single(&ndev->dev, le32_to_cpu(txdesc->addr), |
506 | - le32_to_cpu(txdesc->len) >> 16, |
507 | - DMA_TO_DEVICE); |
508 | - dev_kfree_skb_irq(mdp->tx_skbuff[entry]); |
509 | - mdp->tx_skbuff[entry] = NULL; |
510 | - free_num++; |
511 | - } |
512 | - txdesc->status = cpu_to_le32(TD_TFP); |
513 | - if (entry >= mdp->num_tx_ring - 1) |
514 | - txdesc->status |= cpu_to_le32(TD_TDLE); |
515 | - |
516 | - ndev->stats.tx_packets++; |
517 | - ndev->stats.tx_bytes += le32_to_cpu(txdesc->len) >> 16; |
518 | - } |
519 | - return free_num; |
520 | -} |
521 | - |
522 | /* Packet receive function */ |
523 | static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) |
524 | { |
525 | @@ -1620,7 +1632,7 @@ static void sh_eth_error(struct net_device *ndev, u32 intr_status) |
526 | intr_status, mdp->cur_tx, mdp->dirty_tx, |
527 | (u32)ndev->state, edtrr); |
528 | /* dirty buffer free */ |
529 | - sh_eth_txfree(ndev); |
530 | + sh_eth_tx_free(ndev, true); |
531 | |
532 | /* SH7712 BUG */ |
533 | if (edtrr ^ sh_eth_get_edtrr_trns(mdp)) { |
534 | @@ -1679,7 +1691,7 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev) |
535 | /* Clear Tx interrupts */ |
536 | sh_eth_write(ndev, intr_status & cd->tx_check, EESR); |
537 | |
538 | - sh_eth_txfree(ndev); |
539 | + sh_eth_tx_free(ndev, true); |
540 | netif_wake_queue(ndev); |
541 | } |
542 | |
543 | @@ -2307,7 +2319,7 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev) |
544 | |
545 | spin_lock_irqsave(&mdp->lock, flags); |
546 | if ((mdp->cur_tx - mdp->dirty_tx) >= (mdp->num_tx_ring - 4)) { |
547 | - if (!sh_eth_txfree(ndev)) { |
548 | + if (!sh_eth_tx_free(ndev, true)) { |
549 | netif_warn(mdp, tx_queued, ndev, "TxFD exhausted.\n"); |
550 | netif_stop_queue(ndev); |
551 | spin_unlock_irqrestore(&mdp->lock, flags); |
552 | diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c |
553 | index d2e61e002926..f7c6a40aae81 100644 |
554 | --- a/drivers/net/macsec.c |
555 | +++ b/drivers/net/macsec.c |
556 | @@ -2709,7 +2709,7 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb, |
557 | } |
558 | |
559 | #define MACSEC_FEATURES \ |
560 | - (NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST) |
561 | + (NETIF_F_SG | NETIF_F_HIGHDMA) |
562 | static struct lock_class_key macsec_netdev_addr_lock_key; |
563 | |
564 | static int macsec_dev_init(struct net_device *dev) |
565 | diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c |
566 | index 26d6f0bbe14b..dc8ccac0a01d 100644 |
567 | --- a/drivers/net/macvlan.c |
568 | +++ b/drivers/net/macvlan.c |
569 | @@ -1140,6 +1140,7 @@ static int macvlan_port_create(struct net_device *dev) |
570 | static void macvlan_port_destroy(struct net_device *dev) |
571 | { |
572 | struct macvlan_port *port = macvlan_port_get_rtnl(dev); |
573 | + struct sk_buff *skb; |
574 | |
575 | dev->priv_flags &= ~IFF_MACVLAN_PORT; |
576 | netdev_rx_handler_unregister(dev); |
577 | @@ -1148,7 +1149,15 @@ static void macvlan_port_destroy(struct net_device *dev) |
578 | * but we need to cancel it and purge left skbs if any. |
579 | */ |
580 | cancel_work_sync(&port->bc_work); |
581 | - __skb_queue_purge(&port->bc_queue); |
582 | + |
583 | + while ((skb = __skb_dequeue(&port->bc_queue))) { |
584 | + const struct macvlan_dev *src = MACVLAN_SKB_CB(skb)->src; |
585 | + |
586 | + if (src) |
587 | + dev_put(src->dev); |
588 | + |
589 | + kfree_skb(skb); |
590 | + } |
591 | |
592 | kfree_rcu(port, rcu); |
593 | } |
594 | diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c |
595 | index 7a240fce3a7e..4865221aa9ac 100644 |
596 | --- a/drivers/net/phy/dp83640.c |
597 | +++ b/drivers/net/phy/dp83640.c |
598 | @@ -1438,8 +1438,6 @@ static bool dp83640_rxtstamp(struct phy_device *phydev, |
599 | skb_info->tmo = jiffies + SKB_TIMESTAMP_TIMEOUT; |
600 | skb_queue_tail(&dp83640->rx_queue, skb); |
601 | schedule_delayed_work(&dp83640->ts_work, SKB_TIMESTAMP_TIMEOUT); |
602 | - } else { |
603 | - netif_rx_ni(skb); |
604 | } |
605 | |
606 | return true; |
607 | diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c |
608 | index 201ffa5fe4f7..a9be26f1f677 100644 |
609 | --- a/drivers/net/phy/phy.c |
610 | +++ b/drivers/net/phy/phy.c |
611 | @@ -552,16 +552,18 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd) |
612 | EXPORT_SYMBOL(phy_mii_ioctl); |
613 | |
614 | /** |
615 | - * phy_start_aneg - start auto-negotiation for this PHY device |
616 | + * phy_start_aneg_priv - start auto-negotiation for this PHY device |
617 | * @phydev: the phy_device struct |
618 | + * @sync: indicate whether we should wait for the workqueue cancelation |
619 | * |
620 | * Description: Sanitizes the settings (if we're not autonegotiating |
621 | * them), and then calls the driver's config_aneg function. |
622 | * If the PHYCONTROL Layer is operating, we change the state to |
623 | * reflect the beginning of Auto-negotiation or forcing. |
624 | */ |
625 | -int phy_start_aneg(struct phy_device *phydev) |
626 | +static int phy_start_aneg_priv(struct phy_device *phydev, bool sync) |
627 | { |
628 | + bool trigger = 0; |
629 | int err; |
630 | |
631 | mutex_lock(&phydev->lock); |
632 | @@ -586,10 +588,40 @@ int phy_start_aneg(struct phy_device *phydev) |
633 | } |
634 | } |
635 | |
636 | + /* Re-schedule a PHY state machine to check PHY status because |
637 | + * negotiation may already be done and aneg interrupt may not be |
638 | + * generated. |
639 | + */ |
640 | + if (phy_interrupt_is_valid(phydev) && (phydev->state == PHY_AN)) { |
641 | + err = phy_aneg_done(phydev); |
642 | + if (err > 0) { |
643 | + trigger = true; |
644 | + err = 0; |
645 | + } |
646 | + } |
647 | + |
648 | out_unlock: |
649 | mutex_unlock(&phydev->lock); |
650 | + |
651 | + if (trigger) |
652 | + phy_trigger_machine(phydev, sync); |
653 | + |
654 | return err; |
655 | } |
656 | + |
657 | +/** |
658 | + * phy_start_aneg - start auto-negotiation for this PHY device |
659 | + * @phydev: the phy_device struct |
660 | + * |
661 | + * Description: Sanitizes the settings (if we're not autonegotiating |
662 | + * them), and then calls the driver's config_aneg function. |
663 | + * If the PHYCONTROL Layer is operating, we change the state to |
664 | + * reflect the beginning of Auto-negotiation or forcing. |
665 | + */ |
666 | +int phy_start_aneg(struct phy_device *phydev) |
667 | +{ |
668 | + return phy_start_aneg_priv(phydev, true); |
669 | +} |
670 | EXPORT_SYMBOL(phy_start_aneg); |
671 | |
672 | /** |
673 | @@ -617,7 +649,7 @@ void phy_start_machine(struct phy_device *phydev) |
674 | * state machine runs. |
675 | */ |
676 | |
677 | -static void phy_trigger_machine(struct phy_device *phydev, bool sync) |
678 | +void phy_trigger_machine(struct phy_device *phydev, bool sync) |
679 | { |
680 | if (sync) |
681 | cancel_delayed_work_sync(&phydev->state_queue); |
682 | @@ -639,7 +671,7 @@ void phy_stop_machine(struct phy_device *phydev) |
683 | cancel_delayed_work_sync(&phydev->state_queue); |
684 | |
685 | mutex_lock(&phydev->lock); |
686 | - if (phydev->state > PHY_UP) |
687 | + if (phydev->state > PHY_UP && phydev->state != PHY_HALTED) |
688 | phydev->state = PHY_UP; |
689 | mutex_unlock(&phydev->lock); |
690 | } |
691 | @@ -1100,7 +1132,7 @@ void phy_state_machine(struct work_struct *work) |
692 | mutex_unlock(&phydev->lock); |
693 | |
694 | if (needs_aneg) |
695 | - err = phy_start_aneg(phydev); |
696 | + err = phy_start_aneg_priv(phydev, false); |
697 | else if (do_suspend) |
698 | phy_suspend(phydev); |
699 | |
700 | diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c |
701 | index a2afb8ecb5bc..80ef4865cc8b 100644 |
702 | --- a/drivers/net/vrf.c |
703 | +++ b/drivers/net/vrf.c |
704 | @@ -1124,7 +1124,7 @@ static int vrf_fib_rule(const struct net_device *dev, __u8 family, bool add_it) |
705 | goto nla_put_failure; |
706 | |
707 | /* rule only needs to appear once */ |
708 | - nlh->nlmsg_flags &= NLM_F_EXCL; |
709 | + nlh->nlmsg_flags |= NLM_F_EXCL; |
710 | |
711 | frh = nlmsg_data(nlh); |
712 | memset(frh, 0, sizeof(*frh)); |
713 | diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c |
714 | index 12f2252f6c98..953275b651bc 100644 |
715 | --- a/fs/ceph/inode.c |
716 | +++ b/fs/ceph/inode.c |
717 | @@ -2080,11 +2080,6 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) |
718 | if (inode_dirty_flags) |
719 | __mark_inode_dirty(inode, inode_dirty_flags); |
720 | |
721 | - if (ia_valid & ATTR_MODE) { |
722 | - err = posix_acl_chmod(inode, attr->ia_mode); |
723 | - if (err) |
724 | - goto out_put; |
725 | - } |
726 | |
727 | if (mask) { |
728 | req->r_inode = inode; |
729 | @@ -2098,13 +2093,11 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) |
730 | ceph_cap_string(dirtied), mask); |
731 | |
732 | ceph_mdsc_put_request(req); |
733 | - if (mask & CEPH_SETATTR_SIZE) |
734 | - __ceph_do_pending_vmtruncate(inode); |
735 | - ceph_free_cap_flush(prealloc_cf); |
736 | - return err; |
737 | -out_put: |
738 | - ceph_mdsc_put_request(req); |
739 | ceph_free_cap_flush(prealloc_cf); |
740 | + |
741 | + if (err >= 0 && (mask & CEPH_SETATTR_SIZE)) |
742 | + __ceph_do_pending_vmtruncate(inode); |
743 | + |
744 | return err; |
745 | } |
746 | |
747 | @@ -2123,7 +2116,12 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) |
748 | if (err != 0) |
749 | return err; |
750 | |
751 | - return __ceph_setattr(inode, attr); |
752 | + err = __ceph_setattr(inode, attr); |
753 | + |
754 | + if (err >= 0 && (attr->ia_valid & ATTR_MODE)) |
755 | + err = posix_acl_chmod(inode, attr->ia_mode); |
756 | + |
757 | + return err; |
758 | } |
759 | |
760 | /* |
761 | diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c |
762 | index dba2ff8eaa68..452334694a5d 100644 |
763 | --- a/fs/nfsd/nfs3xdr.c |
764 | +++ b/fs/nfsd/nfs3xdr.c |
765 | @@ -358,6 +358,8 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p, |
766 | { |
767 | unsigned int len, v, hdr, dlen; |
768 | u32 max_blocksize = svc_max_payload(rqstp); |
769 | + struct kvec *head = rqstp->rq_arg.head; |
770 | + struct kvec *tail = rqstp->rq_arg.tail; |
771 | |
772 | p = decode_fh(p, &args->fh); |
773 | if (!p) |
774 | @@ -367,6 +369,8 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p, |
775 | args->count = ntohl(*p++); |
776 | args->stable = ntohl(*p++); |
777 | len = args->len = ntohl(*p++); |
778 | + if ((void *)p > head->iov_base + head->iov_len) |
779 | + return 0; |
780 | /* |
781 | * The count must equal the amount of data passed. |
782 | */ |
783 | @@ -377,9 +381,8 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p, |
784 | * Check to make sure that we got the right number of |
785 | * bytes. |
786 | */ |
787 | - hdr = (void*)p - rqstp->rq_arg.head[0].iov_base; |
788 | - dlen = rqstp->rq_arg.head[0].iov_len + rqstp->rq_arg.page_len |
789 | - + rqstp->rq_arg.tail[0].iov_len - hdr; |
790 | + hdr = (void*)p - head->iov_base; |
791 | + dlen = head->iov_len + rqstp->rq_arg.page_len + tail->iov_len - hdr; |
792 | /* |
793 | * Round the length of the data which was specified up to |
794 | * the next multiple of XDR units and then compare that |
795 | @@ -396,7 +399,7 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p, |
796 | len = args->len = max_blocksize; |
797 | } |
798 | rqstp->rq_vec[0].iov_base = (void*)p; |
799 | - rqstp->rq_vec[0].iov_len = rqstp->rq_arg.head[0].iov_len - hdr; |
800 | + rqstp->rq_vec[0].iov_len = head->iov_len - hdr; |
801 | v = 0; |
802 | while (len > rqstp->rq_vec[v].iov_len) { |
803 | len -= rqstp->rq_vec[v].iov_len; |
804 | @@ -471,6 +474,8 @@ nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p, |
805 | /* first copy and check from the first page */ |
806 | old = (char*)p; |
807 | vec = &rqstp->rq_arg.head[0]; |
808 | + if ((void *)old > vec->iov_base + vec->iov_len) |
809 | + return 0; |
810 | avail = vec->iov_len - (old - (char*)vec->iov_base); |
811 | while (len && avail && *old) { |
812 | *new++ = *old++; |
813 | diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c |
814 | index a2b65fc56dd6..1645b977c9c6 100644 |
815 | --- a/fs/nfsd/nfssvc.c |
816 | +++ b/fs/nfsd/nfssvc.c |
817 | @@ -733,6 +733,37 @@ static __be32 map_new_errors(u32 vers, __be32 nfserr) |
818 | return nfserr; |
819 | } |
820 | |
821 | +/* |
822 | + * A write procedure can have a large argument, and a read procedure can |
823 | + * have a large reply, but no NFSv2 or NFSv3 procedure has argument and |
824 | + * reply that can both be larger than a page. The xdr code has taken |
825 | + * advantage of this assumption to be a sloppy about bounds checking in |
826 | + * some cases. Pending a rewrite of the NFSv2/v3 xdr code to fix that |
827 | + * problem, we enforce these assumptions here: |
828 | + */ |
829 | +static bool nfs_request_too_big(struct svc_rqst *rqstp, |
830 | + struct svc_procedure *proc) |
831 | +{ |
832 | + /* |
833 | + * The ACL code has more careful bounds-checking and is not |
834 | + * susceptible to this problem: |
835 | + */ |
836 | + if (rqstp->rq_prog != NFS_PROGRAM) |
837 | + return false; |
838 | + /* |
839 | + * Ditto NFSv4 (which can in theory have argument and reply both |
840 | + * more than a page): |
841 | + */ |
842 | + if (rqstp->rq_vers >= 4) |
843 | + return false; |
844 | + /* The reply will be small, we're OK: */ |
845 | + if (proc->pc_xdrressize > 0 && |
846 | + proc->pc_xdrressize < XDR_QUADLEN(PAGE_SIZE)) |
847 | + return false; |
848 | + |
849 | + return rqstp->rq_arg.len > PAGE_SIZE; |
850 | +} |
851 | + |
852 | int |
853 | nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) |
854 | { |
855 | @@ -745,6 +776,11 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) |
856 | rqstp->rq_vers, rqstp->rq_proc); |
857 | proc = rqstp->rq_procinfo; |
858 | |
859 | + if (nfs_request_too_big(rqstp, proc)) { |
860 | + dprintk("nfsd: NFSv%d argument too large\n", rqstp->rq_vers); |
861 | + *statp = rpc_garbage_args; |
862 | + return 1; |
863 | + } |
864 | /* |
865 | * Give the xdr decoder a chance to change this if it wants |
866 | * (necessary in the NFSv4.0 compound case) |
867 | diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c |
868 | index 41b468a6a90f..de07ff625777 100644 |
869 | --- a/fs/nfsd/nfsxdr.c |
870 | +++ b/fs/nfsd/nfsxdr.c |
871 | @@ -280,6 +280,7 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p, |
872 | struct nfsd_writeargs *args) |
873 | { |
874 | unsigned int len, hdr, dlen; |
875 | + struct kvec *head = rqstp->rq_arg.head; |
876 | int v; |
877 | |
878 | p = decode_fh(p, &args->fh); |
879 | @@ -300,9 +301,10 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p, |
880 | * Check to make sure that we got the right number of |
881 | * bytes. |
882 | */ |
883 | - hdr = (void*)p - rqstp->rq_arg.head[0].iov_base; |
884 | - dlen = rqstp->rq_arg.head[0].iov_len + rqstp->rq_arg.page_len |
885 | - - hdr; |
886 | + hdr = (void*)p - head->iov_base; |
887 | + if (hdr > head->iov_len) |
888 | + return 0; |
889 | + dlen = head->iov_len + rqstp->rq_arg.page_len - hdr; |
890 | |
891 | /* |
892 | * Round the length of the data which was specified up to |
893 | @@ -316,7 +318,7 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p, |
894 | return 0; |
895 | |
896 | rqstp->rq_vec[0].iov_base = (void*)p; |
897 | - rqstp->rq_vec[0].iov_len = rqstp->rq_arg.head[0].iov_len - hdr; |
898 | + rqstp->rq_vec[0].iov_len = head->iov_len - hdr; |
899 | v = 0; |
900 | while (len > rqstp->rq_vec[v].iov_len) { |
901 | len -= rqstp->rq_vec[v].iov_len; |
902 | diff --git a/include/linux/phy.h b/include/linux/phy.h |
903 | index e25f1830fbcf..bd22670e2182 100644 |
904 | --- a/include/linux/phy.h |
905 | +++ b/include/linux/phy.h |
906 | @@ -806,6 +806,7 @@ void phy_change(struct work_struct *work); |
907 | void phy_mac_interrupt(struct phy_device *phydev, int new_link); |
908 | void phy_start_machine(struct phy_device *phydev); |
909 | void phy_stop_machine(struct phy_device *phydev); |
910 | +void phy_trigger_machine(struct phy_device *phydev, bool sync); |
911 | int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd); |
912 | int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd); |
913 | int phy_ethtool_ksettings_get(struct phy_device *phydev, |
914 | diff --git a/include/uapi/linux/ipv6_route.h b/include/uapi/linux/ipv6_route.h |
915 | index f6598d1c886e..316e838b7470 100644 |
916 | --- a/include/uapi/linux/ipv6_route.h |
917 | +++ b/include/uapi/linux/ipv6_route.h |
918 | @@ -34,7 +34,7 @@ |
919 | #define RTF_PREF(pref) ((pref) << 27) |
920 | #define RTF_PREF_MASK 0x18000000 |
921 | |
922 | -#define RTF_PCPU 0x40000000 |
923 | +#define RTF_PCPU 0x40000000 /* read-only: can not be set by user */ |
924 | #define RTF_LOCAL 0x80000000 |
925 | |
926 | |
927 | diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c |
928 | index 85d1c9423ccb..7c9f94c53441 100644 |
929 | --- a/kernel/bpf/verifier.c |
930 | +++ b/kernel/bpf/verifier.c |
931 | @@ -1829,14 +1829,15 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state, |
932 | |
933 | for (i = 0; i < MAX_BPF_REG; i++) |
934 | if (regs[i].type == PTR_TO_PACKET && regs[i].id == dst_reg->id) |
935 | - regs[i].range = dst_reg->off; |
936 | + /* keep the maximum range already checked */ |
937 | + regs[i].range = max(regs[i].range, dst_reg->off); |
938 | |
939 | for (i = 0; i < MAX_BPF_STACK; i += BPF_REG_SIZE) { |
940 | if (state->stack_slot_type[i] != STACK_SPILL) |
941 | continue; |
942 | reg = &state->spilled_regs[i / BPF_REG_SIZE]; |
943 | if (reg->type == PTR_TO_PACKET && reg->id == dst_reg->id) |
944 | - reg->range = dst_reg->off; |
945 | + reg->range = max(reg->range, dst_reg->off); |
946 | } |
947 | } |
948 | |
949 | diff --git a/net/9p/client.c b/net/9p/client.c |
950 | index 3fc94a49ccd5..cf129fec7329 100644 |
951 | --- a/net/9p/client.c |
952 | +++ b/net/9p/client.c |
953 | @@ -2101,6 +2101,10 @@ int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset) |
954 | trace_9p_protocol_dump(clnt, req->rc); |
955 | goto free_and_error; |
956 | } |
957 | + if (rsize < count) { |
958 | + pr_err("bogus RREADDIR count (%d > %d)\n", count, rsize); |
959 | + count = rsize; |
960 | + } |
961 | |
962 | p9_debug(P9_DEBUG_9P, "<<< RREADDIR count %d\n", count); |
963 | |
964 | diff --git a/net/core/neighbour.c b/net/core/neighbour.c |
965 | index 9901e5b75a05..f45f6198851f 100644 |
966 | --- a/net/core/neighbour.c |
967 | +++ b/net/core/neighbour.c |
968 | @@ -859,7 +859,8 @@ static void neigh_probe(struct neighbour *neigh) |
969 | if (skb) |
970 | skb = skb_clone(skb, GFP_ATOMIC); |
971 | write_unlock(&neigh->lock); |
972 | - neigh->ops->solicit(neigh, skb); |
973 | + if (neigh->ops->solicit) |
974 | + neigh->ops->solicit(neigh, skb); |
975 | atomic_inc(&neigh->probes); |
976 | kfree_skb(skb); |
977 | } |
978 | diff --git a/net/core/netpoll.c b/net/core/netpoll.c |
979 | index 53599bd0c82d..457f882b0f7b 100644 |
980 | --- a/net/core/netpoll.c |
981 | +++ b/net/core/netpoll.c |
982 | @@ -105,15 +105,21 @@ static void queue_process(struct work_struct *work) |
983 | while ((skb = skb_dequeue(&npinfo->txq))) { |
984 | struct net_device *dev = skb->dev; |
985 | struct netdev_queue *txq; |
986 | + unsigned int q_index; |
987 | |
988 | if (!netif_device_present(dev) || !netif_running(dev)) { |
989 | kfree_skb(skb); |
990 | continue; |
991 | } |
992 | |
993 | - txq = skb_get_tx_queue(dev, skb); |
994 | - |
995 | local_irq_save(flags); |
996 | + /* check if skb->queue_mapping is still valid */ |
997 | + q_index = skb_get_queue_mapping(skb); |
998 | + if (unlikely(q_index >= dev->real_num_tx_queues)) { |
999 | + q_index = q_index % dev->real_num_tx_queues; |
1000 | + skb_set_queue_mapping(skb, q_index); |
1001 | + } |
1002 | + txq = netdev_get_tx_queue(dev, q_index); |
1003 | HARD_TX_LOCK(dev, txq, smp_processor_id()); |
1004 | if (netif_xmit_frozen_or_stopped(txq) || |
1005 | netpoll_start_xmit(skb, dev, txq) != NETDEV_TX_OK) { |
1006 | diff --git a/net/core/skbuff.c b/net/core/skbuff.c |
1007 | index f0f462c0573d..fe008f1bd930 100644 |
1008 | --- a/net/core/skbuff.c |
1009 | +++ b/net/core/skbuff.c |
1010 | @@ -3076,22 +3076,32 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, |
1011 | if (sg && csum && (mss != GSO_BY_FRAGS)) { |
1012 | if (!(features & NETIF_F_GSO_PARTIAL)) { |
1013 | struct sk_buff *iter; |
1014 | + unsigned int frag_len; |
1015 | |
1016 | if (!list_skb || |
1017 | !net_gso_ok(features, skb_shinfo(head_skb)->gso_type)) |
1018 | goto normal; |
1019 | |
1020 | - /* Split the buffer at the frag_list pointer. |
1021 | - * This is based on the assumption that all |
1022 | - * buffers in the chain excluding the last |
1023 | - * containing the same amount of data. |
1024 | + /* If we get here then all the required |
1025 | + * GSO features except frag_list are supported. |
1026 | + * Try to split the SKB to multiple GSO SKBs |
1027 | + * with no frag_list. |
1028 | + * Currently we can do that only when the buffers don't |
1029 | + * have a linear part and all the buffers except |
1030 | + * the last are of the same length. |
1031 | */ |
1032 | + frag_len = list_skb->len; |
1033 | skb_walk_frags(head_skb, iter) { |
1034 | + if (frag_len != iter->len && iter->next) |
1035 | + goto normal; |
1036 | if (skb_headlen(iter)) |
1037 | goto normal; |
1038 | |
1039 | len -= iter->len; |
1040 | } |
1041 | + |
1042 | + if (len != frag_len) |
1043 | + goto normal; |
1044 | } |
1045 | |
1046 | /* GSO partial only requires that we trim off any excess that |
1047 | @@ -3779,6 +3789,7 @@ static void __skb_complete_tx_timestamp(struct sk_buff *skb, |
1048 | serr->ee.ee_errno = ENOMSG; |
1049 | serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING; |
1050 | serr->ee.ee_info = tstype; |
1051 | + serr->header.h4.iif = skb->dev ? skb->dev->ifindex : 0; |
1052 | if (sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID) { |
1053 | serr->ee.ee_data = skb_shinfo(skb)->tskey; |
1054 | if (sk->sk_protocol == IPPROTO_TCP && |
1055 | diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c |
1056 | index 9826695ddfc6..4d37bdcbc2d5 100644 |
1057 | --- a/net/ipv4/ip_sockglue.c |
1058 | +++ b/net/ipv4/ip_sockglue.c |
1059 | @@ -474,16 +474,15 @@ static bool ipv4_datagram_support_cmsg(const struct sock *sk, |
1060 | return false; |
1061 | |
1062 | /* Support IP_PKTINFO on tstamp packets if requested, to correlate |
1063 | - * timestamp with egress dev. Not possible for packets without dev |
1064 | + * timestamp with egress dev. Not possible for packets without iif |
1065 | * or without payload (SOF_TIMESTAMPING_OPT_TSONLY). |
1066 | */ |
1067 | - if ((!(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_CMSG)) || |
1068 | - (!skb->dev)) |
1069 | + info = PKTINFO_SKB_CB(skb); |
1070 | + if (!(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_CMSG) || |
1071 | + !info->ipi_ifindex) |
1072 | return false; |
1073 | |
1074 | - info = PKTINFO_SKB_CB(skb); |
1075 | info->ipi_spec_dst.s_addr = ip_hdr(skb)->saddr; |
1076 | - info->ipi_ifindex = skb->dev->ifindex; |
1077 | return true; |
1078 | } |
1079 | |
1080 | diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c |
1081 | index 105c0748c52f..e612991c9185 100644 |
1082 | --- a/net/ipv4/ping.c |
1083 | +++ b/net/ipv4/ping.c |
1084 | @@ -156,17 +156,18 @@ int ping_hash(struct sock *sk) |
1085 | void ping_unhash(struct sock *sk) |
1086 | { |
1087 | struct inet_sock *isk = inet_sk(sk); |
1088 | + |
1089 | pr_debug("ping_unhash(isk=%p,isk->num=%u)\n", isk, isk->inet_num); |
1090 | + write_lock_bh(&ping_table.lock); |
1091 | if (sk_hashed(sk)) { |
1092 | - write_lock_bh(&ping_table.lock); |
1093 | hlist_nulls_del(&sk->sk_nulls_node); |
1094 | sk_nulls_node_init(&sk->sk_nulls_node); |
1095 | sock_put(sk); |
1096 | isk->inet_num = 0; |
1097 | isk->inet_sport = 0; |
1098 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); |
1099 | - write_unlock_bh(&ping_table.lock); |
1100 | } |
1101 | + write_unlock_bh(&ping_table.lock); |
1102 | } |
1103 | EXPORT_SYMBOL_GPL(ping_unhash); |
1104 | |
1105 | diff --git a/net/ipv4/route.c b/net/ipv4/route.c |
1106 | index 17e6fbf30448..6dbcb37753d7 100644 |
1107 | --- a/net/ipv4/route.c |
1108 | +++ b/net/ipv4/route.c |
1109 | @@ -2569,7 +2569,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh) |
1110 | skb_reset_network_header(skb); |
1111 | |
1112 | /* Bugfix: need to give ip_route_input enough of an IP header to not gag. */ |
1113 | - ip_hdr(skb)->protocol = IPPROTO_ICMP; |
1114 | + ip_hdr(skb)->protocol = IPPROTO_UDP; |
1115 | skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr)); |
1116 | |
1117 | src = tb[RTA_SRC] ? nla_get_in_addr(tb[RTA_SRC]) : 0; |
1118 | diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c |
1119 | index 6a90a0e130dc..eb142ca71fc5 100644 |
1120 | --- a/net/ipv4/tcp.c |
1121 | +++ b/net/ipv4/tcp.c |
1122 | @@ -2297,6 +2297,7 @@ int tcp_disconnect(struct sock *sk, int flags) |
1123 | tcp_init_send_head(sk); |
1124 | memset(&tp->rx_opt, 0, sizeof(tp->rx_opt)); |
1125 | __sk_dst_reset(sk); |
1126 | + tcp_saved_syn_free(tp); |
1127 | |
1128 | WARN_ON(inet->inet_num && !icsk->icsk_bind_hash); |
1129 | |
1130 | diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c |
1131 | index f9038d6b109e..baea5df43598 100644 |
1132 | --- a/net/ipv4/tcp_cong.c |
1133 | +++ b/net/ipv4/tcp_cong.c |
1134 | @@ -167,12 +167,8 @@ void tcp_assign_congestion_control(struct sock *sk) |
1135 | } |
1136 | out: |
1137 | rcu_read_unlock(); |
1138 | + memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); |
1139 | |
1140 | - /* Clear out private data before diag gets it and |
1141 | - * the ca has not been initialized. |
1142 | - */ |
1143 | - if (ca->get_info) |
1144 | - memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); |
1145 | if (ca->flags & TCP_CONG_NEEDS_ECN) |
1146 | INET_ECN_xmit(sk); |
1147 | else |
1148 | @@ -199,11 +195,10 @@ static void tcp_reinit_congestion_control(struct sock *sk, |
1149 | tcp_cleanup_congestion_control(sk); |
1150 | icsk->icsk_ca_ops = ca; |
1151 | icsk->icsk_ca_setsockopt = 1; |
1152 | + memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); |
1153 | |
1154 | - if (sk->sk_state != TCP_CLOSE) { |
1155 | - memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); |
1156 | + if (sk->sk_state != TCP_CLOSE) |
1157 | tcp_init_congestion_control(sk); |
1158 | - } |
1159 | } |
1160 | |
1161 | /* Manage refcounts on socket close. */ |
1162 | diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c |
1163 | index 95dfcba38ff6..cffdbdbff3a2 100644 |
1164 | --- a/net/ipv6/addrconf.c |
1165 | +++ b/net/ipv6/addrconf.c |
1166 | @@ -3253,14 +3253,24 @@ static void addrconf_gre_config(struct net_device *dev) |
1167 | static int fixup_permanent_addr(struct inet6_dev *idev, |
1168 | struct inet6_ifaddr *ifp) |
1169 | { |
1170 | - if (!ifp->rt) { |
1171 | - struct rt6_info *rt; |
1172 | + /* rt6i_ref == 0 means the host route was removed from the |
1173 | + * FIB, for example, if 'lo' device is taken down. In that |
1174 | + * case regenerate the host route. |
1175 | + */ |
1176 | + if (!ifp->rt || !atomic_read(&ifp->rt->rt6i_ref)) { |
1177 | + struct rt6_info *rt, *prev; |
1178 | |
1179 | rt = addrconf_dst_alloc(idev, &ifp->addr, false); |
1180 | if (unlikely(IS_ERR(rt))) |
1181 | return PTR_ERR(rt); |
1182 | |
1183 | + /* ifp->rt can be accessed outside of rtnl */ |
1184 | + spin_lock(&ifp->lock); |
1185 | + prev = ifp->rt; |
1186 | ifp->rt = rt; |
1187 | + spin_unlock(&ifp->lock); |
1188 | + |
1189 | + ip6_rt_put(prev); |
1190 | } |
1191 | |
1192 | if (!(ifp->flags & IFA_F_NOPREFIXROUTE)) { |
1193 | @@ -3602,14 +3612,19 @@ static int addrconf_ifdown(struct net_device *dev, int how) |
1194 | INIT_LIST_HEAD(&del_list); |
1195 | list_for_each_entry_safe(ifa, tmp, &idev->addr_list, if_list) { |
1196 | struct rt6_info *rt = NULL; |
1197 | + bool keep; |
1198 | |
1199 | addrconf_del_dad_work(ifa); |
1200 | |
1201 | + keep = keep_addr && (ifa->flags & IFA_F_PERMANENT) && |
1202 | + !addr_is_local(&ifa->addr); |
1203 | + if (!keep) |
1204 | + list_move(&ifa->if_list, &del_list); |
1205 | + |
1206 | write_unlock_bh(&idev->lock); |
1207 | spin_lock_bh(&ifa->lock); |
1208 | |
1209 | - if (keep_addr && (ifa->flags & IFA_F_PERMANENT) && |
1210 | - !addr_is_local(&ifa->addr)) { |
1211 | + if (keep) { |
1212 | /* set state to skip the notifier below */ |
1213 | state = INET6_IFADDR_STATE_DEAD; |
1214 | ifa->state = 0; |
1215 | @@ -3621,8 +3636,6 @@ static int addrconf_ifdown(struct net_device *dev, int how) |
1216 | } else { |
1217 | state = ifa->state; |
1218 | ifa->state = INET6_IFADDR_STATE_DEAD; |
1219 | - |
1220 | - list_move(&ifa->if_list, &del_list); |
1221 | } |
1222 | |
1223 | spin_unlock_bh(&ifa->lock); |
1224 | diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c |
1225 | index 8616d17cf08f..442ec1f39ed1 100644 |
1226 | --- a/net/ipv6/datagram.c |
1227 | +++ b/net/ipv6/datagram.c |
1228 | @@ -400,9 +400,6 @@ static inline bool ipv6_datagram_support_addr(struct sock_exterr_skb *serr) |
1229 | * At one point, excluding local errors was a quick test to identify icmp/icmp6 |
1230 | * errors. This is no longer true, but the test remained, so the v6 stack, |
1231 | * unlike v4, also honors cmsg requests on all wifi and timestamp errors. |
1232 | - * |
1233 | - * Timestamp code paths do not initialize the fields expected by cmsg: |
1234 | - * the PKTINFO fields in skb->cb[]. Fill those in here. |
1235 | */ |
1236 | static bool ip6_datagram_support_cmsg(struct sk_buff *skb, |
1237 | struct sock_exterr_skb *serr) |
1238 | @@ -414,14 +411,9 @@ static bool ip6_datagram_support_cmsg(struct sk_buff *skb, |
1239 | if (serr->ee.ee_origin == SO_EE_ORIGIN_LOCAL) |
1240 | return false; |
1241 | |
1242 | - if (!skb->dev) |
1243 | + if (!IP6CB(skb)->iif) |
1244 | return false; |
1245 | |
1246 | - if (skb->protocol == htons(ETH_P_IPV6)) |
1247 | - IP6CB(skb)->iif = skb->dev->ifindex; |
1248 | - else |
1249 | - PKTINFO_SKB_CB(skb)->ipi_ifindex = skb->dev->ifindex; |
1250 | - |
1251 | return true; |
1252 | } |
1253 | |
1254 | diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c |
1255 | index f6ba45242851..116b4da06820 100644 |
1256 | --- a/net/ipv6/ip6_tunnel.c |
1257 | +++ b/net/ipv6/ip6_tunnel.c |
1258 | @@ -1037,7 +1037,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield, |
1259 | struct ip6_tnl *t = netdev_priv(dev); |
1260 | struct net *net = t->net; |
1261 | struct net_device_stats *stats = &t->dev->stats; |
1262 | - struct ipv6hdr *ipv6h = ipv6_hdr(skb); |
1263 | + struct ipv6hdr *ipv6h; |
1264 | struct ipv6_tel_txoption opt; |
1265 | struct dst_entry *dst = NULL, *ndst = NULL; |
1266 | struct net_device *tdev; |
1267 | @@ -1057,26 +1057,28 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield, |
1268 | |
1269 | /* NBMA tunnel */ |
1270 | if (ipv6_addr_any(&t->parms.raddr)) { |
1271 | - struct in6_addr *addr6; |
1272 | - struct neighbour *neigh; |
1273 | - int addr_type; |
1274 | + if (skb->protocol == htons(ETH_P_IPV6)) { |
1275 | + struct in6_addr *addr6; |
1276 | + struct neighbour *neigh; |
1277 | + int addr_type; |
1278 | |
1279 | - if (!skb_dst(skb)) |
1280 | - goto tx_err_link_failure; |
1281 | + if (!skb_dst(skb)) |
1282 | + goto tx_err_link_failure; |
1283 | |
1284 | - neigh = dst_neigh_lookup(skb_dst(skb), |
1285 | - &ipv6_hdr(skb)->daddr); |
1286 | - if (!neigh) |
1287 | - goto tx_err_link_failure; |
1288 | + neigh = dst_neigh_lookup(skb_dst(skb), |
1289 | + &ipv6_hdr(skb)->daddr); |
1290 | + if (!neigh) |
1291 | + goto tx_err_link_failure; |
1292 | |
1293 | - addr6 = (struct in6_addr *)&neigh->primary_key; |
1294 | - addr_type = ipv6_addr_type(addr6); |
1295 | + addr6 = (struct in6_addr *)&neigh->primary_key; |
1296 | + addr_type = ipv6_addr_type(addr6); |
1297 | |
1298 | - if (addr_type == IPV6_ADDR_ANY) |
1299 | - addr6 = &ipv6_hdr(skb)->daddr; |
1300 | + if (addr_type == IPV6_ADDR_ANY) |
1301 | + addr6 = &ipv6_hdr(skb)->daddr; |
1302 | |
1303 | - memcpy(&fl6->daddr, addr6, sizeof(fl6->daddr)); |
1304 | - neigh_release(neigh); |
1305 | + memcpy(&fl6->daddr, addr6, sizeof(fl6->daddr)); |
1306 | + neigh_release(neigh); |
1307 | + } |
1308 | } else if (!(t->parms.flags & |
1309 | (IP6_TNL_F_USE_ORIG_TCLASS | IP6_TNL_F_USE_ORIG_FWMARK))) { |
1310 | /* enable the cache only only if the routing decision does |
1311 | diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c |
1312 | index 7f4265b1649b..117405dd07a3 100644 |
1313 | --- a/net/ipv6/ip6mr.c |
1314 | +++ b/net/ipv6/ip6mr.c |
1315 | @@ -774,7 +774,8 @@ static struct net_device *ip6mr_reg_vif(struct net *net, struct mr6_table *mrt) |
1316 | * Delete a VIF entry |
1317 | */ |
1318 | |
1319 | -static int mif6_delete(struct mr6_table *mrt, int vifi, struct list_head *head) |
1320 | +static int mif6_delete(struct mr6_table *mrt, int vifi, int notify, |
1321 | + struct list_head *head) |
1322 | { |
1323 | struct mif_device *v; |
1324 | struct net_device *dev; |
1325 | @@ -820,7 +821,7 @@ static int mif6_delete(struct mr6_table *mrt, int vifi, struct list_head *head) |
1326 | dev->ifindex, &in6_dev->cnf); |
1327 | } |
1328 | |
1329 | - if (v->flags & MIFF_REGISTER) |
1330 | + if ((v->flags & MIFF_REGISTER) && !notify) |
1331 | unregister_netdevice_queue(dev, head); |
1332 | |
1333 | dev_put(dev); |
1334 | @@ -1331,7 +1332,6 @@ static int ip6mr_device_event(struct notifier_block *this, |
1335 | struct mr6_table *mrt; |
1336 | struct mif_device *v; |
1337 | int ct; |
1338 | - LIST_HEAD(list); |
1339 | |
1340 | if (event != NETDEV_UNREGISTER) |
1341 | return NOTIFY_DONE; |
1342 | @@ -1340,10 +1340,9 @@ static int ip6mr_device_event(struct notifier_block *this, |
1343 | v = &mrt->vif6_table[0]; |
1344 | for (ct = 0; ct < mrt->maxvif; ct++, v++) { |
1345 | if (v->dev == dev) |
1346 | - mif6_delete(mrt, ct, &list); |
1347 | + mif6_delete(mrt, ct, 1, NULL); |
1348 | } |
1349 | } |
1350 | - unregister_netdevice_many(&list); |
1351 | |
1352 | return NOTIFY_DONE; |
1353 | } |
1354 | @@ -1552,7 +1551,7 @@ static void mroute_clean_tables(struct mr6_table *mrt, bool all) |
1355 | for (i = 0; i < mrt->maxvif; i++) { |
1356 | if (!all && (mrt->vif6_table[i].flags & VIFF_STATIC)) |
1357 | continue; |
1358 | - mif6_delete(mrt, i, &list); |
1359 | + mif6_delete(mrt, i, 0, &list); |
1360 | } |
1361 | unregister_netdevice_many(&list); |
1362 | |
1363 | @@ -1706,7 +1705,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns |
1364 | if (copy_from_user(&mifi, optval, sizeof(mifi_t))) |
1365 | return -EFAULT; |
1366 | rtnl_lock(); |
1367 | - ret = mif6_delete(mrt, mifi, NULL); |
1368 | + ret = mif6_delete(mrt, mifi, 0, NULL); |
1369 | rtnl_unlock(); |
1370 | return ret; |
1371 | |
1372 | diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c |
1373 | index 869ffc76befa..ced3817539c2 100644 |
1374 | --- a/net/ipv6/raw.c |
1375 | +++ b/net/ipv6/raw.c |
1376 | @@ -1171,8 +1171,7 @@ static int rawv6_ioctl(struct sock *sk, int cmd, unsigned long arg) |
1377 | spin_lock_bh(&sk->sk_receive_queue.lock); |
1378 | skb = skb_peek(&sk->sk_receive_queue); |
1379 | if (skb) |
1380 | - amount = skb_tail_pointer(skb) - |
1381 | - skb_transport_header(skb); |
1382 | + amount = skb->len; |
1383 | spin_unlock_bh(&sk->sk_receive_queue.lock); |
1384 | return put_user(amount, (int __user *)arg); |
1385 | } |
1386 | diff --git a/net/ipv6/route.c b/net/ipv6/route.c |
1387 | index 8d6c09f082c2..9f1bc756799a 100644 |
1388 | --- a/net/ipv6/route.c |
1389 | +++ b/net/ipv6/route.c |
1390 | @@ -1826,6 +1826,10 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg) |
1391 | int addr_type; |
1392 | int err = -EINVAL; |
1393 | |
1394 | + /* RTF_PCPU is an internal flag; can not be set by userspace */ |
1395 | + if (cfg->fc_flags & RTF_PCPU) |
1396 | + goto out; |
1397 | + |
1398 | if (cfg->fc_dst_len > 128 || cfg->fc_src_len > 128) |
1399 | goto out; |
1400 | #ifndef CONFIG_IPV6_SUBTREES |
1401 | diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c |
1402 | index a646f3481240..fecad1098cf8 100644 |
1403 | --- a/net/kcm/kcmsock.c |
1404 | +++ b/net/kcm/kcmsock.c |
1405 | @@ -1685,7 +1685,7 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
1406 | struct kcm_attach info; |
1407 | |
1408 | if (copy_from_user(&info, (void __user *)arg, sizeof(info))) |
1409 | - err = -EFAULT; |
1410 | + return -EFAULT; |
1411 | |
1412 | err = kcm_attach_ioctl(sock, &info); |
1413 | |
1414 | @@ -1695,7 +1695,7 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
1415 | struct kcm_unattach info; |
1416 | |
1417 | if (copy_from_user(&info, (void __user *)arg, sizeof(info))) |
1418 | - err = -EFAULT; |
1419 | + return -EFAULT; |
1420 | |
1421 | err = kcm_unattach_ioctl(sock, &info); |
1422 | |
1423 | @@ -1706,7 +1706,7 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
1424 | struct socket *newsock = NULL; |
1425 | |
1426 | if (copy_from_user(&info, (void __user *)arg, sizeof(info))) |
1427 | - err = -EFAULT; |
1428 | + return -EFAULT; |
1429 | |
1430 | err = kcm_clone(sock, &info, &newsock); |
1431 | |
1432 | diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c |
1433 | index a2ed3bda4ddc..e702cb95b89b 100644 |
1434 | --- a/net/l2tp/l2tp_core.c |
1435 | +++ b/net/l2tp/l2tp_core.c |
1436 | @@ -278,7 +278,8 @@ struct l2tp_session *l2tp_session_find(struct net *net, struct l2tp_tunnel *tunn |
1437 | } |
1438 | EXPORT_SYMBOL_GPL(l2tp_session_find); |
1439 | |
1440 | -struct l2tp_session *l2tp_session_find_nth(struct l2tp_tunnel *tunnel, int nth) |
1441 | +struct l2tp_session *l2tp_session_get_nth(struct l2tp_tunnel *tunnel, int nth, |
1442 | + bool do_ref) |
1443 | { |
1444 | int hash; |
1445 | struct l2tp_session *session; |
1446 | @@ -288,6 +289,9 @@ struct l2tp_session *l2tp_session_find_nth(struct l2tp_tunnel *tunnel, int nth) |
1447 | for (hash = 0; hash < L2TP_HASH_SIZE; hash++) { |
1448 | hlist_for_each_entry(session, &tunnel->session_hlist[hash], hlist) { |
1449 | if (++count > nth) { |
1450 | + l2tp_session_inc_refcount(session); |
1451 | + if (do_ref && session->ref) |
1452 | + session->ref(session); |
1453 | read_unlock_bh(&tunnel->hlist_lock); |
1454 | return session; |
1455 | } |
1456 | @@ -298,7 +302,7 @@ struct l2tp_session *l2tp_session_find_nth(struct l2tp_tunnel *tunnel, int nth) |
1457 | |
1458 | return NULL; |
1459 | } |
1460 | -EXPORT_SYMBOL_GPL(l2tp_session_find_nth); |
1461 | +EXPORT_SYMBOL_GPL(l2tp_session_get_nth); |
1462 | |
1463 | /* Lookup a session by interface name. |
1464 | * This is very inefficient but is only used by management interfaces. |
1465 | diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h |
1466 | index 181e755c2fc4..e7233bad65e0 100644 |
1467 | --- a/net/l2tp/l2tp_core.h |
1468 | +++ b/net/l2tp/l2tp_core.h |
1469 | @@ -243,7 +243,8 @@ static inline struct l2tp_tunnel *l2tp_sock_to_tunnel(struct sock *sk) |
1470 | struct l2tp_session *l2tp_session_find(struct net *net, |
1471 | struct l2tp_tunnel *tunnel, |
1472 | u32 session_id); |
1473 | -struct l2tp_session *l2tp_session_find_nth(struct l2tp_tunnel *tunnel, int nth); |
1474 | +struct l2tp_session *l2tp_session_get_nth(struct l2tp_tunnel *tunnel, int nth, |
1475 | + bool do_ref); |
1476 | struct l2tp_session *l2tp_session_find_by_ifname(struct net *net, char *ifname); |
1477 | struct l2tp_tunnel *l2tp_tunnel_find(struct net *net, u32 tunnel_id); |
1478 | struct l2tp_tunnel *l2tp_tunnel_find_nth(struct net *net, int nth); |
1479 | diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c |
1480 | index 2d6760a2ae34..d100aed3d06f 100644 |
1481 | --- a/net/l2tp/l2tp_debugfs.c |
1482 | +++ b/net/l2tp/l2tp_debugfs.c |
1483 | @@ -53,7 +53,7 @@ static void l2tp_dfs_next_tunnel(struct l2tp_dfs_seq_data *pd) |
1484 | |
1485 | static void l2tp_dfs_next_session(struct l2tp_dfs_seq_data *pd) |
1486 | { |
1487 | - pd->session = l2tp_session_find_nth(pd->tunnel, pd->session_idx); |
1488 | + pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx, true); |
1489 | pd->session_idx++; |
1490 | |
1491 | if (pd->session == NULL) { |
1492 | @@ -238,10 +238,14 @@ static int l2tp_dfs_seq_show(struct seq_file *m, void *v) |
1493 | } |
1494 | |
1495 | /* Show the tunnel or session context */ |
1496 | - if (pd->session == NULL) |
1497 | + if (!pd->session) { |
1498 | l2tp_dfs_seq_tunnel_show(m, pd->tunnel); |
1499 | - else |
1500 | + } else { |
1501 | l2tp_dfs_seq_session_show(m, pd->session); |
1502 | + if (pd->session->deref) |
1503 | + pd->session->deref(pd->session); |
1504 | + l2tp_session_dec_refcount(pd->session); |
1505 | + } |
1506 | |
1507 | out: |
1508 | return 0; |
1509 | diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c |
1510 | index ff750bb334fa..20669537816e 100644 |
1511 | --- a/net/l2tp/l2tp_ip.c |
1512 | +++ b/net/l2tp/l2tp_ip.c |
1513 | @@ -178,9 +178,10 @@ static int l2tp_ip_recv(struct sk_buff *skb) |
1514 | |
1515 | tunnel_id = ntohl(*(__be32 *) &skb->data[4]); |
1516 | tunnel = l2tp_tunnel_find(net, tunnel_id); |
1517 | - if (tunnel != NULL) |
1518 | + if (tunnel) { |
1519 | sk = tunnel->sock; |
1520 | - else { |
1521 | + sock_hold(sk); |
1522 | + } else { |
1523 | struct iphdr *iph = (struct iphdr *) skb_network_header(skb); |
1524 | |
1525 | read_lock_bh(&l2tp_ip_lock); |
1526 | diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c |
1527 | index 1a65c9a517b6..a4b0c9232bf1 100644 |
1528 | --- a/net/l2tp/l2tp_ip6.c |
1529 | +++ b/net/l2tp/l2tp_ip6.c |
1530 | @@ -191,9 +191,10 @@ static int l2tp_ip6_recv(struct sk_buff *skb) |
1531 | |
1532 | tunnel_id = ntohl(*(__be32 *) &skb->data[4]); |
1533 | tunnel = l2tp_tunnel_find(net, tunnel_id); |
1534 | - if (tunnel != NULL) |
1535 | + if (tunnel) { |
1536 | sk = tunnel->sock; |
1537 | - else { |
1538 | + sock_hold(sk); |
1539 | + } else { |
1540 | struct ipv6hdr *iph = ipv6_hdr(skb); |
1541 | |
1542 | read_lock_bh(&l2tp_ip6_lock); |
1543 | diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c |
1544 | index bf3117771822..9f66272b163b 100644 |
1545 | --- a/net/l2tp/l2tp_netlink.c |
1546 | +++ b/net/l2tp/l2tp_netlink.c |
1547 | @@ -844,7 +844,7 @@ static int l2tp_nl_cmd_session_dump(struct sk_buff *skb, struct netlink_callback |
1548 | goto out; |
1549 | } |
1550 | |
1551 | - session = l2tp_session_find_nth(tunnel, si); |
1552 | + session = l2tp_session_get_nth(tunnel, si, false); |
1553 | if (session == NULL) { |
1554 | ti++; |
1555 | tunnel = NULL; |
1556 | @@ -854,8 +854,11 @@ static int l2tp_nl_cmd_session_dump(struct sk_buff *skb, struct netlink_callback |
1557 | |
1558 | if (l2tp_nl_session_send(skb, NETLINK_CB(cb->skb).portid, |
1559 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
1560 | - session, L2TP_CMD_SESSION_GET) < 0) |
1561 | + session, L2TP_CMD_SESSION_GET) < 0) { |
1562 | + l2tp_session_dec_refcount(session); |
1563 | break; |
1564 | + } |
1565 | + l2tp_session_dec_refcount(session); |
1566 | |
1567 | si++; |
1568 | } |
1569 | diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c |
1570 | index 41d47bfda15c..1387f547a09e 100644 |
1571 | --- a/net/l2tp/l2tp_ppp.c |
1572 | +++ b/net/l2tp/l2tp_ppp.c |
1573 | @@ -450,6 +450,10 @@ static void pppol2tp_session_close(struct l2tp_session *session) |
1574 | static void pppol2tp_session_destruct(struct sock *sk) |
1575 | { |
1576 | struct l2tp_session *session = sk->sk_user_data; |
1577 | + |
1578 | + skb_queue_purge(&sk->sk_receive_queue); |
1579 | + skb_queue_purge(&sk->sk_write_queue); |
1580 | + |
1581 | if (session) { |
1582 | sk->sk_user_data = NULL; |
1583 | BUG_ON(session->magic != L2TP_SESSION_MAGIC); |
1584 | @@ -488,9 +492,6 @@ static int pppol2tp_release(struct socket *sock) |
1585 | l2tp_session_queue_purge(session); |
1586 | sock_put(sk); |
1587 | } |
1588 | - skb_queue_purge(&sk->sk_receive_queue); |
1589 | - skb_queue_purge(&sk->sk_write_queue); |
1590 | - |
1591 | release_sock(sk); |
1592 | |
1593 | /* This will delete the session context via |
1594 | @@ -1554,7 +1555,7 @@ static void pppol2tp_next_tunnel(struct net *net, struct pppol2tp_seq_data *pd) |
1595 | |
1596 | static void pppol2tp_next_session(struct net *net, struct pppol2tp_seq_data *pd) |
1597 | { |
1598 | - pd->session = l2tp_session_find_nth(pd->tunnel, pd->session_idx); |
1599 | + pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx, true); |
1600 | pd->session_idx++; |
1601 | |
1602 | if (pd->session == NULL) { |
1603 | @@ -1681,10 +1682,14 @@ static int pppol2tp_seq_show(struct seq_file *m, void *v) |
1604 | |
1605 | /* Show the tunnel or session context. |
1606 | */ |
1607 | - if (pd->session == NULL) |
1608 | + if (!pd->session) { |
1609 | pppol2tp_seq_tunnel_show(m, pd->tunnel); |
1610 | - else |
1611 | + } else { |
1612 | pppol2tp_seq_session_show(m, pd->session); |
1613 | + if (pd->session->deref) |
1614 | + pd->session->deref(pd->session); |
1615 | + l2tp_session_dec_refcount(pd->session); |
1616 | + } |
1617 | |
1618 | out: |
1619 | return 0; |
1620 | @@ -1843,4 +1848,4 @@ MODULE_DESCRIPTION("PPP over L2TP over UDP"); |
1621 | MODULE_LICENSE("GPL"); |
1622 | MODULE_VERSION(PPPOL2TP_DRV_VERSION); |
1623 | MODULE_ALIAS_NET_PF_PROTO(PF_PPPOX, PX_PROTO_OL2TP); |
1624 | -MODULE_ALIAS_L2TP_PWTYPE(11); |
1625 | +MODULE_ALIAS_L2TP_PWTYPE(7); |
1626 | diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c |
1627 | index 8ab0974f4ee2..cb76ff3088e9 100644 |
1628 | --- a/net/packet/af_packet.c |
1629 | +++ b/net/packet/af_packet.c |
1630 | @@ -3702,6 +3702,8 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv |
1631 | return -EBUSY; |
1632 | if (copy_from_user(&val, optval, sizeof(val))) |
1633 | return -EFAULT; |
1634 | + if (val > INT_MAX) |
1635 | + return -EINVAL; |
1636 | po->tp_reserve = val; |
1637 | return 0; |
1638 | } |
1639 | @@ -4247,6 +4249,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, |
1640 | rb->frames_per_block = req->tp_block_size / req->tp_frame_size; |
1641 | if (unlikely(rb->frames_per_block == 0)) |
1642 | goto out; |
1643 | + if (unlikely(req->tp_block_size > UINT_MAX / req->tp_block_nr)) |
1644 | + goto out; |
1645 | if (unlikely((rb->frames_per_block * req->tp_block_nr) != |
1646 | req->tp_frame_nr)) |
1647 | goto out; |
1648 | diff --git a/net/sctp/socket.c b/net/sctp/socket.c |
1649 | index 673442025bfd..14346dccc4fe 100644 |
1650 | --- a/net/sctp/socket.c |
1651 | +++ b/net/sctp/socket.c |
1652 | @@ -6861,6 +6861,9 @@ int sctp_inet_listen(struct socket *sock, int backlog) |
1653 | if (sock->state != SS_UNCONNECTED) |
1654 | goto out; |
1655 | |
1656 | + if (!sctp_sstate(sk, LISTENING) && !sctp_sstate(sk, CLOSED)) |
1657 | + goto out; |
1658 | + |
1659 | /* If backlog is zero, disable listening. */ |
1660 | if (!backlog) { |
1661 | if (sctp_sstate(sk, CLOSED)) |
1662 | diff --git a/sound/core/seq/seq_lock.c b/sound/core/seq/seq_lock.c |
1663 | index 3b693e924db7..12ba83367b1b 100644 |
1664 | --- a/sound/core/seq/seq_lock.c |
1665 | +++ b/sound/core/seq/seq_lock.c |
1666 | @@ -28,19 +28,16 @@ |
1667 | /* wait until all locks are released */ |
1668 | void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line) |
1669 | { |
1670 | - int max_count = 5 * HZ; |
1671 | + int warn_count = 5 * HZ; |
1672 | |
1673 | if (atomic_read(lockp) < 0) { |
1674 | pr_warn("ALSA: seq_lock: lock trouble [counter = %d] in %s:%d\n", atomic_read(lockp), file, line); |
1675 | return; |
1676 | } |
1677 | while (atomic_read(lockp) > 0) { |
1678 | - if (max_count == 0) { |
1679 | - pr_warn("ALSA: seq_lock: timeout [%d left] in %s:%d\n", atomic_read(lockp), file, line); |
1680 | - break; |
1681 | - } |
1682 | + if (warn_count-- == 0) |
1683 | + pr_warn("ALSA: seq_lock: waiting [%d left] in %s:%d\n", atomic_read(lockp), file, line); |
1684 | schedule_timeout_uninterruptible(1); |
1685 | - max_count--; |
1686 | } |
1687 | } |
1688 | |
1689 | diff --git a/sound/firewire/lib.h b/sound/firewire/lib.h |
1690 | index f6769312ebfc..c3768cd494a5 100644 |
1691 | --- a/sound/firewire/lib.h |
1692 | +++ b/sound/firewire/lib.h |
1693 | @@ -45,7 +45,7 @@ struct snd_fw_async_midi_port { |
1694 | |
1695 | struct snd_rawmidi_substream *substream; |
1696 | snd_fw_async_midi_port_fill fill; |
1697 | - unsigned int consume_bytes; |
1698 | + int consume_bytes; |
1699 | }; |
1700 | |
1701 | int snd_fw_async_midi_port_init(struct snd_fw_async_midi_port *port, |
1702 | diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c |
1703 | index e629b88f7d93..474b06d8acd1 100644 |
1704 | --- a/sound/firewire/oxfw/oxfw.c |
1705 | +++ b/sound/firewire/oxfw/oxfw.c |
1706 | @@ -226,11 +226,11 @@ static void do_registration(struct work_struct *work) |
1707 | if (err < 0) |
1708 | goto error; |
1709 | |
1710 | - err = detect_quirks(oxfw); |
1711 | + err = snd_oxfw_stream_discover(oxfw); |
1712 | if (err < 0) |
1713 | goto error; |
1714 | |
1715 | - err = snd_oxfw_stream_discover(oxfw); |
1716 | + err = detect_quirks(oxfw); |
1717 | if (err < 0) |
1718 | goto error; |
1719 | |
1720 | diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c |
1721 | index 4c8ff298ad26..d5873eeae1aa 100644 |
1722 | --- a/sound/soc/intel/boards/bytcr_rt5640.c |
1723 | +++ b/sound/soc/intel/boards/bytcr_rt5640.c |
1724 | @@ -621,7 +621,7 @@ static struct snd_soc_dai_link byt_rt5640_dais[] = { |
1725 | .codec_dai_name = "snd-soc-dummy-dai", |
1726 | .codec_name = "snd-soc-dummy", |
1727 | .platform_name = "sst-mfld-platform", |
1728 | - .ignore_suspend = 1, |
1729 | + .nonatomic = true, |
1730 | .dynamic = 1, |
1731 | .dpcm_playback = 1, |
1732 | .dpcm_capture = 1, |
1733 | @@ -634,7 +634,6 @@ static struct snd_soc_dai_link byt_rt5640_dais[] = { |
1734 | .codec_dai_name = "snd-soc-dummy-dai", |
1735 | .codec_name = "snd-soc-dummy", |
1736 | .platform_name = "sst-mfld-platform", |
1737 | - .ignore_suspend = 1, |
1738 | .nonatomic = true, |
1739 | .dynamic = 1, |
1740 | .dpcm_playback = 1, |
1741 | @@ -661,6 +660,7 @@ static struct snd_soc_dai_link byt_rt5640_dais[] = { |
1742 | | SND_SOC_DAIFMT_CBS_CFS, |
1743 | .be_hw_params_fixup = byt_rt5640_codec_fixup, |
1744 | .ignore_suspend = 1, |
1745 | + .nonatomic = true, |
1746 | .dpcm_playback = 1, |
1747 | .dpcm_capture = 1, |
1748 | .init = byt_rt5640_init, |
1749 | diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c |
1750 | index 35f591eab3c9..eabff3a857d0 100644 |
1751 | --- a/sound/soc/intel/boards/bytcr_rt5651.c |
1752 | +++ b/sound/soc/intel/boards/bytcr_rt5651.c |
1753 | @@ -235,7 +235,6 @@ static struct snd_soc_dai_link byt_rt5651_dais[] = { |
1754 | .codec_dai_name = "snd-soc-dummy-dai", |
1755 | .codec_name = "snd-soc-dummy", |
1756 | .platform_name = "sst-mfld-platform", |
1757 | - .ignore_suspend = 1, |
1758 | .nonatomic = true, |
1759 | .dynamic = 1, |
1760 | .dpcm_playback = 1, |
1761 | @@ -249,7 +248,6 @@ static struct snd_soc_dai_link byt_rt5651_dais[] = { |
1762 | .codec_dai_name = "snd-soc-dummy-dai", |
1763 | .codec_name = "snd-soc-dummy", |
1764 | .platform_name = "sst-mfld-platform", |
1765 | - .ignore_suspend = 1, |
1766 | .nonatomic = true, |
1767 | .dynamic = 1, |
1768 | .dpcm_playback = 1, |