Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Simple overlapping changes in bpf land wrt. bpf_helper_defs.h
handling.

Signed-off-by: David S. Miller <davem@davemloft.net>

+1472 -1110
+5 -8
Documentation/dev-tools/kunit/start.rst
··· 24 24 For more information on this wrapper (also called kunit_tool) checkout the 25 25 :doc:`kunit-tool` page. 26 26 27 - Creating a kunitconfig 28 - ====================== 27 + Creating a .kunitconfig 28 + ======================= 29 29 The Python script is a thin wrapper around Kbuild. As such, it needs to be 30 - configured with a ``kunitconfig`` file. This file essentially contains the 30 + configured with a ``.kunitconfig`` file. This file essentially contains the 31 31 regular Kernel config, with the specific test targets as well. 32 32 33 33 .. code-block:: bash 34 34 35 - git clone -b master https://kunit.googlesource.com/kunitconfig $PATH_TO_KUNITCONFIG_REPO 36 35 cd $PATH_TO_LINUX_REPO 37 - ln -s $PATH_TO_KUNIT_CONFIG_REPO/kunitconfig kunitconfig 38 - 39 - You may want to add kunitconfig to your local gitignore. 36 + cp arch/um/configs/kunit_defconfig .kunitconfig 40 37 41 38 Verifying KUnit Works 42 39 --------------------- ··· 148 151 149 152 obj-$(CONFIG_MISC_EXAMPLE_TEST) += example-test.o 150 153 151 - Now add it to your ``kunitconfig``: 154 + Now add it to your ``.kunitconfig``: 152 155 153 156 .. code-block:: none 154 157
-6
Documentation/networking/dsa/sja1105.rst
··· 230 230 against this restriction and errors out when appropriate. Schedule analysis is 231 231 needed to avoid this, which is outside the scope of the document. 232 232 233 - At the moment, the time-aware scheduler can only be triggered based on a 234 - standalone clock and not based on PTP time. This means the base-time argument 235 - from tc-taprio is ignored and the schedule starts right away. It also means it 236 - is more difficult to phase-align the scheduler with the other devices in the 237 - network. 238 - 239 233 Device Tree bindings and board design 240 234 ===================================== 241 235
+3
MAINTAINERS
··· 771 771 772 772 AMAZON ETHERNET DRIVERS 773 773 M: Netanel Belgazal <netanel@amazon.com> 774 + M: Arthur Kiyanovski <akiyano@amazon.com> 775 + R: Guy Tzalik <gtzalik@amazon.com> 774 776 R: Saeed Bishara <saeedb@amazon.com> 775 777 R: Zorik Machulsky <zorik@amazon.com> 776 778 L: netdev@vger.kernel.org ··· 7036 7034 S: Maintained 7037 7035 F: Documentation/firmware-guide/acpi/gpio-properties.rst 7038 7036 F: drivers/gpio/gpiolib-acpi.c 7037 + F: drivers/gpio/gpiolib-acpi.h 7039 7038 7040 7039 GPIO IR Transmitter 7041 7040 M: Sean Young <sean@mess.org>
+1 -1
Makefile
··· 2 2 VERSION = 5 3 3 PATCHLEVEL = 5 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc2 5 + EXTRAVERSION = -rc4 6 6 NAME = Kleptomaniac Octopus 7 7 8 8 # *DOCUMENTATION*
+1
arch/riscv/kernel/entry.S
··· 246 246 */ 247 247 li t1, -1 248 248 beq a7, t1, ret_from_syscall_rejected 249 + blt a7, t1, 1f 249 250 /* Call syscall */ 250 251 la s0, sys_call_table 251 252 slli t0, a7, RISCV_LGPTR
-3
arch/riscv/kernel/riscv_ksyms.c
··· 9 9 /* 10 10 * Assembly functions that may be used (directly or indirectly) by modules 11 11 */ 12 - EXPORT_SYMBOL(__clear_user); 13 - EXPORT_SYMBOL(__asm_copy_to_user); 14 - EXPORT_SYMBOL(__asm_copy_from_user); 15 12 EXPORT_SYMBOL(memset); 16 13 EXPORT_SYMBOL(memcpy);
+4
arch/riscv/lib/uaccess.S
··· 1 1 #include <linux/linkage.h> 2 + #include <asm-generic/export.h> 2 3 #include <asm/asm.h> 3 4 #include <asm/csr.h> 4 5 ··· 67 66 j 3b 68 67 ENDPROC(__asm_copy_to_user) 69 68 ENDPROC(__asm_copy_from_user) 69 + EXPORT_SYMBOL(__asm_copy_to_user) 70 + EXPORT_SYMBOL(__asm_copy_from_user) 70 71 71 72 72 73 ENTRY(__clear_user) ··· 111 108 bltu a0, a3, 5b 112 109 j 3b 113 110 ENDPROC(__clear_user) 111 + EXPORT_SYMBOL(__clear_user) 114 112 115 113 .section .fixup,"ax" 116 114 .balign 4
+1
arch/riscv/mm/cacheflush.c
··· 22 22 else 23 23 on_each_cpu(ipi_remote_fence_i, NULL, 1); 24 24 } 25 + EXPORT_SYMBOL(flush_icache_all); 25 26 26 27 /* 27 28 * Performs an icache flush for the given MM context. RISC-V has no direct
+16
block/compat_ioctl.c
··· 6 6 #include <linux/compat.h> 7 7 #include <linux/elevator.h> 8 8 #include <linux/hdreg.h> 9 + #include <linux/pr.h> 9 10 #include <linux/slab.h> 10 11 #include <linux/syscalls.h> 11 12 #include <linux/types.h> ··· 355 354 * but we call blkdev_ioctl, which gets the lock for us 356 355 */ 357 356 case BLKRRPART: 357 + case BLKREPORTZONE: 358 + case BLKRESETZONE: 359 + case BLKOPENZONE: 360 + case BLKCLOSEZONE: 361 + case BLKFINISHZONE: 362 + case BLKGETZONESZ: 363 + case BLKGETNRZONES: 358 364 return blkdev_ioctl(bdev, mode, cmd, 359 365 (unsigned long)compat_ptr(arg)); 360 366 case BLKBSZSET_32: ··· 409 401 case BLKTRACETEARDOWN: /* compatible */ 410 402 ret = blk_trace_ioctl(bdev, cmd, compat_ptr(arg)); 411 403 return ret; 404 + case IOC_PR_REGISTER: 405 + case IOC_PR_RESERVE: 406 + case IOC_PR_RELEASE: 407 + case IOC_PR_PREEMPT: 408 + case IOC_PR_PREEMPT_ABORT: 409 + case IOC_PR_CLEAR: 410 + return blkdev_ioctl(bdev, mode, cmd, 411 + (unsigned long)compat_ptr(arg)); 412 412 default: 413 413 if (disk->fops->compat_ioctl) 414 414 ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg);
+95 -40
drivers/ata/ahci_brcm.c
··· 76 76 }; 77 77 78 78 enum brcm_ahci_quirks { 79 - BRCM_AHCI_QUIRK_NO_NCQ = BIT(0), 80 - BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(1), 79 + BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(0), 81 80 }; 82 81 83 82 struct brcm_ahci_priv { ··· 212 213 brcm_sata_phy_disable(priv, i); 213 214 } 214 215 215 - static u32 brcm_ahci_get_portmask(struct platform_device *pdev, 216 + static u32 brcm_ahci_get_portmask(struct ahci_host_priv *hpriv, 216 217 struct brcm_ahci_priv *priv) 217 218 { 218 - void __iomem *ahci; 219 - struct resource *res; 220 219 u32 impl; 221 220 222 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ahci"); 223 - ahci = devm_ioremap_resource(&pdev->dev, res); 224 - if (IS_ERR(ahci)) 225 - return 0; 226 - 227 - impl = readl(ahci + HOST_PORTS_IMPL); 221 + impl = readl(hpriv->mmio + HOST_PORTS_IMPL); 228 222 229 223 if (fls(impl) > SATA_TOP_MAX_PHYS) 230 224 dev_warn(priv->dev, "warning: more ports than PHYs (%#x)\n", 231 225 impl); 232 226 else if (!impl) 233 227 dev_info(priv->dev, "no ports found\n"); 234 - 235 - devm_iounmap(&pdev->dev, ahci); 236 - devm_release_mem_region(&pdev->dev, res->start, resource_size(res)); 237 228 238 229 return impl; 239 230 } ··· 273 284 274 285 /* Perform the SATA PHY reset sequence */ 275 286 brcm_sata_phy_disable(priv, ap->port_no); 287 + 288 + /* Reset the SATA clock */ 289 + ahci_platform_disable_clks(hpriv); 290 + msleep(10); 291 + 292 + ahci_platform_enable_clks(hpriv); 293 + msleep(10); 276 294 277 295 /* Bring the PHY back on */ 278 296 brcm_sata_phy_enable(priv, ap->port_no); ··· 343 347 struct ata_host *host = dev_get_drvdata(dev); 344 348 struct ahci_host_priv *hpriv = host->private_data; 345 349 struct brcm_ahci_priv *priv = hpriv->plat_data; 346 - int ret; 347 350 348 - ret = ahci_platform_suspend(dev); 349 351 brcm_sata_phys_disable(priv); 350 - return ret; 352 + 353 + return ahci_platform_suspend(dev); 351 354 } 352 355 353 356 static int brcm_ahci_resume(struct device *dev) ··· 354 359 struct ata_host *host = dev_get_drvdata(dev); 355 360 struct ahci_host_priv *hpriv = host->private_data; 356 361 struct brcm_ahci_priv *priv = hpriv->plat_data; 362 + int ret; 363 + 364 + /* Make sure clocks are turned on before re-configuration */ 365 + ret = ahci_platform_enable_clks(hpriv); 366 + if (ret) 367 + return ret; 357 368 358 369 brcm_sata_init(priv); 359 370 brcm_sata_phys_enable(priv); 360 371 brcm_sata_alpm_init(hpriv); 361 - return ahci_platform_resume(dev); 372 + 373 + /* Since we had to enable clocks earlier on, we cannot use 374 + * ahci_platform_resume() as-is since a second call to 375 + * ahci_platform_enable_resources() would bump up the resources 376 + * (regulators, clocks, PHYs) count artificially so we copy the part 377 + * after ahci_platform_enable_resources(). 378 + */ 379 + ret = ahci_platform_enable_phys(hpriv); 380 + if (ret) 381 + goto out_disable_phys; 382 + 383 + ret = ahci_platform_resume_host(dev); 384 + if (ret) 385 + goto out_disable_platform_phys; 386 + 387 + /* We resumed so update PM runtime state */ 388 + pm_runtime_disable(dev); 389 + pm_runtime_set_active(dev); 390 + pm_runtime_enable(dev); 391 + 392 + return 0; 393 + 394 + out_disable_platform_phys: 395 + ahci_platform_disable_phys(hpriv); 396 + out_disable_phys: 397 + brcm_sata_phys_disable(priv); 398 + ahci_platform_disable_clks(hpriv); 399 + return ret; 362 400 } 363 401 #endif 364 402 ··· 438 410 if (!IS_ERR_OR_NULL(priv->rcdev)) 439 411 reset_control_deassert(priv->rcdev); 440 412 441 - if ((priv->version == BRCM_SATA_BCM7425) || 442 - (priv->version == BRCM_SATA_NSP)) { 443 - priv->quirks |= BRCM_AHCI_QUIRK_NO_NCQ; 444 - priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE; 413 + hpriv = ahci_platform_get_resources(pdev, 0); 414 + if (IS_ERR(hpriv)) { 415 + ret = PTR_ERR(hpriv); 416 + goto out_reset; 445 417 } 446 418 419 + hpriv->plat_data = priv; 420 + hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP | AHCI_HFLAG_NO_WRITE_TO_RO; 421 + 422 + switch (priv->version) { 423 + case BRCM_SATA_BCM7425: 424 + hpriv->flags |= AHCI_HFLAG_DELAY_ENGINE; 425 + /* fall through */ 426 + case BRCM_SATA_NSP: 427 + hpriv->flags |= AHCI_HFLAG_NO_NCQ; 428 + priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE; 429 + break; 430 + default: 431 + break; 432 + } 433 + 434 + ret = ahci_platform_enable_clks(hpriv); 435 + if (ret) 436 + goto out_reset; 437 + 438 + /* Must be first so as to configure endianness including that 439 + * of the standard AHCI register space. 440 + */ 447 441 brcm_sata_init(priv); 448 442 449 - priv->port_mask = brcm_ahci_get_portmask(pdev, priv); 450 - if (!priv->port_mask) 451 - return -ENODEV; 443 + /* Initializes priv->port_mask which is used below */ 444 + priv->port_mask = brcm_ahci_get_portmask(hpriv, priv); 445 + if (!priv->port_mask) { 446 + ret = -ENODEV; 447 + goto out_disable_clks; 448 + } 452 449 450 + /* Must be done before ahci_platform_enable_phys() */ 453 451 brcm_sata_phys_enable(priv); 454 - 455 - hpriv = ahci_platform_get_resources(pdev, 0); 456 - if (IS_ERR(hpriv)) 457 - return PTR_ERR(hpriv); 458 - hpriv->plat_data = priv; 459 - hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP; 460 452 461 453 brcm_sata_alpm_init(hpriv); 462 454 463 - ret = ahci_platform_enable_resources(hpriv); 455 + ret = ahci_platform_enable_phys(hpriv); 464 456 if (ret) 465 - return ret; 466 - 467 - if (priv->quirks & BRCM_AHCI_QUIRK_NO_NCQ) 468 - hpriv->flags |= AHCI_HFLAG_NO_NCQ; 469 - hpriv->flags |= AHCI_HFLAG_NO_WRITE_TO_RO; 457 + goto out_disable_phys; 470 458 471 459 ret = ahci_platform_init_host(pdev, hpriv, &ahci_brcm_port_info, 472 460 &ahci_platform_sht); 473 461 if (ret) 474 - return ret; 462 + goto out_disable_platform_phys; 475 463 476 464 dev_info(dev, "Broadcom AHCI SATA3 registered\n"); 477 465 478 466 return 0; 467 + 468 + out_disable_platform_phys: 469 + ahci_platform_disable_phys(hpriv); 470 + out_disable_phys: 471 + brcm_sata_phys_disable(priv); 472 + out_disable_clks: 473 + ahci_platform_disable_clks(hpriv); 474 + out_reset: 475 + if (!IS_ERR_OR_NULL(priv->rcdev)) 476 + reset_control_assert(priv->rcdev); 477 + return ret; 479 478 } 480 479 481 480 static int brcm_ahci_remove(struct platform_device *pdev) ··· 512 457 struct brcm_ahci_priv *priv = hpriv->plat_data; 513 458 int ret; 514 459 460 + brcm_sata_phys_disable(priv); 461 + 515 462 ret = ata_platform_remove_one(pdev); 516 463 if (ret) 517 464 return ret; 518 - 519 - brcm_sata_phys_disable(priv); 520 465 521 466 return 0; 522 467 }
+4 -2
drivers/ata/libahci_platform.c
··· 43 43 * RETURNS: 44 44 * 0 on success otherwise a negative error code 45 45 */ 46 - static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv) 46 + int ahci_platform_enable_phys(struct ahci_host_priv *hpriv) 47 47 { 48 48 int rc, i; 49 49 ··· 74 74 } 75 75 return rc; 76 76 } 77 + EXPORT_SYMBOL_GPL(ahci_platform_enable_phys); 77 78 78 79 /** 79 80 * ahci_platform_disable_phys - Disable PHYs ··· 82 81 * 83 82 * This function disables all PHYs found in hpriv->phys. 84 83 */ 85 - static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) 84 + void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) 86 85 { 87 86 int i; 88 87 ··· 91 90 phy_exit(hpriv->phys[i]); 92 91 } 93 92 } 93 + EXPORT_SYMBOL_GPL(ahci_platform_disable_phys); 94 94 95 95 /** 96 96 * ahci_platform_enable_clks - Enable platform clocks
+24
drivers/ata/libata-core.c
··· 5329 5329 } 5330 5330 5331 5331 /** 5332 + * ata_qc_get_active - get bitmask of active qcs 5333 + * @ap: port in question 5334 + * 5335 + * LOCKING: 5336 + * spin_lock_irqsave(host lock) 5337 + * 5338 + * RETURNS: 5339 + * Bitmask of active qcs 5340 + */ 5341 + u64 ata_qc_get_active(struct ata_port *ap) 5342 + { 5343 + u64 qc_active = ap->qc_active; 5344 + 5345 + /* ATA_TAG_INTERNAL is sent to hw as tag 0 */ 5346 + if (qc_active & (1ULL << ATA_TAG_INTERNAL)) { 5347 + qc_active |= (1 << 0); 5348 + qc_active &= ~(1ULL << ATA_TAG_INTERNAL); 5349 + } 5350 + 5351 + return qc_active; 5352 + } 5353 + EXPORT_SYMBOL_GPL(ata_qc_get_active); 5354 + 5355 + /** 5332 5356 * ata_qc_complete_multiple - Complete multiple qcs successfully 5333 5357 * @ap: port in question 5334 5358 * @qc_active: new qc_active mask
+1 -1
drivers/ata/sata_fsl.c
··· 1280 1280 i, ioread32(hcr_base + CC), 1281 1281 ioread32(hcr_base + CA)); 1282 1282 } 1283 - ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask); 1283 + ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask); 1284 1284 return; 1285 1285 1286 1286 } else if ((ap->qc_active & (1ULL << ATA_TAG_INTERNAL))) {
+1 -1
drivers/ata/sata_mv.c
··· 2829 2829 } 2830 2830 2831 2831 if (work_done) { 2832 - ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask); 2832 + ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask); 2833 2833 2834 2834 /* Update the software queue position index in hardware */ 2835 2835 writelfl((pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK) |
+1 -1
drivers/ata/sata_nv.c
··· 984 984 check_commands = 0; 985 985 check_commands &= ~(1 << pos); 986 986 } 987 - ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask); 987 + ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask); 988 988 } 989 989 } 990 990
+1 -1
drivers/block/pktcdvd.c
··· 2707 2707 .release = pkt_close, 2708 2708 .ioctl = pkt_ioctl, 2709 2709 #ifdef CONFIG_COMPAT 2710 - .ioctl = pkt_compat_ioctl, 2710 + .compat_ioctl = pkt_compat_ioctl, 2711 2711 #endif 2712 2712 .check_events = pkt_check_events, 2713 2713 };
+1 -4
drivers/devfreq/Kconfig
··· 83 83 select DEVFREQ_GOV_PASSIVE 84 84 select DEVFREQ_EVENT_EXYNOS_PPMU 85 85 select PM_DEVFREQ_EVENT 86 - select PM_OPP 87 86 help 88 87 This adds the common DEVFREQ driver for Exynos Memory bus. Exynos 89 88 Memory bus has one more group of memory bus (e.g, MIF and INT block). ··· 97 98 ARCH_TEGRA_132_SOC || ARCH_TEGRA_124_SOC || \ 98 99 ARCH_TEGRA_210_SOC || \ 99 100 COMPILE_TEST 100 - select PM_OPP 101 + depends on COMMON_CLK 101 102 help 102 103 This adds the DEVFREQ driver for the Tegra family of SoCs. 103 104 It reads ACTMON counters of memory controllers and adjusts the ··· 108 109 depends on (TEGRA_MC && TEGRA20_EMC) || COMPILE_TEST 109 110 depends on COMMON_CLK 110 111 select DEVFREQ_GOV_SIMPLE_ONDEMAND 111 - select PM_OPP 112 112 help 113 113 This adds the DEVFREQ driver for the Tegra20 family of SoCs. 114 114 It reads Memory Controller counters and adjusts the operating ··· 119 121 select DEVFREQ_EVENT_ROCKCHIP_DFI 120 122 select DEVFREQ_GOV_SIMPLE_ONDEMAND 121 123 select PM_DEVFREQ_EVENT 122 - select PM_OPP 123 124 help 124 125 This adds the DEVFREQ driver for the RK3399 DMC(Dynamic Memory Controller). 125 126 It sets the frequency for the memory controller and reads the usage counts
+2 -2
drivers/gpio/Kconfig
··· 553 553 554 554 config GPIO_TEGRA186 555 555 tristate "NVIDIA Tegra186 GPIO support" 556 - default ARCH_TEGRA_186_SOC 557 - depends on ARCH_TEGRA_186_SOC || COMPILE_TEST 556 + default ARCH_TEGRA_186_SOC || ARCH_TEGRA_194_SOC 557 + depends on ARCH_TEGRA_186_SOC || ARCH_TEGRA_194_SOC || COMPILE_TEST 558 558 depends on OF_GPIO 559 559 select GPIOLIB_IRQCHIP 560 560 select IRQ_DOMAIN_HIERARCHY
+1 -1
drivers/gpio/gpio-aspeed-sgpio.c
··· 107 107 return gpio->base + bank->irq_regs + GPIO_IRQ_STATUS; 108 108 default: 109 109 /* acturally if code runs to here, it's an error case */ 110 - BUG_ON(1); 110 + BUG(); 111 111 } 112 112 } 113 113
+5 -2
drivers/gpio/gpio-mockup.c
··· 226 226 int direction; 227 227 228 228 mutex_lock(&chip->lock); 229 - direction = !chip->lines[offset].dir; 229 + direction = chip->lines[offset].dir; 230 230 mutex_unlock(&chip->lock); 231 231 232 232 return direction; ··· 395 395 struct gpio_chip *gc; 396 396 struct device *dev; 397 397 const char *name; 398 - int rv, base; 398 + int rv, base, i; 399 399 u16 ngpio; 400 400 401 401 dev = &pdev->dev; ··· 446 446 sizeof(*chip->lines), GFP_KERNEL); 447 447 if (!chip->lines) 448 448 return -ENOMEM; 449 + 450 + for (i = 0; i < gc->ngpio; i++) 451 + chip->lines[i].dir = GPIO_LINE_DIRECTION_IN; 449 452 450 453 if (device_property_read_bool(dev, "named-gpio-lines")) { 451 454 rv = gpio_mockup_name_lines(dev, chip);
+1
drivers/gpio/gpio-mpc8xxx.c
··· 346 346 return -ENOMEM; 347 347 348 348 gc = &mpc8xxx_gc->gc; 349 + gc->parent = &pdev->dev; 349 350 350 351 if (of_property_read_bool(np, "little-endian")) { 351 352 ret = bgpio_init(gc, &pdev->dev, 4,
+10 -16
drivers/gpio/gpio-pca953x.c
··· 568 568 { 569 569 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 570 570 struct pca953x_chip *chip = gpiochip_get_data(gc); 571 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 571 572 572 - chip->irq_mask[d->hwirq / BANK_SZ] &= ~BIT(d->hwirq % BANK_SZ); 573 + clear_bit(hwirq, chip->irq_mask); 573 574 } 574 575 575 576 static void pca953x_irq_unmask(struct irq_data *d) 576 577 { 577 578 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 578 579 struct pca953x_chip *chip = gpiochip_get_data(gc); 580 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 579 581 580 - chip->irq_mask[d->hwirq / BANK_SZ] |= BIT(d->hwirq % BANK_SZ); 582 + set_bit(hwirq, chip->irq_mask); 581 583 } 582 584 583 585 static int pca953x_irq_set_wake(struct irq_data *d, unsigned int on) ··· 637 635 { 638 636 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 639 637 struct pca953x_chip *chip = gpiochip_get_data(gc); 640 - int bank_nb = d->hwirq / BANK_SZ; 641 - u8 mask = BIT(d->hwirq % BANK_SZ); 638 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 642 639 643 640 if (!(type & IRQ_TYPE_EDGE_BOTH)) { 644 641 dev_err(&chip->client->dev, "irq %d: unsupported type %d\n", ··· 645 644 return -EINVAL; 646 645 } 647 646 648 - if (type & IRQ_TYPE_EDGE_FALLING) 649 - chip->irq_trig_fall[bank_nb] |= mask; 650 - else 651 - chip->irq_trig_fall[bank_nb] &= ~mask; 652 - 653 - if (type & IRQ_TYPE_EDGE_RISING) 654 - chip->irq_trig_raise[bank_nb] |= mask; 655 - else 656 - chip->irq_trig_raise[bank_nb] &= ~mask; 647 + assign_bit(hwirq, chip->irq_trig_fall, type & IRQ_TYPE_EDGE_FALLING); 648 + assign_bit(hwirq, chip->irq_trig_raise, type & IRQ_TYPE_EDGE_RISING); 657 649 658 650 return 0; 659 651 } ··· 655 661 { 656 662 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 657 663 struct pca953x_chip *chip = gpiochip_get_data(gc); 658 - u8 mask = BIT(d->hwirq % BANK_SZ); 664 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 659 665 660 - chip->irq_trig_raise[d->hwirq / BANK_SZ] &= ~mask; 661 - chip->irq_trig_fall[d->hwirq / BANK_SZ] &= ~mask; 666 + clear_bit(hwirq, chip->irq_trig_raise); 667 + clear_bit(hwirq, chip->irq_trig_fall); 662 668 } 663 669 664 670 static bool pca953x_irq_pending(struct pca953x_chip *chip, unsigned long *pending)
+1 -1
drivers/gpio/gpio-xgs-iproc.c
··· 280 280 return 0; 281 281 } 282 282 283 - static int __exit iproc_gpio_remove(struct platform_device *pdev) 283 + static int iproc_gpio_remove(struct platform_device *pdev) 284 284 { 285 285 struct iproc_gpio_chip *chip; 286 286
+3 -4
drivers/gpio/gpio-xtensa.c
··· 44 44 unsigned long flags; 45 45 46 46 local_irq_save(flags); 47 - RSR_CPENABLE(*cpenable); 48 - WSR_CPENABLE(*cpenable | BIT(XCHAL_CP_ID_XTIOP)); 49 - 47 + *cpenable = xtensa_get_sr(cpenable); 48 + xtensa_set_sr(*cpenable | BIT(XCHAL_CP_ID_XTIOP), cpenable); 50 49 return flags; 51 50 } 52 51 53 52 static inline void disable_cp(unsigned long flags, unsigned long cpenable) 54 53 { 55 - WSR_CPENABLE(cpenable); 54 + xtensa_set_sr(cpenable, cpenable); 56 55 local_irq_restore(flags); 57 56 } 58 57
+11 -2
drivers/gpio/gpiolib.c
··· 220 220 chip = gpiod_to_chip(desc); 221 221 offset = gpio_chip_hwgpio(desc); 222 222 223 + /* 224 + * Open drain emulation using input mode may incorrectly report 225 + * input here, fix that up. 226 + */ 227 + if (test_bit(FLAG_OPEN_DRAIN, &desc->flags) && 228 + test_bit(FLAG_IS_OUT, &desc->flags)) 229 + return 0; 230 + 223 231 if (!chip->get_direction) 224 232 return -ENOTSUPP; 225 233 ··· 4480 4472 4481 4473 if (chip->ngpio <= p->chip_hwnum) { 4482 4474 dev_err(dev, 4483 - "requested GPIO %d is out of range [0..%d] for chip %s\n", 4484 - idx, chip->ngpio, chip->label); 4475 + "requested GPIO %u (%u) is out of range [0..%u] for chip %s\n", 4476 + idx, p->chip_hwnum, chip->ngpio - 1, 4477 + chip->label); 4485 4478 return ERR_PTR(-EINVAL); 4486 4479 } 4487 4480
+1 -1
drivers/gpu/drm/i915/display/intel_display.c
··· 15112 15112 return ret; 15113 15113 15114 15114 fb_obj_bump_render_priority(obj); 15115 - intel_frontbuffer_flush(obj->frontbuffer, ORIGIN_DIRTYFB); 15115 + i915_gem_object_flush_frontbuffer(obj, ORIGIN_DIRTYFB); 15116 15116 15117 15117 if (!new_plane_state->base.fence) { /* implicit fencing */ 15118 15118 struct dma_fence *fence;
+6 -10
drivers/gpu/drm/i915/display/intel_frontbuffer.c
··· 229 229 vma->display_alignment = I915_GTT_MIN_ALIGNMENT; 230 230 spin_unlock(&obj->vma.lock); 231 231 232 - obj->frontbuffer = NULL; 232 + RCU_INIT_POINTER(obj->frontbuffer, NULL); 233 233 spin_unlock(&to_i915(obj->base.dev)->fb_tracking.lock); 234 234 235 235 i915_gem_object_put(obj); 236 - kfree(front); 236 + kfree_rcu(front, rcu); 237 237 } 238 238 239 239 struct intel_frontbuffer * ··· 242 242 struct drm_i915_private *i915 = to_i915(obj->base.dev); 243 243 struct intel_frontbuffer *front; 244 244 245 - spin_lock(&i915->fb_tracking.lock); 246 - front = obj->frontbuffer; 247 - if (front) 248 - kref_get(&front->ref); 249 - spin_unlock(&i915->fb_tracking.lock); 245 + front = __intel_frontbuffer_get(obj); 250 246 if (front) 251 247 return front; 252 248 ··· 258 262 i915_active_may_sleep(frontbuffer_retire)); 259 263 260 264 spin_lock(&i915->fb_tracking.lock); 261 - if (obj->frontbuffer) { 265 + if (rcu_access_pointer(obj->frontbuffer)) { 262 266 kfree(front); 263 - front = obj->frontbuffer; 267 + front = rcu_dereference_protected(obj->frontbuffer, true); 264 268 kref_get(&front->ref); 265 269 } else { 266 270 i915_gem_object_get(obj); 267 - obj->frontbuffer = front; 271 + rcu_assign_pointer(obj->frontbuffer, front); 268 272 } 269 273 spin_unlock(&i915->fb_tracking.lock); 270 274
+31 -3
drivers/gpu/drm/i915/display/intel_frontbuffer.h
··· 27 27 #include <linux/atomic.h> 28 28 #include <linux/kref.h> 29 29 30 + #include "gem/i915_gem_object_types.h" 30 31 #include "i915_active.h" 31 32 32 33 struct drm_i915_private; 33 - struct drm_i915_gem_object; 34 34 35 35 enum fb_op_origin { 36 36 ORIGIN_GTT, ··· 45 45 atomic_t bits; 46 46 struct i915_active write; 47 47 struct drm_i915_gem_object *obj; 48 + struct rcu_head rcu; 48 49 }; 49 50 50 51 void intel_frontbuffer_flip_prepare(struct drm_i915_private *i915, ··· 54 53 unsigned frontbuffer_bits); 55 54 void intel_frontbuffer_flip(struct drm_i915_private *i915, 56 55 unsigned frontbuffer_bits); 56 + 57 + void intel_frontbuffer_put(struct intel_frontbuffer *front); 58 + 59 + static inline struct intel_frontbuffer * 60 + __intel_frontbuffer_get(const struct drm_i915_gem_object *obj) 61 + { 62 + struct intel_frontbuffer *front; 63 + 64 + if (likely(!rcu_access_pointer(obj->frontbuffer))) 65 + return NULL; 66 + 67 + rcu_read_lock(); 68 + do { 69 + front = rcu_dereference(obj->frontbuffer); 70 + if (!front) 71 + break; 72 + 73 + if (unlikely(!kref_get_unless_zero(&front->ref))) 74 + continue; 75 + 76 + if (likely(front == rcu_access_pointer(obj->frontbuffer))) 77 + break; 78 + 79 + intel_frontbuffer_put(front); 80 + } while (1); 81 + rcu_read_unlock(); 82 + 83 + return front; 84 + } 57 85 58 86 struct intel_frontbuffer * 59 87 intel_frontbuffer_get(struct drm_i915_gem_object *obj); ··· 148 118 void intel_frontbuffer_track(struct intel_frontbuffer *old, 149 119 struct intel_frontbuffer *new, 150 120 unsigned int frontbuffer_bits); 151 - 152 - void intel_frontbuffer_put(struct intel_frontbuffer *front); 153 121 154 122 #endif /* __INTEL_FRONTBUFFER_H__ */
+13 -4
drivers/gpu/drm/i915/display/intel_overlay.c
··· 279 279 struct i915_vma *vma) 280 280 { 281 281 enum pipe pipe = overlay->crtc->pipe; 282 + struct intel_frontbuffer *from = NULL, *to = NULL; 282 283 283 284 WARN_ON(overlay->old_vma); 284 285 285 - intel_frontbuffer_track(overlay->vma ? overlay->vma->obj->frontbuffer : NULL, 286 - vma ? vma->obj->frontbuffer : NULL, 287 - INTEL_FRONTBUFFER_OVERLAY(pipe)); 286 + if (overlay->vma) 287 + from = intel_frontbuffer_get(overlay->vma->obj); 288 + if (vma) 289 + to = intel_frontbuffer_get(vma->obj); 290 + 291 + intel_frontbuffer_track(from, to, INTEL_FRONTBUFFER_OVERLAY(pipe)); 292 + 293 + if (to) 294 + intel_frontbuffer_put(to); 295 + if (from) 296 + intel_frontbuffer_put(from); 288 297 289 298 intel_frontbuffer_flip_prepare(overlay->i915, 290 299 INTEL_FRONTBUFFER_OVERLAY(pipe)); ··· 775 766 ret = PTR_ERR(vma); 776 767 goto out_pin_section; 777 768 } 778 - intel_frontbuffer_flush(new_bo->frontbuffer, ORIGIN_DIRTYFB); 769 + i915_gem_object_flush_frontbuffer(new_bo, ORIGIN_DIRTYFB); 779 770 780 771 if (!overlay->active) { 781 772 u32 oconfig;
+2 -1
drivers/gpu/drm/i915/gem/i915_gem_clflush.c
··· 20 20 { 21 21 GEM_BUG_ON(!i915_gem_object_has_pages(obj)); 22 22 drm_clflush_sg(obj->mm.pages); 23 - intel_frontbuffer_flush(obj->frontbuffer, ORIGIN_CPU); 23 + 24 + i915_gem_object_flush_frontbuffer(obj, ORIGIN_CPU); 24 25 } 25 26 26 27 static int clflush_work(struct dma_fence_work *base)
+2 -2
drivers/gpu/drm/i915/gem/i915_gem_domain.c
··· 664 664 i915_gem_object_unlock(obj); 665 665 666 666 if (write_domain) 667 - intel_frontbuffer_invalidate(obj->frontbuffer, ORIGIN_CPU); 667 + i915_gem_object_invalidate_frontbuffer(obj, ORIGIN_CPU); 668 668 669 669 out_unpin: 670 670 i915_gem_object_unpin_pages(obj); ··· 784 784 } 785 785 786 786 out: 787 - intel_frontbuffer_invalidate(obj->frontbuffer, ORIGIN_CPU); 787 + i915_gem_object_invalidate_frontbuffer(obj, ORIGIN_CPU); 788 788 obj->mm.dirty = true; 789 789 /* return with the pages pinned */ 790 790 return 0;
+25 -1
drivers/gpu/drm/i915/gem/i915_gem_object.c
··· 280 280 for_each_ggtt_vma(vma, obj) 281 281 intel_gt_flush_ggtt_writes(vma->vm->gt); 282 282 283 - intel_frontbuffer_flush(obj->frontbuffer, ORIGIN_CPU); 283 + i915_gem_object_flush_frontbuffer(obj, ORIGIN_CPU); 284 284 285 285 for_each_ggtt_vma(vma, obj) { 286 286 if (vma->iomap) ··· 306 306 } 307 307 308 308 obj->write_domain = 0; 309 + } 310 + 311 + void __i915_gem_object_flush_frontbuffer(struct drm_i915_gem_object *obj, 312 + enum fb_op_origin origin) 313 + { 314 + struct intel_frontbuffer *front; 315 + 316 + front = __intel_frontbuffer_get(obj); 317 + if (front) { 318 + intel_frontbuffer_flush(front, origin); 319 + intel_frontbuffer_put(front); 320 + } 321 + } 322 + 323 + void __i915_gem_object_invalidate_frontbuffer(struct drm_i915_gem_object *obj, 324 + enum fb_op_origin origin) 325 + { 326 + struct intel_frontbuffer *front; 327 + 328 + front = __intel_frontbuffer_get(obj); 329 + if (front) { 330 + intel_frontbuffer_invalidate(front, origin); 331 + intel_frontbuffer_put(front); 332 + } 309 333 } 310 334 311 335 void i915_gem_init__objects(struct drm_i915_private *i915)
+22 -1
drivers/gpu/drm/i915/gem/i915_gem_object.h
··· 13 13 14 14 #include <drm/i915_drm.h> 15 15 16 + #include "display/intel_frontbuffer.h" 16 17 #include "i915_gem_object_types.h" 17 - 18 18 #include "i915_gem_gtt.h" 19 19 20 20 void i915_gem_init__objects(struct drm_i915_private *i915); ··· 462 462 int i915_gem_object_wait_priority(struct drm_i915_gem_object *obj, 463 463 unsigned int flags, 464 464 const struct i915_sched_attr *attr); 465 + 466 + void __i915_gem_object_flush_frontbuffer(struct drm_i915_gem_object *obj, 467 + enum fb_op_origin origin); 468 + void __i915_gem_object_invalidate_frontbuffer(struct drm_i915_gem_object *obj, 469 + enum fb_op_origin origin); 470 + 471 + static inline void 472 + i915_gem_object_flush_frontbuffer(struct drm_i915_gem_object *obj, 473 + enum fb_op_origin origin) 474 + { 475 + if (unlikely(rcu_access_pointer(obj->frontbuffer))) 476 + __i915_gem_object_flush_frontbuffer(obj, origin); 477 + } 478 + 479 + static inline void 480 + i915_gem_object_invalidate_frontbuffer(struct drm_i915_gem_object *obj, 481 + enum fb_op_origin origin) 482 + { 483 + if (unlikely(rcu_access_pointer(obj->frontbuffer))) 484 + __i915_gem_object_invalidate_frontbuffer(obj, origin); 485 + } 465 486 466 487 #endif
+1 -1
drivers/gpu/drm/i915/gem/i915_gem_object_types.h
··· 150 150 */ 151 151 u16 write_domain; 152 152 153 - struct intel_frontbuffer *frontbuffer; 153 + struct intel_frontbuffer __rcu *frontbuffer; 154 154 155 155 /** Current tiling stride for the object, if it's tiled. */ 156 156 unsigned int tiling_and_stride;
+2 -1
drivers/gpu/drm/i915/gt/intel_gt_pm.c
··· 94 94 intel_uncore_forcewake_put(&i915->uncore, FORCEWAKE_ALL); 95 95 } 96 96 97 + /* Defer dropping the display power well for 100ms, it's slow! */ 97 98 GEM_BUG_ON(!wakeref); 98 - intel_display_power_put(i915, POWER_DOMAIN_GT_IRQ, wakeref); 99 + intel_display_power_put_async(i915, POWER_DOMAIN_GT_IRQ, wakeref); 99 100 100 101 i915_globals_park(); 101 102
+5 -5
drivers/gpu/drm/i915/i915_gem.c
··· 161 161 * We manually control the domain here and pretend that it 162 162 * remains coherent i.e. in the GTT domain, like shmem_pwrite. 163 163 */ 164 - intel_frontbuffer_invalidate(obj->frontbuffer, ORIGIN_CPU); 164 + i915_gem_object_invalidate_frontbuffer(obj, ORIGIN_CPU); 165 165 166 166 if (copy_from_user(vaddr, user_data, args->size)) 167 167 return -EFAULT; ··· 169 169 drm_clflush_virt_range(vaddr, args->size); 170 170 intel_gt_chipset_flush(&to_i915(obj->base.dev)->gt); 171 171 172 - intel_frontbuffer_flush(obj->frontbuffer, ORIGIN_CPU); 172 + i915_gem_object_flush_frontbuffer(obj, ORIGIN_CPU); 173 173 return 0; 174 174 } 175 175 ··· 589 589 goto out_unpin; 590 590 } 591 591 592 - intel_frontbuffer_invalidate(obj->frontbuffer, ORIGIN_CPU); 592 + i915_gem_object_invalidate_frontbuffer(obj, ORIGIN_CPU); 593 593 594 594 user_data = u64_to_user_ptr(args->data_ptr); 595 595 offset = args->offset; ··· 631 631 user_data += page_length; 632 632 offset += page_length; 633 633 } 634 - intel_frontbuffer_flush(obj->frontbuffer, ORIGIN_CPU); 634 + i915_gem_object_flush_frontbuffer(obj, ORIGIN_CPU); 635 635 636 636 i915_gem_object_unlock_fence(obj, fence); 637 637 out_unpin: ··· 721 721 offset = 0; 722 722 } 723 723 724 - intel_frontbuffer_flush(obj->frontbuffer, ORIGIN_CPU); 724 + i915_gem_object_flush_frontbuffer(obj, ORIGIN_CPU); 725 725 i915_gem_object_unlock_fence(obj, fence); 726 726 727 727 return ret;
+20 -53
drivers/gpu/drm/i915/i915_pmu.c
··· 144 144 return ktime_to_ns(ktime_sub(ktime_get(), kt)); 145 145 } 146 146 147 - static u64 __pmu_estimate_rc6(struct i915_pmu *pmu) 148 - { 149 - u64 val; 150 - 151 - /* 152 - * We think we are runtime suspended. 153 - * 154 - * Report the delta from when the device was suspended to now, 155 - * on top of the last known real value, as the approximated RC6 156 - * counter value. 157 - */ 158 - val = ktime_since(pmu->sleep_last); 159 - val += pmu->sample[__I915_SAMPLE_RC6].cur; 160 - 161 - pmu->sample[__I915_SAMPLE_RC6_ESTIMATED].cur = val; 162 - 163 - return val; 164 - } 165 - 166 - static u64 __pmu_update_rc6(struct i915_pmu *pmu, u64 val) 167 - { 168 - /* 169 - * If we are coming back from being runtime suspended we must 170 - * be careful not to report a larger value than returned 171 - * previously. 172 - */ 173 - if (val >= pmu->sample[__I915_SAMPLE_RC6_ESTIMATED].cur) { 174 - pmu->sample[__I915_SAMPLE_RC6_ESTIMATED].cur = 0; 175 - pmu->sample[__I915_SAMPLE_RC6].cur = val; 176 - } else { 177 - val = pmu->sample[__I915_SAMPLE_RC6_ESTIMATED].cur; 178 - } 179 - 180 - return val; 181 - } 182 - 183 147 static u64 get_rc6(struct intel_gt *gt) 184 148 { 185 149 struct drm_i915_private *i915 = gt->i915; 186 150 struct i915_pmu *pmu = &i915->pmu; 187 151 unsigned long flags; 152 + bool awake = false; 188 153 u64 val; 189 154 190 - val = 0; 191 155 if (intel_gt_pm_get_if_awake(gt)) { 192 156 val = __get_rc6(gt); 193 157 intel_gt_pm_put_async(gt); 158 + awake = true; 194 159 } 195 160 196 161 spin_lock_irqsave(&pmu->lock, flags); 197 162 198 - if (val) 199 - val = __pmu_update_rc6(pmu, val); 163 + if (awake) { 164 + pmu->sample[__I915_SAMPLE_RC6].cur = val; 165 + } else { 166 + /* 167 + * We think we are runtime suspended. 168 + * 169 + * Report the delta from when the device was suspended to now, 170 + * on top of the last known real value, as the approximated RC6 171 + * counter value. 172 + */ 173 + val = ktime_since(pmu->sleep_last); 174 + val += pmu->sample[__I915_SAMPLE_RC6].cur; 175 + } 176 + 177 + if (val < pmu->sample[__I915_SAMPLE_RC6_LAST_REPORTED].cur) 178 + val = pmu->sample[__I915_SAMPLE_RC6_LAST_REPORTED].cur; 200 179 else 201 - val = __pmu_estimate_rc6(pmu); 180 + pmu->sample[__I915_SAMPLE_RC6_LAST_REPORTED].cur = val; 202 181 203 182 spin_unlock_irqrestore(&pmu->lock, flags); 204 183 ··· 189 210 struct i915_pmu *pmu = &i915->pmu; 190 211 191 212 if (pmu->enable & config_enabled_mask(I915_PMU_RC6_RESIDENCY)) 192 - __pmu_update_rc6(pmu, __get_rc6(&i915->gt)); 213 + pmu->sample[__I915_SAMPLE_RC6].cur = __get_rc6(&i915->gt); 193 214 194 215 pmu->sleep_last = ktime_get(); 195 - } 196 - 197 - static void unpark_rc6(struct drm_i915_private *i915) 198 - { 199 - struct i915_pmu *pmu = &i915->pmu; 200 - 201 - /* Estimate how long we slept and accumulate that into rc6 counters */ 202 - if (pmu->enable & config_enabled_mask(I915_PMU_RC6_RESIDENCY)) 203 - __pmu_estimate_rc6(pmu); 204 216 } 205 217 206 218 #else ··· 202 232 } 203 233 204 234 static void park_rc6(struct drm_i915_private *i915) {} 205 - static void unpark_rc6(struct drm_i915_private *i915) {} 206 235 207 236 #endif 208 237 ··· 249 280 * Re-enable sampling timer when GPU goes active. 250 281 */ 251 282 __i915_pmu_maybe_start_timer(pmu); 252 - 253 - unpark_rc6(i915); 254 283 255 284 spin_unlock_irq(&pmu->lock); 256 285 }
+1 -1
drivers/gpu/drm/i915/i915_pmu.h
··· 18 18 __I915_SAMPLE_FREQ_ACT = 0, 19 19 __I915_SAMPLE_FREQ_REQ, 20 20 __I915_SAMPLE_RC6, 21 - __I915_SAMPLE_RC6_ESTIMATED, 21 + __I915_SAMPLE_RC6_LAST_REPORTED, 22 22 __I915_NUM_PMU_SAMPLERS 23 23 }; 24 24
+8 -2
drivers/gpu/drm/i915/i915_vma.c
··· 1104 1104 return err; 1105 1105 1106 1106 if (flags & EXEC_OBJECT_WRITE) { 1107 - if (intel_frontbuffer_invalidate(obj->frontbuffer, ORIGIN_CS)) 1108 - i915_active_add_request(&obj->frontbuffer->write, rq); 1107 + struct intel_frontbuffer *front; 1108 + 1109 + front = __intel_frontbuffer_get(obj); 1110 + if (unlikely(front)) { 1111 + if (intel_frontbuffer_invalidate(front, ORIGIN_CS)) 1112 + i915_active_add_request(&front->write, rq); 1113 + intel_frontbuffer_put(front); 1114 + } 1109 1115 1110 1116 dma_resv_add_excl_fence(vma->resv, &rq->fence); 1111 1117 obj->write_domain = I915_GEM_DOMAIN_RENDER;
+3 -3
drivers/net/dsa/bcm_sf2_cfp.c
··· 358 358 return -EINVAL; 359 359 } 360 360 361 - ip_frag = be32_to_cpu(fs->m_ext.data[0]); 361 + ip_frag = !!(be32_to_cpu(fs->h_ext.data[0]) & 1); 362 362 363 363 /* Locate the first rule available */ 364 364 if (fs->location == RX_CLS_LOC_ANY) ··· 569 569 570 570 if (rule->fs.flow_type != fs->flow_type || 571 571 rule->fs.ring_cookie != fs->ring_cookie || 572 - rule->fs.m_ext.data[0] != fs->m_ext.data[0]) 572 + rule->fs.h_ext.data[0] != fs->h_ext.data[0]) 573 573 continue; 574 574 575 575 switch (fs->flow_type & ~FLOW_EXT) { ··· 621 621 return -EINVAL; 622 622 } 623 623 624 - ip_frag = be32_to_cpu(fs->m_ext.data[0]); 624 + ip_frag = !!(be32_to_cpu(fs->h_ext.data[0]) & 1); 625 625 626 626 layout = &udf_tcpip6_layout; 627 627 slice_num = bcm_sf2_get_slice_number(layout, 0);
+5 -5
drivers/net/dsa/sja1105/sja1105_main.c
··· 1569 1569 1570 1570 if (enabled) { 1571 1571 /* Enable VLAN filtering. */ 1572 - tpid = ETH_P_8021AD; 1573 - tpid2 = ETH_P_8021Q; 1572 + tpid = ETH_P_8021Q; 1573 + tpid2 = ETH_P_8021AD; 1574 1574 } else { 1575 1575 /* Disable VLAN filtering. */ 1576 1576 tpid = ETH_P_SJA1105; ··· 1579 1579 1580 1580 table = &priv->static_config.tables[BLK_IDX_GENERAL_PARAMS]; 1581 1581 general_params = table->entries; 1582 - /* EtherType used to identify outer tagged (S-tag) VLAN traffic */ 1583 - general_params->tpid = tpid; 1584 1582 /* EtherType used to identify inner tagged (C-tag) VLAN traffic */ 1583 + general_params->tpid = tpid; 1584 + /* EtherType used to identify outer tagged (S-tag) VLAN traffic */ 1585 1585 general_params->tpid2 = tpid2; 1586 1586 /* When VLAN filtering is on, we need to at least be able to 1587 1587 * decode management traffic through the "backup plan". ··· 1855 1855 if (!clone) 1856 1856 goto out; 1857 1857 1858 - sja1105_ptp_txtstamp_skb(ds, slot, clone); 1858 + sja1105_ptp_txtstamp_skb(ds, port, clone); 1859 1859 1860 1860 out: 1861 1861 mutex_unlock(&priv->mgmt_lock);
+3 -3
drivers/net/dsa/sja1105/sja1105_ptp.c
··· 237 237 if (rw == SPI_WRITE) 238 238 priv->info->ptp_cmd_packing(buf, cmd, PACK); 239 239 240 - rc = sja1105_xfer_buf(priv, SPI_WRITE, regs->ptp_control, buf, 240 + rc = sja1105_xfer_buf(priv, rw, regs->ptp_control, buf, 241 241 SJA1105_SIZE_PTP_CMD); 242 242 243 243 if (rw == SPI_READ) ··· 659 659 ptp_data->clock = NULL; 660 660 } 661 661 662 - void sja1105_ptp_txtstamp_skb(struct dsa_switch *ds, int slot, 662 + void sja1105_ptp_txtstamp_skb(struct dsa_switch *ds, int port, 663 663 struct sk_buff *skb) 664 664 { 665 665 struct sja1105_private *priv = ds->priv; ··· 679 679 goto out; 680 680 } 681 681 682 - rc = sja1105_ptpegr_ts_poll(ds, slot, &ts); 682 + rc = sja1105_ptpegr_ts_poll(ds, port, &ts); 683 683 if (rc < 0) { 684 684 dev_err(ds->dev, "timed out polling for tstamp\n"); 685 685 kfree_skb(skb);
+5 -2
drivers/net/dsa/sja1105/sja1105_static_config.c
··· 142 142 return size; 143 143 } 144 144 145 + /* TPID and TPID2 are intentionally reversed so that semantic 146 + * compatibility with E/T is kept. 147 + */ 145 148 static size_t 146 149 sja1105pqrs_general_params_entry_packing(void *buf, void *entry_ptr, 147 150 enum packing_op op) ··· 169 166 sja1105_packing(buf, &entry->mirr_port, 141, 139, size, op); 170 167 sja1105_packing(buf, &entry->vlmarker, 138, 107, size, op); 171 168 sja1105_packing(buf, &entry->vlmask, 106, 75, size, op); 172 - sja1105_packing(buf, &entry->tpid, 74, 59, size, op); 169 + sja1105_packing(buf, &entry->tpid2, 74, 59, size, op); 173 170 sja1105_packing(buf, &entry->ignore2stf, 58, 58, size, op); 174 - sja1105_packing(buf, &entry->tpid2, 57, 42, size, op); 171 + sja1105_packing(buf, &entry->tpid, 57, 42, size, op); 175 172 sja1105_packing(buf, &entry->queue_ts, 41, 41, size, op); 176 173 sja1105_packing(buf, &entry->egrmirrvid, 40, 29, size, op); 177 174 sja1105_packing(buf, &entry->egrmirrpcp, 28, 26, size, op);
-5
drivers/net/dsa/sja1105/sja1105_tas.c
··· 477 477 if (admin->cycle_time_extension) 478 478 return -ENOTSUPP; 479 479 480 - if (!ns_to_sja1105_delta(admin->base_time)) { 481 - dev_err(ds->dev, "A base time of zero is not hardware-allowed\n"); 482 - return -ERANGE; 483 - } 484 - 485 480 for (i = 0; i < admin->num_entries; i++) { 486 481 s64 delta_ns = admin->entries[i].interval; 487 482 s64 delta_cycles = ns_to_sja1105_delta(delta_ns);
+4 -1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
··· 1536 1536 ((MAX_MAC_CREDIT_E2 - GET_NUM_VFS_PER_PATH(bp) * VF_MAC_CREDIT_CNT) / \ 1537 1537 func_num + GET_NUM_VFS_PER_PF(bp) * VF_MAC_CREDIT_CNT) 1538 1538 1539 + #define BNX2X_VFS_VLAN_CREDIT(bp) \ 1540 + (GET_NUM_VFS_PER_PATH(bp) * VF_VLAN_CREDIT_CNT) 1541 + 1539 1542 #define PF_VLAN_CREDIT_E2(bp, func_num) \ 1540 - ((MAX_MAC_CREDIT_E2 - GET_NUM_VFS_PER_PATH(bp) * VF_VLAN_CREDIT_CNT) / \ 1543 + ((MAX_VLAN_CREDIT_E2 - 1 - BNX2X_VFS_VLAN_CREDIT(bp)) / \ 1541 1544 func_num + GET_NUM_VFS_PER_PF(bp) * VF_VLAN_CREDIT_CNT) 1542 1545 1543 1546 #endif /* BNX2X_SP_VERBS */
+1
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
··· 515 515 516 516 enum cc_pause requested_fc; /* flow control user has requested */ 517 517 enum cc_pause fc; /* actual link flow control */ 518 + enum cc_pause advertised_fc; /* actual advertised flow control */ 518 519 519 520 enum cc_fec requested_fec; /* Forward Error Correction: */ 520 521 enum cc_fec fec; /* requested and actual in use */
+2 -2
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
··· 807 807 struct port_info *p = netdev_priv(dev); 808 808 809 809 epause->autoneg = (p->link_cfg.requested_fc & PAUSE_AUTONEG) != 0; 810 - epause->rx_pause = (p->link_cfg.fc & PAUSE_RX) != 0; 811 - epause->tx_pause = (p->link_cfg.fc & PAUSE_TX) != 0; 810 + epause->rx_pause = (p->link_cfg.advertised_fc & PAUSE_RX) != 0; 811 + epause->tx_pause = (p->link_cfg.advertised_fc & PAUSE_TX) != 0; 812 812 } 813 813 814 814 static int set_pauseparam(struct net_device *dev,
+14 -9
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
··· 4089 4089 if (cc_pause & PAUSE_TX) 4090 4090 fw_pause |= FW_PORT_CAP32_802_3_PAUSE; 4091 4091 else 4092 - fw_pause |= FW_PORT_CAP32_802_3_ASM_DIR; 4092 + fw_pause |= FW_PORT_CAP32_802_3_ASM_DIR | 4093 + FW_PORT_CAP32_802_3_PAUSE; 4093 4094 } else if (cc_pause & PAUSE_TX) { 4094 4095 fw_pause |= FW_PORT_CAP32_802_3_ASM_DIR; 4095 4096 } ··· 8564 8563 void t4_handle_get_port_info(struct port_info *pi, const __be64 *rpl) 8565 8564 { 8566 8565 const struct fw_port_cmd *cmd = (const void *)rpl; 8567 - int action = FW_PORT_CMD_ACTION_G(be32_to_cpu(cmd->action_to_len16)); 8568 - struct adapter *adapter = pi->adapter; 8569 - struct link_config *lc = &pi->link_cfg; 8570 - int link_ok, linkdnrc; 8571 - enum fw_port_type port_type; 8572 - enum fw_port_module_type mod_type; 8573 - unsigned int speed, fc, fec; 8574 8566 fw_port_cap32_t pcaps, acaps, lpacaps, linkattr; 8567 + struct link_config *lc = &pi->link_cfg; 8568 + struct adapter *adapter = pi->adapter; 8569 + unsigned int speed, fc, fec, adv_fc; 8570 + enum fw_port_module_type mod_type; 8571 + int action, link_ok, linkdnrc; 8572 + enum fw_port_type port_type; 8575 8573 8576 8574 /* Extract the various fields from the Port Information message. 8577 8575 */ 8576 + action = FW_PORT_CMD_ACTION_G(be32_to_cpu(cmd->action_to_len16)); 8578 8577 switch (action) { 8579 8578 case FW_PORT_ACTION_GET_PORT_INFO: { 8580 8579 u32 lstatus = be32_to_cpu(cmd->u.info.lstatus_to_modtype); ··· 8612 8611 } 8613 8612 8614 8613 fec = fwcap_to_cc_fec(acaps); 8614 + adv_fc = fwcap_to_cc_pause(acaps); 8615 8615 fc = fwcap_to_cc_pause(linkattr); 8616 8616 speed = fwcap_to_speed(linkattr); 8617 8617 ··· 8669 8667 } 8670 8668 8671 8669 if (link_ok != lc->link_ok || speed != lc->speed || 8672 - fc != lc->fc || fec != lc->fec) { /* something changed */ 8670 + fc != lc->fc || adv_fc != lc->advertised_fc || 8671 + fec != lc->fec) { 8672 + /* something changed */ 8673 8673 if (!link_ok && lc->link_ok) { 8674 8674 lc->link_down_rc = linkdnrc; 8675 8675 dev_warn_ratelimited(adapter->pdev_dev, ··· 8681 8677 } 8682 8678 lc->link_ok = link_ok; 8683 8679 lc->speed = speed; 8680 + lc->advertised_fc = adv_fc; 8684 8681 lc->fc = fc; 8685 8682 lc->fec = fec; 8686 8683
+2 -2
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
··· 1690 1690 struct port_info *pi = netdev_priv(dev); 1691 1691 1692 1692 pauseparam->autoneg = (pi->link_cfg.requested_fc & PAUSE_AUTONEG) != 0; 1693 - pauseparam->rx_pause = (pi->link_cfg.fc & PAUSE_RX) != 0; 1694 - pauseparam->tx_pause = (pi->link_cfg.fc & PAUSE_TX) != 0; 1693 + pauseparam->rx_pause = (pi->link_cfg.advertised_fc & PAUSE_RX) != 0; 1694 + pauseparam->tx_pause = (pi->link_cfg.advertised_fc & PAUSE_TX) != 0; 1695 1695 } 1696 1696 1697 1697 /*
+1
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
··· 135 135 136 136 enum cc_pause requested_fc; /* flow control user has requested */ 137 137 enum cc_pause fc; /* actual link flow control */ 138 + enum cc_pause advertised_fc; /* actual advertised flow control */ 138 139 139 140 enum cc_fec auto_fec; /* Forward Error Correction: */ 140 141 enum cc_fec requested_fec; /* "automatic" (IEEE 802.3), */
+12 -8
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
··· 1913 1913 static void t4vf_handle_get_port_info(struct port_info *pi, 1914 1914 const struct fw_port_cmd *cmd) 1915 1915 { 1916 - int action = FW_PORT_CMD_ACTION_G(be32_to_cpu(cmd->action_to_len16)); 1917 - struct adapter *adapter = pi->adapter; 1918 - struct link_config *lc = &pi->link_cfg; 1919 - int link_ok, linkdnrc; 1920 - enum fw_port_type port_type; 1921 - enum fw_port_module_type mod_type; 1922 - unsigned int speed, fc, fec; 1923 1916 fw_port_cap32_t pcaps, acaps, lpacaps, linkattr; 1917 + struct link_config *lc = &pi->link_cfg; 1918 + struct adapter *adapter = pi->adapter; 1919 + unsigned int speed, fc, fec, adv_fc; 1920 + enum fw_port_module_type mod_type; 1921 + int action, link_ok, linkdnrc; 1922 + enum fw_port_type port_type; 1924 1923 1925 1924 /* Extract the various fields from the Port Information message. */ 1925 + action = FW_PORT_CMD_ACTION_G(be32_to_cpu(cmd->action_to_len16)); 1926 1926 switch (action) { 1927 1927 case FW_PORT_ACTION_GET_PORT_INFO: { 1928 1928 u32 lstatus = be32_to_cpu(cmd->u.info.lstatus_to_modtype); ··· 1982 1982 } 1983 1983 1984 1984 fec = fwcap_to_cc_fec(acaps); 1985 + adv_fc = fwcap_to_cc_pause(acaps); 1985 1986 fc = fwcap_to_cc_pause(linkattr); 1986 1987 speed = fwcap_to_speed(linkattr); 1987 1988 ··· 2013 2012 } 2014 2013 2015 2014 if (link_ok != lc->link_ok || speed != lc->speed || 2016 - fc != lc->fc || fec != lc->fec) { /* something changed */ 2015 + fc != lc->fc || adv_fc != lc->advertised_fc || 2016 + fec != lc->fec) { 2017 + /* something changed */ 2017 2018 if (!link_ok && lc->link_ok) { 2018 2019 lc->link_down_rc = linkdnrc; 2019 2020 dev_warn_ratelimited(adapter->pdev_dev, ··· 2025 2022 } 2026 2023 lc->link_ok = link_ok; 2027 2024 lc->speed = speed; 2025 + lc->advertised_fc = adv_fc; 2028 2026 lc->fc = fc; 2029 2027 lc->fec = fec; 2030 2028
+20 -19
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
··· 1719 1719 int page_offset; 1720 1720 unsigned int sz; 1721 1721 int *count_ptr; 1722 - int i; 1722 + int i, j; 1723 1723 1724 1724 vaddr = phys_to_virt(addr); 1725 1725 WARN_ON(!IS_ALIGNED((unsigned long)vaddr, SMP_CACHE_BYTES)); ··· 1736 1736 WARN_ON(!IS_ALIGNED((unsigned long)sg_vaddr, 1737 1737 SMP_CACHE_BYTES)); 1738 1738 1739 + dma_unmap_page(priv->rx_dma_dev, sg_addr, 1740 + DPAA_BP_RAW_SIZE, DMA_FROM_DEVICE); 1741 + 1739 1742 /* We may use multiple Rx pools */ 1740 1743 dpaa_bp = dpaa_bpid2pool(sgt[i].bpid); 1741 1744 if (!dpaa_bp) 1742 1745 goto free_buffers; 1743 1746 1744 - count_ptr = this_cpu_ptr(dpaa_bp->percpu_count); 1745 - dma_unmap_page(priv->rx_dma_dev, sg_addr, 1746 - DPAA_BP_RAW_SIZE, DMA_FROM_DEVICE); 1747 1747 if (!skb) { 1748 1748 sz = dpaa_bp->size + 1749 1749 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); ··· 1786 1786 skb_add_rx_frag(skb, i - 1, head_page, frag_off, 1787 1787 frag_len, dpaa_bp->size); 1788 1788 } 1789 + 1789 1790 /* Update the pool count for the current {cpu x bpool} */ 1791 + count_ptr = this_cpu_ptr(dpaa_bp->percpu_count); 1790 1792 (*count_ptr)--; 1791 1793 1792 1794 if (qm_sg_entry_is_final(&sgt[i])) ··· 1802 1800 return skb; 1803 1801 1804 1802 free_buffers: 1805 - /* compensate sw bpool counter changes */ 1806 - for (i--; i >= 0; i--) { 1807 - dpaa_bp = dpaa_bpid2pool(sgt[i].bpid); 1808 - if (dpaa_bp) { 1809 - count_ptr = this_cpu_ptr(dpaa_bp->percpu_count); 1810 - (*count_ptr)++; 1811 - } 1812 - } 1813 1803 /* free all the SG entries */ 1814 - for (i = 0; i < DPAA_SGT_MAX_ENTRIES ; i++) { 1815 - sg_addr = qm_sg_addr(&sgt[i]); 1804 + for (j = 0; j < DPAA_SGT_MAX_ENTRIES ; j++) { 1805 + sg_addr = qm_sg_addr(&sgt[j]); 1816 1806 sg_vaddr = phys_to_virt(sg_addr); 1807 + /* all pages 0..i were unmaped */ 1808 + if (j > i) 1809 + dma_unmap_page(priv->rx_dma_dev, qm_sg_addr(&sgt[j]), 1810 + DPAA_BP_RAW_SIZE, DMA_FROM_DEVICE); 1817 1811 free_pages((unsigned long)sg_vaddr, 0); 1818 - dpaa_bp = dpaa_bpid2pool(sgt[i].bpid); 1819 - if (dpaa_bp) { 1820 - count_ptr = this_cpu_ptr(dpaa_bp->percpu_count); 1821 - (*count_ptr)--; 1812 + /* counters 0..i-1 were decremented */ 1813 + if (j >= i) { 1814 + dpaa_bp = dpaa_bpid2pool(sgt[j].bpid); 1815 + if (dpaa_bp) { 1816 + count_ptr = this_cpu_ptr(dpaa_bp->percpu_count); 1817 + (*count_ptr)--; 1818 + } 1822 1819 } 1823 1820 1824 - if (qm_sg_entry_is_final(&sgt[i])) 1821 + if (qm_sg_entry_is_final(&sgt[j])) 1825 1822 break; 1826 1823 } 1827 1824 /* free the SGT fragment */
+4 -3
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
··· 6 6 #include <linux/kernel.h> 7 7 #include <linux/module.h> 8 8 #include <linux/netlink.h> 9 + #include <linux/vmalloc.h> 9 10 #include <linux/xz.h> 10 11 #include "mlxfw_mfa2.h" 11 12 #include "mlxfw_mfa2_file.h" ··· 549 548 comp_size = be32_to_cpu(comp->size); 550 549 comp_buf_size = comp_size + mlxfw_mfa2_comp_magic_len; 551 550 552 - comp_data = kmalloc(sizeof(*comp_data) + comp_buf_size, GFP_KERNEL); 551 + comp_data = vzalloc(sizeof(*comp_data) + comp_buf_size); 553 552 if (!comp_data) 554 553 return ERR_PTR(-ENOMEM); 555 554 comp_data->comp.data_size = comp_size; ··· 571 570 comp_data->comp.data = comp_data->buff + mlxfw_mfa2_comp_magic_len; 572 571 return &comp_data->comp; 573 572 err_out: 574 - kfree(comp_data); 573 + vfree(comp_data); 575 574 return ERR_PTR(err); 576 575 } 577 576 ··· 580 579 const struct mlxfw_mfa2_comp_data *comp_data; 581 580 582 581 comp_data = container_of(comp, struct mlxfw_mfa2_comp_data, comp); 583 - kfree(comp_data); 582 + vfree(comp_data); 584 583 } 585 584 586 585 void mlxfw_mfa2_file_fini(struct mlxfw_mfa2_file *mfa2_file)
+1
drivers/net/ethernet/mellanox/mlxsw/reg.h
··· 5471 5471 MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR, 5472 5472 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0, 5473 5473 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1, 5474 + MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP, 5474 5475 5475 5476 __MLXSW_REG_HTGT_TRAP_GROUP_MAX, 5476 5477 MLXSW_REG_HTGT_TRAP_GROUP_MAX = __MLXSW_REG_HTGT_TRAP_GROUP_MAX - 1
+7 -2
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
··· 4543 4543 MLXSW_SP_RXL_MARK(ROUTER_ALERT_IPV6, TRAP_TO_CPU, ROUTER_EXP, false), 4544 4544 MLXSW_SP_RXL_MARK(IPIP_DECAP_ERROR, TRAP_TO_CPU, ROUTER_EXP, false), 4545 4545 MLXSW_SP_RXL_MARK(DECAP_ECN0, TRAP_TO_CPU, ROUTER_EXP, false), 4546 - MLXSW_SP_RXL_MARK(IPV4_VRRP, TRAP_TO_CPU, ROUTER_EXP, false), 4547 - MLXSW_SP_RXL_MARK(IPV6_VRRP, TRAP_TO_CPU, ROUTER_EXP, false), 4546 + MLXSW_SP_RXL_MARK(IPV4_VRRP, TRAP_TO_CPU, VRRP, false), 4547 + MLXSW_SP_RXL_MARK(IPV6_VRRP, TRAP_TO_CPU, VRRP, false), 4548 4548 /* PKT Sample trap */ 4549 4549 MLXSW_RXL(mlxsw_sp_rx_listener_sample_func, PKT_SAMPLE, MIRROR_TO_CPU, 4550 4550 false, SP_IP2ME, DISCARD), ··· 4627 4627 rate = 19 * 1024; 4628 4628 burst_size = 12; 4629 4629 break; 4630 + case MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP: 4631 + rate = 360; 4632 + burst_size = 7; 4633 + break; 4630 4634 default: 4631 4635 continue; 4632 4636 } ··· 4670 4666 case MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF: 4671 4667 case MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM: 4672 4668 case MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0: 4669 + case MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP: 4673 4670 priority = 5; 4674 4671 tc = 5; 4675 4672 break;
+3
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
··· 6787 6787 6788 6788 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) { 6789 6789 rif = mlxsw_sp->router->rifs[i]; 6790 + if (rif && rif->ops && 6791 + rif->ops->type == MLXSW_SP_RIF_TYPE_IPIP_LB) 6792 + continue; 6790 6793 if (rif && rif->dev && rif->dev != dev && 6791 6794 !ether_addr_equal_masked(rif->dev->dev_addr, dev_addr, 6792 6795 mlxsw_sp->mac_mask)) {
+11 -3
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
··· 112 112 struct device *dev = dwmac->dev; 113 113 const char *parent_name, *mux_parent_names[MUX_CLK_NUM_PARENTS]; 114 114 struct meson8b_dwmac_clk_configs *clk_configs; 115 + static const struct clk_div_table div_table[] = { 116 + { .div = 2, .val = 2, }, 117 + { .div = 3, .val = 3, }, 118 + { .div = 4, .val = 4, }, 119 + { .div = 5, .val = 5, }, 120 + { .div = 6, .val = 6, }, 121 + { .div = 7, .val = 7, }, 122 + }; 115 123 116 124 clk_configs = devm_kzalloc(dev, sizeof(*clk_configs), GFP_KERNEL); 117 125 if (!clk_configs) ··· 154 146 clk_configs->m250_div.reg = dwmac->regs + PRG_ETH0; 155 147 clk_configs->m250_div.shift = PRG_ETH0_CLK_M250_DIV_SHIFT; 156 148 clk_configs->m250_div.width = PRG_ETH0_CLK_M250_DIV_WIDTH; 157 - clk_configs->m250_div.flags = CLK_DIVIDER_ONE_BASED | 158 - CLK_DIVIDER_ALLOW_ZERO | 159 - CLK_DIVIDER_ROUND_CLOSEST; 149 + clk_configs->m250_div.table = div_table; 150 + clk_configs->m250_div.flags = CLK_DIVIDER_ALLOW_ZERO | 151 + CLK_DIVIDER_ROUND_CLOSEST; 160 152 clk = meson8b_dwmac_register_clk(dwmac, "m250_div", &parent_name, 1, 161 153 &clk_divider_ops, 162 154 &clk_configs->m250_div.hw);
+1 -1
drivers/net/gtp.c
··· 540 540 mtu = dst_mtu(&rt->dst); 541 541 } 542 542 543 - rt->dst.ops->update_pmtu(&rt->dst, NULL, skb, mtu); 543 + rt->dst.ops->update_pmtu(&rt->dst, NULL, skb, mtu, false); 544 544 545 545 if (!skb_is_gso(skb) && (iph->frag_off & htons(IP_DF)) && 546 546 mtu < ntohs(iph->tot_len)) {
+2
drivers/net/phy/aquantia_main.c
··· 627 627 .config_intr = aqr_config_intr, 628 628 .ack_interrupt = aqr_ack_interrupt, 629 629 .read_status = aqr_read_status, 630 + .suspend = aqr107_suspend, 631 + .resume = aqr107_resume, 630 632 }, 631 633 { 632 634 PHY_ID_MATCH_MODEL(PHY_ID_AQR106),
+14 -17
drivers/ptp/ptp_clock.c
··· 166 166 .read = ptp_read, 167 167 }; 168 168 169 - static void delete_ptp_clock(struct posix_clock *pc) 169 + static void ptp_clock_release(struct device *dev) 170 170 { 171 - struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); 171 + struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev); 172 172 173 173 mutex_destroy(&ptp->tsevq_mux); 174 174 mutex_destroy(&ptp->pincfg_mux); ··· 213 213 } 214 214 215 215 ptp->clock.ops = ptp_clock_ops; 216 - ptp->clock.release = delete_ptp_clock; 217 216 ptp->info = info; 218 217 ptp->devid = MKDEV(major, index); 219 218 ptp->index = index; ··· 235 236 if (err) 236 237 goto no_pin_groups; 237 238 238 - /* Create a new device in our class. */ 239 - ptp->dev = device_create_with_groups(ptp_class, parent, ptp->devid, 240 - ptp, ptp->pin_attr_groups, 241 - "ptp%d", ptp->index); 242 - if (IS_ERR(ptp->dev)) { 243 - err = PTR_ERR(ptp->dev); 244 - goto no_device; 245 - } 246 - 247 239 /* Register a new PPS source. */ 248 240 if (info->pps) { 249 241 struct pps_source_info pps; ··· 250 260 } 251 261 } 252 262 253 - /* Create a posix clock. */ 254 - err = posix_clock_register(&ptp->clock, ptp->devid); 263 + /* Initialize a new device of our class in our clock structure. */ 264 + device_initialize(&ptp->dev); 265 + ptp->dev.devt = ptp->devid; 266 + ptp->dev.class = ptp_class; 267 + ptp->dev.parent = parent; 268 + ptp->dev.groups = ptp->pin_attr_groups; 269 + ptp->dev.release = ptp_clock_release; 270 + dev_set_drvdata(&ptp->dev, ptp); 271 + dev_set_name(&ptp->dev, "ptp%d", ptp->index); 272 + 273 + /* Create a posix clock and link it to the device. */ 274 + err = posix_clock_register(&ptp->clock, &ptp->dev); 255 275 if (err) { 256 276 pr_err("failed to create posix clock\n"); 257 277 goto no_clock; ··· 273 273 if (ptp->pps_source) 274 274 pps_unregister_source(ptp->pps_source); 275 275 no_pps: 276 - device_destroy(ptp_class, ptp->devid); 277 - no_device: 278 276 ptp_cleanup_pin_groups(ptp); 279 277 no_pin_groups: 280 278 if (ptp->kworker) ··· 302 304 if (ptp->pps_source) 303 305 pps_unregister_source(ptp->pps_source); 304 306 305 - device_destroy(ptp_class, ptp->devid); 306 307 ptp_cleanup_pin_groups(ptp); 307 308 308 309 posix_clock_unregister(&ptp->clock);
+1 -1
drivers/ptp/ptp_private.h
··· 28 28 29 29 struct ptp_clock { 30 30 struct posix_clock clock; 31 - struct device *dev; 31 + struct device dev; 32 32 struct ptp_clock_info *info; 33 33 dev_t devid; 34 34 int index; /* index into clocks.map */
+9 -20
drivers/s390/net/qeth_core_main.c
··· 2473 2473 rc = qeth_cm_enable(card); 2474 2474 if (rc) { 2475 2475 QETH_CARD_TEXT_(card, 2, "2err%d", rc); 2476 - goto out_qdio; 2476 + return rc; 2477 2477 } 2478 2478 rc = qeth_cm_setup(card); 2479 2479 if (rc) { 2480 2480 QETH_CARD_TEXT_(card, 2, "3err%d", rc); 2481 - goto out_qdio; 2481 + return rc; 2482 2482 } 2483 2483 rc = qeth_ulp_enable(card); 2484 2484 if (rc) { 2485 2485 QETH_CARD_TEXT_(card, 2, "4err%d", rc); 2486 - goto out_qdio; 2486 + return rc; 2487 2487 } 2488 2488 rc = qeth_ulp_setup(card); 2489 2489 if (rc) { 2490 2490 QETH_CARD_TEXT_(card, 2, "5err%d", rc); 2491 - goto out_qdio; 2491 + return rc; 2492 2492 } 2493 2493 rc = qeth_alloc_qdio_queues(card); 2494 2494 if (rc) { 2495 2495 QETH_CARD_TEXT_(card, 2, "5err%d", rc); 2496 - goto out_qdio; 2496 + return rc; 2497 2497 } 2498 2498 rc = qeth_qdio_establish(card); 2499 2499 if (rc) { 2500 2500 QETH_CARD_TEXT_(card, 2, "6err%d", rc); 2501 2501 qeth_free_qdio_queues(card); 2502 - goto out_qdio; 2502 + return rc; 2503 2503 } 2504 2504 rc = qeth_qdio_activate(card); 2505 2505 if (rc) { 2506 2506 QETH_CARD_TEXT_(card, 2, "7err%d", rc); 2507 - goto out_qdio; 2507 + return rc; 2508 2508 } 2509 2509 rc = qeth_dm_act(card); 2510 2510 if (rc) { 2511 2511 QETH_CARD_TEXT_(card, 2, "8err%d", rc); 2512 - goto out_qdio; 2512 + return rc; 2513 2513 } 2514 2514 2515 2515 return 0; 2516 - out_qdio: 2517 - qeth_qdio_clear_card(card, !IS_IQD(card)); 2518 - qdio_free(CARD_DDEV(card)); 2519 - return rc; 2520 2516 } 2521 2517 2522 2518 void qeth_print_status_message(struct qeth_card *card) ··· 3412 3416 } else { 3413 3417 if (card->options.cq == cq) { 3414 3418 rc = 0; 3415 - goto out; 3416 - } 3417 - 3418 - if (card->state != CARD_STATE_DOWN) { 3419 - rc = -1; 3420 3419 goto out; 3421 3420 } 3422 3421 ··· 5014 5023 } 5015 5024 if (qeth_adp_supported(card, IPA_SETADP_SET_DIAG_ASSIST)) { 5016 5025 rc = qeth_query_setdiagass(card); 5017 - if (rc < 0) { 5026 + if (rc) 5018 5027 QETH_CARD_TEXT_(card, 2, "8err%d", rc); 5019 - goto out; 5020 - } 5021 5028 } 5022 5029 5023 5030 if (!qeth_is_diagass_supported(card, QETH_DIAGS_CMD_TRAP) ||
+5 -5
drivers/s390/net/qeth_l2_main.c
··· 287 287 card->state = CARD_STATE_HARDSETUP; 288 288 } 289 289 if (card->state == CARD_STATE_HARDSETUP) { 290 - qeth_qdio_clear_card(card, 0); 291 290 qeth_drain_output_queues(card); 292 291 qeth_clear_working_pool_list(card); 293 292 card->state = CARD_STATE_DOWN; 294 293 } 295 294 295 + qeth_qdio_clear_card(card, 0); 296 296 flush_workqueue(card->event_wq); 297 297 card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED; 298 298 card->info.promisc_mode = 0; ··· 1912 1912 /* check if VNICC is currently enabled */ 1913 1913 bool qeth_l2_vnicc_is_in_use(struct qeth_card *card) 1914 1914 { 1915 - /* if everything is turned off, VNICC is not active */ 1916 - if (!card->options.vnicc.cur_chars) 1915 + if (!card->options.vnicc.sup_chars) 1917 1916 return false; 1918 1917 /* default values are only OK if rx_bcast was not enabled by user 1919 1918 * or the card is offline. ··· 1999 2000 /* enforce assumed default values and recover settings, if changed */ 2000 2001 error |= qeth_l2_vnicc_recover_timeout(card, QETH_VNICC_LEARNING, 2001 2002 timeout); 2002 - chars_tmp = card->options.vnicc.wanted_chars ^ QETH_VNICC_DEFAULT; 2003 - chars_tmp |= QETH_VNICC_BRIDGE_INVISIBLE; 2003 + /* Change chars, if necessary */ 2004 + chars_tmp = card->options.vnicc.wanted_chars ^ 2005 + card->options.vnicc.cur_chars; 2004 2006 chars_len = sizeof(card->options.vnicc.wanted_chars) * BITS_PER_BYTE; 2005 2007 for_each_set_bit(i, &chars_tmp, chars_len) { 2006 2008 vnicc = BIT(i);
+1 -1
drivers/s390/net/qeth_l3_main.c
··· 1183 1183 card->state = CARD_STATE_HARDSETUP; 1184 1184 } 1185 1185 if (card->state == CARD_STATE_HARDSETUP) { 1186 - qeth_qdio_clear_card(card, 0); 1187 1186 qeth_drain_output_queues(card); 1188 1187 qeth_clear_working_pool_list(card); 1189 1188 card->state = CARD_STATE_DOWN; 1190 1189 } 1191 1190 1191 + qeth_qdio_clear_card(card, 0); 1192 1192 flush_workqueue(card->event_wq); 1193 1193 card->info.promisc_mode = 0; 1194 1194 }
+28 -12
drivers/s390/net/qeth_l3_sys.c
··· 242 242 struct device_attribute *attr, const char *buf, size_t count) 243 243 { 244 244 struct qeth_card *card = dev_get_drvdata(dev); 245 + int rc = 0; 245 246 char *tmp; 246 - int rc; 247 247 248 248 if (!IS_IQD(card)) 249 249 return -EPERM; 250 - if (card->state != CARD_STATE_DOWN) 251 - return -EPERM; 252 - if (card->options.sniffer) 253 - return -EPERM; 254 - if (card->options.cq == QETH_CQ_NOTAVAILABLE) 255 - return -EPERM; 250 + 251 + mutex_lock(&card->conf_mutex); 252 + if (card->state != CARD_STATE_DOWN) { 253 + rc = -EPERM; 254 + goto out; 255 + } 256 + 257 + if (card->options.sniffer) { 258 + rc = -EPERM; 259 + goto out; 260 + } 261 + 262 + if (card->options.cq == QETH_CQ_NOTAVAILABLE) { 263 + rc = -EPERM; 264 + goto out; 265 + } 256 266 257 267 tmp = strsep((char **)&buf, "\n"); 258 - if (strlen(tmp) > 8) 259 - return -EINVAL; 268 + if (strlen(tmp) > 8) { 269 + rc = -EINVAL; 270 + goto out; 271 + } 260 272 261 273 if (card->options.hsuid[0]) 262 274 /* delete old ip address */ ··· 279 267 card->options.hsuid[0] = '\0'; 280 268 memcpy(card->dev->perm_addr, card->options.hsuid, 9); 281 269 qeth_configure_cq(card, QETH_CQ_DISABLED); 282 - return count; 270 + goto out; 283 271 } 284 272 285 - if (qeth_configure_cq(card, QETH_CQ_ENABLED)) 286 - return -EPERM; 273 + if (qeth_configure_cq(card, QETH_CQ_ENABLED)) { 274 + rc = -EPERM; 275 + goto out; 276 + } 287 277 288 278 snprintf(card->options.hsuid, sizeof(card->options.hsuid), 289 279 "%-8s", tmp); ··· 294 280 295 281 rc = qeth_l3_modify_hsuid(card, true); 296 282 283 + out: 284 + mutex_unlock(&card->conf_mutex); 297 285 return rc ? rc : count; 298 286 } 299 287
+2 -1
drivers/scsi/cxgbi/libcxgbi.c
··· 121 121 "cdev 0x%p, p# %u.\n", cdev, cdev->nports); 122 122 cxgbi_hbas_remove(cdev); 123 123 cxgbi_device_portmap_cleanup(cdev); 124 - cxgbi_ppm_release(cdev->cdev2ppm(cdev)); 124 + if (cdev->cdev2ppm) 125 + cxgbi_ppm_release(cdev->cdev2ppm(cdev)); 125 126 if (cdev->pmap.max_connect) 126 127 cxgbi_free_big_mem(cdev->pmap.port_csk); 127 128 kfree(cdev);
+1 -2
drivers/scsi/lpfc/lpfc_debugfs.c
··· 5385 5385 .read = lpfc_debugfs_read, 5386 5386 .release = lpfc_debugfs_ras_log_release, 5387 5387 }; 5388 - #endif 5389 5388 5390 5389 #undef lpfc_debugfs_op_dumpHBASlim 5391 5390 static const struct file_operations lpfc_debugfs_op_dumpHBASlim = { ··· 5556 5557 .write = lpfc_idiag_extacc_write, 5557 5558 .release = lpfc_idiag_cmd_release, 5558 5559 }; 5559 - 5560 + #endif 5560 5561 5561 5562 /* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command 5562 5563 * @phba: Pointer to HBA context object.
+1 -1
drivers/scsi/lpfc/lpfc_init.c
··· 5883 5883 break; 5884 5884 default: 5885 5885 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 5886 - "1804 Invalid asynchrous event code: " 5886 + "1804 Invalid asynchronous event code: " 5887 5887 "x%x\n", bf_get(lpfc_trailer_code, 5888 5888 &cq_event->cqe.mcqe_cmpl)); 5889 5889 break;
+5 -5
drivers/scsi/lpfc/lpfc_sli.c
··· 8555 8555 psli->sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; 8556 8556 spin_unlock_irq(&phba->hbalock); 8557 8557 8558 - /* wake up worker thread to post asynchronlous mailbox command */ 8558 + /* wake up worker thread to post asynchronous mailbox command */ 8559 8559 lpfc_worker_wake_up(phba); 8560 8560 } 8561 8561 ··· 8823 8823 return rc; 8824 8824 } 8825 8825 8826 - /* Now, interrupt mode asynchrous mailbox command */ 8826 + /* Now, interrupt mode asynchronous mailbox command */ 8827 8827 rc = lpfc_mbox_cmd_check(phba, mboxq); 8828 8828 if (rc) { 8829 8829 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, ··· 13112 13112 } 13113 13113 13114 13114 /** 13115 - * lpfc_sli4_sp_handle_async_event - Handle an asynchroous event 13115 + * lpfc_sli4_sp_handle_async_event - Handle an asynchronous event 13116 13116 * @phba: Pointer to HBA context object. 13117 13117 * @cqe: Pointer to mailbox completion queue entry. 13118 13118 * 13119 - * This routine process a mailbox completion queue entry with asynchrous 13119 + * This routine process a mailbox completion queue entry with asynchronous 13120 13120 * event. 13121 13121 * 13122 13122 * Return: true if work posted to worker thread, otherwise false. ··· 13270 13270 * @cqe: Pointer to mailbox completion queue entry. 13271 13271 * 13272 13272 * This routine process a mailbox completion queue entry, it invokes the 13273 - * proper mailbox complete handling or asynchrous event handling routine 13273 + * proper mailbox complete handling or asynchronous event handling routine 13274 13274 * according to the MCQE's async bit. 13275 13275 * 13276 13276 * Return: true if work posted to worker thread, otherwise false.
-1
drivers/scsi/mpt3sas/mpt3sas_base.c
··· 5248 5248 &ct->chain_buffer_dma); 5249 5249 if (!ct->chain_buffer) { 5250 5250 ioc_err(ioc, "chain_lookup: pci_pool_alloc failed\n"); 5251 - _base_release_memory_pools(ioc); 5252 5251 goto out; 5253 5252 } 5254 5253 }
+3 -1
drivers/target/target_core_iblock.c
··· 646 646 } 647 647 648 648 bip->bip_iter.bi_size = bio_integrity_bytes(bi, bio_sectors(bio)); 649 - bip_set_seed(bip, bio->bi_iter.bi_sector); 649 + /* virtual start sector must be in integrity interval units */ 650 + bip_set_seed(bip, bio->bi_iter.bi_sector >> 651 + (bi->interval_exp - SECTOR_SHIFT)); 650 652 651 653 pr_debug("IBLOCK BIP Size: %u Sector: %llu\n", bip->bip_iter.bi_size, 652 654 (unsigned long long)bip->bip_iter.bi_sector);
+1
fs/cifs/cifsglob.h
··· 1693 1693 struct timespec64 cf_atime; 1694 1694 struct timespec64 cf_mtime; 1695 1695 struct timespec64 cf_ctime; 1696 + u32 cf_cifstag; 1696 1697 }; 1697 1698 1698 1699 static inline void free_dfs_info_param(struct dfs_info3_param *param)
+54 -9
fs/cifs/readdir.c
··· 139 139 dput(dentry); 140 140 } 141 141 142 + static bool reparse_file_needs_reval(const struct cifs_fattr *fattr) 143 + { 144 + if (!(fattr->cf_cifsattrs & ATTR_REPARSE)) 145 + return false; 146 + /* 147 + * The DFS tags should be only intepreted by server side as per 148 + * MS-FSCC 2.1.2.1, but let's include them anyway. 149 + * 150 + * Besides, if cf_cifstag is unset (0), then we still need it to be 151 + * revalidated to know exactly what reparse point it is. 152 + */ 153 + switch (fattr->cf_cifstag) { 154 + case IO_REPARSE_TAG_DFS: 155 + case IO_REPARSE_TAG_DFSR: 156 + case IO_REPARSE_TAG_SYMLINK: 157 + case IO_REPARSE_TAG_NFS: 158 + case 0: 159 + return true; 160 + } 161 + return false; 162 + } 163 + 142 164 static void 143 165 cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb) 144 166 { ··· 180 158 * is a symbolic link, DFS referral or a reparse point with a direct 181 159 * access like junctions, deduplicated files, NFS symlinks. 182 160 */ 183 - if (fattr->cf_cifsattrs & ATTR_REPARSE) 161 + if (reparse_file_needs_reval(fattr)) 184 162 fattr->cf_flags |= CIFS_FATTR_NEED_REVAL; 185 163 186 164 /* non-unix readdir doesn't provide nlink */ ··· 216 194 } 217 195 } 218 196 197 + static void __dir_info_to_fattr(struct cifs_fattr *fattr, const void *info) 198 + { 199 + const FILE_DIRECTORY_INFO *fi = info; 200 + 201 + memset(fattr, 0, sizeof(*fattr)); 202 + fattr->cf_cifsattrs = le32_to_cpu(fi->ExtFileAttributes); 203 + fattr->cf_eof = le64_to_cpu(fi->EndOfFile); 204 + fattr->cf_bytes = le64_to_cpu(fi->AllocationSize); 205 + fattr->cf_createtime = le64_to_cpu(fi->CreationTime); 206 + fattr->cf_atime = cifs_NTtimeToUnix(fi->LastAccessTime); 207 + fattr->cf_ctime = cifs_NTtimeToUnix(fi->ChangeTime); 208 + fattr->cf_mtime = cifs_NTtimeToUnix(fi->LastWriteTime); 209 + } 210 + 219 211 void 220 212 cifs_dir_info_to_fattr(struct cifs_fattr *fattr, FILE_DIRECTORY_INFO *info, 221 213 struct cifs_sb_info *cifs_sb) 222 214 { 223 - memset(fattr, 0, sizeof(*fattr)); 224 - fattr->cf_cifsattrs = le32_to_cpu(info->ExtFileAttributes); 225 - fattr->cf_eof = le64_to_cpu(info->EndOfFile); 226 - fattr->cf_bytes = le64_to_cpu(info->AllocationSize); 227 - fattr->cf_createtime = le64_to_cpu(info->CreationTime); 228 - fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime); 229 - fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime); 230 - fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime); 215 + __dir_info_to_fattr(fattr, info); 216 + cifs_fill_common_info(fattr, cifs_sb); 217 + } 231 218 219 + static void cifs_fulldir_info_to_fattr(struct cifs_fattr *fattr, 220 + SEARCH_ID_FULL_DIR_INFO *info, 221 + struct cifs_sb_info *cifs_sb) 222 + { 223 + __dir_info_to_fattr(fattr, info); 224 + 225 + /* See MS-FSCC 2.4.18 FileIdFullDirectoryInformation */ 226 + if (fattr->cf_cifsattrs & ATTR_REPARSE) 227 + fattr->cf_cifstag = le32_to_cpu(info->EaSize); 232 228 cifs_fill_common_info(fattr, cifs_sb); 233 229 } 234 230 ··· 794 754 cifs_std_info_to_fattr(&fattr, 795 755 (FIND_FILE_STANDARD_INFO *)find_entry, 796 756 cifs_sb); 757 + break; 758 + case SMB_FIND_FILE_ID_FULL_DIR_INFO: 759 + cifs_fulldir_info_to_fattr(&fattr, 760 + (SEARCH_ID_FULL_DIR_INFO *)find_entry, 761 + cifs_sb); 797 762 break; 798 763 default: 799 764 cifs_dir_info_to_fattr(&fattr,
+1 -1
fs/cifs/smb2file.c
··· 67 67 goto out; 68 68 69 69 70 - if (oparms->tcon->use_resilient) { 70 + if (oparms->tcon->use_resilient) { 71 71 /* default timeout is 0, servers pick default (120 seconds) */ 72 72 nr_ioctl_req.Timeout = 73 73 cpu_to_le32(oparms->tcon->handle_timeout);
+1 -1
fs/drop_caches.c
··· 35 35 spin_unlock(&inode->i_lock); 36 36 spin_unlock(&sb->s_inode_list_lock); 37 37 38 - cond_resched(); 39 38 invalidate_mapping_pages(inode->i_mapping, 0, -1); 40 39 iput(toput_inode); 41 40 toput_inode = inode; 42 41 42 + cond_resched(); 43 43 spin_lock(&sb->s_inode_list_lock); 44 44 } 45 45 spin_unlock(&sb->s_inode_list_lock);
+7
fs/inode.c
··· 676 676 struct inode *inode, *next; 677 677 LIST_HEAD(dispose); 678 678 679 + again: 679 680 spin_lock(&sb->s_inode_list_lock); 680 681 list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) { 681 682 spin_lock(&inode->i_lock); ··· 699 698 inode_lru_list_del(inode); 700 699 spin_unlock(&inode->i_lock); 701 700 list_add(&inode->i_lru, &dispose); 701 + if (need_resched()) { 702 + spin_unlock(&sb->s_inode_list_lock); 703 + cond_resched(); 704 + dispose_list(&dispose); 705 + goto again; 706 + } 702 707 } 703 708 spin_unlock(&sb->s_inode_list_lock); 704 709
+2 -8
fs/io-wq.c
··· 92 92 struct io_wqe_acct acct[2]; 93 93 94 94 struct hlist_nulls_head free_list; 95 - struct hlist_nulls_head busy_list; 96 95 struct list_head all_list; 97 96 98 97 struct io_wq *wq; ··· 326 327 if (worker->flags & IO_WORKER_F_FREE) { 327 328 worker->flags &= ~IO_WORKER_F_FREE; 328 329 hlist_nulls_del_init_rcu(&worker->nulls_node); 329 - hlist_nulls_add_head_rcu(&worker->nulls_node, &wqe->busy_list); 330 330 } 331 331 332 332 /* ··· 363 365 { 364 366 if (!(worker->flags & IO_WORKER_F_FREE)) { 365 367 worker->flags |= IO_WORKER_F_FREE; 366 - hlist_nulls_del_init_rcu(&worker->nulls_node); 367 368 hlist_nulls_add_head_rcu(&worker->nulls_node, &wqe->free_list); 368 369 } 369 370 ··· 428 431 /* flush any pending signals before assigning new work */ 429 432 if (signal_pending(current)) 430 433 flush_signals(current); 434 + 435 + cond_resched(); 431 436 432 437 spin_lock_irq(&worker->lock); 433 438 worker->cur_work = work; ··· 797 798 798 799 set_bit(IO_WQ_BIT_CANCEL, &wq->state); 799 800 800 - /* 801 - * Browse both lists, as there's a gap between handing work off 802 - * to a worker and the worker putting itself on the busy_list 803 - */ 804 801 rcu_read_lock(); 805 802 for_each_node(node) { 806 803 struct io_wqe *wqe = wq->wqes[node]; ··· 1044 1049 spin_lock_init(&wqe->lock); 1045 1050 INIT_WQ_LIST(&wqe->work_list); 1046 1051 INIT_HLIST_NULLS_HEAD(&wqe->free_list, 0); 1047 - INIT_HLIST_NULLS_HEAD(&wqe->busy_list, 1); 1048 1052 INIT_LIST_HEAD(&wqe->all_list); 1049 1053 } 1050 1054
+355 -335
fs/io_uring.c
··· 330 330 struct file *file; 331 331 u64 addr; 332 332 int flags; 333 + unsigned count; 334 + }; 335 + 336 + struct io_rw { 337 + /* NOTE: kiocb has the file as the first member, so don't do it here */ 338 + struct kiocb kiocb; 339 + u64 addr; 340 + u64 len; 341 + }; 342 + 343 + struct io_connect { 344 + struct file *file; 345 + struct sockaddr __user *addr; 346 + int addr_len; 347 + }; 348 + 349 + struct io_sr_msg { 350 + struct file *file; 351 + struct user_msghdr __user *msg; 352 + int msg_flags; 333 353 }; 334 354 335 355 struct io_async_connect { ··· 371 351 }; 372 352 373 353 struct io_async_ctx { 374 - struct io_uring_sqe sqe; 375 354 union { 376 355 struct io_async_rw rw; 377 356 struct io_async_msghdr msg; ··· 388 369 struct io_kiocb { 389 370 union { 390 371 struct file *file; 391 - struct kiocb rw; 372 + struct io_rw rw; 392 373 struct io_poll_iocb poll; 393 374 struct io_accept accept; 394 375 struct io_sync sync; 395 376 struct io_cancel cancel; 396 377 struct io_timeout timeout; 378 + struct io_connect connect; 379 + struct io_sr_msg sr_msg; 397 380 }; 398 381 399 - const struct io_uring_sqe *sqe; 400 382 struct io_async_ctx *io; 401 383 struct file *ring_file; 402 384 int ring_fd; ··· 431 411 #define REQ_F_INFLIGHT 16384 /* on inflight list */ 432 412 #define REQ_F_COMP_LOCKED 32768 /* completion under lock */ 433 413 #define REQ_F_HARDLINK 65536 /* doesn't sever on completion < 0 */ 434 - #define REQ_F_PREPPED 131072 /* request already opcode prepared */ 435 414 u64 user_data; 436 415 u32 result; 437 416 u32 sequence; ··· 628 609 { 629 610 bool do_hashed = false; 630 611 631 - if (req->sqe) { 632 - switch (req->opcode) { 633 - case IORING_OP_WRITEV: 634 - case IORING_OP_WRITE_FIXED: 635 - /* only regular files should be hashed for writes */ 636 - if (req->flags & REQ_F_ISREG) 637 - do_hashed = true; 638 - /* fall-through */ 639 - case IORING_OP_READV: 640 - case IORING_OP_READ_FIXED: 641 - case IORING_OP_SENDMSG: 642 - case IORING_OP_RECVMSG: 643 - case IORING_OP_ACCEPT: 644 - case IORING_OP_POLL_ADD: 645 - case IORING_OP_CONNECT: 646 - /* 647 - * We know REQ_F_ISREG is not set on some of these 648 - * opcodes, but this enables us to keep the check in 649 - * just one place. 650 - */ 651 - if (!(req->flags & REQ_F_ISREG)) 652 - req->work.flags |= IO_WQ_WORK_UNBOUND; 653 - break; 654 - } 655 - if (io_req_needs_user(req)) 656 - req->work.flags |= IO_WQ_WORK_NEEDS_USER; 612 + switch (req->opcode) { 613 + case IORING_OP_WRITEV: 614 + case IORING_OP_WRITE_FIXED: 615 + /* only regular files should be hashed for writes */ 616 + if (req->flags & REQ_F_ISREG) 617 + do_hashed = true; 618 + /* fall-through */ 619 + case IORING_OP_READV: 620 + case IORING_OP_READ_FIXED: 621 + case IORING_OP_SENDMSG: 622 + case IORING_OP_RECVMSG: 623 + case IORING_OP_ACCEPT: 624 + case IORING_OP_POLL_ADD: 625 + case IORING_OP_CONNECT: 626 + /* 627 + * We know REQ_F_ISREG is not set on some of these 628 + * opcodes, but this enables us to keep the check in 629 + * just one place. 630 + */ 631 + if (!(req->flags & REQ_F_ISREG)) 632 + req->work.flags |= IO_WQ_WORK_UNBOUND; 633 + break; 657 634 } 635 + if (io_req_needs_user(req)) 636 + req->work.flags |= IO_WQ_WORK_NEEDS_USER; 658 637 659 638 *link = io_prep_linked_timeout(req); 660 639 return do_hashed; ··· 1197 1180 1198 1181 ret = 0; 1199 1182 list_for_each_entry_safe(req, tmp, &ctx->poll_list, list) { 1200 - struct kiocb *kiocb = &req->rw; 1183 + struct kiocb *kiocb = &req->rw.kiocb; 1201 1184 1202 1185 /* 1203 1186 * Move completed entries to our local list. If we find a ··· 1352 1335 1353 1336 static void io_complete_rw_common(struct kiocb *kiocb, long res) 1354 1337 { 1355 - struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw); 1338 + struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); 1356 1339 1357 1340 if (kiocb->ki_flags & IOCB_WRITE) 1358 1341 kiocb_end_write(req); ··· 1364 1347 1365 1348 static void io_complete_rw(struct kiocb *kiocb, long res, long res2) 1366 1349 { 1367 - struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw); 1350 + struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); 1368 1351 1369 1352 io_complete_rw_common(kiocb, res); 1370 1353 io_put_req(req); ··· 1372 1355 1373 1356 static struct io_kiocb *__io_complete_rw(struct kiocb *kiocb, long res) 1374 1357 { 1375 - struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw); 1358 + struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); 1376 1359 struct io_kiocb *nxt = NULL; 1377 1360 1378 1361 io_complete_rw_common(kiocb, res); ··· 1383 1366 1384 1367 static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2) 1385 1368 { 1386 - struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw); 1369 + struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); 1387 1370 1388 1371 if (kiocb->ki_flags & IOCB_WRITE) 1389 1372 kiocb_end_write(req); ··· 1417 1400 1418 1401 list_req = list_first_entry(&ctx->poll_list, struct io_kiocb, 1419 1402 list); 1420 - if (list_req->rw.ki_filp != req->rw.ki_filp) 1403 + if (list_req->file != req->file) 1421 1404 ctx->poll_multi_file = true; 1422 1405 } 1423 1406 ··· 1488 1471 return false; 1489 1472 } 1490 1473 1491 - static int io_prep_rw(struct io_kiocb *req, bool force_nonblock) 1474 + static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, 1475 + bool force_nonblock) 1492 1476 { 1493 - const struct io_uring_sqe *sqe = req->sqe; 1494 1477 struct io_ring_ctx *ctx = req->ctx; 1495 - struct kiocb *kiocb = &req->rw; 1478 + struct kiocb *kiocb = &req->rw.kiocb; 1496 1479 unsigned ioprio; 1497 1480 int ret; 1498 1481 ··· 1541 1524 return -EINVAL; 1542 1525 kiocb->ki_complete = io_complete_rw; 1543 1526 } 1527 + 1528 + req->rw.addr = READ_ONCE(sqe->addr); 1529 + req->rw.len = READ_ONCE(sqe->len); 1530 + /* we own ->private, reuse it for the buffer index */ 1531 + req->rw.kiocb.private = (void *) (unsigned long) 1532 + READ_ONCE(sqe->buf_index); 1544 1533 return 0; 1545 1534 } 1546 1535 ··· 1580 1557 io_rw_done(kiocb, ret); 1581 1558 } 1582 1559 1583 - static ssize_t io_import_fixed(struct io_ring_ctx *ctx, int rw, 1584 - const struct io_uring_sqe *sqe, 1560 + static ssize_t io_import_fixed(struct io_kiocb *req, int rw, 1585 1561 struct iov_iter *iter) 1586 1562 { 1587 - size_t len = READ_ONCE(sqe->len); 1563 + struct io_ring_ctx *ctx = req->ctx; 1564 + size_t len = req->rw.len; 1588 1565 struct io_mapped_ubuf *imu; 1589 1566 unsigned index, buf_index; 1590 1567 size_t offset; ··· 1594 1571 if (unlikely(!ctx->user_bufs)) 1595 1572 return -EFAULT; 1596 1573 1597 - buf_index = READ_ONCE(sqe->buf_index); 1574 + buf_index = (unsigned long) req->rw.kiocb.private; 1598 1575 if (unlikely(buf_index >= ctx->nr_user_bufs)) 1599 1576 return -EFAULT; 1600 1577 1601 1578 index = array_index_nospec(buf_index, ctx->nr_user_bufs); 1602 1579 imu = &ctx->user_bufs[index]; 1603 - buf_addr = READ_ONCE(sqe->addr); 1580 + buf_addr = req->rw.addr; 1604 1581 1605 1582 /* overflow */ 1606 1583 if (buf_addr + len < buf_addr) ··· 1657 1634 static ssize_t io_import_iovec(int rw, struct io_kiocb *req, 1658 1635 struct iovec **iovec, struct iov_iter *iter) 1659 1636 { 1660 - const struct io_uring_sqe *sqe = req->sqe; 1661 - void __user *buf = u64_to_user_ptr(READ_ONCE(sqe->addr)); 1662 - size_t sqe_len = READ_ONCE(sqe->len); 1637 + void __user *buf = u64_to_user_ptr(req->rw.addr); 1638 + size_t sqe_len = req->rw.len; 1663 1639 u8 opcode; 1664 1640 1665 - /* 1666 - * We're reading ->opcode for the second time, but the first read 1667 - * doesn't care whether it's _FIXED or not, so it doesn't matter 1668 - * whether ->opcode changes concurrently. The first read does care 1669 - * about whether it is a READ or a WRITE, so we don't trust this read 1670 - * for that purpose and instead let the caller pass in the read/write 1671 - * flag. 1672 - */ 1673 1641 opcode = req->opcode; 1674 1642 if (opcode == IORING_OP_READ_FIXED || opcode == IORING_OP_WRITE_FIXED) { 1675 1643 *iovec = NULL; 1676 - return io_import_fixed(req->ctx, rw, sqe, iter); 1644 + return io_import_fixed(req, rw, iter); 1677 1645 } 1646 + 1647 + /* buffer index only valid with fixed read/write */ 1648 + if (req->rw.kiocb.private) 1649 + return -EINVAL; 1678 1650 1679 1651 if (req->io) { 1680 1652 struct io_async_rw *iorw = &req->io->rw; ··· 1768 1750 static int io_alloc_async_ctx(struct io_kiocb *req) 1769 1751 { 1770 1752 req->io = kmalloc(sizeof(*req->io), GFP_KERNEL); 1771 - if (req->io) { 1772 - memcpy(&req->io->sqe, req->sqe, sizeof(req->io->sqe)); 1773 - req->sqe = &req->io->sqe; 1774 - return 0; 1775 - } 1776 - 1777 - return 1; 1753 + return req->io == NULL; 1778 1754 } 1779 1755 1780 1756 static void io_rw_async(struct io_wq_work **workptr) ··· 1794 1782 return 0; 1795 1783 } 1796 1784 1797 - static int io_read_prep(struct io_kiocb *req, struct iovec **iovec, 1798 - struct iov_iter *iter, bool force_nonblock) 1785 + static int io_read_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe, 1786 + bool force_nonblock) 1799 1787 { 1788 + struct io_async_ctx *io; 1789 + struct iov_iter iter; 1800 1790 ssize_t ret; 1801 1791 1802 - ret = io_prep_rw(req, force_nonblock); 1792 + ret = io_prep_rw(req, sqe, force_nonblock); 1803 1793 if (ret) 1804 1794 return ret; 1805 1795 1806 1796 if (unlikely(!(req->file->f_mode & FMODE_READ))) 1807 1797 return -EBADF; 1808 1798 1809 - return io_import_iovec(READ, req, iovec, iter); 1799 + if (!req->io) 1800 + return 0; 1801 + 1802 + io = req->io; 1803 + io->rw.iov = io->rw.fast_iov; 1804 + req->io = NULL; 1805 + ret = io_import_iovec(READ, req, &io->rw.iov, &iter); 1806 + req->io = io; 1807 + if (ret < 0) 1808 + return ret; 1809 + 1810 + io_req_map_rw(req, ret, io->rw.iov, io->rw.fast_iov, &iter); 1811 + return 0; 1810 1812 } 1811 1813 1812 1814 static int io_read(struct io_kiocb *req, struct io_kiocb **nxt, 1813 1815 bool force_nonblock) 1814 1816 { 1815 1817 struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; 1816 - struct kiocb *kiocb = &req->rw; 1818 + struct kiocb *kiocb = &req->rw.kiocb; 1817 1819 struct iov_iter iter; 1818 - struct file *file; 1819 1820 size_t iov_count; 1820 1821 ssize_t io_size, ret; 1821 1822 1822 - if (!req->io) { 1823 - ret = io_read_prep(req, &iovec, &iter, force_nonblock); 1824 - if (ret < 0) 1825 - return ret; 1826 - } else { 1827 - ret = io_import_iovec(READ, req, &iovec, &iter); 1828 - if (ret < 0) 1829 - return ret; 1830 - } 1823 + ret = io_import_iovec(READ, req, &iovec, &iter); 1824 + if (ret < 0) 1825 + return ret; 1831 1826 1832 1827 /* Ensure we clear previously set non-block flag */ 1833 1828 if (!force_nonblock) 1834 - req->rw.ki_flags &= ~IOCB_NOWAIT; 1829 + req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT; 1835 1830 1836 - file = req->file; 1837 1831 io_size = ret; 1838 1832 if (req->flags & REQ_F_LINK) 1839 1833 req->result = io_size; ··· 1848 1830 * If the file doesn't support async, mark it as REQ_F_MUST_PUNT so 1849 1831 * we know to async punt it even if it was opened O_NONBLOCK 1850 1832 */ 1851 - if (force_nonblock && !io_file_supports_async(file)) { 1833 + if (force_nonblock && !io_file_supports_async(req->file)) { 1852 1834 req->flags |= REQ_F_MUST_PUNT; 1853 1835 goto copy_iov; 1854 1836 } 1855 1837 1856 1838 iov_count = iov_iter_count(&iter); 1857 - ret = rw_verify_area(READ, file, &kiocb->ki_pos, iov_count); 1839 + ret = rw_verify_area(READ, req->file, &kiocb->ki_pos, iov_count); 1858 1840 if (!ret) { 1859 1841 ssize_t ret2; 1860 1842 1861 - if (file->f_op->read_iter) 1862 - ret2 = call_read_iter(file, kiocb, &iter); 1843 + if (req->file->f_op->read_iter) 1844 + ret2 = call_read_iter(req->file, kiocb, &iter); 1863 1845 else 1864 - ret2 = loop_rw_iter(READ, file, kiocb, &iter); 1846 + ret2 = loop_rw_iter(READ, req->file, kiocb, &iter); 1865 1847 1866 1848 /* 1867 1849 * In case of a short read, punt to async. This can happen ··· 1893 1875 return ret; 1894 1876 } 1895 1877 1896 - static int io_write_prep(struct io_kiocb *req, struct iovec **iovec, 1897 - struct iov_iter *iter, bool force_nonblock) 1878 + static int io_write_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe, 1879 + bool force_nonblock) 1898 1880 { 1881 + struct io_async_ctx *io; 1882 + struct iov_iter iter; 1899 1883 ssize_t ret; 1900 1884 1901 - ret = io_prep_rw(req, force_nonblock); 1885 + ret = io_prep_rw(req, sqe, force_nonblock); 1902 1886 if (ret) 1903 1887 return ret; 1904 1888 1905 1889 if (unlikely(!(req->file->f_mode & FMODE_WRITE))) 1906 1890 return -EBADF; 1907 1891 1908 - return io_import_iovec(WRITE, req, iovec, iter); 1892 + if (!req->io) 1893 + return 0; 1894 + 1895 + io = req->io; 1896 + io->rw.iov = io->rw.fast_iov; 1897 + req->io = NULL; 1898 + ret = io_import_iovec(WRITE, req, &io->rw.iov, &iter); 1899 + req->io = io; 1900 + if (ret < 0) 1901 + return ret; 1902 + 1903 + io_req_map_rw(req, ret, io->rw.iov, io->rw.fast_iov, &iter); 1904 + return 0; 1909 1905 } 1910 1906 1911 1907 static int io_write(struct io_kiocb *req, struct io_kiocb **nxt, 1912 1908 bool force_nonblock) 1913 1909 { 1914 1910 struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; 1915 - struct kiocb *kiocb = &req->rw; 1911 + struct kiocb *kiocb = &req->rw.kiocb; 1916 1912 struct iov_iter iter; 1917 - struct file *file; 1918 1913 size_t iov_count; 1919 1914 ssize_t ret, io_size; 1920 1915 1921 - if (!req->io) { 1922 - ret = io_write_prep(req, &iovec, &iter, force_nonblock); 1923 - if (ret < 0) 1924 - return ret; 1925 - } else { 1926 - ret = io_import_iovec(WRITE, req, &iovec, &iter); 1927 - if (ret < 0) 1928 - return ret; 1929 - } 1916 + ret = io_import_iovec(WRITE, req, &iovec, &iter); 1917 + if (ret < 0) 1918 + return ret; 1930 1919 1931 1920 /* Ensure we clear previously set non-block flag */ 1932 1921 if (!force_nonblock) 1933 - req->rw.ki_flags &= ~IOCB_NOWAIT; 1922 + req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT; 1934 1923 1935 - file = kiocb->ki_filp; 1936 1924 io_size = ret; 1937 1925 if (req->flags & REQ_F_LINK) 1938 1926 req->result = io_size; ··· 1958 1934 goto copy_iov; 1959 1935 1960 1936 iov_count = iov_iter_count(&iter); 1961 - ret = rw_verify_area(WRITE, file, &kiocb->ki_pos, iov_count); 1937 + ret = rw_verify_area(WRITE, req->file, &kiocb->ki_pos, iov_count); 1962 1938 if (!ret) { 1963 1939 ssize_t ret2; 1964 1940 ··· 1970 1946 * we return to userspace. 1971 1947 */ 1972 1948 if (req->flags & REQ_F_ISREG) { 1973 - __sb_start_write(file_inode(file)->i_sb, 1949 + __sb_start_write(file_inode(req->file)->i_sb, 1974 1950 SB_FREEZE_WRITE, true); 1975 - __sb_writers_release(file_inode(file)->i_sb, 1951 + __sb_writers_release(file_inode(req->file)->i_sb, 1976 1952 SB_FREEZE_WRITE); 1977 1953 } 1978 1954 kiocb->ki_flags |= IOCB_WRITE; 1979 1955 1980 - if (file->f_op->write_iter) 1981 - ret2 = call_write_iter(file, kiocb, &iter); 1956 + if (req->file->f_op->write_iter) 1957 + ret2 = call_write_iter(req->file, kiocb, &iter); 1982 1958 else 1983 - ret2 = loop_rw_iter(WRITE, file, kiocb, &iter); 1959 + ret2 = loop_rw_iter(WRITE, req->file, kiocb, &iter); 1984 1960 if (!force_nonblock || ret2 != -EAGAIN) { 1985 1961 kiocb_done(kiocb, ret2, nxt, req->in_async); 1986 1962 } else { ··· 2013 1989 return 0; 2014 1990 } 2015 1991 2016 - static int io_prep_fsync(struct io_kiocb *req) 1992 + static int io_prep_fsync(struct io_kiocb *req, const struct io_uring_sqe *sqe) 2017 1993 { 2018 - const struct io_uring_sqe *sqe = req->sqe; 2019 1994 struct io_ring_ctx *ctx = req->ctx; 2020 1995 2021 - if (req->flags & REQ_F_PREPPED) 2022 - return 0; 2023 1996 if (!req->file) 2024 1997 return -EBADF; 2025 1998 ··· 2031 2010 2032 2011 req->sync.off = READ_ONCE(sqe->off); 2033 2012 req->sync.len = READ_ONCE(sqe->len); 2034 - req->flags |= REQ_F_PREPPED; 2035 2013 return 0; 2036 2014 } 2037 2015 ··· 2056 2036 if (io_req_cancelled(req)) 2057 2037 return; 2058 2038 2059 - ret = vfs_fsync_range(req->rw.ki_filp, req->sync.off, 2039 + ret = vfs_fsync_range(req->file, req->sync.off, 2060 2040 end > 0 ? end : LLONG_MAX, 2061 2041 req->sync.flags & IORING_FSYNC_DATASYNC); 2062 2042 if (ret < 0) ··· 2071 2051 bool force_nonblock) 2072 2052 { 2073 2053 struct io_wq_work *work, *old_work; 2074 - int ret; 2075 - 2076 - ret = io_prep_fsync(req); 2077 - if (ret) 2078 - return ret; 2079 2054 2080 2055 /* fsync always requires a blocking context */ 2081 2056 if (force_nonblock) { ··· 2086 2071 return 0; 2087 2072 } 2088 2073 2089 - static int io_prep_sfr(struct io_kiocb *req) 2074 + static int io_prep_sfr(struct io_kiocb *req, const struct io_uring_sqe *sqe) 2090 2075 { 2091 - const struct io_uring_sqe *sqe = req->sqe; 2092 2076 struct io_ring_ctx *ctx = req->ctx; 2093 2077 2094 - if (req->flags & REQ_F_PREPPED) 2095 - return 0; 2096 2078 if (!req->file) 2097 2079 return -EBADF; 2098 2080 ··· 2101 2089 req->sync.off = READ_ONCE(sqe->off); 2102 2090 req->sync.len = READ_ONCE(sqe->len); 2103 2091 req->sync.flags = READ_ONCE(sqe->sync_range_flags); 2104 - req->flags |= REQ_F_PREPPED; 2105 2092 return 0; 2106 2093 } 2107 2094 ··· 2113 2102 if (io_req_cancelled(req)) 2114 2103 return; 2115 2104 2116 - ret = sync_file_range(req->rw.ki_filp, req->sync.off, req->sync.len, 2105 + ret = sync_file_range(req->file, req->sync.off, req->sync.len, 2117 2106 req->sync.flags); 2118 2107 if (ret < 0) 2119 2108 req_set_fail_links(req); ··· 2127 2116 bool force_nonblock) 2128 2117 { 2129 2118 struct io_wq_work *work, *old_work; 2130 - int ret; 2131 - 2132 - ret = io_prep_sfr(req); 2133 - if (ret) 2134 - return ret; 2135 2119 2136 2120 /* sync_file_range always requires a blocking context */ 2137 2121 if (force_nonblock) { ··· 2155 2149 } 2156 2150 #endif 2157 2151 2158 - static int io_sendmsg_prep(struct io_kiocb *req, struct io_async_ctx *io) 2152 + static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 2159 2153 { 2160 2154 #if defined(CONFIG_NET) 2161 - const struct io_uring_sqe *sqe = req->sqe; 2162 - struct user_msghdr __user *msg; 2163 - unsigned flags; 2155 + struct io_sr_msg *sr = &req->sr_msg; 2156 + struct io_async_ctx *io = req->io; 2164 2157 2165 - flags = READ_ONCE(sqe->msg_flags); 2166 - msg = (struct user_msghdr __user *)(unsigned long) READ_ONCE(sqe->addr); 2158 + sr->msg_flags = READ_ONCE(sqe->msg_flags); 2159 + sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr)); 2160 + 2161 + if (!io) 2162 + return 0; 2163 + 2167 2164 io->msg.iov = io->msg.fast_iov; 2168 - return sendmsg_copy_msghdr(&io->msg.msg, msg, flags, &io->msg.iov); 2165 + return sendmsg_copy_msghdr(&io->msg.msg, sr->msg, sr->msg_flags, 2166 + &io->msg.iov); 2169 2167 #else 2170 - return 0; 2168 + return -EOPNOTSUPP; 2171 2169 #endif 2172 2170 } 2173 2171 ··· 2179 2169 bool force_nonblock) 2180 2170 { 2181 2171 #if defined(CONFIG_NET) 2182 - const struct io_uring_sqe *sqe = req->sqe; 2183 2172 struct io_async_msghdr *kmsg = NULL; 2184 2173 struct socket *sock; 2185 2174 int ret; ··· 2192 2183 struct sockaddr_storage addr; 2193 2184 unsigned flags; 2194 2185 2195 - flags = READ_ONCE(sqe->msg_flags); 2196 - if (flags & MSG_DONTWAIT) 2197 - req->flags |= REQ_F_NOWAIT; 2198 - else if (force_nonblock) 2199 - flags |= MSG_DONTWAIT; 2200 - 2201 2186 if (req->io) { 2202 2187 kmsg = &req->io->msg; 2203 2188 kmsg->msg.msg_name = &addr; ··· 2200 2197 kmsg->iov = kmsg->fast_iov; 2201 2198 kmsg->msg.msg_iter.iov = kmsg->iov; 2202 2199 } else { 2200 + struct io_sr_msg *sr = &req->sr_msg; 2201 + 2203 2202 kmsg = &io.msg; 2204 2203 kmsg->msg.msg_name = &addr; 2205 - ret = io_sendmsg_prep(req, &io); 2204 + 2205 + io.msg.iov = io.msg.fast_iov; 2206 + ret = sendmsg_copy_msghdr(&io.msg.msg, sr->msg, 2207 + sr->msg_flags, &io.msg.iov); 2206 2208 if (ret) 2207 - goto out; 2209 + return ret; 2208 2210 } 2211 + 2212 + flags = req->sr_msg.msg_flags; 2213 + if (flags & MSG_DONTWAIT) 2214 + req->flags |= REQ_F_NOWAIT; 2215 + else if (force_nonblock) 2216 + flags |= MSG_DONTWAIT; 2209 2217 2210 2218 ret = __sys_sendmsg_sock(sock, &kmsg->msg, flags); 2211 2219 if (force_nonblock && ret == -EAGAIN) { ··· 2232 2218 ret = -EINTR; 2233 2219 } 2234 2220 2235 - out: 2236 2221 if (!io_wq_current_is_worker() && kmsg && kmsg->iov != kmsg->fast_iov) 2237 2222 kfree(kmsg->iov); 2238 2223 io_cqring_add_event(req, ret); ··· 2244 2231 #endif 2245 2232 } 2246 2233 2247 - static int io_recvmsg_prep(struct io_kiocb *req, struct io_async_ctx *io) 2234 + static int io_recvmsg_prep(struct io_kiocb *req, 2235 + const struct io_uring_sqe *sqe) 2248 2236 { 2249 2237 #if defined(CONFIG_NET) 2250 - const struct io_uring_sqe *sqe = req->sqe; 2251 - struct user_msghdr __user *msg; 2252 - unsigned flags; 2238 + struct io_sr_msg *sr = &req->sr_msg; 2239 + struct io_async_ctx *io = req->io; 2253 2240 2254 - flags = READ_ONCE(sqe->msg_flags); 2255 - msg = (struct user_msghdr __user *)(unsigned long) READ_ONCE(sqe->addr); 2241 + sr->msg_flags = READ_ONCE(sqe->msg_flags); 2242 + sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr)); 2243 + 2244 + if (!io) 2245 + return 0; 2246 + 2256 2247 io->msg.iov = io->msg.fast_iov; 2257 - return recvmsg_copy_msghdr(&io->msg.msg, msg, flags, &io->msg.uaddr, 2258 - &io->msg.iov); 2248 + return recvmsg_copy_msghdr(&io->msg.msg, sr->msg, sr->msg_flags, 2249 + &io->msg.uaddr, &io->msg.iov); 2259 2250 #else 2260 - return 0; 2251 + return -EOPNOTSUPP; 2261 2252 #endif 2262 2253 } 2263 2254 ··· 2269 2252 bool force_nonblock) 2270 2253 { 2271 2254 #if defined(CONFIG_NET) 2272 - const struct io_uring_sqe *sqe = req->sqe; 2273 2255 struct io_async_msghdr *kmsg = NULL; 2274 2256 struct socket *sock; 2275 2257 int ret; ··· 2278 2262 2279 2263 sock = sock_from_file(req->file, &ret); 2280 2264 if (sock) { 2281 - struct user_msghdr __user *msg; 2282 2265 struct io_async_ctx io; 2283 2266 struct sockaddr_storage addr; 2284 2267 unsigned flags; 2285 2268 2286 - flags = READ_ONCE(sqe->msg_flags); 2287 - if (flags & MSG_DONTWAIT) 2288 - req->flags |= REQ_F_NOWAIT; 2289 - else if (force_nonblock) 2290 - flags |= MSG_DONTWAIT; 2291 - 2292 - msg = (struct user_msghdr __user *) (unsigned long) 2293 - READ_ONCE(sqe->addr); 2294 2269 if (req->io) { 2295 2270 kmsg = &req->io->msg; 2296 2271 kmsg->msg.msg_name = &addr; ··· 2290 2283 kmsg->iov = kmsg->fast_iov; 2291 2284 kmsg->msg.msg_iter.iov = kmsg->iov; 2292 2285 } else { 2286 + struct io_sr_msg *sr = &req->sr_msg; 2287 + 2293 2288 kmsg = &io.msg; 2294 2289 kmsg->msg.msg_name = &addr; 2295 - ret = io_recvmsg_prep(req, &io); 2290 + 2291 + io.msg.iov = io.msg.fast_iov; 2292 + ret = recvmsg_copy_msghdr(&io.msg.msg, sr->msg, 2293 + sr->msg_flags, &io.msg.uaddr, 2294 + &io.msg.iov); 2296 2295 if (ret) 2297 - goto out; 2296 + return ret; 2298 2297 } 2299 2298 2300 - ret = __sys_recvmsg_sock(sock, &kmsg->msg, msg, kmsg->uaddr, flags); 2299 + flags = req->sr_msg.msg_flags; 2300 + if (flags & MSG_DONTWAIT) 2301 + req->flags |= REQ_F_NOWAIT; 2302 + else if (force_nonblock) 2303 + flags |= MSG_DONTWAIT; 2304 + 2305 + ret = __sys_recvmsg_sock(sock, &kmsg->msg, req->sr_msg.msg, 2306 + kmsg->uaddr, flags); 2301 2307 if (force_nonblock && ret == -EAGAIN) { 2302 2308 if (req->io) 2303 2309 return -EAGAIN; ··· 2324 2304 ret = -EINTR; 2325 2305 } 2326 2306 2327 - out: 2328 2307 if (!io_wq_current_is_worker() && kmsg && kmsg->iov != kmsg->fast_iov) 2329 2308 kfree(kmsg->iov); 2330 2309 io_cqring_add_event(req, ret); ··· 2336 2317 #endif 2337 2318 } 2338 2319 2339 - static int io_accept_prep(struct io_kiocb *req) 2320 + static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 2340 2321 { 2341 2322 #if defined(CONFIG_NET) 2342 - const struct io_uring_sqe *sqe = req->sqe; 2343 2323 struct io_accept *accept = &req->accept; 2344 - 2345 - if (req->flags & REQ_F_PREPPED) 2346 - return 0; 2347 2324 2348 2325 if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL))) 2349 2326 return -EINVAL; 2350 2327 if (sqe->ioprio || sqe->len || sqe->buf_index) 2351 2328 return -EINVAL; 2352 2329 2353 - accept->addr = (struct sockaddr __user *) 2354 - (unsigned long) READ_ONCE(sqe->addr); 2355 - accept->addr_len = (int __user *) (unsigned long) READ_ONCE(sqe->addr2); 2330 + accept->addr = u64_to_user_ptr(READ_ONCE(sqe->addr)); 2331 + accept->addr_len = u64_to_user_ptr(READ_ONCE(sqe->addr2)); 2356 2332 accept->flags = READ_ONCE(sqe->accept_flags); 2357 - req->flags |= REQ_F_PREPPED; 2358 2333 return 0; 2359 2334 #else 2360 2335 return -EOPNOTSUPP; ··· 2396 2383 #if defined(CONFIG_NET) 2397 2384 int ret; 2398 2385 2399 - ret = io_accept_prep(req); 2400 - if (ret) 2401 - return ret; 2402 - 2403 2386 ret = __io_accept(req, nxt, force_nonblock); 2404 2387 if (ret == -EAGAIN && force_nonblock) { 2405 2388 req->work.func = io_accept_finish; ··· 2409 2400 #endif 2410 2401 } 2411 2402 2412 - static int io_connect_prep(struct io_kiocb *req, struct io_async_ctx *io) 2403 + static int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 2413 2404 { 2414 2405 #if defined(CONFIG_NET) 2415 - const struct io_uring_sqe *sqe = req->sqe; 2416 - struct sockaddr __user *addr; 2417 - int addr_len; 2406 + struct io_connect *conn = &req->connect; 2407 + struct io_async_ctx *io = req->io; 2418 2408 2419 - addr = (struct sockaddr __user *) (unsigned long) READ_ONCE(sqe->addr); 2420 - addr_len = READ_ONCE(sqe->addr2); 2421 - return move_addr_to_kernel(addr, addr_len, &io->connect.address); 2409 + if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL))) 2410 + return -EINVAL; 2411 + if (sqe->ioprio || sqe->len || sqe->buf_index || sqe->rw_flags) 2412 + return -EINVAL; 2413 + 2414 + conn->addr = u64_to_user_ptr(READ_ONCE(sqe->addr)); 2415 + conn->addr_len = READ_ONCE(sqe->addr2); 2416 + 2417 + if (!io) 2418 + return 0; 2419 + 2420 + return move_addr_to_kernel(conn->addr, conn->addr_len, 2421 + &io->connect.address); 2422 2422 #else 2423 - return 0; 2423 + return -EOPNOTSUPP; 2424 2424 #endif 2425 2425 } 2426 2426 ··· 2437 2419 bool force_nonblock) 2438 2420 { 2439 2421 #if defined(CONFIG_NET) 2440 - const struct io_uring_sqe *sqe = req->sqe; 2441 2422 struct io_async_ctx __io, *io; 2442 2423 unsigned file_flags; 2443 - int addr_len, ret; 2444 - 2445 - if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL))) 2446 - return -EINVAL; 2447 - if (sqe->ioprio || sqe->len || sqe->buf_index || sqe->rw_flags) 2448 - return -EINVAL; 2449 - 2450 - addr_len = READ_ONCE(sqe->addr2); 2451 - file_flags = force_nonblock ? O_NONBLOCK : 0; 2424 + int ret; 2452 2425 2453 2426 if (req->io) { 2454 2427 io = req->io; 2455 2428 } else { 2456 - ret = io_connect_prep(req, &__io); 2429 + ret = move_addr_to_kernel(req->connect.addr, 2430 + req->connect.addr_len, 2431 + &__io.connect.address); 2457 2432 if (ret) 2458 2433 goto out; 2459 2434 io = &__io; 2460 2435 } 2461 2436 2462 - ret = __sys_connect_file(req->file, &io->connect.address, addr_len, 2463 - file_flags); 2437 + file_flags = force_nonblock ? O_NONBLOCK : 0; 2438 + 2439 + ret = __sys_connect_file(req->file, &io->connect.address, 2440 + req->connect.addr_len, file_flags); 2464 2441 if ((ret == -EAGAIN || ret == -EINPROGRESS) && force_nonblock) { 2465 2442 if (req->io) 2466 2443 return -EAGAIN; ··· 2526 2513 return -ENOENT; 2527 2514 } 2528 2515 2529 - static int io_poll_remove_prep(struct io_kiocb *req) 2516 + static int io_poll_remove_prep(struct io_kiocb *req, 2517 + const struct io_uring_sqe *sqe) 2530 2518 { 2531 - const struct io_uring_sqe *sqe = req->sqe; 2532 - 2533 - if (req->flags & REQ_F_PREPPED) 2534 - return 0; 2535 2519 if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) 2536 2520 return -EINVAL; 2537 2521 if (sqe->ioprio || sqe->off || sqe->len || sqe->buf_index || ··· 2536 2526 return -EINVAL; 2537 2527 2538 2528 req->poll.addr = READ_ONCE(sqe->addr); 2539 - req->flags |= REQ_F_PREPPED; 2540 2529 return 0; 2541 2530 } 2542 2531 ··· 2548 2539 struct io_ring_ctx *ctx = req->ctx; 2549 2540 u64 addr; 2550 2541 int ret; 2551 - 2552 - ret = io_poll_remove_prep(req); 2553 - if (ret) 2554 - return ret; 2555 2542 2556 2543 addr = req->poll.addr; 2557 2544 spin_lock_irq(&ctx->completion_lock); ··· 2686 2681 hlist_add_head(&req->hash_node, list); 2687 2682 } 2688 2683 2689 - static int io_poll_add_prep(struct io_kiocb *req) 2684 + static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 2690 2685 { 2691 - const struct io_uring_sqe *sqe = req->sqe; 2692 2686 struct io_poll_iocb *poll = &req->poll; 2693 2687 u16 events; 2694 2688 2695 - if (req->flags & REQ_F_PREPPED) 2696 - return 0; 2697 2689 if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) 2698 2690 return -EINVAL; 2699 2691 if (sqe->addr || sqe->ioprio || sqe->off || sqe->len || sqe->buf_index) ··· 2698 2696 if (!poll->file) 2699 2697 return -EBADF; 2700 2698 2701 - req->flags |= REQ_F_PREPPED; 2702 2699 events = READ_ONCE(sqe->poll_events); 2703 2700 poll->events = demangle_poll(events) | EPOLLERR | EPOLLHUP; 2704 2701 return 0; ··· 2710 2709 struct io_poll_table ipt; 2711 2710 bool cancel = false; 2712 2711 __poll_t mask; 2713 - int ret; 2714 - 2715 - ret = io_poll_add_prep(req); 2716 - if (ret) 2717 - return ret; 2718 2712 2719 2713 INIT_IO_WORK(&req->work, io_poll_complete_work); 2720 2714 INIT_HLIST_NODE(&req->hash_node); ··· 2828 2832 return 0; 2829 2833 } 2830 2834 2831 - static int io_timeout_remove_prep(struct io_kiocb *req) 2835 + static int io_timeout_remove_prep(struct io_kiocb *req, 2836 + const struct io_uring_sqe *sqe) 2832 2837 { 2833 - const struct io_uring_sqe *sqe = req->sqe; 2834 - 2835 - if (req->flags & REQ_F_PREPPED) 2836 - return 0; 2837 2838 if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) 2838 2839 return -EINVAL; 2839 2840 if (sqe->flags || sqe->ioprio || sqe->buf_index || sqe->len) ··· 2841 2848 if (req->timeout.flags) 2842 2849 return -EINVAL; 2843 2850 2844 - req->flags |= REQ_F_PREPPED; 2845 2851 return 0; 2846 2852 } 2847 2853 ··· 2851 2859 { 2852 2860 struct io_ring_ctx *ctx = req->ctx; 2853 2861 int ret; 2854 - 2855 - ret = io_timeout_remove_prep(req); 2856 - if (ret) 2857 - return ret; 2858 2862 2859 2863 spin_lock_irq(&ctx->completion_lock); 2860 2864 ret = io_timeout_cancel(ctx, req->timeout.addr); ··· 2865 2877 return 0; 2866 2878 } 2867 2879 2868 - static int io_timeout_prep(struct io_kiocb *req, struct io_async_ctx *io, 2880 + static int io_timeout_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe, 2869 2881 bool is_timeout_link) 2870 2882 { 2871 - const struct io_uring_sqe *sqe = req->sqe; 2872 2883 struct io_timeout_data *data; 2873 2884 unsigned flags; 2874 2885 ··· 2881 2894 if (flags & ~IORING_TIMEOUT_ABS) 2882 2895 return -EINVAL; 2883 2896 2884 - data = &io->timeout; 2897 + req->timeout.count = READ_ONCE(sqe->off); 2898 + 2899 + if (!req->io && io_alloc_async_ctx(req)) 2900 + return -ENOMEM; 2901 + 2902 + data = &req->io->timeout; 2885 2903 data->req = req; 2886 2904 req->flags |= REQ_F_TIMEOUT; 2887 2905 ··· 2904 2912 2905 2913 static int io_timeout(struct io_kiocb *req) 2906 2914 { 2907 - const struct io_uring_sqe *sqe = req->sqe; 2908 2915 unsigned count; 2909 2916 struct io_ring_ctx *ctx = req->ctx; 2910 2917 struct io_timeout_data *data; 2911 2918 struct list_head *entry; 2912 2919 unsigned span = 0; 2913 - int ret; 2914 2920 2915 - if (!req->io) { 2916 - if (io_alloc_async_ctx(req)) 2917 - return -ENOMEM; 2918 - ret = io_timeout_prep(req, req->io, false); 2919 - if (ret) 2920 - return ret; 2921 - } 2922 2921 data = &req->io->timeout; 2923 2922 2924 2923 /* ··· 2917 2934 * timeout event to be satisfied. If it isn't set, then this is 2918 2935 * a pure timeout request, sequence isn't used. 2919 2936 */ 2920 - count = READ_ONCE(sqe->off); 2937 + count = req->timeout.count; 2921 2938 if (!count) { 2922 2939 req->flags |= REQ_F_TIMEOUT_NOSEQ; 2923 2940 spin_lock_irq(&ctx->completion_lock); ··· 3035 3052 io_put_req_find_next(req, nxt); 3036 3053 } 3037 3054 3038 - static int io_async_cancel_prep(struct io_kiocb *req) 3055 + static int io_async_cancel_prep(struct io_kiocb *req, 3056 + const struct io_uring_sqe *sqe) 3039 3057 { 3040 - const struct io_uring_sqe *sqe = req->sqe; 3041 - 3042 - if (req->flags & REQ_F_PREPPED) 3043 - return 0; 3044 3058 if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) 3045 3059 return -EINVAL; 3046 3060 if (sqe->flags || sqe->ioprio || sqe->off || sqe->len || 3047 3061 sqe->cancel_flags) 3048 3062 return -EINVAL; 3049 3063 3050 - req->flags |= REQ_F_PREPPED; 3051 3064 req->cancel.addr = READ_ONCE(sqe->addr); 3052 3065 return 0; 3053 3066 } ··· 3051 3072 static int io_async_cancel(struct io_kiocb *req, struct io_kiocb **nxt) 3052 3073 { 3053 3074 struct io_ring_ctx *ctx = req->ctx; 3054 - int ret; 3055 - 3056 - ret = io_async_cancel_prep(req); 3057 - if (ret) 3058 - return ret; 3059 3075 3060 3076 io_async_find_and_cancel(ctx, req, req->cancel.addr, nxt, 0); 3061 3077 return 0; 3062 3078 } 3063 3079 3064 - static int io_req_defer_prep(struct io_kiocb *req) 3080 + static int io_req_defer_prep(struct io_kiocb *req, 3081 + const struct io_uring_sqe *sqe) 3065 3082 { 3066 - struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; 3067 - struct io_async_ctx *io = req->io; 3068 - struct iov_iter iter; 3069 3083 ssize_t ret = 0; 3070 3084 3071 3085 switch (req->opcode) { ··· 3066 3094 break; 3067 3095 case IORING_OP_READV: 3068 3096 case IORING_OP_READ_FIXED: 3069 - /* ensure prep does right import */ 3070 - req->io = NULL; 3071 - ret = io_read_prep(req, &iovec, &iter, true); 3072 - req->io = io; 3073 - if (ret < 0) 3074 - break; 3075 - io_req_map_rw(req, ret, iovec, inline_vecs, &iter); 3076 - ret = 0; 3097 + ret = io_read_prep(req, sqe, true); 3077 3098 break; 3078 3099 case IORING_OP_WRITEV: 3079 3100 case IORING_OP_WRITE_FIXED: 3080 - /* ensure prep does right import */ 3081 - req->io = NULL; 3082 - ret = io_write_prep(req, &iovec, &iter, true); 3083 - req->io = io; 3084 - if (ret < 0) 3085 - break; 3086 - io_req_map_rw(req, ret, iovec, inline_vecs, &iter); 3087 - ret = 0; 3101 + ret = io_write_prep(req, sqe, true); 3088 3102 break; 3089 3103 case IORING_OP_POLL_ADD: 3090 - ret = io_poll_add_prep(req); 3104 + ret = io_poll_add_prep(req, sqe); 3091 3105 break; 3092 3106 case IORING_OP_POLL_REMOVE: 3093 - ret = io_poll_remove_prep(req); 3107 + ret = io_poll_remove_prep(req, sqe); 3094 3108 break; 3095 3109 case IORING_OP_FSYNC: 3096 - ret = io_prep_fsync(req); 3110 + ret = io_prep_fsync(req, sqe); 3097 3111 break; 3098 3112 case IORING_OP_SYNC_FILE_RANGE: 3099 - ret = io_prep_sfr(req); 3113 + ret = io_prep_sfr(req, sqe); 3100 3114 break; 3101 3115 case IORING_OP_SENDMSG: 3102 - ret = io_sendmsg_prep(req, io); 3116 + ret = io_sendmsg_prep(req, sqe); 3103 3117 break; 3104 3118 case IORING_OP_RECVMSG: 3105 - ret = io_recvmsg_prep(req, io); 3119 + ret = io_recvmsg_prep(req, sqe); 3106 3120 break; 3107 3121 case IORING_OP_CONNECT: 3108 - ret = io_connect_prep(req, io); 3122 + ret = io_connect_prep(req, sqe); 3109 3123 break; 3110 3124 case IORING_OP_TIMEOUT: 3111 - ret = io_timeout_prep(req, io, false); 3125 + ret = io_timeout_prep(req, sqe, false); 3112 3126 break; 3113 3127 case IORING_OP_TIMEOUT_REMOVE: 3114 - ret = io_timeout_remove_prep(req); 3128 + ret = io_timeout_remove_prep(req, sqe); 3115 3129 break; 3116 3130 case IORING_OP_ASYNC_CANCEL: 3117 - ret = io_async_cancel_prep(req); 3131 + ret = io_async_cancel_prep(req, sqe); 3118 3132 break; 3119 3133 case IORING_OP_LINK_TIMEOUT: 3120 - ret = io_timeout_prep(req, io, true); 3134 + ret = io_timeout_prep(req, sqe, true); 3121 3135 break; 3122 3136 case IORING_OP_ACCEPT: 3123 - ret = io_accept_prep(req); 3137 + ret = io_accept_prep(req, sqe); 3124 3138 break; 3125 3139 default: 3126 3140 printk_once(KERN_WARNING "io_uring: unhandled opcode %d\n", ··· 3118 3160 return ret; 3119 3161 } 3120 3162 3121 - static int io_req_defer(struct io_kiocb *req) 3163 + static int io_req_defer(struct io_kiocb *req, const struct io_uring_sqe *sqe) 3122 3164 { 3123 3165 struct io_ring_ctx *ctx = req->ctx; 3124 3166 int ret; ··· 3127 3169 if (!req_need_defer(req) && list_empty(&ctx->defer_list)) 3128 3170 return 0; 3129 3171 3130 - if (io_alloc_async_ctx(req)) 3172 + if (!req->io && io_alloc_async_ctx(req)) 3131 3173 return -EAGAIN; 3132 3174 3133 - ret = io_req_defer_prep(req); 3175 + ret = io_req_defer_prep(req, sqe); 3134 3176 if (ret < 0) 3135 3177 return ret; 3136 3178 ··· 3146 3188 return -EIOCBQUEUED; 3147 3189 } 3148 3190 3149 - __attribute__((nonnull)) 3150 - static int io_issue_sqe(struct io_kiocb *req, struct io_kiocb **nxt, 3151 - bool force_nonblock) 3191 + static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, 3192 + struct io_kiocb **nxt, bool force_nonblock) 3152 3193 { 3153 3194 struct io_ring_ctx *ctx = req->ctx; 3154 3195 int ret; ··· 3157 3200 ret = io_nop(req); 3158 3201 break; 3159 3202 case IORING_OP_READV: 3160 - if (unlikely(req->sqe->buf_index)) 3161 - return -EINVAL; 3203 + case IORING_OP_READ_FIXED: 3204 + if (sqe) { 3205 + ret = io_read_prep(req, sqe, force_nonblock); 3206 + if (ret < 0) 3207 + break; 3208 + } 3162 3209 ret = io_read(req, nxt, force_nonblock); 3163 3210 break; 3164 3211 case IORING_OP_WRITEV: 3165 - if (unlikely(req->sqe->buf_index)) 3166 - return -EINVAL; 3167 - ret = io_write(req, nxt, force_nonblock); 3168 - break; 3169 - case IORING_OP_READ_FIXED: 3170 - ret = io_read(req, nxt, force_nonblock); 3171 - break; 3172 3212 case IORING_OP_WRITE_FIXED: 3213 + if (sqe) { 3214 + ret = io_write_prep(req, sqe, force_nonblock); 3215 + if (ret < 0) 3216 + break; 3217 + } 3173 3218 ret = io_write(req, nxt, force_nonblock); 3174 3219 break; 3175 3220 case IORING_OP_FSYNC: 3221 + if (sqe) { 3222 + ret = io_prep_fsync(req, sqe); 3223 + if (ret < 0) 3224 + break; 3225 + } 3176 3226 ret = io_fsync(req, nxt, force_nonblock); 3177 3227 break; 3178 3228 case IORING_OP_POLL_ADD: 3229 + if (sqe) { 3230 + ret = io_poll_add_prep(req, sqe); 3231 + if (ret) 3232 + break; 3233 + } 3179 3234 ret = io_poll_add(req, nxt); 3180 3235 break; 3181 3236 case IORING_OP_POLL_REMOVE: 3237 + if (sqe) { 3238 + ret = io_poll_remove_prep(req, sqe); 3239 + if (ret < 0) 3240 + break; 3241 + } 3182 3242 ret = io_poll_remove(req); 3183 3243 break; 3184 3244 case IORING_OP_SYNC_FILE_RANGE: 3245 + if (sqe) { 3246 + ret = io_prep_sfr(req, sqe); 3247 + if (ret < 0) 3248 + break; 3249 + } 3185 3250 ret = io_sync_file_range(req, nxt, force_nonblock); 3186 3251 break; 3187 3252 case IORING_OP_SENDMSG: 3253 + if (sqe) { 3254 + ret = io_sendmsg_prep(req, sqe); 3255 + if (ret < 0) 3256 + break; 3257 + } 3188 3258 ret = io_sendmsg(req, nxt, force_nonblock); 3189 3259 break; 3190 3260 case IORING_OP_RECVMSG: 3261 + if (sqe) { 3262 + ret = io_recvmsg_prep(req, sqe); 3263 + if (ret) 3264 + break; 3265 + } 3191 3266 ret = io_recvmsg(req, nxt, force_nonblock); 3192 3267 break; 3193 3268 case IORING_OP_TIMEOUT: 3269 + if (sqe) { 3270 + ret = io_timeout_prep(req, sqe, false); 3271 + if (ret) 3272 + break; 3273 + } 3194 3274 ret = io_timeout(req); 3195 3275 break; 3196 3276 case IORING_OP_TIMEOUT_REMOVE: 3277 + if (sqe) { 3278 + ret = io_timeout_remove_prep(req, sqe); 3279 + if (ret) 3280 + break; 3281 + } 3197 3282 ret = io_timeout_remove(req); 3198 3283 break; 3199 3284 case IORING_OP_ACCEPT: 3285 + if (sqe) { 3286 + ret = io_accept_prep(req, sqe); 3287 + if (ret) 3288 + break; 3289 + } 3200 3290 ret = io_accept(req, nxt, force_nonblock); 3201 3291 break; 3202 3292 case IORING_OP_CONNECT: 3293 + if (sqe) { 3294 + ret = io_connect_prep(req, sqe); 3295 + if (ret) 3296 + break; 3297 + } 3203 3298 ret = io_connect(req, nxt, force_nonblock); 3204 3299 break; 3205 3300 case IORING_OP_ASYNC_CANCEL: 3301 + if (sqe) { 3302 + ret = io_async_cancel_prep(req, sqe); 3303 + if (ret) 3304 + break; 3305 + } 3206 3306 ret = io_async_cancel(req, nxt); 3207 3307 break; 3208 3308 default: ··· 3303 3289 req->has_user = (work->flags & IO_WQ_WORK_HAS_MM) != 0; 3304 3290 req->in_async = true; 3305 3291 do { 3306 - ret = io_issue_sqe(req, &nxt, false); 3292 + ret = io_issue_sqe(req, NULL, &nxt, false); 3307 3293 /* 3308 3294 * We can get EAGAIN for polled IO even though we're 3309 3295 * forcing a sync submission from here, since we can't ··· 3369 3355 return table->files[index & IORING_FILE_TABLE_MASK]; 3370 3356 } 3371 3357 3372 - static int io_req_set_file(struct io_submit_state *state, struct io_kiocb *req) 3358 + static int io_req_set_file(struct io_submit_state *state, struct io_kiocb *req, 3359 + const struct io_uring_sqe *sqe) 3373 3360 { 3374 3361 struct io_ring_ctx *ctx = req->ctx; 3375 3362 unsigned flags; 3376 3363 int fd, ret; 3377 3364 3378 - flags = READ_ONCE(req->sqe->flags); 3379 - fd = READ_ONCE(req->sqe->fd); 3365 + flags = READ_ONCE(sqe->flags); 3366 + fd = READ_ONCE(sqe->fd); 3380 3367 3381 3368 if (flags & IOSQE_IO_DRAIN) 3382 3369 req->flags |= REQ_F_IO_DRAIN; ··· 3509 3494 return nxt; 3510 3495 } 3511 3496 3512 - static void __io_queue_sqe(struct io_kiocb *req) 3497 + static void __io_queue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe) 3513 3498 { 3514 3499 struct io_kiocb *linked_timeout; 3515 3500 struct io_kiocb *nxt = NULL; ··· 3518 3503 again: 3519 3504 linked_timeout = io_prep_linked_timeout(req); 3520 3505 3521 - ret = io_issue_sqe(req, &nxt, true); 3506 + ret = io_issue_sqe(req, sqe, &nxt, true); 3522 3507 3523 3508 /* 3524 3509 * We async punt it if the file wasn't marked NOWAIT, or if the file ··· 3565 3550 } 3566 3551 } 3567 3552 3568 - static void io_queue_sqe(struct io_kiocb *req) 3553 + static void io_queue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe) 3569 3554 { 3570 3555 int ret; 3571 3556 ··· 3575 3560 } 3576 3561 req->ctx->drain_next = (req->flags & REQ_F_DRAIN_LINK); 3577 3562 3578 - ret = io_req_defer(req); 3563 + ret = io_req_defer(req, sqe); 3579 3564 if (ret) { 3580 3565 if (ret != -EIOCBQUEUED) { 3581 3566 io_cqring_add_event(req, ret); ··· 3583 3568 io_double_put_req(req); 3584 3569 } 3585 3570 } else 3586 - __io_queue_sqe(req); 3571 + __io_queue_sqe(req, sqe); 3587 3572 } 3588 3573 3589 3574 static inline void io_queue_link_head(struct io_kiocb *req) ··· 3592 3577 io_cqring_add_event(req, -ECANCELED); 3593 3578 io_double_put_req(req); 3594 3579 } else 3595 - io_queue_sqe(req); 3580 + io_queue_sqe(req, NULL); 3596 3581 } 3597 3582 3598 3583 #define SQE_VALID_FLAGS (IOSQE_FIXED_FILE|IOSQE_IO_DRAIN|IOSQE_IO_LINK| \ 3599 3584 IOSQE_IO_HARDLINK) 3600 3585 3601 - static bool io_submit_sqe(struct io_kiocb *req, struct io_submit_state *state, 3602 - struct io_kiocb **link) 3586 + static bool io_submit_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, 3587 + struct io_submit_state *state, struct io_kiocb **link) 3603 3588 { 3604 3589 struct io_ring_ctx *ctx = req->ctx; 3605 3590 int ret; 3606 3591 3607 3592 /* enforce forwards compatibility on users */ 3608 - if (unlikely(req->sqe->flags & ~SQE_VALID_FLAGS)) { 3593 + if (unlikely(sqe->flags & ~SQE_VALID_FLAGS)) { 3609 3594 ret = -EINVAL; 3610 3595 goto err_req; 3611 3596 } 3612 3597 3613 - ret = io_req_set_file(state, req); 3598 + ret = io_req_set_file(state, req, sqe); 3614 3599 if (unlikely(ret)) { 3615 3600 err_req: 3616 3601 io_cqring_add_event(req, ret); ··· 3628 3613 if (*link) { 3629 3614 struct io_kiocb *prev = *link; 3630 3615 3631 - if (req->sqe->flags & IOSQE_IO_DRAIN) 3616 + if (sqe->flags & IOSQE_IO_DRAIN) 3632 3617 (*link)->flags |= REQ_F_DRAIN_LINK | REQ_F_IO_DRAIN; 3633 3618 3634 - if (req->sqe->flags & IOSQE_IO_HARDLINK) 3619 + if (sqe->flags & IOSQE_IO_HARDLINK) 3635 3620 req->flags |= REQ_F_HARDLINK; 3636 3621 3637 3622 if (io_alloc_async_ctx(req)) { ··· 3639 3624 goto err_req; 3640 3625 } 3641 3626 3642 - ret = io_req_defer_prep(req); 3627 + ret = io_req_defer_prep(req, sqe); 3643 3628 if (ret) { 3644 3629 /* fail even hard links since we don't submit */ 3645 3630 prev->flags |= REQ_F_FAIL_LINK; ··· 3647 3632 } 3648 3633 trace_io_uring_link(ctx, req, prev); 3649 3634 list_add_tail(&req->link_list, &prev->link_list); 3650 - } else if (req->sqe->flags & (IOSQE_IO_LINK|IOSQE_IO_HARDLINK)) { 3635 + } else if (sqe->flags & (IOSQE_IO_LINK|IOSQE_IO_HARDLINK)) { 3651 3636 req->flags |= REQ_F_LINK; 3652 - if (req->sqe->flags & IOSQE_IO_HARDLINK) 3637 + if (sqe->flags & IOSQE_IO_HARDLINK) 3653 3638 req->flags |= REQ_F_HARDLINK; 3654 3639 3655 3640 INIT_LIST_HEAD(&req->link_list); 3641 + ret = io_req_defer_prep(req, sqe); 3642 + if (ret) 3643 + req->flags |= REQ_F_FAIL_LINK; 3656 3644 *link = req; 3657 3645 } else { 3658 - io_queue_sqe(req); 3646 + io_queue_sqe(req, sqe); 3659 3647 } 3660 3648 3661 3649 return true; ··· 3703 3685 } 3704 3686 3705 3687 /* 3706 - * Fetch an sqe, if one is available. Note that req->sqe will point to memory 3688 + * Fetch an sqe, if one is available. Note that sqe_ptr will point to memory 3707 3689 * that is mapped by userspace. This means that care needs to be taken to 3708 3690 * ensure that reads are stable, as we cannot rely on userspace always 3709 3691 * being a good citizen. If members of the sqe are validated and then later 3710 3692 * used, it's important that those reads are done through READ_ONCE() to 3711 3693 * prevent a re-load down the line. 3712 3694 */ 3713 - static bool io_get_sqring(struct io_ring_ctx *ctx, struct io_kiocb *req) 3695 + static bool io_get_sqring(struct io_ring_ctx *ctx, struct io_kiocb *req, 3696 + const struct io_uring_sqe **sqe_ptr) 3714 3697 { 3715 3698 struct io_rings *rings = ctx->rings; 3716 3699 u32 *sq_array = ctx->sq_array; ··· 3738 3719 * link list. 3739 3720 */ 3740 3721 req->sequence = ctx->cached_sq_head; 3741 - req->sqe = &ctx->sq_sqes[head]; 3742 - req->opcode = READ_ONCE(req->sqe->opcode); 3743 - req->user_data = READ_ONCE(req->sqe->user_data); 3722 + *sqe_ptr = &ctx->sq_sqes[head]; 3723 + req->opcode = READ_ONCE((*sqe_ptr)->opcode); 3724 + req->user_data = READ_ONCE((*sqe_ptr)->user_data); 3744 3725 ctx->cached_sq_head++; 3745 3726 return true; 3746 3727 } ··· 3772 3753 } 3773 3754 3774 3755 for (i = 0; i < nr; i++) { 3756 + const struct io_uring_sqe *sqe; 3775 3757 struct io_kiocb *req; 3776 3758 unsigned int sqe_flags; 3777 3759 ··· 3782 3762 submitted = -EAGAIN; 3783 3763 break; 3784 3764 } 3785 - if (!io_get_sqring(ctx, req)) { 3765 + if (!io_get_sqring(ctx, req, &sqe)) { 3786 3766 __io_free_req(req); 3787 3767 break; 3788 3768 } ··· 3796 3776 } 3797 3777 3798 3778 submitted++; 3799 - sqe_flags = req->sqe->flags; 3779 + sqe_flags = sqe->flags; 3800 3780 3801 3781 req->ring_file = ring_file; 3802 3782 req->ring_fd = ring_fd; ··· 3804 3784 req->in_async = async; 3805 3785 req->needs_fixed_file = async; 3806 3786 trace_io_uring_submit_sqe(ctx, req->user_data, true, async); 3807 - if (!io_submit_sqe(req, statep, &link)) 3787 + if (!io_submit_sqe(req, sqe, statep, &link)) 3808 3788 break; 3809 3789 /* 3810 3790 * If previous wasn't linked and we have a linked command, ··· 4722 4702 if (copy_from_user(&ciov, &ciovs[index], sizeof(ciov))) 4723 4703 return -EFAULT; 4724 4704 4725 - dst->iov_base = (void __user *) (unsigned long) ciov.iov_base; 4705 + dst->iov_base = u64_to_user_ptr((u64)ciov.iov_base); 4726 4706 dst->iov_len = ciov.iov_len; 4727 4707 return 0; 4728 4708 }
+1 -1
fs/locks.c
··· 2853 2853 } 2854 2854 if (inode) { 2855 2855 /* userspace relies on this representation of dev_t */ 2856 - seq_printf(f, "%d %02x:%02x:%ld ", fl_pid, 2856 + seq_printf(f, "%d %02x:%02x:%lu ", fl_pid, 2857 2857 MAJOR(inode->i_sb->s_dev), 2858 2858 MINOR(inode->i_sb->s_dev), inode->i_ino); 2859 2859 } else {
+4
fs/notify/fsnotify.c
··· 57 57 * doing an __iget/iput with SB_ACTIVE clear would actually 58 58 * evict all inodes with zero i_count from icache which is 59 59 * unnecessarily violent and may in fact be illegal to do. 60 + * However, we should have been called /after/ evict_inodes 61 + * removed all zero refcount inodes, in any case. Test to 62 + * be sure. 60 63 */ 61 64 if (!atomic_read(&inode->i_count)) { 62 65 spin_unlock(&inode->i_lock); ··· 80 77 81 78 iput_inode = inode; 82 79 80 + cond_resched(); 83 81 spin_lock(&sb->s_inode_list_lock); 84 82 } 85 83 spin_unlock(&sb->s_inode_list_lock);
+1
fs/quota/dquot.c
··· 984 984 * later. 985 985 */ 986 986 old_inode = inode; 987 + cond_resched(); 987 988 spin_lock(&sb->s_inode_list_lock); 988 989 } 989 990 spin_unlock(&sb->s_inode_list_lock);
+3 -1
fs/super.c
··· 448 448 sync_filesystem(sb); 449 449 sb->s_flags &= ~SB_ACTIVE; 450 450 451 - fsnotify_sb_delete(sb); 452 451 cgroup_writeback_umount(); 453 452 453 + /* evict all inodes with zero refcount */ 454 454 evict_inodes(sb); 455 + /* only nonzero refcount inodes can have marks */ 456 + fsnotify_sb_delete(sb); 455 457 456 458 if (sb->s_dio_done_wq) { 457 459 destroy_workqueue(sb->s_dio_done_wq);
+2
include/linux/ahci_platform.h
··· 19 19 struct platform_device; 20 20 struct scsi_host_template; 21 21 22 + int ahci_platform_enable_phys(struct ahci_host_priv *hpriv); 23 + void ahci_platform_disable_phys(struct ahci_host_priv *hpriv); 22 24 int ahci_platform_enable_clks(struct ahci_host_priv *hpriv); 23 25 void ahci_platform_disable_clks(struct ahci_host_priv *hpriv); 24 26 int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv);
+1
include/linux/libata.h
··· 1175 1175 struct ata_taskfile *tf, u16 *id); 1176 1176 extern void ata_qc_complete(struct ata_queued_cmd *qc); 1177 1177 extern int ata_qc_complete_multiple(struct ata_port *ap, u64 qc_active); 1178 + extern u64 ata_qc_get_active(struct ata_port *ap); 1178 1179 extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd); 1179 1180 extern int ata_std_bios_param(struct scsi_device *sdev, 1180 1181 struct block_device *bdev,
+1 -1
include/linux/of_mdio.h
··· 55 55 } 56 56 57 57 #else /* CONFIG_OF_MDIO */ 58 - static bool of_mdiobus_child_is_phy(struct device_node *child) 58 + static inline bool of_mdiobus_child_is_phy(struct device_node *child) 59 59 { 60 60 return false; 61 61 }
+11 -8
include/linux/posix-clock.h
··· 69 69 * 70 70 * @ops: Functional interface to the clock 71 71 * @cdev: Character device instance for this clock 72 - * @kref: Reference count. 72 + * @dev: Pointer to the clock's device. 73 73 * @rwsem: Protects the 'zombie' field from concurrent access. 74 74 * @zombie: If 'zombie' is true, then the hardware has disappeared. 75 - * @release: A function to free the structure when the reference count reaches 76 - * zero. May be NULL if structure is statically allocated. 77 75 * 78 76 * Drivers should embed their struct posix_clock within a private 79 77 * structure, obtaining a reference to it during callbacks using 80 78 * container_of(). 79 + * 80 + * Drivers should supply an initialized but not exposed struct device 81 + * to posix_clock_register(). It is used to manage lifetime of the 82 + * driver's private structure. It's 'release' field should be set to 83 + * a release function for this private structure. 81 84 */ 82 85 struct posix_clock { 83 86 struct posix_clock_operations ops; 84 87 struct cdev cdev; 85 - struct kref kref; 88 + struct device *dev; 86 89 struct rw_semaphore rwsem; 87 90 bool zombie; 88 - void (*release)(struct posix_clock *clk); 89 91 }; 90 92 91 93 /** 92 94 * posix_clock_register() - register a new clock 93 - * @clk: Pointer to the clock. Caller must provide 'ops' and 'release' 94 - * @devid: Allocated device id 95 + * @clk: Pointer to the clock. Caller must provide 'ops' field 96 + * @dev: Pointer to the initialized device. Caller must provide 97 + * 'release' field 95 98 * 96 99 * A clock driver calls this function to register itself with the 97 100 * clock device subsystem. If 'clk' points to dynamically allocated ··· 103 100 * 104 101 * Returns zero on success, non-zero otherwise. 105 102 */ 106 - int posix_clock_register(struct posix_clock *clk, dev_t devid); 103 + int posix_clock_register(struct posix_clock *clk, struct device *dev); 107 104 108 105 /** 109 106 * posix_clock_unregister() - unregister a clock
+11 -2
include/net/dst.h
··· 516 516 struct dst_entry *dst = skb_dst(skb); 517 517 518 518 if (dst && dst->ops->update_pmtu) 519 - dst->ops->update_pmtu(dst, NULL, skb, mtu); 519 + dst->ops->update_pmtu(dst, NULL, skb, mtu, true); 520 + } 521 + 522 + /* update dst pmtu but not do neighbor confirm */ 523 + static inline void skb_dst_update_pmtu_no_confirm(struct sk_buff *skb, u32 mtu) 524 + { 525 + struct dst_entry *dst = skb_dst(skb); 526 + 527 + if (dst && dst->ops->update_pmtu) 528 + dst->ops->update_pmtu(dst, NULL, skb, mtu, false); 520 529 } 521 530 522 531 static inline void skb_tunnel_check_pmtu(struct sk_buff *skb, ··· 535 526 u32 encap_mtu = dst_mtu(encap_dst); 536 527 537 528 if (skb->len > encap_mtu - headroom) 538 - skb_dst_update_pmtu(skb, encap_mtu - headroom); 529 + skb_dst_update_pmtu_no_confirm(skb, encap_mtu - headroom); 539 530 } 540 531 541 532 #endif /* _NET_DST_H */
+2 -1
include/net/dst_ops.h
··· 27 27 struct dst_entry * (*negative_advice)(struct dst_entry *); 28 28 void (*link_failure)(struct sk_buff *); 29 29 void (*update_pmtu)(struct dst_entry *dst, struct sock *sk, 30 - struct sk_buff *skb, u32 mtu); 30 + struct sk_buff *skb, u32 mtu, 31 + bool confirm_neigh); 31 32 void (*redirect)(struct dst_entry *dst, struct sock *sk, 32 33 struct sk_buff *skb); 33 34 int (*local_out)(struct net *net, struct sock *sk, struct sk_buff *skb);
+5
include/net/sch_generic.h
··· 308 308 int (*delete)(struct tcf_proto *tp, void *arg, 309 309 bool *last, bool rtnl_held, 310 310 struct netlink_ext_ack *); 311 + bool (*delete_empty)(struct tcf_proto *tp); 311 312 void (*walk)(struct tcf_proto *tp, 312 313 struct tcf_walker *arg, bool rtnl_held); 313 314 int (*reoffload)(struct tcf_proto *tp, bool add, ··· 337 336 int flags; 338 337 }; 339 338 339 + /* Classifiers setting TCF_PROTO_OPS_DOIT_UNLOCKED in tcf_proto_ops->flags 340 + * are expected to implement tcf_proto_ops->delete_empty(), otherwise race 341 + * conditions can occur when filters are inserted/deleted simultaneously. 342 + */ 340 343 enum tcf_proto_ops_flags { 341 344 TCF_PROTO_OPS_DOIT_UNLOCKED = 1, 342 345 };
+22 -21
kernel/bpf/verifier.c
··· 907 907 BPF_REG_0, BPF_REG_1, BPF_REG_2, BPF_REG_3, BPF_REG_4, BPF_REG_5 908 908 }; 909 909 910 - static void __mark_reg_not_init(struct bpf_reg_state *reg); 910 + static void __mark_reg_not_init(const struct bpf_verifier_env *env, 911 + struct bpf_reg_state *reg); 911 912 912 913 /* Mark the unknown part of a register (variable offset or scalar value) as 913 914 * known to have the value @imm. ··· 946 945 verbose(env, "mark_reg_known_zero(regs, %u)\n", regno); 947 946 /* Something bad happened, let's kill all regs */ 948 947 for (regno = 0; regno < MAX_BPF_REG; regno++) 949 - __mark_reg_not_init(regs + regno); 948 + __mark_reg_not_init(env, regs + regno); 950 949 return; 951 950 } 952 951 __mark_reg_known_zero(regs + regno); ··· 1055 1054 } 1056 1055 1057 1056 /* Mark a register as having a completely unknown (scalar) value. */ 1058 - static void __mark_reg_unknown(struct bpf_reg_state *reg) 1057 + static void __mark_reg_unknown(const struct bpf_verifier_env *env, 1058 + struct bpf_reg_state *reg) 1059 1059 { 1060 1060 /* 1061 1061 * Clear type, id, off, and union(map_ptr, range) and ··· 1066 1064 reg->type = SCALAR_VALUE; 1067 1065 reg->var_off = tnum_unknown; 1068 1066 reg->frameno = 0; 1067 + reg->precise = env->subprog_cnt > 1 || !env->allow_ptr_leaks ? 1068 + true : false; 1069 1069 __mark_reg_unbounded(reg); 1070 1070 } 1071 1071 ··· 1078 1074 verbose(env, "mark_reg_unknown(regs, %u)\n", regno); 1079 1075 /* Something bad happened, let's kill all regs except FP */ 1080 1076 for (regno = 0; regno < BPF_REG_FP; regno++) 1081 - __mark_reg_not_init(regs + regno); 1077 + __mark_reg_not_init(env, regs + regno); 1082 1078 return; 1083 1079 } 1084 - regs += regno; 1085 - __mark_reg_unknown(regs); 1086 - /* constant backtracking is enabled for root without bpf2bpf calls */ 1087 - regs->precise = env->subprog_cnt > 1 || !env->allow_ptr_leaks ? 1088 - true : false; 1080 + __mark_reg_unknown(env, regs + regno); 1089 1081 } 1090 1082 1091 - static void __mark_reg_not_init(struct bpf_reg_state *reg) 1083 + static void __mark_reg_not_init(const struct bpf_verifier_env *env, 1084 + struct bpf_reg_state *reg) 1092 1085 { 1093 - __mark_reg_unknown(reg); 1086 + __mark_reg_unknown(env, reg); 1094 1087 reg->type = NOT_INIT; 1095 1088 } 1096 1089 ··· 1098 1097 verbose(env, "mark_reg_not_init(regs, %u)\n", regno); 1099 1098 /* Something bad happened, let's kill all regs except FP */ 1100 1099 for (regno = 0; regno < BPF_REG_FP; regno++) 1101 - __mark_reg_not_init(regs + regno); 1100 + __mark_reg_not_init(env, regs + regno); 1102 1101 return; 1103 1102 } 1104 - __mark_reg_not_init(regs + regno); 1103 + __mark_reg_not_init(env, regs + regno); 1105 1104 } 1106 1105 1107 1106 #define DEF_NOT_SUBREG (0) ··· 3235 3234 } 3236 3235 if (state->stack[spi].slot_type[0] == STACK_SPILL && 3237 3236 state->stack[spi].spilled_ptr.type == SCALAR_VALUE) { 3238 - __mark_reg_unknown(&state->stack[spi].spilled_ptr); 3237 + __mark_reg_unknown(env, &state->stack[spi].spilled_ptr); 3239 3238 for (j = 0; j < BPF_REG_SIZE; j++) 3240 3239 state->stack[spi].slot_type[j] = STACK_MISC; 3241 3240 goto mark; ··· 3893 3892 if (!reg) 3894 3893 continue; 3895 3894 if (reg_is_pkt_pointer_any(reg)) 3896 - __mark_reg_unknown(reg); 3895 + __mark_reg_unknown(env, reg); 3897 3896 } 3898 3897 } 3899 3898 ··· 3921 3920 if (!reg) 3922 3921 continue; 3923 3922 if (reg->ref_obj_id == ref_obj_id) 3924 - __mark_reg_unknown(reg); 3923 + __mark_reg_unknown(env, reg); 3925 3924 } 3926 3925 } 3927 3926 ··· 4583 4582 /* Taint dst register if offset had invalid bounds derived from 4584 4583 * e.g. dead branches. 4585 4584 */ 4586 - __mark_reg_unknown(dst_reg); 4585 + __mark_reg_unknown(env, dst_reg); 4587 4586 return 0; 4588 4587 } 4589 4588 ··· 4835 4834 /* Taint dst register if offset had invalid bounds derived from 4836 4835 * e.g. dead branches. 4837 4836 */ 4838 - __mark_reg_unknown(dst_reg); 4837 + __mark_reg_unknown(env, dst_reg); 4839 4838 return 0; 4840 4839 } 4841 4840 4842 4841 if (!src_known && 4843 4842 opcode != BPF_ADD && opcode != BPF_SUB && opcode != BPF_AND) { 4844 - __mark_reg_unknown(dst_reg); 4843 + __mark_reg_unknown(env, dst_reg); 4845 4844 return 0; 4846 4845 } 4847 4846 ··· 6983 6982 /* since the register is unused, clear its state 6984 6983 * to make further comparison simpler 6985 6984 */ 6986 - __mark_reg_not_init(&st->regs[i]); 6985 + __mark_reg_not_init(env, &st->regs[i]); 6987 6986 } 6988 6987 6989 6988 for (i = 0; i < st->allocated_stack / BPF_REG_SIZE; i++) { ··· 6991 6990 /* liveness must not touch this stack slot anymore */ 6992 6991 st->stack[i].spilled_ptr.live |= REG_LIVE_DONE; 6993 6992 if (!(live & REG_LIVE_READ)) { 6994 - __mark_reg_not_init(&st->stack[i].spilled_ptr); 6993 + __mark_reg_not_init(env, &st->stack[i].spilled_ptr); 6995 6994 for (j = 0; j < BPF_REG_SIZE; j++) 6996 6995 st->stack[i].slot_type[j] = STACK_INVALID; 6997 6996 }
+13 -18
kernel/time/posix-clock.c
··· 14 14 15 15 #include "posix-timers.h" 16 16 17 - static void delete_clock(struct kref *kref); 18 - 19 17 /* 20 18 * Returns NULL if the posix_clock instance attached to 'fp' is old and stale. 21 19 */ ··· 123 125 err = 0; 124 126 125 127 if (!err) { 126 - kref_get(&clk->kref); 128 + get_device(clk->dev); 127 129 fp->private_data = clk; 128 130 } 129 131 out: ··· 139 141 if (clk->ops.release) 140 142 err = clk->ops.release(clk); 141 143 142 - kref_put(&clk->kref, delete_clock); 144 + put_device(clk->dev); 143 145 144 146 fp->private_data = NULL; 145 147 ··· 159 161 #endif 160 162 }; 161 163 162 - int posix_clock_register(struct posix_clock *clk, dev_t devid) 164 + int posix_clock_register(struct posix_clock *clk, struct device *dev) 163 165 { 164 166 int err; 165 167 166 - kref_init(&clk->kref); 167 168 init_rwsem(&clk->rwsem); 168 169 169 170 cdev_init(&clk->cdev, &posix_clock_file_operations); 171 + err = cdev_device_add(&clk->cdev, dev); 172 + if (err) { 173 + pr_err("%s unable to add device %d:%d\n", 174 + dev_name(dev), MAJOR(dev->devt), MINOR(dev->devt)); 175 + return err; 176 + } 170 177 clk->cdev.owner = clk->ops.owner; 171 - err = cdev_add(&clk->cdev, devid, 1); 178 + clk->dev = dev; 172 179 173 - return err; 180 + return 0; 174 181 } 175 182 EXPORT_SYMBOL_GPL(posix_clock_register); 176 183 177 - static void delete_clock(struct kref *kref) 178 - { 179 - struct posix_clock *clk = container_of(kref, struct posix_clock, kref); 180 - 181 - if (clk->release) 182 - clk->release(clk); 183 - } 184 - 185 184 void posix_clock_unregister(struct posix_clock *clk) 186 185 { 187 - cdev_del(&clk->cdev); 186 + cdev_device_del(&clk->cdev, clk->dev); 188 187 189 188 down_write(&clk->rwsem); 190 189 clk->zombie = true; 191 190 up_write(&clk->rwsem); 192 191 193 - kref_put(&clk->kref, delete_clock); 192 + put_device(clk->dev); 194 193 } 195 194 EXPORT_SYMBOL_GPL(posix_clock_unregister); 196 195
+2 -1
lib/iov_iter.c
··· 1222 1222 1223 1223 unsigned long iov_iter_alignment(const struct iov_iter *i) 1224 1224 { 1225 - unsigned int p_mask = i->pipe->ring_size - 1; 1226 1225 unsigned long res = 0; 1227 1226 size_t size = i->count; 1228 1227 1229 1228 if (unlikely(iov_iter_is_pipe(i))) { 1229 + unsigned int p_mask = i->pipe->ring_size - 1; 1230 + 1230 1231 if (size && i->iov_offset && allocated(&i->pipe->bufs[i->head & p_mask])) 1231 1232 return size | i->iov_offset; 1232 1233 return size;
+2 -1
net/bridge/br_nf_core.c
··· 22 22 #endif 23 23 24 24 static void fake_update_pmtu(struct dst_entry *dst, struct sock *sk, 25 - struct sk_buff *skb, u32 mtu) 25 + struct sk_buff *skb, u32 mtu, 26 + bool confirm_neigh) 26 27 { 27 28 } 28 29
+17 -18
net/bridge/netfilter/ebtables.c
··· 1867 1867 } 1868 1868 1869 1869 static int ebt_buf_add(struct ebt_entries_buf_state *state, 1870 - void *data, unsigned int sz) 1870 + const void *data, unsigned int sz) 1871 1871 { 1872 1872 if (state->buf_kern_start == NULL) 1873 1873 goto count_only; ··· 1901 1901 EBT_COMPAT_TARGET, 1902 1902 }; 1903 1903 1904 - static int compat_mtw_from_user(struct compat_ebt_entry_mwt *mwt, 1904 + static int compat_mtw_from_user(const struct compat_ebt_entry_mwt *mwt, 1905 1905 enum compat_mwt compat_mwt, 1906 1906 struct ebt_entries_buf_state *state, 1907 1907 const unsigned char *base) ··· 1979 1979 /* return size of all matches, watchers or target, including necessary 1980 1980 * alignment and padding. 1981 1981 */ 1982 - static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32, 1982 + static int ebt_size_mwt(const struct compat_ebt_entry_mwt *match32, 1983 1983 unsigned int size_left, enum compat_mwt type, 1984 1984 struct ebt_entries_buf_state *state, const void *base) 1985 1985 { 1986 + const char *buf = (const char *)match32; 1986 1987 int growth = 0; 1987 - char *buf; 1988 1988 1989 1989 if (size_left == 0) 1990 1990 return 0; 1991 1991 1992 - buf = (char *) match32; 1993 - 1994 - while (size_left >= sizeof(*match32)) { 1992 + do { 1995 1993 struct ebt_entry_match *match_kern; 1996 1994 int ret; 1995 + 1996 + if (size_left < sizeof(*match32)) 1997 + return -EINVAL; 1997 1998 1998 1999 match_kern = (struct ebt_entry_match *) state->buf_kern_start; 1999 2000 if (match_kern) { ··· 2032 2031 if (match_kern) 2033 2032 match_kern->match_size = ret; 2034 2033 2035 - /* rule should have no remaining data after target */ 2036 - if (type == EBT_COMPAT_TARGET && size_left) 2037 - return -EINVAL; 2038 - 2039 2034 match32 = (struct compat_ebt_entry_mwt *) buf; 2040 - } 2035 + } while (size_left); 2041 2036 2042 2037 return growth; 2043 2038 } 2044 2039 2045 2040 /* called for all ebt_entry structures. */ 2046 - static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base, 2041 + static int size_entry_mwt(const struct ebt_entry *entry, const unsigned char *base, 2047 2042 unsigned int *total, 2048 2043 struct ebt_entries_buf_state *state) 2049 2044 { 2050 - unsigned int i, j, startoff, new_offset = 0; 2045 + unsigned int i, j, startoff, next_expected_off, new_offset = 0; 2051 2046 /* stores match/watchers/targets & offset of next struct ebt_entry: */ 2052 2047 unsigned int offsets[4]; 2053 2048 unsigned int *offsets_update = NULL; ··· 2129 2132 return ret; 2130 2133 } 2131 2134 2132 - startoff = state->buf_user_offset - startoff; 2133 - 2134 - if (WARN_ON(*total < startoff)) 2135 + next_expected_off = state->buf_user_offset - startoff; 2136 + if (next_expected_off != entry->next_offset) 2135 2137 return -EINVAL; 2136 - *total -= startoff; 2138 + 2139 + if (*total < entry->next_offset) 2140 + return -EINVAL; 2141 + *total -= entry->next_offset; 2137 2142 return 0; 2138 2143 } 2139 2144
+4 -2
net/decnet/dn_route.c
··· 110 110 static struct dst_entry *dn_dst_negative_advice(struct dst_entry *); 111 111 static void dn_dst_link_failure(struct sk_buff *); 112 112 static void dn_dst_update_pmtu(struct dst_entry *dst, struct sock *sk, 113 - struct sk_buff *skb , u32 mtu); 113 + struct sk_buff *skb , u32 mtu, 114 + bool confirm_neigh); 114 115 static void dn_dst_redirect(struct dst_entry *dst, struct sock *sk, 115 116 struct sk_buff *skb); 116 117 static struct neighbour *dn_dst_neigh_lookup(const struct dst_entry *dst, ··· 252 251 * advertise to the other end). 253 252 */ 254 253 static void dn_dst_update_pmtu(struct dst_entry *dst, struct sock *sk, 255 - struct sk_buff *skb, u32 mtu) 254 + struct sk_buff *skb, u32 mtu, 255 + bool confirm_neigh) 256 256 { 257 257 struct dn_route *rt = (struct dn_route *) dst; 258 258 struct neighbour *n = rt->n;
+40 -12
net/hsr/hsr_debugfs.c
··· 20 20 #include "hsr_main.h" 21 21 #include "hsr_framereg.h" 22 22 23 + static struct dentry *hsr_debugfs_root_dir; 24 + 23 25 static void print_mac_address(struct seq_file *sfp, unsigned char *mac) 24 26 { 25 27 seq_printf(sfp, "%02x:%02x:%02x:%02x:%02x:%02x:", ··· 65 63 return single_open(filp, hsr_node_table_show, inode->i_private); 66 64 } 67 65 66 + void hsr_debugfs_rename(struct net_device *dev) 67 + { 68 + struct hsr_priv *priv = netdev_priv(dev); 69 + struct dentry *d; 70 + 71 + d = debugfs_rename(hsr_debugfs_root_dir, priv->node_tbl_root, 72 + hsr_debugfs_root_dir, dev->name); 73 + if (IS_ERR(d)) 74 + netdev_warn(dev, "failed to rename\n"); 75 + else 76 + priv->node_tbl_root = d; 77 + } 78 + 68 79 static const struct file_operations hsr_fops = { 69 - .owner = THIS_MODULE, 70 80 .open = hsr_node_table_open, 71 81 .read = seq_read, 72 82 .llseek = seq_lseek, ··· 92 78 * When debugfs is configured this routine sets up the node_table file per 93 79 * hsr device for dumping the node_table entries 94 80 */ 95 - int hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev) 81 + void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev) 96 82 { 97 - int rc = -1; 98 83 struct dentry *de = NULL; 99 84 100 - de = debugfs_create_dir(hsr_dev->name, NULL); 101 - if (!de) { 102 - pr_err("Cannot create hsr debugfs root\n"); 103 - return rc; 85 + de = debugfs_create_dir(hsr_dev->name, hsr_debugfs_root_dir); 86 + if (IS_ERR(de)) { 87 + pr_err("Cannot create hsr debugfs directory\n"); 88 + return; 104 89 } 105 90 106 91 priv->node_tbl_root = de; ··· 107 94 de = debugfs_create_file("node_table", S_IFREG | 0444, 108 95 priv->node_tbl_root, priv, 109 96 &hsr_fops); 110 - if (!de) { 111 - pr_err("Cannot create hsr node_table directory\n"); 112 - return rc; 97 + if (IS_ERR(de)) { 98 + pr_err("Cannot create hsr node_table file\n"); 99 + debugfs_remove(priv->node_tbl_root); 100 + priv->node_tbl_root = NULL; 101 + return; 113 102 } 114 103 priv->node_tbl_file = de; 115 - 116 - return 0; 117 104 } 118 105 119 106 /* hsr_debugfs_term - Tear down debugfs intrastructure ··· 129 116 priv->node_tbl_file = NULL; 130 117 debugfs_remove(priv->node_tbl_root); 131 118 priv->node_tbl_root = NULL; 119 + } 120 + 121 + void hsr_debugfs_create_root(void) 122 + { 123 + hsr_debugfs_root_dir = debugfs_create_dir("hsr", NULL); 124 + if (IS_ERR(hsr_debugfs_root_dir)) { 125 + pr_err("Cannot create hsr debugfs root directory\n"); 126 + hsr_debugfs_root_dir = NULL; 127 + } 128 + } 129 + 130 + void hsr_debugfs_remove_root(void) 131 + { 132 + /* debugfs_remove() internally checks NULL and ERROR */ 133 + debugfs_remove(hsr_debugfs_root_dir); 132 134 }
+16 -12
net/hsr/hsr_device.c
··· 272 272 skb->dev->dev_addr, skb->len) <= 0) 273 273 goto out; 274 274 skb_reset_mac_header(skb); 275 + skb_reset_network_header(skb); 276 + skb_reset_transport_header(skb); 275 277 276 278 if (hsr_ver > 0) { 277 279 hsr_tag = skb_put(skb, sizeof(struct hsr_tag)); ··· 370 368 del_timer_sync(&hsr->prune_timer); 371 369 del_timer_sync(&hsr->announce_timer); 372 370 373 - hsr_del_self_node(&hsr->self_node_db); 371 + hsr_del_self_node(hsr); 374 372 hsr_del_nodes(&hsr->node_db); 375 373 } 376 374 ··· 442 440 INIT_LIST_HEAD(&hsr->ports); 443 441 INIT_LIST_HEAD(&hsr->node_db); 444 442 INIT_LIST_HEAD(&hsr->self_node_db); 443 + spin_lock_init(&hsr->list_lock); 445 444 446 445 ether_addr_copy(hsr_dev->dev_addr, slave[0]->dev_addr); 447 446 448 447 /* Make sure we recognize frames from ourselves in hsr_rcv() */ 449 - res = hsr_create_self_node(&hsr->self_node_db, hsr_dev->dev_addr, 448 + res = hsr_create_self_node(hsr, hsr_dev->dev_addr, 450 449 slave[1]->dev_addr); 451 450 if (res < 0) 452 451 return res; ··· 480 477 481 478 res = hsr_add_port(hsr, hsr_dev, HSR_PT_MASTER); 482 479 if (res) 483 - goto err_add_port; 480 + goto err_add_master; 484 481 485 482 res = register_netdevice(hsr_dev); 486 483 if (res) 487 - goto fail; 484 + goto err_unregister; 488 485 489 486 res = hsr_add_port(hsr, slave[0], HSR_PT_SLAVE_A); 490 487 if (res) 491 - goto fail; 488 + goto err_add_slaves; 489 + 492 490 res = hsr_add_port(hsr, slave[1], HSR_PT_SLAVE_B); 493 491 if (res) 494 - goto fail; 492 + goto err_add_slaves; 495 493 494 + hsr_debugfs_init(hsr, hsr_dev); 496 495 mod_timer(&hsr->prune_timer, jiffies + msecs_to_jiffies(PRUNE_PERIOD)); 497 - res = hsr_debugfs_init(hsr, hsr_dev); 498 - if (res) 499 - goto fail; 500 496 501 497 return 0; 502 498 503 - fail: 499 + err_add_slaves: 500 + unregister_netdevice(hsr_dev); 501 + err_unregister: 504 502 list_for_each_entry_safe(port, tmp, &hsr->ports, port_list) 505 503 hsr_del_port(port); 506 - err_add_port: 507 - hsr_del_self_node(&hsr->self_node_db); 504 + err_add_master: 505 + hsr_del_self_node(hsr); 508 506 509 507 return res; 510 508 }
+46 -27
net/hsr/hsr_framereg.c
··· 75 75 /* Helper for device init; the self_node_db is used in hsr_rcv() to recognize 76 76 * frames from self that's been looped over the HSR ring. 77 77 */ 78 - int hsr_create_self_node(struct list_head *self_node_db, 78 + int hsr_create_self_node(struct hsr_priv *hsr, 79 79 unsigned char addr_a[ETH_ALEN], 80 80 unsigned char addr_b[ETH_ALEN]) 81 81 { 82 + struct list_head *self_node_db = &hsr->self_node_db; 82 83 struct hsr_node *node, *oldnode; 83 84 84 85 node = kmalloc(sizeof(*node), GFP_KERNEL); ··· 89 88 ether_addr_copy(node->macaddress_A, addr_a); 90 89 ether_addr_copy(node->macaddress_B, addr_b); 91 90 92 - rcu_read_lock(); 91 + spin_lock_bh(&hsr->list_lock); 93 92 oldnode = list_first_or_null_rcu(self_node_db, 94 93 struct hsr_node, mac_list); 95 94 if (oldnode) { 96 95 list_replace_rcu(&oldnode->mac_list, &node->mac_list); 97 - rcu_read_unlock(); 98 - synchronize_rcu(); 99 - kfree(oldnode); 96 + spin_unlock_bh(&hsr->list_lock); 97 + kfree_rcu(oldnode, rcu_head); 100 98 } else { 101 - rcu_read_unlock(); 102 99 list_add_tail_rcu(&node->mac_list, self_node_db); 100 + spin_unlock_bh(&hsr->list_lock); 103 101 } 104 102 105 103 return 0; 106 104 } 107 105 108 - void hsr_del_self_node(struct list_head *self_node_db) 106 + void hsr_del_self_node(struct hsr_priv *hsr) 109 107 { 108 + struct list_head *self_node_db = &hsr->self_node_db; 110 109 struct hsr_node *node; 111 110 112 - rcu_read_lock(); 111 + spin_lock_bh(&hsr->list_lock); 113 112 node = list_first_or_null_rcu(self_node_db, struct hsr_node, mac_list); 114 - rcu_read_unlock(); 115 113 if (node) { 116 114 list_del_rcu(&node->mac_list); 117 - kfree(node); 115 + kfree_rcu(node, rcu_head); 118 116 } 117 + spin_unlock_bh(&hsr->list_lock); 119 118 } 120 119 121 120 void hsr_del_nodes(struct list_head *node_db) ··· 131 130 * seq_out is used to initialize filtering of outgoing duplicate frames 132 131 * originating from the newly added node. 133 132 */ 134 - struct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[], 135 - u16 seq_out) 133 + static struct hsr_node *hsr_add_node(struct hsr_priv *hsr, 134 + struct list_head *node_db, 135 + unsigned char addr[], 136 + u16 seq_out) 136 137 { 137 - struct hsr_node *node; 138 + struct hsr_node *new_node, *node; 138 139 unsigned long now; 139 140 int i; 140 141 141 - node = kzalloc(sizeof(*node), GFP_ATOMIC); 142 - if (!node) 142 + new_node = kzalloc(sizeof(*new_node), GFP_ATOMIC); 143 + if (!new_node) 143 144 return NULL; 144 145 145 - ether_addr_copy(node->macaddress_A, addr); 146 + ether_addr_copy(new_node->macaddress_A, addr); 146 147 147 148 /* We are only interested in time diffs here, so use current jiffies 148 149 * as initialization. (0 could trigger an spurious ring error warning). 149 150 */ 150 151 now = jiffies; 151 152 for (i = 0; i < HSR_PT_PORTS; i++) 152 - node->time_in[i] = now; 153 + new_node->time_in[i] = now; 153 154 for (i = 0; i < HSR_PT_PORTS; i++) 154 - node->seq_out[i] = seq_out; 155 + new_node->seq_out[i] = seq_out; 155 156 156 - list_add_tail_rcu(&node->mac_list, node_db); 157 - 157 + spin_lock_bh(&hsr->list_lock); 158 + list_for_each_entry_rcu(node, node_db, mac_list) { 159 + if (ether_addr_equal(node->macaddress_A, addr)) 160 + goto out; 161 + if (ether_addr_equal(node->macaddress_B, addr)) 162 + goto out; 163 + } 164 + list_add_tail_rcu(&new_node->mac_list, node_db); 165 + spin_unlock_bh(&hsr->list_lock); 166 + return new_node; 167 + out: 168 + spin_unlock_bh(&hsr->list_lock); 169 + kfree(new_node); 158 170 return node; 159 171 } 160 172 ··· 177 163 bool is_sup) 178 164 { 179 165 struct list_head *node_db = &port->hsr->node_db; 166 + struct hsr_priv *hsr = port->hsr; 180 167 struct hsr_node *node; 181 168 struct ethhdr *ethhdr; 182 169 u16 seq_out; ··· 211 196 seq_out = HSR_SEQNR_START; 212 197 } 213 198 214 - return hsr_add_node(node_db, ethhdr->h_source, seq_out); 199 + return hsr_add_node(hsr, node_db, ethhdr->h_source, seq_out); 215 200 } 216 201 217 202 /* Use the Supervision frame's info about an eventual macaddress_B for merging ··· 221 206 void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr, 222 207 struct hsr_port *port_rcv) 223 208 { 224 - struct ethhdr *ethhdr; 225 - struct hsr_node *node_real; 209 + struct hsr_priv *hsr = port_rcv->hsr; 226 210 struct hsr_sup_payload *hsr_sp; 211 + struct hsr_node *node_real; 227 212 struct list_head *node_db; 213 + struct ethhdr *ethhdr; 228 214 int i; 229 215 230 216 ethhdr = (struct ethhdr *)skb_mac_header(skb); ··· 247 231 node_real = find_node_by_addr_A(node_db, hsr_sp->macaddress_A); 248 232 if (!node_real) 249 233 /* No frame received from AddrA of this node yet */ 250 - node_real = hsr_add_node(node_db, hsr_sp->macaddress_A, 234 + node_real = hsr_add_node(hsr, node_db, hsr_sp->macaddress_A, 251 235 HSR_SEQNR_START - 1); 252 236 if (!node_real) 253 237 goto done; /* No mem */ ··· 268 252 } 269 253 node_real->addr_B_port = port_rcv->type; 270 254 255 + spin_lock_bh(&hsr->list_lock); 271 256 list_del_rcu(&node_curr->mac_list); 257 + spin_unlock_bh(&hsr->list_lock); 272 258 kfree_rcu(node_curr, rcu_head); 273 259 274 260 done: ··· 386 368 { 387 369 struct hsr_priv *hsr = from_timer(hsr, t, prune_timer); 388 370 struct hsr_node *node; 371 + struct hsr_node *tmp; 389 372 struct hsr_port *port; 390 373 unsigned long timestamp; 391 374 unsigned long time_a, time_b; 392 375 393 - rcu_read_lock(); 394 - list_for_each_entry_rcu(node, &hsr->node_db, mac_list) { 376 + spin_lock_bh(&hsr->list_lock); 377 + list_for_each_entry_safe(node, tmp, &hsr->node_db, mac_list) { 395 378 /* Don't prune own node. Neither time_in[HSR_PT_SLAVE_A] 396 379 * nor time_in[HSR_PT_SLAVE_B], will ever be updated for 397 380 * the master port. Thus the master node will be repeatedly ··· 440 421 kfree_rcu(node, rcu_head); 441 422 } 442 423 } 443 - rcu_read_unlock(); 424 + spin_unlock_bh(&hsr->list_lock); 444 425 445 426 /* Restart timer */ 446 427 mod_timer(&hsr->prune_timer,
+2 -4
net/hsr/hsr_framereg.h
··· 12 12 13 13 struct hsr_node; 14 14 15 - void hsr_del_self_node(struct list_head *self_node_db); 15 + void hsr_del_self_node(struct hsr_priv *hsr); 16 16 void hsr_del_nodes(struct list_head *node_db); 17 - struct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[], 18 - u16 seq_out); 19 17 struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb, 20 18 bool is_sup); 21 19 void hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr, ··· 31 33 32 34 void hsr_prune_nodes(struct timer_list *t); 33 35 34 - int hsr_create_self_node(struct list_head *self_node_db, 36 + int hsr_create_self_node(struct hsr_priv *hsr, 35 37 unsigned char addr_a[ETH_ALEN], 36 38 unsigned char addr_b[ETH_ALEN]); 37 39
+6 -1
net/hsr/hsr_main.c
··· 45 45 case NETDEV_CHANGE: /* Link (carrier) state changes */ 46 46 hsr_check_carrier_and_operstate(hsr); 47 47 break; 48 + case NETDEV_CHANGENAME: 49 + if (is_hsr_master(dev)) 50 + hsr_debugfs_rename(dev); 51 + break; 48 52 case NETDEV_CHANGEADDR: 49 53 if (port->type == HSR_PT_MASTER) { 50 54 /* This should not happen since there's no ··· 68 64 69 65 /* Make sure we recognize frames from ourselves in hsr_rcv() */ 70 66 port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B); 71 - res = hsr_create_self_node(&hsr->self_node_db, 67 + res = hsr_create_self_node(hsr, 72 68 master->dev->dev_addr, 73 69 port ? 74 70 port->dev->dev_addr : ··· 127 123 { 128 124 unregister_netdevice_notifier(&hsr_nb); 129 125 hsr_netlink_exit(); 126 + hsr_debugfs_remove_root(); 130 127 } 131 128 132 129 module_init(hsr_init);
+15 -7
net/hsr/hsr_main.h
··· 160 160 int announce_count; 161 161 u16 sequence_nr; 162 162 u16 sup_sequence_nr; /* For HSRv1 separate seq_nr for supervision */ 163 - u8 prot_version; /* Indicate if HSRv0 or HSRv1. */ 164 - spinlock_t seqnr_lock; /* locking for sequence_nr */ 163 + u8 prot_version; /* Indicate if HSRv0 or HSRv1. */ 164 + spinlock_t seqnr_lock; /* locking for sequence_nr */ 165 + spinlock_t list_lock; /* locking for node list */ 165 166 unsigned char sup_multicast_addr[ETH_ALEN]; 166 167 #ifdef CONFIG_DEBUG_FS 167 168 struct dentry *node_tbl_root; ··· 185 184 } 186 185 187 186 #if IS_ENABLED(CONFIG_DEBUG_FS) 188 - int hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev); 187 + void hsr_debugfs_rename(struct net_device *dev); 188 + void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev); 189 189 void hsr_debugfs_term(struct hsr_priv *priv); 190 + void hsr_debugfs_create_root(void); 191 + void hsr_debugfs_remove_root(void); 190 192 #else 191 - static inline int hsr_debugfs_init(struct hsr_priv *priv, 192 - struct net_device *hsr_dev) 193 + static inline void void hsr_debugfs_rename(struct net_device *dev) 193 194 { 194 - return 0; 195 195 } 196 - 196 + static inline void hsr_debugfs_init(struct hsr_priv *priv, 197 + struct net_device *hsr_dev) 198 + {} 197 199 static inline void hsr_debugfs_term(struct hsr_priv *priv) 200 + {} 201 + static inline void hsr_debugfs_create_root(void) 202 + {} 203 + static inline void hsr_debugfs_remove_root(void) 198 204 {} 199 205 #endif 200 206
+1
net/hsr/hsr_netlink.c
··· 476 476 if (rc) 477 477 goto fail_genl_register_family; 478 478 479 + hsr_debugfs_create_root(); 479 480 return 0; 480 481 481 482 fail_genl_register_family:
+1 -1
net/ipv4/inet_connection_sock.c
··· 1086 1086 if (!dst) 1087 1087 goto out; 1088 1088 } 1089 - dst->ops->update_pmtu(dst, sk, NULL, mtu); 1089 + dst->ops->update_pmtu(dst, sk, NULL, mtu, true); 1090 1090 1091 1091 dst = __sk_dst_check(sk, 0); 1092 1092 if (!dst)
+1 -1
net/ipv4/ip_tunnel.c
··· 505 505 mtu = skb_valid_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu; 506 506 507 507 if (skb_valid_dst(skb)) 508 - skb_dst_update_pmtu(skb, mtu); 508 + skb_dst_update_pmtu_no_confirm(skb, mtu); 509 509 510 510 if (skb->protocol == htons(ETH_P_IP)) { 511 511 if (!skb_is_gso(skb) &&
+1 -1
net/ipv4/ip_vti.c
··· 214 214 215 215 mtu = dst_mtu(dst); 216 216 if (skb->len > mtu) { 217 - skb_dst_update_pmtu(skb, mtu); 217 + skb_dst_update_pmtu_no_confirm(skb, mtu); 218 218 if (skb->protocol == htons(ETH_P_IP)) { 219 219 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, 220 220 htonl(mtu));
+6 -3
net/ipv4/route.c
··· 139 139 static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst); 140 140 static void ipv4_link_failure(struct sk_buff *skb); 141 141 static void ip_rt_update_pmtu(struct dst_entry *dst, struct sock *sk, 142 - struct sk_buff *skb, u32 mtu); 142 + struct sk_buff *skb, u32 mtu, 143 + bool confirm_neigh); 143 144 static void ip_do_redirect(struct dst_entry *dst, struct sock *sk, 144 145 struct sk_buff *skb); 145 146 static void ipv4_dst_destroy(struct dst_entry *dst); ··· 1044 1043 } 1045 1044 1046 1045 static void ip_rt_update_pmtu(struct dst_entry *dst, struct sock *sk, 1047 - struct sk_buff *skb, u32 mtu) 1046 + struct sk_buff *skb, u32 mtu, 1047 + bool confirm_neigh) 1048 1048 { 1049 1049 struct rtable *rt = (struct rtable *) dst; 1050 1050 struct flowi4 fl4; ··· 2689 2687 } 2690 2688 2691 2689 static void ipv4_rt_blackhole_update_pmtu(struct dst_entry *dst, struct sock *sk, 2692 - struct sk_buff *skb, u32 mtu) 2690 + struct sk_buff *skb, u32 mtu, 2691 + bool confirm_neigh) 2693 2692 { 2694 2693 } 2695 2694
+3
net/ipv4/tcp_output.c
··· 72 72 __skb_unlink(skb, &sk->sk_write_queue); 73 73 tcp_rbtree_insert(&sk->tcp_rtx_queue, skb); 74 74 75 + if (tp->highest_sack == NULL) 76 + tp->highest_sack = skb; 77 + 75 78 tp->packets_out += tcp_skb_pcount(skb); 76 79 if (!prior_packets || icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) 77 80 tcp_rearm_rto(sk);
+1 -1
net/ipv4/udp.c
··· 1475 1475 * queue contains some other skb 1476 1476 */ 1477 1477 rmem = atomic_add_return(size, &sk->sk_rmem_alloc); 1478 - if (rmem > (size + sk->sk_rcvbuf)) 1478 + if (rmem > (size + (unsigned int)sk->sk_rcvbuf)) 1479 1479 goto uncharge_drop; 1480 1480 1481 1481 spin_lock(&list->lock);
+3 -2
net/ipv4/xfrm4_policy.c
··· 100 100 } 101 101 102 102 static void xfrm4_update_pmtu(struct dst_entry *dst, struct sock *sk, 103 - struct sk_buff *skb, u32 mtu) 103 + struct sk_buff *skb, u32 mtu, 104 + bool confirm_neigh) 104 105 { 105 106 struct xfrm_dst *xdst = (struct xfrm_dst *)dst; 106 107 struct dst_entry *path = xdst->route; 107 108 108 - path->ops->update_pmtu(path, sk, skb, mtu); 109 + path->ops->update_pmtu(path, sk, skb, mtu, confirm_neigh); 109 110 } 110 111 111 112 static void xfrm4_redirect(struct dst_entry *dst, struct sock *sk,
+1 -1
net/ipv6/inet6_connection_sock.c
··· 146 146 147 147 if (IS_ERR(dst)) 148 148 return NULL; 149 - dst->ops->update_pmtu(dst, sk, NULL, mtu); 149 + dst->ops->update_pmtu(dst, sk, NULL, mtu, true); 150 150 151 151 dst = inet6_csk_route_socket(sk, &fl6); 152 152 return IS_ERR(dst) ? NULL : dst;
+1 -1
net/ipv6/ip6_gre.c
··· 1040 1040 1041 1041 /* TooBig packet may have updated dst->dev's mtu */ 1042 1042 if (!t->parms.collect_md && dst && dst_mtu(dst) > dst->dev->mtu) 1043 - dst->ops->update_pmtu(dst, NULL, skb, dst->dev->mtu); 1043 + dst->ops->update_pmtu(dst, NULL, skb, dst->dev->mtu, false); 1044 1044 1045 1045 err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu, 1046 1046 NEXTHDR_GRE);
+2 -2
net/ipv6/ip6_tunnel.c
··· 640 640 if (rel_info > dst_mtu(skb_dst(skb2))) 641 641 goto out; 642 642 643 - skb_dst_update_pmtu(skb2, rel_info); 643 + skb_dst_update_pmtu_no_confirm(skb2, rel_info); 644 644 } 645 645 646 646 icmp_send(skb2, rel_type, rel_code, htonl(rel_info)); ··· 1132 1132 mtu = max(mtu, skb->protocol == htons(ETH_P_IPV6) ? 1133 1133 IPV6_MIN_MTU : IPV4_MIN_MTU); 1134 1134 1135 - skb_dst_update_pmtu(skb, mtu); 1135 + skb_dst_update_pmtu_no_confirm(skb, mtu); 1136 1136 if (skb->len - t->tun_hlen - eth_hlen > mtu && !skb_is_gso(skb)) { 1137 1137 *pmtu = mtu; 1138 1138 err = -EMSGSIZE;
+1 -1
net/ipv6/ip6_vti.c
··· 479 479 480 480 mtu = dst_mtu(dst); 481 481 if (skb->len > mtu) { 482 - skb_dst_update_pmtu(skb, mtu); 482 + skb_dst_update_pmtu_no_confirm(skb, mtu); 483 483 484 484 if (skb->protocol == htons(ETH_P_IPV6)) { 485 485 if (mtu < IPV6_MIN_MTU)
+15 -7
net/ipv6/route.c
··· 95 95 static int ip6_pkt_prohibit_out(struct net *net, struct sock *sk, struct sk_buff *skb); 96 96 static void ip6_link_failure(struct sk_buff *skb); 97 97 static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk, 98 - struct sk_buff *skb, u32 mtu); 98 + struct sk_buff *skb, u32 mtu, 99 + bool confirm_neigh); 99 100 static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, 100 101 struct sk_buff *skb); 101 102 static int rt6_score_route(const struct fib6_nh *nh, u32 fib6_flags, int oif, ··· 265 264 } 266 265 267 266 static void ip6_rt_blackhole_update_pmtu(struct dst_entry *dst, struct sock *sk, 268 - struct sk_buff *skb, u32 mtu) 267 + struct sk_buff *skb, u32 mtu, 268 + bool confirm_neigh) 269 269 { 270 270 } 271 271 ··· 2694 2692 } 2695 2693 2696 2694 static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk, 2697 - const struct ipv6hdr *iph, u32 mtu) 2695 + const struct ipv6hdr *iph, u32 mtu, 2696 + bool confirm_neigh) 2698 2697 { 2699 2698 const struct in6_addr *daddr, *saddr; 2700 2699 struct rt6_info *rt6 = (struct rt6_info *)dst; ··· 2713 2710 daddr = NULL; 2714 2711 saddr = NULL; 2715 2712 } 2716 - dst_confirm_neigh(dst, daddr); 2713 + 2714 + if (confirm_neigh) 2715 + dst_confirm_neigh(dst, daddr); 2716 + 2717 2717 mtu = max_t(u32, mtu, IPV6_MIN_MTU); 2718 2718 if (mtu >= dst_mtu(dst)) 2719 2719 return; ··· 2770 2764 } 2771 2765 2772 2766 static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk, 2773 - struct sk_buff *skb, u32 mtu) 2767 + struct sk_buff *skb, u32 mtu, 2768 + bool confirm_neigh) 2774 2769 { 2775 - __ip6_rt_update_pmtu(dst, sk, skb ? ipv6_hdr(skb) : NULL, mtu); 2770 + __ip6_rt_update_pmtu(dst, sk, skb ? ipv6_hdr(skb) : NULL, mtu, 2771 + confirm_neigh); 2776 2772 } 2777 2773 2778 2774 void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu, ··· 2793 2785 2794 2786 dst = ip6_route_output(net, NULL, &fl6); 2795 2787 if (!dst->error) 2796 - __ip6_rt_update_pmtu(dst, NULL, iph, ntohl(mtu)); 2788 + __ip6_rt_update_pmtu(dst, NULL, iph, ntohl(mtu), true); 2797 2789 dst_release(dst); 2798 2790 } 2799 2791 EXPORT_SYMBOL_GPL(ip6_update_pmtu);
+1 -1
net/ipv6/sit.c
··· 944 944 } 945 945 946 946 if (tunnel->parms.iph.daddr) 947 - skb_dst_update_pmtu(skb, mtu); 947 + skb_dst_update_pmtu_no_confirm(skb, mtu); 948 948 949 949 if (skb->len > mtu && !skb_is_gso(skb)) { 950 950 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
+3 -2
net/ipv6/xfrm6_policy.c
··· 98 98 } 99 99 100 100 static void xfrm6_update_pmtu(struct dst_entry *dst, struct sock *sk, 101 - struct sk_buff *skb, u32 mtu) 101 + struct sk_buff *skb, u32 mtu, 102 + bool confirm_neigh) 102 103 { 103 104 struct xfrm_dst *xdst = (struct xfrm_dst *)dst; 104 105 struct dst_entry *path = xdst->route; 105 106 106 - path->ops->update_pmtu(path, sk, skb, mtu); 107 + path->ops->update_pmtu(path, sk, skb, mtu, confirm_neigh); 107 108 } 108 109 109 110 static void xfrm6_redirect(struct dst_entry *dst, struct sock *sk,
+1 -1
net/netfilter/ipvs/ip_vs_xmit.c
··· 208 208 struct rtable *ort = skb_rtable(skb); 209 209 210 210 if (!skb->dev && sk && sk_fullsock(sk)) 211 - ort->dst.ops->update_pmtu(&ort->dst, sk, NULL, mtu); 211 + ort->dst.ops->update_pmtu(&ort->dst, sk, NULL, mtu, true); 212 212 } 213 213 214 214 static inline bool ensure_mtu_is_adequate(struct netns_ipvs *ipvs, int skb_af,
+1 -1
net/netfilter/nf_flow_table_offload.c
··· 88 88 switch (tuple->l4proto) { 89 89 case IPPROTO_TCP: 90 90 key->tcp.flags = 0; 91 - mask->tcp.flags = TCP_FLAG_RST | TCP_FLAG_FIN; 91 + mask->tcp.flags = cpu_to_be16(be32_to_cpu(TCP_FLAG_RST | TCP_FLAG_FIN) >> 16); 92 92 match->dissector.used_keys |= BIT(FLOW_DISSECTOR_KEY_TCP); 93 93 break; 94 94 case IPPROTO_UDP:
+2 -2
net/netfilter/nft_tproxy.c
··· 50 50 taddr = nf_tproxy_laddr4(skb, taddr, iph->daddr); 51 51 52 52 if (priv->sreg_port) 53 - tport = regs->data[priv->sreg_port]; 53 + tport = nft_reg_load16(&regs->data[priv->sreg_port]); 54 54 if (!tport) 55 55 tport = hp->dest; 56 56 ··· 117 117 taddr = *nf_tproxy_laddr6(skb, &taddr, &iph->daddr); 118 118 119 119 if (priv->sreg_port) 120 - tport = regs->data[priv->sreg_port]; 120 + tport = nft_reg_load16(&regs->data[priv->sreg_port]); 121 121 if (!tport) 122 122 tport = hp->dest; 123 123
+7 -3
net/rxrpc/ar-internal.h
··· 209 209 struct rxrpc_security { 210 210 const char *name; /* name of this service */ 211 211 u8 security_index; /* security type provided */ 212 + u32 no_key_abort; /* Abort code indicating no key */ 212 213 213 214 /* Initialise a security service */ 214 215 int (*init)(void); ··· 978 977 struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *, 979 978 struct sk_buff *); 980 979 struct rxrpc_connection *rxrpc_prealloc_service_connection(struct rxrpc_net *, gfp_t); 981 - void rxrpc_new_incoming_connection(struct rxrpc_sock *, 982 - struct rxrpc_connection *, struct sk_buff *); 980 + void rxrpc_new_incoming_connection(struct rxrpc_sock *, struct rxrpc_connection *, 981 + const struct rxrpc_security *, struct key *, 982 + struct sk_buff *); 983 983 void rxrpc_unpublish_service_conn(struct rxrpc_connection *); 984 984 985 985 /* ··· 1105 1103 int __init rxrpc_init_security(void); 1106 1104 void rxrpc_exit_security(void); 1107 1105 int rxrpc_init_client_conn_security(struct rxrpc_connection *); 1108 - int rxrpc_init_server_conn_security(struct rxrpc_connection *); 1106 + bool rxrpc_look_up_server_security(struct rxrpc_local *, struct rxrpc_sock *, 1107 + const struct rxrpc_security **, struct key **, 1108 + struct sk_buff *); 1109 1109 1110 1110 /* 1111 1111 * sendmsg.c
+37 -23
net/rxrpc/call_accept.c
··· 240 240 } 241 241 242 242 /* 243 + * Ping the other end to fill our RTT cache and to retrieve the rwind 244 + * and MTU parameters. 245 + */ 246 + static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb) 247 + { 248 + struct rxrpc_skb_priv *sp = rxrpc_skb(skb); 249 + ktime_t now = skb->tstamp; 250 + 251 + if (call->peer->rtt_usage < 3 || 252 + ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000), now)) 253 + rxrpc_propose_ACK(call, RXRPC_ACK_PING, sp->hdr.serial, 254 + true, true, 255 + rxrpc_propose_ack_ping_for_params); 256 + } 257 + 258 + /* 243 259 * Allocate a new incoming call from the prealloc pool, along with a connection 244 260 * and a peer as necessary. 245 261 */ ··· 263 247 struct rxrpc_local *local, 264 248 struct rxrpc_peer *peer, 265 249 struct rxrpc_connection *conn, 250 + const struct rxrpc_security *sec, 251 + struct key *key, 266 252 struct sk_buff *skb) 267 253 { 268 254 struct rxrpc_backlog *b = rx->backlog; ··· 312 294 conn->params.local = rxrpc_get_local(local); 313 295 conn->params.peer = peer; 314 296 rxrpc_see_connection(conn); 315 - rxrpc_new_incoming_connection(rx, conn, skb); 297 + rxrpc_new_incoming_connection(rx, conn, sec, key, skb); 316 298 } else { 317 299 rxrpc_get_connection(conn); 318 300 } ··· 351 333 struct sk_buff *skb) 352 334 { 353 335 struct rxrpc_skb_priv *sp = rxrpc_skb(skb); 336 + const struct rxrpc_security *sec = NULL; 354 337 struct rxrpc_connection *conn; 355 338 struct rxrpc_peer *peer = NULL; 356 - struct rxrpc_call *call; 339 + struct rxrpc_call *call = NULL; 340 + struct key *key = NULL; 357 341 358 342 _enter(""); 359 343 ··· 366 346 sp->hdr.seq, RX_INVALID_OPERATION, ESHUTDOWN); 367 347 skb->mark = RXRPC_SKB_MARK_REJECT_ABORT; 368 348 skb->priority = RX_INVALID_OPERATION; 369 - _leave(" = NULL [close]"); 370 - call = NULL; 371 - goto out; 349 + goto no_call; 372 350 } 373 351 374 352 /* The peer, connection and call may all have sprung into existence due ··· 376 358 */ 377 359 conn = rxrpc_find_connection_rcu(local, skb, &peer); 378 360 379 - call = rxrpc_alloc_incoming_call(rx, local, peer, conn, skb); 361 + if (!conn && !rxrpc_look_up_server_security(local, rx, &sec, &key, skb)) 362 + goto no_call; 363 + 364 + call = rxrpc_alloc_incoming_call(rx, local, peer, conn, sec, key, skb); 365 + key_put(key); 380 366 if (!call) { 381 367 skb->mark = RXRPC_SKB_MARK_REJECT_BUSY; 382 - _leave(" = NULL [busy]"); 383 - call = NULL; 384 - goto out; 368 + goto no_call; 385 369 } 386 370 387 371 trace_rxrpc_receive(call, rxrpc_receive_incoming, 388 372 sp->hdr.serial, sp->hdr.seq); 389 - 390 - /* Lock the call to prevent rxrpc_kernel_send/recv_data() and 391 - * sendmsg()/recvmsg() inconveniently stealing the mutex once the 392 - * notification is generated. 393 - * 394 - * The BUG should never happen because the kernel should be well 395 - * behaved enough not to access the call before the first notification 396 - * event and userspace is prevented from doing so until the state is 397 - * appropriate. 398 - */ 399 - if (!mutex_trylock(&call->user_mutex)) 400 - BUG(); 401 373 402 374 /* Make the call live. */ 403 375 rxrpc_incoming_call(rx, call, skb); ··· 429 421 BUG(); 430 422 } 431 423 spin_unlock(&conn->state_lock); 424 + spin_unlock(&rx->incoming_lock); 425 + 426 + rxrpc_send_ping(call, skb); 432 427 433 428 if (call->state == RXRPC_CALL_SERVER_ACCEPTING) 434 429 rxrpc_notify_socket(call); ··· 444 433 rxrpc_put_call(call, rxrpc_call_put); 445 434 446 435 _leave(" = %p{%d}", call, call->debug_id); 447 - out: 448 - spin_unlock(&rx->incoming_lock); 449 436 return call; 437 + 438 + no_call: 439 + spin_unlock(&rx->incoming_lock); 440 + _leave(" = NULL [%u]", skb->mark); 441 + return NULL; 450 442 } 451 443 452 444 /*
+1 -15
net/rxrpc/conn_event.c
··· 376 376 _enter("{%d}", conn->debug_id); 377 377 378 378 ASSERT(conn->security_ix != 0); 379 - 380 - if (!conn->params.key) { 381 - _debug("set up security"); 382 - ret = rxrpc_init_server_conn_security(conn); 383 - switch (ret) { 384 - case 0: 385 - break; 386 - case -ENOENT: 387 - abort_code = RX_CALL_DEAD; 388 - goto abort; 389 - default: 390 - abort_code = RXKADNOAUTH; 391 - goto abort; 392 - } 393 - } 379 + ASSERT(conn->server_key); 394 380 395 381 if (conn->security->issue_challenge(conn) < 0) { 396 382 abort_code = RX_CALL_DEAD;
+4
net/rxrpc/conn_service.c
··· 148 148 */ 149 149 void rxrpc_new_incoming_connection(struct rxrpc_sock *rx, 150 150 struct rxrpc_connection *conn, 151 + const struct rxrpc_security *sec, 152 + struct key *key, 151 153 struct sk_buff *skb) 152 154 { 153 155 struct rxrpc_skb_priv *sp = rxrpc_skb(skb); ··· 162 160 conn->service_id = sp->hdr.serviceId; 163 161 conn->security_ix = sp->hdr.securityIndex; 164 162 conn->out_clientflag = 0; 163 + conn->security = sec; 164 + conn->server_key = key_get(key); 165 165 if (conn->security_ix) 166 166 conn->state = RXRPC_CONN_SERVICE_UNSECURED; 167 167 else
-18
net/rxrpc/input.c
··· 193 193 } 194 194 195 195 /* 196 - * Ping the other end to fill our RTT cache and to retrieve the rwind 197 - * and MTU parameters. 198 - */ 199 - static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb) 200 - { 201 - struct rxrpc_skb_priv *sp = rxrpc_skb(skb); 202 - ktime_t now = skb->tstamp; 203 - 204 - if (call->peer->rtt_usage < 3 || 205 - ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000), now)) 206 - rxrpc_propose_ACK(call, RXRPC_ACK_PING, sp->hdr.serial, 207 - true, true, 208 - rxrpc_propose_ack_ping_for_params); 209 - } 210 - 211 - /* 212 196 * Apply a hard ACK by advancing the Tx window. 213 197 */ 214 198 static bool rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to, ··· 1380 1396 call = rxrpc_new_incoming_call(local, rx, skb); 1381 1397 if (!call) 1382 1398 goto reject_packet; 1383 - rxrpc_send_ping(call, skb); 1384 - mutex_unlock(&call->user_mutex); 1385 1399 } 1386 1400 1387 1401 /* Process a call packet; this either discards or passes on the ref
+3 -2
net/rxrpc/rxkad.c
··· 648 648 u32 serial; 649 649 int ret; 650 650 651 - _enter("{%d,%x}", conn->debug_id, key_serial(conn->params.key)); 651 + _enter("{%d,%x}", conn->debug_id, key_serial(conn->server_key)); 652 652 653 - ret = key_validate(conn->params.key); 653 + ret = key_validate(conn->server_key); 654 654 if (ret < 0) 655 655 return ret; 656 656 ··· 1293 1293 const struct rxrpc_security rxkad = { 1294 1294 .name = "rxkad", 1295 1295 .security_index = RXRPC_SECURITY_RXKAD, 1296 + .no_key_abort = RXKADUNKNOWNKEY, 1296 1297 .init = rxkad_init, 1297 1298 .exit = rxkad_exit, 1298 1299 .init_connection_security = rxkad_init_connection_security,
+33 -37
net/rxrpc/security.c
··· 101 101 } 102 102 103 103 /* 104 - * initialise the security on a server connection 104 + * Find the security key for a server connection. 105 105 */ 106 - int rxrpc_init_server_conn_security(struct rxrpc_connection *conn) 106 + bool rxrpc_look_up_server_security(struct rxrpc_local *local, struct rxrpc_sock *rx, 107 + const struct rxrpc_security **_sec, 108 + struct key **_key, 109 + struct sk_buff *skb) 107 110 { 108 111 const struct rxrpc_security *sec; 109 - struct rxrpc_local *local = conn->params.local; 110 - struct rxrpc_sock *rx; 111 - struct key *key; 112 - key_ref_t kref; 112 + struct rxrpc_skb_priv *sp = rxrpc_skb(skb); 113 + key_ref_t kref = NULL; 113 114 char kdesc[5 + 1 + 3 + 1]; 114 115 115 116 _enter(""); 116 117 117 - sprintf(kdesc, "%u:%u", conn->service_id, conn->security_ix); 118 + sprintf(kdesc, "%u:%u", sp->hdr.serviceId, sp->hdr.securityIndex); 118 119 119 - sec = rxrpc_security_lookup(conn->security_ix); 120 + sec = rxrpc_security_lookup(sp->hdr.securityIndex); 120 121 if (!sec) { 121 - _leave(" = -ENOKEY [lookup]"); 122 - return -ENOKEY; 122 + trace_rxrpc_abort(0, "SVS", 123 + sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq, 124 + RX_INVALID_OPERATION, EKEYREJECTED); 125 + skb->mark = RXRPC_SKB_MARK_REJECT_ABORT; 126 + skb->priority = RX_INVALID_OPERATION; 127 + return false; 123 128 } 124 129 125 - /* find the service */ 126 - read_lock(&local->services_lock); 127 - rx = rcu_dereference_protected(local->service, 128 - lockdep_is_held(&local->services_lock)); 129 - if (rx && (rx->srx.srx_service == conn->service_id || 130 - rx->second_service == conn->service_id)) 131 - goto found_service; 130 + if (sp->hdr.securityIndex == RXRPC_SECURITY_NONE) 131 + goto out; 132 132 133 - /* the service appears to have died */ 134 - read_unlock(&local->services_lock); 135 - _leave(" = -ENOENT"); 136 - return -ENOENT; 137 - 138 - found_service: 139 133 if (!rx->securities) { 140 - read_unlock(&local->services_lock); 141 - _leave(" = -ENOKEY"); 142 - return -ENOKEY; 134 + trace_rxrpc_abort(0, "SVR", 135 + sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq, 136 + RX_INVALID_OPERATION, EKEYREJECTED); 137 + skb->mark = RXRPC_SKB_MARK_REJECT_ABORT; 138 + skb->priority = RX_INVALID_OPERATION; 139 + return false; 143 140 } 144 141 145 142 /* look through the service's keyring */ 146 143 kref = keyring_search(make_key_ref(rx->securities, 1UL), 147 144 &key_type_rxrpc_s, kdesc, true); 148 145 if (IS_ERR(kref)) { 149 - read_unlock(&local->services_lock); 150 - _leave(" = %ld [search]", PTR_ERR(kref)); 151 - return PTR_ERR(kref); 146 + trace_rxrpc_abort(0, "SVK", 147 + sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq, 148 + sec->no_key_abort, EKEYREJECTED); 149 + skb->mark = RXRPC_SKB_MARK_REJECT_ABORT; 150 + skb->priority = sec->no_key_abort; 151 + return false; 152 152 } 153 153 154 - key = key_ref_to_ptr(kref); 155 - read_unlock(&local->services_lock); 156 - 157 - conn->server_key = key; 158 - conn->security = sec; 159 - 160 - _leave(" = 0"); 161 - return 0; 154 + out: 155 + *_sec = sec; 156 + *_key = key_ref_to_ptr(kref); 157 + return true; 162 158 }
+12 -10
net/sched/act_mirred.c
··· 219 219 bool use_reinsert; 220 220 bool want_ingress; 221 221 bool is_redirect; 222 + bool expects_nh; 222 223 int m_eaction; 223 224 int mac_len; 225 + bool at_nh; 224 226 225 227 rec_level = __this_cpu_inc_return(mirred_rec_level); 226 228 if (unlikely(rec_level > MIRRED_RECURSION_LIMIT)) { ··· 263 261 goto out; 264 262 } 265 263 266 - /* If action's target direction differs than filter's direction, 267 - * and devices expect a mac header on xmit, then mac push/pull is 268 - * needed. 269 - */ 270 264 want_ingress = tcf_mirred_act_wants_ingress(m_eaction); 271 - if (skb_at_tc_ingress(skb) != want_ingress && m_mac_header_xmit) { 272 - if (!skb_at_tc_ingress(skb)) { 273 - /* caught at egress, act ingress: pull mac */ 274 - mac_len = skb_network_header(skb) - skb_mac_header(skb); 265 + 266 + expects_nh = want_ingress || !m_mac_header_xmit; 267 + at_nh = skb->data == skb_network_header(skb); 268 + if (at_nh != expects_nh) { 269 + mac_len = skb_at_tc_ingress(skb) ? skb->mac_len : 270 + skb_network_header(skb) - skb_mac_header(skb); 271 + if (expects_nh) { 272 + /* target device/action expect data at nh */ 275 273 skb_pull_rcsum(skb2, mac_len); 276 274 } else { 277 - /* caught at ingress, act egress: push mac */ 278 - skb_push_rcsum(skb2, skb->mac_len); 275 + /* target device/action expect data at mac */ 276 + skb_push_rcsum(skb2, mac_len); 279 277 } 280 278 } 281 279
+5 -26
net/sched/cls_api.c
··· 308 308 tcf_proto_destroy(tp, rtnl_held, true, extack); 309 309 } 310 310 311 - static int walker_check_empty(struct tcf_proto *tp, void *fh, 312 - struct tcf_walker *arg) 311 + static bool tcf_proto_check_delete(struct tcf_proto *tp) 313 312 { 314 - if (fh) { 315 - arg->nonempty = true; 316 - return -1; 317 - } 318 - return 0; 319 - } 313 + if (tp->ops->delete_empty) 314 + return tp->ops->delete_empty(tp); 320 315 321 - static bool tcf_proto_is_empty(struct tcf_proto *tp, bool rtnl_held) 322 - { 323 - struct tcf_walker walker = { .fn = walker_check_empty, }; 324 - 325 - if (tp->ops->walk) { 326 - tp->ops->walk(tp, &walker, rtnl_held); 327 - return !walker.nonempty; 328 - } 329 - return true; 330 - } 331 - 332 - static bool tcf_proto_check_delete(struct tcf_proto *tp, bool rtnl_held) 333 - { 334 - spin_lock(&tp->lock); 335 - if (tcf_proto_is_empty(tp, rtnl_held)) 336 - tp->deleting = true; 337 - spin_unlock(&tp->lock); 316 + tp->deleting = true; 338 317 return tp->deleting; 339 318 } 340 319 ··· 1730 1751 * concurrently. 1731 1752 * Mark tp for deletion if it is empty. 1732 1753 */ 1733 - if (!tp_iter || !tcf_proto_check_delete(tp, rtnl_held)) { 1754 + if (!tp_iter || !tcf_proto_check_delete(tp)) { 1734 1755 mutex_unlock(&chain->filter_chain_lock); 1735 1756 return; 1736 1757 }
+12
net/sched/cls_flower.c
··· 2773 2773 f->res.class = cl; 2774 2774 } 2775 2775 2776 + static bool fl_delete_empty(struct tcf_proto *tp) 2777 + { 2778 + struct cls_fl_head *head = fl_head_dereference(tp); 2779 + 2780 + spin_lock(&tp->lock); 2781 + tp->deleting = idr_is_empty(&head->handle_idr); 2782 + spin_unlock(&tp->lock); 2783 + 2784 + return tp->deleting; 2785 + } 2786 + 2776 2787 static struct tcf_proto_ops cls_fl_ops __read_mostly = { 2777 2788 .kind = "flower", 2778 2789 .classify = fl_classify, ··· 2793 2782 .put = fl_put, 2794 2783 .change = fl_change, 2795 2784 .delete = fl_delete, 2785 + .delete_empty = fl_delete_empty, 2796 2786 .walk = fl_walk, 2797 2787 .reoffload = fl_reoffload, 2798 2788 .hw_add = fl_hw_add,
-25
net/sched/cls_u32.c
··· 1108 1108 return err; 1109 1109 } 1110 1110 1111 - static bool u32_hnode_empty(struct tc_u_hnode *ht, bool *non_root_ht) 1112 - { 1113 - int i; 1114 - 1115 - if (!ht) 1116 - return true; 1117 - if (!ht->is_root) { 1118 - *non_root_ht = true; 1119 - return false; 1120 - } 1121 - if (*non_root_ht) 1122 - return false; 1123 - if (ht->refcnt < 2) 1124 - return true; 1125 - 1126 - for (i = 0; i <= ht->divisor; i++) { 1127 - if (rtnl_dereference(ht->ht[i])) 1128 - return false; 1129 - } 1130 - return true; 1131 - } 1132 - 1133 1111 static void u32_walk(struct tcf_proto *tp, struct tcf_walker *arg, 1134 1112 bool rtnl_held) 1135 1113 { 1136 1114 struct tc_u_common *tp_c = tp->data; 1137 - bool non_root_ht = false; 1138 1115 struct tc_u_hnode *ht; 1139 1116 struct tc_u_knode *n; 1140 1117 unsigned int h; ··· 1124 1147 ht = rtnl_dereference(ht->next)) { 1125 1148 if (ht->prio != tp->prio) 1126 1149 continue; 1127 - if (u32_hnode_empty(ht, &non_root_ht)) 1128 - return; 1129 1150 if (arg->count >= arg->skip) { 1130 1151 if (arg->fn(tp, ht, arg) < 0) { 1131 1152 arg->stop = 1;
+8 -9
net/sched/sch_fq.c
··· 301 301 f->socket_hash != sk->sk_hash)) { 302 302 f->credit = q->initial_quantum; 303 303 f->socket_hash = sk->sk_hash; 304 + if (q->rate_enable) 305 + smp_store_release(&sk->sk_pacing_status, 306 + SK_PACING_FQ); 304 307 if (fq_flow_is_throttled(f)) 305 308 fq_flow_unset_throttled(q, f); 306 309 f->time_next_packet = 0ULL; ··· 325 322 326 323 fq_flow_set_detached(f); 327 324 f->sk = sk; 328 - if (skb->sk == sk) 325 + if (skb->sk == sk) { 329 326 f->socket_hash = sk->sk_hash; 327 + if (q->rate_enable) 328 + smp_store_release(&sk->sk_pacing_status, 329 + SK_PACING_FQ); 330 + } 330 331 f->credit = q->initial_quantum; 331 332 332 333 rb_link_node(&f->fq_node, parent, p); ··· 435 428 f->qlen++; 436 429 qdisc_qstats_backlog_inc(sch, skb); 437 430 if (fq_flow_is_detached(f)) { 438 - struct sock *sk = skb->sk; 439 - 440 431 fq_flow_add_tail(&q->new_flows, f); 441 432 if (time_after(jiffies, f->age + q->flow_refill_delay)) 442 433 f->credit = max_t(u32, f->credit, q->quantum); 443 - if (sk && q->rate_enable) { 444 - if (unlikely(smp_load_acquire(&sk->sk_pacing_status) != 445 - SK_PACING_FQ)) 446 - smp_store_release(&sk->sk_pacing_status, 447 - SK_PACING_FQ); 448 - } 449 434 q->inactive_flows--; 450 435 } 451 436
+15 -15
net/sctp/stream.c
··· 84 84 return 0; 85 85 86 86 ret = genradix_prealloc(&stream->out, outcnt, gfp); 87 - if (ret) { 88 - genradix_free(&stream->out); 87 + if (ret) 89 88 return ret; 90 - } 91 89 92 90 stream->outcnt = outcnt; 93 91 return 0; ··· 100 102 return 0; 101 103 102 104 ret = genradix_prealloc(&stream->in, incnt, gfp); 103 - if (ret) { 104 - genradix_free(&stream->in); 105 + if (ret) 105 106 return ret; 106 - } 107 107 108 108 stream->incnt = incnt; 109 109 return 0; ··· 119 123 * a new one with new outcnt to save memory if needed. 120 124 */ 121 125 if (outcnt == stream->outcnt) 122 - goto in; 126 + goto handle_in; 123 127 124 128 /* Filter out chunks queued on streams that won't exist anymore */ 125 129 sched->unsched_all(stream); ··· 128 132 129 133 ret = sctp_stream_alloc_out(stream, outcnt, gfp); 130 134 if (ret) 131 - goto out; 135 + goto out_err; 132 136 133 137 for (i = 0; i < stream->outcnt; i++) 134 138 SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN; 135 139 136 - in: 140 + handle_in: 137 141 sctp_stream_interleave_init(stream); 138 142 if (!incnt) 139 143 goto out; 140 144 141 145 ret = sctp_stream_alloc_in(stream, incnt, gfp); 142 - if (ret) { 143 - sched->free(stream); 144 - genradix_free(&stream->out); 145 - stream->outcnt = 0; 146 - goto out; 147 - } 146 + if (ret) 147 + goto in_err; 148 148 149 + goto out; 150 + 151 + in_err: 152 + sched->free(stream); 153 + genradix_free(&stream->in); 154 + out_err: 155 + genradix_free(&stream->out); 156 + stream->outcnt = 0; 149 157 out: 150 158 return ret; 151 159 }
+1 -1
net/sctp/transport.c
··· 263 263 264 264 pf->af->from_sk(&addr, sk); 265 265 pf->to_sk_daddr(&t->ipaddr, sk); 266 - dst->ops->update_pmtu(dst, sk, NULL, pmtu); 266 + dst->ops->update_pmtu(dst, sk, NULL, pmtu, true); 267 267 pf->to_sk_daddr(&addr, sk); 268 268 269 269 dst = sctp_transport_dst_check(t);
+6 -3
security/tomoyo/common.c
··· 951 951 exe = tomoyo_get_exe(); 952 952 if (!exe) 953 953 return false; 954 - list_for_each_entry_rcu(ptr, &tomoyo_kernel_namespace.policy_list[TOMOYO_ID_MANAGER], head.list) { 954 + list_for_each_entry_rcu(ptr, &tomoyo_kernel_namespace.policy_list[TOMOYO_ID_MANAGER], head.list, 955 + srcu_read_lock_held(&tomoyo_ss)) { 955 956 if (!ptr->head.is_deleted && 956 957 (!tomoyo_pathcmp(domainname, ptr->manager) || 957 958 !strcmp(exe, ptr->manager->name))) { ··· 1096 1095 if (mutex_lock_interruptible(&tomoyo_policy_lock)) 1097 1096 return -EINTR; 1098 1097 /* Is there an active domain? */ 1099 - list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) { 1098 + list_for_each_entry_rcu(domain, &tomoyo_domain_list, list, 1099 + srcu_read_lock_held(&tomoyo_ss)) { 1100 1100 /* Never delete tomoyo_kernel_domain */ 1101 1101 if (domain == &tomoyo_kernel_domain) 1102 1102 continue; ··· 2780 2778 2781 2779 tomoyo_policy_loaded = true; 2782 2780 pr_info("TOMOYO: 2.6.0\n"); 2783 - list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) { 2781 + list_for_each_entry_rcu(domain, &tomoyo_domain_list, list, 2782 + srcu_read_lock_held(&tomoyo_ss)) { 2784 2783 const u8 profile = domain->profile; 2785 2784 struct tomoyo_policy_namespace *ns = domain->ns; 2786 2785
+10 -5
security/tomoyo/domain.c
··· 41 41 42 42 if (mutex_lock_interruptible(&tomoyo_policy_lock)) 43 43 return -ENOMEM; 44 - list_for_each_entry_rcu(entry, list, list) { 44 + list_for_each_entry_rcu(entry, list, list, 45 + srcu_read_lock_held(&tomoyo_ss)) { 45 46 if (entry->is_deleted == TOMOYO_GC_IN_PROGRESS) 46 47 continue; 47 48 if (!check_duplicate(entry, new_entry)) ··· 120 119 } 121 120 if (mutex_lock_interruptible(&tomoyo_policy_lock)) 122 121 goto out; 123 - list_for_each_entry_rcu(entry, list, list) { 122 + list_for_each_entry_rcu(entry, list, list, 123 + srcu_read_lock_held(&tomoyo_ss)) { 124 124 if (entry->is_deleted == TOMOYO_GC_IN_PROGRESS) 125 125 continue; 126 126 if (!tomoyo_same_acl_head(entry, new_entry) || ··· 168 166 u16 i = 0; 169 167 170 168 retry: 171 - list_for_each_entry_rcu(ptr, list, list) { 169 + list_for_each_entry_rcu(ptr, list, list, 170 + srcu_read_lock_held(&tomoyo_ss)) { 172 171 if (ptr->is_deleted || ptr->type != r->param_type) 173 172 continue; 174 173 if (!check_entry(r, ptr)) ··· 301 298 { 302 299 const struct tomoyo_transition_control *ptr; 303 300 304 - list_for_each_entry_rcu(ptr, list, head.list) { 301 + list_for_each_entry_rcu(ptr, list, head.list, 302 + srcu_read_lock_held(&tomoyo_ss)) { 305 303 if (ptr->head.is_deleted || ptr->type != type) 306 304 continue; 307 305 if (ptr->domainname) { ··· 739 735 740 736 /* Check 'aggregator' directive. */ 741 737 candidate = &exename; 742 - list_for_each_entry_rcu(ptr, list, head.list) { 738 + list_for_each_entry_rcu(ptr, list, head.list, 739 + srcu_read_lock_held(&tomoyo_ss)) { 743 740 if (ptr->head.is_deleted || 744 741 !tomoyo_path_matches_pattern(&exename, 745 742 ptr->original_name))
+6 -3
security/tomoyo/group.c
··· 133 133 { 134 134 struct tomoyo_path_group *member; 135 135 136 - list_for_each_entry_rcu(member, &group->member_list, head.list) { 136 + list_for_each_entry_rcu(member, &group->member_list, head.list, 137 + srcu_read_lock_held(&tomoyo_ss)) { 137 138 if (member->head.is_deleted) 138 139 continue; 139 140 if (!tomoyo_path_matches_pattern(pathname, member->member_name)) ··· 162 161 struct tomoyo_number_group *member; 163 162 bool matched = false; 164 163 165 - list_for_each_entry_rcu(member, &group->member_list, head.list) { 164 + list_for_each_entry_rcu(member, &group->member_list, head.list, 165 + srcu_read_lock_held(&tomoyo_ss)) { 166 166 if (member->head.is_deleted) 167 167 continue; 168 168 if (min > member->number.values[1] || ··· 193 191 bool matched = false; 194 192 const u8 size = is_ipv6 ? 16 : 4; 195 193 196 - list_for_each_entry_rcu(member, &group->member_list, head.list) { 194 + list_for_each_entry_rcu(member, &group->member_list, head.list, 195 + srcu_read_lock_held(&tomoyo_ss)) { 197 196 if (member->head.is_deleted) 198 197 continue; 199 198 if (member->address.is_ipv6 != is_ipv6)
+1 -31
security/tomoyo/realpath.c
··· 218 218 } 219 219 220 220 /** 221 - * tomoyo_get_socket_name - Get the name of a socket. 222 - * 223 - * @path: Pointer to "struct path". 224 - * @buffer: Pointer to buffer to return value in. 225 - * @buflen: Sizeof @buffer. 226 - * 227 - * Returns the buffer. 228 - */ 229 - static char *tomoyo_get_socket_name(const struct path *path, char * const buffer, 230 - const int buflen) 231 - { 232 - struct inode *inode = d_backing_inode(path->dentry); 233 - struct socket *sock = inode ? SOCKET_I(inode) : NULL; 234 - struct sock *sk = sock ? sock->sk : NULL; 235 - 236 - if (sk) { 237 - snprintf(buffer, buflen, "socket:[family=%u:type=%u:protocol=%u]", 238 - sk->sk_family, sk->sk_type, sk->sk_protocol); 239 - } else { 240 - snprintf(buffer, buflen, "socket:[unknown]"); 241 - } 242 - return buffer; 243 - } 244 - 245 - /** 246 221 * tomoyo_realpath_from_path - Returns realpath(3) of the given pathname but ignores chroot'ed root. 247 222 * 248 223 * @path: Pointer to "struct path". ··· 254 279 break; 255 280 /* To make sure that pos is '\0' terminated. */ 256 281 buf[buf_len - 1] = '\0'; 257 - /* Get better name for socket. */ 258 - if (sb->s_magic == SOCKFS_MAGIC) { 259 - pos = tomoyo_get_socket_name(path, buf, buf_len - 1); 260 - goto encode; 261 - } 262 - /* For "pipe:[\$]". */ 282 + /* For "pipe:[\$]" and "socket:[\$]". */ 263 283 if (dentry->d_op && dentry->d_op->d_dname) { 264 284 pos = dentry->d_op->d_dname(dentry, buf, buf_len - 1); 265 285 goto encode;
+4 -2
security/tomoyo/util.c
··· 594 594 595 595 name.name = domainname; 596 596 tomoyo_fill_path_info(&name); 597 - list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) { 597 + list_for_each_entry_rcu(domain, &tomoyo_domain_list, list, 598 + srcu_read_lock_held(&tomoyo_ss)) { 598 599 if (!domain->is_deleted && 599 600 !tomoyo_pathcmp(&name, domain->domainname)) 600 601 return domain; ··· 1029 1028 return false; 1030 1029 if (!domain) 1031 1030 return true; 1032 - list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { 1031 + list_for_each_entry_rcu(ptr, &domain->acl_info_list, list, 1032 + srcu_read_lock_held(&tomoyo_ss)) { 1033 1033 u16 perm; 1034 1034 u8 i; 1035 1035
+8 -7
tools/lib/bpf/Makefile
··· 138 138 BPF_IN_SHARED := $(SHARED_OBJDIR)libbpf-in.o 139 139 BPF_IN_STATIC := $(STATIC_OBJDIR)libbpf-in.o 140 140 VERSION_SCRIPT := libbpf.map 141 + BPF_HELPER_DEFS := $(OUTPUT)bpf_helper_defs.h 141 142 142 143 LIB_TARGET := $(addprefix $(OUTPUT),$(LIB_TARGET)) 143 144 LIB_FILE := $(addprefix $(OUTPUT),$(LIB_FILE)) ··· 161 160 162 161 all_cmd: $(CMD_TARGETS) check 163 162 164 - $(BPF_IN_SHARED): force elfdep zdep bpfdep bpf_helper_defs.h 163 + $(BPF_IN_SHARED): force elfdep zdep bpfdep $(BPF_HELPER_DEFS) 165 164 @(test -f ../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \ 166 165 (diff -B ../../include/uapi/linux/bpf.h ../../../include/uapi/linux/bpf.h >/dev/null) || \ 167 166 echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'" >&2 )) || true ··· 179 178 echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' differs from latest version at 'include/uapi/linux/if_xdp.h'" >&2 )) || true 180 179 $(Q)$(MAKE) $(build)=libbpf OUTPUT=$(SHARED_OBJDIR) CFLAGS="$(CFLAGS) $(SHLIB_FLAGS)" 181 180 182 - $(BPF_IN_STATIC): force elfdep zdep bpfdep bpf_helper_defs.h 181 + $(BPF_IN_STATIC): force elfdep zdep bpfdep $(BPF_HELPER_DEFS) 183 182 $(Q)$(MAKE) $(build)=libbpf OUTPUT=$(STATIC_OBJDIR) 184 183 185 - bpf_helper_defs.h: $(srctree)/tools/include/uapi/linux/bpf.h 184 + $(BPF_HELPER_DEFS): $(srctree)/tools/include/uapi/linux/bpf.h 186 185 $(Q)$(srctree)/scripts/bpf_helpers_doc.py --header \ 187 - --file $(srctree)/tools/include/uapi/linux/bpf.h > bpf_helper_defs.h 186 + --file $(srctree)/tools/include/uapi/linux/bpf.h > $(BPF_HELPER_DEFS) 188 187 189 188 $(OUTPUT)libbpf.so: $(OUTPUT)libbpf.so.$(LIBBPF_VERSION) 190 189 ··· 246 245 $(call do_install_mkdir,$(libdir_SQ)); \ 247 246 cp -fpR $(LIB_FILE) $(DESTDIR)$(libdir_SQ) 248 247 249 - install_headers: bpf_helper_defs.h 248 + install_headers: $(BPF_HELPER_DEFS) 250 249 $(call QUIET_INSTALL, headers) \ 251 250 $(call do_install,bpf.h,$(prefix)/include/bpf,644); \ 252 251 $(call do_install,libbpf.h,$(prefix)/include/bpf,644); \ ··· 255 254 $(call do_install,libbpf_common.h,$(prefix)/include/bpf,644); \ 256 255 $(call do_install,xsk.h,$(prefix)/include/bpf,644); \ 257 256 $(call do_install,bpf_helpers.h,$(prefix)/include/bpf,644); \ 258 - $(call do_install,bpf_helper_defs.h,$(prefix)/include/bpf,644); \ 257 + $(call do_install,$(BPF_HELPER_DEFS),$(prefix)/include/bpf,644); \ 259 258 $(call do_install,bpf_tracing.h,$(prefix)/include/bpf,644); \ 260 259 $(call do_install,bpf_endian.h,$(prefix)/include/bpf,644); \ 261 260 $(call do_install,bpf_core_read.h,$(prefix)/include/bpf,644); ··· 275 274 clean: 276 275 $(call QUIET_CLEAN, libbpf) $(RM) -rf $(CMD_TARGETS) \ 277 276 *.o *~ *.a *.so *.so.$(LIBBPF_MAJOR_VERSION) .*.d .*.cmd \ 278 - *.pc LIBBPF-CFLAGS bpf_helper_defs.h \ 277 + *.pc LIBBPF-CFLAGS $(BPF_HELPER_DEFS) \ 279 278 $(SHARED_OBJDIR) $(STATIC_OBJDIR) 280 279 $(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf 281 280
+11 -7
tools/testing/kunit/kunit.py
··· 31 31 TEST_FAILURE = auto() 32 32 33 33 def create_default_kunitconfig(): 34 - if not os.path.exists(kunit_kernel.KUNITCONFIG_PATH): 34 + if not os.path.exists(kunit_kernel.kunitconfig_path): 35 35 shutil.copyfile('arch/um/configs/kunit_defconfig', 36 - kunit_kernel.KUNITCONFIG_PATH) 36 + kunit_kernel.kunitconfig_path) 37 37 38 38 def run_tests(linux: kunit_kernel.LinuxSourceTree, 39 39 request: KunitRequest) -> KunitResult: 40 - if request.defconfig: 41 - create_default_kunitconfig() 42 - 43 40 config_start = time.time() 44 41 success = linux.build_reconfig(request.build_dir) 45 42 config_end = time.time() ··· 105 108 run_parser.add_argument('--build_dir', 106 109 help='As in the make command, it specifies the build ' 107 110 'directory.', 108 - type=str, default=None, metavar='build_dir') 111 + type=str, default='', metavar='build_dir') 109 112 110 113 run_parser.add_argument('--defconfig', 111 - help='Uses a default kunitconfig.', 114 + help='Uses a default .kunitconfig.', 112 115 action='store_true') 113 116 114 117 cli_args = parser.parse_args(argv) 115 118 116 119 if cli_args.subcommand == 'run': 120 + if cli_args.build_dir: 121 + if not os.path.exists(cli_args.build_dir): 122 + os.mkdir(cli_args.build_dir) 123 + kunit_kernel.kunitconfig_path = os.path.join( 124 + cli_args.build_dir, 125 + kunit_kernel.kunitconfig_path) 126 + 117 127 if cli_args.defconfig: 118 128 create_default_kunitconfig() 119 129
+5 -5
tools/testing/kunit/kunit_kernel.py
··· 14 14 import kunit_config 15 15 16 16 KCONFIG_PATH = '.config' 17 - KUNITCONFIG_PATH = 'kunitconfig' 17 + kunitconfig_path = '.kunitconfig' 18 18 19 19 class ConfigError(Exception): 20 20 """Represents an error trying to configure the Linux kernel.""" ··· 82 82 83 83 def __init__(self): 84 84 self._kconfig = kunit_config.Kconfig() 85 - self._kconfig.read_from_file(KUNITCONFIG_PATH) 85 + self._kconfig.read_from_file(kunitconfig_path) 86 86 self._ops = LinuxSourceTreeOperations() 87 87 88 88 def clean(self): ··· 111 111 return True 112 112 113 113 def build_reconfig(self, build_dir): 114 - """Creates a new .config if it is not a subset of the kunitconfig.""" 114 + """Creates a new .config if it is not a subset of the .kunitconfig.""" 115 115 kconfig_path = get_kconfig_path(build_dir) 116 116 if os.path.exists(kconfig_path): 117 117 existing_kconfig = kunit_config.Kconfig() ··· 140 140 return False 141 141 return True 142 142 143 - def run_kernel(self, args=[], timeout=None, build_dir=None): 143 + def run_kernel(self, args=[], timeout=None, build_dir=''): 144 144 args.extend(['mem=256M']) 145 145 process = self._ops.linux_bin(args, timeout, build_dir) 146 - with open('test.log', 'w') as f: 146 + with open(os.path.join(build_dir, 'test.log'), 'w') as f: 147 147 for line in process.stdout: 148 148 f.write(line.rstrip().decode('ascii') + '\n') 149 149 yield line.rstrip().decode('ascii')
+9 -1
tools/testing/kunit/kunit_tool_test.py
··· 174 174 kunit.main(['run'], self.linux_source_mock) 175 175 assert self.linux_source_mock.build_reconfig.call_count == 1 176 176 assert self.linux_source_mock.run_kernel.call_count == 1 177 + self.linux_source_mock.run_kernel.assert_called_once_with(build_dir='', timeout=300) 177 178 self.print_mock.assert_any_call(StrContains('Testing complete.')) 178 179 179 180 def test_run_passes_args_fail(self): ··· 200 199 timeout = 3453 201 200 kunit.main(['run', '--timeout', str(timeout)], self.linux_source_mock) 202 201 assert self.linux_source_mock.build_reconfig.call_count == 1 203 - self.linux_source_mock.run_kernel.assert_called_once_with(build_dir=None, timeout=timeout) 202 + self.linux_source_mock.run_kernel.assert_called_once_with(build_dir='', timeout=timeout) 203 + self.print_mock.assert_any_call(StrContains('Testing complete.')) 204 + 205 + def test_run_builddir(self): 206 + build_dir = '.kunit' 207 + kunit.main(['run', '--build_dir', build_dir], self.linux_source_mock) 208 + assert self.linux_source_mock.build_reconfig.call_count == 1 209 + self.linux_source_mock.run_kernel.assert_called_once_with(build_dir=build_dir, timeout=300) 204 210 self.print_mock.assert_any_call(StrContains('Testing complete.')) 205 211 206 212 if __name__ == '__main__':
+1
tools/testing/selftests/bpf/.gitignore
··· 41 41 /no_alu32 42 42 /bpf_gcc 43 43 /tools 44 + bpf_helper_defs.h
+3 -3
tools/testing/selftests/bpf/Makefile
··· 151 151 $(BPFOBJ): force 152 152 $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ 153 153 154 - BPF_HELPERS := $(BPFDIR)/bpf_helper_defs.h $(wildcard $(BPFDIR)/bpf_*.h) 155 - $(BPFDIR)/bpf_helper_defs.h: 156 - $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ bpf_helper_defs.h 154 + BPF_HELPERS := $(OUTPUT)/bpf_helper_defs.h $(wildcard $(BPFDIR)/bpf_*.h) 155 + $(OUTPUT)/bpf_helper_defs.h: 156 + $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ $(OUTPUT)/bpf_helper_defs.h 157 157 158 158 # Get Clang's default includes on this system, as opposed to those seen by 159 159 # '-target bpf'. This fixes "missing" files on some architectures/distros,
+1 -1
tools/testing/selftests/filesystems/epoll/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 3 CFLAGS += -I../../../../../usr/include/ 4 - LDFLAGS += -lpthread 4 + LDLIBS += -lpthread 5 5 TEST_GEN_PROGS := epoll_wakeup_test 6 6 7 7 include ../../lib.mk
+6
tools/testing/selftests/firmware/fw_lib.sh
··· 34 34 35 35 check_mods() 36 36 { 37 + local uid=$(id -u) 38 + if [ $uid -ne 0 ]; then 39 + echo "skip all tests: must be run as root" >&2 40 + exit $ksft_skip 41 + fi 42 + 37 43 trap "test_modprobe" EXIT 38 44 if [ ! -d $DIR ]; then 39 45 modprobe test_firmware
+14 -1
tools/testing/selftests/livepatch/functions.sh
··· 7 7 MAX_RETRIES=600 8 8 RETRY_INTERVAL=".1" # seconds 9 9 10 + # Kselftest framework requirement - SKIP code is 4 11 + ksft_skip=4 12 + 10 13 # log(msg) - write message to kernel log 11 14 # msg - insightful words 12 15 function log() { ··· 21 18 function skip() { 22 19 log "SKIP: $1" 23 20 echo "SKIP: $1" >&2 24 - exit 4 21 + exit $ksft_skip 22 + } 23 + 24 + # root test 25 + function is_root() { 26 + uid=$(id -u) 27 + if [ $uid -ne 0 ]; then 28 + echo "skip all tests: must be run as root" >&2 29 + exit $ksft_skip 30 + fi 25 31 } 26 32 27 33 # die(msg) - game over, man ··· 74 62 # for verbose livepatching output and turn on 75 63 # the ftrace_enabled sysctl. 76 64 function setup_config() { 65 + is_root 77 66 push_config 78 67 set_dynamic_debug 79 68 set_ftrace_enabled 1
+1 -2
tools/testing/selftests/livepatch/test-state.sh
··· 8 8 MOD_LIVEPATCH2=test_klp_state2 9 9 MOD_LIVEPATCH3=test_klp_state3 10 10 11 - set_dynamic_debug 12 - 11 + setup_config 13 12 14 13 # TEST: Loading and removing a module that modifies the system state 15 14
+34 -5
tools/testing/selftests/netfilter/nft_flowtable.sh
··· 226 226 return 0 227 227 } 228 228 229 - test_tcp_forwarding() 229 + test_tcp_forwarding_ip() 230 230 { 231 231 local nsa=$1 232 232 local nsb=$2 233 + local dstip=$3 234 + local dstport=$4 233 235 local lret=0 234 236 235 237 ip netns exec $nsb nc -w 5 -l -p 12345 < "$ns2in" > "$ns2out" & 236 238 lpid=$! 237 239 238 240 sleep 1 239 - ip netns exec $nsa nc -w 4 10.0.2.99 12345 < "$ns1in" > "$ns1out" & 241 + ip netns exec $nsa nc -w 4 "$dstip" "$dstport" < "$ns1in" > "$ns1out" & 240 242 cpid=$! 241 243 242 244 sleep 3 ··· 255 253 check_transfer "$ns2in" "$ns1out" "ns1 <- ns2" 256 254 if [ $? -ne 0 ];then 257 255 lret=1 256 + fi 257 + 258 + return $lret 259 + } 260 + 261 + test_tcp_forwarding() 262 + { 263 + test_tcp_forwarding_ip "$1" "$2" 10.0.2.99 12345 264 + 265 + return $? 266 + } 267 + 268 + test_tcp_forwarding_nat() 269 + { 270 + local lret 271 + 272 + test_tcp_forwarding_ip "$1" "$2" 10.0.2.99 12345 273 + lret=$? 274 + 275 + if [ $lret -eq 0 ] ; then 276 + test_tcp_forwarding_ip "$1" "$2" 10.6.6.6 1666 277 + lret=$? 258 278 fi 259 279 260 280 return $lret ··· 307 283 # Same, but with NAT enabled. 308 284 ip netns exec nsr1 nft -f - <<EOF 309 285 table ip nat { 286 + chain prerouting { 287 + type nat hook prerouting priority 0; policy accept; 288 + meta iif "veth0" ip daddr 10.6.6.6 tcp dport 1666 counter dnat ip to 10.0.2.99:12345 289 + } 290 + 310 291 chain postrouting { 311 292 type nat hook postrouting priority 0; policy accept; 312 - meta oifname "veth1" masquerade 293 + meta oifname "veth1" counter masquerade 313 294 } 314 295 } 315 296 EOF 316 297 317 - test_tcp_forwarding ns1 ns2 298 + test_tcp_forwarding_nat ns1 ns2 318 299 319 300 if [ $? -eq 0 ] ;then 320 301 echo "PASS: flow offloaded for ns1/ns2 with NAT" ··· 342 313 ip netns exec ns1 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null 343 314 ip netns exec ns2 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null 344 315 345 - test_tcp_forwarding ns1 ns2 316 + test_tcp_forwarding_nat ns1 ns2 346 317 if [ $? -eq 0 ] ;then 347 318 echo "PASS: flow offloaded for ns1/ns2 with NAT and pmtu discovery" 348 319 else
+10 -8
tools/testing/selftests/rseq/param_test.c
··· 15 15 #include <errno.h> 16 16 #include <stddef.h> 17 17 18 - static inline pid_t gettid(void) 18 + static inline pid_t rseq_gettid(void) 19 19 { 20 20 return syscall(__NR_gettid); 21 21 } ··· 373 373 rseq_percpu_unlock(&data->lock, cpu); 374 374 #ifndef BENCHMARK 375 375 if (i != 0 && !(i % (reps / 10))) 376 - printf_verbose("tid %d: count %lld\n", (int) gettid(), i); 376 + printf_verbose("tid %d: count %lld\n", 377 + (int) rseq_gettid(), i); 377 378 #endif 378 379 } 379 380 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 380 - (int) gettid(), nr_abort, signals_delivered); 381 + (int) rseq_gettid(), nr_abort, signals_delivered); 381 382 if (!opt_disable_rseq && thread_data->reg && 382 383 rseq_unregister_current_thread()) 383 384 abort(); ··· 455 454 } while (rseq_unlikely(ret)); 456 455 #ifndef BENCHMARK 457 456 if (i != 0 && !(i % (reps / 10))) 458 - printf_verbose("tid %d: count %lld\n", (int) gettid(), i); 457 + printf_verbose("tid %d: count %lld\n", 458 + (int) rseq_gettid(), i); 459 459 #endif 460 460 } 461 461 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 462 - (int) gettid(), nr_abort, signals_delivered); 462 + (int) rseq_gettid(), nr_abort, signals_delivered); 463 463 if (!opt_disable_rseq && thread_data->reg && 464 464 rseq_unregister_current_thread()) 465 465 abort(); ··· 607 605 } 608 606 609 607 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 610 - (int) gettid(), nr_abort, signals_delivered); 608 + (int) rseq_gettid(), nr_abort, signals_delivered); 611 609 if (!opt_disable_rseq && rseq_unregister_current_thread()) 612 610 abort(); 613 611 ··· 798 796 } 799 797 800 798 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 801 - (int) gettid(), nr_abort, signals_delivered); 799 + (int) rseq_gettid(), nr_abort, signals_delivered); 802 800 if (!opt_disable_rseq && rseq_unregister_current_thread()) 803 801 abort(); 804 802 ··· 1013 1011 } 1014 1012 1015 1013 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 1016 - (int) gettid(), nr_abort, signals_delivered); 1014 + (int) rseq_gettid(), nr_abort, signals_delivered); 1017 1015 if (!opt_disable_rseq && rseq_unregister_current_thread()) 1018 1016 abort(); 1019 1017
+7 -5
tools/testing/selftests/rseq/rseq.h
··· 149 149 /* 150 150 * rseq_prepare_unload() should be invoked by each thread executing a rseq 151 151 * critical section at least once between their last critical section and 152 - * library unload of the library defining the rseq critical section 153 - * (struct rseq_cs). This also applies to use of rseq in code generated by 154 - * JIT: rseq_prepare_unload() should be invoked at least once by each 155 - * thread executing a rseq critical section before reclaim of the memory 156 - * holding the struct rseq_cs. 152 + * library unload of the library defining the rseq critical section (struct 153 + * rseq_cs) or the code referred to by the struct rseq_cs start_ip and 154 + * post_commit_offset fields. This also applies to use of rseq in code 155 + * generated by JIT: rseq_prepare_unload() should be invoked at least once by 156 + * each thread executing a rseq critical section before reclaim of the memory 157 + * holding the struct rseq_cs or reclaim of the code pointed to by struct 158 + * rseq_cs start_ip and post_commit_offset fields. 157 159 */ 158 160 static inline void rseq_prepare_unload(void) 159 161 {
+1
tools/testing/selftests/rseq/settings
··· 1 + timeout=0