Changes in 6.1.28 ASOC: Intel: sof_sdw: add quirk for Intel 'Rooks County' NUC M15 ASoC: Intel: soc-acpi: add table for Intel 'Rooks County' NUC M15 ASoC: soc-pcm: fix hw->formats cleared by soc_pcm_hw_init() for dpcm x86/hyperv: Block root partition functionality in a Confidential VM ASoC: amd: yc: Add DMI entries to support Victus by HP Laptop 16-e1xxx (8A22) iio: adc: palmas_gpadc: fix NULL dereference on rmmod ASoC: Intel: bytcr_rt5640: Add quirk for the Acer Iconia One 7 B1-750 ASoC: da7213.c: add missing pm_runtime_disable() net: wwan: t7xx: do not compile with -Werror selftests mount: Fix mount_setattr_test builds failed scsi: mpi3mr: Handle soft reset in progress fault code (0xF002) net: sfp: add quirk enabling 2500Base-x for HG MXPD-483II platform/x86: thinkpad_acpi: Add missing T14s Gen1 type to s2idle quirk list wifi: ath11k: reduce the MHI timeout to 20s tracing: Error if a trace event has an array for a __field() asm-generic/io.h: suppress endianness warnings for readq() and writeq() x86/cpu: Add model number for Intel Arrow Lake processor wireguard: timers: cast enum limits members to int in prints wifi: mt76: mt7921e: Set memory space enable in PCI_COMMAND if unset ASoC: amd: fix ACP version typo mistake ASoC: amd: ps: update the acp clock source. arm64: Always load shadow stack pointer directly from the task struct arm64: Stash shadow stack pointer in the task struct on interrupt powerpc/boot: Fix boot wrapper code generation with CONFIG_POWER10_CPU PCI: kirin: Select REGMAP_MMIO PCI: pciehp: Fix AB-BA deadlock between reset_lock and device_lock PCI: qcom: Fix the incorrect register usage in v2.7.0 config phy: qcom-qmp-pcie: sc8180x PCIe PHY has 2 lanes IMA: allow/fix UML builds usb: gadget: udc: core: Invoke usb_gadget_connect only when started usb: gadget: udc: core: Prevent redundant calls to pullup usb: dwc3: gadget: Stall and restart EP0 if host is unresponsive USB: dwc3: fix runtime pm imbalance on probe errors USB: dwc3: fix runtime pm imbalance on unbind hwmon: (k10temp) Check range scale when CUR_TEMP register is read-write hwmon: (adt7475) Use device_property APIs when configuring polarity tpm: Add !tpm_amd_is_rng_defective() to the hwrng_unregister() call site posix-cpu-timers: Implement the missing timer_wait_running callback media: ov8856: Do not check for for module version blk-stat: fix QUEUE_FLAG_STATS clear blk-crypto: don't use struct request_queue for public interfaces blk-crypto: add a blk_crypto_config_supported_natively helper blk-crypto: move internal only declarations to blk-crypto-internal.h blk-crypto: Add a missing include directive blk-mq: release crypto keyslot before reporting I/O complete blk-crypto: make blk_crypto_evict_key() return void blk-crypto: make blk_crypto_evict_key() more robust staging: iio: resolver: ads1210: fix config mode tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH xhci: fix debugfs register accesses while suspended serial: fix TIOCSRS485 locking serial: 8250: Fix serial8250_tx_empty() race with DMA Tx serial: max310x: fix IO data corruption in batched operations tick/nohz: Fix cpu_is_hotpluggable() by checking with nohz subsystem fs: fix sysctls.c built MIPS: fw: Allow firmware to pass a empty env ipmi:ssif: Add send_retries increment ipmi: fix SSIF not responding under certain cond. iio: addac: stx104: Fix race condition when converting analog-to-digital iio: addac: stx104: Fix race condition for stx104_write_raw() kheaders: Use array declaration instead of char wifi: mt76: add missing locking to protect against concurrent rx/status calls pwm: meson: Fix axg ao mux parents pwm: meson: Fix g12a ao clk81 name soundwire: qcom: correct setting ignore bit on v1.5.1 pinctrl: qcom: lpass-lpi: set output value before enabling output ring-buffer: Ensure proper resetting of atomic variables in ring_buffer_reset_online_cpus ring-buffer: Sync IRQ works before buffer destruction crypto: api - Demote BUG_ON() in crypto_unregister_alg() to a WARN_ON() crypto: safexcel - Cleanup ring IRQ workqueues on load failure crypto: arm64/aes-neonbs - fix crash with CFI enabled crypto: ccp - Don't initialize CCP for PSP 0x1649 rcu: Avoid stack overflow due to __rcu_irq_enter_check_tick() being kprobe-ed reiserfs: Add security prefix to xattr name in reiserfs_security_write() KVM: nVMX: Emulate NOPs in L2, and PAUSE if it's not intercepted KVM: arm64: Avoid vcpu->mutex v. kvm->lock inversion in CPU_ON KVM: arm64: Avoid lock inversion when setting the VM register width KVM: arm64: Use config_lock to protect data ordered against KVM_RUN KVM: arm64: Use config_lock to protect vgic state KVM: arm64: vgic: Don't acquire its_lock before config_lock relayfs: fix out-of-bounds access in relay_file_read drm/amd/display: Remove stutter only configurations drm/amd/display: limit timing for single dimm memory drm/amd/display: fix PSR-SU/DSC interoperability support drm/amd/display: fix a divided-by-zero error KVM: RISC-V: Retry fault if vma_lookup() results become invalid ksmbd: fix racy issue under cocurrent smb2 tree disconnect ksmbd: call rcu_barrier() in ksmbd_server_exit() ksmbd: fix NULL pointer dereference in smb2_get_info_filesystem() ksmbd: fix memleak in session setup ksmbd: not allow guest user on multichannel ksmbd: fix deadlock in ksmbd_find_crypto_ctx() ACPI: video: Remove acpi_backlight=video quirk for Lenovo ThinkPad W530 i2c: omap: Fix standard mode false ACK readings riscv: mm: remove redundant parameter of create_fdt_early_page_table tracing: Fix permissions for the buffer_percent file swsmu/amdgpu_smu: Fix the wrong if-condition drm/amd/pm: re-enable the gfx imu when smu resume iommu/amd: Fix "Guest Virtual APIC Table Root Pointer" configuration in IRTE RISC-V: Align SBI probe implementation with spec Revert "ubifs: dirty_cow_znode: Fix memleak in error handling path" ubifs: Fix memleak when insert_old_idx() failed ubi: Fix return value overwrite issue in try_write_vid_and_data() ubifs: Free memory for tmpfile name ubifs: Fix memory leak in do_rename ceph: fix potential use-after-free bug when trimming caps xfs: don't consider future format versions valid cxl/hdm: Fail upon detecting 0-sized decoders bus: mhi: host: Remove duplicate ee check for syserr bus: mhi: host: Use mhi_tryset_pm_state() for setting fw error state bus: mhi: host: Range check CHDBOFF and ERDBOFF ASoC: dt-bindings: qcom,lpass-rx-macro: correct minItems for clocks kunit: improve KTAP compliance of KUnit test output kunit: fix bug in the order of lines in debugfs logs rcu: Fix missing TICK_DEP_MASK_RCU_EXP dependency check selftests/resctrl: Return NULL if malloc_and_init_memory() did not alloc mem selftests/resctrl: Move ->setup() call outside of test specific branches selftests/resctrl: Allow ->setup() to return errors selftests/resctrl: Check for return value after write_schemata() selinux: fix Makefile dependencies of flask.h selinux: ensure av_permissions.h is built when needed tpm, tpm_tis: Do not skip reset of original interrupt vector tpm, tpm_tis: Claim locality before writing TPM_INT_ENABLE register tpm, tpm_tis: Disable interrupts if tpm_tis_probe_irq() failed tpm, tpm_tis: Claim locality before writing interrupt registers tpm, tpm: Implement usage counter for locality tpm, tpm_tis: Claim locality when interrupts are reenabled on resume erofs: stop parsing non-compact HEAD index if clusterofs is invalid erofs: initialize packed inode after root inode is assigned erofs: fix potential overflow calculating xattr_isize drm/rockchip: Drop unbalanced obj unref drm/i915/dg2: Drop one PCI ID drm/vgem: add missing mutex_destroy drm/probe-helper: Cancel previous job before starting new one drm/amdgpu: register a vga_switcheroo client for MacBooks with apple-gmux tools/x86/kcpuid: Fix avx512bw and avx512lvl fields in Fn00000007 soc: ti: pm33xx: Fix refcount leak in am33xx_pm_probe arm64: dts: renesas: r8a77990: Remove bogus voltages from OPP table arm64: dts: renesas: r8a774c0: Remove bogus voltages from OPP table arm64: dts: renesas: r9a07g044: Update IRQ numbers for SSI channels arm64: dts: renesas: r9a07g054: Update IRQ numbers for SSI channels arm64: dts: renesas: r9a07g043: Introduce SOC_PERIPHERAL_IRQ() macro to specify interrupt property arm64: dts: renesas: r9a07g043: Update IRQ numbers for SSI channels drm/mediatek: dp: Only trigger DRM HPD events if bridge is attached drm/msm/disp/dpu: check for crtc enable rather than crtc active to release shared resources EDAC/skx: Fix overflows on the DRAM row address mapping arrays ARM: dts: qcom-apq8064: Fix opp table child name regulator: core: Shorten off-on-delay-us for always-on/boot-on by time since booted arm64: dts: ti: k3-am62-main: Fix GPIO numbers in DT arm64: dts: ti: k3-am62a7-sk: Fix DDR size to full 4GB arm64: dts: ti: k3-j721e-main: Remove ti,strobe-sel property arm64: dts: broadcom: bcmbca: bcm4908: fix NAND interrupt name arm64: dts: broadcom: bcmbca: bcm4908: fix LED nodenames arm64: dts: broadcom: bcmbca: bcm4908: fix procmon nodename arm64: dts: qcom: msm8998: Fix stm-stimulus-base reg name arm64: dts: qcom: sc7280: fix EUD port properties arm64: dts: qcom: sdm845: correct dynamic power coefficients arm64: dts: qcom: sdm845: Fix the PCI I/O port range arm64: dts: qcom: msm8998: Fix the PCI I/O port range arm64: dts: qcom: sc7280: Fix the PCI I/O port range arm64: dts: qcom: ipq8074: Fix the PCI I/O port range arm64: dts: qcom: ipq6018: Fix the PCI I/O port range arm64: dts: qcom: msm8996: Fix the PCI I/O port range arm64: dts: qcom: sm8250: Fix the PCI I/O port range arm64: dts: qcom: sm8150: Fix the PCI I/O port range arm64: dts: qcom: sm8450: Fix the PCI I/O port range ARM: dts: qcom: ipq4019: Fix the PCI I/O port range ARM: dts: qcom: ipq8064: Fix the PCI I/O port range ARM: dts: qcom: sdx55: Fix the unit address of PCIe EP node x86/MCE/AMD: Use an u64 for bank_map media: bdisp: Add missing check for create_workqueue media: platform: mtk-mdp3: Add missing check and free for ida_alloc media: amphion: decoder implement display delay enable media: av7110: prevent underflow in write_ts_to_decoder() firmware: qcom_scm: Clear download bit during reboot drm/bridge: adv7533: Fix adv7533_mode_valid for adv7533 and adv7535 media: max9286: Free control handler arm64: dts: ti: k3-am625: Correct L2 cache size to 512KB arm64: dts: ti: k3-am62a7: Correct L2 cache size to 512KB drm/msm/adreno: drop bogus pm_runtime_set_active() drm: msm: adreno: Disable preemption on Adreno 510 virt/coco/sev-guest: Double-buffer messages arm64: dts: qcom: sm8350-microsoft-surface: fix USB dual-role mode property drm/amd/display/dc/dce60/Makefile: Fix previous attempt to silence known override-init warnings ACPI: processor: Fix evaluating _PDC method when running as Xen dom0 mmc: sdhci-of-esdhc: fix quirk to ignore command inhibit for data arm64: dts: qcom: sm8450: fix pcie1 gpios properties name drm: rcar-du: Fix a NULL vs IS_ERR() bug ARM: dts: gta04: fix excess dma channel usage firmware: arm_scmi: Fix xfers allocation on Rx channel perf/arm-cmn: Move overlapping wp_combine field ARM: dts: stm32: fix spi1 pin assignment on stm32mp15 arm64: dts: apple: t8103: Disable unused PCIe ports cpufreq: mediatek: fix passing zero to 'PTR_ERR' cpufreq: mediatek: fix KP caused by handler usage after regulator_put/clk_put cpufreq: mediatek: raise proc/sram max voltage for MT8516 cpufreq: mediatek: Raise proc and sram max voltage for MT7622/7623 cpufreq: qcom-cpufreq-hw: Revert adding cpufreq qos arm64: dts: mediatek: mt8192-asurada: Fix voltage constraint for Vgpu ACPI: VIOT: Initialize the correct IOMMU fwspec drm/lima/lima_drv: Add missing unwind goto in lima_pdev_probe() drm/mediatek: dp: Change the aux retries times when receiving AUX_DEFER mailbox: mpfs: switch to txdone_poll soc: bcm: brcmstb: biuctrl: fix of_iomap leak soc: renesas: renesas-soc: Release 'chipid' from ioremap() gpu: host1x: Fix potential double free if IOMMU is disabled gpu: host1x: Fix memory leak of device names arm64: dts: qcom: sc7280-herobrine-villager: correct trackpad supply arm64: dts: qcom: sc7180-trogdor-lazor: correct trackpad supply arm64: dts: qcom: sc7180-trogdor-pazquel: correct trackpad supply arm64: dts: qcom: msm8994-kitakami: drop unit address from PMI8994 regulator arm64: dts: qcom: msm8994-msft-lumia-octagon: drop unit address from PMI8994 regulator arm64: dts: qcom: apq8096-db820c: drop unit address from PMI8994 regulator drm/ttm: optimize pool allocations a bit v2 drm/ttm/pool: Fix ttm_pool_alloc error path regulator: core: Consistently set mutex_owner when using ww_mutex_lock_slow() regulator: core: Avoid lockdep reports when resolving supplies x86/apic: Fix atomic update of offset in reserve_eilvt_offset() arm64: dts: qcom: msm8994-angler: Fix cont_splash_mem mapping arm64: dts: qcom: msm8994-angler: removed clash with smem_region arm64: dts: sc7180: Rename qspi data12 as data23 arm64: dts: sc7280: Rename qspi data12 as data23 media: mediatek: vcodec: Use 4K frame size when supported by stateful decoder media: mediatek: vcodec: Make MM21 the default capture format media: mediatek: vcodec: Force capture queue format to MM21 media: mediatek: vcodec: add params to record lat and core lat_buf count media: mediatek: vcodec: using each instance lat_buf count replace core ready list media: mediatek: vcodec: move lat_buf to the top of core list media: mediatek: vcodec: add core decode done event media: mediatek: vcodec: remove unused lat_buf media: mediatek: vcodec: making sure queue_work successfully media: mediatek: vcodec: change lat thread decode error condition media: cedrus: fix use after free bug in cedrus_remove due to race condition media: rkvdec: fix use after free bug in rkvdec_remove platform/x86/amd/pmf: Move out of BIOS SMN pair for driver probe platform/x86/amd: pmc: Don't try to read SMU version on Picasso platform/x86/amd: pmc: Hide SMU version and program attributes for Picasso platform/x86/amd: pmc: Don't dump data after resume from s0i3 on picasso platform/x86/amd: pmc: Move idlemask check into `amd_pmc_idlemask_read` platform/x86/amd: pmc: Utilize SMN index 0 for driver probe platform/x86/amd: pmc: Move out of BIOS SMN pair for STB init media: dm1105: Fix use after free bug in dm1105_remove due to race condition media: saa7134: fix use after free bug in saa7134_finidev due to race condition media: platform: mtk-mdp3: fix potential frame size overflow in mdp_try_fmt_mplane() media: rcar_fdp1: Fix refcount leak in probe and remove function media: v4l: async: Return async sub-devices to subnotifier list media: hi846: Fix memleak in hi846_init_controls() drm/amd/display: Fix potential null dereference media: rc: gpio-ir-recv: Fix support for wake-up media: venus: dec: Fix handling of the start cmd media: venus: dec: Fix capture formats enumeration order regulator: stm32-pwr: fix of_iomap leak x86/ioapic: Don't return 0 from arch_dynirq_lower_bound() arm64: kgdb: Set PSTATE.SS to 1 to re-enable single-step perf/arm-cmn: Fix port detection for CMN-700 media: mediatek: vcodec: fix decoder disable pm crash media: mediatek: vcodec: add remove function for decoder platform driver debugobject: Prevent init race with static objects drm/i915: Make intel_get_crtc_new_encoder() less oopsy tick/common: Align tick period with the HZ tick. ACPI: bus: Ensure that notify handlers are not running after removal cpufreq: use correct unit when verify cur freq rpmsg: glink: Propagate TX failures in intentless mode as well hwmon: (pmbus/fsp-3y) Fix functionality bitmask in FSP-3Y YM-2151E platform/chrome: cros_typec_switch: Add missing fwnode_handle_put() wifi: ath6kl: minor fix for allocation size wifi: ath9k: hif_usb: fix memory leak of remain_skbs wifi: ath11k: Use platform_get_irq() to get the interrupt wifi: ath5k: Use platform_get_irq() to get the interrupt wifi: ath5k: fix an off by one check in ath5k_eeprom_read_freq_list() wifi: ath11k: fix SAC bug on peer addition with sta band migration wifi: brcmfmac: support CQM RSSI notification with older firmware wifi: ath6kl: reduce WARN to dev_dbg() in callback tools: bpftool: Remove invalid \' json escape wifi: rtw88: mac: Return the original error from rtw_pwr_seq_parser() wifi: rtw88: mac: Return the original error from rtw_mac_power_switch() bpf: take into account liveness when propagating precision bpf: fix precision propagation verbose logging crypto: qat - fix concurrency issue when device state changes scm: fix MSG_CTRUNC setting condition for SO_PASSSEC wifi: ath11k: fix deinitialization of firmware resources selftests/bpf: Fix a fd leak in an error path in network_helpers.c bpf: Remove misleading spec_v1 check on var-offset stack read net: pcs: xpcs: remove double-read of link state when using AN vlan: partially enable SIOCSHWTSTAMP in container net/packet: annotate accesses to po->xmit net/packet: convert po->origdev to an atomic flag net/packet: convert po->auxdata to an atomic flag libbpf: Fix ld_imm64 copy logic for ksym in light skeleton. net: dsa: qca8k: remove assignment of an_enabled in pcs_get_state() netfilter: keep conntrack reference until IPsecv6 policy checks are done bpf: Fix __reg_bound_offset 64->32 var_off subreg propagation scsi: target: core: Change the way target_xcopy_do_work() sets restiction on max I/O scsi: target: Move sess cmd counter to new struct scsi: target: Move cmd counter allocation scsi: target: Pass in cmd counter to use during cmd setup scsi: target: iscsit: isert: Alloc per conn cmd counter scsi: target: iscsit: Stop/wait on cmds during conn close scsi: target: Fix multiple LUN_RESET handling scsi: target: iscsit: Fix TAS handling during conn cleanup scsi: megaraid: Fix mega_cmd_done() CMDID_INT_CMDS net: sunhme: Fix uninitialized return code f2fs: handle dqget error in f2fs_transfer_project_quota() f2fs: fix uninitialized skipped_gc_rwsem f2fs: apply zone capacity to all zone type f2fs: compress: fix to call f2fs_wait_on_page_writeback() in f2fs_write_raw_pages() f2fs: fix scheduling while atomic in decompression path crypto: caam - Clear some memory in instantiate_rng crypto: sa2ul - Select CRYPTO_DES wifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_rfreg() wifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_reg() scsi: libsas: Add sas_ata_device_link_abort() scsi: hisi_sas: Handle NCQ error when IPTT is valid wifi: rt2x00: Fix memory leak when handling surveys f2fs: fix iostat lock protection net: qrtr: correct types of trace event parameters selftests: xsk: Use correct UMEM size in testapp_invalid_desc selftests: xsk: Disable IPv6 on VETH1 selftests: xsk: Deflakify STATS_RX_DROPPED test selftests/bpf: Wait for receive in cg_storage_multi test bpftool: Fix bug for long instructions in program CFG dumps crypto: drbg - Only fail when jent is unavailable in FIPS mode xsk: Fix unaligned descriptor validation f2fs: fix to avoid use-after-free for cached IPU bio wifi: iwlwifi: fix duplicate entry in iwl_dev_info_table bpf/btf: Fix is_int_ptr() scsi: lpfc: Fix ioremap issues in lpfc_sli4_pci_mem_setup() net: ethernet: stmmac: dwmac-rk: rework optional clock handling net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling wifi: ath11k: fix writing to unintended memory region bpf, sockmap: fix deadlocks in the sockhash and sockmap nvmet: fix error handling in nvmet_execute_identify_cns_cs_ns() nvmet: fix Identify Namespace handling nvmet: fix Identify Controller handling nvmet: fix Identify Active Namespace ID list handling nvmet: fix I/O Command Set specific Identify Controller nvme: fix async event trace event nvme-fcloop: fix "inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage" selftests/bpf: Use read_perf_max_sample_freq() in perf_event_stackmap selftests/bpf: Fix leaked bpf_link in get_stackid_cannot_attach blk-mq: don't plug for head insertions in blk_execute_rq_nowait wifi: iwlwifi: debug: fix crash in __iwl_err() wifi: iwlwifi: trans: don't trigger d3 interrupt twice wifi: iwlwifi: mvm: don't set CHECKSUM_COMPLETE for unsupported protocols bpf, sockmap: Revert buggy deadlock fix in the sockhash and sockmap f2fs: fix to check return value of f2fs_do_truncate_blocks() f2fs: fix to check return value of inc_valid_block_count() md/raid10: fix task hung in raid10d md/raid10: fix leak of 'r10bio->remaining' for recovery md/raid10: fix memleak for 'conf->bio_split' md/raid10: fix memleak of md thread md/raid10: don't call bio_start_io_acct twice for bio which experienced read error wifi: iwlwifi: mvm: don't drop unencrypted MCAST frames wifi: iwlwifi: yoyo: skip dump correctly on hw error wifi: iwlwifi: yoyo: Fix possible division by zero wifi: iwlwifi: mvm: initialize seq variable wifi: iwlwifi: fw: move memset before early return jdb2: Don't refuse invalidation of already invalidated buffers io_uring/rsrc: use nospec'ed indexes wifi: iwlwifi: make the loop for card preparation effective wifi: mt76: mt7915: expose device tree match table wifi: mt76: handle failure of vzalloc in mt7615_coredump_work wifi: mt76: add flexible polling wait-interval support wifi: mt76: mt7921e: fix probe timeout after reboot wifi: mt76: fix 6GHz high channel not be scanned mt76: mt7921: fix kernel panic by accessing unallocated eeprom.data wifi: mt76: mt7921: fix missing unwind goto in `mt7921u_probe` wifi: mt76: mt7921e: improve reliability of dma reset wifi: mt76: mt7921e: stop chip reset worker in unregister hook wifi: mt76: connac: fix txd multicast rate setting wifi: iwlwifi: mvm: check firmware response size netfilter: conntrack: restore IPS_CONFIRMED out of nf_conntrack_hash_check_insert() netfilter: conntrack: fix wrong ct->timeout value wifi: iwlwifi: fw: fix memory leak in debugfs ixgbe: Allow flow hash to be set via ethtool ixgbe: Enable setting RSS table to default values net/mlx5e: Don't clone flow post action attributes second time net/mlx5: E-switch, Create per vport table based on devlink encap mode net/mlx5: E-switch, Don't destroy indirect table in split rule net/mlx5e: Fix error flow in representor failing to add vport rx rule net/mlx5: Remove "recovery" arg from mlx5_load_one() function net/mlx5: Suspend auxiliary devices only in case of PCI device suspend Revert "net/mlx5: Remove "recovery" arg from mlx5_load_one() function" net/mlx5: Use recovery timeout on sync reset flow net/mlx5e: Nullify table pointer when failing to create net: stmmac:fix system hang when setting up tag_8021q VLAN for DSA ports bpf: Fix race between btf_put and btf_idr walk. bpf: Don't EFAULT for getsockopt with optval=NULL netfilter: nf_tables: don't write table validation state without mutex net: dpaa: Fix uninitialized variable in dpaa_stop() net/sched: sch_fq: fix integer overflow of "credit" ipv4: Fix potential uninit variable access bug in __ip_make_skb() Revert "Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work" netlink: Use copy_to_user() for optval in netlink_getsockopt(). net: amd: Fix link leak when verifying config failed tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp. ipmi: ASPEED_BT_IPMI_BMC: select REGMAP_MMIO instead of depending on it ASoC: cs35l41: Only disable internal boost drivers: staging: rtl8723bs: Fix locking in _rtw_join_timeout_handler() drivers: staging: rtl8723bs: Fix locking in rtw_scan_timeout_handler() pstore: Revert pmsg_lock back to a normal mutex usb: host: xhci-rcar: remove leftover quirk handling usb: dwc3: gadget: Change condition for processing suspend event serial: stm32: Re-assert RTS/DE GPIO in RS485 mode only if more data are transmitted fpga: bridge: fix kernel-doc parameter description iio: light: max44009: add missing OF device matching serial: 8250_bcm7271: Fix arbitration handling spi: atmel-quadspi: Don't leak clk enable count in pm resume spi: atmel-quadspi: Free resources even if runtime resume failed in .remove() spi: imx: Don't skip cleanup in remove's error path usb: gadget: udc: renesas_usb3: Fix use after free bug in renesas_usb3_remove due to race condition ASoC: soc-compress: Inherit atomicity from DAI link for Compress FE PCI: imx6: Install the fault handler only on compatible match ASoC: es8316: Handle optional IRQ assignment linux/vt_buffer.h: allow either builtin or modular for macros spi: qup: Don't skip cleanup in remove's error path interconnect: qcom: rpm: drop bogus pm domain attach spi: fsl-spi: Fix CPM/QE mode Litte Endian vmci_host: fix a race condition in vmci_host_poll() causing GPF of: Fix modalias string generation PCI/EDR: Clear Device Status after EDR error recovery ia64: mm/contig: fix section mismatch warning/error ia64: salinfo: placate defined-but-not-used warning scripts/gdb: bail early if there are no clocks scripts/gdb: bail early if there are no generic PD HID: amd_sfh: Correct the structure fields HID: amd_sfh: Correct the sensor enable and disable command HID: amd_sfh: Fix illuminance value HID: amd_sfh: Add support for shutdown operation HID: amd_sfh: Correct the stop all command HID: amd_sfh: Increase sensor command timeout for SFH1.1 HID: amd_sfh: Handle "no sensors" enabled for SFH1.1 cacheinfo: Check sib_leaf in cache_leaves_are_shared() coresight: etm_pmu: Set the module field drm/panel: novatek-nt35950: Improve error handling ASoC: fsl_mqs: move of_node_put() to the correct location PCI/PM: Extend D3hot delay for NVIDIA HDA controllers drm/panel: novatek-nt35950: Only unregister DSI1 if it exists spi: cadence-quadspi: fix suspend-resume implementations i2c: cadence: cdns_i2c_master_xfer(): Fix runtime PM leak on error path i2c: xiic: xiic_xfer(): Fix runtime PM leak on error path scripts/gdb: raise error with reduced debugging information uapi/linux/const.h: prefer ISO-friendly __typeof__ sh: sq: Fix incorrect element size for allocating bitmap buffer usb: gadget: tegra-xudc: Fix crash in vbus_draw usb: chipidea: fix missing goto in `ci_hdrc_probe` usb: mtu3: fix kernel panic at qmu transfer done irq handler firmware: stratix10-svc: Fix an NULL vs IS_ERR() bug in probe tty: serial: fsl_lpuart: adjust buffer length to the intended size serial: 8250: Add missing wakeup event reporting spi: cadence-quadspi: use macro DEFINE_SIMPLE_DEV_PM_OPS staging: rtl8192e: Fix W_DISABLE# does not work after stop/start spmi: Add a check for remove callback when removing a SPMI driver virtio_ring: don't update event idx on get_buf fbdev: mmp: Fix deferred clk handling in mmphw_probe() selftests/powerpc/pmu: Fix sample field check in the mmcra_thresh_marked_sample_test macintosh/windfarm_smu_sat: Add missing of_node_put() powerpc/perf: Properly detect mpc7450 family powerpc/mpc512x: fix resource printk format warning powerpc/wii: fix resource printk format warnings powerpc/sysdev/tsi108: fix resource printk format warnings macintosh: via-pmu-led: requires ATA to be set powerpc/rtas: use memmove for potentially overlapping buffer copy sched/fair: Fix inaccurate tally of ttwu_move_affine perf/core: Fix hardlockup failure caused by perf throttle Revert "objtool: Support addition to set CFA base" riscv: Fix ptdump when KASAN is enabled sched/rt: Fix bad task migration for rt tasks tracing/user_events: Ensure write index cannot be negative clk: at91: clk-sam9x60-pll: fix return value check IB/hifi1: add a null check of kzalloc_node in hfi1_ipoib_txreq_init RDMA/siw: Fix potential page_array out of range access clk: mediatek: mt2712: Add error handling to clk_mt2712_apmixed_probe() clk: mediatek: Consistently use GATE_MTK() macro clk: mediatek: mt7622: Properly use CLK_IS_CRITICAL flag clk: mediatek: mt8135: Properly use CLK_IS_CRITICAL flag RDMA/rdmavt: Delete unnecessary NULL check clk: qcom: gcc-qcm2290: Fix up gcc_sdcc2_apps_clk_src workqueue: Fix hung time report of worker pools rtc: omap: include header for omap_rtc_power_off_program prototype RDMA/mlx4: Prevent shift wrapping in set_user_sq_size() rtc: meson-vrtc: Use ktime_get_real_ts64() to get the current time rtc: k3: handle errors while enabling wake irq RDMA/erdma: Use fixed hardware page size fs/ntfs3: Fix memory leak if ntfs_read_mft failed fs/ntfs3: Add check for kmemdup fs/ntfs3: Fix OOB read in indx_insert_into_buffer fs/ntfs3: Fix slab-out-of-bounds read in hdr_delete_de() iommu/mediatek: Set dma_mask for PGTABLE_PA_35_EN power: supply: generic-adc-battery: fix unit scaling clk: add missing of_node_put() in "assigned-clocks" property parsing RDMA/siw: Remove namespace check from siw_netdev_event() clk: qcom: gcc-sm6115: Mark RCGs shared where applicable power: supply: rk817: Fix low SOC bugs RDMA/cm: Trace icm_send_rej event before the cm state is reset RDMA/srpt: Add a check for valid 'mad_agent' pointer IB/hfi1: Fix SDMA mmu_rb_node not being evicted in LRU order IB/hfi1: Fix bugs with non-PAGE_SIZE-end multi-iovec user SDMA requests clk: imx: fracn-gppll: fix the rate table clk: imx: fracn-gppll: disable hardware select control clk: imx: imx8ulp: Fix XBAR_DIVBUS and AD_SLOW clock parents NFSv4.1: Always send a RECLAIM_COMPLETE after establishing lease iommu/amd: Set page size bitmap during V2 domain allocation clk: qcom: lpasscc-sc7280: Skip qdsp6ss clock registration clk: qcom: lpassaudiocc-sc7280: Add required gdsc power domain clks in lpass_cc_sc7280_desc clk: qcom: gcc-sm8350: fix PCIe PIPE clocks handling clk: qcom: dispcc-qcm2290: get rid of test clock clk: qcom: dispcc-qcm2290: Remove inexistent DSI1PHY clk Input: raspberrypi-ts - fix refcount leak in rpi_ts_probe swiotlb: relocate PageHighMem test away from rmem_swiotlb_setup swiotlb: fix debugfs reporting of reserved memory pools RDMA/mlx5: Check pcie_relaxed_ordering_enabled() in UMR RDMA/mlx5: Fix flow counter query via DEVX SUNRPC: remove the maximum number of retries in call_bind_status RDMA/mlx5: Use correct device num_ports when modify DC clocksource/drivers/davinci: Fix memory leak in davinci_timer_register when init fails openrisc: Properly store r31 to pt_regs on unhandled exceptions timekeeping: Fix references to nonexistent ktime_get_fast_ns() SMB3: Add missing locks to protect deferred close file list SMB3: Close deferred file handles in case of handle lease break ext4: fix i_disksize exceeding i_size problem in paritally written case ext4: fix use-after-free read in ext4_find_extent for bigalloc + inline pinctrl: renesas: r8a779a0: Remove incorrect AVB[01] pinmux configuration pinctrl: renesas: r8a779f0: Fix tsn1_avtp_pps pin group pinctrl: renesas: r8a779g0: Fix Group 4/5 pin functions pinctrl: renesas: r8a779g0: Fix Group 6/7 pin functions pinctrl: renesas: r8a779g0: Fix ERROROUTC function names leds: TI_LMU_COMMON: select REGMAP instead of depending on it pinctrl: ralink: reintroduce ralink,rt2880-pinmux compatible string dmaengine: mv_xor_v2: Fix an error code. leds: tca6507: Fix error handling of using fwnode_property_read_string pwm: mtk-disp: Disable shadow registers before setting backlight values pwm: mtk-disp: Configure double buffering before reading in .get_state() soundwire: cadence: rename sdw_cdns_dai_dma_data as sdw_cdns_dai_runtime soundwire: intel: don't save hw_params for use in prepare phy: tegra: xusb: Add missing tegra_xusb_port_unregister for usb2_port and ulpi_port phy: ti: j721e-wiz: Fix unreachable code in wiz_mode_select() dma: gpi: remove spurious unlock in gpi_ch_init dmaengine: dw-edma: Fix to change for continuous transfer dmaengine: dw-edma: Fix to enable to issue dma request on DMA processing dmaengine: at_xdmac: do not enable all cyclic channels pinctrl-bcm2835.c: fix race condition when setting gpio dir thermal/drivers/mediatek: Use devm_of_iomap to avoid resource leak in mtk_thermal_probe mfd: tqmx86: Do not access I2C_DETECT register through io_base mfd: tqmx86: Specify IO port register range more precisely mfd: tqmx86: Correct board names for TQMxE39x mfd: ocelot-spi: Fix unsupported bulk read mfd: arizona-spi: Add missing MODULE_DEVICE_TABLE hte: tegra: fix 'struct of_device_id' build error hte: tegra-194: Fix off by one in tegra_hte_map_to_line_id() ACPI: PM: Do not turn of unused power resources on the Toshiba Click Mini PM: hibernate: Turn snapshot_test into global variable PM: hibernate: Do not get block device exclusively in test_resume mode afs: Fix updating of i_size with dv jump from server afs: Fix getattr to report server i_size on dirs, not local size afs: Avoid endless loop if file is larger than expected parisc: Fix argument pointer in real64_call_asm() parisc: Ensure page alignment in flush functions ALSA: usb-audio: Add quirk for Pioneer DDJ-800 ALSA: hda/realtek: Add quirk for ThinkPad P1 Gen 6 ALSA: hda/realtek: Add quirk for ASUS UM3402YAR using CS35L41 ALSA: hda/realtek: support HP Pavilion Aero 13-be0xxx Mute LED ALSA: hda/realtek: Fix mute and micmute LEDs for an HP laptop nilfs2: do not write dirty data after degenerating to read-only nilfs2: fix infinite loop in nilfs_mdt_get_block() mm: do not reclaim private data from pinned page drbd: correctly submit flush bio on barrier md/raid10: fix null-ptr-deref in raid10_sync_request md/raid5: Improve performance for sequential IO kasan: hw_tags: avoid invalid virt_to_page() mtd: core: provide unique name for nvmem device, take two mtd: core: fix nvmem error reporting mtd: core: fix error path for nvmem provider mtd: spi-nor: core: Update flash's current address mode when changing address mode mailbox: zynqmp: Fix IPI isr handling kcsan: Avoid READ_ONCE() in read_instrumented_memory() mailbox: zynqmp: Fix typo in IPI documentation wifi: rtl8xxxu: RTL8192EU always needs full init wifi: rtw89: fix potential race condition between napi_init and napi_enable clk: microchip: fix potential UAF in auxdev release callback clk: rockchip: rk3399: allow clk_cifout to force clk_cifout_src to reparent scripts/gdb: fix lx-timerlist for Python3 btrfs: scrub: reject unsupported scrub flags s390/dasd: fix hanging blockdevice after request requeue ia64: fix an addr to taddr in huge_pte_offset() mm/mempolicy: correctly update prev when policy is equal on mbind vhost_vdpa: fix unmap process in no-batch mode dm verity: fix error handling for check_at_most_once on FEC dm clone: call kmem_cache_destroy() in dm_clone_init() error path dm integrity: call kmem_cache_destroy() in dm_integrity_init() error path dm flakey: fix a crash with invalid table line dm ioctl: fix nested locking in table_clear() to remove deadlock concern dm: don't lock fs when the map is NULL in process of resume blk-iocost: avoid 64-bit division in ioc_timer_fn cifs: fix potential use-after-free bugs in TCP_Server_Info::hostname cifs: protect session status check in smb2_reconnect() thunderbolt: Use correct type in tb_port_is_clx_enabled() prototype bonding (gcc13): synchronize bond_{a,t}lb_xmit() types wifi: ath11k: synchronize ath11k_mac_he_gi_to_nl80211_he_gi()'s return type perf auxtrace: Fix address filter entire kernel size perf intel-pt: Fix CYC timestamps after standalone CBR block/blk-iocost (gcc13): keep large values in a new enum sfc (gcc13): synchronize ef100_enqueue_skb()'s return type i40e: Remove unused i40e status codes i40e: Remove string printing for i40e_status i40e: use int for i40e_status drm/amd/display (gcc13): fix enum mismatch debugobject: Ensure pool refill (again) scsi: libsas: Grab the ATA port lock in sas_ata_device_link_abort() netfilter: nf_tables: deactivate anonymous set from preparation phase Linux 6.1.28 Change-Id: I61b5133e2d051cc2aa39b8c7c1be3fc25da40210 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
1319 lines
30 KiB
C
1319 lines
30 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Cryptographic API for algorithms (i.e., low-level API).
|
|
*
|
|
* Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
|
|
*/
|
|
|
|
#include <crypto/algapi.h>
|
|
#include <crypto/internal/simd.h>
|
|
#include <linux/err.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/fips.h>
|
|
#include <linux/init.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/list.h>
|
|
#include <linux/module.h>
|
|
#include <linux/rtnetlink.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/string.h>
|
|
|
|
#include "internal.h"
|
|
|
|
static LIST_HEAD(crypto_template_list);
|
|
|
|
#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS
|
|
DEFINE_PER_CPU(bool, crypto_simd_disabled_for_test);
|
|
EXPORT_PER_CPU_SYMBOL_GPL(crypto_simd_disabled_for_test);
|
|
#endif
|
|
|
|
static inline void crypto_check_module_sig(struct module *mod)
|
|
{
|
|
if (fips_enabled && mod && !module_sig_ok(mod))
|
|
panic("Module %s signature verification failed in FIPS mode\n",
|
|
module_name(mod));
|
|
}
|
|
|
|
static int crypto_check_alg(struct crypto_alg *alg)
|
|
{
|
|
crypto_check_module_sig(alg->cra_module);
|
|
|
|
if (!alg->cra_name[0] || !alg->cra_driver_name[0])
|
|
return -EINVAL;
|
|
|
|
if (alg->cra_alignmask & (alg->cra_alignmask + 1))
|
|
return -EINVAL;
|
|
|
|
/* General maximums for all algs. */
|
|
if (alg->cra_alignmask > MAX_ALGAPI_ALIGNMASK)
|
|
return -EINVAL;
|
|
|
|
if (alg->cra_blocksize > MAX_ALGAPI_BLOCKSIZE)
|
|
return -EINVAL;
|
|
|
|
/* Lower maximums for specific alg types. */
|
|
if (!alg->cra_type && (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
|
|
CRYPTO_ALG_TYPE_CIPHER) {
|
|
if (alg->cra_alignmask > MAX_CIPHER_ALIGNMASK)
|
|
return -EINVAL;
|
|
|
|
if (alg->cra_blocksize > MAX_CIPHER_BLOCKSIZE)
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (alg->cra_priority < 0)
|
|
return -EINVAL;
|
|
|
|
refcount_set(&alg->cra_refcnt, 1);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void crypto_free_instance(struct crypto_instance *inst)
|
|
{
|
|
inst->alg.cra_type->free(inst);
|
|
}
|
|
|
|
static void crypto_destroy_instance(struct crypto_alg *alg)
|
|
{
|
|
struct crypto_instance *inst = (void *)alg;
|
|
struct crypto_template *tmpl = inst->tmpl;
|
|
|
|
crypto_free_instance(inst);
|
|
crypto_tmpl_put(tmpl);
|
|
}
|
|
|
|
/*
|
|
* This function adds a spawn to the list secondary_spawns which
|
|
* will be used at the end of crypto_remove_spawns to unregister
|
|
* instances, unless the spawn happens to be one that is depended
|
|
* on by the new algorithm (nalg in crypto_remove_spawns).
|
|
*
|
|
* This function is also responsible for resurrecting any algorithms
|
|
* in the dependency chain of nalg by unsetting n->dead.
|
|
*/
|
|
static struct list_head *crypto_more_spawns(struct crypto_alg *alg,
|
|
struct list_head *stack,
|
|
struct list_head *top,
|
|
struct list_head *secondary_spawns)
|
|
{
|
|
struct crypto_spawn *spawn, *n;
|
|
|
|
spawn = list_first_entry_or_null(stack, struct crypto_spawn, list);
|
|
if (!spawn)
|
|
return NULL;
|
|
|
|
n = list_prev_entry(spawn, list);
|
|
list_move(&spawn->list, secondary_spawns);
|
|
|
|
if (list_is_last(&n->list, stack))
|
|
return top;
|
|
|
|
n = list_next_entry(n, list);
|
|
if (!spawn->dead)
|
|
n->dead = false;
|
|
|
|
return &n->inst->alg.cra_users;
|
|
}
|
|
|
|
static void crypto_remove_instance(struct crypto_instance *inst,
|
|
struct list_head *list)
|
|
{
|
|
struct crypto_template *tmpl = inst->tmpl;
|
|
|
|
if (crypto_is_dead(&inst->alg))
|
|
return;
|
|
|
|
inst->alg.cra_flags |= CRYPTO_ALG_DEAD;
|
|
|
|
if (!tmpl || !crypto_tmpl_get(tmpl))
|
|
return;
|
|
|
|
list_move(&inst->alg.cra_list, list);
|
|
hlist_del(&inst->list);
|
|
inst->alg.cra_destroy = crypto_destroy_instance;
|
|
|
|
BUG_ON(!list_empty(&inst->alg.cra_users));
|
|
}
|
|
|
|
/*
|
|
* Given an algorithm alg, remove all algorithms that depend on it
|
|
* through spawns. If nalg is not null, then exempt any algorithms
|
|
* that is depended on by nalg. This is useful when nalg itself
|
|
* depends on alg.
|
|
*/
|
|
void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list,
|
|
struct crypto_alg *nalg)
|
|
{
|
|
u32 new_type = (nalg ?: alg)->cra_flags;
|
|
struct crypto_spawn *spawn, *n;
|
|
LIST_HEAD(secondary_spawns);
|
|
struct list_head *spawns;
|
|
LIST_HEAD(stack);
|
|
LIST_HEAD(top);
|
|
|
|
spawns = &alg->cra_users;
|
|
list_for_each_entry_safe(spawn, n, spawns, list) {
|
|
if ((spawn->alg->cra_flags ^ new_type) & spawn->mask)
|
|
continue;
|
|
|
|
list_move(&spawn->list, &top);
|
|
}
|
|
|
|
/*
|
|
* Perform a depth-first walk starting from alg through
|
|
* the cra_users tree. The list stack records the path
|
|
* from alg to the current spawn.
|
|
*/
|
|
spawns = ⊤
|
|
do {
|
|
while (!list_empty(spawns)) {
|
|
struct crypto_instance *inst;
|
|
|
|
spawn = list_first_entry(spawns, struct crypto_spawn,
|
|
list);
|
|
inst = spawn->inst;
|
|
|
|
list_move(&spawn->list, &stack);
|
|
spawn->dead = !spawn->registered || &inst->alg != nalg;
|
|
|
|
if (!spawn->registered)
|
|
break;
|
|
|
|
BUG_ON(&inst->alg == alg);
|
|
|
|
if (&inst->alg == nalg)
|
|
break;
|
|
|
|
spawns = &inst->alg.cra_users;
|
|
|
|
/*
|
|
* Even if spawn->registered is true, the
|
|
* instance itself may still be unregistered.
|
|
* This is because it may have failed during
|
|
* registration. Therefore we still need to
|
|
* make the following test.
|
|
*
|
|
* We may encounter an unregistered instance here, since
|
|
* an instance's spawns are set up prior to the instance
|
|
* being registered. An unregistered instance will have
|
|
* NULL ->cra_users.next, since ->cra_users isn't
|
|
* properly initialized until registration. But an
|
|
* unregistered instance cannot have any users, so treat
|
|
* it the same as ->cra_users being empty.
|
|
*/
|
|
if (spawns->next == NULL)
|
|
break;
|
|
}
|
|
} while ((spawns = crypto_more_spawns(alg, &stack, &top,
|
|
&secondary_spawns)));
|
|
|
|
/*
|
|
* Remove all instances that are marked as dead. Also
|
|
* complete the resurrection of the others by moving them
|
|
* back to the cra_users list.
|
|
*/
|
|
list_for_each_entry_safe(spawn, n, &secondary_spawns, list) {
|
|
if (!spawn->dead)
|
|
list_move(&spawn->list, &spawn->alg->cra_users);
|
|
else if (spawn->registered)
|
|
crypto_remove_instance(spawn->inst, list);
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_remove_spawns);
|
|
|
|
static void crypto_alg_finish_registration(struct crypto_alg *alg,
|
|
bool fulfill_requests,
|
|
struct list_head *algs_to_put)
|
|
{
|
|
struct crypto_alg *q;
|
|
|
|
list_for_each_entry(q, &crypto_alg_list, cra_list) {
|
|
if (q == alg)
|
|
continue;
|
|
|
|
if (crypto_is_moribund(q))
|
|
continue;
|
|
|
|
if (crypto_is_larval(q)) {
|
|
struct crypto_larval *larval = (void *)q;
|
|
|
|
/*
|
|
* Check to see if either our generic name or
|
|
* specific name can satisfy the name requested
|
|
* by the larval entry q.
|
|
*/
|
|
if (strcmp(alg->cra_name, q->cra_name) &&
|
|
strcmp(alg->cra_driver_name, q->cra_name))
|
|
continue;
|
|
|
|
if (larval->adult)
|
|
continue;
|
|
if ((q->cra_flags ^ alg->cra_flags) & larval->mask)
|
|
continue;
|
|
|
|
if (fulfill_requests && crypto_mod_get(alg))
|
|
larval->adult = alg;
|
|
else
|
|
larval->adult = ERR_PTR(-EAGAIN);
|
|
|
|
continue;
|
|
}
|
|
|
|
if (strcmp(alg->cra_name, q->cra_name))
|
|
continue;
|
|
|
|
if (strcmp(alg->cra_driver_name, q->cra_driver_name) &&
|
|
q->cra_priority > alg->cra_priority)
|
|
continue;
|
|
|
|
crypto_remove_spawns(q, algs_to_put, alg);
|
|
}
|
|
|
|
crypto_notify(CRYPTO_MSG_ALG_LOADED, alg);
|
|
}
|
|
|
|
static struct crypto_larval *crypto_alloc_test_larval(struct crypto_alg *alg)
|
|
{
|
|
struct crypto_larval *larval;
|
|
|
|
if (!IS_ENABLED(CONFIG_CRYPTO_MANAGER) ||
|
|
IS_ENABLED(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS) ||
|
|
(alg->cra_flags & CRYPTO_ALG_INTERNAL))
|
|
return NULL; /* No self-test needed */
|
|
|
|
larval = crypto_larval_alloc(alg->cra_name,
|
|
alg->cra_flags | CRYPTO_ALG_TESTED, 0);
|
|
if (IS_ERR(larval))
|
|
return larval;
|
|
|
|
larval->adult = crypto_mod_get(alg);
|
|
if (!larval->adult) {
|
|
kfree(larval);
|
|
return ERR_PTR(-ENOENT);
|
|
}
|
|
|
|
refcount_set(&larval->alg.cra_refcnt, 1);
|
|
memcpy(larval->alg.cra_driver_name, alg->cra_driver_name,
|
|
CRYPTO_MAX_ALG_NAME);
|
|
larval->alg.cra_priority = alg->cra_priority;
|
|
|
|
return larval;
|
|
}
|
|
|
|
static struct crypto_larval *
|
|
__crypto_register_alg(struct crypto_alg *alg, struct list_head *algs_to_put)
|
|
{
|
|
struct crypto_alg *q;
|
|
struct crypto_larval *larval;
|
|
int ret = -EAGAIN;
|
|
|
|
if (crypto_is_dead(alg))
|
|
goto err;
|
|
|
|
INIT_LIST_HEAD(&alg->cra_users);
|
|
|
|
ret = -EEXIST;
|
|
|
|
list_for_each_entry(q, &crypto_alg_list, cra_list) {
|
|
if (q == alg)
|
|
goto err;
|
|
|
|
if (crypto_is_moribund(q))
|
|
continue;
|
|
|
|
if (crypto_is_larval(q)) {
|
|
if (!strcmp(alg->cra_driver_name, q->cra_driver_name))
|
|
goto err;
|
|
continue;
|
|
}
|
|
|
|
if (!strcmp(q->cra_driver_name, alg->cra_name) ||
|
|
!strcmp(q->cra_name, alg->cra_driver_name))
|
|
goto err;
|
|
}
|
|
|
|
larval = crypto_alloc_test_larval(alg);
|
|
if (IS_ERR(larval))
|
|
goto out;
|
|
|
|
list_add(&alg->cra_list, &crypto_alg_list);
|
|
|
|
crypto_stats_init(alg);
|
|
|
|
if (larval) {
|
|
/* No cheating! */
|
|
alg->cra_flags &= ~CRYPTO_ALG_TESTED;
|
|
|
|
list_add(&larval->alg.cra_list, &crypto_alg_list);
|
|
} else {
|
|
alg->cra_flags |= CRYPTO_ALG_TESTED;
|
|
crypto_alg_finish_registration(alg, true, algs_to_put);
|
|
}
|
|
|
|
out:
|
|
return larval;
|
|
|
|
err:
|
|
larval = ERR_PTR(ret);
|
|
goto out;
|
|
}
|
|
|
|
void crypto_alg_tested(const char *name, int err)
|
|
{
|
|
struct crypto_larval *test;
|
|
struct crypto_alg *alg;
|
|
struct crypto_alg *q;
|
|
LIST_HEAD(list);
|
|
bool best;
|
|
|
|
down_write(&crypto_alg_sem);
|
|
list_for_each_entry(q, &crypto_alg_list, cra_list) {
|
|
if (crypto_is_moribund(q) || !crypto_is_larval(q))
|
|
continue;
|
|
|
|
test = (struct crypto_larval *)q;
|
|
|
|
if (!strcmp(q->cra_driver_name, name))
|
|
goto found;
|
|
}
|
|
|
|
pr_err("alg: Unexpected test result for %s: %d\n", name, err);
|
|
goto unlock;
|
|
|
|
found:
|
|
q->cra_flags |= CRYPTO_ALG_DEAD;
|
|
alg = test->adult;
|
|
|
|
if (list_empty(&alg->cra_list))
|
|
goto complete;
|
|
|
|
if (err == -ECANCELED)
|
|
alg->cra_flags |= CRYPTO_ALG_FIPS_INTERNAL;
|
|
else if (err)
|
|
goto complete;
|
|
else
|
|
alg->cra_flags &= ~CRYPTO_ALG_FIPS_INTERNAL;
|
|
|
|
alg->cra_flags |= CRYPTO_ALG_TESTED;
|
|
|
|
/*
|
|
* If a higher-priority implementation of the same algorithm is
|
|
* currently being tested, then don't fulfill request larvals.
|
|
*/
|
|
best = true;
|
|
list_for_each_entry(q, &crypto_alg_list, cra_list) {
|
|
if (crypto_is_moribund(q) || !crypto_is_larval(q))
|
|
continue;
|
|
|
|
if (strcmp(alg->cra_name, q->cra_name))
|
|
continue;
|
|
|
|
if (q->cra_priority > alg->cra_priority) {
|
|
best = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
crypto_alg_finish_registration(alg, best, &list);
|
|
|
|
complete:
|
|
complete_all(&test->completion);
|
|
|
|
unlock:
|
|
up_write(&crypto_alg_sem);
|
|
|
|
crypto_remove_final(&list);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_alg_tested);
|
|
|
|
void crypto_remove_final(struct list_head *list)
|
|
{
|
|
struct crypto_alg *alg;
|
|
struct crypto_alg *n;
|
|
|
|
list_for_each_entry_safe(alg, n, list, cra_list) {
|
|
list_del_init(&alg->cra_list);
|
|
crypto_alg_put(alg);
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_remove_final);
|
|
|
|
int crypto_register_alg(struct crypto_alg *alg)
|
|
{
|
|
struct crypto_larval *larval;
|
|
LIST_HEAD(algs_to_put);
|
|
bool test_started = false;
|
|
int err;
|
|
|
|
alg->cra_flags &= ~CRYPTO_ALG_DEAD;
|
|
err = crypto_check_alg(alg);
|
|
if (err)
|
|
return err;
|
|
|
|
down_write(&crypto_alg_sem);
|
|
larval = __crypto_register_alg(alg, &algs_to_put);
|
|
if (!IS_ERR_OR_NULL(larval)) {
|
|
test_started = crypto_boot_test_finished();
|
|
larval->test_started = test_started;
|
|
}
|
|
up_write(&crypto_alg_sem);
|
|
|
|
if (IS_ERR(larval))
|
|
return PTR_ERR(larval);
|
|
if (test_started)
|
|
crypto_wait_for_test(larval);
|
|
crypto_remove_final(&algs_to_put);
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_register_alg);
|
|
|
|
static int crypto_remove_alg(struct crypto_alg *alg, struct list_head *list)
|
|
{
|
|
if (unlikely(list_empty(&alg->cra_list)))
|
|
return -ENOENT;
|
|
|
|
alg->cra_flags |= CRYPTO_ALG_DEAD;
|
|
|
|
list_del_init(&alg->cra_list);
|
|
crypto_remove_spawns(alg, list, NULL);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void crypto_unregister_alg(struct crypto_alg *alg)
|
|
{
|
|
int ret;
|
|
LIST_HEAD(list);
|
|
|
|
down_write(&crypto_alg_sem);
|
|
ret = crypto_remove_alg(alg, &list);
|
|
up_write(&crypto_alg_sem);
|
|
|
|
if (WARN(ret, "Algorithm %s is not registered", alg->cra_driver_name))
|
|
return;
|
|
|
|
if (WARN_ON(refcount_read(&alg->cra_refcnt) != 1))
|
|
return;
|
|
|
|
if (alg->cra_destroy)
|
|
alg->cra_destroy(alg);
|
|
|
|
crypto_remove_final(&list);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_unregister_alg);
|
|
|
|
int crypto_register_algs(struct crypto_alg *algs, int count)
|
|
{
|
|
int i, ret;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
ret = crypto_register_alg(&algs[i]);
|
|
if (ret)
|
|
goto err;
|
|
}
|
|
|
|
return 0;
|
|
|
|
err:
|
|
for (--i; i >= 0; --i)
|
|
crypto_unregister_alg(&algs[i]);
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_register_algs);
|
|
|
|
void crypto_unregister_algs(struct crypto_alg *algs, int count)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < count; i++)
|
|
crypto_unregister_alg(&algs[i]);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_unregister_algs);
|
|
|
|
int crypto_register_template(struct crypto_template *tmpl)
|
|
{
|
|
struct crypto_template *q;
|
|
int err = -EEXIST;
|
|
|
|
down_write(&crypto_alg_sem);
|
|
|
|
crypto_check_module_sig(tmpl->module);
|
|
|
|
list_for_each_entry(q, &crypto_template_list, list) {
|
|
if (q == tmpl)
|
|
goto out;
|
|
}
|
|
|
|
list_add(&tmpl->list, &crypto_template_list);
|
|
err = 0;
|
|
out:
|
|
up_write(&crypto_alg_sem);
|
|
return err;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_register_template);
|
|
|
|
int crypto_register_templates(struct crypto_template *tmpls, int count)
|
|
{
|
|
int i, err;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
err = crypto_register_template(&tmpls[i]);
|
|
if (err)
|
|
goto out;
|
|
}
|
|
return 0;
|
|
|
|
out:
|
|
for (--i; i >= 0; --i)
|
|
crypto_unregister_template(&tmpls[i]);
|
|
return err;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_register_templates);
|
|
|
|
void crypto_unregister_template(struct crypto_template *tmpl)
|
|
{
|
|
struct crypto_instance *inst;
|
|
struct hlist_node *n;
|
|
struct hlist_head *list;
|
|
LIST_HEAD(users);
|
|
|
|
down_write(&crypto_alg_sem);
|
|
|
|
BUG_ON(list_empty(&tmpl->list));
|
|
list_del_init(&tmpl->list);
|
|
|
|
list = &tmpl->instances;
|
|
hlist_for_each_entry(inst, list, list) {
|
|
int err = crypto_remove_alg(&inst->alg, &users);
|
|
|
|
BUG_ON(err);
|
|
}
|
|
|
|
up_write(&crypto_alg_sem);
|
|
|
|
hlist_for_each_entry_safe(inst, n, list, list) {
|
|
BUG_ON(refcount_read(&inst->alg.cra_refcnt) != 1);
|
|
crypto_free_instance(inst);
|
|
}
|
|
crypto_remove_final(&users);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_unregister_template);
|
|
|
|
void crypto_unregister_templates(struct crypto_template *tmpls, int count)
|
|
{
|
|
int i;
|
|
|
|
for (i = count - 1; i >= 0; --i)
|
|
crypto_unregister_template(&tmpls[i]);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_unregister_templates);
|
|
|
|
static struct crypto_template *__crypto_lookup_template(const char *name)
|
|
{
|
|
struct crypto_template *q, *tmpl = NULL;
|
|
|
|
down_read(&crypto_alg_sem);
|
|
list_for_each_entry(q, &crypto_template_list, list) {
|
|
if (strcmp(q->name, name))
|
|
continue;
|
|
if (unlikely(!crypto_tmpl_get(q)))
|
|
continue;
|
|
|
|
tmpl = q;
|
|
break;
|
|
}
|
|
up_read(&crypto_alg_sem);
|
|
|
|
return tmpl;
|
|
}
|
|
|
|
struct crypto_template *crypto_lookup_template(const char *name)
|
|
{
|
|
return try_then_request_module(__crypto_lookup_template(name),
|
|
"crypto-%s", name);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_lookup_template);
|
|
|
|
int crypto_register_instance(struct crypto_template *tmpl,
|
|
struct crypto_instance *inst)
|
|
{
|
|
struct crypto_larval *larval;
|
|
struct crypto_spawn *spawn;
|
|
u32 fips_internal = 0;
|
|
LIST_HEAD(algs_to_put);
|
|
int err;
|
|
|
|
err = crypto_check_alg(&inst->alg);
|
|
if (err)
|
|
return err;
|
|
|
|
inst->alg.cra_module = tmpl->module;
|
|
inst->alg.cra_flags |= CRYPTO_ALG_INSTANCE;
|
|
|
|
down_write(&crypto_alg_sem);
|
|
|
|
larval = ERR_PTR(-EAGAIN);
|
|
for (spawn = inst->spawns; spawn;) {
|
|
struct crypto_spawn *next;
|
|
|
|
if (spawn->dead)
|
|
goto unlock;
|
|
|
|
next = spawn->next;
|
|
spawn->inst = inst;
|
|
spawn->registered = true;
|
|
|
|
fips_internal |= spawn->alg->cra_flags;
|
|
|
|
crypto_mod_put(spawn->alg);
|
|
|
|
spawn = next;
|
|
}
|
|
|
|
inst->alg.cra_flags |= (fips_internal & CRYPTO_ALG_FIPS_INTERNAL);
|
|
|
|
larval = __crypto_register_alg(&inst->alg, &algs_to_put);
|
|
if (IS_ERR(larval))
|
|
goto unlock;
|
|
else if (larval)
|
|
larval->test_started = true;
|
|
|
|
hlist_add_head(&inst->list, &tmpl->instances);
|
|
inst->tmpl = tmpl;
|
|
|
|
unlock:
|
|
up_write(&crypto_alg_sem);
|
|
|
|
if (IS_ERR(larval))
|
|
return PTR_ERR(larval);
|
|
if (larval)
|
|
crypto_wait_for_test(larval);
|
|
crypto_remove_final(&algs_to_put);
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_register_instance);
|
|
|
|
void crypto_unregister_instance(struct crypto_instance *inst)
|
|
{
|
|
LIST_HEAD(list);
|
|
|
|
down_write(&crypto_alg_sem);
|
|
|
|
crypto_remove_spawns(&inst->alg, &list, NULL);
|
|
crypto_remove_instance(inst, &list);
|
|
|
|
up_write(&crypto_alg_sem);
|
|
|
|
crypto_remove_final(&list);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_unregister_instance);
|
|
|
|
int crypto_grab_spawn(struct crypto_spawn *spawn, struct crypto_instance *inst,
|
|
const char *name, u32 type, u32 mask)
|
|
{
|
|
struct crypto_alg *alg;
|
|
int err = -EAGAIN;
|
|
|
|
if (WARN_ON_ONCE(inst == NULL))
|
|
return -EINVAL;
|
|
|
|
/* Allow the result of crypto_attr_alg_name() to be passed directly */
|
|
if (IS_ERR(name))
|
|
return PTR_ERR(name);
|
|
|
|
alg = crypto_find_alg(name, spawn->frontend,
|
|
type | CRYPTO_ALG_FIPS_INTERNAL, mask);
|
|
if (IS_ERR(alg))
|
|
return PTR_ERR(alg);
|
|
|
|
down_write(&crypto_alg_sem);
|
|
if (!crypto_is_moribund(alg)) {
|
|
list_add(&spawn->list, &alg->cra_users);
|
|
spawn->alg = alg;
|
|
spawn->mask = mask;
|
|
spawn->next = inst->spawns;
|
|
inst->spawns = spawn;
|
|
inst->alg.cra_flags |=
|
|
(alg->cra_flags & CRYPTO_ALG_INHERITED_FLAGS);
|
|
err = 0;
|
|
}
|
|
up_write(&crypto_alg_sem);
|
|
if (err)
|
|
crypto_mod_put(alg);
|
|
return err;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_grab_spawn);
|
|
|
|
void crypto_drop_spawn(struct crypto_spawn *spawn)
|
|
{
|
|
if (!spawn->alg) /* not yet initialized? */
|
|
return;
|
|
|
|
down_write(&crypto_alg_sem);
|
|
if (!spawn->dead)
|
|
list_del(&spawn->list);
|
|
up_write(&crypto_alg_sem);
|
|
|
|
if (!spawn->registered)
|
|
crypto_mod_put(spawn->alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_drop_spawn);
|
|
|
|
static struct crypto_alg *crypto_spawn_alg(struct crypto_spawn *spawn)
|
|
{
|
|
struct crypto_alg *alg = ERR_PTR(-EAGAIN);
|
|
struct crypto_alg *target;
|
|
bool shoot = false;
|
|
|
|
down_read(&crypto_alg_sem);
|
|
if (!spawn->dead) {
|
|
alg = spawn->alg;
|
|
if (!crypto_mod_get(alg)) {
|
|
target = crypto_alg_get(alg);
|
|
shoot = true;
|
|
alg = ERR_PTR(-EAGAIN);
|
|
}
|
|
}
|
|
up_read(&crypto_alg_sem);
|
|
|
|
if (shoot) {
|
|
crypto_shoot_alg(target);
|
|
crypto_alg_put(target);
|
|
}
|
|
|
|
return alg;
|
|
}
|
|
|
|
struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
|
|
u32 mask)
|
|
{
|
|
struct crypto_alg *alg;
|
|
struct crypto_tfm *tfm;
|
|
|
|
alg = crypto_spawn_alg(spawn);
|
|
if (IS_ERR(alg))
|
|
return ERR_CAST(alg);
|
|
|
|
tfm = ERR_PTR(-EINVAL);
|
|
if (unlikely((alg->cra_flags ^ type) & mask))
|
|
goto out_put_alg;
|
|
|
|
tfm = __crypto_alloc_tfm(alg, type, mask);
|
|
if (IS_ERR(tfm))
|
|
goto out_put_alg;
|
|
|
|
return tfm;
|
|
|
|
out_put_alg:
|
|
crypto_mod_put(alg);
|
|
return tfm;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_spawn_tfm);
|
|
|
|
void *crypto_spawn_tfm2(struct crypto_spawn *spawn)
|
|
{
|
|
struct crypto_alg *alg;
|
|
struct crypto_tfm *tfm;
|
|
|
|
alg = crypto_spawn_alg(spawn);
|
|
if (IS_ERR(alg))
|
|
return ERR_CAST(alg);
|
|
|
|
tfm = crypto_create_tfm(alg, spawn->frontend);
|
|
if (IS_ERR(tfm))
|
|
goto out_put_alg;
|
|
|
|
return tfm;
|
|
|
|
out_put_alg:
|
|
crypto_mod_put(alg);
|
|
return tfm;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_spawn_tfm2);
|
|
|
|
int crypto_register_notifier(struct notifier_block *nb)
|
|
{
|
|
return blocking_notifier_chain_register(&crypto_chain, nb);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_register_notifier);
|
|
|
|
int crypto_unregister_notifier(struct notifier_block *nb)
|
|
{
|
|
return blocking_notifier_chain_unregister(&crypto_chain, nb);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_unregister_notifier);
|
|
|
|
struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb)
|
|
{
|
|
struct rtattr *rta = tb[0];
|
|
struct crypto_attr_type *algt;
|
|
|
|
if (!rta)
|
|
return ERR_PTR(-ENOENT);
|
|
if (RTA_PAYLOAD(rta) < sizeof(*algt))
|
|
return ERR_PTR(-EINVAL);
|
|
if (rta->rta_type != CRYPTOA_TYPE)
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
algt = RTA_DATA(rta);
|
|
|
|
return algt;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_get_attr_type);
|
|
|
|
/**
|
|
* crypto_check_attr_type() - check algorithm type and compute inherited mask
|
|
* @tb: the template parameters
|
|
* @type: the algorithm type the template would be instantiated as
|
|
* @mask_ret: (output) the mask that should be passed to crypto_grab_*()
|
|
* to restrict the flags of any inner algorithms
|
|
*
|
|
* Validate that the algorithm type the user requested is compatible with the
|
|
* one the template would actually be instantiated as. E.g., if the user is
|
|
* doing crypto_alloc_shash("cbc(aes)", ...), this would return an error because
|
|
* the "cbc" template creates an "skcipher" algorithm, not an "shash" algorithm.
|
|
*
|
|
* Also compute the mask to use to restrict the flags of any inner algorithms.
|
|
*
|
|
* Return: 0 on success; -errno on failure
|
|
*/
|
|
int crypto_check_attr_type(struct rtattr **tb, u32 type, u32 *mask_ret)
|
|
{
|
|
struct crypto_attr_type *algt;
|
|
|
|
algt = crypto_get_attr_type(tb);
|
|
if (IS_ERR(algt))
|
|
return PTR_ERR(algt);
|
|
|
|
if ((algt->type ^ type) & algt->mask)
|
|
return -EINVAL;
|
|
|
|
*mask_ret = crypto_algt_inherited_mask(algt);
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_check_attr_type);
|
|
|
|
const char *crypto_attr_alg_name(struct rtattr *rta)
|
|
{
|
|
struct crypto_attr_alg *alga;
|
|
|
|
if (!rta)
|
|
return ERR_PTR(-ENOENT);
|
|
if (RTA_PAYLOAD(rta) < sizeof(*alga))
|
|
return ERR_PTR(-EINVAL);
|
|
if (rta->rta_type != CRYPTOA_ALG)
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
alga = RTA_DATA(rta);
|
|
alga->name[CRYPTO_MAX_ALG_NAME - 1] = 0;
|
|
|
|
return alga->name;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_attr_alg_name);
|
|
|
|
int crypto_inst_setname(struct crypto_instance *inst, const char *name,
|
|
struct crypto_alg *alg)
|
|
{
|
|
if (snprintf(inst->alg.cra_name, CRYPTO_MAX_ALG_NAME, "%s(%s)", name,
|
|
alg->cra_name) >= CRYPTO_MAX_ALG_NAME)
|
|
return -ENAMETOOLONG;
|
|
|
|
if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s(%s)",
|
|
name, alg->cra_driver_name) >= CRYPTO_MAX_ALG_NAME)
|
|
return -ENAMETOOLONG;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_inst_setname);
|
|
|
|
void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen)
|
|
{
|
|
INIT_LIST_HEAD(&queue->list);
|
|
queue->backlog = &queue->list;
|
|
queue->qlen = 0;
|
|
queue->max_qlen = max_qlen;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_init_queue);
|
|
|
|
int crypto_enqueue_request(struct crypto_queue *queue,
|
|
struct crypto_async_request *request)
|
|
{
|
|
int err = -EINPROGRESS;
|
|
|
|
if (unlikely(queue->qlen >= queue->max_qlen)) {
|
|
if (!(request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) {
|
|
err = -ENOSPC;
|
|
goto out;
|
|
}
|
|
err = -EBUSY;
|
|
if (queue->backlog == &queue->list)
|
|
queue->backlog = &request->list;
|
|
}
|
|
|
|
queue->qlen++;
|
|
list_add_tail(&request->list, &queue->list);
|
|
|
|
out:
|
|
return err;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_enqueue_request);
|
|
|
|
void crypto_enqueue_request_head(struct crypto_queue *queue,
|
|
struct crypto_async_request *request)
|
|
{
|
|
queue->qlen++;
|
|
list_add(&request->list, &queue->list);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_enqueue_request_head);
|
|
|
|
struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue)
|
|
{
|
|
struct list_head *request;
|
|
|
|
if (unlikely(!queue->qlen))
|
|
return NULL;
|
|
|
|
queue->qlen--;
|
|
|
|
if (queue->backlog != &queue->list)
|
|
queue->backlog = queue->backlog->next;
|
|
|
|
request = queue->list.next;
|
|
list_del(request);
|
|
|
|
return list_entry(request, struct crypto_async_request, list);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_dequeue_request);
|
|
|
|
static inline void crypto_inc_byte(u8 *a, unsigned int size)
|
|
{
|
|
u8 *b = (a + size);
|
|
u8 c;
|
|
|
|
for (; size; size--) {
|
|
c = *--b + 1;
|
|
*b = c;
|
|
if (c)
|
|
break;
|
|
}
|
|
}
|
|
|
|
void crypto_inc(u8 *a, unsigned int size)
|
|
{
|
|
__be32 *b = (__be32 *)(a + size);
|
|
u32 c;
|
|
|
|
if (IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) ||
|
|
IS_ALIGNED((unsigned long)b, __alignof__(*b)))
|
|
for (; size >= 4; size -= 4) {
|
|
c = be32_to_cpu(*--b) + 1;
|
|
*b = cpu_to_be32(c);
|
|
if (likely(c))
|
|
return;
|
|
}
|
|
|
|
crypto_inc_byte(a, size);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_inc);
|
|
|
|
unsigned int crypto_alg_extsize(struct crypto_alg *alg)
|
|
{
|
|
return alg->cra_ctxsize +
|
|
(alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1));
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_alg_extsize);
|
|
|
|
int crypto_type_has_alg(const char *name, const struct crypto_type *frontend,
|
|
u32 type, u32 mask)
|
|
{
|
|
int ret = 0;
|
|
struct crypto_alg *alg = crypto_find_alg(name, frontend, type, mask);
|
|
|
|
if (!IS_ERR(alg)) {
|
|
crypto_mod_put(alg);
|
|
ret = 1;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_type_has_alg);
|
|
|
|
#ifdef CONFIG_CRYPTO_STATS
|
|
void crypto_stats_init(struct crypto_alg *alg)
|
|
{
|
|
memset(&alg->stats, 0, sizeof(alg->stats));
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_init);
|
|
|
|
void crypto_stats_get(struct crypto_alg *alg)
|
|
{
|
|
crypto_alg_get(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_get);
|
|
|
|
void crypto_stats_aead_encrypt(unsigned int cryptlen, struct crypto_alg *alg,
|
|
int ret)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
|
atomic64_inc(&alg->stats.aead.err_cnt);
|
|
} else {
|
|
atomic64_inc(&alg->stats.aead.encrypt_cnt);
|
|
atomic64_add(cryptlen, &alg->stats.aead.encrypt_tlen);
|
|
}
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_aead_encrypt);
|
|
|
|
void crypto_stats_aead_decrypt(unsigned int cryptlen, struct crypto_alg *alg,
|
|
int ret)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
|
atomic64_inc(&alg->stats.aead.err_cnt);
|
|
} else {
|
|
atomic64_inc(&alg->stats.aead.decrypt_cnt);
|
|
atomic64_add(cryptlen, &alg->stats.aead.decrypt_tlen);
|
|
}
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_aead_decrypt);
|
|
|
|
void crypto_stats_akcipher_encrypt(unsigned int src_len, int ret,
|
|
struct crypto_alg *alg)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
|
atomic64_inc(&alg->stats.akcipher.err_cnt);
|
|
} else {
|
|
atomic64_inc(&alg->stats.akcipher.encrypt_cnt);
|
|
atomic64_add(src_len, &alg->stats.akcipher.encrypt_tlen);
|
|
}
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_akcipher_encrypt);
|
|
|
|
void crypto_stats_akcipher_decrypt(unsigned int src_len, int ret,
|
|
struct crypto_alg *alg)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
|
atomic64_inc(&alg->stats.akcipher.err_cnt);
|
|
} else {
|
|
atomic64_inc(&alg->stats.akcipher.decrypt_cnt);
|
|
atomic64_add(src_len, &alg->stats.akcipher.decrypt_tlen);
|
|
}
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_akcipher_decrypt);
|
|
|
|
void crypto_stats_akcipher_sign(int ret, struct crypto_alg *alg)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY)
|
|
atomic64_inc(&alg->stats.akcipher.err_cnt);
|
|
else
|
|
atomic64_inc(&alg->stats.akcipher.sign_cnt);
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_akcipher_sign);
|
|
|
|
void crypto_stats_akcipher_verify(int ret, struct crypto_alg *alg)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY)
|
|
atomic64_inc(&alg->stats.akcipher.err_cnt);
|
|
else
|
|
atomic64_inc(&alg->stats.akcipher.verify_cnt);
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_akcipher_verify);
|
|
|
|
void crypto_stats_compress(unsigned int slen, int ret, struct crypto_alg *alg)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
|
atomic64_inc(&alg->stats.compress.err_cnt);
|
|
} else {
|
|
atomic64_inc(&alg->stats.compress.compress_cnt);
|
|
atomic64_add(slen, &alg->stats.compress.compress_tlen);
|
|
}
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_compress);
|
|
|
|
void crypto_stats_decompress(unsigned int slen, int ret, struct crypto_alg *alg)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
|
atomic64_inc(&alg->stats.compress.err_cnt);
|
|
} else {
|
|
atomic64_inc(&alg->stats.compress.decompress_cnt);
|
|
atomic64_add(slen, &alg->stats.compress.decompress_tlen);
|
|
}
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_decompress);
|
|
|
|
void crypto_stats_ahash_update(unsigned int nbytes, int ret,
|
|
struct crypto_alg *alg)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY)
|
|
atomic64_inc(&alg->stats.hash.err_cnt);
|
|
else
|
|
atomic64_add(nbytes, &alg->stats.hash.hash_tlen);
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_ahash_update);
|
|
|
|
void crypto_stats_ahash_final(unsigned int nbytes, int ret,
|
|
struct crypto_alg *alg)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
|
atomic64_inc(&alg->stats.hash.err_cnt);
|
|
} else {
|
|
atomic64_inc(&alg->stats.hash.hash_cnt);
|
|
atomic64_add(nbytes, &alg->stats.hash.hash_tlen);
|
|
}
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_ahash_final);
|
|
|
|
void crypto_stats_kpp_set_secret(struct crypto_alg *alg, int ret)
|
|
{
|
|
if (ret)
|
|
atomic64_inc(&alg->stats.kpp.err_cnt);
|
|
else
|
|
atomic64_inc(&alg->stats.kpp.setsecret_cnt);
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_kpp_set_secret);
|
|
|
|
void crypto_stats_kpp_generate_public_key(struct crypto_alg *alg, int ret)
|
|
{
|
|
if (ret)
|
|
atomic64_inc(&alg->stats.kpp.err_cnt);
|
|
else
|
|
atomic64_inc(&alg->stats.kpp.generate_public_key_cnt);
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_kpp_generate_public_key);
|
|
|
|
void crypto_stats_kpp_compute_shared_secret(struct crypto_alg *alg, int ret)
|
|
{
|
|
if (ret)
|
|
atomic64_inc(&alg->stats.kpp.err_cnt);
|
|
else
|
|
atomic64_inc(&alg->stats.kpp.compute_shared_secret_cnt);
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_kpp_compute_shared_secret);
|
|
|
|
void crypto_stats_rng_seed(struct crypto_alg *alg, int ret)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY)
|
|
atomic64_inc(&alg->stats.rng.err_cnt);
|
|
else
|
|
atomic64_inc(&alg->stats.rng.seed_cnt);
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_rng_seed);
|
|
|
|
void crypto_stats_rng_generate(struct crypto_alg *alg, unsigned int dlen,
|
|
int ret)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
|
atomic64_inc(&alg->stats.rng.err_cnt);
|
|
} else {
|
|
atomic64_inc(&alg->stats.rng.generate_cnt);
|
|
atomic64_add(dlen, &alg->stats.rng.generate_tlen);
|
|
}
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_rng_generate);
|
|
|
|
void crypto_stats_skcipher_encrypt(unsigned int cryptlen, int ret,
|
|
struct crypto_alg *alg)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
|
atomic64_inc(&alg->stats.cipher.err_cnt);
|
|
} else {
|
|
atomic64_inc(&alg->stats.cipher.encrypt_cnt);
|
|
atomic64_add(cryptlen, &alg->stats.cipher.encrypt_tlen);
|
|
}
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_skcipher_encrypt);
|
|
|
|
void crypto_stats_skcipher_decrypt(unsigned int cryptlen, int ret,
|
|
struct crypto_alg *alg)
|
|
{
|
|
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
|
atomic64_inc(&alg->stats.cipher.err_cnt);
|
|
} else {
|
|
atomic64_inc(&alg->stats.cipher.decrypt_cnt);
|
|
atomic64_add(cryptlen, &alg->stats.cipher.decrypt_tlen);
|
|
}
|
|
crypto_alg_put(alg);
|
|
}
|
|
EXPORT_SYMBOL_GPL(crypto_stats_skcipher_decrypt);
|
|
#endif
|
|
|
|
static void __init crypto_start_tests(void)
|
|
{
|
|
if (IS_ENABLED(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS))
|
|
return;
|
|
|
|
for (;;) {
|
|
struct crypto_larval *larval = NULL;
|
|
struct crypto_alg *q;
|
|
|
|
down_write(&crypto_alg_sem);
|
|
|
|
list_for_each_entry(q, &crypto_alg_list, cra_list) {
|
|
struct crypto_larval *l;
|
|
|
|
if (!crypto_is_larval(q))
|
|
continue;
|
|
|
|
l = (void *)q;
|
|
|
|
if (!crypto_is_test_larval(l))
|
|
continue;
|
|
|
|
if (l->test_started)
|
|
continue;
|
|
|
|
l->test_started = true;
|
|
larval = l;
|
|
break;
|
|
}
|
|
|
|
up_write(&crypto_alg_sem);
|
|
|
|
if (!larval)
|
|
break;
|
|
|
|
crypto_wait_for_test(larval);
|
|
}
|
|
|
|
set_crypto_boot_test_finished();
|
|
}
|
|
|
|
static int __init crypto_algapi_init(void)
|
|
{
|
|
crypto_init_proc();
|
|
crypto_start_tests();
|
|
return 0;
|
|
}
|
|
|
|
static void __exit crypto_algapi_exit(void)
|
|
{
|
|
crypto_exit_proc();
|
|
}
|
|
|
|
/*
|
|
* We run this at late_initcall so that all the built-in algorithms
|
|
* have had a chance to register themselves first.
|
|
*/
|
|
late_initcall(crypto_algapi_init);
|
|
module_exit(crypto_algapi_exit);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_DESCRIPTION("Cryptographic algorithms API");
|
|
MODULE_SOFTDEP("pre: cryptomgr");
|