Contents of /trunk/kernel-alx/patches-4.19/0119-4.19.20-all-fixes.patch
Parent Directory | Revision Log
Revision 3398 -
(show annotations)
(download)
Fri Aug 2 11:47:32 2019 UTC (5 years, 1 month ago) by niro
File size: 105175 byte(s)
Fri Aug 2 11:47:32 2019 UTC (5 years, 1 month ago) by niro
File size: 105175 byte(s)
-linux-4.19.20
1 | diff --git a/Makefile b/Makefile |
2 | index 39c4e7c3c13c..f1859811dca1 100644 |
3 | --- a/Makefile |
4 | +++ b/Makefile |
5 | @@ -1,7 +1,7 @@ |
6 | # SPDX-License-Identifier: GPL-2.0 |
7 | VERSION = 4 |
8 | PATCHLEVEL = 19 |
9 | -SUBLEVEL = 19 |
10 | +SUBLEVEL = 20 |
11 | EXTRAVERSION = |
12 | NAME = "People's Front" |
13 | |
14 | diff --git a/arch/arm/mach-cns3xxx/pcie.c b/arch/arm/mach-cns3xxx/pcie.c |
15 | index 318394ed5c7a..5e11ad3164e0 100644 |
16 | --- a/arch/arm/mach-cns3xxx/pcie.c |
17 | +++ b/arch/arm/mach-cns3xxx/pcie.c |
18 | @@ -83,7 +83,7 @@ static void __iomem *cns3xxx_pci_map_bus(struct pci_bus *bus, |
19 | } else /* remote PCI bus */ |
20 | base = cnspci->cfg1_regs + ((busno & 0xf) << 20); |
21 | |
22 | - return base + (where & 0xffc) + (devfn << 12); |
23 | + return base + where + (devfn << 12); |
24 | } |
25 | |
26 | static int cns3xxx_pci_read_config(struct pci_bus *bus, unsigned int devfn, |
27 | diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c |
28 | index 29cdc99688f3..9859e1178e6b 100644 |
29 | --- a/arch/arm64/kernel/hibernate.c |
30 | +++ b/arch/arm64/kernel/hibernate.c |
31 | @@ -299,8 +299,10 @@ int swsusp_arch_suspend(void) |
32 | dcache_clean_range(__idmap_text_start, __idmap_text_end); |
33 | |
34 | /* Clean kvm setup code to PoC? */ |
35 | - if (el2_reset_needed()) |
36 | + if (el2_reset_needed()) { |
37 | dcache_clean_range(__hyp_idmap_text_start, __hyp_idmap_text_end); |
38 | + dcache_clean_range(__hyp_text_start, __hyp_text_end); |
39 | + } |
40 | |
41 | /* make the crash dump kernel image protected again */ |
42 | crash_post_resume(); |
43 | diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S |
44 | index e1261fbaa374..17f325ba831e 100644 |
45 | --- a/arch/arm64/kernel/hyp-stub.S |
46 | +++ b/arch/arm64/kernel/hyp-stub.S |
47 | @@ -28,6 +28,8 @@ |
48 | #include <asm/virt.h> |
49 | |
50 | .text |
51 | + .pushsection .hyp.text, "ax" |
52 | + |
53 | .align 11 |
54 | |
55 | ENTRY(__hyp_stub_vectors) |
56 | diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c |
57 | index ba6b41790fcd..b09b6f75f759 100644 |
58 | --- a/arch/arm64/kernel/kaslr.c |
59 | +++ b/arch/arm64/kernel/kaslr.c |
60 | @@ -88,6 +88,7 @@ u64 __init kaslr_early_init(u64 dt_phys) |
61 | * we end up running with module randomization disabled. |
62 | */ |
63 | module_alloc_base = (u64)_etext - MODULES_VSIZE; |
64 | + __flush_dcache_area(&module_alloc_base, sizeof(module_alloc_base)); |
65 | |
66 | /* |
67 | * Try to map the FDT early. If this fails, we simply bail, |
68 | diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c |
69 | index 30695a868107..5c9073bace83 100644 |
70 | --- a/arch/arm64/mm/flush.c |
71 | +++ b/arch/arm64/mm/flush.c |
72 | @@ -33,7 +33,11 @@ void sync_icache_aliases(void *kaddr, unsigned long len) |
73 | __clean_dcache_area_pou(kaddr, len); |
74 | __flush_icache_all(); |
75 | } else { |
76 | - flush_icache_range(addr, addr + len); |
77 | + /* |
78 | + * Don't issue kick_all_cpus_sync() after I-cache invalidation |
79 | + * for user mappings. |
80 | + */ |
81 | + __flush_icache_range(addr, addr + len); |
82 | } |
83 | } |
84 | |
85 | diff --git a/drivers/gpio/gpio-altera-a10sr.c b/drivers/gpio/gpio-altera-a10sr.c |
86 | index 6b11f1314248..7f9e0304b510 100644 |
87 | --- a/drivers/gpio/gpio-altera-a10sr.c |
88 | +++ b/drivers/gpio/gpio-altera-a10sr.c |
89 | @@ -66,8 +66,10 @@ static int altr_a10sr_gpio_direction_input(struct gpio_chip *gc, |
90 | static int altr_a10sr_gpio_direction_output(struct gpio_chip *gc, |
91 | unsigned int nr, int value) |
92 | { |
93 | - if (nr <= (ALTR_A10SR_OUT_VALID_RANGE_HI - ALTR_A10SR_LED_VALID_SHIFT)) |
94 | + if (nr <= (ALTR_A10SR_OUT_VALID_RANGE_HI - ALTR_A10SR_LED_VALID_SHIFT)) { |
95 | + altr_a10sr_gpio_set(gc, nr, value); |
96 | return 0; |
97 | + } |
98 | return -EINVAL; |
99 | } |
100 | |
101 | diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c |
102 | index e0d6a0a7bc69..e41223c05f6e 100644 |
103 | --- a/drivers/gpio/gpio-eic-sprd.c |
104 | +++ b/drivers/gpio/gpio-eic-sprd.c |
105 | @@ -180,7 +180,18 @@ static void sprd_eic_free(struct gpio_chip *chip, unsigned int offset) |
106 | |
107 | static int sprd_eic_get(struct gpio_chip *chip, unsigned int offset) |
108 | { |
109 | - return sprd_eic_read(chip, offset, SPRD_EIC_DBNC_DATA); |
110 | + struct sprd_eic *sprd_eic = gpiochip_get_data(chip); |
111 | + |
112 | + switch (sprd_eic->type) { |
113 | + case SPRD_EIC_DEBOUNCE: |
114 | + return sprd_eic_read(chip, offset, SPRD_EIC_DBNC_DATA); |
115 | + case SPRD_EIC_ASYNC: |
116 | + return sprd_eic_read(chip, offset, SPRD_EIC_ASYNC_DATA); |
117 | + case SPRD_EIC_SYNC: |
118 | + return sprd_eic_read(chip, offset, SPRD_EIC_SYNC_DATA); |
119 | + default: |
120 | + return -ENOTSUPP; |
121 | + } |
122 | } |
123 | |
124 | static int sprd_eic_direction_input(struct gpio_chip *chip, unsigned int offset) |
125 | @@ -368,6 +379,7 @@ static int sprd_eic_irq_set_type(struct irq_data *data, unsigned int flow_type) |
126 | irq_set_handler_locked(data, handle_edge_irq); |
127 | break; |
128 | case IRQ_TYPE_EDGE_BOTH: |
129 | + sprd_eic_update(chip, offset, SPRD_EIC_ASYNC_INTMODE, 0); |
130 | sprd_eic_update(chip, offset, SPRD_EIC_ASYNC_INTBOTH, 1); |
131 | irq_set_handler_locked(data, handle_edge_irq); |
132 | break; |
133 | diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c |
134 | index adf72dda25a2..68a35b65925a 100644 |
135 | --- a/drivers/gpio/gpio-pcf857x.c |
136 | +++ b/drivers/gpio/gpio-pcf857x.c |
137 | @@ -84,6 +84,7 @@ MODULE_DEVICE_TABLE(of, pcf857x_of_table); |
138 | */ |
139 | struct pcf857x { |
140 | struct gpio_chip chip; |
141 | + struct irq_chip irqchip; |
142 | struct i2c_client *client; |
143 | struct mutex lock; /* protect 'out' */ |
144 | unsigned out; /* software latch */ |
145 | @@ -252,18 +253,6 @@ static void pcf857x_irq_bus_sync_unlock(struct irq_data *data) |
146 | mutex_unlock(&gpio->lock); |
147 | } |
148 | |
149 | -static struct irq_chip pcf857x_irq_chip = { |
150 | - .name = "pcf857x", |
151 | - .irq_enable = pcf857x_irq_enable, |
152 | - .irq_disable = pcf857x_irq_disable, |
153 | - .irq_ack = noop, |
154 | - .irq_mask = noop, |
155 | - .irq_unmask = noop, |
156 | - .irq_set_wake = pcf857x_irq_set_wake, |
157 | - .irq_bus_lock = pcf857x_irq_bus_lock, |
158 | - .irq_bus_sync_unlock = pcf857x_irq_bus_sync_unlock, |
159 | -}; |
160 | - |
161 | /*-------------------------------------------------------------------------*/ |
162 | |
163 | static int pcf857x_probe(struct i2c_client *client, |
164 | @@ -376,8 +365,17 @@ static int pcf857x_probe(struct i2c_client *client, |
165 | |
166 | /* Enable irqchip if we have an interrupt */ |
167 | if (client->irq) { |
168 | + gpio->irqchip.name = "pcf857x", |
169 | + gpio->irqchip.irq_enable = pcf857x_irq_enable, |
170 | + gpio->irqchip.irq_disable = pcf857x_irq_disable, |
171 | + gpio->irqchip.irq_ack = noop, |
172 | + gpio->irqchip.irq_mask = noop, |
173 | + gpio->irqchip.irq_unmask = noop, |
174 | + gpio->irqchip.irq_set_wake = pcf857x_irq_set_wake, |
175 | + gpio->irqchip.irq_bus_lock = pcf857x_irq_bus_lock, |
176 | + gpio->irqchip.irq_bus_sync_unlock = pcf857x_irq_bus_sync_unlock, |
177 | status = gpiochip_irqchip_add_nested(&gpio->chip, |
178 | - &pcf857x_irq_chip, |
179 | + &gpio->irqchip, |
180 | 0, handle_level_irq, |
181 | IRQ_TYPE_NONE); |
182 | if (status) { |
183 | @@ -392,7 +390,7 @@ static int pcf857x_probe(struct i2c_client *client, |
184 | if (status) |
185 | goto fail; |
186 | |
187 | - gpiochip_set_nested_irqchip(&gpio->chip, &pcf857x_irq_chip, |
188 | + gpiochip_set_nested_irqchip(&gpio->chip, &gpio->irqchip, |
189 | client->irq); |
190 | gpio->irq_parent = client->irq; |
191 | } |
192 | diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c |
193 | index a8e01d99919c..b3ab6c428423 100644 |
194 | --- a/drivers/gpio/gpiolib.c |
195 | +++ b/drivers/gpio/gpiolib.c |
196 | @@ -817,7 +817,15 @@ static irqreturn_t lineevent_irq_thread(int irq, void *p) |
197 | /* Do not leak kernel stack to userspace */ |
198 | memset(&ge, 0, sizeof(ge)); |
199 | |
200 | - ge.timestamp = le->timestamp; |
201 | + /* |
202 | + * We may be running from a nested threaded interrupt in which case |
203 | + * we didn't get the timestamp from lineevent_irq_handler(). |
204 | + */ |
205 | + if (!le->timestamp) |
206 | + ge.timestamp = ktime_get_real_ns(); |
207 | + else |
208 | + ge.timestamp = le->timestamp; |
209 | + |
210 | level = gpiod_get_value_cansleep(le->desc); |
211 | |
212 | if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE |
213 | diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h |
214 | index 9122ee6e55e4..1fe93920fb25 100644 |
215 | --- a/drivers/gpu/drm/msm/msm_gpu.h |
216 | +++ b/drivers/gpu/drm/msm/msm_gpu.h |
217 | @@ -63,7 +63,7 @@ struct msm_gpu_funcs { |
218 | struct msm_ringbuffer *(*active_ring)(struct msm_gpu *gpu); |
219 | void (*recover)(struct msm_gpu *gpu); |
220 | void (*destroy)(struct msm_gpu *gpu); |
221 | -#ifdef CONFIG_DEBUG_FS |
222 | +#if defined(CONFIG_DEBUG_FS) || defined(CONFIG_DEV_COREDUMP) |
223 | /* show GPU status in debugfs: */ |
224 | void (*show)(struct msm_gpu *gpu, struct msm_gpu_state *state, |
225 | struct drm_printer *p); |
226 | diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c |
227 | index 1fc75647e47b..34ffca618427 100644 |
228 | --- a/drivers/infiniband/hw/hfi1/file_ops.c |
229 | +++ b/drivers/infiniband/hw/hfi1/file_ops.c |
230 | @@ -488,7 +488,7 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma) |
231 | vmf = 1; |
232 | break; |
233 | case STATUS: |
234 | - if (flags & (unsigned long)(VM_WRITE | VM_EXEC)) { |
235 | + if (flags & VM_WRITE) { |
236 | ret = -EPERM; |
237 | goto done; |
238 | } |
239 | diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c |
240 | index 4339177629e3..2b8f5ebae821 100644 |
241 | --- a/drivers/iommu/intel-iommu.c |
242 | +++ b/drivers/iommu/intel-iommu.c |
243 | @@ -5230,7 +5230,7 @@ static void intel_iommu_put_resv_regions(struct device *dev, |
244 | struct iommu_resv_region *entry, *next; |
245 | |
246 | list_for_each_entry_safe(entry, next, head, list) { |
247 | - if (entry->type == IOMMU_RESV_RESERVED) |
248 | + if (entry->type == IOMMU_RESV_MSI) |
249 | kfree(entry); |
250 | } |
251 | } |
252 | diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c |
253 | index e6e925add700..6518b012756f 100644 |
254 | --- a/drivers/md/raid5-cache.c |
255 | +++ b/drivers/md/raid5-cache.c |
256 | @@ -1935,12 +1935,14 @@ out: |
257 | } |
258 | |
259 | static struct stripe_head * |
260 | -r5c_recovery_alloc_stripe(struct r5conf *conf, |
261 | - sector_t stripe_sect) |
262 | +r5c_recovery_alloc_stripe( |
263 | + struct r5conf *conf, |
264 | + sector_t stripe_sect, |
265 | + int noblock) |
266 | { |
267 | struct stripe_head *sh; |
268 | |
269 | - sh = raid5_get_active_stripe(conf, stripe_sect, 0, 1, 0); |
270 | + sh = raid5_get_active_stripe(conf, stripe_sect, 0, noblock, 0); |
271 | if (!sh) |
272 | return NULL; /* no more stripe available */ |
273 | |
274 | @@ -2150,7 +2152,7 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log, |
275 | stripe_sect); |
276 | |
277 | if (!sh) { |
278 | - sh = r5c_recovery_alloc_stripe(conf, stripe_sect); |
279 | + sh = r5c_recovery_alloc_stripe(conf, stripe_sect, 1); |
280 | /* |
281 | * cannot get stripe from raid5_get_active_stripe |
282 | * try replay some stripes |
283 | @@ -2159,20 +2161,29 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log, |
284 | r5c_recovery_replay_stripes( |
285 | cached_stripe_list, ctx); |
286 | sh = r5c_recovery_alloc_stripe( |
287 | - conf, stripe_sect); |
288 | + conf, stripe_sect, 1); |
289 | } |
290 | if (!sh) { |
291 | + int new_size = conf->min_nr_stripes * 2; |
292 | pr_debug("md/raid:%s: Increasing stripe cache size to %d to recovery data on journal.\n", |
293 | mdname(mddev), |
294 | - conf->min_nr_stripes * 2); |
295 | - raid5_set_cache_size(mddev, |
296 | - conf->min_nr_stripes * 2); |
297 | - sh = r5c_recovery_alloc_stripe(conf, |
298 | - stripe_sect); |
299 | + new_size); |
300 | + ret = raid5_set_cache_size(mddev, new_size); |
301 | + if (conf->min_nr_stripes <= new_size / 2) { |
302 | + pr_err("md/raid:%s: Cannot increase cache size, ret=%d, new_size=%d, min_nr_stripes=%d, max_nr_stripes=%d\n", |
303 | + mdname(mddev), |
304 | + ret, |
305 | + new_size, |
306 | + conf->min_nr_stripes, |
307 | + conf->max_nr_stripes); |
308 | + return -ENOMEM; |
309 | + } |
310 | + sh = r5c_recovery_alloc_stripe( |
311 | + conf, stripe_sect, 0); |
312 | } |
313 | if (!sh) { |
314 | pr_err("md/raid:%s: Cannot get enough stripes due to memory pressure. Recovery failed.\n", |
315 | - mdname(mddev)); |
316 | + mdname(mddev)); |
317 | return -ENOMEM; |
318 | } |
319 | list_add_tail(&sh->lru, cached_stripe_list); |
320 | diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c |
321 | index e4e98f47865d..45a3551d3afd 100644 |
322 | --- a/drivers/md/raid5.c |
323 | +++ b/drivers/md/raid5.c |
324 | @@ -6357,6 +6357,7 @@ raid5_show_stripe_cache_size(struct mddev *mddev, char *page) |
325 | int |
326 | raid5_set_cache_size(struct mddev *mddev, int size) |
327 | { |
328 | + int result = 0; |
329 | struct r5conf *conf = mddev->private; |
330 | |
331 | if (size <= 16 || size > 32768) |
332 | @@ -6373,11 +6374,14 @@ raid5_set_cache_size(struct mddev *mddev, int size) |
333 | |
334 | mutex_lock(&conf->cache_size_mutex); |
335 | while (size > conf->max_nr_stripes) |
336 | - if (!grow_one_stripe(conf, GFP_KERNEL)) |
337 | + if (!grow_one_stripe(conf, GFP_KERNEL)) { |
338 | + conf->min_nr_stripes = conf->max_nr_stripes; |
339 | + result = -ENOMEM; |
340 | break; |
341 | + } |
342 | mutex_unlock(&conf->cache_size_mutex); |
343 | |
344 | - return 0; |
345 | + return result; |
346 | } |
347 | EXPORT_SYMBOL(raid5_set_cache_size); |
348 | |
349 | diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c |
350 | index 768972af8b85..0d3b7473bc21 100644 |
351 | --- a/drivers/mmc/host/bcm2835.c |
352 | +++ b/drivers/mmc/host/bcm2835.c |
353 | @@ -1427,6 +1427,8 @@ static int bcm2835_probe(struct platform_device *pdev) |
354 | |
355 | err: |
356 | dev_dbg(dev, "%s -> err %d\n", __func__, ret); |
357 | + if (host->dma_chan_rxtx) |
358 | + dma_release_channel(host->dma_chan_rxtx); |
359 | mmc_free_host(mmc); |
360 | |
361 | return ret; |
362 | diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c |
363 | index 04841386b65d..f171cce5197d 100644 |
364 | --- a/drivers/mmc/host/mtk-sd.c |
365 | +++ b/drivers/mmc/host/mtk-sd.c |
366 | @@ -784,7 +784,7 @@ static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u32 hz) |
367 | |
368 | if (timing == MMC_TIMING_MMC_HS400 && |
369 | host->dev_comp->hs400_tune) |
370 | - sdr_set_field(host->base + PAD_CMD_TUNE, |
371 | + sdr_set_field(host->base + tune_reg, |
372 | MSDC_PAD_TUNE_CMDRRDLY, |
373 | host->hs400_cmd_int_delay); |
374 | dev_dbg(host->dev, "sclk: %d, timing: %d\n", host->sclk, timing); |
375 | diff --git a/drivers/mmc/host/sdhci-iproc.c b/drivers/mmc/host/sdhci-iproc.c |
376 | index d0e83db42ae5..94eeed2a1b53 100644 |
377 | --- a/drivers/mmc/host/sdhci-iproc.c |
378 | +++ b/drivers/mmc/host/sdhci-iproc.c |
379 | @@ -279,7 +279,10 @@ static int sdhci_iproc_probe(struct platform_device *pdev) |
380 | |
381 | iproc_host->data = iproc_data; |
382 | |
383 | - mmc_of_parse(host->mmc); |
384 | + ret = mmc_of_parse(host->mmc); |
385 | + if (ret) |
386 | + goto err; |
387 | + |
388 | sdhci_get_of_property(pdev); |
389 | |
390 | host->mmc->caps |= iproc_host->data->mmc_caps; |
391 | diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c |
392 | index 22a817da861e..1e2b53a934fb 100644 |
393 | --- a/drivers/net/ethernet/freescale/ucc_geth.c |
394 | +++ b/drivers/net/ethernet/freescale/ucc_geth.c |
395 | @@ -1888,6 +1888,8 @@ static void ucc_geth_free_tx(struct ucc_geth_private *ugeth) |
396 | u16 i, j; |
397 | u8 __iomem *bd; |
398 | |
399 | + netdev_reset_queue(ugeth->ndev); |
400 | + |
401 | ug_info = ugeth->ug_info; |
402 | uf_info = &ug_info->uf_info; |
403 | |
404 | diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c |
405 | index babcfd9c0571..75213046563c 100644 |
406 | --- a/drivers/net/ethernet/mellanox/mlx4/fw.c |
407 | +++ b/drivers/net/ethernet/mellanox/mlx4/fw.c |
408 | @@ -2064,9 +2064,11 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev, |
409 | { |
410 | struct mlx4_cmd_mailbox *mailbox; |
411 | __be32 *outbox; |
412 | + u64 qword_field; |
413 | u32 dword_field; |
414 | - int err; |
415 | + u16 word_field; |
416 | u8 byte_field; |
417 | + int err; |
418 | static const u8 a0_dmfs_query_hw_steering[] = { |
419 | [0] = MLX4_STEERING_DMFS_A0_DEFAULT, |
420 | [1] = MLX4_STEERING_DMFS_A0_DYNAMIC, |
421 | @@ -2094,19 +2096,32 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev, |
422 | |
423 | /* QPC/EEC/CQC/EQC/RDMARC attributes */ |
424 | |
425 | - MLX4_GET(param->qpc_base, outbox, INIT_HCA_QPC_BASE_OFFSET); |
426 | - MLX4_GET(param->log_num_qps, outbox, INIT_HCA_LOG_QP_OFFSET); |
427 | - MLX4_GET(param->srqc_base, outbox, INIT_HCA_SRQC_BASE_OFFSET); |
428 | - MLX4_GET(param->log_num_srqs, outbox, INIT_HCA_LOG_SRQ_OFFSET); |
429 | - MLX4_GET(param->cqc_base, outbox, INIT_HCA_CQC_BASE_OFFSET); |
430 | - MLX4_GET(param->log_num_cqs, outbox, INIT_HCA_LOG_CQ_OFFSET); |
431 | - MLX4_GET(param->altc_base, outbox, INIT_HCA_ALTC_BASE_OFFSET); |
432 | - MLX4_GET(param->auxc_base, outbox, INIT_HCA_AUXC_BASE_OFFSET); |
433 | - MLX4_GET(param->eqc_base, outbox, INIT_HCA_EQC_BASE_OFFSET); |
434 | - MLX4_GET(param->log_num_eqs, outbox, INIT_HCA_LOG_EQ_OFFSET); |
435 | - MLX4_GET(param->num_sys_eqs, outbox, INIT_HCA_NUM_SYS_EQS_OFFSET); |
436 | - MLX4_GET(param->rdmarc_base, outbox, INIT_HCA_RDMARC_BASE_OFFSET); |
437 | - MLX4_GET(param->log_rd_per_qp, outbox, INIT_HCA_LOG_RD_OFFSET); |
438 | + MLX4_GET(qword_field, outbox, INIT_HCA_QPC_BASE_OFFSET); |
439 | + param->qpc_base = qword_field & ~((u64)0x1f); |
440 | + MLX4_GET(byte_field, outbox, INIT_HCA_LOG_QP_OFFSET); |
441 | + param->log_num_qps = byte_field & 0x1f; |
442 | + MLX4_GET(qword_field, outbox, INIT_HCA_SRQC_BASE_OFFSET); |
443 | + param->srqc_base = qword_field & ~((u64)0x1f); |
444 | + MLX4_GET(byte_field, outbox, INIT_HCA_LOG_SRQ_OFFSET); |
445 | + param->log_num_srqs = byte_field & 0x1f; |
446 | + MLX4_GET(qword_field, outbox, INIT_HCA_CQC_BASE_OFFSET); |
447 | + param->cqc_base = qword_field & ~((u64)0x1f); |
448 | + MLX4_GET(byte_field, outbox, INIT_HCA_LOG_CQ_OFFSET); |
449 | + param->log_num_cqs = byte_field & 0x1f; |
450 | + MLX4_GET(qword_field, outbox, INIT_HCA_ALTC_BASE_OFFSET); |
451 | + param->altc_base = qword_field; |
452 | + MLX4_GET(qword_field, outbox, INIT_HCA_AUXC_BASE_OFFSET); |
453 | + param->auxc_base = qword_field; |
454 | + MLX4_GET(qword_field, outbox, INIT_HCA_EQC_BASE_OFFSET); |
455 | + param->eqc_base = qword_field & ~((u64)0x1f); |
456 | + MLX4_GET(byte_field, outbox, INIT_HCA_LOG_EQ_OFFSET); |
457 | + param->log_num_eqs = byte_field & 0x1f; |
458 | + MLX4_GET(word_field, outbox, INIT_HCA_NUM_SYS_EQS_OFFSET); |
459 | + param->num_sys_eqs = word_field & 0xfff; |
460 | + MLX4_GET(qword_field, outbox, INIT_HCA_RDMARC_BASE_OFFSET); |
461 | + param->rdmarc_base = qword_field & ~((u64)0x1f); |
462 | + MLX4_GET(byte_field, outbox, INIT_HCA_LOG_RD_OFFSET); |
463 | + param->log_rd_per_qp = byte_field & 0x7; |
464 | |
465 | MLX4_GET(dword_field, outbox, INIT_HCA_FLAGS_OFFSET); |
466 | if (dword_field & (1 << INIT_HCA_DEVICE_MANAGED_FLOW_STEERING_EN)) { |
467 | @@ -2125,22 +2140,21 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev, |
468 | /* steering attributes */ |
469 | if (param->steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED) { |
470 | MLX4_GET(param->mc_base, outbox, INIT_HCA_FS_BASE_OFFSET); |
471 | - MLX4_GET(param->log_mc_entry_sz, outbox, |
472 | - INIT_HCA_FS_LOG_ENTRY_SZ_OFFSET); |
473 | - MLX4_GET(param->log_mc_table_sz, outbox, |
474 | - INIT_HCA_FS_LOG_TABLE_SZ_OFFSET); |
475 | - MLX4_GET(byte_field, outbox, |
476 | - INIT_HCA_FS_A0_OFFSET); |
477 | + MLX4_GET(byte_field, outbox, INIT_HCA_FS_LOG_ENTRY_SZ_OFFSET); |
478 | + param->log_mc_entry_sz = byte_field & 0x1f; |
479 | + MLX4_GET(byte_field, outbox, INIT_HCA_FS_LOG_TABLE_SZ_OFFSET); |
480 | + param->log_mc_table_sz = byte_field & 0x1f; |
481 | + MLX4_GET(byte_field, outbox, INIT_HCA_FS_A0_OFFSET); |
482 | param->dmfs_high_steer_mode = |
483 | a0_dmfs_query_hw_steering[(byte_field >> 6) & 3]; |
484 | } else { |
485 | MLX4_GET(param->mc_base, outbox, INIT_HCA_MC_BASE_OFFSET); |
486 | - MLX4_GET(param->log_mc_entry_sz, outbox, |
487 | - INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET); |
488 | - MLX4_GET(param->log_mc_hash_sz, outbox, |
489 | - INIT_HCA_LOG_MC_HASH_SZ_OFFSET); |
490 | - MLX4_GET(param->log_mc_table_sz, outbox, |
491 | - INIT_HCA_LOG_MC_TABLE_SZ_OFFSET); |
492 | + MLX4_GET(byte_field, outbox, INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET); |
493 | + param->log_mc_entry_sz = byte_field & 0x1f; |
494 | + MLX4_GET(byte_field, outbox, INIT_HCA_LOG_MC_HASH_SZ_OFFSET); |
495 | + param->log_mc_hash_sz = byte_field & 0x1f; |
496 | + MLX4_GET(byte_field, outbox, INIT_HCA_LOG_MC_TABLE_SZ_OFFSET); |
497 | + param->log_mc_table_sz = byte_field & 0x1f; |
498 | } |
499 | |
500 | /* CX3 is capable of extending CQEs/EQEs from 32 to 64 bytes */ |
501 | @@ -2164,15 +2178,18 @@ int mlx4_QUERY_HCA(struct mlx4_dev *dev, |
502 | /* TPT attributes */ |
503 | |
504 | MLX4_GET(param->dmpt_base, outbox, INIT_HCA_DMPT_BASE_OFFSET); |
505 | - MLX4_GET(param->mw_enabled, outbox, INIT_HCA_TPT_MW_OFFSET); |
506 | - MLX4_GET(param->log_mpt_sz, outbox, INIT_HCA_LOG_MPT_SZ_OFFSET); |
507 | + MLX4_GET(byte_field, outbox, INIT_HCA_TPT_MW_OFFSET); |
508 | + param->mw_enabled = byte_field >> 7; |
509 | + MLX4_GET(byte_field, outbox, INIT_HCA_LOG_MPT_SZ_OFFSET); |
510 | + param->log_mpt_sz = byte_field & 0x3f; |
511 | MLX4_GET(param->mtt_base, outbox, INIT_HCA_MTT_BASE_OFFSET); |
512 | MLX4_GET(param->cmpt_base, outbox, INIT_HCA_CMPT_BASE_OFFSET); |
513 | |
514 | /* UAR attributes */ |
515 | |
516 | MLX4_GET(param->uar_page_sz, outbox, INIT_HCA_UAR_PAGE_SZ_OFFSET); |
517 | - MLX4_GET(param->log_uar_sz, outbox, INIT_HCA_LOG_UAR_SZ_OFFSET); |
518 | + MLX4_GET(byte_field, outbox, INIT_HCA_LOG_UAR_SZ_OFFSET); |
519 | + param->log_uar_sz = byte_field & 0xf; |
520 | |
521 | /* phv_check enable */ |
522 | MLX4_GET(byte_field, outbox, INIT_HCA_CACHELINE_SZ_OFFSET); |
523 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c |
524 | index ea7dedc2d5ad..d6706475a3ba 100644 |
525 | --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c |
526 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c |
527 | @@ -1133,13 +1133,6 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw, |
528 | int err = 0; |
529 | u8 *smac_v; |
530 | |
531 | - if (vport->info.spoofchk && !is_valid_ether_addr(vport->info.mac)) { |
532 | - mlx5_core_warn(esw->dev, |
533 | - "vport[%d] configure ingress rules failed, illegal mac with spoofchk\n", |
534 | - vport->vport); |
535 | - return -EPERM; |
536 | - } |
537 | - |
538 | esw_vport_cleanup_ingress_rules(esw, vport); |
539 | |
540 | if (!vport->info.vlan && !vport->info.qos && !vport->info.spoofchk) { |
541 | @@ -1696,7 +1689,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev) |
542 | int vport_num; |
543 | int err; |
544 | |
545 | - if (!MLX5_ESWITCH_MANAGER(dev)) |
546 | + if (!MLX5_VPORT_MANAGER(dev)) |
547 | return 0; |
548 | |
549 | esw_info(dev, |
550 | @@ -1765,7 +1758,7 @@ abort: |
551 | |
552 | void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw) |
553 | { |
554 | - if (!esw || !MLX5_ESWITCH_MANAGER(esw->dev)) |
555 | + if (!esw || !MLX5_VPORT_MANAGER(esw->dev)) |
556 | return; |
557 | |
558 | esw_info(esw->dev, "cleanup\n"); |
559 | @@ -1812,13 +1805,10 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw, |
560 | mutex_lock(&esw->state_lock); |
561 | evport = &esw->vports[vport]; |
562 | |
563 | - if (evport->info.spoofchk && !is_valid_ether_addr(mac)) { |
564 | + if (evport->info.spoofchk && !is_valid_ether_addr(mac)) |
565 | mlx5_core_warn(esw->dev, |
566 | - "MAC invalidation is not allowed when spoofchk is on, vport(%d)\n", |
567 | + "Set invalid MAC while spoofchk is on, vport(%d)\n", |
568 | vport); |
569 | - err = -EPERM; |
570 | - goto unlock; |
571 | - } |
572 | |
573 | err = mlx5_modify_nic_vport_mac_address(esw->dev, vport, mac); |
574 | if (err) { |
575 | @@ -1964,6 +1954,10 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, |
576 | evport = &esw->vports[vport]; |
577 | pschk = evport->info.spoofchk; |
578 | evport->info.spoofchk = spoofchk; |
579 | + if (pschk && !is_valid_ether_addr(evport->info.mac)) |
580 | + mlx5_core_warn(esw->dev, |
581 | + "Spoofchk in set while MAC is invalid, vport(%d)\n", |
582 | + evport->vport); |
583 | if (evport->enabled && esw->mode == SRIOV_LEGACY) |
584 | err = esw_vport_ingress_config(esw, evport); |
585 | if (err) |
586 | diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c |
587 | index d6f753925352..8441c86d9f3b 100644 |
588 | --- a/drivers/net/ethernet/renesas/ravb_main.c |
589 | +++ b/drivers/net/ethernet/renesas/ravb_main.c |
590 | @@ -344,7 +344,7 @@ static int ravb_ring_init(struct net_device *ndev, int q) |
591 | int i; |
592 | |
593 | priv->rx_buf_sz = (ndev->mtu <= 1492 ? PKT_BUF_SZ : ndev->mtu) + |
594 | - ETH_HLEN + VLAN_HLEN; |
595 | + ETH_HLEN + VLAN_HLEN + sizeof(__sum16); |
596 | |
597 | /* Allocate RX and TX skb rings */ |
598 | priv->rx_skb[q] = kcalloc(priv->num_rx_ring[q], |
599 | @@ -525,13 +525,15 @@ static void ravb_rx_csum(struct sk_buff *skb) |
600 | { |
601 | u8 *hw_csum; |
602 | |
603 | - /* The hardware checksum is 2 bytes appended to packet data */ |
604 | - if (unlikely(skb->len < 2)) |
605 | + /* The hardware checksum is contained in sizeof(__sum16) (2) bytes |
606 | + * appended to packet data |
607 | + */ |
608 | + if (unlikely(skb->len < sizeof(__sum16))) |
609 | return; |
610 | - hw_csum = skb_tail_pointer(skb) - 2; |
611 | + hw_csum = skb_tail_pointer(skb) - sizeof(__sum16); |
612 | skb->csum = csum_unfold((__force __sum16)get_unaligned_le16(hw_csum)); |
613 | skb->ip_summed = CHECKSUM_COMPLETE; |
614 | - skb_trim(skb, skb->len - 2); |
615 | + skb_trim(skb, skb->len - sizeof(__sum16)); |
616 | } |
617 | |
618 | /* Packet receive function for Ethernet AVB */ |
619 | diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c |
620 | index 4a949569ec4c..5fb541897863 100644 |
621 | --- a/drivers/net/ipvlan/ipvlan_main.c |
622 | +++ b/drivers/net/ipvlan/ipvlan_main.c |
623 | @@ -97,12 +97,12 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval) |
624 | err = ipvlan_register_nf_hook(read_pnet(&port->pnet)); |
625 | if (!err) { |
626 | mdev->l3mdev_ops = &ipvl_l3mdev_ops; |
627 | - mdev->priv_flags |= IFF_L3MDEV_MASTER; |
628 | + mdev->priv_flags |= IFF_L3MDEV_RX_HANDLER; |
629 | } else |
630 | goto fail; |
631 | } else if (port->mode == IPVLAN_MODE_L3S) { |
632 | /* Old mode was L3S */ |
633 | - mdev->priv_flags &= ~IFF_L3MDEV_MASTER; |
634 | + mdev->priv_flags &= ~IFF_L3MDEV_RX_HANDLER; |
635 | ipvlan_unregister_nf_hook(read_pnet(&port->pnet)); |
636 | mdev->l3mdev_ops = NULL; |
637 | } |
638 | @@ -162,7 +162,7 @@ static void ipvlan_port_destroy(struct net_device *dev) |
639 | struct sk_buff *skb; |
640 | |
641 | if (port->mode == IPVLAN_MODE_L3S) { |
642 | - dev->priv_flags &= ~IFF_L3MDEV_MASTER; |
643 | + dev->priv_flags &= ~IFF_L3MDEV_RX_HANDLER; |
644 | ipvlan_unregister_nf_hook(dev_net(dev)); |
645 | dev->l3mdev_ops = NULL; |
646 | } |
647 | diff --git a/drivers/net/tun.c b/drivers/net/tun.c |
648 | index 33978b0cdac8..65844f28db30 100644 |
649 | --- a/drivers/net/tun.c |
650 | +++ b/drivers/net/tun.c |
651 | @@ -866,8 +866,6 @@ static int tun_attach(struct tun_struct *tun, struct file *file, |
652 | tun_napi_init(tun, tfile, napi, napi_frags); |
653 | } |
654 | |
655 | - tun_set_real_num_queues(tun); |
656 | - |
657 | /* device is allowed to go away first, so no need to hold extra |
658 | * refcnt. |
659 | */ |
660 | @@ -879,6 +877,7 @@ static int tun_attach(struct tun_struct *tun, struct file *file, |
661 | rcu_assign_pointer(tfile->tun, tun); |
662 | rcu_assign_pointer(tun->tfiles[tun->numqueues], tfile); |
663 | tun->numqueues++; |
664 | + tun_set_real_num_queues(tun); |
665 | out: |
666 | return err; |
667 | } |
668 | diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c |
669 | index ad14fbfa1864..42feaa4d2916 100644 |
670 | --- a/drivers/net/virtio_net.c |
671 | +++ b/drivers/net/virtio_net.c |
672 | @@ -57,6 +57,8 @@ module_param(napi_tx, bool, 0644); |
673 | #define VIRTIO_XDP_TX BIT(0) |
674 | #define VIRTIO_XDP_REDIR BIT(1) |
675 | |
676 | +#define VIRTIO_XDP_FLAG BIT(0) |
677 | + |
678 | /* RX packet size EWMA. The average packet size is used to determine the packet |
679 | * buffer size when refilling RX rings. As the entire RX ring may be refilled |
680 | * at once, the weight is chosen so that the EWMA will be insensitive to short- |
681 | @@ -251,6 +253,21 @@ struct padded_vnet_hdr { |
682 | char padding[4]; |
683 | }; |
684 | |
685 | +static bool is_xdp_frame(void *ptr) |
686 | +{ |
687 | + return (unsigned long)ptr & VIRTIO_XDP_FLAG; |
688 | +} |
689 | + |
690 | +static void *xdp_to_ptr(struct xdp_frame *ptr) |
691 | +{ |
692 | + return (void *)((unsigned long)ptr | VIRTIO_XDP_FLAG); |
693 | +} |
694 | + |
695 | +static struct xdp_frame *ptr_to_xdp(void *ptr) |
696 | +{ |
697 | + return (struct xdp_frame *)((unsigned long)ptr & ~VIRTIO_XDP_FLAG); |
698 | +} |
699 | + |
700 | /* Converting between virtqueue no. and kernel tx/rx queue no. |
701 | * 0:rx0 1:tx0 2:rx1 3:tx1 ... 2N:rxN 2N+1:txN 2N+2:cvq |
702 | */ |
703 | @@ -461,7 +478,8 @@ static int __virtnet_xdp_xmit_one(struct virtnet_info *vi, |
704 | |
705 | sg_init_one(sq->sg, xdpf->data, xdpf->len); |
706 | |
707 | - err = virtqueue_add_outbuf(sq->vq, sq->sg, 1, xdpf, GFP_ATOMIC); |
708 | + err = virtqueue_add_outbuf(sq->vq, sq->sg, 1, xdp_to_ptr(xdpf), |
709 | + GFP_ATOMIC); |
710 | if (unlikely(err)) |
711 | return -ENOSPC; /* Caller handle free/refcnt */ |
712 | |
713 | @@ -481,36 +499,37 @@ static int virtnet_xdp_xmit(struct net_device *dev, |
714 | { |
715 | struct virtnet_info *vi = netdev_priv(dev); |
716 | struct receive_queue *rq = vi->rq; |
717 | - struct xdp_frame *xdpf_sent; |
718 | struct bpf_prog *xdp_prog; |
719 | struct send_queue *sq; |
720 | unsigned int len; |
721 | int drops = 0; |
722 | int kicks = 0; |
723 | int ret, err; |
724 | + void *ptr; |
725 | int i; |
726 | |
727 | - sq = virtnet_xdp_sq(vi); |
728 | - |
729 | - if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK)) { |
730 | - ret = -EINVAL; |
731 | - drops = n; |
732 | - goto out; |
733 | - } |
734 | - |
735 | /* Only allow ndo_xdp_xmit if XDP is loaded on dev, as this |
736 | * indicate XDP resources have been successfully allocated. |
737 | */ |
738 | xdp_prog = rcu_dereference(rq->xdp_prog); |
739 | - if (!xdp_prog) { |
740 | - ret = -ENXIO; |
741 | + if (!xdp_prog) |
742 | + return -ENXIO; |
743 | + |
744 | + sq = virtnet_xdp_sq(vi); |
745 | + |
746 | + if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK)) { |
747 | + ret = -EINVAL; |
748 | drops = n; |
749 | goto out; |
750 | } |
751 | |
752 | /* Free up any pending old buffers before queueing new ones. */ |
753 | - while ((xdpf_sent = virtqueue_get_buf(sq->vq, &len)) != NULL) |
754 | - xdp_return_frame(xdpf_sent); |
755 | + while ((ptr = virtqueue_get_buf(sq->vq, &len)) != NULL) { |
756 | + if (likely(is_xdp_frame(ptr))) |
757 | + xdp_return_frame(ptr_to_xdp(ptr)); |
758 | + else |
759 | + napi_consume_skb(ptr, false); |
760 | + } |
761 | |
762 | for (i = 0; i < n; i++) { |
763 | struct xdp_frame *xdpf = frames[i]; |
764 | @@ -1329,20 +1348,28 @@ static int virtnet_receive(struct receive_queue *rq, int budget, |
765 | return stats.packets; |
766 | } |
767 | |
768 | -static void free_old_xmit_skbs(struct send_queue *sq) |
769 | +static void free_old_xmit_skbs(struct send_queue *sq, bool in_napi) |
770 | { |
771 | - struct sk_buff *skb; |
772 | unsigned int len; |
773 | unsigned int packets = 0; |
774 | unsigned int bytes = 0; |
775 | + void *ptr; |
776 | |
777 | - while ((skb = virtqueue_get_buf(sq->vq, &len)) != NULL) { |
778 | - pr_debug("Sent skb %p\n", skb); |
779 | + while ((ptr = virtqueue_get_buf(sq->vq, &len)) != NULL) { |
780 | + if (likely(!is_xdp_frame(ptr))) { |
781 | + struct sk_buff *skb = ptr; |
782 | |
783 | - bytes += skb->len; |
784 | - packets++; |
785 | + pr_debug("Sent skb %p\n", skb); |
786 | + |
787 | + bytes += skb->len; |
788 | + napi_consume_skb(skb, in_napi); |
789 | + } else { |
790 | + struct xdp_frame *frame = ptr_to_xdp(ptr); |
791 | |
792 | - dev_consume_skb_any(skb); |
793 | + bytes += frame->len; |
794 | + xdp_return_frame(frame); |
795 | + } |
796 | + packets++; |
797 | } |
798 | |
799 | /* Avoid overhead when no packets have been processed |
800 | @@ -1357,6 +1384,16 @@ static void free_old_xmit_skbs(struct send_queue *sq) |
801 | u64_stats_update_end(&sq->stats.syncp); |
802 | } |
803 | |
804 | +static bool is_xdp_raw_buffer_queue(struct virtnet_info *vi, int q) |
805 | +{ |
806 | + if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs)) |
807 | + return false; |
808 | + else if (q < vi->curr_queue_pairs) |
809 | + return true; |
810 | + else |
811 | + return false; |
812 | +} |
813 | + |
814 | static void virtnet_poll_cleantx(struct receive_queue *rq) |
815 | { |
816 | struct virtnet_info *vi = rq->vq->vdev->priv; |
817 | @@ -1364,11 +1401,11 @@ static void virtnet_poll_cleantx(struct receive_queue *rq) |
818 | struct send_queue *sq = &vi->sq[index]; |
819 | struct netdev_queue *txq = netdev_get_tx_queue(vi->dev, index); |
820 | |
821 | - if (!sq->napi.weight) |
822 | + if (!sq->napi.weight || is_xdp_raw_buffer_queue(vi, index)) |
823 | return; |
824 | |
825 | if (__netif_tx_trylock(txq)) { |
826 | - free_old_xmit_skbs(sq); |
827 | + free_old_xmit_skbs(sq, true); |
828 | __netif_tx_unlock(txq); |
829 | } |
830 | |
831 | @@ -1441,10 +1478,18 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget) |
832 | { |
833 | struct send_queue *sq = container_of(napi, struct send_queue, napi); |
834 | struct virtnet_info *vi = sq->vq->vdev->priv; |
835 | - struct netdev_queue *txq = netdev_get_tx_queue(vi->dev, vq2txq(sq->vq)); |
836 | + unsigned int index = vq2txq(sq->vq); |
837 | + struct netdev_queue *txq; |
838 | |
839 | + if (unlikely(is_xdp_raw_buffer_queue(vi, index))) { |
840 | + /* We don't need to enable cb for XDP */ |
841 | + napi_complete_done(napi, 0); |
842 | + return 0; |
843 | + } |
844 | + |
845 | + txq = netdev_get_tx_queue(vi->dev, index); |
846 | __netif_tx_lock(txq, raw_smp_processor_id()); |
847 | - free_old_xmit_skbs(sq); |
848 | + free_old_xmit_skbs(sq, true); |
849 | __netif_tx_unlock(txq); |
850 | |
851 | virtqueue_napi_complete(napi, sq->vq, 0); |
852 | @@ -1513,7 +1558,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev) |
853 | bool use_napi = sq->napi.weight; |
854 | |
855 | /* Free up any pending old buffers before queueing new ones. */ |
856 | - free_old_xmit_skbs(sq); |
857 | + free_old_xmit_skbs(sq, false); |
858 | |
859 | if (use_napi && kick) |
860 | virtqueue_enable_cb_delayed(sq->vq); |
861 | @@ -1556,7 +1601,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev) |
862 | if (!use_napi && |
863 | unlikely(!virtqueue_enable_cb_delayed(sq->vq))) { |
864 | /* More just got used, free them then recheck. */ |
865 | - free_old_xmit_skbs(sq); |
866 | + free_old_xmit_skbs(sq, false); |
867 | if (sq->vq->num_free >= 2+MAX_SKB_FRAGS) { |
868 | netif_start_subqueue(dev, qnum); |
869 | virtqueue_disable_cb(sq->vq); |
870 | @@ -2345,6 +2390,10 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog, |
871 | return -ENOMEM; |
872 | } |
873 | |
874 | + old_prog = rtnl_dereference(vi->rq[0].xdp_prog); |
875 | + if (!prog && !old_prog) |
876 | + return 0; |
877 | + |
878 | if (prog) { |
879 | prog = bpf_prog_add(prog, vi->max_queue_pairs - 1); |
880 | if (IS_ERR(prog)) |
881 | @@ -2352,36 +2401,62 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog, |
882 | } |
883 | |
884 | /* Make sure NAPI is not using any XDP TX queues for RX. */ |
885 | - if (netif_running(dev)) |
886 | - for (i = 0; i < vi->max_queue_pairs; i++) |
887 | + if (netif_running(dev)) { |
888 | + for (i = 0; i < vi->max_queue_pairs; i++) { |
889 | napi_disable(&vi->rq[i].napi); |
890 | + virtnet_napi_tx_disable(&vi->sq[i].napi); |
891 | + } |
892 | + } |
893 | + |
894 | + if (!prog) { |
895 | + for (i = 0; i < vi->max_queue_pairs; i++) { |
896 | + rcu_assign_pointer(vi->rq[i].xdp_prog, prog); |
897 | + if (i == 0) |
898 | + virtnet_restore_guest_offloads(vi); |
899 | + } |
900 | + synchronize_net(); |
901 | + } |
902 | |
903 | - netif_set_real_num_rx_queues(dev, curr_qp + xdp_qp); |
904 | err = _virtnet_set_queues(vi, curr_qp + xdp_qp); |
905 | if (err) |
906 | goto err; |
907 | + netif_set_real_num_rx_queues(dev, curr_qp + xdp_qp); |
908 | vi->xdp_queue_pairs = xdp_qp; |
909 | |
910 | - for (i = 0; i < vi->max_queue_pairs; i++) { |
911 | - old_prog = rtnl_dereference(vi->rq[i].xdp_prog); |
912 | - rcu_assign_pointer(vi->rq[i].xdp_prog, prog); |
913 | - if (i == 0) { |
914 | - if (!old_prog) |
915 | + if (prog) { |
916 | + for (i = 0; i < vi->max_queue_pairs; i++) { |
917 | + rcu_assign_pointer(vi->rq[i].xdp_prog, prog); |
918 | + if (i == 0 && !old_prog) |
919 | virtnet_clear_guest_offloads(vi); |
920 | - if (!prog) |
921 | - virtnet_restore_guest_offloads(vi); |
922 | } |
923 | + } |
924 | + |
925 | + for (i = 0; i < vi->max_queue_pairs; i++) { |
926 | if (old_prog) |
927 | bpf_prog_put(old_prog); |
928 | - if (netif_running(dev)) |
929 | + if (netif_running(dev)) { |
930 | virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi); |
931 | + virtnet_napi_tx_enable(vi, vi->sq[i].vq, |
932 | + &vi->sq[i].napi); |
933 | + } |
934 | } |
935 | |
936 | return 0; |
937 | |
938 | err: |
939 | - for (i = 0; i < vi->max_queue_pairs; i++) |
940 | - virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi); |
941 | + if (!prog) { |
942 | + virtnet_clear_guest_offloads(vi); |
943 | + for (i = 0; i < vi->max_queue_pairs; i++) |
944 | + rcu_assign_pointer(vi->rq[i].xdp_prog, old_prog); |
945 | + } |
946 | + |
947 | + if (netif_running(dev)) { |
948 | + for (i = 0; i < vi->max_queue_pairs; i++) { |
949 | + virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi); |
950 | + virtnet_napi_tx_enable(vi, vi->sq[i].vq, |
951 | + &vi->sq[i].napi); |
952 | + } |
953 | + } |
954 | if (prog) |
955 | bpf_prog_sub(prog, vi->max_queue_pairs - 1); |
956 | return err; |
957 | @@ -2537,16 +2612,6 @@ static void free_receive_page_frags(struct virtnet_info *vi) |
958 | put_page(vi->rq[i].alloc_frag.page); |
959 | } |
960 | |
961 | -static bool is_xdp_raw_buffer_queue(struct virtnet_info *vi, int q) |
962 | -{ |
963 | - if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs)) |
964 | - return false; |
965 | - else if (q < vi->curr_queue_pairs) |
966 | - return true; |
967 | - else |
968 | - return false; |
969 | -} |
970 | - |
971 | static void free_unused_bufs(struct virtnet_info *vi) |
972 | { |
973 | void *buf; |
974 | @@ -2555,10 +2620,10 @@ static void free_unused_bufs(struct virtnet_info *vi) |
975 | for (i = 0; i < vi->max_queue_pairs; i++) { |
976 | struct virtqueue *vq = vi->sq[i].vq; |
977 | while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) { |
978 | - if (!is_xdp_raw_buffer_queue(vi, i)) |
979 | + if (!is_xdp_frame(buf)) |
980 | dev_kfree_skb(buf); |
981 | else |
982 | - put_page(virt_to_head_page(buf)); |
983 | + xdp_return_frame(ptr_to_xdp(buf)); |
984 | } |
985 | } |
986 | |
987 | diff --git a/drivers/of/device.c b/drivers/of/device.c |
988 | index 40b9051a7fce..258742830e36 100644 |
989 | --- a/drivers/of/device.c |
990 | +++ b/drivers/of/device.c |
991 | @@ -221,7 +221,8 @@ static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len |
992 | return -ENODEV; |
993 | |
994 | /* Name & Type */ |
995 | - csize = snprintf(str, len, "of:N%sT%s", dev->of_node->name, |
996 | + /* %p eats all alphanum characters, so %c must be used here */ |
997 | + csize = snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T', |
998 | dev->of_node->type); |
999 | tsize = csize; |
1000 | len -= csize; |
1001 | @@ -300,7 +301,7 @@ void of_device_uevent(struct device *dev, struct kobj_uevent_env *env) |
1002 | if ((!dev) || (!dev->of_node)) |
1003 | return; |
1004 | |
1005 | - add_uevent_var(env, "OF_NAME=%s", dev->of_node->name); |
1006 | + add_uevent_var(env, "OF_NAME=%pOFn", dev->of_node); |
1007 | add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node); |
1008 | if (dev->of_node->type && strcmp("<NULL>", dev->of_node->type) != 0) |
1009 | add_uevent_var(env, "OF_TYPE=%s", dev->of_node->type); |
1010 | diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c |
1011 | index ecea92f68c87..45c0b1f4cb69 100644 |
1012 | --- a/drivers/of/dynamic.c |
1013 | +++ b/drivers/of/dynamic.c |
1014 | @@ -275,9 +275,6 @@ void __of_detach_node(struct device_node *np) |
1015 | |
1016 | /** |
1017 | * of_detach_node() - "Unplug" a node from the device tree. |
1018 | - * |
1019 | - * The caller must hold a reference to the node. The memory associated with |
1020 | - * the node is not freed until its refcount goes to zero. |
1021 | */ |
1022 | int of_detach_node(struct device_node *np) |
1023 | { |
1024 | @@ -333,6 +330,25 @@ void of_node_release(struct kobject *kobj) |
1025 | if (!of_node_check_flag(node, OF_DYNAMIC)) |
1026 | return; |
1027 | |
1028 | + if (of_node_check_flag(node, OF_OVERLAY)) { |
1029 | + |
1030 | + if (!of_node_check_flag(node, OF_OVERLAY_FREE_CSET)) { |
1031 | + /* premature refcount of zero, do not free memory */ |
1032 | + pr_err("ERROR: memory leak before free overlay changeset, %pOF\n", |
1033 | + node); |
1034 | + return; |
1035 | + } |
1036 | + |
1037 | + /* |
1038 | + * If node->properties non-empty then properties were added |
1039 | + * to this node either by different overlay that has not |
1040 | + * yet been removed, or by a non-overlay mechanism. |
1041 | + */ |
1042 | + if (node->properties) |
1043 | + pr_err("ERROR: %s(), unexpected properties in %pOF\n", |
1044 | + __func__, node); |
1045 | + } |
1046 | + |
1047 | property_list_free(node->properties); |
1048 | property_list_free(node->deadprops); |
1049 | |
1050 | @@ -437,6 +453,16 @@ struct device_node *__of_node_dup(const struct device_node *np, |
1051 | |
1052 | static void __of_changeset_entry_destroy(struct of_changeset_entry *ce) |
1053 | { |
1054 | + if (ce->action == OF_RECONFIG_ATTACH_NODE && |
1055 | + of_node_check_flag(ce->np, OF_OVERLAY)) { |
1056 | + if (kref_read(&ce->np->kobj.kref) > 1) { |
1057 | + pr_err("ERROR: memory leak, expected refcount 1 instead of %d, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node %pOF\n", |
1058 | + kref_read(&ce->np->kobj.kref), ce->np); |
1059 | + } else { |
1060 | + of_node_set_flag(ce->np, OF_OVERLAY_FREE_CSET); |
1061 | + } |
1062 | + } |
1063 | + |
1064 | of_node_put(ce->np); |
1065 | list_del(&ce->node); |
1066 | kfree(ce); |
1067 | diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c |
1068 | index 7a0a18980b98..c72eef988041 100644 |
1069 | --- a/drivers/of/kobj.c |
1070 | +++ b/drivers/of/kobj.c |
1071 | @@ -133,6 +133,9 @@ int __of_attach_node_sysfs(struct device_node *np) |
1072 | } |
1073 | if (!name) |
1074 | return -ENOMEM; |
1075 | + |
1076 | + of_node_get(np); |
1077 | + |
1078 | rc = kobject_add(&np->kobj, parent, "%s", name); |
1079 | kfree(name); |
1080 | if (rc) |
1081 | @@ -159,6 +162,5 @@ void __of_detach_node_sysfs(struct device_node *np) |
1082 | kobject_del(&np->kobj); |
1083 | } |
1084 | |
1085 | - /* finally remove the kobj_init ref */ |
1086 | of_node_put(np); |
1087 | } |
1088 | diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c |
1089 | index e92391d6d1bd..5ad1342f5682 100644 |
1090 | --- a/drivers/of/of_mdio.c |
1091 | +++ b/drivers/of/of_mdio.c |
1092 | @@ -97,8 +97,8 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, |
1093 | return rc; |
1094 | } |
1095 | |
1096 | - dev_dbg(&mdio->dev, "registered phy %s at address %i\n", |
1097 | - child->name, addr); |
1098 | + dev_dbg(&mdio->dev, "registered phy %pOFn at address %i\n", |
1099 | + child, addr); |
1100 | return 0; |
1101 | } |
1102 | |
1103 | @@ -127,8 +127,8 @@ static int of_mdiobus_register_device(struct mii_bus *mdio, |
1104 | return rc; |
1105 | } |
1106 | |
1107 | - dev_dbg(&mdio->dev, "registered mdio device %s at address %i\n", |
1108 | - child->name, addr); |
1109 | + dev_dbg(&mdio->dev, "registered mdio device %pOFn at address %i\n", |
1110 | + child, addr); |
1111 | return 0; |
1112 | } |
1113 | |
1114 | @@ -263,8 +263,8 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) |
1115 | continue; |
1116 | |
1117 | /* be noisy to encourage people to set reg property */ |
1118 | - dev_info(&mdio->dev, "scan phy %s at address %i\n", |
1119 | - child->name, addr); |
1120 | + dev_info(&mdio->dev, "scan phy %pOFn at address %i\n", |
1121 | + child, addr); |
1122 | |
1123 | if (of_mdiobus_child_is_phy(child)) { |
1124 | rc = of_mdiobus_register_phy(mdio, child, addr); |
1125 | diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c |
1126 | index 2411ed3c7303..f5b452218092 100644 |
1127 | --- a/drivers/of/of_numa.c |
1128 | +++ b/drivers/of/of_numa.c |
1129 | @@ -168,8 +168,8 @@ int of_node_to_nid(struct device_node *device) |
1130 | np = of_get_next_parent(np); |
1131 | } |
1132 | if (np && r) |
1133 | - pr_warn("Invalid \"numa-node-id\" property in node %s\n", |
1134 | - np->name); |
1135 | + pr_warn("Invalid \"numa-node-id\" property in node %pOFn\n", |
1136 | + np); |
1137 | of_node_put(np); |
1138 | |
1139 | /* |
1140 | diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c |
1141 | index baa9cee6fa2c..9808aae4621a 100644 |
1142 | --- a/drivers/of/overlay.c |
1143 | +++ b/drivers/of/overlay.c |
1144 | @@ -23,6 +23,26 @@ |
1145 | |
1146 | #include "of_private.h" |
1147 | |
1148 | +/** |
1149 | + * struct target - info about current target node as recursing through overlay |
1150 | + * @np: node where current level of overlay will be applied |
1151 | + * @in_livetree: @np is a node in the live devicetree |
1152 | + * |
1153 | + * Used in the algorithm to create the portion of a changeset that describes |
1154 | + * an overlay fragment, which is a devicetree subtree. Initially @np is a node |
1155 | + * in the live devicetree where the overlay subtree is targeted to be grafted |
1156 | + * into. When recursing to the next level of the overlay subtree, the target |
1157 | + * also recurses to the next level of the live devicetree, as long as overlay |
1158 | + * subtree node also exists in the live devicetree. When a node in the overlay |
1159 | + * subtree does not exist at the same level in the live devicetree, target->np |
1160 | + * points to a newly allocated node, and all subsequent targets in the subtree |
1161 | + * will be newly allocated nodes. |
1162 | + */ |
1163 | +struct target { |
1164 | + struct device_node *np; |
1165 | + bool in_livetree; |
1166 | +}; |
1167 | + |
1168 | /** |
1169 | * struct fragment - info about fragment nodes in overlay expanded device tree |
1170 | * @target: target of the overlay operation |
1171 | @@ -72,8 +92,7 @@ static int devicetree_corrupt(void) |
1172 | } |
1173 | |
1174 | static int build_changeset_next_level(struct overlay_changeset *ovcs, |
1175 | - struct device_node *target_node, |
1176 | - const struct device_node *overlay_node); |
1177 | + struct target *target, const struct device_node *overlay_node); |
1178 | |
1179 | /* |
1180 | * of_resolve_phandles() finds the largest phandle in the live tree. |
1181 | @@ -257,14 +276,17 @@ err_free_target_path: |
1182 | /** |
1183 | * add_changeset_property() - add @overlay_prop to overlay changeset |
1184 | * @ovcs: overlay changeset |
1185 | - * @target_node: where to place @overlay_prop in live tree |
1186 | + * @target: where @overlay_prop will be placed |
1187 | * @overlay_prop: property to add or update, from overlay tree |
1188 | * @is_symbols_prop: 1 if @overlay_prop is from node "/__symbols__" |
1189 | * |
1190 | - * If @overlay_prop does not already exist in @target_node, add changeset entry |
1191 | - * to add @overlay_prop in @target_node, else add changeset entry to update |
1192 | + * If @overlay_prop does not already exist in live devicetree, add changeset |
1193 | + * entry to add @overlay_prop in @target, else add changeset entry to update |
1194 | * value of @overlay_prop. |
1195 | * |
1196 | + * @target may be either in the live devicetree or in a new subtree that |
1197 | + * is contained in the changeset. |
1198 | + * |
1199 | * Some special properties are not updated (no error returned). |
1200 | * |
1201 | * Update of property in symbols node is not allowed. |
1202 | @@ -273,20 +295,22 @@ err_free_target_path: |
1203 | * invalid @overlay. |
1204 | */ |
1205 | static int add_changeset_property(struct overlay_changeset *ovcs, |
1206 | - struct device_node *target_node, |
1207 | - struct property *overlay_prop, |
1208 | + struct target *target, struct property *overlay_prop, |
1209 | bool is_symbols_prop) |
1210 | { |
1211 | struct property *new_prop = NULL, *prop; |
1212 | int ret = 0; |
1213 | |
1214 | - prop = of_find_property(target_node, overlay_prop->name, NULL); |
1215 | - |
1216 | if (!of_prop_cmp(overlay_prop->name, "name") || |
1217 | !of_prop_cmp(overlay_prop->name, "phandle") || |
1218 | !of_prop_cmp(overlay_prop->name, "linux,phandle")) |
1219 | return 0; |
1220 | |
1221 | + if (target->in_livetree) |
1222 | + prop = of_find_property(target->np, overlay_prop->name, NULL); |
1223 | + else |
1224 | + prop = NULL; |
1225 | + |
1226 | if (is_symbols_prop) { |
1227 | if (prop) |
1228 | return -EINVAL; |
1229 | @@ -299,10 +323,10 @@ static int add_changeset_property(struct overlay_changeset *ovcs, |
1230 | return -ENOMEM; |
1231 | |
1232 | if (!prop) |
1233 | - ret = of_changeset_add_property(&ovcs->cset, target_node, |
1234 | + ret = of_changeset_add_property(&ovcs->cset, target->np, |
1235 | new_prop); |
1236 | else |
1237 | - ret = of_changeset_update_property(&ovcs->cset, target_node, |
1238 | + ret = of_changeset_update_property(&ovcs->cset, target->np, |
1239 | new_prop); |
1240 | |
1241 | if (ret) { |
1242 | @@ -315,14 +339,14 @@ static int add_changeset_property(struct overlay_changeset *ovcs, |
1243 | |
1244 | /** |
1245 | * add_changeset_node() - add @node (and children) to overlay changeset |
1246 | - * @ovcs: overlay changeset |
1247 | - * @target_node: where to place @node in live tree |
1248 | - * @node: node from within overlay device tree fragment |
1249 | + * @ovcs: overlay changeset |
1250 | + * @target: where @node will be placed in live tree or changeset |
1251 | + * @node: node from within overlay device tree fragment |
1252 | * |
1253 | - * If @node does not already exist in @target_node, add changeset entry |
1254 | - * to add @node in @target_node. |
1255 | + * If @node does not already exist in @target, add changeset entry |
1256 | + * to add @node in @target. |
1257 | * |
1258 | - * If @node already exists in @target_node, and the existing node has |
1259 | + * If @node already exists in @target, and the existing node has |
1260 | * a phandle, the overlay node is not allowed to have a phandle. |
1261 | * |
1262 | * If @node has child nodes, add the children recursively via |
1263 | @@ -355,38 +379,46 @@ static int add_changeset_property(struct overlay_changeset *ovcs, |
1264 | * invalid @overlay. |
1265 | */ |
1266 | static int add_changeset_node(struct overlay_changeset *ovcs, |
1267 | - struct device_node *target_node, struct device_node *node) |
1268 | + struct target *target, struct device_node *node) |
1269 | { |
1270 | const char *node_kbasename; |
1271 | struct device_node *tchild; |
1272 | + struct target target_child; |
1273 | int ret = 0; |
1274 | |
1275 | node_kbasename = kbasename(node->full_name); |
1276 | |
1277 | - for_each_child_of_node(target_node, tchild) |
1278 | + for_each_child_of_node(target->np, tchild) |
1279 | if (!of_node_cmp(node_kbasename, kbasename(tchild->full_name))) |
1280 | break; |
1281 | |
1282 | if (!tchild) { |
1283 | - tchild = __of_node_dup(node, node_kbasename); |
1284 | + tchild = __of_node_dup(NULL, node_kbasename); |
1285 | if (!tchild) |
1286 | return -ENOMEM; |
1287 | |
1288 | - tchild->parent = target_node; |
1289 | + tchild->parent = target->np; |
1290 | + of_node_set_flag(tchild, OF_OVERLAY); |
1291 | |
1292 | ret = of_changeset_attach_node(&ovcs->cset, tchild); |
1293 | if (ret) |
1294 | return ret; |
1295 | |
1296 | - ret = build_changeset_next_level(ovcs, tchild, node); |
1297 | + target_child.np = tchild; |
1298 | + target_child.in_livetree = false; |
1299 | + |
1300 | + ret = build_changeset_next_level(ovcs, &target_child, node); |
1301 | of_node_put(tchild); |
1302 | return ret; |
1303 | } |
1304 | |
1305 | - if (node->phandle && tchild->phandle) |
1306 | + if (node->phandle && tchild->phandle) { |
1307 | ret = -EINVAL; |
1308 | - else |
1309 | - ret = build_changeset_next_level(ovcs, tchild, node); |
1310 | + } else { |
1311 | + target_child.np = tchild; |
1312 | + target_child.in_livetree = target->in_livetree; |
1313 | + ret = build_changeset_next_level(ovcs, &target_child, node); |
1314 | + } |
1315 | of_node_put(tchild); |
1316 | |
1317 | return ret; |
1318 | @@ -395,7 +427,7 @@ static int add_changeset_node(struct overlay_changeset *ovcs, |
1319 | /** |
1320 | * build_changeset_next_level() - add level of overlay changeset |
1321 | * @ovcs: overlay changeset |
1322 | - * @target_node: where to place @overlay_node in live tree |
1323 | + * @target: where to place @overlay_node in live tree |
1324 | * @overlay_node: node from within an overlay device tree fragment |
1325 | * |
1326 | * Add the properties (if any) and nodes (if any) from @overlay_node to the |
1327 | @@ -408,27 +440,26 @@ static int add_changeset_node(struct overlay_changeset *ovcs, |
1328 | * invalid @overlay_node. |
1329 | */ |
1330 | static int build_changeset_next_level(struct overlay_changeset *ovcs, |
1331 | - struct device_node *target_node, |
1332 | - const struct device_node *overlay_node) |
1333 | + struct target *target, const struct device_node *overlay_node) |
1334 | { |
1335 | struct device_node *child; |
1336 | struct property *prop; |
1337 | int ret; |
1338 | |
1339 | for_each_property_of_node(overlay_node, prop) { |
1340 | - ret = add_changeset_property(ovcs, target_node, prop, 0); |
1341 | + ret = add_changeset_property(ovcs, target, prop, 0); |
1342 | if (ret) { |
1343 | pr_debug("Failed to apply prop @%pOF/%s, err=%d\n", |
1344 | - target_node, prop->name, ret); |
1345 | + target->np, prop->name, ret); |
1346 | return ret; |
1347 | } |
1348 | } |
1349 | |
1350 | for_each_child_of_node(overlay_node, child) { |
1351 | - ret = add_changeset_node(ovcs, target_node, child); |
1352 | + ret = add_changeset_node(ovcs, target, child); |
1353 | if (ret) { |
1354 | - pr_debug("Failed to apply node @%pOF/%s, err=%d\n", |
1355 | - target_node, child->name, ret); |
1356 | + pr_debug("Failed to apply node @%pOF/%pOFn, err=%d\n", |
1357 | + target->np, child, ret); |
1358 | of_node_put(child); |
1359 | return ret; |
1360 | } |
1361 | @@ -441,17 +472,17 @@ static int build_changeset_next_level(struct overlay_changeset *ovcs, |
1362 | * Add the properties from __overlay__ node to the @ovcs->cset changeset. |
1363 | */ |
1364 | static int build_changeset_symbols_node(struct overlay_changeset *ovcs, |
1365 | - struct device_node *target_node, |
1366 | + struct target *target, |
1367 | const struct device_node *overlay_symbols_node) |
1368 | { |
1369 | struct property *prop; |
1370 | int ret; |
1371 | |
1372 | for_each_property_of_node(overlay_symbols_node, prop) { |
1373 | - ret = add_changeset_property(ovcs, target_node, prop, 1); |
1374 | + ret = add_changeset_property(ovcs, target, prop, 1); |
1375 | if (ret) { |
1376 | pr_debug("Failed to apply prop @%pOF/%s, err=%d\n", |
1377 | - target_node, prop->name, ret); |
1378 | + target->np, prop->name, ret); |
1379 | return ret; |
1380 | } |
1381 | } |
1382 | @@ -474,6 +505,7 @@ static int build_changeset_symbols_node(struct overlay_changeset *ovcs, |
1383 | static int build_changeset(struct overlay_changeset *ovcs) |
1384 | { |
1385 | struct fragment *fragment; |
1386 | + struct target target; |
1387 | int fragments_count, i, ret; |
1388 | |
1389 | /* |
1390 | @@ -488,7 +520,9 @@ static int build_changeset(struct overlay_changeset *ovcs) |
1391 | for (i = 0; i < fragments_count; i++) { |
1392 | fragment = &ovcs->fragments[i]; |
1393 | |
1394 | - ret = build_changeset_next_level(ovcs, fragment->target, |
1395 | + target.np = fragment->target; |
1396 | + target.in_livetree = true; |
1397 | + ret = build_changeset_next_level(ovcs, &target, |
1398 | fragment->overlay); |
1399 | if (ret) { |
1400 | pr_debug("apply failed '%pOF'\n", fragment->target); |
1401 | @@ -498,7 +532,10 @@ static int build_changeset(struct overlay_changeset *ovcs) |
1402 | |
1403 | if (ovcs->symbols_fragment) { |
1404 | fragment = &ovcs->fragments[ovcs->count - 1]; |
1405 | - ret = build_changeset_symbols_node(ovcs, fragment->target, |
1406 | + |
1407 | + target.np = fragment->target; |
1408 | + target.in_livetree = true; |
1409 | + ret = build_changeset_symbols_node(ovcs, &target, |
1410 | fragment->overlay); |
1411 | if (ret) { |
1412 | pr_debug("apply failed '%pOF'\n", fragment->target); |
1413 | @@ -516,7 +553,7 @@ static int build_changeset(struct overlay_changeset *ovcs) |
1414 | * 1) "target" property containing the phandle of the target |
1415 | * 2) "target-path" property containing the path of the target |
1416 | */ |
1417 | -static struct device_node *find_target_node(struct device_node *info_node) |
1418 | +static struct device_node *find_target(struct device_node *info_node) |
1419 | { |
1420 | struct device_node *node; |
1421 | const char *path; |
1422 | @@ -622,7 +659,7 @@ static int init_overlay_changeset(struct overlay_changeset *ovcs, |
1423 | |
1424 | fragment = &fragments[cnt]; |
1425 | fragment->overlay = overlay_node; |
1426 | - fragment->target = find_target_node(node); |
1427 | + fragment->target = find_target(node); |
1428 | if (!fragment->target) { |
1429 | of_node_put(fragment->overlay); |
1430 | ret = -EINVAL; |
1431 | diff --git a/drivers/of/platform.c b/drivers/of/platform.c |
1432 | index 6c59673933e9..04ad312fd85b 100644 |
1433 | --- a/drivers/of/platform.c |
1434 | +++ b/drivers/of/platform.c |
1435 | @@ -91,8 +91,8 @@ static void of_device_make_bus_id(struct device *dev) |
1436 | */ |
1437 | reg = of_get_property(node, "reg", NULL); |
1438 | if (reg && (addr = of_translate_address(node, reg)) != OF_BAD_ADDR) { |
1439 | - dev_set_name(dev, dev_name(dev) ? "%llx.%s:%s" : "%llx.%s", |
1440 | - (unsigned long long)addr, node->name, |
1441 | + dev_set_name(dev, dev_name(dev) ? "%llx.%pOFn:%s" : "%llx.%pOFn", |
1442 | + (unsigned long long)addr, node, |
1443 | dev_name(dev)); |
1444 | return; |
1445 | } |
1446 | @@ -142,8 +142,8 @@ struct platform_device *of_device_alloc(struct device_node *np, |
1447 | WARN_ON(rc); |
1448 | } |
1449 | if (of_irq_to_resource_table(np, res, num_irq) != num_irq) |
1450 | - pr_debug("not all legacy IRQ resources mapped for %s\n", |
1451 | - np->name); |
1452 | + pr_debug("not all legacy IRQ resources mapped for %pOFn\n", |
1453 | + np); |
1454 | } |
1455 | |
1456 | dev->dev.of_node = of_node_get(np); |
1457 | diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c |
1458 | index 41b49716ac75..7f42314da6ae 100644 |
1459 | --- a/drivers/of/unittest.c |
1460 | +++ b/drivers/of/unittest.c |
1461 | @@ -212,8 +212,8 @@ static int __init of_unittest_check_node_linkage(struct device_node *np) |
1462 | |
1463 | for_each_child_of_node(np, child) { |
1464 | if (child->parent != np) { |
1465 | - pr_err("Child node %s links to wrong parent %s\n", |
1466 | - child->name, np->name); |
1467 | + pr_err("Child node %pOFn links to wrong parent %pOFn\n", |
1468 | + child, np); |
1469 | rc = -EINVAL; |
1470 | goto put_child; |
1471 | } |
1472 | @@ -1046,16 +1046,16 @@ static void __init of_unittest_platform_populate(void) |
1473 | for_each_child_of_node(np, child) { |
1474 | for_each_child_of_node(child, grandchild) |
1475 | unittest(of_find_device_by_node(grandchild), |
1476 | - "Could not create device for node '%s'\n", |
1477 | - grandchild->name); |
1478 | + "Could not create device for node '%pOFn'\n", |
1479 | + grandchild); |
1480 | } |
1481 | |
1482 | of_platform_depopulate(&test_bus->dev); |
1483 | for_each_child_of_node(np, child) { |
1484 | for_each_child_of_node(child, grandchild) |
1485 | unittest(!of_find_device_by_node(grandchild), |
1486 | - "device didn't get destroyed '%s'\n", |
1487 | - grandchild->name); |
1488 | + "device didn't get destroyed '%pOFn'\n", |
1489 | + grandchild); |
1490 | } |
1491 | |
1492 | platform_device_unregister(test_bus); |
1493 | diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c |
1494 | index db2af09067db..b6f2ff95c3ed 100644 |
1495 | --- a/drivers/platform/x86/asus-nb-wmi.c |
1496 | +++ b/drivers/platform/x86/asus-nb-wmi.c |
1497 | @@ -442,8 +442,7 @@ static const struct key_entry asus_nb_wmi_keymap[] = { |
1498 | { KE_KEY, 0x30, { KEY_VOLUMEUP } }, |
1499 | { KE_KEY, 0x31, { KEY_VOLUMEDOWN } }, |
1500 | { KE_KEY, 0x32, { KEY_MUTE } }, |
1501 | - { KE_KEY, 0x33, { KEY_DISPLAYTOGGLE } }, /* LCD on */ |
1502 | - { KE_KEY, 0x34, { KEY_DISPLAY_OFF } }, /* LCD off */ |
1503 | + { KE_KEY, 0x35, { KEY_SCREENLOCK } }, |
1504 | { KE_KEY, 0x40, { KEY_PREVIOUSSONG } }, |
1505 | { KE_KEY, 0x41, { KEY_NEXTSONG } }, |
1506 | { KE_KEY, 0x43, { KEY_STOPCD } }, /* Stop/Eject */ |
1507 | diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c |
1508 | index a86aa65ad66d..39155d7cc894 100644 |
1509 | --- a/drivers/vhost/net.c |
1510 | +++ b/drivers/vhost/net.c |
1511 | @@ -1114,7 +1114,8 @@ static int vhost_net_open(struct inode *inode, struct file *f) |
1512 | n->vqs[i].rx_ring = NULL; |
1513 | vhost_net_buf_init(&n->vqs[i].rxq); |
1514 | } |
1515 | - vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX); |
1516 | + vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX, |
1517 | + UIO_MAXIOV + VHOST_NET_BATCH); |
1518 | |
1519 | vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, EPOLLOUT, dev); |
1520 | vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, EPOLLIN, dev); |
1521 | diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c |
1522 | index e7e3ae13516d..0cfa925be4ec 100644 |
1523 | --- a/drivers/vhost/scsi.c |
1524 | +++ b/drivers/vhost/scsi.c |
1525 | @@ -1398,7 +1398,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) |
1526 | vqs[i] = &vs->vqs[i].vq; |
1527 | vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick; |
1528 | } |
1529 | - vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ); |
1530 | + vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ, UIO_MAXIOV); |
1531 | |
1532 | vhost_scsi_init_inflight(vs, NULL); |
1533 | |
1534 | diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c |
1535 | index c66fc8308b5e..cf82e7266397 100644 |
1536 | --- a/drivers/vhost/vhost.c |
1537 | +++ b/drivers/vhost/vhost.c |
1538 | @@ -390,9 +390,9 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *dev) |
1539 | vq->indirect = kmalloc_array(UIO_MAXIOV, |
1540 | sizeof(*vq->indirect), |
1541 | GFP_KERNEL); |
1542 | - vq->log = kmalloc_array(UIO_MAXIOV, sizeof(*vq->log), |
1543 | + vq->log = kmalloc_array(dev->iov_limit, sizeof(*vq->log), |
1544 | GFP_KERNEL); |
1545 | - vq->heads = kmalloc_array(UIO_MAXIOV, sizeof(*vq->heads), |
1546 | + vq->heads = kmalloc_array(dev->iov_limit, sizeof(*vq->heads), |
1547 | GFP_KERNEL); |
1548 | if (!vq->indirect || !vq->log || !vq->heads) |
1549 | goto err_nomem; |
1550 | @@ -414,7 +414,7 @@ static void vhost_dev_free_iovecs(struct vhost_dev *dev) |
1551 | } |
1552 | |
1553 | void vhost_dev_init(struct vhost_dev *dev, |
1554 | - struct vhost_virtqueue **vqs, int nvqs) |
1555 | + struct vhost_virtqueue **vqs, int nvqs, int iov_limit) |
1556 | { |
1557 | struct vhost_virtqueue *vq; |
1558 | int i; |
1559 | @@ -427,6 +427,7 @@ void vhost_dev_init(struct vhost_dev *dev, |
1560 | dev->iotlb = NULL; |
1561 | dev->mm = NULL; |
1562 | dev->worker = NULL; |
1563 | + dev->iov_limit = iov_limit; |
1564 | init_llist_head(&dev->work_list); |
1565 | init_waitqueue_head(&dev->wait); |
1566 | INIT_LIST_HEAD(&dev->read_list); |
1567 | diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h |
1568 | index 1b675dad5e05..9490e7ddb340 100644 |
1569 | --- a/drivers/vhost/vhost.h |
1570 | +++ b/drivers/vhost/vhost.h |
1571 | @@ -170,9 +170,11 @@ struct vhost_dev { |
1572 | struct list_head read_list; |
1573 | struct list_head pending_list; |
1574 | wait_queue_head_t wait; |
1575 | + int iov_limit; |
1576 | }; |
1577 | |
1578 | -void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs); |
1579 | +void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, |
1580 | + int nvqs, int iov_limit); |
1581 | long vhost_dev_set_owner(struct vhost_dev *dev); |
1582 | bool vhost_dev_has_owner(struct vhost_dev *dev); |
1583 | long vhost_dev_check_owner(struct vhost_dev *); |
1584 | diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c |
1585 | index 98ed5be132c6..fa93f6711d8d 100644 |
1586 | --- a/drivers/vhost/vsock.c |
1587 | +++ b/drivers/vhost/vsock.c |
1588 | @@ -531,7 +531,7 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file) |
1589 | vsock->vqs[VSOCK_VQ_TX].handle_kick = vhost_vsock_handle_tx_kick; |
1590 | vsock->vqs[VSOCK_VQ_RX].handle_kick = vhost_vsock_handle_rx_kick; |
1591 | |
1592 | - vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs)); |
1593 | + vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs), UIO_MAXIOV); |
1594 | |
1595 | file->private_data = vsock; |
1596 | spin_lock_init(&vsock->send_pkt_list_lock); |
1597 | diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c |
1598 | index 7ad6f2eec711..48ac8b7c43a5 100644 |
1599 | --- a/fs/btrfs/ctree.c |
1600 | +++ b/fs/btrfs/ctree.c |
1601 | @@ -1003,6 +1003,48 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans, |
1602 | return 0; |
1603 | } |
1604 | |
1605 | +static struct extent_buffer *alloc_tree_block_no_bg_flush( |
1606 | + struct btrfs_trans_handle *trans, |
1607 | + struct btrfs_root *root, |
1608 | + u64 parent_start, |
1609 | + const struct btrfs_disk_key *disk_key, |
1610 | + int level, |
1611 | + u64 hint, |
1612 | + u64 empty_size) |
1613 | +{ |
1614 | + struct btrfs_fs_info *fs_info = root->fs_info; |
1615 | + struct extent_buffer *ret; |
1616 | + |
1617 | + /* |
1618 | + * If we are COWing a node/leaf from the extent, chunk, device or free |
1619 | + * space trees, make sure that we do not finish block group creation of |
1620 | + * pending block groups. We do this to avoid a deadlock. |
1621 | + * COWing can result in allocation of a new chunk, and flushing pending |
1622 | + * block groups (btrfs_create_pending_block_groups()) can be triggered |
1623 | + * when finishing allocation of a new chunk. Creation of a pending block |
1624 | + * group modifies the extent, chunk, device and free space trees, |
1625 | + * therefore we could deadlock with ourselves since we are holding a |
1626 | + * lock on an extent buffer that btrfs_create_pending_block_groups() may |
1627 | + * try to COW later. |
1628 | + * For similar reasons, we also need to delay flushing pending block |
1629 | + * groups when splitting a leaf or node, from one of those trees, since |
1630 | + * we are holding a write lock on it and its parent or when inserting a |
1631 | + * new root node for one of those trees. |
1632 | + */ |
1633 | + if (root == fs_info->extent_root || |
1634 | + root == fs_info->chunk_root || |
1635 | + root == fs_info->dev_root || |
1636 | + root == fs_info->free_space_root) |
1637 | + trans->can_flush_pending_bgs = false; |
1638 | + |
1639 | + ret = btrfs_alloc_tree_block(trans, root, parent_start, |
1640 | + root->root_key.objectid, disk_key, level, |
1641 | + hint, empty_size); |
1642 | + trans->can_flush_pending_bgs = true; |
1643 | + |
1644 | + return ret; |
1645 | +} |
1646 | + |
1647 | /* |
1648 | * does the dirty work in cow of a single block. The parent block (if |
1649 | * supplied) is updated to point to the new cow copy. The new buffer is marked |
1650 | @@ -1050,28 +1092,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, |
1651 | if ((root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) && parent) |
1652 | parent_start = parent->start; |
1653 | |
1654 | - /* |
1655 | - * If we are COWing a node/leaf from the extent, chunk, device or free |
1656 | - * space trees, make sure that we do not finish block group creation of |
1657 | - * pending block groups. We do this to avoid a deadlock. |
1658 | - * COWing can result in allocation of a new chunk, and flushing pending |
1659 | - * block groups (btrfs_create_pending_block_groups()) can be triggered |
1660 | - * when finishing allocation of a new chunk. Creation of a pending block |
1661 | - * group modifies the extent, chunk, device and free space trees, |
1662 | - * therefore we could deadlock with ourselves since we are holding a |
1663 | - * lock on an extent buffer that btrfs_create_pending_block_groups() may |
1664 | - * try to COW later. |
1665 | - */ |
1666 | - if (root == fs_info->extent_root || |
1667 | - root == fs_info->chunk_root || |
1668 | - root == fs_info->dev_root || |
1669 | - root == fs_info->free_space_root) |
1670 | - trans->can_flush_pending_bgs = false; |
1671 | - |
1672 | - cow = btrfs_alloc_tree_block(trans, root, parent_start, |
1673 | - root->root_key.objectid, &disk_key, level, |
1674 | - search_start, empty_size); |
1675 | - trans->can_flush_pending_bgs = true; |
1676 | + cow = alloc_tree_block_no_bg_flush(trans, root, parent_start, &disk_key, |
1677 | + level, search_start, empty_size); |
1678 | if (IS_ERR(cow)) |
1679 | return PTR_ERR(cow); |
1680 | |
1681 | @@ -3383,8 +3405,8 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans, |
1682 | else |
1683 | btrfs_node_key(lower, &lower_key, 0); |
1684 | |
1685 | - c = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid, |
1686 | - &lower_key, level, root->node->start, 0); |
1687 | + c = alloc_tree_block_no_bg_flush(trans, root, 0, &lower_key, level, |
1688 | + root->node->start, 0); |
1689 | if (IS_ERR(c)) |
1690 | return PTR_ERR(c); |
1691 | |
1692 | @@ -3513,8 +3535,8 @@ static noinline int split_node(struct btrfs_trans_handle *trans, |
1693 | mid = (c_nritems + 1) / 2; |
1694 | btrfs_node_key(c, &disk_key, mid); |
1695 | |
1696 | - split = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid, |
1697 | - &disk_key, level, c->start, 0); |
1698 | + split = alloc_tree_block_no_bg_flush(trans, root, 0, &disk_key, level, |
1699 | + c->start, 0); |
1700 | if (IS_ERR(split)) |
1701 | return PTR_ERR(split); |
1702 | |
1703 | @@ -4298,8 +4320,8 @@ again: |
1704 | else |
1705 | btrfs_item_key(l, &disk_key, mid); |
1706 | |
1707 | - right = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid, |
1708 | - &disk_key, 0, l->start, 0); |
1709 | + right = alloc_tree_block_no_bg_flush(trans, root, 0, &disk_key, 0, |
1710 | + l->start, 0); |
1711 | if (IS_ERR(right)) |
1712 | return PTR_ERR(right); |
1713 | |
1714 | diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c |
1715 | index 8ad145820ea8..8888337a95b6 100644 |
1716 | --- a/fs/btrfs/super.c |
1717 | +++ b/fs/btrfs/super.c |
1718 | @@ -1677,6 +1677,7 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags, |
1719 | flags | SB_RDONLY, device_name, data); |
1720 | if (IS_ERR(mnt_root)) { |
1721 | root = ERR_CAST(mnt_root); |
1722 | + kfree(subvol_name); |
1723 | goto out; |
1724 | } |
1725 | |
1726 | @@ -1686,12 +1687,14 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags, |
1727 | if (error < 0) { |
1728 | root = ERR_PTR(error); |
1729 | mntput(mnt_root); |
1730 | + kfree(subvol_name); |
1731 | goto out; |
1732 | } |
1733 | } |
1734 | } |
1735 | if (IS_ERR(mnt_root)) { |
1736 | root = ERR_CAST(mnt_root); |
1737 | + kfree(subvol_name); |
1738 | goto out; |
1739 | } |
1740 | |
1741 | diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c |
1742 | index d0bba175117c..a5ea742654aa 100644 |
1743 | --- a/fs/cifs/connect.c |
1744 | +++ b/fs/cifs/connect.c |
1745 | @@ -50,6 +50,7 @@ |
1746 | #include "cifs_unicode.h" |
1747 | #include "cifs_debug.h" |
1748 | #include "cifs_fs_sb.h" |
1749 | +#include "dns_resolve.h" |
1750 | #include "ntlmssp.h" |
1751 | #include "nterr.h" |
1752 | #include "rfc1002pdu.h" |
1753 | @@ -317,6 +318,53 @@ static void cifs_prune_tlinks(struct work_struct *work); |
1754 | static int cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data, |
1755 | const char *devname, bool is_smb3); |
1756 | |
1757 | +/* |
1758 | + * Resolve hostname and set ip addr in tcp ses. Useful for hostnames that may |
1759 | + * get their ip addresses changed at some point. |
1760 | + * |
1761 | + * This should be called with server->srv_mutex held. |
1762 | + */ |
1763 | +#ifdef CONFIG_CIFS_DFS_UPCALL |
1764 | +static int reconn_set_ipaddr(struct TCP_Server_Info *server) |
1765 | +{ |
1766 | + int rc; |
1767 | + int len; |
1768 | + char *unc, *ipaddr = NULL; |
1769 | + |
1770 | + if (!server->hostname) |
1771 | + return -EINVAL; |
1772 | + |
1773 | + len = strlen(server->hostname) + 3; |
1774 | + |
1775 | + unc = kmalloc(len, GFP_KERNEL); |
1776 | + if (!unc) { |
1777 | + cifs_dbg(FYI, "%s: failed to create UNC path\n", __func__); |
1778 | + return -ENOMEM; |
1779 | + } |
1780 | + snprintf(unc, len, "\\\\%s", server->hostname); |
1781 | + |
1782 | + rc = dns_resolve_server_name_to_ip(unc, &ipaddr); |
1783 | + kfree(unc); |
1784 | + |
1785 | + if (rc < 0) { |
1786 | + cifs_dbg(FYI, "%s: failed to resolve server part of %s to IP: %d\n", |
1787 | + __func__, server->hostname, rc); |
1788 | + return rc; |
1789 | + } |
1790 | + |
1791 | + rc = cifs_convert_address((struct sockaddr *)&server->dstaddr, ipaddr, |
1792 | + strlen(ipaddr)); |
1793 | + kfree(ipaddr); |
1794 | + |
1795 | + return !rc ? -1 : 0; |
1796 | +} |
1797 | +#else |
1798 | +static inline int reconn_set_ipaddr(struct TCP_Server_Info *server) |
1799 | +{ |
1800 | + return 0; |
1801 | +} |
1802 | +#endif |
1803 | + |
1804 | /* |
1805 | * cifs tcp session reconnection |
1806 | * |
1807 | @@ -417,6 +465,11 @@ cifs_reconnect(struct TCP_Server_Info *server) |
1808 | rc = generic_ip_connect(server); |
1809 | if (rc) { |
1810 | cifs_dbg(FYI, "reconnect error %d\n", rc); |
1811 | + rc = reconn_set_ipaddr(server); |
1812 | + if (rc) { |
1813 | + cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n", |
1814 | + __func__, rc); |
1815 | + } |
1816 | mutex_unlock(&server->srv_mutex); |
1817 | msleep(3000); |
1818 | } else { |
1819 | diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c |
1820 | index dba986524917..8a01e89ff827 100644 |
1821 | --- a/fs/cifs/smb2pdu.c |
1822 | +++ b/fs/cifs/smb2pdu.c |
1823 | @@ -3127,8 +3127,17 @@ smb2_readv_callback(struct mid_q_entry *mid) |
1824 | rdata->mr = NULL; |
1825 | } |
1826 | #endif |
1827 | - if (rdata->result) |
1828 | + if (rdata->result && rdata->result != -ENODATA) { |
1829 | cifs_stats_fail_inc(tcon, SMB2_READ_HE); |
1830 | + trace_smb3_read_err(0 /* xid */, |
1831 | + rdata->cfile->fid.persistent_fid, |
1832 | + tcon->tid, tcon->ses->Suid, rdata->offset, |
1833 | + rdata->bytes, rdata->result); |
1834 | + } else |
1835 | + trace_smb3_read_done(0 /* xid */, |
1836 | + rdata->cfile->fid.persistent_fid, |
1837 | + tcon->tid, tcon->ses->Suid, |
1838 | + rdata->offset, rdata->got_bytes); |
1839 | |
1840 | queue_work(cifsiod_wq, &rdata->work); |
1841 | DeleteMidQEntry(mid); |
1842 | @@ -3203,13 +3212,11 @@ smb2_async_readv(struct cifs_readdata *rdata) |
1843 | if (rc) { |
1844 | kref_put(&rdata->refcount, cifs_readdata_release); |
1845 | cifs_stats_fail_inc(io_parms.tcon, SMB2_READ_HE); |
1846 | - trace_smb3_read_err(rc, 0 /* xid */, io_parms.persistent_fid, |
1847 | - io_parms.tcon->tid, io_parms.tcon->ses->Suid, |
1848 | - io_parms.offset, io_parms.length); |
1849 | - } else |
1850 | - trace_smb3_read_done(0 /* xid */, io_parms.persistent_fid, |
1851 | - io_parms.tcon->tid, io_parms.tcon->ses->Suid, |
1852 | - io_parms.offset, io_parms.length); |
1853 | + trace_smb3_read_err(0 /* xid */, io_parms.persistent_fid, |
1854 | + io_parms.tcon->tid, |
1855 | + io_parms.tcon->ses->Suid, |
1856 | + io_parms.offset, io_parms.length, rc); |
1857 | + } |
1858 | |
1859 | cifs_small_buf_release(buf); |
1860 | return rc; |
1861 | @@ -3253,10 +3260,11 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, |
1862 | if (rc != -ENODATA) { |
1863 | cifs_stats_fail_inc(io_parms->tcon, SMB2_READ_HE); |
1864 | cifs_dbg(VFS, "Send error in read = %d\n", rc); |
1865 | + trace_smb3_read_err(xid, req->PersistentFileId, |
1866 | + io_parms->tcon->tid, ses->Suid, |
1867 | + io_parms->offset, io_parms->length, |
1868 | + rc); |
1869 | } |
1870 | - trace_smb3_read_err(rc, xid, req->PersistentFileId, |
1871 | - io_parms->tcon->tid, ses->Suid, |
1872 | - io_parms->offset, io_parms->length); |
1873 | free_rsp_buf(resp_buftype, rsp_iov.iov_base); |
1874 | return rc == -ENODATA ? 0 : rc; |
1875 | } else |
1876 | @@ -3342,8 +3350,17 @@ smb2_writev_callback(struct mid_q_entry *mid) |
1877 | wdata->mr = NULL; |
1878 | } |
1879 | #endif |
1880 | - if (wdata->result) |
1881 | + if (wdata->result) { |
1882 | cifs_stats_fail_inc(tcon, SMB2_WRITE_HE); |
1883 | + trace_smb3_write_err(0 /* no xid */, |
1884 | + wdata->cfile->fid.persistent_fid, |
1885 | + tcon->tid, tcon->ses->Suid, wdata->offset, |
1886 | + wdata->bytes, wdata->result); |
1887 | + } else |
1888 | + trace_smb3_write_done(0 /* no xid */, |
1889 | + wdata->cfile->fid.persistent_fid, |
1890 | + tcon->tid, tcon->ses->Suid, |
1891 | + wdata->offset, wdata->bytes); |
1892 | |
1893 | queue_work(cifsiod_wq, &wdata->work); |
1894 | DeleteMidQEntry(mid); |
1895 | @@ -3485,10 +3502,7 @@ smb2_async_writev(struct cifs_writedata *wdata, |
1896 | wdata->bytes, rc); |
1897 | kref_put(&wdata->refcount, release); |
1898 | cifs_stats_fail_inc(tcon, SMB2_WRITE_HE); |
1899 | - } else |
1900 | - trace_smb3_write_done(0 /* no xid */, req->PersistentFileId, |
1901 | - tcon->tid, tcon->ses->Suid, wdata->offset, |
1902 | - wdata->bytes); |
1903 | + } |
1904 | |
1905 | async_writev_out: |
1906 | cifs_small_buf_release(req); |
1907 | @@ -3714,8 +3728,8 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, |
1908 | rsp->sync_hdr.Status == STATUS_NO_MORE_FILES) { |
1909 | srch_inf->endOfSearch = true; |
1910 | rc = 0; |
1911 | - } |
1912 | - cifs_stats_fail_inc(tcon, SMB2_QUERY_DIRECTORY_HE); |
1913 | + } else |
1914 | + cifs_stats_fail_inc(tcon, SMB2_QUERY_DIRECTORY_HE); |
1915 | goto qdir_exit; |
1916 | } |
1917 | |
1918 | diff --git a/fs/dcache.c b/fs/dcache.c |
1919 | index 2e7e8d85e9b4..cb515f183482 100644 |
1920 | --- a/fs/dcache.c |
1921 | +++ b/fs/dcache.c |
1922 | @@ -1202,15 +1202,11 @@ static enum lru_status dentry_lru_isolate_shrink(struct list_head *item, |
1923 | */ |
1924 | void shrink_dcache_sb(struct super_block *sb) |
1925 | { |
1926 | - long freed; |
1927 | - |
1928 | do { |
1929 | LIST_HEAD(dispose); |
1930 | |
1931 | - freed = list_lru_walk(&sb->s_dentry_lru, |
1932 | + list_lru_walk(&sb->s_dentry_lru, |
1933 | dentry_lru_isolate_shrink, &dispose, 1024); |
1934 | - |
1935 | - this_cpu_sub(nr_dentry_unused, freed); |
1936 | shrink_dentry_list(&dispose); |
1937 | } while (list_lru_count(&sb->s_dentry_lru) > 0); |
1938 | } |
1939 | diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c |
1940 | index e978f6930575..449d0cb45a84 100644 |
1941 | --- a/fs/gfs2/rgrp.c |
1942 | +++ b/fs/gfs2/rgrp.c |
1943 | @@ -1747,9 +1747,9 @@ static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 *minext, |
1944 | goto next_iter; |
1945 | } |
1946 | if (ret == -E2BIG) { |
1947 | - n += rbm->bii - initial_bii; |
1948 | rbm->bii = 0; |
1949 | rbm->offset = 0; |
1950 | + n += (rbm->bii - initial_bii); |
1951 | goto res_covered_end_of_rgrp; |
1952 | } |
1953 | return ret; |
1954 | diff --git a/fs/nfs/write.c b/fs/nfs/write.c |
1955 | index 586726a590d8..d790faff8e47 100644 |
1956 | --- a/fs/nfs/write.c |
1957 | +++ b/fs/nfs/write.c |
1958 | @@ -621,11 +621,12 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, |
1959 | nfs_set_page_writeback(page); |
1960 | WARN_ON_ONCE(test_bit(PG_CLEAN, &req->wb_flags)); |
1961 | |
1962 | - ret = 0; |
1963 | + ret = req->wb_context->error; |
1964 | /* If there is a fatal error that covers this write, just exit */ |
1965 | - if (nfs_error_is_fatal_on_server(req->wb_context->error)) |
1966 | + if (nfs_error_is_fatal_on_server(ret)) |
1967 | goto out_launder; |
1968 | |
1969 | + ret = 0; |
1970 | if (!nfs_pageio_add_request(pgio, req)) { |
1971 | ret = pgio->pg_error; |
1972 | /* |
1973 | @@ -635,9 +636,9 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, |
1974 | nfs_context_set_write_error(req->wb_context, ret); |
1975 | if (nfs_error_is_fatal_on_server(ret)) |
1976 | goto out_launder; |
1977 | - } |
1978 | + } else |
1979 | + ret = -EAGAIN; |
1980 | nfs_redirty_request(req); |
1981 | - ret = -EAGAIN; |
1982 | } else |
1983 | nfs_add_stats(page_file_mapping(page)->host, |
1984 | NFSIOS_WRITEPAGES, 1); |
1985 | diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h |
1986 | index d837dad24b4c..21fef8c5eca7 100644 |
1987 | --- a/include/linux/netdevice.h |
1988 | +++ b/include/linux/netdevice.h |
1989 | @@ -1455,6 +1455,7 @@ struct net_device_ops { |
1990 | * @IFF_NO_RX_HANDLER: device doesn't support the rx_handler hook |
1991 | * @IFF_FAILOVER: device is a failover master device |
1992 | * @IFF_FAILOVER_SLAVE: device is lower dev of a failover master device |
1993 | + * @IFF_L3MDEV_RX_HANDLER: only invoke the rx handler of L3 master device |
1994 | */ |
1995 | enum netdev_priv_flags { |
1996 | IFF_802_1Q_VLAN = 1<<0, |
1997 | @@ -1486,6 +1487,7 @@ enum netdev_priv_flags { |
1998 | IFF_NO_RX_HANDLER = 1<<26, |
1999 | IFF_FAILOVER = 1<<27, |
2000 | IFF_FAILOVER_SLAVE = 1<<28, |
2001 | + IFF_L3MDEV_RX_HANDLER = 1<<29, |
2002 | }; |
2003 | |
2004 | #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN |
2005 | @@ -1516,6 +1518,7 @@ enum netdev_priv_flags { |
2006 | #define IFF_NO_RX_HANDLER IFF_NO_RX_HANDLER |
2007 | #define IFF_FAILOVER IFF_FAILOVER |
2008 | #define IFF_FAILOVER_SLAVE IFF_FAILOVER_SLAVE |
2009 | +#define IFF_L3MDEV_RX_HANDLER IFF_L3MDEV_RX_HANDLER |
2010 | |
2011 | /** |
2012 | * struct net_device - The DEVICE structure. |
2013 | @@ -4464,6 +4467,11 @@ static inline bool netif_supports_nofcs(struct net_device *dev) |
2014 | return dev->priv_flags & IFF_SUPP_NOFCS; |
2015 | } |
2016 | |
2017 | +static inline bool netif_has_l3_rx_handler(const struct net_device *dev) |
2018 | +{ |
2019 | + return dev->priv_flags & IFF_L3MDEV_RX_HANDLER; |
2020 | +} |
2021 | + |
2022 | static inline bool netif_is_l3_master(const struct net_device *dev) |
2023 | { |
2024 | return dev->priv_flags & IFF_L3MDEV_MASTER; |
2025 | diff --git a/include/linux/of.h b/include/linux/of.h |
2026 | index 99b0ebf49632..40e58b0e9cf4 100644 |
2027 | --- a/include/linux/of.h |
2028 | +++ b/include/linux/of.h |
2029 | @@ -138,11 +138,16 @@ extern struct device_node *of_aliases; |
2030 | extern struct device_node *of_stdout; |
2031 | extern raw_spinlock_t devtree_lock; |
2032 | |
2033 | -/* flag descriptions (need to be visible even when !CONFIG_OF) */ |
2034 | -#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ |
2035 | -#define OF_DETACHED 2 /* node has been detached from the device tree */ |
2036 | -#define OF_POPULATED 3 /* device already created for the node */ |
2037 | -#define OF_POPULATED_BUS 4 /* of_platform_populate recursed to children of this node */ |
2038 | +/* |
2039 | + * struct device_node flag descriptions |
2040 | + * (need to be visible even when !CONFIG_OF) |
2041 | + */ |
2042 | +#define OF_DYNAMIC 1 /* (and properties) allocated via kmalloc */ |
2043 | +#define OF_DETACHED 2 /* detached from the device tree */ |
2044 | +#define OF_POPULATED 3 /* device already created */ |
2045 | +#define OF_POPULATED_BUS 4 /* platform bus created for children */ |
2046 | +#define OF_OVERLAY 5 /* allocated for an overlay */ |
2047 | +#define OF_OVERLAY_FREE_CSET 6 /* in overlay cset being freed */ |
2048 | |
2049 | #define OF_BAD_ADDR ((u64)-1) |
2050 | |
2051 | diff --git a/include/linux/sched/coredump.h b/include/linux/sched/coredump.h |
2052 | index ec912d01126f..ecdc6542070f 100644 |
2053 | --- a/include/linux/sched/coredump.h |
2054 | +++ b/include/linux/sched/coredump.h |
2055 | @@ -71,6 +71,7 @@ static inline int get_dumpable(struct mm_struct *mm) |
2056 | #define MMF_HUGE_ZERO_PAGE 23 /* mm has ever used the global huge zero page */ |
2057 | #define MMF_DISABLE_THP 24 /* disable THP for all VMAs */ |
2058 | #define MMF_OOM_VICTIM 25 /* mm is the oom victim */ |
2059 | +#define MMF_OOM_REAP_QUEUED 26 /* mm was queued for oom_reaper */ |
2060 | #define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP) |
2061 | |
2062 | #define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\ |
2063 | diff --git a/include/net/l3mdev.h b/include/net/l3mdev.h |
2064 | index 3832099289c5..128487658ff7 100644 |
2065 | --- a/include/net/l3mdev.h |
2066 | +++ b/include/net/l3mdev.h |
2067 | @@ -142,7 +142,8 @@ struct sk_buff *l3mdev_l3_rcv(struct sk_buff *skb, u16 proto) |
2068 | |
2069 | if (netif_is_l3_slave(skb->dev)) |
2070 | master = netdev_master_upper_dev_get_rcu(skb->dev); |
2071 | - else if (netif_is_l3_master(skb->dev)) |
2072 | + else if (netif_is_l3_master(skb->dev) || |
2073 | + netif_has_l3_rx_handler(skb->dev)) |
2074 | master = skb->dev; |
2075 | |
2076 | if (master && master->l3mdev_ops->l3mdev_l3_rcv) |
2077 | diff --git a/kernel/exit.c b/kernel/exit.c |
2078 | index 0e21e6d21f35..55b4fa6d01eb 100644 |
2079 | --- a/kernel/exit.c |
2080 | +++ b/kernel/exit.c |
2081 | @@ -558,12 +558,14 @@ static struct task_struct *find_alive_thread(struct task_struct *p) |
2082 | return NULL; |
2083 | } |
2084 | |
2085 | -static struct task_struct *find_child_reaper(struct task_struct *father) |
2086 | +static struct task_struct *find_child_reaper(struct task_struct *father, |
2087 | + struct list_head *dead) |
2088 | __releases(&tasklist_lock) |
2089 | __acquires(&tasklist_lock) |
2090 | { |
2091 | struct pid_namespace *pid_ns = task_active_pid_ns(father); |
2092 | struct task_struct *reaper = pid_ns->child_reaper; |
2093 | + struct task_struct *p, *n; |
2094 | |
2095 | if (likely(reaper != father)) |
2096 | return reaper; |
2097 | @@ -579,6 +581,12 @@ static struct task_struct *find_child_reaper(struct task_struct *father) |
2098 | panic("Attempted to kill init! exitcode=0x%08x\n", |
2099 | father->signal->group_exit_code ?: father->exit_code); |
2100 | } |
2101 | + |
2102 | + list_for_each_entry_safe(p, n, dead, ptrace_entry) { |
2103 | + list_del_init(&p->ptrace_entry); |
2104 | + release_task(p); |
2105 | + } |
2106 | + |
2107 | zap_pid_ns_processes(pid_ns); |
2108 | write_lock_irq(&tasklist_lock); |
2109 | |
2110 | @@ -668,7 +676,7 @@ static void forget_original_parent(struct task_struct *father, |
2111 | exit_ptrace(father, dead); |
2112 | |
2113 | /* Can drop and reacquire tasklist_lock */ |
2114 | - reaper = find_child_reaper(father); |
2115 | + reaper = find_child_reaper(father, dead); |
2116 | if (list_empty(&father->children)) |
2117 | return; |
2118 | |
2119 | diff --git a/mm/hugetlb.c b/mm/hugetlb.c |
2120 | index 309fb8c969af..10e83672bfbe 100644 |
2121 | --- a/mm/hugetlb.c |
2122 | +++ b/mm/hugetlb.c |
2123 | @@ -4269,7 +4269,8 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma, |
2124 | break; |
2125 | } |
2126 | if (ret & VM_FAULT_RETRY) { |
2127 | - if (nonblocking) |
2128 | + if (nonblocking && |
2129 | + !(fault_flags & FAULT_FLAG_RETRY_NOWAIT)) |
2130 | *nonblocking = 0; |
2131 | *nr_pages = 0; |
2132 | /* |
2133 | diff --git a/mm/memory-failure.c b/mm/memory-failure.c |
2134 | index 0cd3de3550f0..d9b8a2490633 100644 |
2135 | --- a/mm/memory-failure.c |
2136 | +++ b/mm/memory-failure.c |
2137 | @@ -372,7 +372,8 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail, |
2138 | if (fail || tk->addr_valid == 0) { |
2139 | pr_err("Memory failure: %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n", |
2140 | pfn, tk->tsk->comm, tk->tsk->pid); |
2141 | - force_sig(SIGKILL, tk->tsk); |
2142 | + do_send_sig_info(SIGKILL, SEND_SIG_PRIV, |
2143 | + tk->tsk, PIDTYPE_PID); |
2144 | } |
2145 | |
2146 | /* |
2147 | diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c |
2148 | index 8a136ffda370..c6119ad3561e 100644 |
2149 | --- a/mm/memory_hotplug.c |
2150 | +++ b/mm/memory_hotplug.c |
2151 | @@ -1326,23 +1326,27 @@ int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn, |
2152 | static unsigned long scan_movable_pages(unsigned long start, unsigned long end) |
2153 | { |
2154 | unsigned long pfn; |
2155 | - struct page *page; |
2156 | + |
2157 | for (pfn = start; pfn < end; pfn++) { |
2158 | - if (pfn_valid(pfn)) { |
2159 | - page = pfn_to_page(pfn); |
2160 | - if (PageLRU(page)) |
2161 | - return pfn; |
2162 | - if (__PageMovable(page)) |
2163 | - return pfn; |
2164 | - if (PageHuge(page)) { |
2165 | - if (hugepage_migration_supported(page_hstate(page)) && |
2166 | - page_huge_active(page)) |
2167 | - return pfn; |
2168 | - else |
2169 | - pfn = round_up(pfn + 1, |
2170 | - 1 << compound_order(page)) - 1; |
2171 | - } |
2172 | - } |
2173 | + struct page *page, *head; |
2174 | + unsigned long skip; |
2175 | + |
2176 | + if (!pfn_valid(pfn)) |
2177 | + continue; |
2178 | + page = pfn_to_page(pfn); |
2179 | + if (PageLRU(page)) |
2180 | + return pfn; |
2181 | + if (__PageMovable(page)) |
2182 | + return pfn; |
2183 | + |
2184 | + if (!PageHuge(page)) |
2185 | + continue; |
2186 | + head = compound_head(page); |
2187 | + if (hugepage_migration_supported(page_hstate(head)) && |
2188 | + page_huge_active(head)) |
2189 | + return pfn; |
2190 | + skip = (1 << compound_order(head)) - (page - head); |
2191 | + pfn += skip - 1; |
2192 | } |
2193 | return 0; |
2194 | } |
2195 | diff --git a/mm/migrate.c b/mm/migrate.c |
2196 | index 84381b55b2bd..ab260260a626 100644 |
2197 | --- a/mm/migrate.c |
2198 | +++ b/mm/migrate.c |
2199 | @@ -1118,10 +1118,13 @@ out: |
2200 | * If migration is successful, decrease refcount of the newpage |
2201 | * which will not free the page because new page owner increased |
2202 | * refcounter. As well, if it is LRU page, add the page to LRU |
2203 | - * list in here. |
2204 | + * list in here. Use the old state of the isolated source page to |
2205 | + * determine if we migrated a LRU page. newpage was already unlocked |
2206 | + * and possibly modified by its owner - don't rely on the page |
2207 | + * state. |
2208 | */ |
2209 | if (rc == MIGRATEPAGE_SUCCESS) { |
2210 | - if (unlikely(__PageMovable(newpage))) |
2211 | + if (unlikely(!is_lru)) |
2212 | put_page(newpage); |
2213 | else |
2214 | putback_lru_page(newpage); |
2215 | diff --git a/mm/oom_kill.c b/mm/oom_kill.c |
2216 | index f10aa5360616..e66ac8a47dd6 100644 |
2217 | --- a/mm/oom_kill.c |
2218 | +++ b/mm/oom_kill.c |
2219 | @@ -634,8 +634,8 @@ static int oom_reaper(void *unused) |
2220 | |
2221 | static void wake_oom_reaper(struct task_struct *tsk) |
2222 | { |
2223 | - /* tsk is already queued? */ |
2224 | - if (tsk == oom_reaper_list || tsk->oom_reaper_list) |
2225 | + /* mm is already queued? */ |
2226 | + if (test_and_set_bit(MMF_OOM_REAP_QUEUED, &tsk->signal->oom_mm->flags)) |
2227 | return; |
2228 | |
2229 | get_task_struct(tsk); |
2230 | @@ -962,6 +962,13 @@ static void oom_kill_process(struct oom_control *oc, const char *message) |
2231 | * still freeing memory. |
2232 | */ |
2233 | read_lock(&tasklist_lock); |
2234 | + |
2235 | + /* |
2236 | + * The task 'p' might have already exited before reaching here. The |
2237 | + * put_task_struct() will free task_struct 'p' while the loop still try |
2238 | + * to access the field of 'p', so, get an extra reference. |
2239 | + */ |
2240 | + get_task_struct(p); |
2241 | for_each_thread(p, t) { |
2242 | list_for_each_entry(child, &t->children, sibling) { |
2243 | unsigned int child_points; |
2244 | @@ -981,6 +988,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message) |
2245 | } |
2246 | } |
2247 | } |
2248 | + put_task_struct(p); |
2249 | read_unlock(&tasklist_lock); |
2250 | |
2251 | /* |
2252 | diff --git a/net/core/dev.c b/net/core/dev.c |
2253 | index 1f1aae27d41f..af097ca9cb4f 100644 |
2254 | --- a/net/core/dev.c |
2255 | +++ b/net/core/dev.c |
2256 | @@ -8599,6 +8599,9 @@ int init_dummy_netdev(struct net_device *dev) |
2257 | set_bit(__LINK_STATE_PRESENT, &dev->state); |
2258 | set_bit(__LINK_STATE_START, &dev->state); |
2259 | |
2260 | + /* napi_busy_loop stats accounting wants this */ |
2261 | + dev_net_set(dev, &init_net); |
2262 | + |
2263 | /* Note : We dont allocate pcpu_refcnt for dummy devices, |
2264 | * because users of this 'device' dont need to change |
2265 | * its refcount. |
2266 | diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c |
2267 | index b798862b6be5..f21ea6125fc2 100644 |
2268 | --- a/net/ipv4/gre_demux.c |
2269 | +++ b/net/ipv4/gre_demux.c |
2270 | @@ -25,6 +25,7 @@ |
2271 | #include <linux/spinlock.h> |
2272 | #include <net/protocol.h> |
2273 | #include <net/gre.h> |
2274 | +#include <net/erspan.h> |
2275 | |
2276 | #include <net/icmp.h> |
2277 | #include <net/route.h> |
2278 | @@ -118,6 +119,22 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, |
2279 | hdr_len += 4; |
2280 | } |
2281 | tpi->hdr_len = hdr_len; |
2282 | + |
2283 | + /* ERSPAN ver 1 and 2 protocol sets GRE key field |
2284 | + * to 0 and sets the configured key in the |
2285 | + * inner erspan header field |
2286 | + */ |
2287 | + if (greh->protocol == htons(ETH_P_ERSPAN) || |
2288 | + greh->protocol == htons(ETH_P_ERSPAN2)) { |
2289 | + struct erspan_base_hdr *ershdr; |
2290 | + |
2291 | + if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr))) |
2292 | + return -EINVAL; |
2293 | + |
2294 | + ershdr = (struct erspan_base_hdr *)options; |
2295 | + tpi->key = cpu_to_be32(get_session_id(ershdr)); |
2296 | + } |
2297 | + |
2298 | return hdr_len; |
2299 | } |
2300 | EXPORT_SYMBOL(gre_parse_header); |
2301 | diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c |
2302 | index f8bbd693c19c..d95b32af4a0e 100644 |
2303 | --- a/net/ipv4/ip_fragment.c |
2304 | +++ b/net/ipv4/ip_fragment.c |
2305 | @@ -425,6 +425,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) |
2306 | * fragment. |
2307 | */ |
2308 | |
2309 | + err = -EINVAL; |
2310 | /* Find out where to put this fragment. */ |
2311 | prev_tail = qp->q.fragments_tail; |
2312 | if (!prev_tail) |
2313 | @@ -501,7 +502,6 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) |
2314 | |
2315 | discard_qp: |
2316 | inet_frag_kill(&qp->q); |
2317 | - err = -EINVAL; |
2318 | __IP_INC_STATS(net, IPSTATS_MIB_REASM_OVERLAPS); |
2319 | err: |
2320 | kfree_skb(skb); |
2321 | diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c |
2322 | index 0bfad3e72509..f199945f6e4a 100644 |
2323 | --- a/net/ipv4/ip_gre.c |
2324 | +++ b/net/ipv4/ip_gre.c |
2325 | @@ -269,20 +269,11 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi, |
2326 | int len; |
2327 | |
2328 | itn = net_generic(net, erspan_net_id); |
2329 | - len = gre_hdr_len + sizeof(*ershdr); |
2330 | - |
2331 | - /* Check based hdr len */ |
2332 | - if (unlikely(!pskb_may_pull(skb, len))) |
2333 | - return PACKET_REJECT; |
2334 | |
2335 | iph = ip_hdr(skb); |
2336 | ershdr = (struct erspan_base_hdr *)(skb->data + gre_hdr_len); |
2337 | ver = ershdr->ver; |
2338 | |
2339 | - /* The original GRE header does not have key field, |
2340 | - * Use ERSPAN 10-bit session ID as key. |
2341 | - */ |
2342 | - tpi->key = cpu_to_be32(get_session_id(ershdr)); |
2343 | tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, |
2344 | tpi->flags | TUNNEL_KEY, |
2345 | iph->saddr, iph->daddr, tpi->key); |
2346 | @@ -1471,12 +1462,17 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev) |
2347 | { |
2348 | struct ip_tunnel *t = netdev_priv(dev); |
2349 | struct ip_tunnel_parm *p = &t->parms; |
2350 | + __be16 o_flags = p->o_flags; |
2351 | + |
2352 | + if ((t->erspan_ver == 1 || t->erspan_ver == 2) && |
2353 | + !t->collect_md) |
2354 | + o_flags |= TUNNEL_KEY; |
2355 | |
2356 | if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) || |
2357 | nla_put_be16(skb, IFLA_GRE_IFLAGS, |
2358 | gre_tnl_flags_to_gre_flags(p->i_flags)) || |
2359 | nla_put_be16(skb, IFLA_GRE_OFLAGS, |
2360 | - gre_tnl_flags_to_gre_flags(p->o_flags)) || |
2361 | + gre_tnl_flags_to_gre_flags(o_flags)) || |
2362 | nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) || |
2363 | nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) || |
2364 | nla_put_in_addr(skb, IFLA_GRE_LOCAL, p->iph.saddr) || |
2365 | diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c |
2366 | index 506b2ae07bb3..79fcd9550fd2 100644 |
2367 | --- a/net/ipv6/af_inet6.c |
2368 | +++ b/net/ipv6/af_inet6.c |
2369 | @@ -361,6 +361,9 @@ static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len, |
2370 | err = -EINVAL; |
2371 | goto out_unlock; |
2372 | } |
2373 | + } |
2374 | + |
2375 | + if (sk->sk_bound_dev_if) { |
2376 | dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if); |
2377 | if (!dev) { |
2378 | err = -ENODEV; |
2379 | diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c |
2380 | index 345e6839f031..be04877b3827 100644 |
2381 | --- a/net/ipv6/ip6_gre.c |
2382 | +++ b/net/ipv6/ip6_gre.c |
2383 | @@ -550,13 +550,9 @@ static int ip6erspan_rcv(struct sk_buff *skb, int gre_hdr_len, |
2384 | struct ip6_tnl *tunnel; |
2385 | u8 ver; |
2386 | |
2387 | - if (unlikely(!pskb_may_pull(skb, sizeof(*ershdr)))) |
2388 | - return PACKET_REJECT; |
2389 | - |
2390 | ipv6h = ipv6_hdr(skb); |
2391 | ershdr = (struct erspan_base_hdr *)skb->data; |
2392 | ver = ershdr->ver; |
2393 | - tpi->key = cpu_to_be32(get_session_id(ershdr)); |
2394 | |
2395 | tunnel = ip6gre_tunnel_lookup(skb->dev, |
2396 | &ipv6h->saddr, &ipv6h->daddr, tpi->key, |
2397 | @@ -2124,12 +2120,17 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev) |
2398 | { |
2399 | struct ip6_tnl *t = netdev_priv(dev); |
2400 | struct __ip6_tnl_parm *p = &t->parms; |
2401 | + __be16 o_flags = p->o_flags; |
2402 | + |
2403 | + if ((p->erspan_ver == 1 || p->erspan_ver == 2) && |
2404 | + !p->collect_md) |
2405 | + o_flags |= TUNNEL_KEY; |
2406 | |
2407 | if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) || |
2408 | nla_put_be16(skb, IFLA_GRE_IFLAGS, |
2409 | gre_tnl_flags_to_gre_flags(p->i_flags)) || |
2410 | nla_put_be16(skb, IFLA_GRE_OFLAGS, |
2411 | - gre_tnl_flags_to_gre_flags(p->o_flags)) || |
2412 | + gre_tnl_flags_to_gre_flags(o_flags)) || |
2413 | nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) || |
2414 | nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) || |
2415 | nla_put_in6_addr(skb, IFLA_GRE_LOCAL, &p->laddr) || |
2416 | diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c |
2417 | index 331e6b6dd252..10aafea3af0f 100644 |
2418 | --- a/net/ipv6/ip6mr.c |
2419 | +++ b/net/ipv6/ip6mr.c |
2420 | @@ -1506,6 +1506,9 @@ static void mroute_clean_tables(struct mr_table *mrt, bool all) |
2421 | continue; |
2422 | rhltable_remove(&mrt->mfc_hash, &c->mnode, ip6mr_rht_params); |
2423 | list_del_rcu(&c->list); |
2424 | + call_ip6mr_mfc_entry_notifiers(read_pnet(&mrt->net), |
2425 | + FIB_EVENT_ENTRY_DEL, |
2426 | + (struct mfc6_cache *)c, mrt->id); |
2427 | mr6_netlink_event(mrt, (struct mfc6_cache *)c, RTM_DELROUTE); |
2428 | mr_cache_put(c); |
2429 | } |
2430 | @@ -1514,10 +1517,6 @@ static void mroute_clean_tables(struct mr_table *mrt, bool all) |
2431 | spin_lock_bh(&mfc_unres_lock); |
2432 | list_for_each_entry_safe(c, tmp, &mrt->mfc_unres_queue, list) { |
2433 | list_del(&c->list); |
2434 | - call_ip6mr_mfc_entry_notifiers(read_pnet(&mrt->net), |
2435 | - FIB_EVENT_ENTRY_DEL, |
2436 | - (struct mfc6_cache *)c, |
2437 | - mrt->id); |
2438 | mr6_netlink_event(mrt, (struct mfc6_cache *)c, |
2439 | RTM_DELROUTE); |
2440 | ip6mr_destroy_unres(mrt, (struct mfc6_cache *)c); |
2441 | diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c |
2442 | index 8181ee7e1e27..ee5403cbe655 100644 |
2443 | --- a/net/ipv6/seg6_iptunnel.c |
2444 | +++ b/net/ipv6/seg6_iptunnel.c |
2445 | @@ -146,6 +146,8 @@ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto) |
2446 | } else { |
2447 | ip6_flow_hdr(hdr, 0, flowlabel); |
2448 | hdr->hop_limit = ip6_dst_hoplimit(skb_dst(skb)); |
2449 | + |
2450 | + memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); |
2451 | } |
2452 | |
2453 | hdr->nexthdr = NEXTHDR_ROUTING; |
2454 | diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c |
2455 | index 26f1d435696a..fed6becc5daf 100644 |
2456 | --- a/net/l2tp/l2tp_core.c |
2457 | +++ b/net/l2tp/l2tp_core.c |
2458 | @@ -83,8 +83,7 @@ |
2459 | #define L2TP_SLFLAG_S 0x40000000 |
2460 | #define L2TP_SL_SEQ_MASK 0x00ffffff |
2461 | |
2462 | -#define L2TP_HDR_SIZE_SEQ 10 |
2463 | -#define L2TP_HDR_SIZE_NOSEQ 6 |
2464 | +#define L2TP_HDR_SIZE_MAX 14 |
2465 | |
2466 | /* Default trace flags */ |
2467 | #define L2TP_DEFAULT_DEBUG_FLAGS 0 |
2468 | @@ -808,7 +807,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb) |
2469 | __skb_pull(skb, sizeof(struct udphdr)); |
2470 | |
2471 | /* Short packet? */ |
2472 | - if (!pskb_may_pull(skb, L2TP_HDR_SIZE_SEQ)) { |
2473 | + if (!pskb_may_pull(skb, L2TP_HDR_SIZE_MAX)) { |
2474 | l2tp_info(tunnel, L2TP_MSG_DATA, |
2475 | "%s: recv short packet (len=%d)\n", |
2476 | tunnel->name, skb->len); |
2477 | @@ -884,6 +883,10 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb) |
2478 | goto error; |
2479 | } |
2480 | |
2481 | + if (tunnel->version == L2TP_HDR_VER_3 && |
2482 | + l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr)) |
2483 | + goto error; |
2484 | + |
2485 | l2tp_recv_common(session, skb, ptr, optr, hdrflags, length); |
2486 | l2tp_session_dec_refcount(session); |
2487 | |
2488 | diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h |
2489 | index 9c9afe94d389..b2ce90260c35 100644 |
2490 | --- a/net/l2tp/l2tp_core.h |
2491 | +++ b/net/l2tp/l2tp_core.h |
2492 | @@ -301,6 +301,26 @@ static inline bool l2tp_tunnel_uses_xfrm(const struct l2tp_tunnel *tunnel) |
2493 | } |
2494 | #endif |
2495 | |
2496 | +static inline int l2tp_v3_ensure_opt_in_linear(struct l2tp_session *session, struct sk_buff *skb, |
2497 | + unsigned char **ptr, unsigned char **optr) |
2498 | +{ |
2499 | + int opt_len = session->peer_cookie_len + l2tp_get_l2specific_len(session); |
2500 | + |
2501 | + if (opt_len > 0) { |
2502 | + int off = *ptr - *optr; |
2503 | + |
2504 | + if (!pskb_may_pull(skb, off + opt_len)) |
2505 | + return -1; |
2506 | + |
2507 | + if (skb->data != *optr) { |
2508 | + *optr = skb->data; |
2509 | + *ptr = skb->data + off; |
2510 | + } |
2511 | + } |
2512 | + |
2513 | + return 0; |
2514 | +} |
2515 | + |
2516 | #define l2tp_printk(ptr, type, func, fmt, ...) \ |
2517 | do { \ |
2518 | if (((ptr)->debug) & (type)) \ |
2519 | diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c |
2520 | index 35f6f86d4dcc..d4c60523c549 100644 |
2521 | --- a/net/l2tp/l2tp_ip.c |
2522 | +++ b/net/l2tp/l2tp_ip.c |
2523 | @@ -165,6 +165,9 @@ static int l2tp_ip_recv(struct sk_buff *skb) |
2524 | print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length); |
2525 | } |
2526 | |
2527 | + if (l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr)) |
2528 | + goto discard_sess; |
2529 | + |
2530 | l2tp_recv_common(session, skb, ptr, optr, 0, skb->len); |
2531 | l2tp_session_dec_refcount(session); |
2532 | |
2533 | diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c |
2534 | index 237f1a4a0b0c..0ae6899edac0 100644 |
2535 | --- a/net/l2tp/l2tp_ip6.c |
2536 | +++ b/net/l2tp/l2tp_ip6.c |
2537 | @@ -178,6 +178,9 @@ static int l2tp_ip6_recv(struct sk_buff *skb) |
2538 | print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length); |
2539 | } |
2540 | |
2541 | + if (l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr)) |
2542 | + goto discard_sess; |
2543 | + |
2544 | l2tp_recv_common(session, skb, ptr, optr, 0, skb->len); |
2545 | l2tp_session_dec_refcount(session); |
2546 | |
2547 | diff --git a/net/netrom/nr_timer.c b/net/netrom/nr_timer.c |
2548 | index cbd51ed5a2d7..908e53ab47a4 100644 |
2549 | --- a/net/netrom/nr_timer.c |
2550 | +++ b/net/netrom/nr_timer.c |
2551 | @@ -52,21 +52,21 @@ void nr_start_t1timer(struct sock *sk) |
2552 | { |
2553 | struct nr_sock *nr = nr_sk(sk); |
2554 | |
2555 | - mod_timer(&nr->t1timer, jiffies + nr->t1); |
2556 | + sk_reset_timer(sk, &nr->t1timer, jiffies + nr->t1); |
2557 | } |
2558 | |
2559 | void nr_start_t2timer(struct sock *sk) |
2560 | { |
2561 | struct nr_sock *nr = nr_sk(sk); |
2562 | |
2563 | - mod_timer(&nr->t2timer, jiffies + nr->t2); |
2564 | + sk_reset_timer(sk, &nr->t2timer, jiffies + nr->t2); |
2565 | } |
2566 | |
2567 | void nr_start_t4timer(struct sock *sk) |
2568 | { |
2569 | struct nr_sock *nr = nr_sk(sk); |
2570 | |
2571 | - mod_timer(&nr->t4timer, jiffies + nr->t4); |
2572 | + sk_reset_timer(sk, &nr->t4timer, jiffies + nr->t4); |
2573 | } |
2574 | |
2575 | void nr_start_idletimer(struct sock *sk) |
2576 | @@ -74,37 +74,37 @@ void nr_start_idletimer(struct sock *sk) |
2577 | struct nr_sock *nr = nr_sk(sk); |
2578 | |
2579 | if (nr->idle > 0) |
2580 | - mod_timer(&nr->idletimer, jiffies + nr->idle); |
2581 | + sk_reset_timer(sk, &nr->idletimer, jiffies + nr->idle); |
2582 | } |
2583 | |
2584 | void nr_start_heartbeat(struct sock *sk) |
2585 | { |
2586 | - mod_timer(&sk->sk_timer, jiffies + 5 * HZ); |
2587 | + sk_reset_timer(sk, &sk->sk_timer, jiffies + 5 * HZ); |
2588 | } |
2589 | |
2590 | void nr_stop_t1timer(struct sock *sk) |
2591 | { |
2592 | - del_timer(&nr_sk(sk)->t1timer); |
2593 | + sk_stop_timer(sk, &nr_sk(sk)->t1timer); |
2594 | } |
2595 | |
2596 | void nr_stop_t2timer(struct sock *sk) |
2597 | { |
2598 | - del_timer(&nr_sk(sk)->t2timer); |
2599 | + sk_stop_timer(sk, &nr_sk(sk)->t2timer); |
2600 | } |
2601 | |
2602 | void nr_stop_t4timer(struct sock *sk) |
2603 | { |
2604 | - del_timer(&nr_sk(sk)->t4timer); |
2605 | + sk_stop_timer(sk, &nr_sk(sk)->t4timer); |
2606 | } |
2607 | |
2608 | void nr_stop_idletimer(struct sock *sk) |
2609 | { |
2610 | - del_timer(&nr_sk(sk)->idletimer); |
2611 | + sk_stop_timer(sk, &nr_sk(sk)->idletimer); |
2612 | } |
2613 | |
2614 | void nr_stop_heartbeat(struct sock *sk) |
2615 | { |
2616 | - del_timer(&sk->sk_timer); |
2617 | + sk_stop_timer(sk, &sk->sk_timer); |
2618 | } |
2619 | |
2620 | int nr_t1timer_running(struct sock *sk) |
2621 | diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c |
2622 | index 77e9f85a2c92..f2ff21d7df08 100644 |
2623 | --- a/net/rose/rose_route.c |
2624 | +++ b/net/rose/rose_route.c |
2625 | @@ -850,6 +850,7 @@ void rose_link_device_down(struct net_device *dev) |
2626 | |
2627 | /* |
2628 | * Route a frame to an appropriate AX.25 connection. |
2629 | + * A NULL ax25_cb indicates an internally generated frame. |
2630 | */ |
2631 | int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25) |
2632 | { |
2633 | @@ -867,6 +868,10 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25) |
2634 | |
2635 | if (skb->len < ROSE_MIN_LEN) |
2636 | return res; |
2637 | + |
2638 | + if (!ax25) |
2639 | + return rose_loopback_queue(skb, NULL); |
2640 | + |
2641 | frametype = skb->data[2]; |
2642 | lci = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF); |
2643 | if (frametype == ROSE_CALL_REQUEST && |
2644 | diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c |
2645 | index 0bae07e9c9e7..4fede55b9010 100644 |
2646 | --- a/net/sctp/ipv6.c |
2647 | +++ b/net/sctp/ipv6.c |
2648 | @@ -277,7 +277,8 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr, |
2649 | |
2650 | if (saddr) { |
2651 | fl6->saddr = saddr->v6.sin6_addr; |
2652 | - fl6->fl6_sport = saddr->v6.sin6_port; |
2653 | + if (!fl6->fl6_sport) |
2654 | + fl6->fl6_sport = saddr->v6.sin6_port; |
2655 | |
2656 | pr_debug("src=%pI6 - ", &fl6->saddr); |
2657 | } |
2658 | diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c |
2659 | index d4352111e69d..1c9f079e8a50 100644 |
2660 | --- a/net/sctp/protocol.c |
2661 | +++ b/net/sctp/protocol.c |
2662 | @@ -440,7 +440,8 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr, |
2663 | } |
2664 | if (saddr) { |
2665 | fl4->saddr = saddr->v4.sin_addr.s_addr; |
2666 | - fl4->fl4_sport = saddr->v4.sin_port; |
2667 | + if (!fl4->fl4_sport) |
2668 | + fl4->fl4_sport = saddr->v4.sin_port; |
2669 | } |
2670 | |
2671 | pr_debug("%s: dst:%pI4, src:%pI4 - ", __func__, &fl4->daddr, |
2672 | diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c |
2673 | index f4ac6c592e13..d05c57664e36 100644 |
2674 | --- a/net/sctp/sm_make_chunk.c |
2675 | +++ b/net/sctp/sm_make_chunk.c |
2676 | @@ -495,7 +495,10 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, |
2677 | * |
2678 | * [INIT ACK back to where the INIT came from.] |
2679 | */ |
2680 | - retval->transport = chunk->transport; |
2681 | + if (chunk->transport) |
2682 | + retval->transport = |
2683 | + sctp_assoc_lookup_paddr(asoc, |
2684 | + &chunk->transport->ipaddr); |
2685 | |
2686 | retval->subh.init_hdr = |
2687 | sctp_addto_chunk(retval, sizeof(initack), &initack); |
2688 | @@ -642,8 +645,10 @@ struct sctp_chunk *sctp_make_cookie_ack(const struct sctp_association *asoc, |
2689 | * |
2690 | * [COOKIE ACK back to where the COOKIE ECHO came from.] |
2691 | */ |
2692 | - if (retval && chunk) |
2693 | - retval->transport = chunk->transport; |
2694 | + if (retval && chunk && chunk->transport) |
2695 | + retval->transport = |
2696 | + sctp_assoc_lookup_paddr(asoc, |
2697 | + &chunk->transport->ipaddr); |
2698 | |
2699 | return retval; |
2700 | } |
2701 | diff --git a/net/sctp/stream.c b/net/sctp/stream.c |
2702 | index 3892e7630f3a..80e0ae5534ec 100644 |
2703 | --- a/net/sctp/stream.c |
2704 | +++ b/net/sctp/stream.c |
2705 | @@ -585,9 +585,9 @@ struct sctp_chunk *sctp_process_strreset_outreq( |
2706 | struct sctp_strreset_outreq *outreq = param.v; |
2707 | struct sctp_stream *stream = &asoc->stream; |
2708 | __u32 result = SCTP_STRRESET_DENIED; |
2709 | - __u16 i, nums, flags = 0; |
2710 | __be16 *str_p = NULL; |
2711 | __u32 request_seq; |
2712 | + __u16 i, nums; |
2713 | |
2714 | request_seq = ntohl(outreq->request_seq); |
2715 | |
2716 | @@ -615,6 +615,15 @@ struct sctp_chunk *sctp_process_strreset_outreq( |
2717 | if (!(asoc->strreset_enable & SCTP_ENABLE_RESET_STREAM_REQ)) |
2718 | goto out; |
2719 | |
2720 | + nums = (ntohs(param.p->length) - sizeof(*outreq)) / sizeof(__u16); |
2721 | + str_p = outreq->list_of_streams; |
2722 | + for (i = 0; i < nums; i++) { |
2723 | + if (ntohs(str_p[i]) >= stream->incnt) { |
2724 | + result = SCTP_STRRESET_ERR_WRONG_SSN; |
2725 | + goto out; |
2726 | + } |
2727 | + } |
2728 | + |
2729 | if (asoc->strreset_chunk) { |
2730 | if (!sctp_chunk_lookup_strreset_param( |
2731 | asoc, outreq->response_seq, |
2732 | @@ -637,32 +646,19 @@ struct sctp_chunk *sctp_process_strreset_outreq( |
2733 | sctp_chunk_put(asoc->strreset_chunk); |
2734 | asoc->strreset_chunk = NULL; |
2735 | } |
2736 | - |
2737 | - flags = SCTP_STREAM_RESET_INCOMING_SSN; |
2738 | } |
2739 | |
2740 | - nums = (ntohs(param.p->length) - sizeof(*outreq)) / sizeof(__u16); |
2741 | - if (nums) { |
2742 | - str_p = outreq->list_of_streams; |
2743 | - for (i = 0; i < nums; i++) { |
2744 | - if (ntohs(str_p[i]) >= stream->incnt) { |
2745 | - result = SCTP_STRRESET_ERR_WRONG_SSN; |
2746 | - goto out; |
2747 | - } |
2748 | - } |
2749 | - |
2750 | + if (nums) |
2751 | for (i = 0; i < nums; i++) |
2752 | SCTP_SI(stream, ntohs(str_p[i]))->mid = 0; |
2753 | - } else { |
2754 | + else |
2755 | for (i = 0; i < stream->incnt; i++) |
2756 | SCTP_SI(stream, i)->mid = 0; |
2757 | - } |
2758 | |
2759 | result = SCTP_STRRESET_PERFORMED; |
2760 | |
2761 | *evp = sctp_ulpevent_make_stream_reset_event(asoc, |
2762 | - flags | SCTP_STREAM_RESET_OUTGOING_SSN, nums, str_p, |
2763 | - GFP_ATOMIC); |
2764 | + SCTP_STREAM_RESET_INCOMING_SSN, nums, str_p, GFP_ATOMIC); |
2765 | |
2766 | out: |
2767 | sctp_update_strreset_result(asoc, result); |
2768 | @@ -738,9 +734,6 @@ struct sctp_chunk *sctp_process_strreset_inreq( |
2769 | |
2770 | result = SCTP_STRRESET_PERFORMED; |
2771 | |
2772 | - *evp = sctp_ulpevent_make_stream_reset_event(asoc, |
2773 | - SCTP_STREAM_RESET_INCOMING_SSN, nums, str_p, GFP_ATOMIC); |
2774 | - |
2775 | out: |
2776 | sctp_update_strreset_result(asoc, result); |
2777 | err: |
2778 | @@ -873,6 +866,14 @@ struct sctp_chunk *sctp_process_strreset_addstrm_out( |
2779 | if (!(asoc->strreset_enable & SCTP_ENABLE_CHANGE_ASSOC_REQ)) |
2780 | goto out; |
2781 | |
2782 | + in = ntohs(addstrm->number_of_streams); |
2783 | + incnt = stream->incnt + in; |
2784 | + if (!in || incnt > SCTP_MAX_STREAM) |
2785 | + goto out; |
2786 | + |
2787 | + if (sctp_stream_alloc_in(stream, incnt, GFP_ATOMIC)) |
2788 | + goto out; |
2789 | + |
2790 | if (asoc->strreset_chunk) { |
2791 | if (!sctp_chunk_lookup_strreset_param( |
2792 | asoc, 0, SCTP_PARAM_RESET_ADD_IN_STREAMS)) { |
2793 | @@ -896,14 +897,6 @@ struct sctp_chunk *sctp_process_strreset_addstrm_out( |
2794 | } |
2795 | } |
2796 | |
2797 | - in = ntohs(addstrm->number_of_streams); |
2798 | - incnt = stream->incnt + in; |
2799 | - if (!in || incnt > SCTP_MAX_STREAM) |
2800 | - goto out; |
2801 | - |
2802 | - if (sctp_stream_alloc_in(stream, incnt, GFP_ATOMIC)) |
2803 | - goto out; |
2804 | - |
2805 | stream->incnt = incnt; |
2806 | |
2807 | result = SCTP_STRRESET_PERFORMED; |
2808 | @@ -973,9 +966,6 @@ struct sctp_chunk *sctp_process_strreset_addstrm_in( |
2809 | |
2810 | result = SCTP_STRRESET_PERFORMED; |
2811 | |
2812 | - *evp = sctp_ulpevent_make_stream_change_event(asoc, |
2813 | - 0, 0, ntohs(addstrm->number_of_streams), GFP_ATOMIC); |
2814 | - |
2815 | out: |
2816 | sctp_update_strreset_result(asoc, result); |
2817 | err: |
2818 | @@ -1036,10 +1026,10 @@ struct sctp_chunk *sctp_process_strreset_resp( |
2819 | sout->mid_uo = 0; |
2820 | } |
2821 | } |
2822 | - |
2823 | - flags = SCTP_STREAM_RESET_OUTGOING_SSN; |
2824 | } |
2825 | |
2826 | + flags |= SCTP_STREAM_RESET_OUTGOING_SSN; |
2827 | + |
2828 | for (i = 0; i < stream->outcnt; i++) |
2829 | SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN; |
2830 | |
2831 | @@ -1058,6 +1048,8 @@ struct sctp_chunk *sctp_process_strreset_resp( |
2832 | nums = (ntohs(inreq->param_hdr.length) - sizeof(*inreq)) / |
2833 | sizeof(__u16); |
2834 | |
2835 | + flags |= SCTP_STREAM_RESET_INCOMING_SSN; |
2836 | + |
2837 | *evp = sctp_ulpevent_make_stream_reset_event(asoc, flags, |
2838 | nums, str_p, GFP_ATOMIC); |
2839 | } else if (req->type == SCTP_PARAM_RESET_TSN_REQUEST) { |
2840 | diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c |
2841 | index f39f34e12fb6..dbb38fe2da7d 100644 |
2842 | --- a/sound/pci/hda/patch_realtek.c |
2843 | +++ b/sound/pci/hda/patch_realtek.c |
2844 | @@ -117,6 +117,7 @@ struct alc_spec { |
2845 | int codec_variant; /* flag for other variants */ |
2846 | unsigned int has_alc5505_dsp:1; |
2847 | unsigned int no_depop_delay:1; |
2848 | + unsigned int done_hp_init:1; |
2849 | |
2850 | /* for PLL fix */ |
2851 | hda_nid_t pll_nid; |
2852 | @@ -3372,6 +3373,48 @@ static void alc_default_shutup(struct hda_codec *codec) |
2853 | snd_hda_shutup_pins(codec); |
2854 | } |
2855 | |
2856 | +static void alc294_hp_init(struct hda_codec *codec) |
2857 | +{ |
2858 | + struct alc_spec *spec = codec->spec; |
2859 | + hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; |
2860 | + int i, val; |
2861 | + |
2862 | + if (!hp_pin) |
2863 | + return; |
2864 | + |
2865 | + snd_hda_codec_write(codec, hp_pin, 0, |
2866 | + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); |
2867 | + |
2868 | + msleep(100); |
2869 | + |
2870 | + snd_hda_codec_write(codec, hp_pin, 0, |
2871 | + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); |
2872 | + |
2873 | + alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */ |
2874 | + alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */ |
2875 | + |
2876 | + /* Wait for depop procedure finish */ |
2877 | + val = alc_read_coefex_idx(codec, 0x58, 0x01); |
2878 | + for (i = 0; i < 20 && val & 0x0080; i++) { |
2879 | + msleep(50); |
2880 | + val = alc_read_coefex_idx(codec, 0x58, 0x01); |
2881 | + } |
2882 | + /* Set HP depop to auto mode */ |
2883 | + alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b); |
2884 | + msleep(50); |
2885 | +} |
2886 | + |
2887 | +static void alc294_init(struct hda_codec *codec) |
2888 | +{ |
2889 | + struct alc_spec *spec = codec->spec; |
2890 | + |
2891 | + if (!spec->done_hp_init) { |
2892 | + alc294_hp_init(codec); |
2893 | + spec->done_hp_init = true; |
2894 | + } |
2895 | + alc_default_init(codec); |
2896 | +} |
2897 | + |
2898 | static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg, |
2899 | unsigned int val) |
2900 | { |
2901 | @@ -7288,37 +7331,6 @@ static void alc269_fill_coef(struct hda_codec *codec) |
2902 | alc_update_coef_idx(codec, 0x4, 0, 1<<11); |
2903 | } |
2904 | |
2905 | -static void alc294_hp_init(struct hda_codec *codec) |
2906 | -{ |
2907 | - struct alc_spec *spec = codec->spec; |
2908 | - hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; |
2909 | - int i, val; |
2910 | - |
2911 | - if (!hp_pin) |
2912 | - return; |
2913 | - |
2914 | - snd_hda_codec_write(codec, hp_pin, 0, |
2915 | - AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); |
2916 | - |
2917 | - msleep(100); |
2918 | - |
2919 | - snd_hda_codec_write(codec, hp_pin, 0, |
2920 | - AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); |
2921 | - |
2922 | - alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */ |
2923 | - alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */ |
2924 | - |
2925 | - /* Wait for depop procedure finish */ |
2926 | - val = alc_read_coefex_idx(codec, 0x58, 0x01); |
2927 | - for (i = 0; i < 20 && val & 0x0080; i++) { |
2928 | - msleep(50); |
2929 | - val = alc_read_coefex_idx(codec, 0x58, 0x01); |
2930 | - } |
2931 | - /* Set HP depop to auto mode */ |
2932 | - alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b); |
2933 | - msleep(50); |
2934 | -} |
2935 | - |
2936 | /* |
2937 | */ |
2938 | static int patch_alc269(struct hda_codec *codec) |
2939 | @@ -7444,7 +7456,7 @@ static int patch_alc269(struct hda_codec *codec) |
2940 | spec->codec_variant = ALC269_TYPE_ALC294; |
2941 | spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */ |
2942 | alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */ |
2943 | - alc294_hp_init(codec); |
2944 | + spec->init_hook = alc294_init; |
2945 | break; |
2946 | case 0x10ec0300: |
2947 | spec->codec_variant = ALC269_TYPE_ALC300; |
2948 | @@ -7456,7 +7468,7 @@ static int patch_alc269(struct hda_codec *codec) |
2949 | spec->codec_variant = ALC269_TYPE_ALC700; |
2950 | spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */ |
2951 | alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */ |
2952 | - alc294_hp_init(codec); |
2953 | + spec->init_hook = alc294_init; |
2954 | break; |
2955 | |
2956 | } |
2957 | diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c |
2958 | index 6623cafc94f2..7e93686a430a 100644 |
2959 | --- a/sound/usb/quirks.c |
2960 | +++ b/sound/usb/quirks.c |
2961 | @@ -1373,6 +1373,7 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, |
2962 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; |
2963 | break; |
2964 | |
2965 | + case USB_ID(0x10cb, 0x0103): /* The Bit Opus #3; with fp->dsd_raw */ |
2966 | case USB_ID(0x152a, 0x85de): /* SMSL D1 DAC */ |
2967 | case USB_ID(0x16d0, 0x09dd): /* Encore mDSD */ |
2968 | case USB_ID(0x0d8c, 0x0316): /* Hegel HD12 DSD */ |
2969 | diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c |
2970 | index e1473234968d..83057fa9d391 100644 |
2971 | --- a/tools/testing/selftests/seccomp/seccomp_bpf.c |
2972 | +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c |
2973 | @@ -1563,7 +1563,16 @@ TEST_F(TRACE_poke, getpid_runs_normally) |
2974 | #ifdef SYSCALL_NUM_RET_SHARE_REG |
2975 | # define EXPECT_SYSCALL_RETURN(val, action) EXPECT_EQ(-1, action) |
2976 | #else |
2977 | -# define EXPECT_SYSCALL_RETURN(val, action) EXPECT_EQ(val, action) |
2978 | +# define EXPECT_SYSCALL_RETURN(val, action) \ |
2979 | + do { \ |
2980 | + errno = 0; \ |
2981 | + if (val < 0) { \ |
2982 | + EXPECT_EQ(-1, action); \ |
2983 | + EXPECT_EQ(-(val), errno); \ |
2984 | + } else { \ |
2985 | + EXPECT_EQ(val, action); \ |
2986 | + } \ |
2987 | + } while (0) |
2988 | #endif |
2989 | |
2990 | /* Use PTRACE_GETREGS and PTRACE_SETREGS when available. This is useful for |
2991 | @@ -1602,7 +1611,7 @@ int get_syscall(struct __test_metadata *_metadata, pid_t tracee) |
2992 | |
2993 | /* Architecture-specific syscall changing routine. */ |
2994 | void change_syscall(struct __test_metadata *_metadata, |
2995 | - pid_t tracee, int syscall) |
2996 | + pid_t tracee, int syscall, int result) |
2997 | { |
2998 | int ret; |
2999 | ARCH_REGS regs; |
3000 | @@ -1661,7 +1670,7 @@ void change_syscall(struct __test_metadata *_metadata, |
3001 | #ifdef SYSCALL_NUM_RET_SHARE_REG |
3002 | TH_LOG("Can't modify syscall return on this architecture"); |
3003 | #else |
3004 | - regs.SYSCALL_RET = EPERM; |
3005 | + regs.SYSCALL_RET = result; |
3006 | #endif |
3007 | |
3008 | #ifdef HAVE_GETREGS |
3009 | @@ -1689,14 +1698,19 @@ void tracer_syscall(struct __test_metadata *_metadata, pid_t tracee, |
3010 | case 0x1002: |
3011 | /* change getpid to getppid. */ |
3012 | EXPECT_EQ(__NR_getpid, get_syscall(_metadata, tracee)); |
3013 | - change_syscall(_metadata, tracee, __NR_getppid); |
3014 | + change_syscall(_metadata, tracee, __NR_getppid, 0); |
3015 | break; |
3016 | case 0x1003: |
3017 | - /* skip gettid. */ |
3018 | + /* skip gettid with valid return code. */ |
3019 | EXPECT_EQ(__NR_gettid, get_syscall(_metadata, tracee)); |
3020 | - change_syscall(_metadata, tracee, -1); |
3021 | + change_syscall(_metadata, tracee, -1, 45000); |
3022 | break; |
3023 | case 0x1004: |
3024 | + /* skip openat with error. */ |
3025 | + EXPECT_EQ(__NR_openat, get_syscall(_metadata, tracee)); |
3026 | + change_syscall(_metadata, tracee, -1, -ESRCH); |
3027 | + break; |
3028 | + case 0x1005: |
3029 | /* do nothing (allow getppid) */ |
3030 | EXPECT_EQ(__NR_getppid, get_syscall(_metadata, tracee)); |
3031 | break; |
3032 | @@ -1729,9 +1743,11 @@ void tracer_ptrace(struct __test_metadata *_metadata, pid_t tracee, |
3033 | nr = get_syscall(_metadata, tracee); |
3034 | |
3035 | if (nr == __NR_getpid) |
3036 | - change_syscall(_metadata, tracee, __NR_getppid); |
3037 | + change_syscall(_metadata, tracee, __NR_getppid, 0); |
3038 | + if (nr == __NR_gettid) |
3039 | + change_syscall(_metadata, tracee, -1, 45000); |
3040 | if (nr == __NR_openat) |
3041 | - change_syscall(_metadata, tracee, -1); |
3042 | + change_syscall(_metadata, tracee, -1, -ESRCH); |
3043 | } |
3044 | |
3045 | FIXTURE_DATA(TRACE_syscall) { |
3046 | @@ -1748,8 +1764,10 @@ FIXTURE_SETUP(TRACE_syscall) |
3047 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1002), |
3048 | BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_gettid, 0, 1), |
3049 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1003), |
3050 | - BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getppid, 0, 1), |
3051 | + BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_openat, 0, 1), |
3052 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1004), |
3053 | + BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getppid, 0, 1), |
3054 | + BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_TRACE | 0x1005), |
3055 | BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), |
3056 | }; |
3057 | |
3058 | @@ -1797,15 +1815,26 @@ TEST_F(TRACE_syscall, ptrace_syscall_redirected) |
3059 | EXPECT_NE(self->mypid, syscall(__NR_getpid)); |
3060 | } |
3061 | |
3062 | -TEST_F(TRACE_syscall, ptrace_syscall_dropped) |
3063 | +TEST_F(TRACE_syscall, ptrace_syscall_errno) |
3064 | +{ |
3065 | + /* Swap SECCOMP_RET_TRACE tracer for PTRACE_SYSCALL tracer. */ |
3066 | + teardown_trace_fixture(_metadata, self->tracer); |
3067 | + self->tracer = setup_trace_fixture(_metadata, tracer_ptrace, NULL, |
3068 | + true); |
3069 | + |
3070 | + /* Tracer should skip the open syscall, resulting in ESRCH. */ |
3071 | + EXPECT_SYSCALL_RETURN(-ESRCH, syscall(__NR_openat)); |
3072 | +} |
3073 | + |
3074 | +TEST_F(TRACE_syscall, ptrace_syscall_faked) |
3075 | { |
3076 | /* Swap SECCOMP_RET_TRACE tracer for PTRACE_SYSCALL tracer. */ |
3077 | teardown_trace_fixture(_metadata, self->tracer); |
3078 | self->tracer = setup_trace_fixture(_metadata, tracer_ptrace, NULL, |
3079 | true); |
3080 | |
3081 | - /* Tracer should skip the open syscall, resulting in EPERM. */ |
3082 | - EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_openat)); |
3083 | + /* Tracer should skip the gettid syscall, resulting fake pid. */ |
3084 | + EXPECT_SYSCALL_RETURN(45000, syscall(__NR_gettid)); |
3085 | } |
3086 | |
3087 | TEST_F(TRACE_syscall, syscall_allowed) |
3088 | @@ -1838,7 +1867,21 @@ TEST_F(TRACE_syscall, syscall_redirected) |
3089 | EXPECT_NE(self->mypid, syscall(__NR_getpid)); |
3090 | } |
3091 | |
3092 | -TEST_F(TRACE_syscall, syscall_dropped) |
3093 | +TEST_F(TRACE_syscall, syscall_errno) |
3094 | +{ |
3095 | + long ret; |
3096 | + |
3097 | + ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); |
3098 | + ASSERT_EQ(0, ret); |
3099 | + |
3100 | + ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &self->prog, 0, 0); |
3101 | + ASSERT_EQ(0, ret); |
3102 | + |
3103 | + /* openat has been skipped and an errno return. */ |
3104 | + EXPECT_SYSCALL_RETURN(-ESRCH, syscall(__NR_openat)); |
3105 | +} |
3106 | + |
3107 | +TEST_F(TRACE_syscall, syscall_faked) |
3108 | { |
3109 | long ret; |
3110 | |
3111 | @@ -1849,8 +1892,7 @@ TEST_F(TRACE_syscall, syscall_dropped) |
3112 | ASSERT_EQ(0, ret); |
3113 | |
3114 | /* gettid has been skipped and an altered return value stored. */ |
3115 | - EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_gettid)); |
3116 | - EXPECT_NE(self->mytid, syscall(__NR_gettid)); |
3117 | + EXPECT_SYSCALL_RETURN(45000, syscall(__NR_gettid)); |
3118 | } |
3119 | |
3120 | TEST_F(TRACE_syscall, skip_after_RET_TRACE) |