2b3ea8bdef
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmVbOmsACgkQONu9yGCS aT5m1RAAx7hgbFDnLHCGh4YVBbNy8JngItsUBaJcI/67Mk5toNi0x8pqcS8mq7ED GTwRnRcKaIR2bTyco5Ed2OZn4jMCyHC4oiyBZnHWg6AMuQjSCYzIgm7DzlTCVYZ7 2r8uRbt/uXADTILJ2kwR2mtVpGcwrXa+lsHrMqvt+MvNwRoSVHBHVVYCrAc+JXwR GXCopzV/RFGS6w4SBsX0K+8pV7GO+bhpxJ1lPz1T/xeLYfT4C3EwSTWDbUXPbez7 IpJ+5yKJXXT9Xn9m/pekwZ/aOirLqtEbDxneEctsjvw140lCoQiEZn6ZRscgNEns 3H+J3Asgc2zXqPzfZFH02TebPj31B8HZ43Upu0okr0hr4A4/4JL9pjXEhm1bON/Z x3jlTF4dyay4vOGGIEYOAuJSUbn6AqpZ318uBWCd3BSPocihEDMJz2aoazVHcb6k 83MVxfFfEL6s9utcoSXB8VjHa4FQmpMYsozegloUSJJCsizgdzmih0buJYhBB9sI HbEohW+YAh3cACSn6arXUJIMH5F5xsfD89od2Pj+6UrapdlPz5gCaggA1RZplCho bjGc1k61Rp2qSdfMEcx+h4ypgoOdhgqZI0YhYDCgBSRcWOXnGrDjFvnnumatcT+H 6vqyX6zlNt6U1NpE56Jtf7gt1Ds6PeoadD0L6B8vjXrkdeXOlUU= =AZ9s -----END PGP SIGNATURE----- Merge 6.1.63 into android14-6.1-lts Changes in 6.1.63 hwmon: (nct6775) Fix incorrect variable reuse in fan_div calculation sched/fair: Fix cfs_rq_is_decayed() on !SMP iov_iter, x86: Be consistent about the __user tag on copy_mc_to_user() sched/uclamp: Set max_spare_cap_cpu even if max_spare_cap is 0 sched/uclamp: Ignore (util == 0) optimization in feec() when p_util_max = 0 objtool: Propagate early errors sched: Fix stop_one_cpu_nowait() vs hotplug vfs: fix readahead(2) on block devices writeback, cgroup: switch inodes with dirty timestamps to release dying cgwbs x86/srso: Fix SBPB enablement for (possible) future fixed HW futex: Don't include process MM in futex key on no-MMU x86/numa: Introduce numa_fill_memblks() ACPI/NUMA: Apply SRAT proximity domain to entire CFMWS window x86/sev-es: Allow copy_from_kernel_nofault() in earlier boot x86/boot: Fix incorrect startup_gdt_descr.size drivers/clocksource/timer-ti-dm: Don't call clk_get_rate() in stop function pstore/platform: Add check for kstrdup string: Adjust strtomem() logic to allow for smaller sources genirq/matrix: Exclude managed interrupts in irq_matrix_allocated() wifi: cfg80211: add flush functions for wiphy work wifi: mac80211: move radar detect work to wiphy work wifi: mac80211: move scan work to wiphy work wifi: mac80211: move offchannel works to wiphy work wifi: mac80211: move sched-scan stop work to wiphy work wifi: mac80211: fix # of MSDU in A-MSDU calculation wifi: iwlwifi: honor the enable_ini value i40e: fix potential memory leaks in i40e_remove() iavf: Fix promiscuous mode configuration flow messages selftests/bpf: Correct map_fd to data_fd in tailcalls udp: add missing WRITE_ONCE() around up->encap_rcv tcp: call tcp_try_undo_recovery when an RTOd TFO SYNACK is ACKed gve: Use size_add() in call to struct_size() mlxsw: Use size_mul() in call to struct_size() tls: Only use data field in crypto completion function tls: Use size_add() in call to struct_size() tipc: Use size_add() in calls to struct_size() net: spider_net: Use size_add() in call to struct_size() net: ethernet: mtk_wed: fix EXT_INT_STATUS_RX_FBUF definitions for MT7986 SoC wifi: rtw88: debug: Fix the NULL vs IS_ERR() bug for debugfs_create_file() wifi: ath11k: fix boot failure with one MSI vector wifi: mt76: mt7603: rework/fix rx pse hang check wifi: mt76: mt7603: improve watchdog reset reliablity wifi: mt76: mt7603: improve stuck beacon handling wifi: mt76: mt7915: fix beamforming availability check wifi: ath: dfs_pattern_detector: Fix a memory initialization issue tcp_metrics: add missing barriers on delete tcp_metrics: properly set tp->snd_ssthresh in tcp_init_metrics() tcp_metrics: do not create an entry from tcp_init_metrics() wifi: rtlwifi: fix EDCA limit set by BT coexistence ACPI: property: Allow _DSD buffer data only for byte accessors ACPI: video: Add acpi_backlight=vendor quirk for Toshiba Portégé R100 wifi: ath11k: fix Tx power value during active CAC can: dev: can_restart(): don't crash kernel if carrier is OK can: dev: can_restart(): fix race condition between controller restart and netif_carrier_on() can: dev: can_put_echo_skb(): don't crash kernel if can_priv::echo_skb is accessed out of bounds PM / devfreq: rockchip-dfi: Make pmu regmap mandatory wifi: wfx: fix case where rates are out of order netfilter: nf_tables: Drop pointless memset when dumping rules thermal: core: prevent potential string overflow r8169: use tp_to_dev instead of open code r8169: fix rare issue with broken rx after link-down on RTL8125 selftests: netfilter: test for sctp collision processing in nf_conntrack net: skb_find_text: Ignore patterns extending past 'to' chtls: fix tp->rcv_tstamp initialization tcp: fix cookie_init_timestamp() overflows wifi: iwlwifi: call napi_synchronize() before freeing rx/tx queues wifi: iwlwifi: pcie: synchronize IRQs before NAPI wifi: iwlwifi: empty overflow queue during flush Bluetooth: hci_sync: Fix Opcode prints in bt_dev_dbg/err bpf: Fix unnecessary -EBUSY from htab_lock_bucket ACPI: sysfs: Fix create_pnp_modalias() and create_of_modalias() ipv6: avoid atomic fragment on GSO packets net: add DEV_STATS_READ() helper ipvlan: properly track tx_errors regmap: debugfs: Fix a erroneous check after snprintf() spi: tegra: Fix missing IRQ check in tegra_slink_probe() clk: qcom: gcc-msm8996: Remove RPM bus clocks clk: qcom: clk-rcg2: Fix clock rate overflow for high parent frequencies clk: qcom: mmcc-msm8998: Don't check halt bit on some branch clks clk: qcom: mmcc-msm8998: Fix the SMMU GDSC clk: qcom: gcc-sm8150: Fix gcc_sdcc2_apps_clk_src regulator: mt6358: Fail probe on unknown chip ID clk: imx: Select MXC_CLK for CLK_IMX8QXP clk: imx: imx8mq: correct error handling path clk: imx: imx8qxp: Fix elcdif_pll clock clk: renesas: rcar-gen3: Extend SDnH divider table clk: renesas: rzg2l: Wait for status bit of SD mux before continuing clk: renesas: rzg2l: Lock around writes to mux register clk: renesas: rzg2l: Trust value returned by hardware clk: renesas: rzg2l: Use FIELD_GET() for PLL register fields clk: renesas: rzg2l: Fix computation formula clk: linux/clk-provider.h: fix kernel-doc warnings and typos spi: nxp-fspi: use the correct ioremap function clk: keystone: pll: fix a couple NULL vs IS_ERR() checks clk: ti: change ti_clk_register[_omap_hw]() API clk: ti: fix double free in of_ti_divider_clk_setup() clk: npcm7xx: Fix incorrect kfree clk: mediatek: clk-mt6765: Add check for mtk_alloc_clk_data clk: mediatek: clk-mt6779: Add check for mtk_alloc_clk_data clk: mediatek: clk-mt6797: Add check for mtk_alloc_clk_data clk: mediatek: clk-mt7629-eth: Add check for mtk_alloc_clk_data clk: mediatek: clk-mt7629: Add check for mtk_alloc_clk_data clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data clk: qcom: config IPQ_APSS_6018 should depend on QCOM_SMEM platform/x86: wmi: Fix probe failure when failing to register WMI devices platform/x86: wmi: Fix opening of char device hwmon: (axi-fan-control) Fix possible NULL pointer dereference hwmon: (coretemp) Fix potentially truncated sysfs attribute name Revert "hwmon: (sch56xx-common) Add DMI override table" Revert "hwmon: (sch56xx-common) Add automatic module loading on supported devices" hwmon: (sch5627) Use bit macros when accessing the control register hwmon: (sch5627) Disallow write access if virtual registers are locked hte: tegra: Fix missing error code in tegra_hte_test_probe() drm/rockchip: vop: Fix reset of state in duplicate state crtc funcs drm/rockchip: vop: Fix call to crtc reset helper drm/rockchip: vop2: Don't crash for invalid duplicate_state drm/rockchip: vop2: Add missing call to crtc reset helper drm/radeon: possible buffer overflow drm: bridge: it66121: Fix invalid connector dereference drm/bridge: lt8912b: Add hot plug detection drm/bridge: lt8912b: Fix bridge_detach drm/bridge: lt8912b: Fix crash on bridge detach drm/bridge: lt8912b: Manually disable HPD only if it was enabled drm/bridge: lt8912b: Add missing drm_bridge_attach call drm/bridge: tc358768: Fix use of uninitialized variable drm/bridge: tc358768: Fix bit updates drm/bridge: tc358768: remove unused variable drm/bridge: tc358768: Use struct videomode drm/bridge: tc358768: Print logical values, not raw register values drm/bridge: tc358768: Use dev for dbg prints, not priv->dev drm/bridge: tc358768: Rename dsibclk to hsbyteclk drm/bridge: tc358768: Clean up clock period code drm/bridge: tc358768: Fix tc358768_ns_to_cnt() drm/amdkfd: fix some race conditions in vram buffer alloc/free of svm code drm/amd/display: Check all enabled planes in dm_check_crtc_cursor drm/amd/display: Refactor dm_get_plane_scale helper drm/amd/display: Bail from dm_check_crtc_cursor if no relevant change io_uring/kbuf: Fix check of BID wrapping in provided buffers io_uring/kbuf: Allow the full buffer id space for provided buffers drm/mediatek: Fix iommu fault by swapping FBs after updating plane state drm/mediatek: Fix iommu fault during crtc enabling drm/rockchip: cdn-dp: Fix some error handling paths in cdn_dp_probe() gpu: host1x: Correct allocated size for contexts drm/bridge: lt9611uxc: fix the race in the error path arm64/arm: xen: enlighten: Fix KPTI checks drm/rockchip: Fix type promotion bug in rockchip_gem_iommu_map() xenbus: fix error exit in xenbus_init() xen-pciback: Consider INTx disabled when MSI/MSI-X is enabled drm/msm/dsi: use msm_gem_kernel_put to free TX buffer drm/msm/dsi: free TX buffer in unbind clocksource/drivers/arm_arch_timer: limit XGene-1 workaround drm: mediatek: mtk_dsi: Fix NO_EOT_PACKET settings/handling drivers/perf: hisi: use cpuhp_state_remove_instance_nocalls() for hisi_hns3_pmu uninit process perf/arm-cmn: Revamp model detection perf/arm-cmn: Fix DTC domain detection drivers/perf: hisi_pcie: Check the type first in pmu::event_init() perf: hisi: Fix use-after-free when register pmu fails ARM: dts: renesas: blanche: Fix typo in GP_11_2 pin name arm64: dts: qcom: sdm845: cheza doesn't support LMh node arm64: dts: qcom: sc7280: link usb3_phy_wrapper_gcc_usb30_pipe_clk arm64: dts: qcom: msm8916: Fix iommu local address range arm64: dts: qcom: msm8992-libra: drop duplicated reserved memory arm64: dts: qcom: sc7280: Add missing LMH interrupts arm64: dts: qcom: sm8150: add ref clock to PCIe PHYs arm64: dts: qcom: sm8350: fix pinctrl for UART18 arm64: dts: qcom: sdm845-mtp: fix WiFi configuration ARM64: dts: marvell: cn9310: Use appropriate label for spi1 pins arm64: dts: qcom: apq8016-sbc: Add missing ADV7533 regulators ARM: dts: qcom: mdm9615: populate vsdcc fixed regulator soc: qcom: llcc: Handle a second device without data corruption kunit: Fix missed memory release in kunit_free_suite_set() firmware: ti_sci: Mark driver as non removable arm64: dts: ti: k3-am62a7-sk: Drop i2c-1 to 100Khz firmware: arm_ffa: Assign the missing IDR allocation ID to the FFA device firmware: arm_ffa: Allow the FF-A drivers to use 32bit mode of messaging ARM: dts: am3517-evm: Fix LED3/4 pinmux clk: scmi: Free scmi_clk allocated when the clocks with invalid info are skipped arm64: dts: imx8qm-ss-img: Fix jpegenc compatible entry arm64: dts: imx8mm: Add sound-dai-cells to micfil node arm64: dts: imx8mn: Add sound-dai-cells to micfil node arm64: tegra: Use correct interrupts for Tegra234 TKE selftests/pidfd: Fix ksft print formats selftests/resctrl: Ensure the benchmark commands fits to its array module/decompress: use vmalloc() for gzip decompression workspace ASoC: cs35l41: Verify PM runtime resume errors in IRQ handler ASoC: cs35l41: Undo runtime PM changes at driver exit time ALSA: hda: cs35l41: Fix unbalanced pm_runtime_get() ALSA: hda: cs35l41: Undo runtime PM changes at driver exit time KEYS: Include linux/errno.h in linux/verification.h crypto: hisilicon/hpre - Fix a erroneous check after snprintf() hwrng: bcm2835 - Fix hwrng throughput regression hwrng: geode - fix accessing registers RDMA/core: Use size_{add,sub,mul}() in calls to struct_size() crypto: qat - ignore subsequent state up commands crypto: qat - relocate bufferlist logic crypto: qat - rename bufferlist functions crypto: qat - change bufferlist logic interface crypto: qat - generalize crypto request buffers crypto: qat - extend buffer list interface crypto: qat - fix unregistration of crypto algorithms scsi: ibmvfc: Fix erroneous use of rtas_busy_delay with hcall return code libnvdimm/of_pmem: Use devm_kstrdup instead of kstrdup and check its return value nd_btt: Make BTT lanes preemptible crypto: caam/qi2 - fix Chacha20 + Poly1305 self test failure crypto: caam/jr - fix Chacha20 + Poly1305 self test failure crypto: qat - increase size of buffers PCI: vmd: Correct PCI Header Type Register's multi-function check hid: cp2112: Fix duplicate workqueue initialization crypto: hisilicon/qm - delete redundant null assignment operations crypto: hisilicon/qm - modify the process of regs dfx crypto: hisilicon/qm - split a debugfs.c from qm crypto: hisilicon/qm - fix PF queue parameter issue ARM: 9321/1: memset: cast the constant byte to unsigned char ext4: move 'ix' sanity check to corrent position ASoC: fsl: mpc5200_dma.c: Fix warning of Function parameter or member not described IB/mlx5: Fix rdma counter binding for RAW QP RDMA/hns: Fix printing level of asynchronous events RDMA/hns: Fix uninitialized ucmd in hns_roce_create_qp_common() RDMA/hns: Fix signed-unsigned mixed comparisons RDMA/hns: Add check for SL RDMA/hns: The UD mode can only be configured with DCQCN ASoC: SOF: core: Ensure sof_ops_free() is still called when probe never ran. ASoC: fsl: Fix PM disable depth imbalance in fsl_easrc_probe scsi: ufs: core: Leave space for '\0' in utf8 desc string RDMA/hfi1: Workaround truncation compilation error HID: cp2112: Make irq_chip immutable hid: cp2112: Fix IRQ shutdown stopping polling for all IRQs on chip sh: bios: Revive earlyprintk support Revert "HID: logitech-hidpp: add a module parameter to keep firmware gestures" HID: logitech-hidpp: Remove HIDPP_QUIRK_NO_HIDINPUT quirk HID: logitech-hidpp: Don't restart IO, instead defer hid_connect() only HID: logitech-hidpp: Revert "Don't restart communication if not necessary" HID: logitech-hidpp: Move get_wireless_feature_index() check to hidpp_connect_event() ASoC: Intel: Skylake: Fix mem leak when parsing UUIDs fails padata: Fix refcnt handling in padata_free_shell() crypto: qat - fix deadlock in backlog processing ASoC: ams-delta.c: use component after check IB/mlx5: Fix init stage error handling to avoid double free of same QP and UAF mfd: core: Un-constify mfd_cell.of_reg mfd: core: Ensure disabled devices are skipped without aborting mfd: dln2: Fix double put in dln2_probe dt-bindings: mfd: mt6397: Add binding for MT6357 dt-bindings: mfd: mt6397: Split out compatible for MediaTek MT6366 PMIC mfd: arizona-spi: Set pdata.hpdet_channel for ACPI enumerated devs leds: turris-omnia: Drop unnecessary mutex locking leds: turris-omnia: Do not use SMBUS calls leds: pwm: Don't disable the PWM when the LED should be off leds: trigger: ledtrig-cpu:: Fix 'output may be truncated' issue for 'cpu' kunit: add macro to allow conditionally exposing static symbols to tests apparmor: test: make static symbols visible during kunit testing apparmor: fix invalid reference on profile->disconnected perf stat: Fix aggr mode initialization iio: frequency: adf4350: Use device managed functions and fix power down issue. perf kwork: Fix incorrect and missing free atom in work_push_atom() perf kwork: Add the supported subcommands to the document perf kwork: Set ordered_events to true in 'struct perf_tool' filemap: add filemap_get_folios_tag() f2fs: convert f2fs_write_cache_pages() to use filemap_get_folios_tag() f2fs: compress: fix deadloop in f2fs_write_cache_pages() f2fs: compress: fix to avoid use-after-free on dic f2fs: compress: fix to avoid redundant compress extension tty: tty_jobctrl: fix pid memleak in disassociate_ctty() livepatch: Fix missing newline character in klp_resolve_symbols() pinctrl: renesas: rzg2l: Make reverse order of enable() for disable() perf record: Fix BTF type checks in the off-cpu profiling dmaengine: idxd: Register dsa_bus_type before registering idxd sub-drivers usb: dwc2: fix possible NULL pointer dereference caused by driver concurrency usb: chipidea: Fix DMA overwrite for Tegra usb: chipidea: Simplify Tegra DMA alignment code dmaengine: ti: edma: handle irq_of_parse_and_map() errors misc: st_core: Do not call kfree_skb() under spin_lock_irqsave() tools: iio: iio_generic_buffer ensure alignment USB: usbip: fix stub_dev hub disconnect dmaengine: pxa_dma: Remove an erroneous BUG_ON() in pxad_free_desc() f2fs: fix to initialize map.m_pblk in f2fs_precache_extents() interconnect: qcom: sc7180: Retire DEFINE_QBCM interconnect: qcom: sc7180: Set ACV enable_mask interconnect: qcom: sc7280: Set ACV enable_mask interconnect: qcom: sc8180x: Set ACV enable_mask interconnect: qcom: sc8280xp: Set ACV enable_mask interconnect: qcom: sdm845: Retire DEFINE_QBCM interconnect: qcom: sdm845: Set ACV enable_mask interconnect: qcom: sm6350: Retire DEFINE_QBCM interconnect: qcom: sm6350: Set ACV enable_mask interconnect: move ignore_list out of of_count_icc_providers() interconnect: qcom: sm8150: Drop IP0 interconnects interconnect: qcom: sm8150: Retire DEFINE_QBCM interconnect: qcom: sm8150: Set ACV enable_mask interconnect: qcom: sm8350: Retire DEFINE_QBCM interconnect: qcom: sm8350: Set ACV enable_mask powerpc: Only define __parse_fpscr() when required modpost: fix tee MODULE_DEVICE_TABLE built on big-endian host modpost: fix ishtp MODULE_DEVICE_TABLE built on big-endian host powerpc/40x: Remove stale PTE_ATOMIC_UPDATES macro powerpc/xive: Fix endian conversion size powerpc/vas: Limit open window failure messages in log bufffer powerpc/imc-pmu: Use the correct spinlock initializer. powerpc/pseries: fix potential memory leak in init_cpu_associativity() xhci: Loosen RPM as default policy to cover for AMD xHC 1.1 usb: host: xhci-plat: fix possible kernel oops while resuming perf machine: Avoid out of bounds LBR memory read perf hist: Add missing puts to hist__account_cycles 9p/net: fix possible memory leak in p9_check_errors() i3c: Fix potential refcount leak in i3c_master_register_new_i3c_devs cxl/mem: Fix shutdown order crypto: ccp - Name -1 return value as SEV_RET_NO_FW_CALL x86/sev: Change snp_guest_issue_request()'s fw_err argument virt: sevguest: Fix passing a stack buffer as a scatterlist target rtc: pcf85363: fix wrong mask/val parameters in regmap_update_bits call pcmcia: cs: fix possible hung task and memory leak pccardd() pcmcia: ds: fix refcount leak in pcmcia_device_add() pcmcia: ds: fix possible name leak in error path in pcmcia_device_add() media: hantro: Check whether reset op is defined before use media: verisilicon: Do not enable G2 postproc downscale if source is narrower than destination media: ov5640: Drop dead code using frame_interval media: ov5640: fix vblank unchange issue when work at dvp mode media: i2c: max9286: Fix some redundant of_node_put() calls media: ov5640: Fix a memory leak when ov5640_probe fails media: bttv: fix use after free error due to btv->timeout timer media: amphion: handle firmware debug message media: mtk-jpegenc: Fix bug in JPEG encode quality selection media: s3c-camif: Avoid inappropriate kfree() media: vidtv: psi: Add check for kstrdup media: vidtv: mux: Add check and kfree for kstrdup media: cedrus: Fix clock/reset sequence media: cadence: csi2rx: Unregister v4l2 async notifier media: dvb-usb-v2: af9035: fix missing unlock media: cec: meson: always include meson sub-directory in Makefile regmap: prevent noinc writes from clobbering cache pwm: sti: Reduce number of allocations and drop usage of chip_data pwm: brcmstb: Utilize appropriate clock APIs in suspend/resume Input: synaptics-rmi4 - fix use after free in rmi_unregister_function() watchdog: ixp4xx: Make sure restart always works llc: verify mac len before reading mac header hsr: Prevent use after free in prp_create_tagged_frame() tipc: Change nla_policy for bearer-related names to NLA_NUL_STRING bpf: Check map->usercnt after timer->timer is assigned inet: shrink struct flowi_common octeontx2-pf: Fix error codes octeontx2-pf: Fix holes in error code net: page_pool: add missing free_percpu when page_pool_init fail dccp: Call security_inet_conn_request() after setting IPv4 addresses. dccp/tcp: Call security_inet_conn_request() after setting IPv6 addresses. net: r8169: Disable multicast filter for RTL8168H and RTL8107E Fix termination state for idr_for_each_entry_ul() net: stmmac: xgmac: Enable support for multiple Flexible PPS outputs selftests: pmtu.sh: fix result checking octeontx2-pf: Rename tot_tx_queues to non_qos_queues octeontx2-pf: qos send queues management octeontx2-pf: Free pending and dropped SQEs net/smc: fix dangling sock under state SMC_APPFINCLOSEWAIT net/smc: allow cdc msg send rather than drop it with NULL sndbuf_desc net/smc: put sk reference if close work was canceled nvme: fix error-handling for io_uring nvme-passthrough tg3: power down device only on SYSTEM_POWER_OFF nbd: fix uaf in nbd_open blk-core: use pr_warn_ratelimited() in bio_check_ro() virtio/vsock: replace virtio_vsock_pkt with sk_buff vsock/virtio: remove socket from connected/bound list on shutdown r8169: respect userspace disabling IFF_MULTICAST i2c: iproc: handle invalid slave state netfilter: xt_recent: fix (increase) ipv6 literal buffer length netfilter: nft_redir: use `struct nf_nat_range2` throughout and deduplicate eval call-backs netfilter: nat: fix ipv6 nat redirect with mapped and scoped addresses RISC-V: Don't fail in riscv_of_parent_hartid() for disabled HARTs drm/syncobj: fix DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE ASoC: mediatek: mt8186_mt6366_rt1019_rt5682s: trivial: fix error messages ASoC: hdmi-codec: register hpd callback on component probe ASoC: dapm: fix clock get name spi: spi-zynq-qspi: add spi-mem to driver kconfig dependencies fbdev: imsttfb: Fix error path of imsttfb_probe() fbdev: imsttfb: fix a resource leak in probe fbdev: fsl-diu-fb: mark wr_reg_wa() static tracing/kprobes: Fix the order of argument descriptions io_uring/net: ensure socket is marked connected on connect retry x86/amd_nb: Use Family 19h Models 60h-7Fh Function 4 IDs Revert "mmc: core: Capture correct oemid-bits for eMMC cards" btrfs: use u64 for buffer sizes in the tree search ioctls wifi: cfg80211: fix kernel-doc for wiphy_delayed_work_flush() virtio/vsock: don't use skbuff state to account credit virtio/vsock: remove redundant 'skb_pull()' call virtio/vsock: don't drop skbuff on copy failure vsock/loopback: use only sk_buff_head.lock to protect the packet queue virtio/vsock: fix leaks due to missing skb owner virtio/vsock: Fix uninit-value in virtio_transport_recv_pkt() virtio/vsock: fix header length on skb merging Linux 6.1.63 Change-Id: I87b7a539b11c90cfaf16edb07d613f74d54458a4 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
1101 lines
29 KiB
C
1101 lines
29 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* net/dccp/ipv4.c
|
|
*
|
|
* An implementation of the DCCP protocol
|
|
* Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
|
*/
|
|
|
|
#include <linux/dccp.h>
|
|
#include <linux/icmp.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/module.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/random.h>
|
|
|
|
#include <net/icmp.h>
|
|
#include <net/inet_common.h>
|
|
#include <net/inet_hashtables.h>
|
|
#include <net/inet_sock.h>
|
|
#include <net/protocol.h>
|
|
#include <net/sock.h>
|
|
#include <net/timewait_sock.h>
|
|
#include <net/tcp_states.h>
|
|
#include <net/xfrm.h>
|
|
#include <net/secure_seq.h>
|
|
#include <net/netns/generic.h>
|
|
|
|
#include "ackvec.h"
|
|
#include "ccid.h"
|
|
#include "dccp.h"
|
|
#include "feat.h"
|
|
|
|
struct dccp_v4_pernet {
|
|
struct sock *v4_ctl_sk;
|
|
};
|
|
|
|
static unsigned int dccp_v4_pernet_id __read_mostly;
|
|
|
|
/*
|
|
* The per-net v4_ctl_sk socket is used for responding to
|
|
* the Out-of-the-blue (OOTB) packets. A control sock will be created
|
|
* for this socket at the initialization time.
|
|
*/
|
|
|
|
int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
|
|
{
|
|
const struct sockaddr_in *usin = (struct sockaddr_in *)uaddr;
|
|
struct inet_sock *inet = inet_sk(sk);
|
|
struct dccp_sock *dp = dccp_sk(sk);
|
|
__be16 orig_sport, orig_dport;
|
|
__be32 daddr, nexthop;
|
|
struct flowi4 *fl4;
|
|
struct rtable *rt;
|
|
int err;
|
|
struct ip_options_rcu *inet_opt;
|
|
|
|
dp->dccps_role = DCCP_ROLE_CLIENT;
|
|
|
|
if (addr_len < sizeof(struct sockaddr_in))
|
|
return -EINVAL;
|
|
|
|
if (usin->sin_family != AF_INET)
|
|
return -EAFNOSUPPORT;
|
|
|
|
nexthop = daddr = usin->sin_addr.s_addr;
|
|
|
|
inet_opt = rcu_dereference_protected(inet->inet_opt,
|
|
lockdep_sock_is_held(sk));
|
|
if (inet_opt != NULL && inet_opt->opt.srr) {
|
|
if (daddr == 0)
|
|
return -EINVAL;
|
|
nexthop = inet_opt->opt.faddr;
|
|
}
|
|
|
|
orig_sport = inet->inet_sport;
|
|
orig_dport = usin->sin_port;
|
|
fl4 = &inet->cork.fl.u.ip4;
|
|
rt = ip_route_connect(fl4, nexthop, inet->inet_saddr,
|
|
sk->sk_bound_dev_if, IPPROTO_DCCP, orig_sport,
|
|
orig_dport, sk);
|
|
if (IS_ERR(rt))
|
|
return PTR_ERR(rt);
|
|
|
|
if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
|
|
ip_rt_put(rt);
|
|
return -ENETUNREACH;
|
|
}
|
|
|
|
if (inet_opt == NULL || !inet_opt->opt.srr)
|
|
daddr = fl4->daddr;
|
|
|
|
if (inet->inet_saddr == 0) {
|
|
err = inet_bhash2_update_saddr(sk, &fl4->saddr, AF_INET);
|
|
if (err) {
|
|
ip_rt_put(rt);
|
|
return err;
|
|
}
|
|
} else {
|
|
sk_rcv_saddr_set(sk, inet->inet_saddr);
|
|
}
|
|
|
|
inet->inet_dport = usin->sin_port;
|
|
sk_daddr_set(sk, daddr);
|
|
|
|
inet_csk(sk)->icsk_ext_hdr_len = 0;
|
|
if (inet_opt)
|
|
inet_csk(sk)->icsk_ext_hdr_len = inet_opt->opt.optlen;
|
|
/*
|
|
* Socket identity is still unknown (sport may be zero).
|
|
* However we set state to DCCP_REQUESTING and not releasing socket
|
|
* lock select source port, enter ourselves into the hash tables and
|
|
* complete initialization after this.
|
|
*/
|
|
dccp_set_state(sk, DCCP_REQUESTING);
|
|
err = inet_hash_connect(&dccp_death_row, sk);
|
|
if (err != 0)
|
|
goto failure;
|
|
|
|
rt = ip_route_newports(fl4, rt, orig_sport, orig_dport,
|
|
inet->inet_sport, inet->inet_dport, sk);
|
|
if (IS_ERR(rt)) {
|
|
err = PTR_ERR(rt);
|
|
rt = NULL;
|
|
goto failure;
|
|
}
|
|
/* OK, now commit destination to socket. */
|
|
sk_setup_caps(sk, &rt->dst);
|
|
|
|
dp->dccps_iss = secure_dccp_sequence_number(inet->inet_saddr,
|
|
inet->inet_daddr,
|
|
inet->inet_sport,
|
|
inet->inet_dport);
|
|
inet->inet_id = get_random_u16();
|
|
|
|
err = dccp_connect(sk);
|
|
rt = NULL;
|
|
if (err != 0)
|
|
goto failure;
|
|
out:
|
|
return err;
|
|
failure:
|
|
/*
|
|
* This unhashes the socket and releases the local port, if necessary.
|
|
*/
|
|
dccp_set_state(sk, DCCP_CLOSED);
|
|
inet_bhash2_reset_saddr(sk);
|
|
ip_rt_put(rt);
|
|
sk->sk_route_caps = 0;
|
|
inet->inet_dport = 0;
|
|
goto out;
|
|
}
|
|
EXPORT_SYMBOL_GPL(dccp_v4_connect);
|
|
|
|
/*
|
|
* This routine does path mtu discovery as defined in RFC1191.
|
|
*/
|
|
static inline void dccp_do_pmtu_discovery(struct sock *sk,
|
|
const struct iphdr *iph,
|
|
u32 mtu)
|
|
{
|
|
struct dst_entry *dst;
|
|
const struct inet_sock *inet = inet_sk(sk);
|
|
const struct dccp_sock *dp = dccp_sk(sk);
|
|
|
|
/* We are not interested in DCCP_LISTEN and request_socks (RESPONSEs
|
|
* send out by Linux are always < 576bytes so they should go through
|
|
* unfragmented).
|
|
*/
|
|
if (sk->sk_state == DCCP_LISTEN)
|
|
return;
|
|
|
|
dst = inet_csk_update_pmtu(sk, mtu);
|
|
if (!dst)
|
|
return;
|
|
|
|
/* Something is about to be wrong... Remember soft error
|
|
* for the case, if this connection will not able to recover.
|
|
*/
|
|
if (mtu < dst_mtu(dst) && ip_dont_fragment(sk, dst))
|
|
sk->sk_err_soft = EMSGSIZE;
|
|
|
|
mtu = dst_mtu(dst);
|
|
|
|
if (inet->pmtudisc != IP_PMTUDISC_DONT &&
|
|
ip_sk_accept_pmtu(sk) &&
|
|
inet_csk(sk)->icsk_pmtu_cookie > mtu) {
|
|
dccp_sync_mss(sk, mtu);
|
|
|
|
/*
|
|
* From RFC 4340, sec. 14.1:
|
|
*
|
|
* DCCP-Sync packets are the best choice for upward
|
|
* probing, since DCCP-Sync probes do not risk application
|
|
* data loss.
|
|
*/
|
|
dccp_send_sync(sk, dp->dccps_gsr, DCCP_PKT_SYNC);
|
|
} /* else let the usual retransmit timer handle it */
|
|
}
|
|
|
|
static void dccp_do_redirect(struct sk_buff *skb, struct sock *sk)
|
|
{
|
|
struct dst_entry *dst = __sk_dst_check(sk, 0);
|
|
|
|
if (dst)
|
|
dst->ops->redirect(dst, sk, skb);
|
|
}
|
|
|
|
void dccp_req_err(struct sock *sk, u64 seq)
|
|
{
|
|
struct request_sock *req = inet_reqsk(sk);
|
|
struct net *net = sock_net(sk);
|
|
|
|
/*
|
|
* ICMPs are not backlogged, hence we cannot get an established
|
|
* socket here.
|
|
*/
|
|
if (!between48(seq, dccp_rsk(req)->dreq_iss, dccp_rsk(req)->dreq_gss)) {
|
|
__NET_INC_STATS(net, LINUX_MIB_OUTOFWINDOWICMPS);
|
|
} else {
|
|
/*
|
|
* Still in RESPOND, just remove it silently.
|
|
* There is no good way to pass the error to the newly
|
|
* created socket, and POSIX does not want network
|
|
* errors returned from accept().
|
|
*/
|
|
inet_csk_reqsk_queue_drop(req->rsk_listener, req);
|
|
}
|
|
reqsk_put(req);
|
|
}
|
|
EXPORT_SYMBOL(dccp_req_err);
|
|
|
|
/*
|
|
* This routine is called by the ICMP module when it gets some sort of error
|
|
* condition. If err < 0 then the socket should be closed and the error
|
|
* returned to the user. If err > 0 it's just the icmp type << 8 | icmp code.
|
|
* After adjustment header points to the first 8 bytes of the tcp header. We
|
|
* need to find the appropriate port.
|
|
*
|
|
* The locking strategy used here is very "optimistic". When someone else
|
|
* accesses the socket the ICMP is just dropped and for some paths there is no
|
|
* check at all. A more general error queue to queue errors for later handling
|
|
* is probably better.
|
|
*/
|
|
static int dccp_v4_err(struct sk_buff *skb, u32 info)
|
|
{
|
|
const struct iphdr *iph = (struct iphdr *)skb->data;
|
|
const u8 offset = iph->ihl << 2;
|
|
const struct dccp_hdr *dh;
|
|
struct dccp_sock *dp;
|
|
struct inet_sock *inet;
|
|
const int type = icmp_hdr(skb)->type;
|
|
const int code = icmp_hdr(skb)->code;
|
|
struct sock *sk;
|
|
__u64 seq;
|
|
int err;
|
|
struct net *net = dev_net(skb->dev);
|
|
|
|
if (!pskb_may_pull(skb, offset + sizeof(*dh)))
|
|
return -EINVAL;
|
|
dh = (struct dccp_hdr *)(skb->data + offset);
|
|
if (!pskb_may_pull(skb, offset + __dccp_basic_hdr_len(dh)))
|
|
return -EINVAL;
|
|
iph = (struct iphdr *)skb->data;
|
|
dh = (struct dccp_hdr *)(skb->data + offset);
|
|
|
|
sk = __inet_lookup_established(net, &dccp_hashinfo,
|
|
iph->daddr, dh->dccph_dport,
|
|
iph->saddr, ntohs(dh->dccph_sport),
|
|
inet_iif(skb), 0);
|
|
if (!sk) {
|
|
__ICMP_INC_STATS(net, ICMP_MIB_INERRORS);
|
|
return -ENOENT;
|
|
}
|
|
|
|
if (sk->sk_state == DCCP_TIME_WAIT) {
|
|
inet_twsk_put(inet_twsk(sk));
|
|
return 0;
|
|
}
|
|
seq = dccp_hdr_seq(dh);
|
|
if (sk->sk_state == DCCP_NEW_SYN_RECV) {
|
|
dccp_req_err(sk, seq);
|
|
return 0;
|
|
}
|
|
|
|
bh_lock_sock(sk);
|
|
/* If too many ICMPs get dropped on busy
|
|
* servers this needs to be solved differently.
|
|
*/
|
|
if (sock_owned_by_user(sk))
|
|
__NET_INC_STATS(net, LINUX_MIB_LOCKDROPPEDICMPS);
|
|
|
|
if (sk->sk_state == DCCP_CLOSED)
|
|
goto out;
|
|
|
|
dp = dccp_sk(sk);
|
|
if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_LISTEN) &&
|
|
!between48(seq, dp->dccps_awl, dp->dccps_awh)) {
|
|
__NET_INC_STATS(net, LINUX_MIB_OUTOFWINDOWICMPS);
|
|
goto out;
|
|
}
|
|
|
|
switch (type) {
|
|
case ICMP_REDIRECT:
|
|
if (!sock_owned_by_user(sk))
|
|
dccp_do_redirect(skb, sk);
|
|
goto out;
|
|
case ICMP_SOURCE_QUENCH:
|
|
/* Just silently ignore these. */
|
|
goto out;
|
|
case ICMP_PARAMETERPROB:
|
|
err = EPROTO;
|
|
break;
|
|
case ICMP_DEST_UNREACH:
|
|
if (code > NR_ICMP_UNREACH)
|
|
goto out;
|
|
|
|
if (code == ICMP_FRAG_NEEDED) { /* PMTU discovery (RFC1191) */
|
|
if (!sock_owned_by_user(sk))
|
|
dccp_do_pmtu_discovery(sk, iph, info);
|
|
goto out;
|
|
}
|
|
|
|
err = icmp_err_convert[code].errno;
|
|
break;
|
|
case ICMP_TIME_EXCEEDED:
|
|
err = EHOSTUNREACH;
|
|
break;
|
|
default:
|
|
goto out;
|
|
}
|
|
|
|
switch (sk->sk_state) {
|
|
case DCCP_REQUESTING:
|
|
case DCCP_RESPOND:
|
|
if (!sock_owned_by_user(sk)) {
|
|
__DCCP_INC_STATS(DCCP_MIB_ATTEMPTFAILS);
|
|
sk->sk_err = err;
|
|
|
|
sk_error_report(sk);
|
|
|
|
dccp_done(sk);
|
|
} else
|
|
sk->sk_err_soft = err;
|
|
goto out;
|
|
}
|
|
|
|
/* If we've already connected we will keep trying
|
|
* until we time out, or the user gives up.
|
|
*
|
|
* rfc1122 4.2.3.9 allows to consider as hard errors
|
|
* only PROTO_UNREACH and PORT_UNREACH (well, FRAG_FAILED too,
|
|
* but it is obsoleted by pmtu discovery).
|
|
*
|
|
* Note, that in modern internet, where routing is unreliable
|
|
* and in each dark corner broken firewalls sit, sending random
|
|
* errors ordered by their masters even this two messages finally lose
|
|
* their original sense (even Linux sends invalid PORT_UNREACHs)
|
|
*
|
|
* Now we are in compliance with RFCs.
|
|
* --ANK (980905)
|
|
*/
|
|
|
|
inet = inet_sk(sk);
|
|
if (!sock_owned_by_user(sk) && inet->recverr) {
|
|
sk->sk_err = err;
|
|
sk_error_report(sk);
|
|
} else /* Only an error on timeout */
|
|
sk->sk_err_soft = err;
|
|
out:
|
|
bh_unlock_sock(sk);
|
|
sock_put(sk);
|
|
return 0;
|
|
}
|
|
|
|
static inline __sum16 dccp_v4_csum_finish(struct sk_buff *skb,
|
|
__be32 src, __be32 dst)
|
|
{
|
|
return csum_tcpudp_magic(src, dst, skb->len, IPPROTO_DCCP, skb->csum);
|
|
}
|
|
|
|
void dccp_v4_send_check(struct sock *sk, struct sk_buff *skb)
|
|
{
|
|
const struct inet_sock *inet = inet_sk(sk);
|
|
struct dccp_hdr *dh = dccp_hdr(skb);
|
|
|
|
dccp_csum_outgoing(skb);
|
|
dh->dccph_checksum = dccp_v4_csum_finish(skb,
|
|
inet->inet_saddr,
|
|
inet->inet_daddr);
|
|
}
|
|
EXPORT_SYMBOL_GPL(dccp_v4_send_check);
|
|
|
|
static inline u64 dccp_v4_init_sequence(const struct sk_buff *skb)
|
|
{
|
|
return secure_dccp_sequence_number(ip_hdr(skb)->daddr,
|
|
ip_hdr(skb)->saddr,
|
|
dccp_hdr(skb)->dccph_dport,
|
|
dccp_hdr(skb)->dccph_sport);
|
|
}
|
|
|
|
/*
|
|
* The three way handshake has completed - we got a valid ACK or DATAACK -
|
|
* now create the new socket.
|
|
*
|
|
* This is the equivalent of TCP's tcp_v4_syn_recv_sock
|
|
*/
|
|
struct sock *dccp_v4_request_recv_sock(const struct sock *sk,
|
|
struct sk_buff *skb,
|
|
struct request_sock *req,
|
|
struct dst_entry *dst,
|
|
struct request_sock *req_unhash,
|
|
bool *own_req)
|
|
{
|
|
struct inet_request_sock *ireq;
|
|
struct inet_sock *newinet;
|
|
struct sock *newsk;
|
|
|
|
if (sk_acceptq_is_full(sk))
|
|
goto exit_overflow;
|
|
|
|
newsk = dccp_create_openreq_child(sk, req, skb);
|
|
if (newsk == NULL)
|
|
goto exit_nonewsk;
|
|
|
|
newinet = inet_sk(newsk);
|
|
ireq = inet_rsk(req);
|
|
sk_daddr_set(newsk, ireq->ir_rmt_addr);
|
|
sk_rcv_saddr_set(newsk, ireq->ir_loc_addr);
|
|
newinet->inet_saddr = ireq->ir_loc_addr;
|
|
RCU_INIT_POINTER(newinet->inet_opt, rcu_dereference(ireq->ireq_opt));
|
|
newinet->mc_index = inet_iif(skb);
|
|
newinet->mc_ttl = ip_hdr(skb)->ttl;
|
|
newinet->inet_id = get_random_u16();
|
|
|
|
if (dst == NULL && (dst = inet_csk_route_child_sock(sk, newsk, req)) == NULL)
|
|
goto put_and_exit;
|
|
|
|
sk_setup_caps(newsk, dst);
|
|
|
|
dccp_sync_mss(newsk, dst_mtu(dst));
|
|
|
|
if (__inet_inherit_port(sk, newsk) < 0)
|
|
goto put_and_exit;
|
|
*own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash), NULL);
|
|
if (*own_req)
|
|
ireq->ireq_opt = NULL;
|
|
else
|
|
newinet->inet_opt = NULL;
|
|
return newsk;
|
|
|
|
exit_overflow:
|
|
__NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);
|
|
exit_nonewsk:
|
|
dst_release(dst);
|
|
exit:
|
|
__NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENDROPS);
|
|
return NULL;
|
|
put_and_exit:
|
|
newinet->inet_opt = NULL;
|
|
inet_csk_prepare_forced_close(newsk);
|
|
dccp_done(newsk);
|
|
goto exit;
|
|
}
|
|
EXPORT_SYMBOL_GPL(dccp_v4_request_recv_sock);
|
|
|
|
static struct dst_entry* dccp_v4_route_skb(struct net *net, struct sock *sk,
|
|
struct sk_buff *skb)
|
|
{
|
|
struct rtable *rt;
|
|
const struct iphdr *iph = ip_hdr(skb);
|
|
struct flowi4 fl4 = {
|
|
.flowi4_oif = inet_iif(skb),
|
|
.daddr = iph->saddr,
|
|
.saddr = iph->daddr,
|
|
.flowi4_tos = RT_CONN_FLAGS(sk),
|
|
.flowi4_proto = sk->sk_protocol,
|
|
.fl4_sport = dccp_hdr(skb)->dccph_dport,
|
|
.fl4_dport = dccp_hdr(skb)->dccph_sport,
|
|
};
|
|
|
|
security_skb_classify_flow(skb, flowi4_to_flowi_common(&fl4));
|
|
rt = ip_route_output_flow(net, &fl4, sk);
|
|
if (IS_ERR(rt)) {
|
|
IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES);
|
|
return NULL;
|
|
}
|
|
|
|
return &rt->dst;
|
|
}
|
|
|
|
static int dccp_v4_send_response(const struct sock *sk, struct request_sock *req)
|
|
{
|
|
int err = -1;
|
|
struct sk_buff *skb;
|
|
struct dst_entry *dst;
|
|
struct flowi4 fl4;
|
|
|
|
dst = inet_csk_route_req(sk, &fl4, req);
|
|
if (dst == NULL)
|
|
goto out;
|
|
|
|
skb = dccp_make_response(sk, dst, req);
|
|
if (skb != NULL) {
|
|
const struct inet_request_sock *ireq = inet_rsk(req);
|
|
struct dccp_hdr *dh = dccp_hdr(skb);
|
|
|
|
dh->dccph_checksum = dccp_v4_csum_finish(skb, ireq->ir_loc_addr,
|
|
ireq->ir_rmt_addr);
|
|
rcu_read_lock();
|
|
err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr,
|
|
ireq->ir_rmt_addr,
|
|
rcu_dereference(ireq->ireq_opt),
|
|
inet_sk(sk)->tos);
|
|
rcu_read_unlock();
|
|
err = net_xmit_eval(err);
|
|
}
|
|
|
|
out:
|
|
dst_release(dst);
|
|
return err;
|
|
}
|
|
|
|
static void dccp_v4_ctl_send_reset(const struct sock *sk, struct sk_buff *rxskb)
|
|
{
|
|
int err;
|
|
const struct iphdr *rxiph;
|
|
struct sk_buff *skb;
|
|
struct dst_entry *dst;
|
|
struct net *net = dev_net(skb_dst(rxskb)->dev);
|
|
struct dccp_v4_pernet *pn;
|
|
struct sock *ctl_sk;
|
|
|
|
/* Never send a reset in response to a reset. */
|
|
if (dccp_hdr(rxskb)->dccph_type == DCCP_PKT_RESET)
|
|
return;
|
|
|
|
if (skb_rtable(rxskb)->rt_type != RTN_LOCAL)
|
|
return;
|
|
|
|
pn = net_generic(net, dccp_v4_pernet_id);
|
|
ctl_sk = pn->v4_ctl_sk;
|
|
dst = dccp_v4_route_skb(net, ctl_sk, rxskb);
|
|
if (dst == NULL)
|
|
return;
|
|
|
|
skb = dccp_ctl_make_reset(ctl_sk, rxskb);
|
|
if (skb == NULL)
|
|
goto out;
|
|
|
|
rxiph = ip_hdr(rxskb);
|
|
dccp_hdr(skb)->dccph_checksum = dccp_v4_csum_finish(skb, rxiph->saddr,
|
|
rxiph->daddr);
|
|
skb_dst_set(skb, dst_clone(dst));
|
|
|
|
local_bh_disable();
|
|
bh_lock_sock(ctl_sk);
|
|
err = ip_build_and_send_pkt(skb, ctl_sk,
|
|
rxiph->daddr, rxiph->saddr, NULL,
|
|
inet_sk(ctl_sk)->tos);
|
|
bh_unlock_sock(ctl_sk);
|
|
|
|
if (net_xmit_eval(err) == 0) {
|
|
__DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
|
|
__DCCP_INC_STATS(DCCP_MIB_OUTRSTS);
|
|
}
|
|
local_bh_enable();
|
|
out:
|
|
dst_release(dst);
|
|
}
|
|
|
|
static void dccp_v4_reqsk_destructor(struct request_sock *req)
|
|
{
|
|
dccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg);
|
|
kfree(rcu_dereference_protected(inet_rsk(req)->ireq_opt, 1));
|
|
}
|
|
|
|
void dccp_syn_ack_timeout(const struct request_sock *req)
|
|
{
|
|
}
|
|
EXPORT_SYMBOL(dccp_syn_ack_timeout);
|
|
|
|
static struct request_sock_ops dccp_request_sock_ops __read_mostly = {
|
|
.family = PF_INET,
|
|
.obj_size = sizeof(struct dccp_request_sock),
|
|
.rtx_syn_ack = dccp_v4_send_response,
|
|
.send_ack = dccp_reqsk_send_ack,
|
|
.destructor = dccp_v4_reqsk_destructor,
|
|
.send_reset = dccp_v4_ctl_send_reset,
|
|
.syn_ack_timeout = dccp_syn_ack_timeout,
|
|
};
|
|
|
|
int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
|
|
{
|
|
struct inet_request_sock *ireq;
|
|
struct request_sock *req;
|
|
struct dccp_request_sock *dreq;
|
|
const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
|
|
struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
|
|
|
|
/* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */
|
|
if (skb_rtable(skb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST))
|
|
return 0; /* discard, don't send a reset here */
|
|
|
|
if (dccp_bad_service_code(sk, service)) {
|
|
dcb->dccpd_reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
|
|
goto drop;
|
|
}
|
|
/*
|
|
* TW buckets are converted to open requests without
|
|
* limitations, they conserve resources and peer is
|
|
* evidently real one.
|
|
*/
|
|
dcb->dccpd_reset_code = DCCP_RESET_CODE_TOO_BUSY;
|
|
if (inet_csk_reqsk_queue_is_full(sk))
|
|
goto drop;
|
|
|
|
if (sk_acceptq_is_full(sk))
|
|
goto drop;
|
|
|
|
req = inet_reqsk_alloc(&dccp_request_sock_ops, sk, true);
|
|
if (req == NULL)
|
|
goto drop;
|
|
|
|
if (dccp_reqsk_init(req, dccp_sk(sk), skb))
|
|
goto drop_and_free;
|
|
|
|
dreq = dccp_rsk(req);
|
|
if (dccp_parse_options(sk, dreq, skb))
|
|
goto drop_and_free;
|
|
|
|
ireq = inet_rsk(req);
|
|
sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
|
|
sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
|
|
ireq->ir_mark = inet_request_mark(sk, skb);
|
|
ireq->ireq_family = AF_INET;
|
|
ireq->ir_iif = READ_ONCE(sk->sk_bound_dev_if);
|
|
|
|
if (security_inet_conn_request(sk, skb, req))
|
|
goto drop_and_free;
|
|
|
|
/*
|
|
* Step 3: Process LISTEN state
|
|
*
|
|
* Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
|
|
*
|
|
* Setting S.SWL/S.SWH to is deferred to dccp_create_openreq_child().
|
|
*/
|
|
dreq->dreq_isr = dcb->dccpd_seq;
|
|
dreq->dreq_gsr = dreq->dreq_isr;
|
|
dreq->dreq_iss = dccp_v4_init_sequence(skb);
|
|
dreq->dreq_gss = dreq->dreq_iss;
|
|
dreq->dreq_service = service;
|
|
|
|
if (dccp_v4_send_response(sk, req))
|
|
goto drop_and_free;
|
|
|
|
inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
|
|
reqsk_put(req);
|
|
return 0;
|
|
|
|
drop_and_free:
|
|
reqsk_free(req);
|
|
drop:
|
|
__DCCP_INC_STATS(DCCP_MIB_ATTEMPTFAILS);
|
|
return -1;
|
|
}
|
|
EXPORT_SYMBOL_GPL(dccp_v4_conn_request);
|
|
|
|
int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
|
|
{
|
|
struct dccp_hdr *dh = dccp_hdr(skb);
|
|
|
|
if (sk->sk_state == DCCP_OPEN) { /* Fast path */
|
|
if (dccp_rcv_established(sk, skb, dh, skb->len))
|
|
goto reset;
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Step 3: Process LISTEN state
|
|
* If P.type == Request or P contains a valid Init Cookie option,
|
|
* (* Must scan the packet's options to check for Init
|
|
* Cookies. Only Init Cookies are processed here,
|
|
* however; other options are processed in Step 8. This
|
|
* scan need only be performed if the endpoint uses Init
|
|
* Cookies *)
|
|
* (* Generate a new socket and switch to that socket *)
|
|
* Set S := new socket for this port pair
|
|
* S.state = RESPOND
|
|
* Choose S.ISS (initial seqno) or set from Init Cookies
|
|
* Initialize S.GAR := S.ISS
|
|
* Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookies
|
|
* Continue with S.state == RESPOND
|
|
* (* A Response packet will be generated in Step 11 *)
|
|
* Otherwise,
|
|
* Generate Reset(No Connection) unless P.type == Reset
|
|
* Drop packet and return
|
|
*
|
|
* NOTE: the check for the packet types is done in
|
|
* dccp_rcv_state_process
|
|
*/
|
|
|
|
if (dccp_rcv_state_process(sk, skb, dh, skb->len))
|
|
goto reset;
|
|
return 0;
|
|
|
|
reset:
|
|
dccp_v4_ctl_send_reset(sk, skb);
|
|
kfree_skb(skb);
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(dccp_v4_do_rcv);
|
|
|
|
/**
|
|
* dccp_invalid_packet - check for malformed packets
|
|
* @skb: Packet to validate
|
|
*
|
|
* Implements RFC 4340, 8.5: Step 1: Check header basics
|
|
* Packets that fail these checks are ignored and do not receive Resets.
|
|
*/
|
|
int dccp_invalid_packet(struct sk_buff *skb)
|
|
{
|
|
const struct dccp_hdr *dh;
|
|
unsigned int cscov;
|
|
u8 dccph_doff;
|
|
|
|
if (skb->pkt_type != PACKET_HOST)
|
|
return 1;
|
|
|
|
/* If the packet is shorter than 12 bytes, drop packet and return */
|
|
if (!pskb_may_pull(skb, sizeof(struct dccp_hdr))) {
|
|
DCCP_WARN("pskb_may_pull failed\n");
|
|
return 1;
|
|
}
|
|
|
|
dh = dccp_hdr(skb);
|
|
|
|
/* If P.type is not understood, drop packet and return */
|
|
if (dh->dccph_type >= DCCP_PKT_INVALID) {
|
|
DCCP_WARN("invalid packet type\n");
|
|
return 1;
|
|
}
|
|
|
|
/*
|
|
* If P.Data Offset is too small for packet type, drop packet and return
|
|
*/
|
|
dccph_doff = dh->dccph_doff;
|
|
if (dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) {
|
|
DCCP_WARN("P.Data Offset(%u) too small\n", dccph_doff);
|
|
return 1;
|
|
}
|
|
/*
|
|
* If P.Data Offset is too large for packet, drop packet and return
|
|
*/
|
|
if (!pskb_may_pull(skb, dccph_doff * sizeof(u32))) {
|
|
DCCP_WARN("P.Data Offset(%u) too large\n", dccph_doff);
|
|
return 1;
|
|
}
|
|
dh = dccp_hdr(skb);
|
|
/*
|
|
* If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet
|
|
* has short sequence numbers), drop packet and return
|
|
*/
|
|
if ((dh->dccph_type < DCCP_PKT_DATA ||
|
|
dh->dccph_type > DCCP_PKT_DATAACK) && dh->dccph_x == 0) {
|
|
DCCP_WARN("P.type (%s) not Data || [Data]Ack, while P.X == 0\n",
|
|
dccp_packet_name(dh->dccph_type));
|
|
return 1;
|
|
}
|
|
|
|
/*
|
|
* If P.CsCov is too large for the packet size, drop packet and return.
|
|
* This must come _before_ checksumming (not as RFC 4340 suggests).
|
|
*/
|
|
cscov = dccp_csum_coverage(skb);
|
|
if (cscov > skb->len) {
|
|
DCCP_WARN("P.CsCov %u exceeds packet length %d\n",
|
|
dh->dccph_cscov, skb->len);
|
|
return 1;
|
|
}
|
|
|
|
/* If header checksum is incorrect, drop packet and return.
|
|
* (This step is completed in the AF-dependent functions.) */
|
|
skb->csum = skb_checksum(skb, 0, cscov, 0);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(dccp_invalid_packet);
|
|
|
|
/* this is called when real data arrives */
|
|
static int dccp_v4_rcv(struct sk_buff *skb)
|
|
{
|
|
const struct dccp_hdr *dh;
|
|
const struct iphdr *iph;
|
|
bool refcounted;
|
|
struct sock *sk;
|
|
int min_cov;
|
|
|
|
/* Step 1: Check header basics */
|
|
|
|
if (dccp_invalid_packet(skb))
|
|
goto discard_it;
|
|
|
|
iph = ip_hdr(skb);
|
|
/* Step 1: If header checksum is incorrect, drop packet and return */
|
|
if (dccp_v4_csum_finish(skb, iph->saddr, iph->daddr)) {
|
|
DCCP_WARN("dropped packet with invalid checksum\n");
|
|
goto discard_it;
|
|
}
|
|
|
|
dh = dccp_hdr(skb);
|
|
|
|
DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh);
|
|
DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;
|
|
|
|
dccp_pr_debug("%8.8s src=%pI4@%-5d dst=%pI4@%-5d seq=%llu",
|
|
dccp_packet_name(dh->dccph_type),
|
|
&iph->saddr, ntohs(dh->dccph_sport),
|
|
&iph->daddr, ntohs(dh->dccph_dport),
|
|
(unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq);
|
|
|
|
if (dccp_packet_without_ack(skb)) {
|
|
DCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ;
|
|
dccp_pr_debug_cat("\n");
|
|
} else {
|
|
DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);
|
|
dccp_pr_debug_cat(", ack=%llu\n", (unsigned long long)
|
|
DCCP_SKB_CB(skb)->dccpd_ack_seq);
|
|
}
|
|
|
|
lookup:
|
|
sk = __inet_lookup_skb(&dccp_hashinfo, skb, __dccp_hdr_len(dh),
|
|
dh->dccph_sport, dh->dccph_dport, 0, &refcounted);
|
|
if (!sk) {
|
|
dccp_pr_debug("failed to look up flow ID in table and "
|
|
"get corresponding socket\n");
|
|
goto no_dccp_socket;
|
|
}
|
|
|
|
/*
|
|
* Step 2:
|
|
* ... or S.state == TIMEWAIT,
|
|
* Generate Reset(No Connection) unless P.type == Reset
|
|
* Drop packet and return
|
|
*/
|
|
if (sk->sk_state == DCCP_TIME_WAIT) {
|
|
dccp_pr_debug("sk->sk_state == DCCP_TIME_WAIT: do_time_wait\n");
|
|
inet_twsk_put(inet_twsk(sk));
|
|
goto no_dccp_socket;
|
|
}
|
|
|
|
if (sk->sk_state == DCCP_NEW_SYN_RECV) {
|
|
struct request_sock *req = inet_reqsk(sk);
|
|
struct sock *nsk;
|
|
|
|
sk = req->rsk_listener;
|
|
if (unlikely(sk->sk_state != DCCP_LISTEN)) {
|
|
inet_csk_reqsk_queue_drop_and_put(sk, req);
|
|
goto lookup;
|
|
}
|
|
sock_hold(sk);
|
|
refcounted = true;
|
|
nsk = dccp_check_req(sk, skb, req);
|
|
if (!nsk) {
|
|
reqsk_put(req);
|
|
goto discard_and_relse;
|
|
}
|
|
if (nsk == sk) {
|
|
reqsk_put(req);
|
|
} else if (dccp_child_process(sk, nsk, skb)) {
|
|
dccp_v4_ctl_send_reset(sk, skb);
|
|
goto discard_and_relse;
|
|
} else {
|
|
sock_put(sk);
|
|
return 0;
|
|
}
|
|
}
|
|
/*
|
|
* RFC 4340, sec. 9.2.1: Minimum Checksum Coverage
|
|
* o if MinCsCov = 0, only packets with CsCov = 0 are accepted
|
|
* o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov
|
|
*/
|
|
min_cov = dccp_sk(sk)->dccps_pcrlen;
|
|
if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) {
|
|
dccp_pr_debug("Packet CsCov %d does not satisfy MinCsCov %d\n",
|
|
dh->dccph_cscov, min_cov);
|
|
/* FIXME: "Such packets SHOULD be reported using Data Dropped
|
|
* options (Section 11.7) with Drop Code 0, Protocol
|
|
* Constraints." */
|
|
goto discard_and_relse;
|
|
}
|
|
|
|
if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
|
|
goto discard_and_relse;
|
|
nf_reset_ct(skb);
|
|
|
|
return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4, refcounted);
|
|
|
|
no_dccp_socket:
|
|
if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
|
|
goto discard_it;
|
|
/*
|
|
* Step 2:
|
|
* If no socket ...
|
|
* Generate Reset(No Connection) unless P.type == Reset
|
|
* Drop packet and return
|
|
*/
|
|
if (dh->dccph_type != DCCP_PKT_RESET) {
|
|
DCCP_SKB_CB(skb)->dccpd_reset_code =
|
|
DCCP_RESET_CODE_NO_CONNECTION;
|
|
dccp_v4_ctl_send_reset(sk, skb);
|
|
}
|
|
|
|
discard_it:
|
|
kfree_skb(skb);
|
|
return 0;
|
|
|
|
discard_and_relse:
|
|
if (refcounted)
|
|
sock_put(sk);
|
|
goto discard_it;
|
|
}
|
|
|
|
static const struct inet_connection_sock_af_ops dccp_ipv4_af_ops = {
|
|
.queue_xmit = ip_queue_xmit,
|
|
.send_check = dccp_v4_send_check,
|
|
.rebuild_header = inet_sk_rebuild_header,
|
|
.conn_request = dccp_v4_conn_request,
|
|
.syn_recv_sock = dccp_v4_request_recv_sock,
|
|
.net_header_len = sizeof(struct iphdr),
|
|
.setsockopt = ip_setsockopt,
|
|
.getsockopt = ip_getsockopt,
|
|
.addr2sockaddr = inet_csk_addr2sockaddr,
|
|
.sockaddr_len = sizeof(struct sockaddr_in),
|
|
};
|
|
|
|
static int dccp_v4_init_sock(struct sock *sk)
|
|
{
|
|
static __u8 dccp_v4_ctl_sock_initialized;
|
|
int err = dccp_init_sock(sk, dccp_v4_ctl_sock_initialized);
|
|
|
|
if (err == 0) {
|
|
if (unlikely(!dccp_v4_ctl_sock_initialized))
|
|
dccp_v4_ctl_sock_initialized = 1;
|
|
inet_csk(sk)->icsk_af_ops = &dccp_ipv4_af_ops;
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
static struct timewait_sock_ops dccp_timewait_sock_ops = {
|
|
.twsk_obj_size = sizeof(struct inet_timewait_sock),
|
|
};
|
|
|
|
static struct proto dccp_v4_prot = {
|
|
.name = "DCCP",
|
|
.owner = THIS_MODULE,
|
|
.close = dccp_close,
|
|
.connect = dccp_v4_connect,
|
|
.disconnect = dccp_disconnect,
|
|
.ioctl = dccp_ioctl,
|
|
.init = dccp_v4_init_sock,
|
|
.setsockopt = dccp_setsockopt,
|
|
.getsockopt = dccp_getsockopt,
|
|
.sendmsg = dccp_sendmsg,
|
|
.recvmsg = dccp_recvmsg,
|
|
.backlog_rcv = dccp_v4_do_rcv,
|
|
.hash = inet_hash,
|
|
.unhash = inet_unhash,
|
|
.accept = inet_csk_accept,
|
|
.get_port = inet_csk_get_port,
|
|
.shutdown = dccp_shutdown,
|
|
.destroy = dccp_destroy_sock,
|
|
.orphan_count = &dccp_orphan_count,
|
|
.max_header = MAX_DCCP_HEADER,
|
|
.obj_size = sizeof(struct dccp_sock),
|
|
.slab_flags = SLAB_TYPESAFE_BY_RCU,
|
|
.rsk_prot = &dccp_request_sock_ops,
|
|
.twsk_prot = &dccp_timewait_sock_ops,
|
|
.h.hashinfo = &dccp_hashinfo,
|
|
};
|
|
|
|
static const struct net_protocol dccp_v4_protocol = {
|
|
.handler = dccp_v4_rcv,
|
|
.err_handler = dccp_v4_err,
|
|
.no_policy = 1,
|
|
.icmp_strict_tag_validation = 1,
|
|
};
|
|
|
|
static const struct proto_ops inet_dccp_ops = {
|
|
.family = PF_INET,
|
|
.owner = THIS_MODULE,
|
|
.release = inet_release,
|
|
.bind = inet_bind,
|
|
.connect = inet_stream_connect,
|
|
.socketpair = sock_no_socketpair,
|
|
.accept = inet_accept,
|
|
.getname = inet_getname,
|
|
/* FIXME: work on tcp_poll to rename it to inet_csk_poll */
|
|
.poll = dccp_poll,
|
|
.ioctl = inet_ioctl,
|
|
.gettstamp = sock_gettstamp,
|
|
/* FIXME: work on inet_listen to rename it to sock_common_listen */
|
|
.listen = inet_dccp_listen,
|
|
.shutdown = inet_shutdown,
|
|
.setsockopt = sock_common_setsockopt,
|
|
.getsockopt = sock_common_getsockopt,
|
|
.sendmsg = inet_sendmsg,
|
|
.recvmsg = sock_common_recvmsg,
|
|
.mmap = sock_no_mmap,
|
|
.sendpage = sock_no_sendpage,
|
|
};
|
|
|
|
static struct inet_protosw dccp_v4_protosw = {
|
|
.type = SOCK_DCCP,
|
|
.protocol = IPPROTO_DCCP,
|
|
.prot = &dccp_v4_prot,
|
|
.ops = &inet_dccp_ops,
|
|
.flags = INET_PROTOSW_ICSK,
|
|
};
|
|
|
|
static int __net_init dccp_v4_init_net(struct net *net)
|
|
{
|
|
struct dccp_v4_pernet *pn = net_generic(net, dccp_v4_pernet_id);
|
|
|
|
if (dccp_hashinfo.bhash == NULL)
|
|
return -ESOCKTNOSUPPORT;
|
|
|
|
return inet_ctl_sock_create(&pn->v4_ctl_sk, PF_INET,
|
|
SOCK_DCCP, IPPROTO_DCCP, net);
|
|
}
|
|
|
|
static void __net_exit dccp_v4_exit_net(struct net *net)
|
|
{
|
|
struct dccp_v4_pernet *pn = net_generic(net, dccp_v4_pernet_id);
|
|
|
|
inet_ctl_sock_destroy(pn->v4_ctl_sk);
|
|
}
|
|
|
|
static void __net_exit dccp_v4_exit_batch(struct list_head *net_exit_list)
|
|
{
|
|
inet_twsk_purge(&dccp_hashinfo, AF_INET);
|
|
}
|
|
|
|
static struct pernet_operations dccp_v4_ops = {
|
|
.init = dccp_v4_init_net,
|
|
.exit = dccp_v4_exit_net,
|
|
.exit_batch = dccp_v4_exit_batch,
|
|
.id = &dccp_v4_pernet_id,
|
|
.size = sizeof(struct dccp_v4_pernet),
|
|
};
|
|
|
|
static int __init dccp_v4_init(void)
|
|
{
|
|
int err = proto_register(&dccp_v4_prot, 1);
|
|
|
|
if (err)
|
|
goto out;
|
|
|
|
inet_register_protosw(&dccp_v4_protosw);
|
|
|
|
err = register_pernet_subsys(&dccp_v4_ops);
|
|
if (err)
|
|
goto out_destroy_ctl_sock;
|
|
|
|
err = inet_add_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
|
|
if (err)
|
|
goto out_proto_unregister;
|
|
|
|
out:
|
|
return err;
|
|
out_proto_unregister:
|
|
unregister_pernet_subsys(&dccp_v4_ops);
|
|
out_destroy_ctl_sock:
|
|
inet_unregister_protosw(&dccp_v4_protosw);
|
|
proto_unregister(&dccp_v4_prot);
|
|
goto out;
|
|
}
|
|
|
|
static void __exit dccp_v4_exit(void)
|
|
{
|
|
inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
|
|
unregister_pernet_subsys(&dccp_v4_ops);
|
|
inet_unregister_protosw(&dccp_v4_protosw);
|
|
proto_unregister(&dccp_v4_prot);
|
|
}
|
|
|
|
module_init(dccp_v4_init);
|
|
module_exit(dccp_v4_exit);
|
|
|
|
/*
|
|
* __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33)
|
|
* values directly, Also cover the case where the protocol is not specified,
|
|
* i.e. net-pf-PF_INET-proto-0-type-SOCK_DCCP
|
|
*/
|
|
MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET, 33, 6);
|
|
MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET, 0, 6);
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@mandriva.com>");
|
|
MODULE_DESCRIPTION("DCCP - Datagram Congestion Controlled Protocol");
|